Skip to content

Commit 0149931

Browse files
PinglinuxJiri Kosina
authored andcommitted
HID: wacom: set stylus_in_proximity before checking touch_down
In wacom_bpt_pen, we checked touch_down before assigning new stylus_in_proximity value. This would cause stylus_in_proximity not updated properly if touch is down before pen is in proximity. [[email protected]: fix if-else style] Signed-off-by: Ping Cheng <[email protected]> Reviewed-by: Jason Gerecke <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 7d059ed commit 0149931

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

drivers/hid/wacom_wac.c

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1768,9 +1768,6 @@ static int wacom_bpt_pen(struct wacom_wac *wacom)
17681768
if (data[0] != WACOM_REPORT_PENABLED)
17691769
return 0;
17701770

1771-
if (wacom->shared->touch_down)
1772-
return 0;
1773-
17741771
prox = (data[1] & 0x20) == 0x20;
17751772

17761773
/*
@@ -1783,17 +1780,21 @@ static int wacom_bpt_pen(struct wacom_wac *wacom)
17831780
*
17841781
* Hardware does report zero in most out-of-prox cases but not all.
17851782
*/
1786-
if (prox) {
1787-
if (!wacom->shared->stylus_in_proximity) {
1788-
if (data[1] & 0x08) {
1789-
wacom->tool[0] = BTN_TOOL_RUBBER;
1790-
wacom->id[0] = ERASER_DEVICE_ID;
1791-
} else {
1792-
wacom->tool[0] = BTN_TOOL_PEN;
1793-
wacom->id[0] = STYLUS_DEVICE_ID;
1794-
}
1795-
wacom->shared->stylus_in_proximity = true;
1783+
if (!wacom->shared->stylus_in_proximity) {
1784+
if (data[1] & 0x08) {
1785+
wacom->tool[0] = BTN_TOOL_RUBBER;
1786+
wacom->id[0] = ERASER_DEVICE_ID;
1787+
} else {
1788+
wacom->tool[0] = BTN_TOOL_PEN;
1789+
wacom->id[0] = STYLUS_DEVICE_ID;
17961790
}
1791+
}
1792+
1793+
wacom->shared->stylus_in_proximity = prox;
1794+
if (wacom->shared->touch_down)
1795+
return 0;
1796+
1797+
if (prox) {
17971798
x = le16_to_cpup((__le16 *)&data[2]);
17981799
y = le16_to_cpup((__le16 *)&data[4]);
17991800
p = le16_to_cpup((__le16 *)&data[6]);
@@ -1809,6 +1810,8 @@ static int wacom_bpt_pen(struct wacom_wac *wacom)
18091810
pen = data[1] & 0x01;
18101811
btn1 = data[1] & 0x02;
18111812
btn2 = data[1] & 0x04;
1813+
} else {
1814+
wacom->id[0] = 0;
18121815
}
18131816

18141817
input_report_key(input, BTN_TOUCH, pen);
@@ -1820,11 +1823,6 @@ static int wacom_bpt_pen(struct wacom_wac *wacom)
18201823
input_report_abs(input, ABS_PRESSURE, p);
18211824
input_report_abs(input, ABS_DISTANCE, d);
18221825

1823-
if (!prox) {
1824-
wacom->id[0] = 0;
1825-
wacom->shared->stylus_in_proximity = false;
1826-
}
1827-
18281826
input_report_key(input, wacom->tool[0], prox); /* PEN or RUBBER */
18291827
input_report_abs(input, ABS_MISC, wacom->id[0]); /* TOOL ID */
18301828

0 commit comments

Comments
 (0)