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

winebus.sys: Fix HID haptics waveform NONE / STOP ordinals.

There's some inconsistencies between the HID 1.22 specification and HID usage names in Windows SDK headers. The headers use STOP for the 0x1001 usage name, and NULL for 0x1002, where the HID spec uses None for the 0x1001 usage name and Stop for 0x1002. Both are implicit waveforms anyway, and the HID usages aren't really used anywhere, but their ordinal matters. The HID spec says that None has ordinal 1, and Stop ordinal 2, and that Stop waveform can be used to stop any previously started waveform. We are going to stick to that and ignore the HID usages, although the names won't match the usages. Signed-off-by: 's avatarRémi Bernon <rbernon@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent db456c94
......@@ -323,26 +323,22 @@ BOOL hid_device_add_haptics(struct unix_device *iface)
USAGE(1, HID_USAGE_HAPTICS_WAVEFORM_LIST),
COLLECTION(1, NamedArray),
USAGE_PAGE(1, HID_USAGE_PAGE_ORDINAL),
USAGE(1, 3), /* HID_USAGE_HAPTICS_WAVEFORM_RUMBLE */
USAGE(1, 4), /* HID_USAGE_HAPTICS_WAVEFORM_BUZZ */
USAGE(4, (HID_USAGE_PAGE_ORDINAL<<16)|HAPTICS_WAVEFORM_RUMBLE_ORDINAL), /* HID_USAGE_HAPTICS_WAVEFORM_RUMBLE */
USAGE(4, (HID_USAGE_PAGE_ORDINAL<<16)|HAPTICS_WAVEFORM_BUZZ_ORDINAL), /* HID_USAGE_HAPTICS_WAVEFORM_BUZZ */
REPORT_COUNT(1, 2),
REPORT_SIZE(1, 16),
FEATURE(1, Data|Var|Abs|Null),
END_COLLECTION,
USAGE_PAGE(2, HID_USAGE_PAGE_HAPTICS),
USAGE(1, HID_USAGE_HAPTICS_DURATION_LIST),
COLLECTION(1, NamedArray),
USAGE_PAGE(1, HID_USAGE_PAGE_ORDINAL),
USAGE(1, 3), /* 0 (HID_USAGE_HAPTICS_WAVEFORM_RUMBLE) */
USAGE(1, 4), /* 0 (HID_USAGE_HAPTICS_WAVEFORM_BUZZ) */
USAGE(4, (HID_USAGE_PAGE_ORDINAL<<16)|HAPTICS_WAVEFORM_RUMBLE_ORDINAL), /* 0 (HID_USAGE_HAPTICS_WAVEFORM_RUMBLE) */
USAGE(4, (HID_USAGE_PAGE_ORDINAL<<16)|HAPTICS_WAVEFORM_BUZZ_ORDINAL), /* 0 (HID_USAGE_HAPTICS_WAVEFORM_BUZZ) */
REPORT_COUNT(1, 2),
REPORT_SIZE(1, 16),
FEATURE(1, Data|Var|Abs|Null),
END_COLLECTION,
USAGE_PAGE(2, HID_USAGE_PAGE_HAPTICS),
USAGE(1, HID_USAGE_HAPTICS_WAVEFORM_CUTOFF_TIME),
UNIT(2, 0x1001), /* seconds */
UNIT_EXPONENT(1, -3), /* 10^-3 */
......@@ -1042,18 +1038,18 @@ static void hid_device_set_output_report(struct unix_device *iface, HID_XFER_PAC
if (packet->reportId == haptics->waveform_report)
{
struct hid_haptics_waveform *waveform = (struct hid_haptics_waveform *)(packet->reportBuffer + 1);
struct hid_haptics_waveform *rumble = haptics->waveforms + HAPTICS_WAVEFORM_RUMBLE_INDEX;
struct hid_haptics_waveform *buzz = haptics->waveforms + HAPTICS_WAVEFORM_BUZZ_INDEX;
struct hid_haptics_waveform *rumble = haptics->waveforms + HAPTICS_WAVEFORM_RUMBLE_ORDINAL;
struct hid_haptics_waveform *buzz = haptics->waveforms + HAPTICS_WAVEFORM_BUZZ_ORDINAL;
ULONG duration_ms;
io->Information = sizeof(*waveform) + 1;
assert(packet->reportBufferLen == io->Information);
if (waveform->manual_trigger == 0 || waveform->manual_trigger > HAPTICS_WAVEFORM_LAST_INDEX)
if (waveform->manual_trigger == 0 || waveform->manual_trigger > HAPTICS_WAVEFORM_LAST_ORDINAL)
io->Status = STATUS_INVALID_PARAMETER;
else
{
if (waveform->manual_trigger == HAPTICS_WAVEFORM_STOP_INDEX)
if (waveform->manual_trigger == HAPTICS_WAVEFORM_STOP_ORDINAL)
memset(haptics->waveforms, 0, sizeof(haptics->waveforms));
else
haptics->waveforms[waveform->manual_trigger] = *waveform;
......
......@@ -121,19 +121,25 @@ struct hid_report_descriptor
BYTE next_report_id[3];
};
enum haptics_waveform_index
/* HID spec uses None / Stop names for the first two implicit waveforms,
* where Windows SDK headers use STOP / NULL for the corresponding HID
* usage constants. We're not actually using the usages anyway are we
* stick to the HID spec here.
*/
enum haptics_waveform_ordinal
{
HAPTICS_WAVEFORM_STOP_INDEX = 1,
HAPTICS_WAVEFORM_NULL_INDEX = 2,
HAPTICS_WAVEFORM_RUMBLE_INDEX = 3,
HAPTICS_WAVEFORM_BUZZ_INDEX = 4,
HAPTICS_WAVEFORM_LAST_INDEX = HAPTICS_WAVEFORM_BUZZ_INDEX,
HAPTICS_WAVEFORM_NONE_ORDINAL = 1, /* implicit, not included in waveform_list / duration_list */
HAPTICS_WAVEFORM_STOP_ORDINAL = 2, /* implicit, not included in waveform_list / duration_list */
HAPTICS_WAVEFORM_RUMBLE_ORDINAL = 3,
HAPTICS_WAVEFORM_BUZZ_ORDINAL = 4,
HAPTICS_WAVEFORM_FIRST_ORDINAL = HAPTICS_WAVEFORM_RUMBLE_ORDINAL,
HAPTICS_WAVEFORM_LAST_ORDINAL = HAPTICS_WAVEFORM_BUZZ_ORDINAL,
};
struct hid_haptics_features
{
WORD waveform_list[HAPTICS_WAVEFORM_LAST_INDEX - HAPTICS_WAVEFORM_NULL_INDEX];
WORD duration_list[HAPTICS_WAVEFORM_LAST_INDEX - HAPTICS_WAVEFORM_NULL_INDEX];
WORD waveform_list[HAPTICS_WAVEFORM_LAST_ORDINAL - HAPTICS_WAVEFORM_FIRST_ORDINAL + 1];
WORD duration_list[HAPTICS_WAVEFORM_LAST_ORDINAL - HAPTICS_WAVEFORM_FIRST_ORDINAL + 1];
UINT waveform_cutoff_time_ms;
};
......@@ -146,7 +152,7 @@ struct hid_haptics_waveform
struct hid_haptics
{
struct hid_haptics_features features;
struct hid_haptics_waveform waveforms[HAPTICS_WAVEFORM_LAST_INDEX + 1];
struct hid_haptics_waveform waveforms[HAPTICS_WAVEFORM_LAST_ORDINAL + 1];
BYTE features_report;
BYTE waveform_report;
};
......
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