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

winebus.sys: Pass USAGE_AND_PAGE to hid_device_begin_report_descriptor.

parent 9d2c868d
......@@ -229,6 +229,7 @@ static BOOL descriptor_add_haptic(struct sdl_device *impl)
static NTSTATUS build_joystick_report_descriptor(struct unix_device *iface)
{
const USAGE_AND_PAGE device_usage = {.UsagePage = HID_USAGE_PAGE_GENERIC, .Usage = HID_USAGE_GENERIC_JOYSTICK};
static const USAGE_AND_PAGE absolute_usages[] =
{
{.UsagePage = HID_USAGE_PAGE_GENERIC, .Usage = HID_USAGE_GENERIC_X},
......@@ -275,7 +276,7 @@ static NTSTATUS build_joystick_report_descriptor(struct unix_device *iface)
hat_count = pSDL_JoystickNumHats(impl->sdl_joystick);
button_count = pSDL_JoystickNumButtons(impl->sdl_joystick);
if (!hid_device_begin_report_descriptor(iface, HID_USAGE_PAGE_GENERIC, HID_USAGE_GENERIC_JOYSTICK))
if (!hid_device_begin_report_descriptor(iface, &device_usage))
return STATUS_NO_MEMORY;
if (!hid_device_begin_input_report(iface))
......@@ -321,6 +322,7 @@ static NTSTATUS build_joystick_report_descriptor(struct unix_device *iface)
static NTSTATUS build_controller_report_descriptor(struct unix_device *iface)
{
const USAGE_AND_PAGE device_usage = {.UsagePage = HID_USAGE_PAGE_GENERIC, .Usage = HID_USAGE_GENERIC_GAMEPAD};
static const USAGE left_axis_usages[] = {HID_USAGE_GENERIC_X, HID_USAGE_GENERIC_Y};
static const USAGE right_axis_usages[] = {HID_USAGE_GENERIC_RX, HID_USAGE_GENERIC_RY};
static const USAGE trigger_axis_usages[] = {HID_USAGE_GENERIC_Z, HID_USAGE_GENERIC_RZ};
......@@ -328,7 +330,7 @@ static NTSTATUS build_controller_report_descriptor(struct unix_device *iface)
ULONG i, button_count = SDL_CONTROLLER_BUTTON_MAX - 1;
C_ASSERT(SDL_CONTROLLER_AXIS_MAX == 6);
if (!hid_device_begin_report_descriptor(iface, HID_USAGE_PAGE_GENERIC, HID_USAGE_GENERIC_GAMEPAD))
if (!hid_device_begin_report_descriptor(iface, &device_usage))
return STATUS_NO_MEMORY;
if (!hid_device_begin_input_report(iface))
......
......@@ -555,16 +555,16 @@ static struct base_device *find_device_from_syspath(const char *path)
#define test_bit(arr,bit) (((BYTE*)(arr))[(bit)>>3]&(1<<((bit)&7)))
static const BYTE* what_am_I(struct udev_device *dev)
static const USAGE_AND_PAGE *what_am_I(struct udev_device *dev, int fd)
{
static const BYTE Unknown[2] = {HID_USAGE_PAGE_GENERIC, 0};
static const BYTE Mouse[2] = {HID_USAGE_PAGE_GENERIC, HID_USAGE_GENERIC_MOUSE};
static const BYTE Keyboard[2] = {HID_USAGE_PAGE_GENERIC, HID_USAGE_GENERIC_KEYBOARD};
static const BYTE Gamepad[2] = {HID_USAGE_PAGE_GENERIC, HID_USAGE_GENERIC_GAMEPAD};
static const BYTE Keypad[2] = {HID_USAGE_PAGE_GENERIC, HID_USAGE_GENERIC_KEYPAD};
static const BYTE Tablet[2] = {HID_USAGE_PAGE_DIGITIZER, HID_USAGE_DIGITIZER_PEN};
static const BYTE Touchscreen[2] = {HID_USAGE_PAGE_DIGITIZER, HID_USAGE_DIGITIZER_TOUCH_SCREEN};
static const BYTE Touchpad[2] = {HID_USAGE_PAGE_DIGITIZER, HID_USAGE_DIGITIZER_TOUCH_PAD};
static const USAGE_AND_PAGE Unknown = {.UsagePage = HID_USAGE_PAGE_GENERIC, .Usage = 0};
static const USAGE_AND_PAGE Mouse = {.UsagePage = HID_USAGE_PAGE_GENERIC, .Usage = HID_USAGE_GENERIC_MOUSE};
static const USAGE_AND_PAGE Keyboard = {.UsagePage = HID_USAGE_PAGE_GENERIC, .Usage = HID_USAGE_GENERIC_KEYBOARD};
static const USAGE_AND_PAGE Gamepad = {.UsagePage = HID_USAGE_PAGE_GENERIC, .Usage = HID_USAGE_GENERIC_GAMEPAD};
static const USAGE_AND_PAGE Keypad = {.UsagePage = HID_USAGE_PAGE_GENERIC, .Usage = HID_USAGE_GENERIC_KEYPAD};
static const USAGE_AND_PAGE Tablet = {.UsagePage = HID_USAGE_PAGE_DIGITIZER, .Usage = HID_USAGE_DIGITIZER_PEN};
static const USAGE_AND_PAGE Touchscreen = {.UsagePage = HID_USAGE_PAGE_DIGITIZER, .Usage = HID_USAGE_DIGITIZER_TOUCH_SCREEN};
static const USAGE_AND_PAGE Touchpad = {.UsagePage = HID_USAGE_PAGE_DIGITIZER, .Usage = HID_USAGE_DIGITIZER_TOUCH_PAD};
struct udev_device *parent = dev;
......@@ -572,23 +572,24 @@ static const BYTE* what_am_I(struct udev_device *dev)
while (parent)
{
if (udev_device_get_property_value(parent, "ID_INPUT_MOUSE"))
return Mouse;
return &Mouse;
else if (udev_device_get_property_value(parent, "ID_INPUT_KEYBOARD"))
return Keyboard;
return &Keyboard;
else if (udev_device_get_property_value(parent, "ID_INPUT_JOYSTICK"))
return Gamepad;
return &Gamepad;
else if (udev_device_get_property_value(parent, "ID_INPUT_KEY"))
return Keypad;
return &Keypad;
else if (udev_device_get_property_value(parent, "ID_INPUT_TOUCHPAD"))
return Touchpad;
return &Touchpad;
else if (udev_device_get_property_value(parent, "ID_INPUT_TOUCHSCREEN"))
return Touchscreen;
return &Touchscreen;
else if (udev_device_get_property_value(parent, "ID_INPUT_TABLET"))
return Tablet;
return &Tablet;
parent = udev_device_get_parent_with_subsystem_devtype(parent, "input", NULL);
}
return Unknown;
return &Unknown;
}
static INT count_buttons(int device_fd, BYTE *map)
......@@ -642,8 +643,8 @@ static NTSTATUS build_report_descriptor(struct unix_device *iface, struct udev_d
USHORT count = 0;
USAGE usages[16];
INT i, button_count, abs_count, rel_count, hat_count;
const BYTE *device_usage = what_am_I(dev);
struct lnxev_device *impl = lnxev_impl_from_unix_device(iface);
const USAGE_AND_PAGE device_usage = *what_am_I(dev, impl->base.device_fd);
if (ioctl(impl->base.device_fd, EVIOCGBIT(EV_REL, sizeof(relbits)), relbits) == -1)
{
......@@ -661,7 +662,7 @@ static NTSTATUS build_report_descriptor(struct unix_device *iface, struct udev_d
memset(ffbits, 0, sizeof(ffbits));
}
if (!hid_device_begin_report_descriptor(iface, device_usage[0], device_usage[1]))
if (!hid_device_begin_report_descriptor(iface, &device_usage))
return STATUS_NO_MEMORY;
if (!hid_device_begin_input_report(iface))
......
......@@ -74,15 +74,14 @@ static BOOL hid_report_descriptor_append_usage(struct hid_report_descriptor *des
return hid_report_descriptor_append(desc, template, sizeof(template));
}
BOOL hid_device_begin_report_descriptor(struct unix_device *iface, USAGE usage_page, USAGE usage)
BOOL hid_device_begin_report_descriptor(struct unix_device *iface, const USAGE_AND_PAGE *device_usage)
{
struct hid_report_descriptor *desc = &iface->hid_report_descriptor;
const BYTE template[] =
{
USAGE_PAGE(2, usage_page),
USAGE(2, usage),
USAGE_PAGE(2, device_usage->UsagePage),
USAGE(2, device_usage->Usage),
COLLECTION(1, Application),
USAGE(1, 0),
};
memset(desc, 0, sizeof(*desc));
......
......@@ -242,7 +242,7 @@ extern BOOL bus_event_queue_input_report(struct list *queue, struct unix_device
BYTE *report, USHORT length) DECLSPEC_HIDDEN;
extern BOOL bus_event_queue_pop(struct list *queue, struct bus_event *event) DECLSPEC_HIDDEN;
extern BOOL hid_device_begin_report_descriptor(struct unix_device *iface, USAGE usage_page, USAGE usage) DECLSPEC_HIDDEN;
extern BOOL hid_device_begin_report_descriptor(struct unix_device *iface, const USAGE_AND_PAGE *device_usage) DECLSPEC_HIDDEN;
extern BOOL hid_device_end_report_descriptor(struct unix_device *iface) DECLSPEC_HIDDEN;
extern BOOL hid_device_begin_input_report(struct unix_device *iface) DECLSPEC_HIDDEN;
......
......@@ -87,7 +87,8 @@ static void mouse_destroy(struct unix_device *iface)
static NTSTATUS mouse_start(struct unix_device *iface)
{
if (!hid_device_begin_report_descriptor(iface, HID_USAGE_PAGE_GENERIC, HID_USAGE_GENERIC_MOUSE))
const USAGE_AND_PAGE device_usage = {.UsagePage = HID_USAGE_PAGE_GENERIC, .Usage = HID_USAGE_GENERIC_MOUSE};
if (!hid_device_begin_report_descriptor(iface, &device_usage))
return STATUS_NO_MEMORY;
if (!hid_device_add_buttons(iface, HID_USAGE_PAGE_BUTTON, 1, 3))
return STATUS_NO_MEMORY;
......@@ -176,7 +177,8 @@ static void keyboard_destroy(struct unix_device *iface)
static NTSTATUS keyboard_start(struct unix_device *iface)
{
if (!hid_device_begin_report_descriptor(iface, HID_USAGE_PAGE_GENERIC, HID_USAGE_GENERIC_KEYBOARD))
const USAGE_AND_PAGE device_usage = {.UsagePage = HID_USAGE_PAGE_GENERIC, .Usage = HID_USAGE_GENERIC_KEYBOARD};
if (!hid_device_begin_report_descriptor(iface, &device_usage))
return STATUS_NO_MEMORY;
if (!hid_device_add_buttons(iface, HID_USAGE_PAGE_KEYBOARD, 0, 101))
return STATUS_NO_MEMORY;
......
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