Skip to content

Commit 619d3a2

Browse files
skomraJiri Kosina
authored andcommitted
HID: wacom: bluetooth: send exit report for recent Bluetooth devices
The code path for recent Bluetooth devices omits an exit report which resets all the values of the device. Fixes: 4922cd2 ("HID: wacom: Support 2nd-gen Intuos Pro's Bluetooth classic interface") Cc: <[email protected]> # 4.11 Signed-off-by: Aaron Armstrong Skomra <[email protected]> Reviewed-by: Ping Cheng <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent a955358 commit 619d3a2

File tree

1 file changed

+46
-30
lines changed

1 file changed

+46
-30
lines changed

drivers/hid/wacom_wac.c

Lines changed: 46 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,45 @@ static int wacom_intuos_get_tool_type(int tool_id)
689689
return tool_type;
690690
}
691691

692+
static void wacom_exit_report(struct wacom_wac *wacom)
693+
{
694+
struct input_dev *input = wacom->pen_input;
695+
struct wacom_features *features = &wacom->features;
696+
unsigned char *data = wacom->data;
697+
int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0;
698+
699+
/*
700+
* Reset all states otherwise we lose the initial states
701+
* when in-prox next time
702+
*/
703+
input_report_abs(input, ABS_X, 0);
704+
input_report_abs(input, ABS_Y, 0);
705+
input_report_abs(input, ABS_DISTANCE, 0);
706+
input_report_abs(input, ABS_TILT_X, 0);
707+
input_report_abs(input, ABS_TILT_Y, 0);
708+
if (wacom->tool[idx] >= BTN_TOOL_MOUSE) {
709+
input_report_key(input, BTN_LEFT, 0);
710+
input_report_key(input, BTN_MIDDLE, 0);
711+
input_report_key(input, BTN_RIGHT, 0);
712+
input_report_key(input, BTN_SIDE, 0);
713+
input_report_key(input, BTN_EXTRA, 0);
714+
input_report_abs(input, ABS_THROTTLE, 0);
715+
input_report_abs(input, ABS_RZ, 0);
716+
} else {
717+
input_report_abs(input, ABS_PRESSURE, 0);
718+
input_report_key(input, BTN_STYLUS, 0);
719+
input_report_key(input, BTN_STYLUS2, 0);
720+
input_report_key(input, BTN_TOUCH, 0);
721+
input_report_abs(input, ABS_WHEEL, 0);
722+
if (features->type >= INTUOS3S)
723+
input_report_abs(input, ABS_Z, 0);
724+
}
725+
input_report_key(input, wacom->tool[idx], 0);
726+
input_report_abs(input, ABS_MISC, 0); /* reset tool id */
727+
input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
728+
wacom->id[idx] = 0;
729+
}
730+
692731
static int wacom_intuos_inout(struct wacom_wac *wacom)
693732
{
694733
struct wacom_features *features = &wacom->features;
@@ -741,36 +780,7 @@ static int wacom_intuos_inout(struct wacom_wac *wacom)
741780
if (!wacom->id[idx])
742781
return 1;
743782

744-
/*
745-
* Reset all states otherwise we lose the initial states
746-
* when in-prox next time
747-
*/
748-
input_report_abs(input, ABS_X, 0);
749-
input_report_abs(input, ABS_Y, 0);
750-
input_report_abs(input, ABS_DISTANCE, 0);
751-
input_report_abs(input, ABS_TILT_X, 0);
752-
input_report_abs(input, ABS_TILT_Y, 0);
753-
if (wacom->tool[idx] >= BTN_TOOL_MOUSE) {
754-
input_report_key(input, BTN_LEFT, 0);
755-
input_report_key(input, BTN_MIDDLE, 0);
756-
input_report_key(input, BTN_RIGHT, 0);
757-
input_report_key(input, BTN_SIDE, 0);
758-
input_report_key(input, BTN_EXTRA, 0);
759-
input_report_abs(input, ABS_THROTTLE, 0);
760-
input_report_abs(input, ABS_RZ, 0);
761-
} else {
762-
input_report_abs(input, ABS_PRESSURE, 0);
763-
input_report_key(input, BTN_STYLUS, 0);
764-
input_report_key(input, BTN_STYLUS2, 0);
765-
input_report_key(input, BTN_TOUCH, 0);
766-
input_report_abs(input, ABS_WHEEL, 0);
767-
if (features->type >= INTUOS3S)
768-
input_report_abs(input, ABS_Z, 0);
769-
}
770-
input_report_key(input, wacom->tool[idx], 0);
771-
input_report_abs(input, ABS_MISC, 0); /* reset tool id */
772-
input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
773-
wacom->id[idx] = 0;
783+
wacom_exit_report(wacom);
774784
return 2;
775785
}
776786

@@ -1235,6 +1245,12 @@ static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom)
12351245
if (!valid)
12361246
continue;
12371247

1248+
if (!prox) {
1249+
wacom->shared->stylus_in_proximity = false;
1250+
wacom_exit_report(wacom);
1251+
input_sync(pen_input);
1252+
return;
1253+
}
12381254
if (range) {
12391255
input_report_abs(pen_input, ABS_X, get_unaligned_le16(&frame[1]));
12401256
input_report_abs(pen_input, ABS_Y, get_unaligned_le16(&frame[3]));

0 commit comments

Comments
 (0)