Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

HID: wacom: generic: Send BTN_STYLUS3 when both barrel switches are set

The Wacom Pro Pen 3D includes a third barrel switch which is intended to
be particularly useful in applications where one frequency uses pan, zoom,
and rotate to navigate around a scene or model. The pen is compatible with
the MobileStudio Pro, 2nd-gen Intuos Pro, and Cintiq Pro. When the third
button is pressed, these devices set both the HID_DG_BARRELSWITCH and
HID_DG_BARRELSWITCH2 usages since their HID descriptors do not include a
usage specific to the button.

Rather than send both BTN_STYLUS and BTN_STYLUS2 when the third button is
pressed, userspace (libinput) has requested that we detect this condition
and report a newly-defined BTN_STYLUS3 event instead. We could define a
quirk specific to devices compatible with the Pro Pen 3D, but the liklihood
of seeing both barrel switch bits set with other pens/devices is low enough
to not worry about (pens mechanically prevent accidental activation of
multiple switches).

Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>

authored by

Jason Gerecke and committed by
Jiri Kosina
9e429d56 2f84723d

+19 -2
+16 -2
drivers/hid/wacom_wac.c
··· 2140 2140 case HID_DG_TIPSWITCH: 2141 2141 wacom_wac->hid_data.tipswitch |= value; 2142 2142 return; 2143 + case HID_DG_BARRELSWITCH: 2144 + wacom_wac->hid_data.barrelswitch = value; 2145 + return; 2146 + case HID_DG_BARRELSWITCH2: 2147 + wacom_wac->hid_data.barrelswitch2 = value; 2148 + return; 2143 2149 case HID_DG_TOOLSERIALNUMBER: 2144 2150 if (value) { 2145 2151 wacom_wac->serial[0] = (wacom_wac->serial[0] & ~0xFFFFFFFFULL); ··· 2260 2254 2261 2255 if (!delay_pen_events(wacom_wac) && wacom_wac->tool[0]) { 2262 2256 int id = wacom_wac->id[0]; 2257 + int sw_state = wacom_wac->hid_data.barrelswitch | 2258 + (wacom_wac->hid_data.barrelswitch2 << 1); 2259 + 2260 + input_report_key(input, BTN_STYLUS, sw_state == 1); 2261 + input_report_key(input, BTN_STYLUS2, sw_state == 2); 2262 + input_report_key(input, BTN_STYLUS3, sw_state == 3); 2263 2263 2264 2264 /* 2265 2265 * Non-USI EMR tools should have their IDs mangled to ··· 3312 3300 else 3313 3301 __set_bit(INPUT_PROP_POINTER, input_dev->propbit); 3314 3302 3315 - if (features->type == HID_GENERIC) 3316 - /* setup has already been done */ 3303 + if (features->type == HID_GENERIC) { 3304 + /* setup has already been done; apply otherwise-undetectible quirks */ 3305 + input_set_capability(input_dev, EV_KEY, BTN_STYLUS3); 3317 3306 return 0; 3307 + } 3318 3308 3319 3309 __set_bit(BTN_TOUCH, input_dev->keybit); 3320 3310 __set_bit(ABS_MISC, input_dev->absbit);
+2
drivers/hid/wacom_wac.h
··· 291 291 bool inrange_state; 292 292 bool invert_state; 293 293 bool tipswitch; 294 + bool barrelswitch; 295 + bool barrelswitch2; 294 296 int x; 295 297 int y; 296 298 int pressure;
+1
include/uapi/linux/input-event-codes.h
··· 406 406 #define BTN_TOOL_MOUSE 0x146 407 407 #define BTN_TOOL_LENS 0x147 408 408 #define BTN_TOOL_QUINTTAP 0x148 /* Five fingers on trackpad */ 409 + #define BTN_STYLUS3 0x149 409 410 #define BTN_TOUCH 0x14a 410 411 #define BTN_STYLUS 0x14b 411 412 #define BTN_STYLUS2 0x14c