Skip to content

Commit 7525a0b

Browse files
jigpuJiri Kosina
authored andcommitted
HID: wacom: Support touchrings with relative motion
If a touchring is configured to send relative events (e.g. +1 or -1 every time some bit of rotational distance is covered), we should similarly send relative events up to userspace. Previous non-HID tablets used REL_WHEEL to send this kind of information, so we opt to use this same axis since userspace (xf86-input-wacom and libinput) already expects this kind of behavior from the Wacom kernel driver. Signed-off-by: Jason Gerecke <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 3152301 commit 7525a0b

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

drivers/hid/wacom_wac.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1909,6 +1909,7 @@ static void wacom_map_usage(struct input_dev *input, struct hid_usage *usage,
19091909
}
19101910
input_abs_set_res(input, code, resolution);
19111911
break;
1912+
case EV_REL:
19121913
case EV_KEY:
19131914
case EV_MSC:
19141915
case EV_SW:
@@ -2045,7 +2046,10 @@ static void wacom_wac_pad_usage_mapping(struct hid_device *hdev,
20452046
features->device_type |= WACOM_DEVICETYPE_PAD;
20462047
break;
20472048
case WACOM_HID_WD_TOUCHRING:
2048-
wacom_map_usage(input, usage, field, EV_ABS, ABS_WHEEL, 0);
2049+
if (field->flags & HID_MAIN_ITEM_RELATIVE)
2050+
wacom_map_usage(input, usage, field, EV_REL, REL_WHEEL, 0);
2051+
else
2052+
wacom_map_usage(input, usage, field, EV_ABS, ABS_WHEEL, 0);
20492053
features->device_type |= WACOM_DEVICETYPE_PAD;
20502054
break;
20512055
case WACOM_HID_WD_TOUCHRINGSTATUS:
@@ -2110,7 +2114,10 @@ static void wacom_wac_pad_event(struct hid_device *hdev, struct hid_field *field
21102114
return;
21112115

21122116
if (wacom_equivalent_usage(field->physical) == HID_DG_TABLETFUNCTIONKEY) {
2113-
if (usage->hid != WACOM_HID_WD_TOUCHRING)
2117+
bool is_abs_touchring = usage->hid == WACOM_HID_WD_TOUCHRING &&
2118+
!(field->flags & HID_MAIN_ITEM_RELATIVE);
2119+
2120+
if (!is_abs_touchring)
21142121
wacom_wac->hid_data.inrange_state |= value;
21152122
}
21162123

@@ -2163,6 +2170,15 @@ static void wacom_wac_pad_event(struct hid_device *hdev, struct hid_field *field
21632170
hdev->product == 0x3AA)
21642171
value = wacom_offset_rotation(input, usage, value, 1, 2);
21652172
}
2173+
else if (field->flags & HID_MAIN_ITEM_RELATIVE) {
2174+
/* We must invert the sign for vertical
2175+
* relative scrolling. Clockwise rotation
2176+
* produces positive values from HW, but
2177+
* userspace treats positive REL_WHEEL as a
2178+
* scroll *up*!
2179+
*/
2180+
value = -value;
2181+
}
21662182
else {
21672183
value = wacom_offset_rotation(input, usage, value, 1, 4);
21682184
}

0 commit comments

Comments
 (0)