Module: wine Branch: master Commit: 2f41101b954b7c7d021f133f53702e6e463b8a34 URL: https://source.winehq.org/git/wine.git/?a=commit;h=2f41101b954b7c7d021f133f5...
Author: Rémi Bernon rbernon@codeweavers.com Date: Tue Feb 22 13:04:29 2022 +0100
winebus.sys: Link the first two absolute axes to the effect directions.
And use the same usages as for the axes themselves instead of generic HID usages.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/winebus.sys/hid.c | 22 +++++++++++++++++----- dlls/winebus.sys/unix_private.h | 2 ++ 2 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/dlls/winebus.sys/hid.c b/dlls/winebus.sys/hid.c index df648a2019a..8d34fc86e63 100644 --- a/dlls/winebus.sys/hid.c +++ b/dlls/winebus.sys/hid.c @@ -235,10 +235,11 @@ BOOL hid_device_add_hatswitch(struct unix_device *iface, INT count) return hid_report_descriptor_append(desc, template, sizeof(template)); }
-static BOOL hid_device_add_axis_count(struct unix_device *iface, BOOL rel, BYTE count) +static BOOL hid_device_add_axis_count(struct unix_device *iface, BOOL rel, BYTE count, + USAGE usage_page, const USAGE *usages) { struct hid_device_state *state = &iface->hid_device_state; - USHORT offset = state->bit_size / 8; + USHORT i, offset = state->bit_size / 8;
if (!rel && state->rel_axis_count) ERR("absolute axes should be added before relative axes!\n"); @@ -257,6 +258,17 @@ static BOOL hid_device_add_axis_count(struct unix_device *iface, BOOL rel, BYTE } else { + if (state->abs_axis_count + count > ARRAY_SIZE(state->abs_axis_usages)) + { + ERR("absolute axis usage overflow, too many elements!\n"); + return FALSE; + } + for (i = 0; i < count; ++i) + { + state->abs_axis_usages[state->abs_axis_count + i].UsagePage = usage_page; + state->abs_axis_usages[state->abs_axis_count + i].Usage = usages[i]; + } + if (!state->abs_axis_count) state->abs_axis_start = offset; state->abs_axis_count += count; state->bit_size += 32 * count; @@ -289,7 +301,7 @@ BOOL hid_device_add_axes(struct unix_device *iface, BYTE count, USAGE usage_page }; int i;
- if (!hid_device_add_axis_count(iface, rel, count)) + if (!hid_device_add_axis_count(iface, rel, count, usage_page, usages)) return FALSE;
if (!hid_report_descriptor_append(desc, template_begin, sizeof(template_begin))) @@ -872,8 +884,8 @@ BOOL hid_device_add_physical(struct unix_device *iface, USAGE *usages, USHORT co
USAGE(1, PID_USAGE_AXES_ENABLE), COLLECTION(1, Logical), - USAGE(4, (HID_USAGE_PAGE_GENERIC<<16)|HID_USAGE_GENERIC_X), - USAGE(4, (HID_USAGE_PAGE_GENERIC<<16)|HID_USAGE_GENERIC_Y), + USAGE(4, (state->abs_axis_usages[0].UsagePage<<16)|state->abs_axis_usages[0].Usage), + USAGE(4, (state->abs_axis_usages[1].UsagePage<<16)|state->abs_axis_usages[1].Usage), LOGICAL_MINIMUM(1, 0), LOGICAL_MAXIMUM(1, 1), REPORT_SIZE(1, 1), diff --git a/dlls/winebus.sys/unix_private.h b/dlls/winebus.sys/unix_private.h index 04545b7eb98..3c37f219a4b 100644 --- a/dlls/winebus.sys/unix_private.h +++ b/dlls/winebus.sys/unix_private.h @@ -24,6 +24,7 @@ #include <windef.h> #include <winbase.h> #include <winternl.h> +#include <ddk/hidsdi.h>
#include "unixlib.h"
@@ -189,6 +190,7 @@ struct hid_physical struct hid_device_state { ULONG bit_size; + USAGE_AND_PAGE abs_axis_usages[32]; USHORT abs_axis_start; USHORT abs_axis_count; USHORT rel_axis_start;