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 75ff218c26d..c9af7cea1f0 100644 --- a/dlls/winebus.sys/bus.h +++ b/dlls/winebus.sys/bus.h @@ -34,6 +34,4 @@ 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; diff --git a/dlls/winebus.sys/bus_iohid.c b/dlls/winebus.sys/bus_iohid.c index 3df60a1b516..25accb0d86e 100644 --- a/dlls/winebus.sys/bus_iohid.c +++ b/dlls/winebus.sys/bus_iohid.c @@ -316,46 +316,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 78e74de842a..d650dd2ba3e 100644 --- a/dlls/winebus.sys/bus_udev.c +++ b/dlls/winebus.sys/bus_udev.c @@ -1138,6 +1138,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; @@ -1154,23 +1155,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 65385055729..c505ff3a1f0 100644 --- a/dlls/winebus.sys/main.c +++ b/dlls/winebus.sys/main.c @@ -1094,19 +1094,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;