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. [jkosina@suse.cz: fix if-else style] Signed-off-by: Ping Cheng <pingc@wacom.com> Reviewed-by: Jason Gerecke <jason.gerecke@wacom.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
This commit is contained in:
parent
7d059ed01c
commit
0149931e6d
|
@ -1768,9 +1768,6 @@ static int wacom_bpt_pen(struct wacom_wac *wacom)
|
||||||
if (data[0] != WACOM_REPORT_PENABLED)
|
if (data[0] != WACOM_REPORT_PENABLED)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (wacom->shared->touch_down)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
prox = (data[1] & 0x20) == 0x20;
|
prox = (data[1] & 0x20) == 0x20;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1783,17 +1780,21 @@ static int wacom_bpt_pen(struct wacom_wac *wacom)
|
||||||
*
|
*
|
||||||
* Hardware does report zero in most out-of-prox cases but not all.
|
* Hardware does report zero in most out-of-prox cases but not all.
|
||||||
*/
|
*/
|
||||||
if (prox) {
|
if (!wacom->shared->stylus_in_proximity) {
|
||||||
if (!wacom->shared->stylus_in_proximity) {
|
if (data[1] & 0x08) {
|
||||||
if (data[1] & 0x08) {
|
wacom->tool[0] = BTN_TOOL_RUBBER;
|
||||||
wacom->tool[0] = BTN_TOOL_RUBBER;
|
wacom->id[0] = ERASER_DEVICE_ID;
|
||||||
wacom->id[0] = ERASER_DEVICE_ID;
|
} else {
|
||||||
} else {
|
wacom->tool[0] = BTN_TOOL_PEN;
|
||||||
wacom->tool[0] = BTN_TOOL_PEN;
|
wacom->id[0] = STYLUS_DEVICE_ID;
|
||||||
wacom->id[0] = STYLUS_DEVICE_ID;
|
|
||||||
}
|
|
||||||
wacom->shared->stylus_in_proximity = true;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
wacom->shared->stylus_in_proximity = prox;
|
||||||
|
if (wacom->shared->touch_down)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (prox) {
|
||||||
x = le16_to_cpup((__le16 *)&data[2]);
|
x = le16_to_cpup((__le16 *)&data[2]);
|
||||||
y = le16_to_cpup((__le16 *)&data[4]);
|
y = le16_to_cpup((__le16 *)&data[4]);
|
||||||
p = le16_to_cpup((__le16 *)&data[6]);
|
p = le16_to_cpup((__le16 *)&data[6]);
|
||||||
|
@ -1809,6 +1810,8 @@ static int wacom_bpt_pen(struct wacom_wac *wacom)
|
||||||
pen = data[1] & 0x01;
|
pen = data[1] & 0x01;
|
||||||
btn1 = data[1] & 0x02;
|
btn1 = data[1] & 0x02;
|
||||||
btn2 = data[1] & 0x04;
|
btn2 = data[1] & 0x04;
|
||||||
|
} else {
|
||||||
|
wacom->id[0] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
input_report_key(input, BTN_TOUCH, pen);
|
input_report_key(input, BTN_TOUCH, pen);
|
||||||
|
@ -1820,11 +1823,6 @@ static int wacom_bpt_pen(struct wacom_wac *wacom)
|
||||||
input_report_abs(input, ABS_PRESSURE, p);
|
input_report_abs(input, ABS_PRESSURE, p);
|
||||||
input_report_abs(input, ABS_DISTANCE, d);
|
input_report_abs(input, ABS_DISTANCE, d);
|
||||||
|
|
||||||
if (!prox) {
|
|
||||||
wacom->id[0] = 0;
|
|
||||||
wacom->shared->stylus_in_proximity = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
input_report_key(input, wacom->tool[0], prox); /* PEN or RUBBER */
|
input_report_key(input, wacom->tool[0], prox); /* PEN or RUBBER */
|
||||||
input_report_abs(input, ABS_MISC, wacom->id[0]); /* TOOL ID */
|
input_report_abs(input, ABS_MISC, wacom->id[0]); /* TOOL ID */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue