diff --git a/VisualC/tests/controllermap/controllermap.vcxproj b/VisualC/tests/controllermap/controllermap.vcxproj index fedaf6cc8..f0eb15564 100644 --- a/VisualC/tests/controllermap/controllermap.vcxproj +++ b/VisualC/tests/controllermap/controllermap.vcxproj @@ -242,6 +242,24 @@ $(ProjectDir)\%(Filename)%(Extension);%(Outputs) Copying %(Filename)%(Extension) copy %(FullPath) $(ProjectDir)\ + + $(ProjectDir)\%(Filename)%(Extension);%(Outputs) + + + Copying %(Filename)%(Extension) + copy %(FullPath) $(ProjectDir)\ + + $(ProjectDir)\%(Filename)%(Extension);%(Outputs) + Copying %(Filename)%(Extension) + copy %(FullPath) $(ProjectDir)\ + + $(ProjectDir)\%(Filename)%(Extension);%(Outputs) + Copying %(Filename)%(Extension) + copy %(FullPath) $(ProjectDir)\ + + $(ProjectDir)\%(Filename)%(Extension);%(Outputs) + Copying %(Filename)%(Extension) + copy %(FullPath) $(ProjectDir)\ $(ProjectDir)\%(Filename)%(Extension);%(Outputs) @@ -252,4 +270,4 @@ - \ No newline at end of file + diff --git a/VisualC/tests/testgamecontroller/testgamecontroller.vcxproj b/VisualC/tests/testgamecontroller/testgamecontroller.vcxproj index 1b91b8774..54fcaa97f 100644 --- a/VisualC/tests/testgamecontroller/testgamecontroller.vcxproj +++ b/VisualC/tests/testgamecontroller/testgamecontroller.vcxproj @@ -242,6 +242,24 @@ $(ProjectDir)\%(Filename)%(Extension);%(Outputs) Copying %(Filename)%(Extension) copy %(FullPath) $(ProjectDir)\ + + $(ProjectDir)\%(Filename)%(Extension);%(Outputs) + + + Copying %(Filename)%(Extension) + copy %(FullPath) $(ProjectDir)\ + + $(ProjectDir)\%(Filename)%(Extension);%(Outputs) + Copying %(Filename)%(Extension) + copy %(FullPath) $(ProjectDir)\ + + $(ProjectDir)\%(Filename)%(Extension);%(Outputs) + Copying %(Filename)%(Extension) + copy %(FullPath) $(ProjectDir)\ + + $(ProjectDir)\%(Filename)%(Extension);%(Outputs) + Copying %(Filename)%(Extension) + copy %(FullPath) $(ProjectDir)\ $(ProjectDir)\%(Filename)%(Extension);%(Outputs) @@ -252,4 +270,4 @@ - \ No newline at end of file + diff --git a/Xcode-iOS/Test/TestiPhoneOS.xcodeproj/project.pbxproj b/Xcode-iOS/Test/TestiPhoneOS.xcodeproj/project.pbxproj index 952faf2ff..d437660dc 100644 --- a/Xcode-iOS/Test/TestiPhoneOS.xcodeproj/project.pbxproj +++ b/Xcode-iOS/Test/TestiPhoneOS.xcodeproj/project.pbxproj @@ -161,6 +161,9 @@ F3A499CD255618AF00E92A8B /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FDA8A89C0E2D111A00EA573E /* UIKit.framework */; }; F3A499CF255618AF00E92A8B /* hidapi.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = F3A492F32555E1F100E92A8B /* hidapi.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; F3A49A822556190000E92A8B /* controllermap.c in Sources */ = {isa = PBXBuildFile; fileRef = F3A49A4C255618DD00E92A8B /* controllermap.c */; }; + F3A49AFE2556A47500E92A8B /* controllermap_back.bmp in Resources */ = {isa = PBXBuildFile; fileRef = F3A49AFD2556A47500E92A8B /* controllermap_back.bmp */; }; + F3A49AFF2556A47500E92A8B /* controllermap_back.bmp in Resources */ = {isa = PBXBuildFile; fileRef = F3A49AFD2556A47500E92A8B /* controllermap_back.bmp */; }; + F3A49B002556A47500E92A8B /* controllermap_back.bmp in Resources */ = {isa = PBXBuildFile; fileRef = F3A49AFD2556A47500E92A8B /* controllermap_back.bmp */; }; F3F758D322AC561A001D97F2 /* libSDL2test.a in Frameworks */ = {isa = PBXBuildFile; fileRef = AA1EE452176059230029C7A5 /* libSDL2test.a */; }; F3F758D422AC575F001D97F2 /* Metal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AA2F57A91FDB544800832AD7 /* Metal.framework */; }; F3F758D522AC57D8001D97F2 /* Metal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AA2F57A91FDB544800832AD7 /* Metal.framework */; }; @@ -628,6 +631,7 @@ F3A499D3255618AF00E92A8B /* controllermap.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = controllermap.app; sourceTree = BUILT_PRODUCTS_DIR; }; F3A499D4255618AF00E92A8B /* testgamecontroller copy-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = "testgamecontroller copy-Info.plist"; path = "/Users/valve/projects/SDL/Xcode-iOS/Test/testgamecontroller copy-Info.plist"; sourceTree = ""; }; F3A49A4C255618DD00E92A8B /* controllermap.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = controllermap.c; sourceTree = ""; }; + F3A49AFD2556A47500E92A8B /* controllermap_back.bmp */ = {isa = PBXFileReference; lastKnownFileType = image.bmp; path = controllermap_back.bmp; sourceTree = ""; }; FA0EF2221BAF43DE000E07A6 /* testgamecontroller.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = testgamecontroller.c; sourceTree = ""; }; FA0EF2281BAF4487000E07A6 /* axis.bmp */ = {isa = PBXFileReference; lastKnownFileType = image.bmp; path = axis.bmp; sourceTree = ""; }; FA0EF2291BAF4487000E07A6 /* button.bmp */ = {isa = PBXFileReference; lastKnownFileType = image.bmp; path = button.bmp; sourceTree = ""; }; @@ -1439,6 +1443,7 @@ FA0EF2281BAF4487000E07A6 /* axis.bmp */, FA0EF2291BAF4487000E07A6 /* button.bmp */, FA0EF22A1BAF4487000E07A6 /* controllermap.bmp */, + F3A49AFD2556A47500E92A8B /* controllermap_back.bmp */, FDA8AAD90E2D33B000EA573E /* icon.bmp */, FDA8AADA0E2D33BA00EA573E /* moose.dat */, FDA8AADB0E2D33BA00EA573E /* picture.xbm */, @@ -2278,6 +2283,7 @@ buildActionMask = 2147483647; files = ( F3A499B9255618AF00E92A8B /* controllermap.bmp in Resources */, + F3A49AFE2556A47500E92A8B /* controllermap_back.bmp in Resources */, F3A499BA255618AF00E92A8B /* icon.bmp in Resources */, F3A499BB255618AF00E92A8B /* axis.bmp in Resources */, F3A499BC255618AF00E92A8B /* button.bmp in Resources */, @@ -2289,6 +2295,7 @@ buildActionMask = 2147483647; files = ( FA3D99521BC4E70C002C96C8 /* controllermap.bmp in Resources */, + F3A49B002556A47500E92A8B /* controllermap_back.bmp in Resources */, FA3D99541BC4E70F002C96C8 /* button.bmp in Resources */, FA3D99531BC4E70E002C96C8 /* axis.bmp in Resources */, FA3D99551BC4E712002C96C8 /* icon.bmp in Resources */, @@ -2315,6 +2322,7 @@ buildActionMask = 2147483647; files = ( FAE0E9961BAF9B650098DFA4 /* controllermap.bmp in Resources */, + F3A49AFF2556A47500E92A8B /* controllermap_back.bmp in Resources */, FAE0E9821BAF9B230098DFA4 /* icon.bmp in Resources */, FAE0E9981BAF9B6E0098DFA4 /* axis.bmp in Resources */, FAE0E9971BAF9B6A0098DFA4 /* button.bmp in Resources */, diff --git a/include/SDL_config_iphoneos.h b/include/SDL_config_iphoneos.h index e9cf01717..f3b74a637 100644 --- a/include/SDL_config_iphoneos.h +++ b/include/SDL_config_iphoneos.h @@ -137,7 +137,7 @@ #define SDL_HAPTIC_DUMMY 1 /* Enable MFi joystick support */ -/*#define SDL_JOYSTICK_HIDAPI 1*/ +#define SDL_JOYSTICK_HIDAPI 1 #define SDL_JOYSTICK_MFI 1 #define SDL_JOYSTICK_VIRTUAL 1 diff --git a/include/SDL_gamecontroller.h b/include/SDL_gamecontroller.h index 807d50dda..342d94fd3 100644 --- a/include/SDL_gamecontroller.h +++ b/include/SDL_gamecontroller.h @@ -363,10 +363,11 @@ typedef enum SDL_CONTROLLER_BUTTON_DPAD_DOWN, SDL_CONTROLLER_BUTTON_DPAD_LEFT, SDL_CONTROLLER_BUTTON_DPAD_RIGHT, - SDL_CONTROLLER_BUTTON_AUX1, // Xbox Elite paddle upper left, PS4/PS5 touchpad button, Nintendo Switch Pro capture button - SDL_CONTROLLER_BUTTON_AUX2, // Xbox Elite paddle upper right - SDL_CONTROLLER_BUTTON_AUX3, // Xbox Elite paddle lower left - SDL_CONTROLLER_BUTTON_AUX4, // Xbox Elite paddle lower right + SDL_CONTROLLER_BUTTON_MISC1, // Xbox Series X share button, PS4/PS5 touchpad button, Nintendo Switch Pro capture button + SDL_CONTROLLER_BUTTON_PADDLE1, // Xbox Elite paddle P1 + SDL_CONTROLLER_BUTTON_PADDLE2, // Xbox Elite paddle P3 + SDL_CONTROLLER_BUTTON_PADDLE3, // Xbox Elite paddle P2 + SDL_CONTROLLER_BUTTON_PADDLE4, // Xbox Elite paddle P4 SDL_CONTROLLER_BUTTON_MAX } SDL_GameControllerButton; diff --git a/src/joystick/SDL_gamecontroller.c b/src/joystick/SDL_gamecontroller.c index 4967ce583..b37f4c191 100644 --- a/src/joystick/SDL_gamecontroller.c +++ b/src/joystick/SDL_gamecontroller.c @@ -570,20 +570,20 @@ static ControllerMapping_t *SDL_CreateMappingForHIDAPIController(SDL_JoystickGUI if (SDL_IsJoystickXboxOneElite(vendor, product)) { /* XBox One Elite Controllers have 4 back paddle buttons */ - SDL_strlcat(mapping_string, "aux1:b15,aux2:b16,aux3:b17,aux4:b18,", sizeof(mapping_string)); + SDL_strlcat(mapping_string, "paddle1:b15,paddle2:b17,paddle3:b16,paddle4:b18,", sizeof(mapping_string)); } else if (SDL_IsJoystickSteamController(vendor, product)) { /* Steam controllers have 2 back paddle buttons */ - SDL_strlcat(mapping_string, "aux1:b15,aux2:b16,", sizeof(mapping_string)); + SDL_strlcat(mapping_string, "paddle1:b16,paddle2:b15,", sizeof(mapping_string)); } else { switch (SDL_GetJoystickGameControllerTypeFromGUID(guid, NULL)) { case SDL_CONTROLLER_TYPE_PS4: case SDL_CONTROLLER_TYPE_PS5: /* PS4/PS5 controllers have an additional touchpad button */ - SDL_strlcat(mapping_string, "aux1:b15,", sizeof(mapping_string)); + SDL_strlcat(mapping_string, "misc1:b15,", sizeof(mapping_string)); break; case SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO: /* Nintendo Switch Pro controllers have a screenshot button */ - SDL_strlcat(mapping_string, "aux1:b15,", sizeof(mapping_string)); + SDL_strlcat(mapping_string, "misc1:b15,", sizeof(mapping_string)); break; default: break; @@ -705,10 +705,11 @@ static const char* map_StringForControllerButton[] = { "dpdown", "dpleft", "dpright", - "aux1", - "aux2", - "aux3", - "aux4", + "misc1", + "paddle1", + "paddle2", + "paddle3", + "paddle4", NULL }; diff --git a/src/joystick/SDL_gamecontrollerdb.h b/src/joystick/SDL_gamecontrollerdb.h index 204c2bd55..fbfa0bc8a 100644 --- a/src/joystick/SDL_gamecontrollerdb.h +++ b/src/joystick/SDL_gamecontrollerdb.h @@ -701,13 +701,13 @@ static const char *s_ControllerMappings [] = "030000005e0400008e02000020200000,SpeedLink XEOX Pro Analog Gamepad pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "030000005e0400008e02000073050000,Speedlink TORID Wireless Gamepad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "03000000d11800000094000011010000,Stadia Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,", - "03000000de2800000112000001000000,Steam Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,", - "03000000de2800000211000001000000,Steam Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,", - "03000000de2800004211000001000000,Steam Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,", + "03000000de2800000112000001000000,Steam Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,paddle1:b11,paddle2:b10,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,", + "03000000de2800000211000001000000,Steam Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,paddle1:b11,paddle2:b10,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,", + "03000000de2800004211000001000000,Steam Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,paddle1:b11,paddle2:b10,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,", "03000000de280000fc11000001000000,Steam Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", - "05000000de2800000212000001000000,Steam Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,", - "05000000de2800000511000001000000,Steam Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,", - "05000000de2800000611000001000000,Steam Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,", + "05000000de2800000212000001000000,Steam Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,paddle1:b11,paddle2:b10,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,", + "05000000de2800000511000001000000,Steam Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,paddle1:b11,paddle2:b10,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,", + "05000000de2800000611000001000000,Steam Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,paddle1:b11,paddle2:b10,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,", "03000000de280000ff11000001000000,Steam Virtual Gamepad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "0500000011010000311400001b010000,SteelSeries Stratus Duo,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b32,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,", "03000000ad1b000038f0000090040000,Street Fighter IV FightStick TE,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", @@ -810,8 +810,6 @@ static const char *s_ControllerMappings [] = "050000003215000005070000ffff3f00,Razer Raiju Mobile,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,", "050000003215000007070000ffff3f00,Razer Raiju Mobile,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,", "050000003215000000090000bf7f3f00,Razer Serval,a:b0,b:b1,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,x:b2,y:b3,", - "05000000de2800000511000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,", - "05000000de2800000611000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,", "050000004f0400000ed00000fffe3f00,ThrustMaster eSwap PRO Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,", "050000005e040000fd020000ff7f3f00,Xbox One S Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,", "050000005e040000e00200000ffe3f00,Xbox One Wireless Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b3,leftstick:b15,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b16,righttrigger:a5,rightx:a3,righty:a4,start:b10,x:b17,y:b2,", @@ -829,11 +827,9 @@ static const char *s_ControllerMappings [] = "05000000ac050000020000004f066d02,*,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,leftshoulder:b4,rightshoulder:b5,x:b2,y:b3,", "050000004c050000cc090000df070000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b2,y:b3,", "050000004c050000cc090000ff070000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b10,x:b2,y:b3,", - "050000004c050000cc090000ff876d01,PS4 Controller,a:b0,aux1:b11,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b10,x:b2,y:b3,", + "050000004c050000cc090000ff876d01,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,misc1:b11,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b10,x:b2,y:b3,", "05000000ac0500000300000043006d03,Remote,a:b0,b:b2,leftx:a0,lefty:a1,", - "05000000de2800000511000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,", - "05000000de2800000611000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,", - "050000005e040000050b0000ff876d01,Xbox Elite Wireless Controller,a:b0,aux1:b11,aux2:b12,aux3:b13,aux4:b13,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b10,x:b2,y:b3,", + "050000005e040000050b0000ff876d01,Xbox Elite Wireless Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,paddle1:b11,paddle2:b13,paddle3:b12,paddle4:b13,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b10,x:b2,y:b3,", "050000005e040000e0020000df070000,Xbox Wireless Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b2,y:b3,", "050000005e040000e0020000ff070000,Xbox Wireless Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b10,x:b2,y:b3,", #endif diff --git a/src/joystick/android/SDL_sysjoystick.c b/src/joystick/android/SDL_sysjoystick.c index 23107f005..32fc1d82a 100644 --- a/src/joystick/android/SDL_sysjoystick.c +++ b/src/joystick/android/SDL_sysjoystick.c @@ -138,16 +138,16 @@ keycode_to_SDL(int keycode) button = SDL_CONTROLLER_BUTTON_GUIDE; break; case AKEYCODE_BUTTON_L2: - button = SDL_CONTROLLER_BUTTON_AUX1; + button = 15; break; case AKEYCODE_BUTTON_R2: - button = SDL_CONTROLLER_BUTTON_AUX2; + button = 16; break; case AKEYCODE_BUTTON_C: - button = SDL_CONTROLLER_BUTTON_AUX3; + button = 17; break; case AKEYCODE_BUTTON_Z: - button = SDL_CONTROLLER_BUTTON_AUX4; + button = 18; break; /* D-Pad key codes (API 1) */ @@ -165,7 +165,7 @@ keycode_to_SDL(int keycode) break; case AKEYCODE_DPAD_CENTER: /* This is handled better by applications as the A button */ - /*button = 19;*/ /* Not supported by GameController */ + /*button = 19;*/ button = SDL_CONTROLLER_BUTTON_A; break; diff --git a/src/joystick/hidapi/SDL_hidapi_steam.c b/src/joystick/hidapi/SDL_hidapi_steam.c index 8089b22e2..6e3bb0317 100644 --- a/src/joystick/hidapi/SDL_hidapi_steam.c +++ b/src/joystick/hidapi/SDL_hidapi_steam.c @@ -137,8 +137,8 @@ typedef struct SteamControllerStateInternal_t #define STEAM_BUTTON_RIGHTPAD_CLICKED_MASK 0x00040000 #define STEAM_LEFTPAD_FINGERDOWN_MASK 0x00080000 #define STEAM_RIGHTPAD_FINGERDOWN_MASK 0x00100000 -#define STEAM_JOYSTICK_BUTTON_MASK 0x00400000 -#define STEAM_LEFTPAD_AND_JOYSTICK_MASK 0x00800000 +#define STEAM_JOYSTICK_BUTTON_MASK 0x00400000 +#define STEAM_LEFTPAD_AND_JOYSTICK_MASK 0x00800000 // Look for report version 0x0001, type WIRELESS (3), length >= 1 byte @@ -1111,9 +1111,9 @@ HIDAPI_DriverSteam_UpdateDevice(SDL_HIDAPI_Device *device) SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_LEFTSTICK, (ctx->m_state.ulButtons & STEAM_JOYSTICK_BUTTON_MASK) ? SDL_PRESSED : SDL_RELEASED); - SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_AUX1, + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_MISC1 + 0, (ctx->m_state.ulButtons & STEAM_BUTTON_BACK_LEFT_MASK) ? SDL_PRESSED : SDL_RELEASED); - SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_AUX2, + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_MISC1 + 1, (ctx->m_state.ulButtons & STEAM_BUTTON_BACK_RIGHT_MASK) ? SDL_PRESSED : SDL_RELEASED); } { @@ -1186,7 +1186,7 @@ SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverSteam = HIDAPI_DriverSteam_SetJoystickLED, HIDAPI_DriverSteam_CloseJoystick, HIDAPI_DriverSteam_FreeDevice, - NULL + NULL }; #endif /* SDL_JOYSTICK_HIDAPI_STEAM */ diff --git a/src/joystick/hidapi/SDL_hidapi_switch.c b/src/joystick/hidapi/SDL_hidapi_switch.c index 32a298eea..80a560d93 100644 --- a/src/joystick/hidapi/SDL_hidapi_switch.c +++ b/src/joystick/hidapi/SDL_hidapi_switch.c @@ -964,7 +964,7 @@ static void HandleInputOnlyControllerState(SDL_Joystick *joystick, SDL_DriverSwi SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_LEFTSTICK, (data & 0x04) ? SDL_PRESSED : SDL_RELEASED); SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_RIGHTSTICK, (data & 0x08) ? SDL_PRESSED : SDL_RELEASED); SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_GUIDE, (data & 0x10) ? SDL_PRESSED : SDL_RELEASED); - SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_AUX1, (data & 0x20) ? SDL_PRESSED : SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_MISC1, (data & 0x20) ? SDL_PRESSED : SDL_RELEASED); } if (packet->ucStickHat != ctx->m_lastInputOnlyState.ucStickHat) { @@ -1063,7 +1063,7 @@ static void HandleSimpleControllerState(SDL_Joystick *joystick, SDL_DriverSwitch SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_LEFTSTICK, (data & 0x04) ? SDL_PRESSED : SDL_RELEASED); SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_RIGHTSTICK, (data & 0x08) ? SDL_PRESSED : SDL_RELEASED); SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_GUIDE, (data & 0x10) ? SDL_PRESSED : SDL_RELEASED); - SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_AUX1, (data & 0x20) ? SDL_PRESSED : SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_MISC1, (data & 0x20) ? SDL_PRESSED : SDL_RELEASED); } if (packet->ucStickHat != ctx->m_lastSimpleState.ucStickHat) { @@ -1148,7 +1148,7 @@ static void HandleFullControllerState(SDL_Joystick *joystick, SDL_DriverSwitch_C SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_LEFTSTICK, (data & 0x08) ? SDL_PRESSED : SDL_RELEASED); SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_GUIDE, (data & 0x10) ? SDL_PRESSED : SDL_RELEASED); - SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_AUX1, (data & 0x20) ? SDL_PRESSED : SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_MISC1, (data & 0x20) ? SDL_PRESSED : SDL_RELEASED); } if (packet->controllerState.rgucButtons[2] != ctx->m_lastFullState.controllerState.rgucButtons[2]) { diff --git a/src/joystick/hidapi/SDL_hidapi_xboxone.c b/src/joystick/hidapi/SDL_hidapi_xboxone.c index c60b9a1ff..5a82a1098 100644 --- a/src/joystick/hidapi/SDL_hidapi_xboxone.c +++ b/src/joystick/hidapi/SDL_hidapi_xboxone.c @@ -383,12 +383,12 @@ HIDAPI_DriverXboxOne_HandleStatePacket(SDL_Joystick *joystick, hid_device *dev, /* Xbox One S report is 18 bytes Xbox One Elite Series 1 report is 33 bytes, paddles in data[32], mode in data[32] & 0x10, both modes have mapped paddles by default Paddle bits: - UL: 0x01 (A) UR: 0x02 (B) - LL: 0x04 (X) LR: 0x08 (Y) + P3: 0x01 (A) P1: 0x02 (B) + P4: 0x04 (X) P2: 0x08 (Y) Xbox One Elite Series 2 report is 38 bytes, paddles in data[18], mode in data[19], mode 0 has no mapped paddles by default Paddle bits: - UL: 0x04 (A) UR: 0x01 (B) - LL: 0x08 (X) LR: 0x02 (Y) + P3: 0x04 (A) P1: 0x01 (B) + P4: 0x08 (X) P2: 0x02 (Y) */ if (ctx->has_paddles && (size == 33 || size == 38)) { int paddle_index; @@ -401,10 +401,10 @@ HIDAPI_DriverXboxOne_HandleStatePacket(SDL_Joystick *joystick, hid_device *dev, if (size == 33) { /* XBox One Elite Series 1 */ paddle_index = 32; - button1_bit = 0x01; - button2_bit = 0x02; - button3_bit = 0x04; - button4_bit = 0x08; + button1_bit = 0x02; + button2_bit = 0x08; + button3_bit = 0x01; + button4_bit = 0x04; /* The mapped controller state is at offset 4, the raw state is at offset 18, compare them to see if the paddles are mapped */ paddles_mapped = (SDL_memcmp(&data[4], &data[18], 14) != 0); @@ -412,10 +412,10 @@ HIDAPI_DriverXboxOne_HandleStatePacket(SDL_Joystick *joystick, hid_device *dev, } else /* if (size == 38) */ { /* XBox One Elite Series 2 */ paddle_index = 18; - button1_bit = 0x04; - button2_bit = 0x01; - button3_bit = 0x08; - button4_bit = 0x02; + button1_bit = 0x01; + button2_bit = 0x02; + button3_bit = 0x04; + button4_bit = 0x08; paddles_mapped = (data[19] != 0); } #ifdef DEBUG_XBOX_PROTOCOL @@ -434,10 +434,10 @@ HIDAPI_DriverXboxOne_HandleStatePacket(SDL_Joystick *joystick, hid_device *dev, } if (ctx->last_state[paddle_index] != data[paddle_index]) { - SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_AUX1, (data[paddle_index] & button1_bit) ? SDL_PRESSED : SDL_RELEASED); - SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_AUX2, (data[paddle_index] & button2_bit) ? SDL_PRESSED : SDL_RELEASED); - SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_AUX3, (data[paddle_index] & button3_bit) ? SDL_PRESSED : SDL_RELEASED); - SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_AUX4, (data[paddle_index] & button4_bit) ? SDL_PRESSED : SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_MISC1 + 0, (data[paddle_index] & button1_bit) ? SDL_PRESSED : SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_MISC1 + 1, (data[paddle_index] & button2_bit) ? SDL_PRESSED : SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_MISC1 + 2, (data[paddle_index] & button3_bit) ? SDL_PRESSED : SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_MISC1 + 3, (data[paddle_index] & button4_bit) ? SDL_PRESSED : SDL_RELEASED); } } diff --git a/src/joystick/iphoneos/SDL_sysjoystick.m b/src/joystick/iphoneos/SDL_sysjoystick.m index 960151728..732577a51 100644 --- a/src/joystick/iphoneos/SDL_sysjoystick.m +++ b/src/joystick/iphoneos/SDL_sysjoystick.m @@ -193,27 +193,27 @@ IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCController *controlle if ([controller respondsToSelector:@selector(physicalInputProfile)]) { if (controller.physicalInputProfile.buttons[GCInputDualShockTouchpadButton] != nil) { device->has_dualshock_touchpad = SDL_TRUE; - device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_AUX1); + device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_MISC1); ++nbuttons; } if (controller.physicalInputProfile.buttons[GCInputXboxPaddleOne] != nil) { device->has_xbox_paddles = SDL_TRUE; - device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_AUX1); + device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_PADDLE1); ++nbuttons; } if (controller.physicalInputProfile.buttons[GCInputXboxPaddleTwo] != nil) { device->has_xbox_paddles = SDL_TRUE; - device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_AUX2); + device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_PADDLE2); ++nbuttons; } if (controller.physicalInputProfile.buttons[GCInputXboxPaddleThree] != nil) { device->has_xbox_paddles = SDL_TRUE; - device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_AUX3); + device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_PADDLE3); ++nbuttons; } if (controller.physicalInputProfile.buttons[GCInputXboxPaddleFour] != nil) { device->has_xbox_paddles = SDL_TRUE; - device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_AUX4); + device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_PADDLE4); ++nbuttons; } } @@ -747,22 +747,20 @@ IOS_MFIJoystickUpdate(SDL_Joystick * joystick) #ifdef ENABLE_PHYSICAL_INPUT_PROFILE if (joystick->hwdata->has_dualshock_touchpad) { - if (joystick->hwdata->button_mask & (1 << SDL_CONTROLLER_BUTTON_AUX1)) { - buttons[button_count++] = controller.physicalInputProfile.buttons[GCInputDualShockTouchpadButton].isPressed; - } + buttons[button_count++] = controller.physicalInputProfile.buttons[GCInputDualShockTouchpadButton].isPressed; } if (joystick->hwdata->has_xbox_paddles) { - if (joystick->hwdata->button_mask & (1 << SDL_CONTROLLER_BUTTON_AUX1)) { + if (joystick->hwdata->button_mask & (1 << SDL_CONTROLLER_BUTTON_PADDLE1)) { buttons[button_count++] = controller.physicalInputProfile.buttons[GCInputXboxPaddleOne].isPressed; } - if (joystick->hwdata->button_mask & (1 << SDL_CONTROLLER_BUTTON_AUX2)) { + if (joystick->hwdata->button_mask & (1 << SDL_CONTROLLER_BUTTON_PADDLE2)) { buttons[button_count++] = controller.physicalInputProfile.buttons[GCInputXboxPaddleTwo].isPressed; } - if (joystick->hwdata->button_mask & (1 << SDL_CONTROLLER_BUTTON_AUX3)) { + if (joystick->hwdata->button_mask & (1 << SDL_CONTROLLER_BUTTON_PADDLE3)) { buttons[button_count++] = controller.physicalInputProfile.buttons[GCInputXboxPaddleThree].isPressed; } - if (joystick->hwdata->button_mask & (1 << SDL_CONTROLLER_BUTTON_AUX4)) { + if (joystick->hwdata->button_mask & (1 << SDL_CONTROLLER_BUTTON_PADDLE4)) { buttons[button_count++] = controller.physicalInputProfile.buttons[GCInputXboxPaddleFour].isPressed; } diff --git a/test/controllermap.bmp b/test/controllermap.bmp index df167f677..ee9629c2b 100644 Binary files a/test/controllermap.bmp and b/test/controllermap.bmp differ diff --git a/test/controllermap.c b/test/controllermap.c index 4642e5931..e5774c4d0 100644 --- a/test/controllermap.c +++ b/test/controllermap.c @@ -59,7 +59,7 @@ static struct { 342, 132, 0.0, MARKER_BUTTON }, /* SDL_CONTROLLER_BUTTON_X */ { 389, 101, 0.0, MARKER_BUTTON }, /* SDL_CONTROLLER_BUTTON_Y */ { 174, 132, 0.0, MARKER_BUTTON }, /* SDL_CONTROLLER_BUTTON_BACK */ - { 233, 132, 0.0, MARKER_BUTTON }, /* SDL_CONTROLLER_BUTTON_GUIDE */ + { 232, 128, 0.0, MARKER_BUTTON }, /* SDL_CONTROLLER_BUTTON_GUIDE */ { 289, 132, 0.0, MARKER_BUTTON }, /* SDL_CONTROLLER_BUTTON_START */ { 75, 154, 0.0, MARKER_BUTTON }, /* SDL_CONTROLLER_BUTTON_LEFTSTICK */ { 305, 230, 0.0, MARKER_BUTTON }, /* SDL_CONTROLLER_BUTTON_RIGHTSTICK */ @@ -69,10 +69,11 @@ static struct { 154, 249, 0.0, MARKER_BUTTON }, /* SDL_CONTROLLER_BUTTON_DPAD_DOWN */ { 116, 217, 0.0, MARKER_BUTTON }, /* SDL_CONTROLLER_BUTTON_DPAD_LEFT */ { 186, 217, 0.0, MARKER_BUTTON }, /* SDL_CONTROLLER_BUTTON_DPAD_RIGHT */ - { 158, 0, 0.0, MARKER_BUTTON }, /* SDL_CONTROLLER_BUTTON_AUX1 */ - { 208, 0, 0.0, MARKER_BUTTON }, /* SDL_CONTROLLER_BUTTON_AUX2 */ - { 258, 0, 0.0, MARKER_BUTTON }, /* SDL_CONTROLLER_BUTTON_AUX3 */ - { 308, 0, 0.0, MARKER_BUTTON }, /* SDL_CONTROLLER_BUTTON_AUX4 */ + { 232, 174, 0.0, MARKER_BUTTON }, /* SDL_CONTROLLER_BUTTON_MISC1 */ + { 132, 135, 0.0, MARKER_BUTTON }, /* SDL_CONTROLLER_BUTTON_PADDLE1 */ + { 330, 135, 0.0, MARKER_BUTTON }, /* SDL_CONTROLLER_BUTTON_PADDLE2 */ + { 132, 175, 0.0, MARKER_BUTTON }, /* SDL_CONTROLLER_BUTTON_PADDLE3 */ + { 330, 175, 0.0, MARKER_BUTTON }, /* SDL_CONTROLLER_BUTTON_PADDLE4 */ { 74, 153, 270.0, MARKER_AXIS }, /* SDL_CONTROLLER_BINDING_AXIS_LEFTX_NEGATIVE */ { 74, 153, 90.0, MARKER_AXIS }, /* SDL_CONTROLLER_BINDING_AXIS_LEFTX_POSITIVE */ { 74, 153, 0.0, MARKER_AXIS }, /* SDL_CONTROLLER_BINDING_AXIS_LEFTY_NEGATIVE */ @@ -111,10 +112,11 @@ static int s_arrBindingOrder[BINDING_COUNT] = { SDL_CONTROLLER_BUTTON_BACK, SDL_CONTROLLER_BUTTON_GUIDE, SDL_CONTROLLER_BUTTON_START, - SDL_CONTROLLER_BUTTON_AUX1, - SDL_CONTROLLER_BUTTON_AUX2, - SDL_CONTROLLER_BUTTON_AUX3, - SDL_CONTROLLER_BUTTON_AUX4, + SDL_CONTROLLER_BUTTON_MISC1, + SDL_CONTROLLER_BUTTON_PADDLE1, + SDL_CONTROLLER_BUTTON_PADDLE2, + SDL_CONTROLLER_BUTTON_PADDLE3, + SDL_CONTROLLER_BUTTON_PADDLE4, }; typedef struct @@ -364,7 +366,7 @@ static void WatchJoystick(SDL_Joystick * joystick) { SDL_Renderer *screen = NULL; - SDL_Texture *background, *button, *axis, *marker; + SDL_Texture *background_front, *background_back, *button, *axis, *marker; const char *name = NULL; SDL_Event event; SDL_Rect dst; @@ -378,7 +380,8 @@ WatchJoystick(SDL_Joystick * joystick) return; } - background = LoadTexture(screen, "controllermap.bmp", SDL_FALSE); + background_front = LoadTexture(screen, "controllermap.bmp", SDL_FALSE); + background_back = LoadTexture(screen, "controllermap_back.bmp", SDL_FALSE); button = LoadTexture(screen, "button.bmp", SDL_TRUE); axis = LoadTexture(screen, "axis.bmp", SDL_TRUE); SDL_RaiseWindow(window); @@ -445,7 +448,12 @@ WatchJoystick(SDL_Joystick * joystick) SDL_SetRenderDrawColor(screen, 0xFF, 0xFF, 0xFF, SDL_ALPHA_OPAQUE); SDL_RenderClear(screen); - SDL_RenderCopy(screen, background, NULL, NULL); + if (s_arrBindingOrder[s_iCurrentBinding] >= SDL_CONTROLLER_BUTTON_PADDLE1 && + s_arrBindingOrder[s_iCurrentBinding] <= SDL_CONTROLLER_BUTTON_PADDLE4) { + SDL_RenderCopy(screen, background_back, NULL, NULL); + } else { + SDL_RenderCopy(screen, background_front, NULL, NULL); + } SDL_SetTextureAlphaMod(marker, alpha); SDL_SetTextureColorMod(marker, 10, 255, 21); SDL_RenderCopyEx(screen, marker, NULL, &dst, s_arrBindingDisplay[iElement].angle, NULL, SDL_FLIP_NONE); diff --git a/test/controllermap_back.bmp b/test/controllermap_back.bmp new file mode 100644 index 000000000..bfaed6f02 Binary files /dev/null and b/test/controllermap_back.bmp differ diff --git a/test/testgamecontroller.c b/test/testgamecontroller.c index 0394e5c50..3d6a371b6 100644 --- a/test/testgamecontroller.c +++ b/test/testgamecontroller.c @@ -29,42 +29,43 @@ /* This is indexed by SDL_GameControllerButton. */ static const struct { int x; int y; } button_positions[] = { - {387, 167}, /* A */ - {431, 132}, /* B */ - {342, 132}, /* X */ - {389, 101}, /* Y */ - {174, 132}, /* BACK */ - {233, 132}, /* GUIDE */ - {289, 132}, /* START */ - {75, 154}, /* LEFTSTICK */ - {305, 230}, /* RIGHTSTICK */ - {77, 40}, /* LEFTSHOULDER */ - {396, 36}, /* RIGHTSHOULDER */ - {154, 188}, /* DPAD_UP */ - {154, 249}, /* DPAD_DOWN */ - {116, 217}, /* DPAD_LEFT */ - {186, 217}, /* DPAD_RIGHT */ - {158, 0}, /* AUX1 */ - {208, 0}, /* AUX2 */ - {258, 0}, /* AUX3 */ - {308, 0}, /* AUX4 */ + {387, 167}, /* SDL_CONTROLLER_BUTTON_A */ + {431, 132}, /* SDL_CONTROLLER_BUTTON_B */ + {342, 132}, /* SDL_CONTROLLER_BUTTON_X */ + {389, 101}, /* SDL_CONTROLLER_BUTTON_Y */ + {174, 132}, /* SDL_CONTROLLER_BUTTON_BACK */ + {232, 128}, /* SDL_CONTROLLER_BUTTON_GUIDE */ + {289, 132}, /* SDL_CONTROLLER_BUTTON_START */ + {75, 154}, /* SDL_CONTROLLER_BUTTON_LEFTSTICK */ + {305, 230}, /* SDL_CONTROLLER_BUTTON_RIGHTSTICK */ + {77, 40}, /* SDL_CONTROLLER_BUTTON_LEFTSHOULDER */ + {396, 36}, /* SDL_CONTROLLER_BUTTON_RIGHTSHOULDER */ + {154, 188}, /* SDL_CONTROLLER_BUTTON_DPAD_UP */ + {154, 249}, /* SDL_CONTROLLER_BUTTON_DPAD_DOWN */ + {116, 217}, /* SDL_CONTROLLER_BUTTON_DPAD_LEFT */ + {186, 217}, /* SDL_CONTROLLER_BUTTON_DPAD_RIGHT */ + {232, 174}, /* SDL_CONTROLLER_BUTTON_MISC1 */ + {132, 135}, /* SDL_CONTROLLER_BUTTON_PADDLE1 */ + {330, 135}, /* SDL_CONTROLLER_BUTTON_PADDLE2 */ + {132, 175}, /* SDL_CONTROLLER_BUTTON_PADDLE3 */ + {330, 175}, /* SDL_CONTROLLER_BUTTON_PADDLE4 */ }; /* This is indexed by SDL_GameControllerAxis. */ static const struct { int x; int y; double angle; } axis_positions[] = { {74, 153, 270.0}, /* LEFTX */ - {74, 153, 0.0}, /* LEFTY */ + {74, 153, 0.0}, /* LEFTY */ {306, 231, 270.0}, /* RIGHTX */ - {306, 231, 0.0}, /* RIGHTY */ - {91, -20, 0.0}, /* TRIGGERLEFT */ - {375, -20, 0.0}, /* TRIGGERRIGHT */ + {306, 231, 0.0}, /* RIGHTY */ + {91, -20, 0.0}, /* TRIGGERLEFT */ + {375, -20, 0.0}, /* TRIGGERRIGHT */ }; SDL_Window *window = NULL; SDL_Renderer *screen = NULL; SDL_bool retval = SDL_FALSE; SDL_bool done = SDL_FALSE; -SDL_Texture *background, *button, *axis; +SDL_Texture *background_front, *background_back, *button, *axis; SDL_GameController *gamecontroller; static SDL_Texture * @@ -118,11 +119,7 @@ loop(void *arg) { SDL_Event event; int i; - - /* blank screen, set up for drawing this frame. */ - SDL_SetRenderDrawColor(screen, 0xFF, 0xFF, 0xFF, SDL_ALPHA_OPAQUE); - SDL_RenderClear(screen); - SDL_RenderCopy(screen, background, NULL, NULL); + SDL_bool showing_front = SDL_TRUE; while (SDL_PollEvent(&event)) { switch (event.type) { @@ -169,26 +166,46 @@ loop(void *arg) } } + if (gamecontroller) { + /* Show the back of the controller if the paddles are being held */ + for (i = SDL_CONTROLLER_BUTTON_PADDLE1; i <= SDL_CONTROLLER_BUTTON_PADDLE4; ++i) { + if (SDL_GameControllerGetButton(gamecontroller, (SDL_GameControllerButton)i) == SDL_PRESSED) { + showing_front = SDL_FALSE; + break; + } + } + } + + /* blank screen, set up for drawing this frame. */ + SDL_SetRenderDrawColor(screen, 0xFF, 0xFF, 0xFF, SDL_ALPHA_OPAQUE); + SDL_RenderClear(screen); + SDL_RenderCopy(screen, showing_front ? background_front : background_back, NULL, NULL); + if (gamecontroller) { /* Update visual controller state */ for (i = 0; i < SDL_CONTROLLER_BUTTON_MAX; ++i) { if (SDL_GameControllerGetButton(gamecontroller, (SDL_GameControllerButton)i) == SDL_PRESSED) { - const SDL_Rect dst = { button_positions[i].x, button_positions[i].y, 50, 50 }; - SDL_RenderCopyEx(screen, button, NULL, &dst, 0, NULL, SDL_FLIP_NONE); + SDL_bool on_front = (i < SDL_CONTROLLER_BUTTON_PADDLE1 || i > SDL_CONTROLLER_BUTTON_PADDLE4); + if (on_front == showing_front) { + const SDL_Rect dst = { button_positions[i].x, button_positions[i].y, 50, 50 }; + SDL_RenderCopyEx(screen, button, NULL, &dst, 0, NULL, SDL_FLIP_NONE); + } } } - for (i = 0; i < SDL_CONTROLLER_AXIS_MAX; ++i) { - const Sint16 deadzone = 8000; /* !!! FIXME: real deadzone */ - const Sint16 value = SDL_GameControllerGetAxis(gamecontroller, (SDL_GameControllerAxis)(i)); - if (value < -deadzone) { - const SDL_Rect dst = { axis_positions[i].x, axis_positions[i].y, 50, 50 }; - const double angle = axis_positions[i].angle; - SDL_RenderCopyEx(screen, axis, NULL, &dst, angle, NULL, SDL_FLIP_NONE); - } else if (value > deadzone) { - const SDL_Rect dst = { axis_positions[i].x, axis_positions[i].y, 50, 50 }; - const double angle = axis_positions[i].angle + 180.0; - SDL_RenderCopyEx(screen, axis, NULL, &dst, angle, NULL, SDL_FLIP_NONE); + if (showing_front) { + for (i = 0; i < SDL_CONTROLLER_AXIS_MAX; ++i) { + const Sint16 deadzone = 8000; /* !!! FIXME: real deadzone */ + const Sint16 value = SDL_GameControllerGetAxis(gamecontroller, (SDL_GameControllerAxis)(i)); + if (value < -deadzone) { + const SDL_Rect dst = { axis_positions[i].x, axis_positions[i].y, 50, 50 }; + const double angle = axis_positions[i].angle; + SDL_RenderCopyEx(screen, axis, NULL, &dst, angle, NULL, SDL_FLIP_NONE); + } else if (value > deadzone) { + const SDL_Rect dst = { axis_positions[i].x, axis_positions[i].y, 50, 50 }; + const double angle = axis_positions[i].angle + 180.0; + SDL_RenderCopyEx(screen, axis, NULL, &dst, angle, NULL, SDL_FLIP_NONE); + } } } @@ -321,11 +338,12 @@ main(int argc, char *argv[]) /* scale for platforms that don't give you the window size you asked for. */ SDL_RenderSetLogicalSize(screen, SCREEN_WIDTH, SCREEN_HEIGHT); - background = LoadTexture(screen, "controllermap.bmp", SDL_FALSE); + background_front = LoadTexture(screen, "controllermap.bmp", SDL_FALSE); + background_back = LoadTexture(screen, "controllermap_back.bmp", SDL_FALSE); button = LoadTexture(screen, "button.bmp", SDL_TRUE); axis = LoadTexture(screen, "axis.bmp", SDL_TRUE); - if (!background || !button || !axis) { + if (!background_front || !background_back || !button || !axis) { SDL_DestroyRenderer(screen); SDL_DestroyWindow(window); return 2; @@ -346,10 +364,6 @@ main(int argc, char *argv[]) #endif SDL_DestroyRenderer(screen); - screen = NULL; - background = NULL; - button = NULL; - axis = NULL; SDL_DestroyWindow(window); SDL_QuitSubSystem(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER);