Skip to content

Commit 670e909

Browse files
skomraJiri Kosina
authored andcommitted
HID: wacom: support named keys on older devices
Some Wacom devices have keys with predefined meanings. However, when support was originally added for these devices, the codes for these keys were not available yet. These keys were thus reported with the numbered KEY_PROG* range. Some missing key codes were added with commit 4eb220c ("HID: wacom: generic: add 3 tablet touch keys") and we are now able to report the proper key codes. We continue to report the original KEY_PROG codes so as not to break any unknown applications that may depend on them. Also, to support the touch key, track its state in the pad report. Signed-off-by: Aaron Armstrong Skomra <[email protected]> Link: https://gitlab.freedesktop.org/libinput/libinput/merge_requests/155 Link: linuxwacom/xf86-input-wacom#46 Reviewed-by: Ping Cheng <[email protected]> Reviewed-by: Jason Gerecke <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 073b50b commit 670e909

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

drivers/hid/wacom_wac.c

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,8 @@ static int wacom_intuos_pad(struct wacom_wac *wacom)
483483
int ring1 = 0, ring2 = 0;
484484
int strip1 = 0, strip2 = 0;
485485
bool prox = false;
486+
bool wrench = false, keyboard = false, mute_touch = false, menu = false,
487+
info = false;
486488

487489
/* pad packets. Works as a second tool and is always in prox */
488490
if (!(data[0] == WACOM_REPORT_INTUOSPAD || data[0] == WACOM_REPORT_INTUOS5PAD ||
@@ -512,10 +514,32 @@ static int wacom_intuos_pad(struct wacom_wac *wacom)
512514
keys = ((data[3] & 0x1C) ? 1<<2 : 0) |
513515
((data[4] & 0xE0) ? 1<<1 : 0) |
514516
((data[4] & 0x07) ? 1<<0 : 0);
517+
keyboard = !!(data[4] & 0xE0);
518+
info = !!(data[3] & 0x1C);
519+
520+
if (features->oPid) {
521+
mute_touch = !!(data[4] & 0x07);
522+
if (mute_touch)
523+
wacom->shared->is_touch_on =
524+
!wacom->shared->is_touch_on;
525+
} else {
526+
wrench = !!(data[4] & 0x07);
527+
}
515528
} else if (features->type == WACOM_27QHD) {
516529
nkeys = 3;
517530
keys = data[2] & 0x07;
518531

532+
wrench = !!(data[2] & 0x01);
533+
keyboard = !!(data[2] & 0x02);
534+
535+
if (features->oPid) {
536+
mute_touch = !!(data[2] & 0x04);
537+
if (mute_touch)
538+
wacom->shared->is_touch_on =
539+
!wacom->shared->is_touch_on;
540+
} else {
541+
menu = !!(data[2] & 0x04);
542+
}
519543
input_report_abs(input, ABS_X, be16_to_cpup((__be16 *)&data[4]));
520544
input_report_abs(input, ABS_Y, be16_to_cpup((__be16 *)&data[6]));
521545
input_report_abs(input, ABS_Z, be16_to_cpup((__be16 *)&data[8]));
@@ -561,6 +585,9 @@ static int wacom_intuos_pad(struct wacom_wac *wacom)
561585
if (features->type == WACOM_22HD) {
562586
nkeys = 3;
563587
keys = data[9] & 0x07;
588+
589+
info = !!(data[9] & 0x01);
590+
wrench = !!(data[9] & 0x02);
564591
}
565592
} else {
566593
buttons = ((data[6] & 0x10) << 5) |
@@ -580,6 +607,18 @@ static int wacom_intuos_pad(struct wacom_wac *wacom)
580607
for (i = 0; i < nkeys; i++)
581608
input_report_key(input, KEY_PROG1 + i, keys & (1 << i));
582609

610+
input_report_key(input, KEY_BUTTONCONFIG, wrench);
611+
input_report_key(input, KEY_ONSCREEN_KEYBOARD, keyboard);
612+
input_report_key(input, KEY_CONTROLPANEL, menu);
613+
input_report_key(input, KEY_INFO, info);
614+
615+
if (wacom->shared && wacom->shared->touch_input) {
616+
input_report_switch(wacom->shared->touch_input,
617+
SW_MUTE_DEVICE,
618+
!wacom->shared->is_touch_on);
619+
input_sync(wacom->shared->touch_input);
620+
}
621+
583622
input_report_abs(input, ABS_RX, strip1);
584623
input_report_abs(input, ABS_RY, strip2);
585624

@@ -1480,6 +1519,12 @@ static int wacom_24hdt_irq(struct wacom_wac *wacom)
14801519
int byte_per_packet = WACOM_BYTES_PER_24HDT_PACKET;
14811520
int y_offset = 2;
14821521

1522+
if (wacom->shared->has_mute_touch_switch &&
1523+
!wacom->shared->is_touch_on) {
1524+
if (!wacom->shared->touch_down)
1525+
return 0;
1526+
}
1527+
14831528
if (wacom->features.type == WACOM_27QHDT) {
14841529
current_num_contacts = data[63];
14851530
num_contacts_left = 10;
@@ -3812,6 +3857,14 @@ int wacom_setup_touch_input_capabilities(struct input_dev *input_dev,
38123857
/* fall through */
38133858

38143859
case WACOM_27QHDT:
3860+
if (wacom_wac->shared->touch->product == 0x32C ||
3861+
wacom_wac->shared->touch->product == 0xF6) {
3862+
input_dev->evbit[0] |= BIT_MASK(EV_SW);
3863+
__set_bit(SW_MUTE_DEVICE, input_dev->swbit);
3864+
wacom_wac->shared->has_mute_touch_switch = true;
3865+
}
3866+
/* fall through */
3867+
38153868
case MTSCREEN:
38163869
case MTTPC:
38173870
case MTTPC_B:
@@ -4047,6 +4100,12 @@ int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
40474100
__set_bit(KEY_PROG2, input_dev->keybit);
40484101
__set_bit(KEY_PROG3, input_dev->keybit);
40494102

4103+
__set_bit(KEY_ONSCREEN_KEYBOARD, input_dev->keybit);
4104+
__set_bit(KEY_INFO, input_dev->keybit);
4105+
4106+
if (!features->oPid)
4107+
__set_bit(KEY_BUTTONCONFIG, input_dev->keybit);
4108+
40504109
input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
40514110
input_set_abs_params(input_dev, ABS_THROTTLE, 0, 71, 0, 0);
40524111
break;
@@ -4055,6 +4114,12 @@ int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
40554114
__set_bit(KEY_PROG1, input_dev->keybit);
40564115
__set_bit(KEY_PROG2, input_dev->keybit);
40574116
__set_bit(KEY_PROG3, input_dev->keybit);
4117+
4118+
__set_bit(KEY_ONSCREEN_KEYBOARD, input_dev->keybit);
4119+
__set_bit(KEY_BUTTONCONFIG, input_dev->keybit);
4120+
4121+
if (!features->oPid)
4122+
__set_bit(KEY_CONTROLPANEL, input_dev->keybit);
40584123
input_set_abs_params(input_dev, ABS_X, -2048, 2048, 0, 0);
40594124
input_abs_set_res(input_dev, ABS_X, 1024); /* points/g */
40604125
input_set_abs_params(input_dev, ABS_Y, -2048, 2048, 0, 0);
@@ -4068,6 +4133,9 @@ int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
40684133
__set_bit(KEY_PROG1, input_dev->keybit);
40694134
__set_bit(KEY_PROG2, input_dev->keybit);
40704135
__set_bit(KEY_PROG3, input_dev->keybit);
4136+
4137+
__set_bit(KEY_BUTTONCONFIG, input_dev->keybit);
4138+
__set_bit(KEY_INFO, input_dev->keybit);
40714139
/* fall through */
40724140

40734141
case WACOM_21UX2:

0 commit comments

Comments
 (0)