Skip to content

Commit d8bf393

Browse files
committed
HID: wacom: Add preliminary support for high-resolution wheel scrolling
JIRA: https://issues.redhat.com/browse/RHEL-102058 Upstream Status: since v6.12 commit 7ca234e Author: Jason Gerecke <jason.gerecke@wacom.com> Date: Tue Jul 30 08:51:58 2024 -0700 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 <jason.gerecke@wacom.com> Signed-off-by: Jiri Kosina <jkosina@suse.com> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
1 parent fd3796b commit d8bf393

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
@@ -2048,10 +2048,12 @@ static void wacom_wac_pad_usage_mapping(struct hid_device *hdev,
20482048
features->device_type |= WACOM_DEVICETYPE_PAD;
20492049
break;
20502050
case WACOM_HID_WD_TOUCHRING:
2051-
if (field->flags & HID_MAIN_ITEM_RELATIVE)
2052-
wacom_map_usage(input, usage, field, EV_REL, REL_WHEEL, 0);
2053-
else
2051+
if (field->flags & HID_MAIN_ITEM_RELATIVE) {
2052+
wacom_map_usage(input, usage, field, EV_REL, REL_WHEEL_HI_RES, 0);
2053+
set_bit(REL_WHEEL, input->relbit);
2054+
} else {
20542055
wacom_map_usage(input, usage, field, EV_ABS, ABS_WHEEL, 0);
2056+
}
20552057
features->device_type |= WACOM_DEVICETYPE_PAD;
20562058
break;
20572059
case WACOM_HID_WD_TOUCHRINGSTATUS:
@@ -2179,7 +2181,21 @@ static void wacom_wac_pad_event(struct hid_device *hdev, struct hid_field *field
21792181
* userspace treats positive REL_WHEEL as a
21802182
* scroll *up*!
21812183
*/
2182-
value = -value;
2184+
int hires_value = -value * 120 / usage->resolution_multiplier;
2185+
int *ring_value = &wacom_wac->hid_data.ring_value;
2186+
2187+
value = hires_value;
2188+
*ring_value += hires_value;
2189+
2190+
/* Emulate a legacy wheel click for every 120
2191+
* units of hi-res travel.
2192+
*/
2193+
if (*ring_value >= 120 || *ring_value <= -120) {
2194+
int clicks = *ring_value / 120;
2195+
2196+
input_event(input, usage->type, REL_WHEEL, clicks);
2197+
*ring_value -= clicks * 120;
2198+
}
21832199
}
21842200
else {
21852201
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)