Skip to content

Commit

Permalink
Be explicit about mapping the new game controller paddle buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Nov 7, 2020
1 parent 3a43884 commit 009b62f
Show file tree
Hide file tree
Showing 16 changed files with 190 additions and 128 deletions.
20 changes: 19 additions & 1 deletion VisualC/tests/controllermap/controllermap.vcxproj
Expand Up @@ -242,6 +242,24 @@
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir)\%(Filename)%(Extension);%(Outputs)</Outputs>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Copying %(Filename)%(Extension)</Message>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">copy %(FullPath) $(ProjectDir)\
</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectDir)\%(Filename)%(Extension);%(Outputs)</Outputs>
</CustomBuild>
<CustomBuild Include="..\..\..\test\controllermap_back.bmp">
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Copying %(Filename)%(Extension)</Message>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">copy %(FullPath) $(ProjectDir)\
</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir)\%(Filename)%(Extension);%(Outputs)</Outputs>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Copying %(Filename)%(Extension)</Message>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">copy %(FullPath) $(ProjectDir)\
</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectDir)\%(Filename)%(Extension);%(Outputs)</Outputs>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Copying %(Filename)%(Extension)</Message>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">copy %(FullPath) $(ProjectDir)\
</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir)\%(Filename)%(Extension);%(Outputs)</Outputs>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Copying %(Filename)%(Extension)</Message>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">copy %(FullPath) $(ProjectDir)\
</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectDir)\%(Filename)%(Extension);%(Outputs)</Outputs>
</CustomBuild>
Expand All @@ -252,4 +270,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
20 changes: 19 additions & 1 deletion VisualC/tests/testgamecontroller/testgamecontroller.vcxproj
Expand Up @@ -242,6 +242,24 @@
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir)\%(Filename)%(Extension);%(Outputs)</Outputs>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Copying %(Filename)%(Extension)</Message>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">copy %(FullPath) $(ProjectDir)\
</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectDir)\%(Filename)%(Extension);%(Outputs)</Outputs>
</CustomBuild>
<CustomBuild Include="..\..\..\test\controllermap_back.bmp">
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Copying %(Filename)%(Extension)</Message>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">copy %(FullPath) $(ProjectDir)\
</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir)\%(Filename)%(Extension);%(Outputs)</Outputs>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Copying %(Filename)%(Extension)</Message>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">copy %(FullPath) $(ProjectDir)\
</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectDir)\%(Filename)%(Extension);%(Outputs)</Outputs>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Copying %(Filename)%(Extension)</Message>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">copy %(FullPath) $(ProjectDir)\
</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir)\%(Filename)%(Extension);%(Outputs)</Outputs>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Copying %(Filename)%(Extension)</Message>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">copy %(FullPath) $(ProjectDir)\
</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectDir)\%(Filename)%(Extension);%(Outputs)</Outputs>
</CustomBuild>
Expand All @@ -252,4 +270,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
8 changes: 8 additions & 0 deletions Xcode-iOS/Test/TestiPhoneOS.xcodeproj/project.pbxproj
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -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 = "<absolute>"; };
F3A49A4C255618DD00E92A8B /* controllermap.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = controllermap.c; sourceTree = "<group>"; };
F3A49AFD2556A47500E92A8B /* controllermap_back.bmp */ = {isa = PBXFileReference; lastKnownFileType = image.bmp; path = controllermap_back.bmp; sourceTree = "<group>"; };
FA0EF2221BAF43DE000E07A6 /* testgamecontroller.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = testgamecontroller.c; sourceTree = "<group>"; };
FA0EF2281BAF4487000E07A6 /* axis.bmp */ = {isa = PBXFileReference; lastKnownFileType = image.bmp; path = axis.bmp; sourceTree = "<group>"; };
FA0EF2291BAF4487000E07A6 /* button.bmp */ = {isa = PBXFileReference; lastKnownFileType = image.bmp; path = button.bmp; sourceTree = "<group>"; };
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -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 */,
Expand All @@ -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 */,
Expand All @@ -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 */,
Expand Down
2 changes: 1 addition & 1 deletion include/SDL_config_iphoneos.h
Expand Up @@ -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

Expand Down
9 changes: 5 additions & 4 deletions include/SDL_gamecontroller.h
Expand Up @@ -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;

Expand Down
17 changes: 9 additions & 8 deletions src/joystick/SDL_gamecontroller.c
Expand Up @@ -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;
Expand Down Expand Up @@ -705,10 +705,11 @@ static const char* map_StringForControllerButton[] = {
"dpdown",
"dpleft",
"dpright",
"aux1",
"aux2",
"aux3",
"aux4",
"misc1",
"paddle1",
"paddle2",
"paddle3",
"paddle4",
NULL
};

Expand Down

0 comments on commit 009b62f

Please sign in to comment.