Skip to content

Commit b3bd7ef

Browse files
PinglinuxJiri Kosina
authored andcommitted
HID: wacom: peport In Range event according to the spec
Some Cintiq and Intuos tablets report In Range event. This event is sent before valid data is reported when tool enters proximity; or before out of proximity event is reported when tool exits. While entering proximity, In Range means a pen is detected. This information can be used for palm/touch rejection on both pen and touch enabled devices. While exiting, it means the tool has reached its maximum detectable distance. Signed-off-by: Ping Cheng <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 373a535 commit b3bd7ef

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

drivers/hid/wacom_wac.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -443,9 +443,6 @@ static int wacom_intuos_inout(struct wacom_wac *wacom)
443443

444444
/* Enter report */
445445
if ((data[1] & 0xfc) == 0xc0) {
446-
if (features->quirks & WACOM_QUIRK_MULTI_INPUT)
447-
wacom->shared->stylus_in_proximity = true;
448-
449446
/* serial number of the tool */
450447
wacom->serial[idx] = ((data[3] & 0x0f) << 28) +
451448
(data[4] << 20) + (data[5] << 12) +
@@ -554,19 +551,22 @@ static int wacom_intuos_inout(struct wacom_wac *wacom)
554551
(features->type == CINTIQ && !(data[1] & 0x40)))
555552
return 1;
556553

557-
/* Range Report */
558-
if ((data[1] & 0xfe) == 0x20) {
554+
if (features->quirks & WACOM_QUIRK_MULTI_INPUT)
555+
wacom->shared->stylus_in_proximity = true;
556+
557+
/* in Range while exiting */
558+
if (((data[1] & 0xfe) == 0x20) && wacom->reporting_data) {
559559
input_report_key(input, BTN_TOUCH, 0);
560560
input_report_abs(input, ABS_PRESSURE, 0);
561561
input_report_abs(input, ABS_DISTANCE, wacom->features.distance_max);
562-
if (features->quirks & WACOM_QUIRK_MULTI_INPUT)
563-
wacom->shared->stylus_in_proximity = true;
562+
return 2;
564563
}
565564

566565
/* Exit report */
567566
if ((data[1] & 0xfe) == 0x80) {
568567
if (features->quirks & WACOM_QUIRK_MULTI_INPUT)
569568
wacom->shared->stylus_in_proximity = false;
569+
wacom->reporting_data = false;
570570

571571
/* don't report exit if we don't know the ID */
572572
if (!wacom->id[idx])
@@ -952,6 +952,7 @@ static int wacom_intuos_irq(struct wacom_wac *wacom)
952952
input_report_abs(input, ABS_MISC, wacom->id[idx]); /* report tool id */
953953
input_report_key(input, wacom->tool[idx], 1);
954954
input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
955+
wacom->reporting_data = true;
955956
return 1;
956957
}
957958

drivers/hid/wacom_wac.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ struct wacom_wac {
189189
int tool[2];
190190
int id[2];
191191
__u32 serial[2];
192+
bool reporting_data;
192193
struct wacom_features features;
193194
struct wacom_shared *shared;
194195
struct input_dev *input;

0 commit comments

Comments
 (0)