Skip to content

Commit

Permalink
Do not spawn SDL_Gamepad mapping on known hidapi devices
Browse files Browse the repository at this point in the history
If a SDL_Joystick internal lookup manages to define a joystick
type that is not gamepad, it should stay as a joystick
  • Loading branch information
Kethen committed Dec 6, 2024
1 parent dac06e0 commit aff4f81
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/joystick/SDL_gamepad.c
Original file line number Diff line number Diff line change
Expand Up @@ -2572,7 +2572,12 @@ bool SDL_IsGamepad(SDL_JoystickID instance_id)
SDL_LockJoysticks();
{
const void *value;
if (SDL_FindInHashTable(s_gamepadInstanceIDs, (void *)(uintptr_t)instance_id, &value)) {
SDL_JoystickType js_type = SDL_GetJoystickTypeForID(instance_id);
if (js_type != SDL_JOYSTICK_TYPE_GAMEPAD && js_type != SDL_JOYSTICK_TYPE_UNKNOWN)
{
// avoid creating HIDAPI mapping if type is SDL_Joystick knows it is not a game pad
result = false;
} else if (SDL_FindInHashTable(s_gamepadInstanceIDs, (void *)(uintptr_t)instance_id, &value)) {
result = (bool)(uintptr_t)value;
} else {
if (SDL_PrivateGetGamepadMapping(instance_id, true) != NULL) {
Expand Down

0 comments on commit aff4f81

Please sign in to comment.