Skip to content

Commit 1ffc307

Browse files
committed
Do not spawn SDL_GameController mapping on known hidapi devices
If a SDL_Joystick internal lookup manages to define a joystick type that is not game controller, it should stay as a joystick
1 parent 16b2de2 commit 1ffc307

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/joystick/SDL_gamecontroller.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2065,7 +2065,12 @@ SDL_bool SDL_IsGameController(int joystick_index)
20652065

20662066
SDL_LockJoysticks();
20672067
{
2068-
if (SDL_PrivateGetControllerMapping(joystick_index) != NULL) {
2068+
SDL_JoystickType joystick_type = SDL_JoystickGetDeviceType(joystick_index);
2069+
/* do not spawn mappings on known hidapi joystick devices */
2070+
if (joystick_type != SDL_JOYSTICK_TYPE_GAMECONTROLLER &&
2071+
joystick_type != SDL_JOYSTICK_TYPE_UNKNOWN) {
2072+
retval = SDL_FALSE;
2073+
} else if (SDL_PrivateGetControllerMapping(joystick_index) != NULL) {
20692074
retval = SDL_TRUE;
20702075
} else {
20712076
retval = SDL_FALSE;

0 commit comments

Comments
 (0)