Native XBox controllers should now be listed in winexinput.inf, and the axis or button checks should be enough to set the compatible id anyway.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/winebus.sys/bus.h | 2 -- dlls/winebus.sys/bus_iohid.c | 59 +++++++++++++++++------------------- dlls/winebus.sys/bus_udev.c | 13 ++------ dlls/winebus.sys/main.c | 13 -------- 4 files changed, 30 insertions(+), 57 deletions(-)
diff --git a/dlls/winebus.sys/bus.h b/dlls/winebus.sys/bus.h index 15238538328..6affb47c9ed 100644 --- a/dlls/winebus.sys/bus.h +++ b/dlls/winebus.sys/bus.h @@ -35,7 +35,5 @@ DEVICE_OBJECT *bus_find_hid_device(const WCHAR *bus_id, void *platform_dev) DECL void process_hid_report(DEVICE_OBJECT *device, BYTE *report, DWORD length) DECLSPEC_HIDDEN;
/* General Bus Functions */ -BOOL is_xbox_gamepad(WORD vid, WORD pid) DECLSPEC_HIDDEN; - extern HANDLE driver_key DECLSPEC_HIDDEN; extern DEVICE_OBJECT *bus_pdo DECLSPEC_HIDDEN; diff --git a/dlls/winebus.sys/bus_iohid.c b/dlls/winebus.sys/bus_iohid.c index 9a2a6f1ec8b..1e64bb52c17 100644 --- a/dlls/winebus.sys/bus_iohid.c +++ b/dlls/winebus.sys/bus_iohid.c @@ -317,46 +317,41 @@ static void handle_DeviceMatchingCallback(void *context, IOReturn result, void * if (IOHIDDeviceConformsTo(IOHIDDevice, kHIDPage_GenericDesktop, kHIDUsage_GD_GamePad) || IOHIDDeviceConformsTo(IOHIDDevice, kHIDPage_GenericDesktop, kHIDUsage_GD_Joystick)) { - if (is_xbox_gamepad(desc.vid, desc.pid)) - desc.is_gamepad = TRUE; - else - { - int axes=0, buttons=0; - CFArrayRef element_array = IOHIDDeviceCopyMatchingElements( - IOHIDDevice, NULL, kIOHIDOptionsTypeNone); - - if (element_array) { - CFIndex index; - CFIndex count = CFArrayGetCount(element_array); - for (index = 0; index < count; index++) + int axes=0, buttons=0; + CFArrayRef element_array = IOHIDDeviceCopyMatchingElements( + IOHIDDevice, NULL, kIOHIDOptionsTypeNone); + + if (element_array) { + CFIndex index; + CFIndex count = CFArrayGetCount(element_array); + for (index = 0; index < count; index++) + { + IOHIDElementRef element = (IOHIDElementRef)CFArrayGetValueAtIndex(element_array, index); + if (element) { - IOHIDElementRef element = (IOHIDElementRef)CFArrayGetValueAtIndex(element_array, index); - if (element) + int type = IOHIDElementGetType(element); + if (type == kIOHIDElementTypeInput_Button) buttons++; + if (type == kIOHIDElementTypeInput_Axis) axes++; + if (type == kIOHIDElementTypeInput_Misc) { - int type = IOHIDElementGetType(element); - if (type == kIOHIDElementTypeInput_Button) buttons++; - if (type == kIOHIDElementTypeInput_Axis) axes++; - if (type == kIOHIDElementTypeInput_Misc) + uint32_t usage = IOHIDElementGetUsage(element); + switch (usage) { - uint32_t usage = IOHIDElementGetUsage(element); - switch (usage) - { - case kHIDUsage_GD_X: - case kHIDUsage_GD_Y: - case kHIDUsage_GD_Z: - case kHIDUsage_GD_Rx: - case kHIDUsage_GD_Ry: - case kHIDUsage_GD_Rz: - case kHIDUsage_GD_Slider: - axes ++; - } + case kHIDUsage_GD_X: + case kHIDUsage_GD_Y: + case kHIDUsage_GD_Z: + case kHIDUsage_GD_Rx: + case kHIDUsage_GD_Ry: + case kHIDUsage_GD_Rz: + case kHIDUsage_GD_Slider: + axes ++; } } } - CFRelease(element_array); } - desc.is_gamepad = (axes == 6 && buttons >= 14); + CFRelease(element_array); } + desc.is_gamepad = (axes == 6 && buttons >= 14); }
TRACE("dev %p, desc %s.\n", IOHIDDevice, debugstr_device_desc(&desc)); diff --git a/dlls/winebus.sys/bus_udev.c b/dlls/winebus.sys/bus_udev.c index cca1bf5e168..f74cab0e505 100644 --- a/dlls/winebus.sys/bus_udev.c +++ b/dlls/winebus.sys/bus_udev.c @@ -1139,6 +1139,7 @@ static void udev_add_device(struct udev_device *dev) else if (!strcmp(subsystem, "input")) { struct input_id device_id = {0}; + int axes = 0, buttons = 0; char device_uid[255];
desc.busid = lnxev_busidW; @@ -1155,23 +1156,15 @@ static void udev_add_device(struct udev_device *dev) device_uid[0] = 0; if (ioctl(fd, EVIOCGUNIQ(254), device_uid) >= 0 && device_uid[0]) MultiByteToWideChar(CP_UNIXCP, 0, device_uid, -1, desc.serial, ARRAY_SIZE(desc.serial)); - } -#endif
- if (!desc.serial[0]) lstrcpyW(desc.serial, base_serial); - - if (is_xbox_gamepad(desc.vid, desc.pid)) - desc.is_gamepad = TRUE; -#ifdef HAS_PROPER_INPUT_HEADER - else - { - int axes=0, buttons=0; axes = count_abs_axis(fd); buttons = count_buttons(fd, NULL); desc.is_gamepad = (axes == 6 && buttons >= 14); } #endif
+ if (!desc.serial[0]) lstrcpyW(desc.serial, base_serial); + TRACE("dev %p, node %s, desc %s.\n", dev, debugstr_a(devnode), debugstr_device_desc(&desc));
if (strcmp(subsystem, "hidraw") == 0) diff --git a/dlls/winebus.sys/main.c b/dlls/winebus.sys/main.c index d6a16a9a0b2..aab4eb27a54 100644 --- a/dlls/winebus.sys/main.c +++ b/dlls/winebus.sys/main.c @@ -1090,19 +1090,6 @@ void process_hid_report(DEVICE_OBJECT *device, BYTE *report, DWORD length) LeaveCriticalSection(&ext->cs); }
-BOOL is_xbox_gamepad(WORD vid, WORD pid) -{ - int i; - - if (vid != VID_MICROSOFT) - return FALSE; - - for (i = 0; i < ARRAY_SIZE(XBOX_CONTROLLERS); i++) - if (pid == XBOX_CONTROLLERS[i].pid) return TRUE; - - return FALSE; -} - static NTSTATUS WINAPI driver_add_device(DRIVER_OBJECT *driver, DEVICE_OBJECT *pdo) { NTSTATUS ret;