Skip to content

Commit 7ca234e

Browse files
jigpuJiri Kosina
authored andcommitted
HID: wacom: Add preliminary support for high-resolution wheel scrolling
Modern userspace (i.e. libinput) will make use of high-resolution scrolling if supported. Hardware does not currently set a resolution multiplier needed for effective high-res scrolling, but we can still write code to support it in the future. Signed-off-by: Jason Gerecke <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 7525a0b commit 7ca234e

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

drivers/hid/wacom_wac.c

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2046,10 +2046,12 @@ static void wacom_wac_pad_usage_mapping(struct hid_device *hdev,
20462046
features->device_type |= WACOM_DEVICETYPE_PAD;
20472047
break;
20482048
case WACOM_HID_WD_TOUCHRING:
2049-
if (field->flags & HID_MAIN_ITEM_RELATIVE)
2050-
wacom_map_usage(input, usage, field, EV_REL, REL_WHEEL, 0);
2051-
else
2049+
if (field->flags & HID_MAIN_ITEM_RELATIVE) {
2050+
wacom_map_usage(input, usage, field, EV_REL, REL_WHEEL_HI_RES, 0);
2051+
set_bit(REL_WHEEL, input->relbit);
2052+
} else {
20522053
wacom_map_usage(input, usage, field, EV_ABS, ABS_WHEEL, 0);
2054+
}
20532055
features->device_type |= WACOM_DEVICETYPE_PAD;
20542056
break;
20552057
case WACOM_HID_WD_TOUCHRINGSTATUS:
@@ -2177,7 +2179,21 @@ static void wacom_wac_pad_event(struct hid_device *hdev, struct hid_field *field
21772179
* userspace treats positive REL_WHEEL as a
21782180
* scroll *up*!
21792181
*/
2180-
value = -value;
2182+
int hires_value = -value * 120 / usage->resolution_multiplier;
2183+
int *ring_value = &wacom_wac->hid_data.ring_value;
2184+
2185+
value = hires_value;
2186+
*ring_value += hires_value;
2187+
2188+
/* Emulate a legacy wheel click for every 120
2189+
* units of hi-res travel.
2190+
*/
2191+
if (*ring_value >= 120 || *ring_value <= -120) {
2192+
int clicks = *ring_value / 120;
2193+
2194+
input_event(input, usage->type, REL_WHEEL, clicks);
2195+
*ring_value -= clicks * 120;
2196+
}
21812197
}
21822198
else {
21832199
value = wacom_offset_rotation(input, usage, value, 1, 4);

drivers/hid/wacom_wac.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ struct hid_data {
312312
int width;
313313
int height;
314314
int id;
315+
int ring_value;
315316
int cc_report;
316317
int cc_index;
317318
int cc_value_index;

0 commit comments

Comments
 (0)