Skip to content

Commit 46fc466

Browse files
PinglinuxJiri Kosina
authored andcommitted
HID: wacom: Setup pen input capabilities to the targeted tools
Only set the bits that are supported by the targeted devices. This patch also removes duplicated set_bit calls. Signed-off-by: Ping Cheng <[email protected]> Reviewed-by: Jason Gerecke <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 69aea9d commit 46fc466

File tree

2 files changed

+27
-24
lines changed

2 files changed

+27
-24
lines changed

drivers/hid/wacom_wac.c

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1860,22 +1860,16 @@ static void wacom_map_usage(struct input_dev *input, struct hid_usage *usage,
18601860
usage->type = type;
18611861
usage->code = code;
18621862

1863-
set_bit(type, input->evbit);
1864-
18651863
switch (type) {
18661864
case EV_ABS:
18671865
input_set_abs_params(input, code, fmin, fmax, fuzz, 0);
18681866
input_abs_set_res(input, code,
18691867
hidinput_calc_abs_res(field, resolution_code));
18701868
break;
18711869
case EV_KEY:
1872-
input_set_capability(input, EV_KEY, code);
1873-
break;
18741870
case EV_MSC:
1875-
input_set_capability(input, EV_MSC, code);
1876-
break;
18771871
case EV_SW:
1878-
input_set_capability(input, EV_SW, code);
1872+
input_set_capability(input, type, code);
18791873
break;
18801874
}
18811875
}
@@ -2187,6 +2181,18 @@ static void wacom_wac_pad_report(struct hid_device *hdev,
21872181
}
21882182
}
21892183

2184+
static void wacom_set_barrel_switch3_usage(struct wacom_wac *wacom_wac)
2185+
{
2186+
struct input_dev *input = wacom_wac->pen_input;
2187+
struct wacom_features *features = &wacom_wac->features;
2188+
2189+
if (!(features->quirks & WACOM_QUIRK_AESPEN) &&
2190+
wacom_wac->hid_data.barrelswitch &&
2191+
wacom_wac->hid_data.barrelswitch2 &&
2192+
wacom_wac->hid_data.serialhi)
2193+
input_set_capability(input, EV_KEY, BTN_STYLUS3);
2194+
}
2195+
21902196
static void wacom_wac_pen_usage_mapping(struct hid_device *hdev,
21912197
struct hid_field *field, struct hid_usage *usage)
21922198
{
@@ -2227,13 +2233,21 @@ static void wacom_wac_pen_usage_mapping(struct hid_device *hdev,
22272233
wacom_map_usage(input, usage, field, EV_ABS, ABS_Z, 0);
22282234
break;
22292235
case HID_DG_ERASER:
2236+
input_set_capability(input, EV_KEY, BTN_TOOL_RUBBER);
2237+
wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0);
2238+
break;
22302239
case HID_DG_TIPSWITCH:
2240+
input_set_capability(input, EV_KEY, BTN_TOOL_PEN);
22312241
wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0);
22322242
break;
22332243
case HID_DG_BARRELSWITCH:
2244+
wacom_wac->hid_data.barrelswitch = true;
2245+
wacom_set_barrel_switch3_usage(wacom_wac);
22342246
wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS, 0);
22352247
break;
22362248
case HID_DG_BARRELSWITCH2:
2249+
wacom_wac->hid_data.barrelswitch2 = true;
2250+
wacom_set_barrel_switch3_usage(wacom_wac);
22372251
wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS2, 0);
22382252
break;
22392253
case HID_DG_TOOLSERIALNUMBER:
@@ -2245,22 +2259,12 @@ static void wacom_wac_pen_usage_mapping(struct hid_device *hdev,
22452259
wacom_map_usage(input, usage, field, EV_KEY, BTN_TOOL_PEN, 0);
22462260
break;
22472261
case WACOM_HID_WD_SERIALHI:
2262+
wacom_wac->hid_data.serialhi = true;
2263+
wacom_set_barrel_switch3_usage(wacom_wac);
22482264
wacom_map_usage(input, usage, field, EV_ABS, ABS_MISC, 0);
2249-
2250-
if (!(features->quirks & WACOM_QUIRK_AESPEN)) {
2251-
set_bit(EV_KEY, input->evbit);
2252-
input_set_capability(input, EV_KEY, BTN_TOOL_PEN);
2253-
input_set_capability(input, EV_KEY, BTN_TOOL_RUBBER);
2254-
input_set_capability(input, EV_KEY, BTN_TOOL_BRUSH);
2255-
input_set_capability(input, EV_KEY, BTN_TOOL_PENCIL);
2256-
input_set_capability(input, EV_KEY, BTN_TOOL_AIRBRUSH);
2257-
if (!(features->device_type & WACOM_DEVICETYPE_DIRECT)) {
2258-
input_set_capability(input, EV_KEY, BTN_TOOL_MOUSE);
2259-
input_set_capability(input, EV_KEY, BTN_TOOL_LENS);
2260-
}
2261-
}
22622265
break;
22632266
case WACOM_HID_WD_FINGERWHEEL:
2267+
input_set_capability(input, EV_KEY, BTN_TOOL_AIRBRUSH);
22642268
wacom_map_usage(input, usage, field, EV_ABS, ABS_WHEEL, 0);
22652269
break;
22662270
}
@@ -3584,11 +3588,9 @@ int wacom_setup_pen_input_capabilities(struct input_dev *input_dev,
35843588
else
35853589
__set_bit(INPUT_PROP_POINTER, input_dev->propbit);
35863590

3587-
if (features->type == HID_GENERIC) {
3588-
/* setup has already been done; apply otherwise-undetectible quirks */
3589-
input_set_capability(input_dev, EV_KEY, BTN_STYLUS3);
3591+
if (features->type == HID_GENERIC)
3592+
/* setup has already been done */
35903593
return 0;
3591-
}
35923594

35933595
__set_bit(BTN_TOUCH, input_dev->keybit);
35943596
__set_bit(ABS_MISC, input_dev->absbit);

drivers/hid/wacom_wac.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ struct hid_data {
300300
bool tipswitch;
301301
bool barrelswitch;
302302
bool barrelswitch2;
303+
bool serialhi;
303304
int x;
304305
int y;
305306
int pressure;

0 commit comments

Comments
 (0)