Skip to content

Commit

Permalink
Check to make sure the Windows joystick device has buttons and axes
Browse files Browse the repository at this point in the history
This fixes incorrectly detecting the ROG CHAKRAM X mouse as a game controller on Windows 10
  • Loading branch information
slouken committed May 16, 2023
1 parent e2b7b9b commit 642504b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/joystick/windows/SDL_dinputjoystick.c
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ static BOOL CALLBACK EnumJoystickDetectCallback(LPCDIDEVICEINSTANCE pDeviceInsta
char *hidPath = NULL;
char *name = NULL;
LPDIRECTINPUTDEVICE8 device = NULL;
DIDEVCAPS caps;

/* We are only supporting HID devices. */
CHECK(pDeviceInstance->dwDevType & DIDEVTYPE_HID);
Expand All @@ -460,6 +461,13 @@ static BOOL CALLBACK EnumJoystickDetectCallback(LPCDIDEVICEINSTANCE pDeviceInsta
CHECK(QueryDevicePath(device, &hidPath));
CHECK(QueryDeviceInfo(device, &vendor, &product));

/* Check to make sure the device has buttons and axes.
* This fixes incorrectly detecting the ROG CHAKRAM X mouse as a game controller on Windows 10
*/
caps.dwSize = sizeof(caps);
CHECK(SUCCEEDED(IDirectInputDevice8_GetCapabilities(device, &caps)));
CHECK(caps.dwAxes > 0 && caps.dwButtons > 0);

CHECK(!SDL_IsXInputDevice(vendor, product, hidPath));

pNewJoystick = *(JoyStick_DeviceData **)pContext;
Expand Down

0 comments on commit 642504b

Please sign in to comment.