Commit d48e2508 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

winebus: Add HID usages in the device descriptor when possible.

As a hint for the frontend to decide whether to use hidraw. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=56450
parent eac5ad2a
......@@ -276,18 +276,17 @@ static void handle_DeviceMatchingCallback(void *context, IOReturn result, void *
};
struct iohid_device *impl;
CFStringRef str;
UINT usage_page, usage;
usage_page = CFNumberToDWORD(IOHIDDeviceGetProperty(IOHIDDevice, CFSTR(kIOHIDPrimaryUsagePageKey)));
usage = CFNumberToDWORD(IOHIDDeviceGetProperty(IOHIDDevice, CFSTR(kIOHIDPrimaryUsageKey)));
desc.usages.UsagePage = CFNumberToDWORD(IOHIDDeviceGetProperty(IOHIDDevice, CFSTR(kIOHIDPrimaryUsagePageKey)));
desc.usages.Usage = CFNumberToDWORD(IOHIDDeviceGetProperty(IOHIDDevice, CFSTR(kIOHIDPrimaryUsageKey)));
desc.vid = CFNumberToDWORD(IOHIDDeviceGetProperty(IOHIDDevice, CFSTR(kIOHIDVendorIDKey)));
desc.pid = CFNumberToDWORD(IOHIDDeviceGetProperty(IOHIDDevice, CFSTR(kIOHIDProductIDKey)));
desc.version = CFNumberToDWORD(IOHIDDeviceGetProperty(IOHIDDevice, CFSTR(kIOHIDVersionNumberKey)));
desc.uid = CFNumberToDWORD(IOHIDDeviceGetProperty(IOHIDDevice, CFSTR(kIOHIDLocationIDKey)));
if (usage_page != HID_USAGE_PAGE_GENERIC ||
!(usage == HID_USAGE_GENERIC_JOYSTICK || usage == HID_USAGE_GENERIC_GAMEPAD))
if (desc.usages.UsagePage != HID_USAGE_PAGE_GENERIC ||
!(desc.usages.Usage == HID_USAGE_GENERIC_JOYSTICK || desc.usages.Usage == HID_USAGE_GENERIC_GAMEPAD))
{
/* winebus isn't currently meant to handle anything but these, and
* opening keyboards, mice, or the Touch Bar on older MacBooks triggers
......
......@@ -990,6 +990,8 @@ static void sdl_add_device(unsigned int index)
if (controller)
{
desc.is_gamepad = TRUE;
desc.usages.UsagePage = HID_USAGE_PAGE_GENERIC;
desc.usages.Usage = HID_USAGE_GENERIC_GAMEPAD;
axis_count = 6;
}
else
......@@ -997,6 +999,8 @@ static void sdl_add_device(unsigned int index)
int button_count = pSDL_JoystickNumButtons(joystick);
axis_count = pSDL_JoystickNumAxes(joystick);
desc.is_gamepad = (axis_count == 6 && button_count >= 14);
desc.usages.UsagePage = HID_USAGE_PAGE_GENERIC;
desc.usages.Usage = HID_USAGE_GENERIC_JOYSTICK;
}
for (axis_offset = 0; axis_offset < axis_count; axis_offset += (options.split_controllers ? 6 : axis_count))
......
......@@ -1332,6 +1332,7 @@ static void udev_add_device(struct udev_device *dev, int fd)
#ifdef HAS_PROPER_INPUT_HEADER
else if (!strcmp(subsystem, "input"))
{
const USAGE_AND_PAGE device_usage = *what_am_I(dev, fd);
static const WCHAR evdev[] = {'e','v','d','e','v',0};
struct input_id device_id = {0};
char buffer[MAX_PATH];
......@@ -1352,6 +1353,8 @@ static void udev_add_device(struct udev_device *dev, int fd)
if (!desc.serialnumber[0] && ioctl(fd, EVIOCGUNIQ(sizeof(buffer)), buffer) >= 0)
ntdll_umbstowcs(buffer, strlen(buffer) + 1, desc.serialnumber, ARRAY_SIZE(desc.serialnumber));
desc.usages = device_usage;
}
#endif
......
......@@ -25,6 +25,7 @@
#include <winbase.h>
#include <winternl.h>
#include <ddk/hidclass.h>
#include <ddk/hidpi.h>
#include <hidusage.h>
#include "wine/debug.h"
......@@ -37,6 +38,7 @@ struct device_desc
UINT version;
UINT input;
UINT uid;
USAGE_AND_PAGE usages;
BOOL is_gamepad;
BOOL is_hidraw;
......@@ -148,8 +150,9 @@ enum unix_funcs
static inline const char *debugstr_device_desc(struct device_desc *desc)
{
if (!desc) return "(null)";
return wine_dbg_sprintf("{vid %04x, pid %04x, version %04x, input %d, uid %08x, is_gamepad %u, is_hidraw %u}",
desc->vid, desc->pid, desc->version, desc->input, desc->uid, desc->is_gamepad, desc->is_hidraw);
return wine_dbg_sprintf("{vid %04x, pid %04x, version %04x, input %d, uid %08x, usage %04x:%04x, is_gamepad %u, is_hidraw %u}",
desc->vid, desc->pid, desc->version, desc->input, desc->uid, desc->usages.UsagePage, desc->usages.Usage,
desc->is_gamepad, desc->is_hidraw);
}
static inline BOOL is_xbox_gamepad(WORD vid, WORD pid)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment