diff --git a/Source/Core/Common/Src/PluginPAD.h b/Source/Core/Common/Src/PluginPAD.h
index 8197481faa..755c581011 100644
--- a/Source/Core/Common/Src/PluginPAD.h
+++ b/Source/Core/Common/Src/PluginPAD.h
@@ -6,7 +6,7 @@
namespace Common {
typedef void (__cdecl* TPAD_GetStatus)(u8, SPADStatus*);
- typedef void (__cdecl* TPAD_Input)(u8, u8);
+ typedef void (__cdecl* TPAD_Input)(u16, u8);
typedef void (__cdecl* TPAD_Rumble)(u8, unsigned int, unsigned int);
typedef unsigned int (__cdecl* TPAD_GetAttachedPads)();
diff --git a/Source/MusicMod.sln b/Source/MusicMod.sln
index b1ba572b28..f1579fa39a 100644
--- a/Source/MusicMod.sln
+++ b/Source/MusicMod.sln
@@ -6,6 +6,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Core", "Core\Core\Core.vcpr
{C7E5D50A-2916-464B-86A7-E10B3CC88ADA} = {C7E5D50A-2916-464B-86A7-E10B3CC88ADA}
{0318BA30-EF48-441A-9E10-DC85EFAE39F0} = {0318BA30-EF48-441A-9E10-DC85EFAE39F0}
{71B16F46-0B00-4EDA-B253-D6D9D03A215C} = {71B16F46-0B00-4EDA-B253-D6D9D03A215C}
+ {95CCAABC-7062-47C4-B8C1-A064DD5F16FF} = {95CCAABC-7062-47C4-B8C1-A064DD5F16FF}
{29C2ABC1-ADA5-42CD-A5FC-96022D52A510} = {29C2ABC1-ADA5-42CD-A5FC-96022D52A510}
{C573CAF7-EE6A-458E-8049-16C0BF34C2E9} = {C573CAF7-EE6A-458E-8049-16C0BF34C2E9}
{B7F1A9FB-BEA8-416E-9460-AE35A6A5165C} = {B7F1A9FB-BEA8-416E-9460-AE35A6A5165C}
@@ -37,6 +38,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Plugin_DSP_LLE", "Plugins\P
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DiscIO", "Core\DiscIO\DiscIO.vcproj", "{B7F1A9FB-BEA8-416E-9460-AE35A6A5165C}"
ProjectSection(ProjectDependencies) = postProject
+ {95CCAABC-7062-47C4-B8C1-A064DD5F16FF} = {95CCAABC-7062-47C4-B8C1-A064DD5F16FF}
{C573CAF7-EE6A-458E-8049-16C0BF34C2E9} = {C573CAF7-EE6A-458E-8049-16C0BF34C2E9}
EndProjectSection
EndProject
@@ -63,7 +65,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DolphinWX", "Core\DolphinWX
{29C2ABC1-ADA5-42CD-A5FC-96022D52A510} = {29C2ABC1-ADA5-42CD-A5FC-96022D52A510}
{4D3CD4C5-412B-4B49-9B1B-A68A2A129C77} = {4D3CD4C5-412B-4B49-9B1B-A68A2A129C77}
{F0B874CB-4476-4199-9315-8343D05AE684} = {F0B874CB-4476-4199-9315-8343D05AE684}
- {0B72B5D6-5D72-4391-84A7-9CCA5392668A} = {0B72B5D6-5D72-4391-84A7-9CCA5392668A}
{B7F1A9FB-BEA8-416E-9460-AE35A6A5165C} = {B7F1A9FB-BEA8-416E-9460-AE35A6A5165C}
EndProjectSection
EndProject
@@ -133,29 +134,20 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Plugins", "Plugins", "{5C17
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Externals", "Externals", "{4F427D1B-8C90-4D9C-B23D-A51493A1C471}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Player", "..\Branches\MusicMod\Player\Player.vcproj", "{0B72B5D6-5D72-4391-84A7-9CCA5392668A}"
- ProjectSection(ProjectDependencies) = postProject
- {C573CAF7-EE6A-458E-8049-16C0BF34C2E9} = {C573CAF7-EE6A-458E-8049-16C0BF34C2E9}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestPlayer", "..\Branches\MusicMod\TestPlayer\TestPlayer.vcproj", "{0D14F1E9-490B-4A2D-A4EF-0535E8B3C718}"
- ProjectSection(ProjectDependencies) = postProject
- {0B72B5D6-5D72-4391-84A7-9CCA5392668A} = {0B72B5D6-5D72-4391-84A7-9CCA5392668A}
- EndProjectSection
-EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Dolphin", "Dolphin", "{61C7F431-0623-4A8D-9C4B-EDE35696554A}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InputCommon", "Core\InputCommon\InputCommon.vcproj", "{C7E5D50A-2916-464B-86A7-E10B3CC88ADA}"
+EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Common", "..\Branches\MusicMod\Common\Common.vcproj", "{DE7C596C-CBC4-4278-8909-146D63990803}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Main", "..\Branches\MusicMod\Main\Main.vcproj", "{95CCAABC-7062-47C4-B8C1-A064DD5F16FF}"
ProjectSection(ProjectDependencies) = postProject
- {CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160} = {CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160}
{0B72B5D6-5D72-4391-84A7-9CCA5392668A} = {0B72B5D6-5D72-4391-84A7-9CCA5392668A}
EndProjectSection
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InputCommon", "Core\InputCommon\InputCommon.vcproj", "{C7E5D50A-2916-464B-86A7-E10B3CC88ADA}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Player", "..\Branches\MusicMod\Player\Player.vcproj", "{0B72B5D6-5D72-4391-84A7-9CCA5392668A}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL", "..\Externals\SDL\SDL\SDL.vcproj", "{B6C1A81F-99A5-42F5-8C31-E86A6AEF4DCA}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestPlayer", "..\Branches\MusicMod\TestPlayer\TestPlayer.vcproj", "{0D14F1E9-490B-4A2D-A4EF-0535E8B3C718}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -357,48 +349,6 @@ Global
{521498BE-6089-4780-8223-E67C22F4E068}.Release|Win32.Build.0 = Release|Win32
{521498BE-6089-4780-8223-E67C22F4E068}.Release|x64.ActiveCfg = Release|x64
{521498BE-6089-4780-8223-E67C22F4E068}.Release|x64.Build.0 = Release|x64
- {0B72B5D6-5D72-4391-84A7-9CCA5392668A}.Debug|Win32.ActiveCfg = Debug|Win32
- {0B72B5D6-5D72-4391-84A7-9CCA5392668A}.Debug|Win32.Build.0 = Debug|Win32
- {0B72B5D6-5D72-4391-84A7-9CCA5392668A}.Debug|x64.ActiveCfg = Debug|x64
- {0B72B5D6-5D72-4391-84A7-9CCA5392668A}.Debug|x64.Build.0 = Debug|x64
- {0B72B5D6-5D72-4391-84A7-9CCA5392668A}.DebugFast|Win32.ActiveCfg = DebugFast|Win32
- {0B72B5D6-5D72-4391-84A7-9CCA5392668A}.DebugFast|Win32.Build.0 = DebugFast|Win32
- {0B72B5D6-5D72-4391-84A7-9CCA5392668A}.DebugFast|x64.ActiveCfg = Debug|x64
- {0B72B5D6-5D72-4391-84A7-9CCA5392668A}.DebugFast|x64.Build.0 = Debug|x64
- {0B72B5D6-5D72-4391-84A7-9CCA5392668A}.Release|Win32.ActiveCfg = Release|Win32
- {0B72B5D6-5D72-4391-84A7-9CCA5392668A}.Release|Win32.Build.0 = Release|Win32
- {0B72B5D6-5D72-4391-84A7-9CCA5392668A}.Release|x64.ActiveCfg = Release|x64
- {0B72B5D6-5D72-4391-84A7-9CCA5392668A}.Release|x64.Build.0 = Release|x64
- {0D14F1E9-490B-4A2D-A4EF-0535E8B3C718}.Debug|Win32.ActiveCfg = Debug|Win32
- {0D14F1E9-490B-4A2D-A4EF-0535E8B3C718}.Debug|Win32.Build.0 = Debug|Win32
- {0D14F1E9-490B-4A2D-A4EF-0535E8B3C718}.Debug|x64.ActiveCfg = Debug|x64
- {0D14F1E9-490B-4A2D-A4EF-0535E8B3C718}.Debug|x64.Build.0 = Debug|x64
- {0D14F1E9-490B-4A2D-A4EF-0535E8B3C718}.DebugFast|Win32.ActiveCfg = DebugFast|Win32
- {0D14F1E9-490B-4A2D-A4EF-0535E8B3C718}.DebugFast|x64.ActiveCfg = Debug|x64
- {0D14F1E9-490B-4A2D-A4EF-0535E8B3C718}.DebugFast|x64.Build.0 = Debug|x64
- {0D14F1E9-490B-4A2D-A4EF-0535E8B3C718}.Release|Win32.ActiveCfg = Release|Win32
- {0D14F1E9-490B-4A2D-A4EF-0535E8B3C718}.Release|x64.ActiveCfg = Release|x64
- {0D14F1E9-490B-4A2D-A4EF-0535E8B3C718}.Release|x64.Build.0 = Release|x64
- {DE7C596C-CBC4-4278-8909-146D63990803}.Debug|Win32.ActiveCfg = Debug|Win32
- {DE7C596C-CBC4-4278-8909-146D63990803}.Debug|Win32.Build.0 = Debug|Win32
- {DE7C596C-CBC4-4278-8909-146D63990803}.Debug|x64.ActiveCfg = Debug|Win32
- {DE7C596C-CBC4-4278-8909-146D63990803}.DebugFast|Win32.ActiveCfg = DebugFast|Win32
- {DE7C596C-CBC4-4278-8909-146D63990803}.DebugFast|Win32.Build.0 = DebugFast|Win32
- {DE7C596C-CBC4-4278-8909-146D63990803}.DebugFast|x64.ActiveCfg = Debug|Win32
- {DE7C596C-CBC4-4278-8909-146D63990803}.Release|Win32.ActiveCfg = Release|Win32
- {DE7C596C-CBC4-4278-8909-146D63990803}.Release|Win32.Build.0 = Release|Win32
- {DE7C596C-CBC4-4278-8909-146D63990803}.Release|x64.ActiveCfg = Release|x64
- {DE7C596C-CBC4-4278-8909-146D63990803}.Release|x64.Build.0 = Release|x64
- {95CCAABC-7062-47C4-B8C1-A064DD5F16FF}.Debug|Win32.ActiveCfg = Debug|Win32
- {95CCAABC-7062-47C4-B8C1-A064DD5F16FF}.Debug|Win32.Build.0 = Debug|Win32
- {95CCAABC-7062-47C4-B8C1-A064DD5F16FF}.Debug|x64.ActiveCfg = Debug|Win32
- {95CCAABC-7062-47C4-B8C1-A064DD5F16FF}.DebugFast|Win32.ActiveCfg = DebugFast|Win32
- {95CCAABC-7062-47C4-B8C1-A064DD5F16FF}.DebugFast|Win32.Build.0 = DebugFast|Win32
- {95CCAABC-7062-47C4-B8C1-A064DD5F16FF}.DebugFast|x64.ActiveCfg = Debug|Win32
- {95CCAABC-7062-47C4-B8C1-A064DD5F16FF}.Release|Win32.ActiveCfg = Release|Win32
- {95CCAABC-7062-47C4-B8C1-A064DD5F16FF}.Release|Win32.Build.0 = Release|Win32
- {95CCAABC-7062-47C4-B8C1-A064DD5F16FF}.Release|x64.ActiveCfg = Release|x64
- {95CCAABC-7062-47C4-B8C1-A064DD5F16FF}.Release|x64.Build.0 = Release|x64
{C7E5D50A-2916-464B-86A7-E10B3CC88ADA}.Debug|Win32.ActiveCfg = Debug|Win32
{C7E5D50A-2916-464B-86A7-E10B3CC88ADA}.Debug|Win32.Build.0 = Debug|Win32
{C7E5D50A-2916-464B-86A7-E10B3CC88ADA}.Debug|x64.ActiveCfg = Debug|x64
@@ -411,15 +361,54 @@ Global
{C7E5D50A-2916-464B-86A7-E10B3CC88ADA}.Release|Win32.Build.0 = Release|Win32
{C7E5D50A-2916-464B-86A7-E10B3CC88ADA}.Release|x64.ActiveCfg = Release|x64
{C7E5D50A-2916-464B-86A7-E10B3CC88ADA}.Release|x64.Build.0 = Release|x64
- {B6C1A81F-99A5-42F5-8C31-E86A6AEF4DCA}.Debug|Win32.ActiveCfg = Debug|Win32
- {B6C1A81F-99A5-42F5-8C31-E86A6AEF4DCA}.Debug|Win32.Build.0 = Debug|Win32
- {B6C1A81F-99A5-42F5-8C31-E86A6AEF4DCA}.Debug|x64.ActiveCfg = Debug|Win32
- {B6C1A81F-99A5-42F5-8C31-E86A6AEF4DCA}.DebugFast|Win32.ActiveCfg = Debug|Win32
- {B6C1A81F-99A5-42F5-8C31-E86A6AEF4DCA}.DebugFast|Win32.Build.0 = Debug|Win32
- {B6C1A81F-99A5-42F5-8C31-E86A6AEF4DCA}.DebugFast|x64.ActiveCfg = Debug|Win32
- {B6C1A81F-99A5-42F5-8C31-E86A6AEF4DCA}.Release|Win32.ActiveCfg = Release|Win32
- {B6C1A81F-99A5-42F5-8C31-E86A6AEF4DCA}.Release|Win32.Build.0 = Release|Win32
- {B6C1A81F-99A5-42F5-8C31-E86A6AEF4DCA}.Release|x64.ActiveCfg = Release|Win32
+ {DE7C596C-CBC4-4278-8909-146D63990803}.Debug|Win32.ActiveCfg = Debug|Win32
+ {DE7C596C-CBC4-4278-8909-146D63990803}.Debug|Win32.Build.0 = Debug|Win32
+ {DE7C596C-CBC4-4278-8909-146D63990803}.Debug|x64.ActiveCfg = Debug|x64
+ {DE7C596C-CBC4-4278-8909-146D63990803}.Debug|x64.Build.0 = Debug|x64
+ {DE7C596C-CBC4-4278-8909-146D63990803}.DebugFast|Win32.ActiveCfg = DebugFast|Win32
+ {DE7C596C-CBC4-4278-8909-146D63990803}.DebugFast|Win32.Build.0 = DebugFast|Win32
+ {DE7C596C-CBC4-4278-8909-146D63990803}.DebugFast|x64.ActiveCfg = DebugFast|x64
+ {DE7C596C-CBC4-4278-8909-146D63990803}.DebugFast|x64.Build.0 = DebugFast|x64
+ {DE7C596C-CBC4-4278-8909-146D63990803}.Release|Win32.ActiveCfg = Release|Win32
+ {DE7C596C-CBC4-4278-8909-146D63990803}.Release|Win32.Build.0 = Release|Win32
+ {DE7C596C-CBC4-4278-8909-146D63990803}.Release|x64.ActiveCfg = Release|x64
+ {DE7C596C-CBC4-4278-8909-146D63990803}.Release|x64.Build.0 = Release|x64
+ {95CCAABC-7062-47C4-B8C1-A064DD5F16FF}.Debug|Win32.ActiveCfg = Debug|Win32
+ {95CCAABC-7062-47C4-B8C1-A064DD5F16FF}.Debug|Win32.Build.0 = Debug|Win32
+ {95CCAABC-7062-47C4-B8C1-A064DD5F16FF}.Debug|x64.ActiveCfg = Debug|x64
+ {95CCAABC-7062-47C4-B8C1-A064DD5F16FF}.Debug|x64.Build.0 = Debug|x64
+ {95CCAABC-7062-47C4-B8C1-A064DD5F16FF}.DebugFast|Win32.ActiveCfg = DebugFast|Win32
+ {95CCAABC-7062-47C4-B8C1-A064DD5F16FF}.DebugFast|Win32.Build.0 = DebugFast|Win32
+ {95CCAABC-7062-47C4-B8C1-A064DD5F16FF}.DebugFast|x64.ActiveCfg = DebugFast|x64
+ {95CCAABC-7062-47C4-B8C1-A064DD5F16FF}.DebugFast|x64.Build.0 = DebugFast|x64
+ {95CCAABC-7062-47C4-B8C1-A064DD5F16FF}.Release|Win32.ActiveCfg = Release|Win32
+ {95CCAABC-7062-47C4-B8C1-A064DD5F16FF}.Release|Win32.Build.0 = Release|Win32
+ {95CCAABC-7062-47C4-B8C1-A064DD5F16FF}.Release|x64.ActiveCfg = Release|x64
+ {95CCAABC-7062-47C4-B8C1-A064DD5F16FF}.Release|x64.Build.0 = Release|x64
+ {0B72B5D6-5D72-4391-84A7-9CCA5392668A}.Debug|Win32.ActiveCfg = Debug|Win32
+ {0B72B5D6-5D72-4391-84A7-9CCA5392668A}.Debug|Win32.Build.0 = Debug|Win32
+ {0B72B5D6-5D72-4391-84A7-9CCA5392668A}.Debug|x64.ActiveCfg = Debug|x64
+ {0B72B5D6-5D72-4391-84A7-9CCA5392668A}.Debug|x64.Build.0 = Debug|x64
+ {0B72B5D6-5D72-4391-84A7-9CCA5392668A}.DebugFast|Win32.ActiveCfg = DebugFast|Win32
+ {0B72B5D6-5D72-4391-84A7-9CCA5392668A}.DebugFast|Win32.Build.0 = DebugFast|Win32
+ {0B72B5D6-5D72-4391-84A7-9CCA5392668A}.DebugFast|x64.ActiveCfg = DebugFast|x64
+ {0B72B5D6-5D72-4391-84A7-9CCA5392668A}.DebugFast|x64.Build.0 = DebugFast|x64
+ {0B72B5D6-5D72-4391-84A7-9CCA5392668A}.Release|Win32.ActiveCfg = Release|Win32
+ {0B72B5D6-5D72-4391-84A7-9CCA5392668A}.Release|Win32.Build.0 = Release|Win32
+ {0B72B5D6-5D72-4391-84A7-9CCA5392668A}.Release|x64.ActiveCfg = Release|x64
+ {0B72B5D6-5D72-4391-84A7-9CCA5392668A}.Release|x64.Build.0 = Release|x64
+ {0D14F1E9-490B-4A2D-A4EF-0535E8B3C718}.Debug|Win32.ActiveCfg = Debug|Win32
+ {0D14F1E9-490B-4A2D-A4EF-0535E8B3C718}.Debug|Win32.Build.0 = Debug|Win32
+ {0D14F1E9-490B-4A2D-A4EF-0535E8B3C718}.Debug|x64.ActiveCfg = Debug|x64
+ {0D14F1E9-490B-4A2D-A4EF-0535E8B3C718}.Debug|x64.Build.0 = Debug|x64
+ {0D14F1E9-490B-4A2D-A4EF-0535E8B3C718}.DebugFast|Win32.ActiveCfg = DebugFast|Win32
+ {0D14F1E9-490B-4A2D-A4EF-0535E8B3C718}.DebugFast|Win32.Build.0 = DebugFast|Win32
+ {0D14F1E9-490B-4A2D-A4EF-0535E8B3C718}.DebugFast|x64.ActiveCfg = DebugFast|x64
+ {0D14F1E9-490B-4A2D-A4EF-0535E8B3C718}.DebugFast|x64.Build.0 = DebugFast|x64
+ {0D14F1E9-490B-4A2D-A4EF-0535E8B3C718}.Release|Win32.ActiveCfg = Release|Win32
+ {0D14F1E9-490B-4A2D-A4EF-0535E8B3C718}.Release|Win32.Build.0 = Release|Win32
+ {0D14F1E9-490B-4A2D-A4EF-0535E8B3C718}.Release|x64.ActiveCfg = Release|x64
+ {0D14F1E9-490B-4A2D-A4EF-0535E8B3C718}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -447,11 +436,10 @@ Global
{33546D62-7F34-4EA6-A88E-D538B36E16BF} = {4F427D1B-8C90-4D9C-B23D-A51493A1C471}
{71B16F46-0B00-4EDA-B253-D6D9D03A215C} = {4F427D1B-8C90-4D9C-B23D-A51493A1C471}
{29C2ABC1-ADA5-42CD-A5FC-96022D52A510} = {4F427D1B-8C90-4D9C-B23D-A51493A1C471}
- {B6C1A81F-99A5-42F5-8C31-E86A6AEF4DCA} = {4F427D1B-8C90-4D9C-B23D-A51493A1C471}
- {0B72B5D6-5D72-4391-84A7-9CCA5392668A} = {77CF6E34-3038-4B23-A2E7-90AD17801609}
- {0D14F1E9-490B-4A2D-A4EF-0535E8B3C718} = {77CF6E34-3038-4B23-A2E7-90AD17801609}
{DE7C596C-CBC4-4278-8909-146D63990803} = {77CF6E34-3038-4B23-A2E7-90AD17801609}
{95CCAABC-7062-47C4-B8C1-A064DD5F16FF} = {77CF6E34-3038-4B23-A2E7-90AD17801609}
+ {0B72B5D6-5D72-4391-84A7-9CCA5392668A} = {77CF6E34-3038-4B23-A2E7-90AD17801609}
+ {0D14F1E9-490B-4A2D-A4EF-0535E8B3C718} = {77CF6E34-3038-4B23-A2E7-90AD17801609}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
AMDCaProjectFile = D:\Dev\Dolphin\trunk\Source\CodeAnalyst\Dolphin.caw
diff --git a/Source/PluginSpecs/pluginspecs_pad.h b/Source/PluginSpecs/pluginspecs_pad.h
index b901e670f4..aa1b8e4a2f 100644
--- a/Source/PluginSpecs/pluginspecs_pad.h
+++ b/Source/PluginSpecs/pluginspecs_pad.h
@@ -70,7 +70,7 @@ EXPORT void CALL PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus);
// input: The key and if it's pressed or released
// output: None
//
-EXPORT void CALL PAD_Input(u8 _Key, u8 _UpDown);
+EXPORT void CALL PAD_Input(u16 _Key, u8 _UpDown);
// __________________________________________________________________________________________________
// Function: PAD_Rumble
diff --git a/Source/Plugins/Plugin_PadSimple/Src/PadSimple.cpp b/Source/Plugins/Plugin_PadSimple/Src/PadSimple.cpp
index 4b2be37006..2af537e56f 100644
--- a/Source/Plugins/Plugin_PadSimple/Src/PadSimple.cpp
+++ b/Source/Plugins/Plugin_PadSimple/Src/PadSimple.cpp
@@ -590,7 +590,7 @@ void cocoa_Read(int _numPAD, SPADStatus* _pPADStatus)
#endif
// Set buttons status from wxWidgets in the main application
// ŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
-void PAD_Input(u8 _Key, u8 _UpDown) {}
+void PAD_Input(u16 _Key, u8 _UpDown) {}
void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
diff --git a/Source/Plugins/Plugin_nJoy_SDL/Plugin_nJoy_SDL.vcproj b/Source/Plugins/Plugin_nJoy_SDL/Plugin_nJoy_SDL.vcproj
index a57536e7d8..30fd33df90 100644
--- a/Source/Plugins/Plugin_nJoy_SDL/Plugin_nJoy_SDL.vcproj
+++ b/Source/Plugins/Plugin_nJoy_SDL/Plugin_nJoy_SDL.vcproj
@@ -506,10 +506,6 @@
RelativePath=".\Src\Config.cpp"
>
-
-
@@ -534,6 +530,10 @@
RelativePath=".\Src\GUI\AboutBox.h"
>
+
+
diff --git a/Source/Plugins/Plugin_nJoy_SDL/Src/Config.cpp b/Source/Plugins/Plugin_nJoy_SDL/Src/Config.cpp
index fe7dc9bf2e..3676b44e2d 100644
--- a/Source/Plugins/Plugin_nJoy_SDL/Src/Config.cpp
+++ b/Source/Plugins/Plugin_nJoy_SDL/Src/Config.cpp
@@ -220,7 +220,7 @@ void Config::Save(bool CheckedForDuplicates)
file.Set(SectionName.c_str(), "deadzone", joysticks[i].deadzone);
file.Set(SectionName.c_str(), "halfpress", joysticks[i].halfpress);
- //file.Set(SectionName.c_str(), "controllertype", joysticks[i].controllertype);
+ file.Set(SectionName.c_str(), "controllertype", joysticks[i].controllertype);
file.Set(SectionName.c_str(), "eventnum", joysticks[i].eventnum);
file.Set(SectionName.c_str(), "Diagonal", g_Config.SDiagonal);
@@ -293,7 +293,7 @@ void Config::Load(bool config)
file.Get(SectionName.c_str(), "sub_y", &joysticks[i].axis[CTL_SUB_Y], 3);
file.Get(SectionName.c_str(), "deadzone", &joysticks[i].deadzone, 9);
file.Get(SectionName.c_str(), "halfpress", &joysticks[i].halfpress, 6);
- //file.Get(SectionName.c_str(), "controllertype", &joysticks[i].controllertype, 0);
+ file.Get(SectionName.c_str(), "controllertype", &joysticks[i].controllertype, 0);
file.Get(SectionName.c_str(), "eventnum", &joysticks[i].eventnum, 0);
file.Get(SectionName.c_str(), "Diagonal", &g_Config.SDiagonal, "100%");
diff --git a/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigAdvanced.cpp b/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigAdvanced.cpp
index 2a8e9dc730..8686c1b9e2 100644
--- a/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigAdvanced.cpp
+++ b/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigAdvanced.cpp
@@ -130,28 +130,36 @@ void ConfigBox::PadGetStatus()
// Show the current pad status
// ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
-std::string ShowStatus()
+std::string ShowStatus(int Controller)
{
- SDL_Joystick *joy = SDL_JoystickOpen(0);
- int axes = SDL_JoystickNumAxes(joy);
- int hats = SDL_JoystickNumHats(joy);
- int but = SDL_JoystickNumButtons(joy);
+ // Make local shortcut
+ SDL_Joystick *joy = joystate[joysticks[Controller].ID].joy;
+
+ // Temporary storage
std::string StrAxes, StrHats, StrBut;
int value;
- // Go through all axes and read out their values
+ // Get status
+ int Axes = joyinfo[joysticks[Controller].ID].NumAxes;
+ int Balls = joyinfo[joysticks[Controller].ID].NumBalls;
+ int Hats = joyinfo[joysticks[Controller].ID].NumHats;
+ int Buttons = joyinfo[joysticks[Controller].ID].NumButtons;
+
+ // Update the internal values
SDL_JoystickUpdate();
- for(int i = 0; i < axes; i++)
+
+ // Go through all axes and read out their values
+ for(int i = 0; i < Axes; i++)
{
value = SDL_JoystickGetAxis(joy, i);
StrAxes += StringFromFormat(" %i:%05i", i, value);
}
- for(int i = 0;i < hats; i++)
+ for(int i = 0;i < Hats; i++)
{
value = SDL_JoystickGetHat(joy, i);
StrHats += StringFromFormat(" %i:%i", i, value);
}
- for(int i = 0;i < but; i++)
+ for(int i = 0;i < Buttons; i++)
{
value = SDL_JoystickGetButton(joy, i);
StrBut += StringFromFormat(" %i:%i", i+1, value);
@@ -159,9 +167,8 @@ std::string ShowStatus()
return StringFromFormat(
"Axes: %s\nHats: %s\nBut: %s\nDevice: Ax: %i Balls:%i But:%i Hats:%i",
- StrAxes.c_str(), StrHats.c_str(), StrBut.c_str(),
- joyinfo[joysticks[0].ID].NumAxes, joyinfo[joysticks[0].ID].NumBalls,
- joyinfo[joysticks[0].ID].NumButtons, joyinfo[joysticks[0].ID].NumHats
+ StrAxes.c_str(), StrHats.c_str(), StrBut.c_str(),
+ Axes, Balls, Hats, Buttons
);
}
@@ -173,10 +180,10 @@ void ConfigBox::Update()
if(!g_Config.bShowAdvanced) StrangeHack = false; else StrangeHack = true;
// Show the current status
- /**/
+ /*
m_pStatusBar->SetLabel(wxString::Format(
- "%s", ShowStatus().c_str()
- ));
+ "%s", ShowStatus(notebookpage).c_str()
+ ));*/
}
diff --git a/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.cpp b/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.cpp
index a974cdb934..05a6a11221 100644
--- a/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.cpp
+++ b/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.cpp
@@ -43,12 +43,10 @@ extern CONTROLLER_INFO *joyinfo;
//extern CONTROLLER_MAPPING joysticks[4];
extern bool emulator_running;
-static const char* ControllerType[] =
+static const char* DPadType[] =
{
- "Joystick (with hat)",
- "Joystick (no hat)",
-// "Joytstick (xbox360)", // Shoulder buttons -> axis
-// "Keyboard" // Not supported yet, sorry F|RES ;( ...
+ "Hat",
+ "Custom",
};
////////////////////////
@@ -91,16 +89,14 @@ BEGIN_EVENT_TABLE(ConfigBox,wxDialog)
EVT_BUTTON(IDB_ANALOG_SUB_Y, ConfigBox::GetButtons)
#if wxUSE_TIMER
- EVT_TIMER(wxID_ANY, ConfigBox::OnTimer)
+ EVT_TIMER(IDTM_CONSTANT, ConfigBox::OnTimer)
+ EVT_TIMER(IDTM_BUTTON, ConfigBox::OnButtonTimer)
#endif
END_EVENT_TABLE()
ConfigBox::ConfigBox(wxWindow *parent, wxWindowID id, const wxString &title,
const wxPoint &position, const wxSize& size, long style)
: wxDialog(parent, id, title, position, size, style)
- #if wxUSE_TIMER
- , m_timer(this)
- #endif
{
// Define values
notebookpage = 0;
@@ -110,21 +106,28 @@ ConfigBox::ConfigBox(wxWindow *parent, wxWindowID id, const wxString &title,
CreateGUIControls();
#if wxUSE_TIMER
+ m_ConstantTimer = new wxTimer(this, IDTM_CONSTANT);
+ m_ButtonMappingTimer = new wxTimer(this, IDTM_BUTTON);
+
+ // Reset values
+ GetButtonWaitingID = 0; GetButtonWaitingTimer = 0;
+
+ // Start the constant timer
int TimesPerSecond = 30;
- m_timer.Start( floor((double)(1000 / TimesPerSecond)) );
+ m_ConstantTimer->Start( floor((double)(1000 / TimesPerSecond)) );
#endif
- wxTheApp->Connect(wxID_ANY, wxEVT_KEY_DOWN,
+ // wxEVT_KEY_DOWN is blocked for enter, tab and the directional keys
+ wxTheApp->Connect(wxID_ANY, wxEVT_KEY_UP,
wxKeyEventHandler(ConfigBox::OnKeyDown),
(wxObject*)0, this);
-
}
ConfigBox::~ConfigBox()
{
// The statbar sample has this so I add this to
#if wxUSE_TIMER
- if (m_timer.IsRunning()) m_timer.Stop();
+ if (m_ConstantTimer->IsRunning()) m_ConstantTimer->Stop();
#endif
}
@@ -177,7 +180,7 @@ void ConfigBox::OKClick(wxCommandEvent& event)
if (Tmp == wxOK) return; else if (Tmp == wxNO) g_Config.bSaveByIDNotice = false;
}
- for(int i=0; i<4 ;i++) GetControllerAll(i); // Update joysticks array
+ for(int i=0; i<4 ;i++) SaveButtonMapping(i); // Update joysticks array
g_Config.Save(true); // Save settings
g_Config.Load(); // Reload settings
Close(); // Call OnClose()
@@ -243,24 +246,29 @@ void ConfigBox::EnableDisable(wxCommandEvent& event)
// Update GUI
// ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
-// Called from: SetControllerAll(), ChangeControllertype()
+// Called from: UpdateGUIKeys(), ChangeControllertype()
void ConfigBox::UpdateGUI(int _notebookpage)
{
// Update the enable / disable status
joysticks[_notebookpage].enabled = m_Joyattach[_notebookpage]->GetValue();
// Controller type settings
- bool HasHat = (joysticks[_notebookpage].controllertype == CTL_TYPE_JOYSTICK);
- m_JoyDpadDown[_notebookpage]->Show(HasHat);
- m_JoyDpadLeft[_notebookpage]->Show(HasHat);
- m_JoyDpadRight[_notebookpage]->Show(HasHat);
- m_bJoyDpadDown[_notebookpage]->Show(HasHat);
- m_bJoyDpadLeft[_notebookpage]->Show(HasHat);
- m_bJoyDpadRight[_notebookpage]->Show(HasHat);
- m_textDpadUp[_notebookpage]->Show(HasHat);
- m_textDpadDown[_notebookpage]->Show(HasHat);
- m_textDpadLeft[_notebookpage]->Show(HasHat);
- m_textDpadRight[_notebookpage]->Show(HasHat);
+ bool Hat = (joysticks[_notebookpage].controllertype == CTL_DPAD_HAT);
+ m_JoyDpadLeft[_notebookpage]->Show(!Hat);
+ m_JoyDpadRight[_notebookpage]->Show(!Hat);
+ m_JoyDpadDown[_notebookpage]->Show(!Hat);
+
+ m_bJoyDpadLeft[_notebookpage]->Show(!Hat);
+ m_bJoyDpadRight[_notebookpage]->Show(!Hat);
+ m_bJoyDpadDown[_notebookpage]->Show(!Hat);
+
+ m_textDpadDown[_notebookpage]->Show(!Hat);
+ m_textDpadLeft[_notebookpage]->Show(!Hat);
+ m_textDpadRight[_notebookpage]->Show(!Hat);
+
+ m_textDpadUp[_notebookpage]->SetLabel(Hat ? wxT("Select hat") : wxT("Up"));
+ m_bJoyDpadUp[_notebookpage]->SetToolTip(Hat ?
+ wxT("Select a hat by pressing the hat in any direction") : wxT(""));
// General settings
m_CBSaveByID[_notebookpage]->SetValue(g_Config.bSaveByID.at(_notebookpage));
@@ -283,7 +291,6 @@ void ConfigBox::UpdateGUI(int _notebookpage)
m_Controller[_notebookpage]->FindItem(IDC_DEADZONE)->Enable(joysticks[_notebookpage].enabled);
//m_Controller[_notebookpage]->FindItem(IDC_CONTROLTYPE)->Enable(joysticks[_notebookpage].enabled);
#endif
- m_Controltype[_notebookpage]->SetSelection(HasHat ? 0 : 1);
// Repaint the background
m_Controller[_notebookpage]->Refresh();
@@ -306,7 +313,7 @@ void ConfigBox::ChangeJoystick(wxCommandEvent& event)
{
// Before chaning the pad we save potential changes (to support SaveByID)
int TmpID = joysticks[notebookpage].ID; // Don't update the ID
- GetControllerAll(notebookpage);
+ SaveButtonMapping(notebookpage);
joysticks[notebookpage].ID = TmpID;
g_Config.Save();
@@ -317,20 +324,22 @@ void ConfigBox::ChangeJoystick(wxCommandEvent& event)
// Update the controller type
if(joyinfo[joysticks[notebookpage].ID].NumHats > 0)
- joysticks[notebookpage].controllertype = CTL_TYPE_JOYSTICK;
+ joysticks[notebookpage].controllertype = CTL_DPAD_HAT;
//PanicAlert("%i %i", joysticks[notebookpage].ID, notebookpage);
// Load device settings to support SaveByID
g_Config.Load(true); // Then load the current
- SetControllerAll(notebookpage); // Update joystick dialog items
+ UpdateGUIKeys(notebookpage); // Update joystick dialog items
UpdateGUI(notebookpage); // Update other dialog items
// Remap the controller
if (joysticks[notebookpage].enabled)
{
+ return;
if (SDL_JoystickOpened(notebookpage)) SDL_JoystickClose(joystate[notebookpage].joy);
joystate[notebookpage].joy = SDL_JoystickOpen(joysticks[notebookpage].ID);
+ PanicAlert("");
}
}
@@ -361,9 +370,6 @@ void ConfigBox::CreateGUIControls()
SetIcon(wxNullIcon);
- //WxStaticBitmap1_BITMAP(ConfigBox_WxStaticBitmap1_XPM);
- //WxStaticBitmap1_BITMAP = new WxStaticBitmap1_BITMAP(ConfigBox_WxStaticBitmap1_XPM);
-
#ifndef _WIN32
// Force a 8pt font so that it looks more or less "correct" regardless of the default font setting
wxFont f(8, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
@@ -423,10 +429,8 @@ void ConfigBox::CreateGUIControls()
// Populate the controller type list
// -----------------------------
wxArrayString arrayStringFor_Controltype;
- arrayStringFor_Controltype.Add(wxString::FromAscii(ControllerType[CTL_TYPE_JOYSTICK]));
- arrayStringFor_Controltype.Add(wxString::FromAscii(ControllerType[CTL_TYPE_JOYSTICK_NO_HAT]));
- // arrayStringFor_Controltype.Add(wxString::FromAscii(ControllerType[CTL_TYPE_JOYSTICK_XBOX360]));
- // arrayStringFor_Controltype.Add(wxString::FromAscii(ControllerType[CTL_TYPE_KEYBOARD]));
+ arrayStringFor_Controltype.Add(wxString::FromAscii(DPadType[CTL_DPAD_HAT]));
+ arrayStringFor_Controltype.Add(wxString::FromAscii(DPadType[CTL_DPAD_CUSTOM]));
// --------------------------------------------------------------------
@@ -451,7 +455,7 @@ void ConfigBox::CreateGUIControls()
int t = -75; // Top
int l = -4; // Left
m_sKeys[i] = new wxStaticBoxSizer( wxVERTICAL, m_Controller[i], wxT("Keys"));
- m_pKeys[i] = new wxPanel(m_Controller[i], ID_KEYSPANEL1 + i, wxDefaultPosition, wxSize(600, 400));
+ m_pKeys[i] = new wxPanel(m_Controller[i], ID_KEYSPANEL1 + i, wxDefaultPosition, wxSize(600, 400), 0);
//m_sKeys[i] = new wxStaticBox (m_Controller[i], IDG_JOYSTICK, wxT("Keys"), wxDefaultPosition, wxSize(608, 500));
m_sKeys[i]->Add(m_pKeys[i], 0, (wxALL), 0); // margin = 0
@@ -487,7 +491,7 @@ void ConfigBox::CreateGUIControls()
m_bJoyShoulderR[i] = new wxButton(m_pKeys[i], IDB_SHOULDER_R, wxEmptyString, wxPoint(l + 526, t + 108), wxSize(21, 14), 0, wxDefaultValidator, wxEmptyString);
// Left analog
- int ALt = 170; int ALw = ALt + 14; int ALb = ALw + 2; // Set offset
+ int ALt = 169; int ALw = ALt + 14; int ALb = ALw + 2; // Set offset
m_JoyAnalogMainX[i] = new wxTextCtrl(m_pKeys[i], ID_ANALOG_MAIN_X, wxT("0"), wxPoint(l + 6, t + ALw), wxSize(59, 19), wxTE_READONLY | wxTE_CENTRE, wxDefaultValidator, wxT("0"));
m_JoyAnalogMainX[i]->Enable(false);
m_JoyAnalogMainY[i] = new wxTextCtrl(m_pKeys[i], ID_ANALOG_MAIN_Y, wxT("0"), wxPoint(l + 6, t + ALw + 36), wxSize(59, 19), wxTE_READONLY | wxTE_CENTRE, wxDefaultValidator, wxT("0"));
@@ -496,9 +500,9 @@ void ConfigBox::CreateGUIControls()
m_bJoyAnalogMainY[i] = new wxButton(m_pKeys[i], IDB_ANALOG_MAIN_Y, wxEmptyString, wxPoint(l + 70, t + ALb + 36), wxSize(21, 14), 0, wxDefaultValidator, wxEmptyString);
m_textMainX[i] = new wxStaticText(m_pKeys[i], IDT_ANALOG_MAIN_X, wxT("X-axis"), wxPoint(l + 6, t + ALt), wxDefaultSize, 0, wxT("X-axis"));
m_textMainY[i] = new wxStaticText(m_pKeys[i], IDT_ANALOG_MAIN_Y, wxT("Y-axis"), wxPoint(l + 6, t + ALt + 36), wxDefaultSize, 0, wxT("Y-axis"));
-
+
// D-Pad
- int DPt = 255; int DPw = DPt + 14; int DPb = DPw + 2; // Set offset
+ int DPt = 250; int DPw = DPt + 14; int DPb = DPw + 2; // Set offset
m_JoyDpadUp[i] = new wxTextCtrl(m_pKeys[i], ID_DPAD_UP, wxT("0"), wxPoint(l + 6, t + DPw), wxSize(59, 19), wxTE_READONLY | wxTE_CENTRE, wxDefaultValidator, wxT("0"));
m_JoyDpadDown[i] = new wxTextCtrl(m_pKeys[i], ID_DPAD_DOWN, wxT("0"), wxPoint(l + 6, t + DPw + 36*1), wxSize(59, 19), wxTE_READONLY | wxTE_CENTRE, wxDefaultValidator, wxT("0"));
m_JoyDpadLeft[i] = new wxTextCtrl(m_pKeys[i], ID_DPAD_LEFT, wxT("0"), wxPoint(l + 6, t + DPw + 36*2), wxSize(59, 19), wxTE_READONLY | wxTE_CENTRE, wxDefaultValidator, wxT("0"));
@@ -515,7 +519,7 @@ void ConfigBox::CreateGUIControls()
m_textDpadDown[i] = new wxStaticText(m_pKeys[i], IDT_DPAD_DOWN, wxT("Down"), wxPoint(l + 6, t + DPt + 36*1), wxDefaultSize, 0, wxT("Down"));
m_textDpadLeft[i] = new wxStaticText(m_pKeys[i], IDT_DPAD_LEFT, wxT("Left"), wxPoint(l + 6, t + DPt + 36*2), wxDefaultSize, 0, wxT("Left"));
m_textDpadRight[i] = new wxStaticText(m_pKeys[i], IDT_DPAD_RIGHT, wxT("Right"), wxPoint(l + 6, t + DPt + 36*3), wxDefaultSize, 0, wxT("Right"));
-
+
// Buttons
m_JoyButtonA[i] = new wxTextCtrl(m_pKeys[i], ID_BUTTON_A, wxT("0"), wxPoint(l + 552, t + 280), wxSize(59, 19), wxTE_READONLY | wxTE_CENTRE, wxDefaultValidator, wxT("0"));
m_JoyButtonA[i]->Enable(false);
@@ -604,19 +608,16 @@ void ConfigBox::CreateGUIControls()
m_gGBExtrasettings[i]->Add(m_bJoyButtonHalfpress[i], wxGBPosition(1, 2), wxGBSpan(1, 1), (wxLEFT | wxTOP), 2);
m_gExtrasettings[i]->Add(m_gGBExtrasettings[i], 0, wxEXPAND | wxALL, 3);
-
- // Why is there a setting for this? Is it to replaced the analog stick with the digital pad?
-
// Populate controller typ
- m_gControllertype[i] = new wxStaticBoxSizer( wxVERTICAL, m_Controller[i], wxT("Controller type"));
+ m_gControllertype[i] = new wxStaticBoxSizer( wxVERTICAL, m_Controller[i], wxT("D-Pad"));
m_Controltype[i] = new wxComboBox(m_Controller[i], IDC_CONTROLTYPE, arrayStringFor_Controltype[0], wxDefaultPosition, wxDefaultSize, arrayStringFor_Controltype, wxCB_READONLY);
- m_gControllertype[i]->Add(m_Controltype[i], 0, wxEXPAND | wxALL, 3);
- m_Controltype[i]->Enable(false);
+ m_gControllertype[i]->Add(m_Controltype[i], 0, wxEXPAND | wxALL, 3);
+ m_Controltype[i]->SetToolTip(wxT("Use a 'hat' on your gamepad or configure a custom button for each direction."));
// Create objects for general settings
m_gGenSettings[i] = new wxStaticBoxSizer( wxVERTICAL, m_Controller[i], wxT("Settings") );
m_CBSaveByID[i] = new wxCheckBox(m_Controller[i], IDC_SAVEBYID, wxT("Save by ID"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
- m_CBSaveByIDNotice[i] = new wxCheckBox(m_Controller[i], IDC_SAVEBYIDNOTICE, wxT("Notice"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
+ m_CBSaveByIDNotice[i] = new wxCheckBox(m_Controller[i], IDC_SAVEBYIDNOTICE, wxT("Notify"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_CBShowAdvanced[i] = new wxCheckBox(m_Controller[i], IDC_SHOWADVANCED, wxT("Show advanced settings"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
// Populate general settings
@@ -735,7 +736,7 @@ void ConfigBox::CreateGUIControls()
}
// Set dialog items from saved values
- SetControllerAll(i);
+ UpdateGUIKeys(i);
// Update GUI
UpdateGUI(i);
@@ -763,7 +764,7 @@ void ConfigBox::CreateGUIControls()
// --------------------------------------------------------------------
// Debugging
// -----------------------------
- m_pStatusBar = new wxStaticText(this, IDT_DEBUGGING, wxT("Debugging"), wxPoint(100, 490), wxDefaultSize);
+ //m_pStatusBar = new wxStaticText(this, IDT_DEBUGGING, wxT("Debugging"), wxPoint(100, 490), wxDefaultSize);
//m_pStatusBar2 = new wxStaticText(this, IDT_DEBUGGING2, wxT("Debugging2"), wxPoint(100, 530), wxDefaultSize);
//m_pStatusBar->SetLabel(wxString::Format("Debugging text"));
diff --git a/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.h b/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.h
index 7468b461d5..97cceb4f8c 100644
--- a/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.h
+++ b/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.h
@@ -63,7 +63,8 @@ class ConfigBox : public wxDialog
#if wxUSE_TIMER
void OnTimer(wxTimerEvent& WXUNUSED(event)) { Update(); }
- wxTimer m_timer;
+ void OnButtonTimer(wxTimerEvent& WXUNUSED(event)) { DoGetButtons(GetButtonWaitingID); }
+ wxTimer *m_ConstantTimer, *m_ButtonMappingTimer;
#endif
// Debugging
@@ -71,6 +72,9 @@ class ConfigBox : public wxDialog
// Status window
int BoxW, BoxH;
+
+ // Configure buttons
+ int GetButtonWaitingID, GetButtonWaitingTimer;
private:
wxButton *m_About;
@@ -86,7 +90,6 @@ class ConfigBox : public wxDialog
wxStaticBoxSizer * m_sKeys[4];
wxBoxSizer *m_sMain[4], *m_sMainLeft[4], *m_sMainRight[4];
-
/////////////////////////////
// Settings
// ŻŻŻŻŻŻŻŻŻ
@@ -208,6 +211,9 @@ class ConfigBox : public wxDialog
// Advaced settings
IDCB_MAINSTICK_DIAGONAL, IDCB_MAINSTICK_S_TO_C, IDT_MAINSTICK_DIAGONAL,
+ // Timers
+ IDTM_CONSTANT, IDTM_BUTTON,
+
// --------------------------------------------------------------------
// Keys objects
@@ -292,12 +298,12 @@ class ConfigBox : public wxDialog
wxBitmap CreateBitmap(); wxBitmap CreateBitmapDot();
void PadGetStatus(); void Update();
- void SetControllerAll(int controller);
- void GetControllerAll(int controller);
+ void UpdateGUIKeys(int controller);
+ void SaveButtonMapping(int controller);
void NotebookPageChanged(wxNotebookEvent& event);
- void GetButtons(wxCommandEvent& event);
+ void GetButtons(wxCommandEvent& event); void DoGetButtons(int);
void GetHats(int ID);
void GetAxis(wxCommandEvent& event);
diff --git a/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigJoypad.cpp b/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigJoypad.cpp
index f0a5503fff..76383016f0 100644
--- a/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigJoypad.cpp
+++ b/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigJoypad.cpp
@@ -47,7 +47,7 @@ extern bool emulator_running;
// Set dialog items from saved values
// ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
-void ConfigBox::SetControllerAll(int controller)
+void ConfigBox::UpdateGUIKeys(int controller)
{
// http://wiki.wxwidgets.org/Converting_everything_to_and_from_wxString
wxString tmp;
@@ -82,7 +82,7 @@ void ConfigBox::SetControllerAll(int controller)
UpdateGUI(controller);
- if(joysticks[controller].controllertype == CTL_TYPE_JOYSTICK)
+ if(joysticks[controller].controllertype == CTL_DPAD_HAT)
{
tmp << joysticks[controller].dpad; m_JoyDpadUp[controller]->SetValue(tmp); tmp.clear();
}
@@ -98,17 +98,20 @@ void ConfigBox::SetControllerAll(int controller)
/* Populate the joysticks array with the dialog items settings, for example
selected joystick, enabled or disabled status and so on */
// ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
-void ConfigBox::GetControllerAll(int controller)
+void ConfigBox::SaveButtonMapping(int controller)
{
+ // Temporary storage
wxString tmp;
long value;
+ // The controller ID
joysticks[controller].ID = m_Joyname[controller]->GetSelection();
- if(joyinfo[joysticks[controller].ID].NumHats > 0) joysticks[controller].controllertype = CTL_TYPE_JOYSTICK;
- m_JoyShoulderL[controller]->GetValue().ToLong(&value); joysticks[controller].buttons[CTL_L_SHOULDER] = value; tmp.clear();
- m_JoyShoulderR[controller]->GetValue().ToLong(&value); joysticks[controller].buttons[CTL_R_SHOULDER] = value; tmp.clear();
+ // The shoulder buttons
+ m_JoyShoulderL[controller]->GetValue().ToLong(&value); joysticks[controller].buttons[CTL_L_SHOULDER] = value;
+ m_JoyShoulderR[controller]->GetValue().ToLong(&value); joysticks[controller].buttons[CTL_R_SHOULDER] = value;
+ // The digital buttons
m_JoyButtonA[controller]->GetValue().ToLong(&value); joysticks[controller].buttons[CTL_A_BUTTON] = value; tmp.clear();
m_JoyButtonB[controller]->GetValue().ToLong(&value); joysticks[controller].buttons[CTL_B_BUTTON] = value; tmp.clear();
m_JoyButtonX[controller]->GetValue().ToLong(&value); joysticks[controller].buttons[CTL_X_BUTTON] = value; tmp.clear();
@@ -118,7 +121,8 @@ void ConfigBox::GetControllerAll(int controller)
m_JoyButtonHalfpress[controller]->GetValue().ToLong(&value); joysticks[controller].halfpress = value; tmp.clear();
- if(joysticks[controller].controllertype == CTL_TYPE_JOYSTICK)
+ // Digital pad type
+ if(joysticks[controller].controllertype == CTL_DPAD_HAT)
{
m_JoyDpadUp[controller]->GetValue().ToLong(&value); joysticks[controller].dpad = value; tmp.clear();
}
@@ -155,83 +159,52 @@ void ConfigBox::ChangeControllertype(wxCommandEvent& event)
}
+// Update the textbox for the buttons
+// ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
void ConfigBox::SetButtonText(int id, char text[128])
{
int controller = notebookpage;
switch(id)
{
+ case IDB_DPAD_RIGHT:
+ m_JoyDpadRight[controller]->SetValue(wxString::FromAscii(text)); break;
+ case IDB_DPAD_UP:
+ m_JoyDpadUp[controller]->SetValue(wxString::FromAscii(text)); break;
+ case IDB_DPAD_DOWN:
+ m_JoyDpadDown[controller]->SetValue(wxString::FromAscii(text)); break;
+ case IDB_DPAD_LEFT:
+ m_JoyDpadLeft[controller]->SetValue(wxString::FromAscii(text)); break;
+
+ case IDB_ANALOG_MAIN_X:
+ m_JoyAnalogMainX[controller]->SetValue(wxString::FromAscii(text)); break;
+ case IDB_ANALOG_MAIN_Y:
+ m_JoyAnalogMainY[controller]->SetValue(wxString::FromAscii(text)); break;
+ case IDB_ANALOG_SUB_X:
+ m_JoyAnalogSubX[controller]->SetValue(wxString::FromAscii(text)); break;
+ case IDB_ANALOG_SUB_Y:
+ m_JoyAnalogSubY[controller]->SetValue(wxString::FromAscii(text)); break;
+
case IDB_SHOULDER_L:
m_JoyShoulderL[controller]->SetValue(wxString::FromAscii(text)); break;
-
case IDB_SHOULDER_R:
m_JoyShoulderR[controller]->SetValue(wxString::FromAscii(text)); break;
case IDB_BUTTON_A:
- m_JoyButtonA[controller]->SetValue(wxString::FromAscii(text)); break;
-
+ m_JoyButtonA[controller]->SetValue(wxString::FromAscii(text)); break;
case IDB_BUTTON_B:
- {
- m_JoyButtonB[controller]->SetValue(wxString::FromAscii(text));
- }
- break;
-
+ m_JoyButtonB[controller]->SetValue(wxString::FromAscii(text)); break;
case IDB_BUTTON_X:
- {
- m_JoyButtonX[controller]->SetValue(wxString::FromAscii(text));
- }
- break;
-
+ m_JoyButtonX[controller]->SetValue(wxString::FromAscii(text)); break;
case IDB_BUTTON_Y:
m_JoyButtonY[controller]->SetValue(wxString::FromAscii(text)); break;
-
case IDB_BUTTON_Z:
m_JoyButtonZ[controller]->SetValue(wxString::FromAscii(text)); break;
-
case IDB_BUTTONSTART:
- {
- m_JoyButtonStart[controller]->SetValue(wxString::FromAscii(text));
- }
- break;
+ m_JoyButtonStart[controller]->SetValue(wxString::FromAscii(text)); break;
case IDB_BUTTONHALFPRESS:
- {
- m_JoyButtonHalfpress[controller]->SetValue(wxString::FromAscii(text));
- }
- break;
-
- case IDB_DPAD_UP:
- {
- m_JoyDpadUp[controller]->SetValue(wxString::FromAscii(text));
- }
- break;
-
- case IDB_DPAD_DOWN:
- {
- m_JoyDpadDown[controller]->SetValue(wxString::FromAscii(text));
- }
- break;
-
- case IDB_DPAD_LEFT:
- {
- m_JoyDpadLeft[controller]->SetValue(wxString::FromAscii(text));
- }
- break;
-
- case IDB_DPAD_RIGHT:
- m_JoyDpadRight[controller]->SetValue(wxString::FromAscii(text)); break;
-
- case IDB_ANALOG_MAIN_X:
- m_JoyAnalogMainX[controller]->SetValue(wxString::FromAscii(text)); break;
-
- case IDB_ANALOG_MAIN_Y:
- m_JoyAnalogMainY[controller]->SetValue(wxString::FromAscii(text)); break;
-
- case IDB_ANALOG_SUB_X:
- m_JoyAnalogSubX[controller]->SetValue(wxString::FromAscii(text)); break;
-
- case IDB_ANALOG_SUB_Y:
- m_JoyAnalogSubY[controller]->SetValue(wxString::FromAscii(text)); break;
+ m_JoyButtonHalfpress[controller]->SetValue(wxString::FromAscii(text)); break;
default:
break;
@@ -240,7 +213,7 @@ void ConfigBox::SetButtonText(int id, char text[128])
//////////////////////////////////////////////////////////////////////////////////////////
-// Condifigure button mapping
+// Configure button mapping
// ŻŻŻŻŻŻŻŻŻŻ
@@ -261,23 +234,37 @@ bool AvoidValues(int value)
// Wait for button press
// ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
+/* Loop or timer: There are basically two ways to do this. With a while() or for() loop, or with a
+ timer. The downside with the while() or for() loop is that there is no way to stop it if the user
+ should select to configure another button while we are still in an old loop. What will happen then
+ is that we start another parallel loop (at least in Windows) that blocks the old loop. And our only
+ option to wait for the old loop to finish is with a new loop, and that will block the old loop for as
+ long as it's going on. Therefore a timer is easier to control. */
void ConfigBox::GetButtons(wxCommandEvent& event)
{
+ DoGetButtons(event.GetId());
+}
+void ConfigBox::DoGetButtons(int GetId)
+{
+ // =============================================
+ // Collect the starting values
+ // ----------------
+
// Get the current controller
- int controller = notebookpage;
-
- // Get the ID for the wxWidgets button that was pressed
- int ID = event.GetId();
+ int Controller = notebookpage;
// Collect the accepted buttons for this slot
- bool Axis = (event.GetId() >= IDB_ANALOG_MAIN_X && event.GetId() <= IDB_SHOULDER_R);
- bool Button = (event.GetId() >= IDB_BUTTON_A && event.GetId() <= IDB_BUTTONSTART)
- || (event.GetId() == IDB_SHOULDER_L || event.GetId() == IDB_SHOULDER_R);
- bool Hat = (event.GetId() >= IDB_DPAD_UP && event.GetId() <= IDB_DPAD_RIGHT);
+ bool LeftRight = (GetId == IDB_SHOULDER_L || GetId == IDB_SHOULDER_R);
+ bool Axis = (GetId >= IDB_ANALOG_MAIN_X && GetId <= IDB_SHOULDER_R);
+ bool Button = (GetId >= IDB_BUTTON_A && GetId <= IDB_BUTTONSTART)
+ || (GetId == IDB_SHOULDER_L || GetId == IDB_SHOULDER_R)
+ || (GetId >= IDB_DPAD_UP && GetId <= IDB_DPAD_RIGHT && joysticks[Controller].controllertype == CTL_DPAD_CUSTOM);
+ bool Hat = (GetId >= IDB_DPAD_UP && GetId <= IDB_DPAD_RIGHT)
+ && (joysticks[Controller].controllertype == CTL_DPAD_HAT);
- /* Open a new joystick. Joysticks[controller].ID is the system ID of the physical joystick
+ /* Open a new joystick. Joysticks[controller].GetId is the system GetId of the physical joystick
that is mapped to controller, for example 0, 1, 2, 3 for the first four joysticks */
- SDL_Joystick *joy = SDL_JoystickOpen(joysticks[controller].ID);
+ SDL_Joystick *joy = SDL_JoystickOpen(joysticks[Controller].ID);
// Get the number of axes, hats and buttons
int buttons = SDL_JoystickNumButtons(joy);
@@ -287,18 +274,47 @@ void ConfigBox::GetButtons(wxCommandEvent& event)
// Declare values
char format[128];
int value; // Axis value
- bool waiting = true;
- bool succeed = false;
+ int type; // Button type
+ bool Succeed = false;
+ bool Stop = false; // Stop the timer
int pressed = 0;
- int counter1 = 0; // Waiting limits
- int counter2 = 30; // Iterations to wait for
+ int Seconds = 4; // Seconds to wait for
+ int TimesPerSecond = 40; // How often to run the check
+ // =======================
- // Update the text box
- sprintf(format, "[%d]", counter2);
- SetButtonText(ID, format);
- wxWindow::Update(); // Win only? doesnt seem to work in linux...
+ //Console::Print("Before (%i) Id:%i %i IsRunning:%i\n",
+ // GetButtonWaitingTimer, GetButtonWaitingID, GetId, m_ButtonMappingTimer->IsRunning());
- while(waiting)
+ // If the Id has changed or the timer is not running we should start one
+ if( GetButtonWaitingID != GetId || !m_ButtonMappingTimer->IsRunning() )
+ {
+ if(m_ButtonMappingTimer->IsRunning())
+ {
+ m_ButtonMappingTimer->Stop();
+ GetButtonWaitingTimer = 0;
+
+ // Update the old textbox
+ SetButtonText(GetButtonWaitingID, "");
+ }
+
+ // Save the button Id
+ GetButtonWaitingID = GetId;
+
+ // Reset the key in case we happen to have an old one
+ g_Pressed = 0;
+
+ // Update the text box
+ sprintf(format, "[%d]", Seconds);
+ SetButtonText(GetId, format);
+
+ // Start the timer
+ #if wxUSE_TIMER
+ m_ButtonMappingTimer->Start( floor((double)(1000 / TimesPerSecond)) );
+ #endif
+ }
+
+ // If there is a timer but we should not create a new one
+ else
{
// Update the internal status
SDL_JoystickUpdate();
@@ -312,10 +328,9 @@ void ConfigBox::GetButtons(wxCommandEvent& event)
if(AvoidValues(value)) continue; // Avoid values
- pressed = i;
- waiting = false;
- succeed = true;
- break; // Stop this loop
+ pressed = i + (LeftRight ? 1000 : 0); // Identify the analog triggers
+ type = CTL_AXIS;
+ Succeed = true;
}
}
@@ -324,13 +339,11 @@ void ConfigBox::GetButtons(wxCommandEvent& event)
{
for(int i = 0; i < hats; i++)
{
- value = SDL_JoystickGetHat(joy, i);
- if(value)
+ if(SDL_JoystickGetHat(joy, i))
{
- pressed = value;
- waiting = false;
- succeed = true;
- break;
+ pressed = i;
+ type = CTL_HAT;
+ Succeed = true;
}
}
}
@@ -342,25 +355,23 @@ void ConfigBox::GetButtons(wxCommandEvent& event)
{
if(SDL_JoystickGetButton(joy, i))
{
- pressed = i;
- waiting = false;
- succeed = true;
- break;
+ pressed = i;
+ type = CTL_BUTTON;
+ Succeed = true;
}
}
}
// Check for keyboard action
- if (g_Pressed)
+ if (g_Pressed && Button)
{
// Todo: Add a separate keyboard vector to remove this restriction
if(g_Pressed >= buttons)
{
pressed = g_Pressed;
- waiting = false;
- succeed = true;
- g_Pressed = 0;
- break;
+ type = CTL_BUTTON;
+ Succeed = true;
+ g_Pressed = 0;
}
else
{
@@ -370,48 +381,66 @@ void ConfigBox::GetButtons(wxCommandEvent& event)
, wxT("Notice"), wxICON_INFORMATION);
pressed = g_Pressed;
- waiting = false;
- succeed = false;
- g_Pressed = 0;
- break;
+ Succeed = false;
+ g_Pressed = 0;
}
}
- // Stop waiting for a button
- counter1++;
- if(counter1 == 25)
+ // Count each time
+ GetButtonWaitingTimer++;
+
+ // This is run every second
+ if(GetButtonWaitingTimer % TimesPerSecond == 0)
{
- counter1 = 0;
- counter2--;
-
- sprintf(format, "[%d]", counter2);
- SetButtonText(ID, format);
- wxWindow::Update(); // win only? doesnt seem to work in linux...
- wxYieldIfNeeded(); // Let through the keyboard input event
- if(counter2 < 0) waiting = false;
+ //Console::Print("Second\n\n");
+
+ // Current time
+ int TmpTime = Seconds - (GetButtonWaitingTimer / TimesPerSecond);
+
+ // Update text
+ sprintf(format, "[%d]", TmpTime);
+ SetButtonText(GetId, format);
}
- // Sleep for 10 ms then poll for keys again
- SLEEP(10);
-
- // Debugging
- /*
- m_pStatusBar->SetLabel(wxString::Format(
- "ID: %i %i",
- counter1, NumKeys
- ));
- */
+ // Time's up
+ if( (GetButtonWaitingTimer / TimesPerSecond) >= Seconds )
+ {
+ Stop = true;
+
+ // Leave a blank mapping
+ SetButtonText(GetId, "");
+ }
+
+ // If we got a button
+ if(Succeed)
+ {
+ Stop = true;
+
+ // Write the number of the pressed button to the text box
+ sprintf(format, "%d", pressed);
+ SetButtonText(GetId, format);
+ }
}
- // Write the number of the pressed button to the text box
- sprintf(format, "%d", succeed ? pressed : -1);
- SetButtonText(ID, format);
+ // Stop the timer
+ if(Stop)
+ {
+ m_ButtonMappingTimer->Stop();
+ GetButtonWaitingTimer = 0;
+ }
// We don't need thisgamepad handle any more
- if(SDL_JoystickOpened(joysticks[controller].ID)) SDL_JoystickClose(joy);
+ if(SDL_JoystickOpened(joysticks[Controller].ID)) SDL_JoystickClose(joy);
+
+ // Update the button mapping
+ SaveButtonMapping(Controller);
+
+ // Debugging
+ //Console::Print("IsRunning: %i\n", m_ButtonMappingTimer->IsRunning());
}
+#if 0
// Wait for Analog
// ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
void ConfigBox::GetAxis(wxCommandEvent& event)
@@ -476,7 +505,7 @@ void ConfigBox::GetAxis(wxCommandEvent& event)
SDL_JoystickClose(joy);
// Update the axises for the advanced settings status
- GetControllerAll(controller);
+ SaveButtonMapping(controller);
}
@@ -530,5 +559,6 @@ void ConfigBox::GetHats(int ID)
if(SDL_JoystickOpened(joysticks[controller].ID))
SDL_JoystickClose(joy);
}
+#endif
/////////////////////////////////////////////////////////// Configure button mapping
\ No newline at end of file
diff --git a/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp b/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp
index b8550cf597..c2200edd63 100644
--- a/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp
+++ b/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp
@@ -155,6 +155,7 @@ BOOL APIENTRY DllMain( HINSTANCE hinstDLL, // DLL module handle
}
#endif
+
//////////////////////////////////////////////////////////////////////////////////////////
// Input Plugin Functions (from spec's)
// ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
@@ -193,7 +194,7 @@ void DllConfig(HWND _hParent)
_PADInitialize.hWnd = NULL;
_PADInitialize.pLog = NULL;
Initialize((void*)&_PADInitialize);
- emulator_running = FALSE; // Set it back to false
+ emulator_running = false; // Set it back to false
}
g_Config.Load(); // Load settings
@@ -230,8 +231,16 @@ void DllDebugger(HWND _hParent, bool Show) {
// Init PAD (start emulation)
// ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
+/* Information: This function can not be run twice without a Shutdown in between. If
+ it's run twice the SDL_Init() will cause a crash. One solution to this is to keep a
+ global function that remembers the SDL_Init() and SDL_Quit() (emulator_running does
+ not do that since we can open and close this without any game running). But I would
+ suggest that avoiding to run this twice from the Core is better. */
void Initialize(void *init)
{
+ // Debugging
+ //Console::Open();
+
SPADInitialize _PADInitialize = *(SPADInitialize*)init;
emulator_running = true;
#ifdef _DEBUG
@@ -251,7 +260,7 @@ void Initialize(void *init)
}
#ifdef _WIN32
- m_hWnd = (HWND)_PADInitialize.hWnd;
+ m_hWnd = (HWND)_PADInitialize.hWnd;
#endif
Search_Devices(); // Populate joyinfo for all attached devices
@@ -334,11 +343,11 @@ int Search_Devices()
// Shutdown PAD (stop emulation)
// ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
-// Called from: The Dolphin Core
+/* Information: This function can not be run twice without an Initialize in between. If
+ it's run twice the SDL_...() functions below will cause a crash.
+ Called from: The Dolphin Core, ConfigBox::OnClose() */
void Shutdown()
{
- //if(!emulator_running) return;
-
if (joysticks[0].enabled && SDL_JoystickOpened(joysticks[0].ID))
SDL_JoystickClose(joystate[0].joy);
if (joysticks[1].enabled && SDL_JoystickOpened(joysticks[1].ID))
@@ -367,11 +376,10 @@ void Shutdown()
#endif
}
-
// Set buttons status from wxWidgets in the main application
// ŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
-void PAD_Input(u8 _Key, u8 _UpDown)
+void PAD_Input(u16 _Key, u8 _UpDown)
{
// Check if the keys are interesting, and then update it
for(int i = 0; i < 4; i++)
@@ -381,13 +389,25 @@ void PAD_Input(u8 _Key, u8 _UpDown)
if (joysticks[i].buttons[j] == _Key)
{ joystate[i].buttons[j] = _UpDown; break; }
}
+
+ for(int j = CTL_D_PAD_UP; j <= CTL_D_PAD_RIGHT; j++)
+ {
+ if (joysticks[i].dpad2[j] == _Key)
+ { joystate[i].dpad2[j] = _UpDown; break; }
+ }
}
+
+ // Debugging
+ //Console::Print("%i", _Key);
}
-void DoState(unsigned char **ptr, int mode) {
-}
-// Set PAD status.
+// Save state
+// ŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
+void DoState(unsigned char **ptr, int mode) {}
+
+
+// Set PAD status
// ŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
// Called from: SerialInterface_Devices.cpp
// Function: Gives the current pad status to the Core
@@ -399,20 +419,24 @@ void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
// Clear pad status
memset(_pPADStatus, 0, sizeof(SPADStatus));
- // Get pad status
+ // Update the pad status
GetJoyState(_numPAD);
///////////////////////////////////////////////////
- // Set analog controllers
+ // The analog controls
// -----------
- // Read values
+ // Read axis values
int i_main_stick_x = joystate[_numPAD].axis[CTL_MAIN_X];
int i_main_stick_y = -joystate[_numPAD].axis[CTL_MAIN_Y];
int i_sub_stick_x = joystate[_numPAD].axis[CTL_SUB_X];
int i_sub_stick_y = -joystate[_numPAD].axis[CTL_SUB_Y];
+ // This assumes the trigger is -0x8000 when unpressed
+ int SDLTriggerLeft = joystate[_numPAD].axis[CTL_L_SHOULDER];
+ int SDLTriggerRight = joystate[_numPAD].axis[CTL_R_SHOULDER];
+
// Check if we should make adjustments
if(g_Config.bSquareToCircle.at(_numPAD))
{
@@ -421,13 +445,15 @@ void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
i_main_stick_y = main_xy.at(1);
}
- // Convert button values from 0xffff to 0xff
+ // Convert axis values from 0xffff to 0xff
u8 main_stick_x = Pad_Convert(i_main_stick_x);
u8 main_stick_y = Pad_Convert(i_main_stick_y);
u8 sub_stick_x = Pad_Convert(i_sub_stick_x);
u8 sub_stick_y = Pad_Convert(i_sub_stick_y);
+ u8 TriggerLeft = Pad_Convert(SDLTriggerLeft);
+ u8 TriggerRight = Pad_Convert(SDLTriggerRight);
- // Set Deadzones perhaps out of function
+ // Set Deadzones (perhaps out of function?)
int deadzone = (int)(((float)(128.00/100.00)) * (float)(joysticks[_numPAD].deadzone + 1));
int deadzone2 = (int)(((float)(-128.00/100.00)) * (float)(joysticks[_numPAD].deadzone + 1));
@@ -439,27 +465,32 @@ void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
///////////////////////////////////////////////////
- // Set buttons
- // -----------
-
- // The L and R trigger values
+ // The L and R triggers
+ // -----------
int triggervalue = 255;
- if (joystate[_numPAD].halfpress) triggervalue = 100;
-
- // Neutral button value, no button pressed
- _pPADStatus->button |= PAD_USE_ORIGIN;
+ if (joystate[_numPAD].halfpress) triggervalue = 100;
+ _pPADStatus->button |= PAD_USE_ORIGIN; // Neutral value, no button pressed
if (joystate[_numPAD].buttons[CTL_L_SHOULDER])
{
- _pPADStatus->button|=PAD_TRIGGER_L;
- _pPADStatus->triggerLeft = triggervalue;
+ _pPADStatus->button |= PAD_TRIGGER_L;
+ _pPADStatus->triggerLeft = triggervalue;
}
+ else if(joystate[_numPAD].axis[CTL_L_SHOULDER])
+ _pPADStatus->triggerLeft = triggervalue;
+
if (joystate[_numPAD].buttons[CTL_R_SHOULDER])
{
- _pPADStatus->button|=PAD_TRIGGER_R;
- _pPADStatus->triggerRight = triggervalue;
+ _pPADStatus->button |= PAD_TRIGGER_R;
+ _pPADStatus->triggerRight = TriggerLeft;
}
+ else if(joystate[_numPAD].axis[CTL_R_SHOULDER])
+ _pPADStatus->triggerRight = TriggerRight;
+
+ ///////////////////////////////////////////////////
+ // The digital buttons
+ // -----------
if (joystate[_numPAD].buttons[CTL_A_BUTTON])
{
_pPADStatus->button |= PAD_BUTTON_A;
@@ -475,8 +506,11 @@ void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
if (joystate[_numPAD].buttons[CTL_Z_TRIGGER]) _pPADStatus->button|=PAD_TRIGGER_Z;
if (joystate[_numPAD].buttons[CTL_START]) _pPADStatus->button|=PAD_BUTTON_START;
- // Set D-pad
- if (joysticks[_numPAD].controllertype == CTL_TYPE_JOYSTICK)
+
+ ///////////////////////////////////////////////////
+ // The D-pad
+ // -----------
+ if (joysticks[_numPAD].controllertype == CTL_DPAD_HAT)
{
if (joystate[_numPAD].dpad == SDL_HAT_LEFTUP || joystate[_numPAD].dpad == SDL_HAT_UP || joystate[_numPAD].dpad == SDL_HAT_RIGHTUP ) _pPADStatus->button|=PAD_BUTTON_UP;
if (joystate[_numPAD].dpad == SDL_HAT_LEFTUP || joystate[_numPAD].dpad == SDL_HAT_LEFT || joystate[_numPAD].dpad == SDL_HAT_LEFTDOWN ) _pPADStatus->button|=PAD_BUTTON_LEFT;
@@ -500,9 +534,36 @@ void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
// Use rumble
Pad_Use_Rumble(_numPAD, _pPADStatus);
+
+ /* Debugging
+ Console::ClearScreen();
+ Console::Print("TriggerLeft:%04x TriggerRight:%04x\nD-Pad type: %s L:%i R:%i U:%i D:%i",
+ TriggerLeft, TriggerRight,
+ (joysticks[_numPAD].controllertype ? "CTL_DPAD_CUSTOM" : "CTL_DPAD_HAT")
+ ); */
}
+// Set PAD attached pads
+// ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
+unsigned int PAD_GetAttachedPads()
+{
+ unsigned int connected = 0;
+
+ g_Config.Load();
+
+ if (joysticks[0].enabled) connected |= 1;
+ if (joysticks[1].enabled) connected |= 2;
+ if (joysticks[2].enabled) connected |= 4;
+ if (joysticks[3].enabled) connected |= 8;
+
+ return connected;
+}
+
+///////////////////////////////////////////////// Spec functions
+
+
+
//////////////////////////////////////////////////////////////////////////////////////////
// Convert stick values, for example from circle to square analog stick radius
// ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
@@ -568,7 +629,7 @@ std::vector Pad_Square_to_Circle(int _x, int _y)
if(_x > 32767) _x = 32767; if(_y > 32767) _y = 32767; // upper limit
if(_x < -32768) _x = -32768; if(_y > 32767) _y = 32767; // lower limit
- ///////////////////////////////////////////////////
+ // ====================================
// Convert to circle
// -----------
int Tmp = atoi (g_Config.SDiagonal.substr(0, g_Config.SDiagonal.length() - 1).c_str());
@@ -611,30 +672,14 @@ std::vector Pad_Square_to_Circle(int _x, int _y)
//////////////////////////////////////////////////////////////////////////////////////////
-// Set PAD attached pads
-// ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
-unsigned int PAD_GetAttachedPads()
-{
- unsigned int connected = 0;
-
- g_Config.Load();
-
- if (joysticks[0].enabled) connected |= 1;
- if (joysticks[1].enabled) connected |= 2;
- if (joysticks[2].enabled) connected |= 4;
- if (joysticks[3].enabled) connected |= 8;
-
- return connected;
-}
-
-
//////////////////////////////////////////////////////////////////////////////////////////
-// Read current joystick status
+// Supporting functions: Read current joystick status
/* ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
The value joysticks[].buttons[] is the number of the assigned joypad button,
joystate[].buttons[] is the status of the button, it becomes 0 (no pressed) or 1 (pressed) */
+
// Read buttons status. Called from GetJoyState().
// ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
void ReadButton(int controller, int button)
@@ -653,12 +698,25 @@ void ReadButton(int controller, int button)
for a virtual controller 0 to 3. */
void GetJoyState(int controller)
{
+ // Update the gamepad status
SDL_JoystickUpdate();
+ // Save the number of buttons
+ int Buttons = joyinfo[joysticks[controller].ID].NumButtons;
+
+ // Update axis states. It doesn't hurt much if we happen to ask for nonexisting axises here.
joystate[controller].axis[CTL_MAIN_X] = SDL_JoystickGetAxis(joystate[controller].joy, joysticks[controller].axis[CTL_MAIN_X]);
joystate[controller].axis[CTL_MAIN_Y] = SDL_JoystickGetAxis(joystate[controller].joy, joysticks[controller].axis[CTL_MAIN_Y]);
joystate[controller].axis[CTL_SUB_X] = SDL_JoystickGetAxis(joystate[controller].joy, joysticks[controller].axis[CTL_SUB_X]);
joystate[controller].axis[CTL_SUB_Y] = SDL_JoystickGetAxis(joystate[controller].joy, joysticks[controller].axis[CTL_SUB_Y]);
+ joystate[controller].axis[CTL_L_SHOULDER] = SDL_JoystickGetAxis(joystate[controller].joy, joysticks[controller].buttons[CTL_L_SHOULDER] - 1000);
+ joystate[controller].axis[CTL_R_SHOULDER] = SDL_JoystickGetAxis(joystate[controller].joy, joysticks[controller].buttons[CTL_R_SHOULDER] - 1000);
+
+ // Debugging
+ /*
+ Console::Print("Controller:%i %i\n",
+ joystate[controller].axis[CTL_L_SHOULDER], joystate[controller].axis[CTL_R_SHOULDER]
+ ); */
ReadButton(controller, CTL_L_SHOULDER);
ReadButton(controller, CTL_R_SHOULDER);
@@ -674,16 +732,22 @@ void GetJoyState(int controller)
joystate[controller].halfpress = SDL_JoystickGetButton(joystate[controller].joy, joysticks[controller].halfpress);
// Check if we have an analog or digital joypad
- if (joysticks[controller].controllertype == CTL_TYPE_JOYSTICK)
+ if (joysticks[controller].controllertype == CTL_DPAD_HAT)
{
joystate[controller].dpad = SDL_JoystickGetHat(joystate[controller].joy, joysticks[controller].dpad);
}
else
{
- joystate[controller].dpad2[CTL_D_PAD_UP] = SDL_JoystickGetButton(joystate[controller].joy, joysticks[controller].dpad2[CTL_D_PAD_UP]);
- joystate[controller].dpad2[CTL_D_PAD_DOWN] = SDL_JoystickGetButton(joystate[controller].joy, joysticks[controller].dpad2[CTL_D_PAD_DOWN]);
- joystate[controller].dpad2[CTL_D_PAD_LEFT] = SDL_JoystickGetButton(joystate[controller].joy, joysticks[controller].dpad2[CTL_D_PAD_LEFT]);
- joystate[controller].dpad2[CTL_D_PAD_RIGHT] = SDL_JoystickGetButton(joystate[controller].joy, joysticks[controller].dpad2[CTL_D_PAD_RIGHT]);
+ /* Only do this if the assigned button is in range (to allow for the current way of saving keyboard
+ keys in the same array) */
+ if(joysticks[controller].dpad2[CTL_D_PAD_UP] <= Buttons)
+ joystate[controller].dpad2[CTL_D_PAD_UP] = SDL_JoystickGetButton(joystate[controller].joy, joysticks[controller].dpad2[CTL_D_PAD_UP]);
+ if(joysticks[controller].dpad2[CTL_D_PAD_DOWN] <= Buttons)
+ joystate[controller].dpad2[CTL_D_PAD_DOWN] = SDL_JoystickGetButton(joystate[controller].joy, joysticks[controller].dpad2[CTL_D_PAD_DOWN]);
+ if(joysticks[controller].dpad2[CTL_D_PAD_LEFT] <= Buttons)
+ joystate[controller].dpad2[CTL_D_PAD_LEFT] = SDL_JoystickGetButton(joystate[controller].joy, joysticks[controller].dpad2[CTL_D_PAD_LEFT]);
+ if(joysticks[controller].dpad2[CTL_D_PAD_RIGHT] <= Buttons)
+ joystate[controller].dpad2[CTL_D_PAD_RIGHT] = SDL_JoystickGetButton(joystate[controller].joy, joysticks[controller].dpad2[CTL_D_PAD_RIGHT]);
}
}
//////////////////////////////////////////////////////////////////////////////////////////
diff --git a/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.h b/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.h
index c03cc43aee..1803d4c229 100644
--- a/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.h
+++ b/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.h
@@ -29,9 +29,18 @@
//
//////////////////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Settings
+// ŻŻŻŻŻŻŻŻŻŻ
// Set this if you want to use the rumble 'hack' for controller one
//#define USE_RUMBLE_DINPUT_HACK
+//////////////////////////
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Includes
+// ŻŻŻŻŻŻŻŻŻŻ
#include // System
#include
#include
@@ -67,21 +76,22 @@
#endif // _WIN32
#ifdef _WIN32
-#define SLEEP(x) Sleep(x)
+ #define SLEEP(x) Sleep(x)
#else
-#include
-#include
-#define SLEEP(x) usleep(x*1000)
+ #include
+ #include
+ #define SLEEP(x) usleep(x*1000)
#endif
#ifdef __linux__
#include
#endif
+//////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
// Define
-// ŻŻŻŻŻŻ
+// ŻŻŻŻŻŻŻŻŻŻ
#define INPUT_VERSION "0.3"
#define INPUT_STATE "PUBLIC RELEASE"
@@ -96,31 +106,37 @@
/* ŻŻŻŻŻŻŻŻŻŻ
CONTROLLER_STATE buttons (joystate) = 0 or 1
CONTROLLER_MAPPING buttons (joystick) = 0 or 1, 2, 3, 4, a certain joypad button
- */
-struct CONTROLLER_STATE{ // GC PAD INFO/STATE
+ Please remember: The axis limit is hardcoded here, if you allow more axises (for
+ example for analog A and B buttons) you must first incrase the size of the axis array
+ size here
+ */
+struct CONTROLLER_STATE // GC PAD INFO/STATE
+{
int buttons[8]; // Amount of buttons (A B X Y Z, L-Trigger R-Trigger Start) might need to change the triggers buttons
- int dpad; // 1 HAT (8 directions + neutral)
- int dpad2[4]; // d-pad using buttons
- int axis[4]; // 2 x 2 Axes (Main & Sub)
- int halfpress; // ...
+ int dpad; // Automatic SDL D-Pad (8 directions + neutral)
+ int dpad2[4]; // D-pad using buttons
+ int axis[6]; // 2 x 2 Axes (Main & Sub)
+ int halfpress; // Halfpress... you know, like not fully pressed ;)...
SDL_Joystick *joy; // SDL joystick device
};
-struct CONTROLLER_MAPPING{ // GC PAD MAPPING
- int buttons[8]; // Amount of buttons (A B X Y Z, L-Trigger R-Trigger Start) might need to change the triggers buttons
- int dpad; // 1 HAT (8 directions + neutral)
- int dpad2[4]; // d-pad using buttons
- int axis[4]; // 2 x 2 Axes (Main & Sub)
+struct CONTROLLER_MAPPING // GC PAD MAPPING
+{
+ int buttons[8]; // (See above)
+ int dpad; // (See above)
+ int dpad2[4]; // (See above)
+ int axis[6]; // (See above)
+ int halfpress; // (See above)
int enabled; // Pad attached?
int deadzone; // Deadzone... what else?
- int halfpress; // Halfpress... you know, like not fully pressed ;)...
int ID; // SDL joystick device ID
int controllertype; // Joystick, Joystick with no hat or a keyboard (perhaps a mouse later)
int eventnum; // Linux Event Number, Can't be found dynamically yet
};
-struct CONTROLLER_INFO{ // CONNECTED WINDOWS DEVICES INFO
+struct CONTROLLER_INFO // CONNECTED WINDOWS DEVICES INFO
+{
int NumAxes; // Amount of Axes
int NumButtons; // Amount of Buttons
int NumBalls; // Amount of Balls
@@ -132,10 +148,11 @@ struct CONTROLLER_INFO{ // CONNECTED WINDOWS DEVICES INFO
enum
{
- CTL_MAIN_X = 0,
+ // CTL_L_SHOULDER and CTL_R_SHOULDER = 0 and 1
+ CTL_MAIN_X = 2,
CTL_MAIN_Y,
CTL_SUB_X,
- CTL_SUB_Y,
+ CTL_SUB_Y
};
enum
@@ -152,10 +169,8 @@ enum
enum
{
- CTL_TYPE_JOYSTICK = 0,
- CTL_TYPE_JOYSTICK_NO_HAT,
- CTL_TYPE_JOYSTICK_XBOX360,
- CTL_TYPE_KEYBOARD
+ CTL_DPAD_HAT = 0, // Automatically use the first hat that SDL finds
+ CTL_DPAD_CUSTOM // Custom directional pad settings
};
enum
@@ -166,6 +181,15 @@ enum
CTL_D_PAD_RIGHT
};
+// Button type for the configuration
+enum
+{
+ CTL_AXIS = 0,
+ CTL_HAT,
+ CTL_BUTTON,
+ CTL_KEY
+};
+
//////////////////////////////////////////////////////////////////////////////////////////
// Input vector. Todo: Save the configured keys here instead of in joystick
diff --git a/Source/Plugins/Plugin_nJoy_Testing/Src/nJoy.cpp b/Source/Plugins/Plugin_nJoy_Testing/Src/nJoy.cpp
index 90776a0330..2d1746b608 100644
--- a/Source/Plugins/Plugin_nJoy_Testing/Src/nJoy.cpp
+++ b/Source/Plugins/Plugin_nJoy_Testing/Src/nJoy.cpp
@@ -273,7 +273,7 @@ void DoState(unsigned char **ptr, int mode) {
// Set buttons status from wxWidgets in the main application
// ŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
-void PAD_Input(u8 _Key, u8 _UpDown) {}
+void PAD_Input(u16 _Key, u8 _UpDown) {}