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

winebus.sys: Use a physical collection for the HID input report.

parent e4105a71
...@@ -279,7 +279,7 @@ static NTSTATUS build_joystick_report_descriptor(struct unix_device *iface) ...@@ -279,7 +279,7 @@ static NTSTATUS build_joystick_report_descriptor(struct unix_device *iface)
if (!hid_device_begin_report_descriptor(iface, &device_usage)) if (!hid_device_begin_report_descriptor(iface, &device_usage))
return STATUS_NO_MEMORY; return STATUS_NO_MEMORY;
if (!hid_device_begin_input_report(iface)) if (!hid_device_begin_input_report(iface, &device_usage))
return STATUS_NO_MEMORY; return STATUS_NO_MEMORY;
for (i = 0; i < axis_count; i++) for (i = 0; i < axis_count; i++)
...@@ -333,7 +333,7 @@ static NTSTATUS build_controller_report_descriptor(struct unix_device *iface) ...@@ -333,7 +333,7 @@ static NTSTATUS build_controller_report_descriptor(struct unix_device *iface)
if (!hid_device_begin_report_descriptor(iface, &device_usage)) if (!hid_device_begin_report_descriptor(iface, &device_usage))
return STATUS_NO_MEMORY; return STATUS_NO_MEMORY;
if (!hid_device_begin_input_report(iface)) if (!hid_device_begin_input_report(iface, &device_usage))
return STATUS_NO_MEMORY; return STATUS_NO_MEMORY;
if (!hid_device_add_axes(iface, 2, HID_USAGE_PAGE_GENERIC, left_axis_usages, if (!hid_device_add_axes(iface, 2, HID_USAGE_PAGE_GENERIC, left_axis_usages,
......
...@@ -665,7 +665,7 @@ static NTSTATUS build_report_descriptor(struct unix_device *iface, struct udev_d ...@@ -665,7 +665,7 @@ static NTSTATUS build_report_descriptor(struct unix_device *iface, struct udev_d
if (!hid_device_begin_report_descriptor(iface, &device_usage)) if (!hid_device_begin_report_descriptor(iface, &device_usage))
return STATUS_NO_MEMORY; return STATUS_NO_MEMORY;
if (!hid_device_begin_input_report(iface)) if (!hid_device_begin_input_report(iface, &device_usage))
return STATUS_NO_MEMORY; return STATUS_NO_MEMORY;
abs_count = 0; abs_count = 0;
......
...@@ -74,23 +74,21 @@ static BOOL hid_report_descriptor_append_usage(struct hid_report_descriptor *des ...@@ -74,23 +74,21 @@ static BOOL hid_report_descriptor_append_usage(struct hid_report_descriptor *des
return hid_report_descriptor_append(desc, template, sizeof(template)); return hid_report_descriptor_append(desc, template, sizeof(template));
} }
BOOL hid_device_begin_report_descriptor(struct unix_device *iface, const USAGE_AND_PAGE *device_usage) static BOOL hid_device_begin_collection(struct hid_report_descriptor *desc, const USAGE_AND_PAGE *usage, BYTE type)
{ {
struct hid_report_descriptor *desc = &iface->hid_report_descriptor;
const BYTE template[] = const BYTE template[] =
{ {
USAGE_PAGE(2, device_usage->UsagePage), USAGE_PAGE(2, usage->UsagePage),
USAGE(2, device_usage->Usage), USAGE(2, usage->Usage),
COLLECTION(1, Application), COLLECTION(1, type),
}; };
memset(desc, 0, sizeof(*desc)); memset(desc, 0, sizeof(*desc));
return hid_report_descriptor_append(desc, template, sizeof(template)); return hid_report_descriptor_append(desc, template, sizeof(template));
} }
BOOL hid_device_end_report_descriptor(struct unix_device *iface) static BOOL hid_device_end_collection(struct hid_report_descriptor *desc)
{ {
struct hid_report_descriptor *desc = &iface->hid_report_descriptor;
static const BYTE template[] = static const BYTE template[] =
{ {
END_COLLECTION, END_COLLECTION,
...@@ -99,15 +97,27 @@ BOOL hid_device_end_report_descriptor(struct unix_device *iface) ...@@ -99,15 +97,27 @@ BOOL hid_device_end_report_descriptor(struct unix_device *iface)
return hid_report_descriptor_append(desc, template, sizeof(template)); return hid_report_descriptor_append(desc, template, sizeof(template));
} }
BOOL hid_device_begin_input_report(struct unix_device *iface) 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;
memset(desc, 0, sizeof(*desc));
return hid_device_begin_collection(desc, device_usage, Application);
}
BOOL hid_device_end_report_descriptor(struct unix_device *iface)
{
struct hid_report_descriptor *desc = &iface->hid_report_descriptor;
return hid_device_end_collection(desc);
}
BOOL hid_device_begin_input_report(struct unix_device *iface, const USAGE_AND_PAGE *physical_usage)
{ {
struct hid_report_descriptor *desc = &iface->hid_report_descriptor; struct hid_report_descriptor *desc = &iface->hid_report_descriptor;
struct hid_device_state *state = &iface->hid_device_state; struct hid_device_state *state = &iface->hid_device_state;
const BYTE report_id = ++desc->next_report_id[HidP_Input]; const BYTE report_id = ++desc->next_report_id[HidP_Input];
const BYTE template[] = const BYTE template[] =
{ {
COLLECTION(1, Report), REPORT_ID(1, report_id),
REPORT_ID(1, report_id),
}; };
if (state->report_len) if (state->report_len)
...@@ -118,6 +128,10 @@ BOOL hid_device_begin_input_report(struct unix_device *iface) ...@@ -118,6 +128,10 @@ BOOL hid_device_begin_input_report(struct unix_device *iface)
state->id = report_id; state->id = report_id;
state->bit_size += 8; state->bit_size += 8;
if (!hid_device_begin_collection(desc, physical_usage, Physical))
return FALSE;
return hid_report_descriptor_append(desc, template, sizeof(template)); return hid_report_descriptor_append(desc, template, sizeof(template));
} }
...@@ -125,10 +139,6 @@ BOOL hid_device_end_input_report(struct unix_device *iface) ...@@ -125,10 +139,6 @@ BOOL hid_device_end_input_report(struct unix_device *iface)
{ {
struct hid_report_descriptor *desc = &iface->hid_report_descriptor; struct hid_report_descriptor *desc = &iface->hid_report_descriptor;
struct hid_device_state *state = &iface->hid_device_state; struct hid_device_state *state = &iface->hid_device_state;
static const BYTE template[] =
{
END_COLLECTION,
};
state->report_len = (state->bit_size + 7) / 8; state->report_len = (state->bit_size + 7) / 8;
if (!(state->report_buf = calloc(1, state->report_len))) return FALSE; if (!(state->report_buf = calloc(1, state->report_len))) return FALSE;
...@@ -136,7 +146,7 @@ BOOL hid_device_end_input_report(struct unix_device *iface) ...@@ -136,7 +146,7 @@ BOOL hid_device_end_input_report(struct unix_device *iface)
state->report_buf[0] = state->id; state->report_buf[0] = state->id;
state->last_report_buf[0] = state->id; state->last_report_buf[0] = state->id;
return hid_report_descriptor_append(desc, template, sizeof(template)); return hid_device_end_collection(desc);
} }
static BOOL hid_device_add_button_count(struct unix_device *iface, BYTE count) static BOOL hid_device_add_button_count(struct unix_device *iface, BYTE count)
......
...@@ -245,7 +245,7 @@ extern BOOL bus_event_queue_pop(struct list *queue, struct bus_event *event) DEC ...@@ -245,7 +245,7 @@ extern BOOL bus_event_queue_pop(struct list *queue, struct bus_event *event) DEC
extern BOOL hid_device_begin_report_descriptor(struct unix_device *iface, const USAGE_AND_PAGE *device_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_end_report_descriptor(struct unix_device *iface) DECLSPEC_HIDDEN;
extern BOOL hid_device_begin_input_report(struct unix_device *iface) DECLSPEC_HIDDEN; extern BOOL hid_device_begin_input_report(struct unix_device *iface, const USAGE_AND_PAGE *physical_usage) DECLSPEC_HIDDEN;
extern BOOL hid_device_end_input_report(struct unix_device *iface) DECLSPEC_HIDDEN; extern BOOL hid_device_end_input_report(struct unix_device *iface) DECLSPEC_HIDDEN;
extern BOOL hid_device_add_buttons(struct unix_device *iface, USAGE usage_page, extern BOOL hid_device_add_buttons(struct unix_device *iface, USAGE usage_page,
USAGE usage_min, USAGE usage_max) DECLSPEC_HIDDEN; USAGE usage_min, USAGE usage_max) DECLSPEC_HIDDEN;
......
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