Skip to content

Commit aff4f81

Browse files
committed
Do not spawn SDL_Gamepad mapping on known hidapi devices
If a SDL_Joystick internal lookup manages to define a joystick type that is not gamepad, it should stay as a joystick
1 parent dac06e0 commit aff4f81

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/joystick/SDL_gamepad.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2572,7 +2572,12 @@ bool SDL_IsGamepad(SDL_JoystickID instance_id)
25722572
SDL_LockJoysticks();
25732573
{
25742574
const void *value;
2575-
if (SDL_FindInHashTable(s_gamepadInstanceIDs, (void *)(uintptr_t)instance_id, &value)) {
2575+
SDL_JoystickType js_type = SDL_GetJoystickTypeForID(instance_id);
2576+
if (js_type != SDL_JOYSTICK_TYPE_GAMEPAD && js_type != SDL_JOYSTICK_TYPE_UNKNOWN)
2577+
{
2578+
// avoid creating HIDAPI mapping if type is SDL_Joystick knows it is not a game pad
2579+
result = false;
2580+
} else if (SDL_FindInHashTable(s_gamepadInstanceIDs, (void *)(uintptr_t)instance_id, &value)) {
25762581
result = (bool)(uintptr_t)value;
25772582
} else {
25782583
if (SDL_PrivateGetGamepadMapping(instance_id, true) != NULL) {

0 commit comments

Comments
 (0)