Skip to content

Commit 0fd80a7

Browse files
KT Liaodtor
authored andcommitted
Input: update input_mt_report_pointer_emulation to support hovering
For devices that are incapable of reporting per-contact distance and can only report ABS_DISTANCE, just distance is not enough for upper layers of OS to determine whether contact is leaving the area or if it is continuing hovering, we need BTN_TOOL_FINGER for that: Contact State Inactive Hovering Active (far away) (inside hover area) (touching surface) BTN_TOUCH 0 0 1 BTN_TOOL_FINGER 0 1 1 ABS_DISTANCE N/A 1 0 Signed-off-by: KT Liao <kt.liao@emc.com.tw> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
1 parent cd46729 commit 0fd80a7

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

‎drivers/input/input-mt.c‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,23 @@ void input_mt_report_pointer_emulation(struct input_dev *dev, bool use_count)
218218
}
219219

220220
input_event(dev, EV_KEY, BTN_TOUCH, count > 0);
221-
if (use_count)
221+
222+
if (use_count) {
223+
if (count == 0 &&
224+
!test_bit(ABS_MT_DISTANCE, dev->absbit) &&
225+
test_bit(ABS_DISTANCE, dev->absbit) &&
226+
input_abs_get_val(dev, ABS_DISTANCE) != 0) {
227+
/*
228+
* Force reporting BTN_TOOL_FINGER for devices that
229+
* only report general hover (and not per-contact
230+
* distance) when contact is in proximity but not
231+
* on the surface.
232+
*/
233+
count = 1;
234+
}
235+
222236
input_mt_report_finger_count(dev, count);
237+
}
223238

224239
if (oldest) {
225240
int x = input_mt_get_value(oldest, ABS_MT_POSITION_X);

0 commit comments

Comments
 (0)