Switch Joy-Con SL and SR buttons are now mapped to matching paddle positions so that all buttons can be accessed when using SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS

This commit is contained in:
JibbSmart 2021-02-22 17:23:13 +08:00 committed by Sam Lantinga
parent 7a2b6f331b
commit ee52624f95
2 changed files with 16 additions and 1 deletions

View file

@ -612,6 +612,13 @@ static ControllerMapping_t *SDL_CreateMappingForHIDAPIController(SDL_JoystickGUI
case SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO:
/* Nintendo Switch Pro controllers have a screenshot button */
SDL_strlcat(mapping_string, "misc1:b15,", sizeof(mapping_string));
/* Joy-Cons have extra buttons in the same place as paddles */
if (SDL_IsJoystickNintendoSwitchJoyConLeft(vendor, product)) {
SDL_strlcat(mapping_string, "paddle2:b17,paddle4:b19,", sizeof(mapping_string));
}
else if (SDL_IsJoystickNintendoSwitchJoyConRight(vendor, product)) {
SDL_strlcat(mapping_string, "paddle1:b16,paddle3:b18,", sizeof(mapping_string));
}
break;
default:
if (vendor == 0 && product == 0) {