mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-03 08:28:29 +00:00
Fixed non-XBox controllers being detected as Series X controllers
First make sure we have an XBox One controller before checking whether it's a Series X/S controller.
This commit is contained in:
@@ -781,13 +781,7 @@ static GamepadMapping_t *SDL_CreateMappingForHIDAPIGamepad(SDL_GUID guid)
|
||||
// All other gamepads have the standard set of 19 buttons and 6 axes
|
||||
SDL_strlcat(mapping_string, "a:b0,b:b1,back:b4,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,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,", sizeof(mapping_string));
|
||||
|
||||
if (SDL_IsJoystickXboxSeriesX(vendor, product)) {
|
||||
// XBox Series X Controllers have a share button under the guide button
|
||||
SDL_strlcat(mapping_string, "misc1:b11,", sizeof(mapping_string));
|
||||
} else if (SDL_IsJoystickXboxOneElite(vendor, product)) {
|
||||
// XBox One Elite Controllers have 4 back paddle buttons
|
||||
SDL_strlcat(mapping_string, "paddle1:b11,paddle2:b13,paddle3:b12,paddle4:b14,", sizeof(mapping_string));
|
||||
} else if (SDL_IsJoystickSteamController(vendor, product)) {
|
||||
if (SDL_IsJoystickSteamController(vendor, product)) {
|
||||
// Steam controllers have 2 back paddle buttons
|
||||
SDL_strlcat(mapping_string, "paddle1:b12,paddle2:b11,", sizeof(mapping_string));
|
||||
} else if (SDL_IsJoystickNintendoSwitchPro(vendor, product) ||
|
||||
@@ -830,6 +824,15 @@ static GamepadMapping_t *SDL_CreateMappingForHIDAPIGamepad(SDL_GUID guid)
|
||||
SDL_strlcat(mapping_string, "paddle1:b16,paddle2:b15,paddle3:b14,paddle4:b13,", sizeof(mapping_string));
|
||||
}
|
||||
break;
|
||||
case SDL_GAMEPAD_TYPE_XBOXONE:
|
||||
if (SDL_IsJoystickXboxOneElite(vendor, product)) {
|
||||
// XBox One Elite Controllers have 4 back paddle buttons
|
||||
SDL_strlcat(mapping_string, "paddle1:b11,paddle2:b13,paddle3:b12,paddle4:b14,", sizeof(mapping_string));
|
||||
} else if (SDL_IsJoystickXboxSeriesX(vendor, product)) {
|
||||
// XBox Series X Controllers have a share button under the guide button
|
||||
SDL_strlcat(mapping_string, "misc1:b11,", sizeof(mapping_string));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (vendor == 0 && product == 0) {
|
||||
// This is a Bluetooth Nintendo Switch Pro controller
|
||||
|
Reference in New Issue
Block a user