Skip to content

Commit 4e584ac

Browse files
Angela CzubakBenjamin Tissoires
authored andcommitted
Input: MT - add INPUT_MT_TOTAL_FORCE flags
Add a flag to generate ABS_PRESSURE as sum of ABS_MT_PRESSURE across all slots. This flag should be set if one knows a device reports true force and would like to report total force to the userspace. Signed-off-by: Angela Czubak <aczubak@google.com> Co-developed-by: Jonathan Denose <jdenose@google.com> Signed-off-by: Jonathan Denose <jdenose@google.com> Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Signed-off-by: Benjamin Tissoires <bentiss@kernel.org>
1 parent a77efca commit 4e584ac

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

drivers/input/input-mt.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ void input_mt_report_pointer_emulation(struct input_dev *dev, bool use_count)
198198
struct input_mt *mt = dev->mt;
199199
struct input_mt_slot *oldest;
200200
int oldid, count, i;
201+
int p, reported_p = 0;
201202

202203
if (!mt)
203204
return;
@@ -216,6 +217,13 @@ void input_mt_report_pointer_emulation(struct input_dev *dev, bool use_count)
216217
oldest = ps;
217218
oldid = id;
218219
}
220+
if (test_bit(ABS_MT_PRESSURE, dev->absbit)) {
221+
p = input_mt_get_value(ps, ABS_MT_PRESSURE);
222+
if (mt->flags & INPUT_MT_TOTAL_FORCE)
223+
reported_p += p;
224+
else if (oldid == id)
225+
reported_p = p;
226+
}
219227
count++;
220228
}
221229

@@ -245,10 +253,8 @@ void input_mt_report_pointer_emulation(struct input_dev *dev, bool use_count)
245253
input_event(dev, EV_ABS, ABS_X, x);
246254
input_event(dev, EV_ABS, ABS_Y, y);
247255

248-
if (test_bit(ABS_MT_PRESSURE, dev->absbit)) {
249-
int p = input_mt_get_value(oldest, ABS_MT_PRESSURE);
250-
input_event(dev, EV_ABS, ABS_PRESSURE, p);
251-
}
256+
if (test_bit(ABS_MT_PRESSURE, dev->absbit))
257+
input_event(dev, EV_ABS, ABS_PRESSURE, reported_p);
252258
} else {
253259
if (test_bit(ABS_MT_PRESSURE, dev->absbit))
254260
input_event(dev, EV_ABS, ABS_PRESSURE, 0);

include/linux/input/mt.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#define INPUT_MT_DROP_UNUSED 0x0004 /* drop contacts not seen in frame */
1818
#define INPUT_MT_TRACK 0x0008 /* use in-kernel tracking */
1919
#define INPUT_MT_SEMI_MT 0x0010 /* semi-mt device, finger count handled manually */
20+
#define INPUT_MT_TOTAL_FORCE 0x0020 /* calculate total force from slots pressure */
2021

2122
/**
2223
* struct input_mt_slot - represents the state of an input MT slot

0 commit comments

Comments
 (0)