Commit 46fc466e authored by Ping Cheng's avatar Ping Cheng Committed by Jiri Kosina

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: default avatarPing Cheng <ping.cheng@wacom.com>
Reviewed-by: default avatarJason Gerecke <Jason.Gerecke@wacom.com>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent 69aea9d2
...@@ -1860,8 +1860,6 @@ static void wacom_map_usage(struct input_dev *input, struct hid_usage *usage, ...@@ -1860,8 +1860,6 @@ static void wacom_map_usage(struct input_dev *input, struct hid_usage *usage,
usage->type = type; usage->type = type;
usage->code = code; usage->code = code;
set_bit(type, input->evbit);
switch (type) { switch (type) {
case EV_ABS: case EV_ABS:
input_set_abs_params(input, code, fmin, fmax, fuzz, 0); input_set_abs_params(input, code, fmin, fmax, fuzz, 0);
...@@ -1869,13 +1867,9 @@ static void wacom_map_usage(struct input_dev *input, struct hid_usage *usage, ...@@ -1869,13 +1867,9 @@ static void wacom_map_usage(struct input_dev *input, struct hid_usage *usage,
hidinput_calc_abs_res(field, resolution_code)); hidinput_calc_abs_res(field, resolution_code));
break; break;
case EV_KEY: case EV_KEY:
input_set_capability(input, EV_KEY, code);
break;
case EV_MSC: case EV_MSC:
input_set_capability(input, EV_MSC, code);
break;
case EV_SW: case EV_SW:
input_set_capability(input, EV_SW, code); input_set_capability(input, type, code);
break; break;
} }
} }
...@@ -2187,6 +2181,18 @@ static void wacom_wac_pad_report(struct hid_device *hdev, ...@@ -2187,6 +2181,18 @@ static void wacom_wac_pad_report(struct hid_device *hdev,
} }
} }
static void wacom_set_barrel_switch3_usage(struct wacom_wac *wacom_wac)
{
struct input_dev *input = wacom_wac->pen_input;
struct wacom_features *features = &wacom_wac->features;
if (!(features->quirks & WACOM_QUIRK_AESPEN) &&
wacom_wac->hid_data.barrelswitch &&
wacom_wac->hid_data.barrelswitch2 &&
wacom_wac->hid_data.serialhi)
input_set_capability(input, EV_KEY, BTN_STYLUS3);
}
static void wacom_wac_pen_usage_mapping(struct hid_device *hdev, static void wacom_wac_pen_usage_mapping(struct hid_device *hdev,
struct hid_field *field, struct hid_usage *usage) struct hid_field *field, struct hid_usage *usage)
{ {
...@@ -2227,13 +2233,21 @@ static void wacom_wac_pen_usage_mapping(struct hid_device *hdev, ...@@ -2227,13 +2233,21 @@ static void wacom_wac_pen_usage_mapping(struct hid_device *hdev,
wacom_map_usage(input, usage, field, EV_ABS, ABS_Z, 0); wacom_map_usage(input, usage, field, EV_ABS, ABS_Z, 0);
break; break;
case HID_DG_ERASER: case HID_DG_ERASER:
input_set_capability(input, EV_KEY, BTN_TOOL_RUBBER);
wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0);
break;
case HID_DG_TIPSWITCH: case HID_DG_TIPSWITCH:
input_set_capability(input, EV_KEY, BTN_TOOL_PEN);
wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0); wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0);
break; break;
case HID_DG_BARRELSWITCH: case HID_DG_BARRELSWITCH:
wacom_wac->hid_data.barrelswitch = true;
wacom_set_barrel_switch3_usage(wacom_wac);
wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS, 0); wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS, 0);
break; break;
case HID_DG_BARRELSWITCH2: case HID_DG_BARRELSWITCH2:
wacom_wac->hid_data.barrelswitch2 = true;
wacom_set_barrel_switch3_usage(wacom_wac);
wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS2, 0); wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS2, 0);
break; break;
case HID_DG_TOOLSERIALNUMBER: case HID_DG_TOOLSERIALNUMBER:
...@@ -2245,22 +2259,12 @@ static void wacom_wac_pen_usage_mapping(struct hid_device *hdev, ...@@ -2245,22 +2259,12 @@ static void wacom_wac_pen_usage_mapping(struct hid_device *hdev,
wacom_map_usage(input, usage, field, EV_KEY, BTN_TOOL_PEN, 0); wacom_map_usage(input, usage, field, EV_KEY, BTN_TOOL_PEN, 0);
break; break;
case WACOM_HID_WD_SERIALHI: case WACOM_HID_WD_SERIALHI:
wacom_wac->hid_data.serialhi = true;
wacom_set_barrel_switch3_usage(wacom_wac);
wacom_map_usage(input, usage, field, EV_ABS, ABS_MISC, 0); wacom_map_usage(input, usage, field, EV_ABS, ABS_MISC, 0);
if (!(features->quirks & WACOM_QUIRK_AESPEN)) {
set_bit(EV_KEY, input->evbit);
input_set_capability(input, EV_KEY, BTN_TOOL_PEN);
input_set_capability(input, EV_KEY, BTN_TOOL_RUBBER);
input_set_capability(input, EV_KEY, BTN_TOOL_BRUSH);
input_set_capability(input, EV_KEY, BTN_TOOL_PENCIL);
input_set_capability(input, EV_KEY, BTN_TOOL_AIRBRUSH);
if (!(features->device_type & WACOM_DEVICETYPE_DIRECT)) {
input_set_capability(input, EV_KEY, BTN_TOOL_MOUSE);
input_set_capability(input, EV_KEY, BTN_TOOL_LENS);
}
}
break; break;
case WACOM_HID_WD_FINGERWHEEL: case WACOM_HID_WD_FINGERWHEEL:
input_set_capability(input, EV_KEY, BTN_TOOL_AIRBRUSH);
wacom_map_usage(input, usage, field, EV_ABS, ABS_WHEEL, 0); wacom_map_usage(input, usage, field, EV_ABS, ABS_WHEEL, 0);
break; break;
} }
...@@ -3584,11 +3588,9 @@ int wacom_setup_pen_input_capabilities(struct input_dev *input_dev, ...@@ -3584,11 +3588,9 @@ int wacom_setup_pen_input_capabilities(struct input_dev *input_dev,
else else
__set_bit(INPUT_PROP_POINTER, input_dev->propbit); __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
if (features->type == HID_GENERIC) { if (features->type == HID_GENERIC)
/* setup has already been done; apply otherwise-undetectible quirks */ /* setup has already been done */
input_set_capability(input_dev, EV_KEY, BTN_STYLUS3);
return 0; return 0;
}
__set_bit(BTN_TOUCH, input_dev->keybit); __set_bit(BTN_TOUCH, input_dev->keybit);
__set_bit(ABS_MISC, input_dev->absbit); __set_bit(ABS_MISC, input_dev->absbit);
......
...@@ -300,6 +300,7 @@ struct hid_data { ...@@ -300,6 +300,7 @@ struct hid_data {
bool tipswitch; bool tipswitch;
bool barrelswitch; bool barrelswitch;
bool barrelswitch2; bool barrelswitch2;
bool serialhi;
int x; int x;
int y; int y;
int pressure; int pressure;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment