Skip to content

Commit

Permalink
HID: wacom: support named keys on older devices
Browse files Browse the repository at this point in the history
Support for some of the missing key codes needed by older
wacom devices was added with commit ____. These keys previously
reported the anonymous KEY_PROG* rage, and they continue to do so
so as not to break any unknown applications that may depend on
them. We add the proper key codes and track the state of the
touch button in the pad report.

Signed-off-by: Aaron Armstrong Skomra <aaron.skomra@wacom.com>
Link: https://gitlab.freedesktop.org/libinput/libinput/merge_requests/155
Link: linuxwacom/xf86-input-wacom#46
  • Loading branch information
skomra committed Aug 8, 2019
1 parent 7767fc5 commit 7731f70
Showing 1 changed file with 67 additions and 1 deletion.
68 changes: 67 additions & 1 deletion 4.5/wacom_wac.c
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ static int wacom_intuos_pad(struct wacom_wac *wacom)
int ring1 = 0, ring2 = 0;
int strip1 = 0, strip2 = 0;
bool prox = false;
bool wrench = false, keyboard = false, mute_touch = false, menu = false, info = false;

/* pad packets. Works as a second tool and is always in prox */
if (!(data[0] == WACOM_REPORT_INTUOSPAD || data[0] == WACOM_REPORT_INTUOS5PAD ||
Expand All @@ -502,6 +503,7 @@ static int wacom_intuos_pad(struct wacom_wac *wacom)
ring1 = data[1];
} else if (features->type == DTK) {
buttons = data[6];
wrench = data[6] & 0x1;
} else if (features->type == WACOM_13HD) {
buttons = (data[4] << 1) | (data[3] & 0x01);
} else if (features->type == WACOM_24HD) {
Expand All @@ -520,10 +522,30 @@ static int wacom_intuos_pad(struct wacom_wac *wacom)
keys = ((data[3] & 0x1C) ? 1<<2 : 0) |
((data[4] & 0xE0) ? 1<<1 : 0) |
((data[4] & 0x07) ? 1<<0 : 0);
keyboard = !!(data[4] & 0xE0);
info = !!(data[3] & 0x1C);

if (features->oPid) {
mute_touch = !!(data[4] & 0x07);
if (mute_touch)
wacom->shared->is_touch_on = !wacom->shared->is_touch_on;
} else {
wrench = !!(data[4] & 0x07);
}
} else if (features->type == WACOM_27QHD) {
nkeys = 3;
keys = data[2] & 0x07;

wrench = !!(data[2] & 0x01);
keyboard = !!(data[2] & 0x02);

if (features->oPid) {
mute_touch = !!(data[2] & 0x04);
if (mute_touch)
wacom->shared->is_touch_on = !wacom->shared->is_touch_on;
} else {
menu = !!(data[2] & 0x04);
}
input_report_abs(input, ABS_X, be16_to_cpup((__be16 *)&data[4]));
input_report_abs(input, ABS_Y, be16_to_cpup((__be16 *)&data[6]));
input_report_abs(input, ABS_Z, be16_to_cpup((__be16 *)&data[8]));
Expand Down Expand Up @@ -569,6 +591,9 @@ static int wacom_intuos_pad(struct wacom_wac *wacom)
if (features->type == WACOM_22HD) {
nkeys = 3;
keys = data[9] & 0x07;

info = !!(data[9] & 0x01);
wrench = !!(data[9] & 0x02);
}
} else {
buttons = ((data[6] & 0x10) << 5) |
Expand All @@ -588,6 +613,17 @@ static int wacom_intuos_pad(struct wacom_wac *wacom)
for (i = 0; i < nkeys; i++)
input_report_key(input, KEY_PROG1 + i, keys & (1 << i));

input_report_key(input, KEY_BUTTONCONFIG, wrench);
input_report_key(input, KEY_ONSCREEN_KEYBOARD, keyboard);
input_report_key(input, KEY_CONTROLPANEL, menu);
input_report_key(input, KEY_INFO, info);

if (wacom->shared && wacom->shared->touch_input) {
input_report_switch(wacom->shared->touch_input,
SW_MUTE_DEVICE, !wacom->shared->is_touch_on);
input_sync(wacom->shared->touch_input);
}

input_report_abs(input, ABS_RX, strip1);
input_report_abs(input, ABS_RY, strip2);

Expand Down Expand Up @@ -1490,6 +1526,13 @@ static int wacom_24hdt_irq(struct wacom_wac *wacom)
int byte_per_packet = WACOM_BYTES_PER_24HDT_PACKET;
int y_offset = 2;

if (wacom_wac->shared->has_mute_touch_switch &&
!wacom_wac->shared->is_touch_on) {
if (!wacom_wac->shared->touch_down)
return;
prox = 0;
}

if (wacom->features.type == WACOM_27QHDT) {
current_num_contacts = data[63];
num_contacts_left = 10;
Expand Down Expand Up @@ -3823,6 +3866,11 @@ int wacom_setup_touch_input_capabilities(struct input_dev *input_dev,
/* fall through */

case WACOM_27QHDT:
input_dev->evbit[0] |= BIT_MASK(EV_SW);
__set_bit(SW_MUTE_DEVICE, input_dev->swbit);
wacom_wac->shared->has_mute_touch_switch = true; //FIXME 2242 have this?
/* fall through */

case MTSCREEN:
case MTTPC:
case MTTPC_B:
Expand Down Expand Up @@ -4034,11 +4082,14 @@ int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,

case CINTIQ_HYBRID:
case CINTIQ_COMPANION_2:
case DTK:
case DTUS:
case GRAPHIRE_BT:
break;

case DTK:
__set_bit(KEY_BUTTONCONFIG, input_dev->keybit);
break;

case WACOM_MO:
__set_bit(BTN_BACK, input_dev->keybit);
__set_bit(BTN_LEFT, input_dev->keybit);
Expand All @@ -4058,6 +4109,12 @@ int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
__set_bit(KEY_PROG2, input_dev->keybit);
__set_bit(KEY_PROG3, input_dev->keybit);

__set_bit(KEY_ONSCREEN_KEYBOARD, input_dev->keybit);
__set_bit(KEY_INFO, input_dev->keybit);

if (!features->oPid)
__set_bit(KEY_BUTTONCONFIG, input_dev->keybit);

input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
input_set_abs_params(input_dev, ABS_THROTTLE, 0, 71, 0, 0);
break;
Expand All @@ -4066,6 +4123,12 @@ int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
__set_bit(KEY_PROG1, input_dev->keybit);
__set_bit(KEY_PROG2, input_dev->keybit);
__set_bit(KEY_PROG3, input_dev->keybit);

__set_bit(KEY_ONSCREEN_KEYBOARD, input_dev->keybit);
__set_bit(KEY_BUTTONCONFIG, input_dev->keybit);

if (!features->oPid)
__set_bit(KEY_CONTROLPANEL, input_dev->keybit);
input_set_abs_params(input_dev, ABS_X, -2048, 2048, 0, 0);
input_abs_set_res(input_dev, ABS_X, 1024); /* points/g */
input_set_abs_params(input_dev, ABS_Y, -2048, 2048, 0, 0);
Expand All @@ -4079,6 +4142,9 @@ int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
__set_bit(KEY_PROG1, input_dev->keybit);
__set_bit(KEY_PROG2, input_dev->keybit);
__set_bit(KEY_PROG3, input_dev->keybit);

__set_bit(KEY_BUTTONCONFIG, input_dev->keybit);
__set_bit(KEY_INFO, input_dev->keybit);
/* fall through */

case WACOM_21UX2:
Expand Down

0 comments on commit 7731f70

Please sign in to comment.