mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-28 05:58:29 +00:00
Check to make sure the Windows joystick device has buttons and axes
This fixes incorrectly detecting the ROG CHAKRAM X mouse as a game controller on Windows 10
(cherry picked from commit 642504bc59
)
This commit is contained in:
@@ -453,6 +453,7 @@ static BOOL CALLBACK EnumJoystickDetectCallback(LPCDIDEVICEINSTANCE pDeviceInsta
|
|||||||
char *hidPath = NULL;
|
char *hidPath = NULL;
|
||||||
char *name = NULL;
|
char *name = NULL;
|
||||||
LPDIRECTINPUTDEVICE8 device = NULL;
|
LPDIRECTINPUTDEVICE8 device = NULL;
|
||||||
|
DIDEVCAPS caps;
|
||||||
|
|
||||||
/* We are only supporting HID devices. */
|
/* We are only supporting HID devices. */
|
||||||
CHECK(pDeviceInstance->dwDevType & DIDEVTYPE_HID);
|
CHECK(pDeviceInstance->dwDevType & DIDEVTYPE_HID);
|
||||||
@@ -462,6 +463,13 @@ static BOOL CALLBACK EnumJoystickDetectCallback(LPCDIDEVICEINSTANCE pDeviceInsta
|
|||||||
CHECK(QueryDevicePath(device, &hidPath));
|
CHECK(QueryDevicePath(device, &hidPath));
|
||||||
CHECK(QueryDeviceInfo(device, &vendor, &product));
|
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));
|
CHECK(!SDL_IsXInputDevice(vendor, product, hidPath));
|
||||||
|
|
||||||
pNewJoystick = *(JoyStick_DeviceData **)pContext;
|
pNewJoystick = *(JoyStick_DeviceData **)pContext;
|
||||||
|
Reference in New Issue
Block a user