aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Armstrong Skomra <skomra@gmail.com>2018-04-04 17:24:11 -0400
committerJiri Kosina <jkosina@suse.cz>2018-04-12 08:03:40 -0400
commit619d3a2922ce623ca2eca443cc936810d328317c (patch)
treea08c4be7bd60dda0c0b6b6d2ec24f3d1adc2ed97
parenta955358d54695e4ad9f7d6489a7ac4d69a8fc711 (diff)
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: 4922cd26f0 ("HID: wacom: Support 2nd-gen Intuos Pro's Bluetooth classic interface") Cc: <stable@vger.kernel.org> # 4.11 Signed-off-by: Aaron Armstrong Skomra <aaron.skomra@wacom.com> Reviewed-by: Ping Cheng <ping.cheng@wacom.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
-rw-r--r--drivers/hid/wacom_wac.c76
1 files changed, 46 insertions, 30 deletions
diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index 6da16a879c9f..5f947ec20dcb 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -689,6 +689,45 @@ static int wacom_intuos_get_tool_type(int tool_id)
689 return tool_type; 689 return tool_type;
690} 690}
691 691
692static 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
692static int wacom_intuos_inout(struct wacom_wac *wacom) 731static int wacom_intuos_inout(struct wacom_wac *wacom)
693{ 732{
694 struct wacom_features *features = &wacom->features; 733 struct wacom_features *features = &wacom->features;
@@ -741,36 +780,7 @@ static int wacom_intuos_inout(struct wacom_wac *wacom)
741 if (!wacom->id[idx]) 780 if (!wacom->id[idx])
742 return 1; 781 return 1;
743 782
744 /* 783 wacom_exit_report(wacom);
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;
774 return 2; 784 return 2;
775 } 785 }
776 786
@@ -1235,6 +1245,12 @@ static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom)
1235 if (!valid) 1245 if (!valid)
1236 continue; 1246 continue;
1237 1247
1248 if (!prox) {
1249 wacom->shared->stylus_in_proximity = false;
1250 wacom_exit_report(wacom);
1251 input_sync(pen_input);
1252 return;
1253 }
1238 if (range) { 1254 if (range) {
1239 input_report_abs(pen_input, ABS_X, get_unaligned_le16(&frame[1])); 1255 input_report_abs(pen_input, ABS_X, get_unaligned_le16(&frame[1]));
1240 input_report_abs(pen_input, ABS_Y, get_unaligned_le16(&frame[3])); 1256 input_report_abs(pen_input, ABS_Y, get_unaligned_le16(&frame[3]));