Skip to content

Commit 6005a13

Browse files
jigpuJiri Kosina
authored and
Jiri Kosina
committed
HID: wacom: Detect and correct descriptors missing HID_DG_BARRELSWITCH2
ISDv4 devices have long supported reporting data from each of two barrel switches, but HID_DG_BARRELSWITCH2 itself was only recently standardized. Prior to its adoption, ISDv4 devices would associate the bit indicating the state of the second barrel switch with the "Undefined" 0x000D0000 usage. Although most such devices have explicit support, a few use the HID_GENERIC codepath which ignores the "Undefined" usage. This patch adds code which detects the presence of a pre-standard second barrel switch and corrects the usage value so that the HID_GENERIC code will declare its presence and report its state. Signed-off-by: Jason Gerecke <[email protected]> Reviewed-by: Benjamin Tissoires <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 49005b9 commit 6005a13

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

drivers/hid/wacom_sys.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,30 @@ static void wacom_usage_mapping(struct hid_device *hdev,
240240
features->touch_max = 1;
241241
}
242242

243+
/*
244+
* ISDv4 devices which predate HID's adoption of the
245+
* HID_DG_BARELSWITCH2 usage use 0x000D0000 in its
246+
* position instead. We can accurately detect if a
247+
* usage with that value should be HID_DG_BARRELSWITCH2
248+
* based on the surrounding usages, which have remained
249+
* constant across generations.
250+
*/
251+
if (features->type == HID_GENERIC &&
252+
usage->hid == 0x000D0000 &&
253+
field->application == HID_DG_PEN &&
254+
field->physical == HID_DG_STYLUS) {
255+
int i = usage->usage_index;
256+
257+
if (i-4 >= 0 && i+1 < field->maxusage &&
258+
field->usage[i-4].hid == HID_DG_TIPSWITCH &&
259+
field->usage[i-3].hid == HID_DG_BARRELSWITCH &&
260+
field->usage[i-2].hid == HID_DG_ERASER &&
261+
field->usage[i-1].hid == HID_DG_INVERT &&
262+
field->usage[i+1].hid == HID_DG_INRANGE) {
263+
usage->hid = HID_DG_BARRELSWITCH2;
264+
}
265+
}
266+
243267
switch (usage->hid) {
244268
case HID_GD_X:
245269
features->x_max = field->logical_maximum;

0 commit comments

Comments
 (0)