@@ -689,6 +689,45 @@ static int wacom_intuos_get_tool_type(int tool_id)
689
689
return tool_type ;
690
690
}
691
691
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
+
692
731
static int wacom_intuos_inout (struct wacom_wac * wacom )
693
732
{
694
733
struct wacom_features * features = & wacom -> features ;
@@ -741,36 +780,7 @@ static int wacom_intuos_inout(struct wacom_wac *wacom)
741
780
if (!wacom -> id [idx ])
742
781
return 1 ;
743
782
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 );
774
784
return 2 ;
775
785
}
776
786
@@ -1235,6 +1245,12 @@ static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom)
1235
1245
if (!valid )
1236
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
1254
if (range ) {
1239
1255
input_report_abs (pen_input , ABS_X , get_unaligned_le16 (& frame [1 ]));
1240
1256
input_report_abs (pen_input , ABS_Y , get_unaligned_le16 (& frame [3 ]));
0 commit comments