diff options
| author | Jason Gerecke <killertofu@gmail.com> | 2017-11-07 11:25:17 -0500 |
|---|---|---|
| committer | Jiri Kosina <jkosina@suse.cz> | 2017-11-09 07:32:43 -0500 |
| commit | 9e429d564926d3bca49907fa03031da705ad6f2c (patch) | |
| tree | 591f242c7674ac2076d9e2a56139167ffbf1c5b1 | |
| parent | 2f84723de7cdd031f293b900fecd68ddbec3feaa (diff) | |
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>
| -rw-r--r-- | drivers/hid/wacom_wac.c | 18 | ||||
| -rw-r--r-- | drivers/hid/wacom_wac.h | 2 | ||||
| -rw-r--r-- | include/uapi/linux/input-event-codes.h | 1 |
3 files changed, 19 insertions, 2 deletions
diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c index e3223b0c4f90..16af6886e828 100644 --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c | |||
| @@ -2140,6 +2140,12 @@ static void wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field | |||
| 2140 | case HID_DG_TIPSWITCH: | 2140 | case HID_DG_TIPSWITCH: |
| 2141 | wacom_wac->hid_data.tipswitch |= value; | 2141 | wacom_wac->hid_data.tipswitch |= value; |
| 2142 | return; | 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 | case HID_DG_TOOLSERIALNUMBER: | 2149 | case HID_DG_TOOLSERIALNUMBER: |
| 2144 | if (value) { | 2150 | if (value) { |
| 2145 | wacom_wac->serial[0] = (wacom_wac->serial[0] & ~0xFFFFFFFFULL); | 2151 | wacom_wac->serial[0] = (wacom_wac->serial[0] & ~0xFFFFFFFFULL); |
| @@ -2254,6 +2260,12 @@ static void wacom_wac_pen_report(struct hid_device *hdev, | |||
| 2254 | 2260 | ||
| 2255 | if (!delay_pen_events(wacom_wac) && wacom_wac->tool[0]) { | 2261 | if (!delay_pen_events(wacom_wac) && wacom_wac->tool[0]) { |
| 2256 | int id = wacom_wac->id[0]; | 2262 | int id = wacom_wac->id[0]; |
| 2263 | int sw_state = wacom_wac->hid_data.barrelswitch | | ||
| 2264 | (wacom_wac->hid_data.barrelswitch2 << 1); | ||
| 2265 | |||
| 2266 | input_report_key(input, BTN_STYLUS, sw_state == 1); | ||
| 2267 | input_report_key(input, BTN_STYLUS2, sw_state == 2); | ||
| 2268 | input_report_key(input, BTN_STYLUS3, sw_state == 3); | ||
| 2257 | 2269 | ||
| 2258 | /* | 2270 | /* |
| 2259 | * Non-USI EMR tools should have their IDs mangled to | 2271 | * Non-USI EMR tools should have their IDs mangled to |
| @@ -3300,9 +3312,11 @@ int wacom_setup_pen_input_capabilities(struct input_dev *input_dev, | |||
| 3300 | else | 3312 | else |
| 3301 | __set_bit(INPUT_PROP_POINTER, input_dev->propbit); | 3313 | __set_bit(INPUT_PROP_POINTER, input_dev->propbit); |
| 3302 | 3314 | ||
| 3303 | if (features->type == HID_GENERIC) | 3315 | if (features->type == HID_GENERIC) { |
| 3304 | /* setup has already been done */ | 3316 | /* setup has already been done; apply otherwise-undetectible quirks */ |
| 3317 | input_set_capability(input_dev, EV_KEY, BTN_STYLUS3); | ||
| 3305 | return 0; | 3318 | return 0; |
| 3319 | } | ||
| 3306 | 3320 | ||
| 3307 | __set_bit(BTN_TOUCH, input_dev->keybit); | 3321 | __set_bit(BTN_TOUCH, input_dev->keybit); |
| 3308 | __set_bit(ABS_MISC, input_dev->absbit); | 3322 | __set_bit(ABS_MISC, input_dev->absbit); |
diff --git a/drivers/hid/wacom_wac.h b/drivers/hid/wacom_wac.h index 8a03654048bf..69dda27e8dde 100644 --- a/drivers/hid/wacom_wac.h +++ b/drivers/hid/wacom_wac.h | |||
| @@ -291,6 +291,8 @@ struct hid_data { | |||
| 291 | bool inrange_state; | 291 | bool inrange_state; |
| 292 | bool invert_state; | 292 | bool invert_state; |
| 293 | bool tipswitch; | 293 | bool tipswitch; |
| 294 | bool barrelswitch; | ||
| 295 | bool barrelswitch2; | ||
| 294 | int x; | 296 | int x; |
| 295 | int y; | 297 | int y; |
| 296 | int pressure; | 298 | int pressure; |
diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h index 179891074b3c..9b3a522f50d1 100644 --- a/include/uapi/linux/input-event-codes.h +++ b/include/uapi/linux/input-event-codes.h | |||
| @@ -406,6 +406,7 @@ | |||
| 406 | #define BTN_TOOL_MOUSE 0x146 | 406 | #define BTN_TOOL_MOUSE 0x146 |
| 407 | #define BTN_TOOL_LENS 0x147 | 407 | #define BTN_TOOL_LENS 0x147 |
| 408 | #define BTN_TOOL_QUINTTAP 0x148 /* Five fingers on trackpad */ | 408 | #define BTN_TOOL_QUINTTAP 0x148 /* Five fingers on trackpad */ |
| 409 | #define BTN_STYLUS3 0x149 | ||
| 409 | #define BTN_TOUCH 0x14a | 410 | #define BTN_TOUCH 0x14a |
| 410 | #define BTN_STYLUS 0x14b | 411 | #define BTN_STYLUS 0x14b |
| 411 | #define BTN_STYLUS2 0x14c | 412 | #define BTN_STYLUS2 0x14c |
