From abf3a5b7ed3897165c8a6b731e268146187859bf Mon Sep 17 00:00:00 2001 From: Cpasjuste Date: Fri, 30 Mar 2018 01:04:30 +0200 Subject: [PATCH] switch: add game controller support --- src/joystick/SDL_gamecontrollerdb.h | 4 ++++ src/joystick/switch/SDL_sysjoystick.c | 19 +------------------ 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/src/joystick/SDL_gamecontrollerdb.h b/src/joystick/SDL_gamecontrollerdb.h index e032bdede..3a12e02e0 100644 --- a/src/joystick/SDL_gamecontrollerdb.h +++ b/src/joystick/SDL_gamecontrollerdb.h @@ -846,6 +846,10 @@ static const char *s_ControllerMappings [] = #if defined(SDL_JOYSTICK_EMSCRIPTEN) "default,Standard Gamepad,a:b0,b:b1,back:b8,dpdown:b13,dpleft:b14,dpright:b15,dpup:b12,guide:b16,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,", #endif +#if defined(SDL_JOYSTICK_SWITCH) + "53776974636820436F6E74726F6C6C65,Switch Controller,a:b1,b:b0,back:b11,dpdown:b15,dpleft:b12,dpright:b14,dpup:b13,leftshoulder:b6,leftstick:b4,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b5,righttrigger:b9,rightx:a2,righty:a3,start:b10,x:b3,y:b2,", +#endif + "hidapi,*,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,", NULL }; diff --git a/src/joystick/switch/SDL_sysjoystick.c b/src/joystick/switch/SDL_sysjoystick.c index 6a9cc5764..7fdbe3d66 100644 --- a/src/joystick/switch/SDL_sysjoystick.c +++ b/src/joystick/switch/SDL_sysjoystick.c @@ -91,24 +91,7 @@ SDL_SYS_JoystickDetect(void) const char * SDL_SYS_JoystickNameForDeviceIndex(int device_index) { - if (device_index == 1) - return "Switch Controller #1"; - if (device_index == 2) - return "Switch Controller #2"; - if (device_index == 3) - return "Switch Controller #3"; - if (device_index == 4) - return "Switch Controller #4"; - if (device_index == 5) - return "Switch Controller #5"; - if (device_index == 6) - return "Switch Controller #6"; - if (device_index == 7) - return "Switch Controller #7"; - if (device_index == 8) - return "Switch Controller #8"; - - return "Switch Controller #0"; + return "Switch Controller"; } /* Function to perform the mapping from device index to the instance id for this index */