Skip to content

Commit fd37636

Browse files
authored
Fix GameController interface on Switch (#54)
1 parent d116109 commit fd37636

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

src/joystick/SDL_gamecontrollerdb.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -993,7 +993,7 @@ static const char *s_ControllerMappings[] = {
993993
"000000004e696e74656e646f20334400,Nintendo 3DS,crc:3210,a:b0,b:b1,back:b2,dpdown:b7,dpleft:b5,dpright:b4,dpup:b6,leftshoulder:b9,lefttrigger:b14,leftx:a0,lefty:a1,rightshoulder:b8,righttrigger:b15,rightx:a2,righty:a3,start:b3,x:b10,y:b11,",
994994
#endif
995995
#if defined(SDL_JOYSTICK_SWITCH)
996-
"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,",
996+
"000038f853776974636820436f6e7400,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,",
997997
#endif
998998
"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,",
999999
NULL

src/joystick/switch/SDL_sysjoystick.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,9 @@ static void SWITCH_JoystickSetDevicePlayerIndex(int device_index, int player_ind
201201
}
202202

203203
static SDL_JoystickGUID SWITCH_JoystickGetDeviceGUID(int device_index) {
204-
SDL_JoystickGUID guid;
205-
/* the GUID is just the first 16 chars of the name for now */
204+
/* the GUID is just the name for now */
206205
const char *name = SWITCH_JoystickGetDeviceName(device_index);
207-
SDL_zero(guid);
208-
SDL_memcpy(&guid, name, SDL_min(sizeof(guid), SDL_strlen(name)));
209-
return guid;
206+
return SDL_CreateJoystickGUIDForName(name);
210207
}
211208

212209
/* Function to perform the mapping from device index to the instance id for this index */

0 commit comments

Comments
 (0)