diff options
| author | Peter Hutterer <peter.hutterer@who-t.net> | 2013-08-15 11:10:17 +1000 |
|---|---|---|
| committer | Peter Hutterer <peter.hutterer@who-t.net> | 2013-08-26 09:52:33 +1000 |
| commit | edc31cf12ef9f99e22aacdc93f12dc1511cd6ad0 (patch) | |
| tree | bbdc20653d7603084bb35207b12869ae6e2fdb27 /libevdev/libevdev.c | |
| parent | f29e4118fcbc58ad79561e64f7ede15f59224240 (diff) | |
| download | libevdev-edc31cf12ef9f99e22aacdc93f12dc1511cd6ad0.tar.gz | |
Store the abs value after handling mt events
This way any ABS_MT_ event value that comes in will also be stored in abs_info.
That always corresponds to "current slot", so if a user calls
libevdev_set_event_value() or libevdev_get_event_value() they're actually
modifying the current slot value.
When the current slot changes, sync the state back into the absinfo values.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'libevdev/libevdev.c')
| -rw-r--r-- | libevdev/libevdev.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/libevdev/libevdev.c b/libevdev/libevdev.c index ba5b17f..e59d795 100644 --- a/libevdev/libevdev.c +++ b/libevdev/libevdev.c @@ -507,7 +507,14 @@ static int update_mt_state(struct libevdev *dev, const struct input_event *e) { if (e->code == ABS_MT_SLOT) { + int i; dev->current_slot = e->value; + /* sync abs_info with the current slot values */ + for (i = ABS_MT_SLOT + 1; i <= ABS_MT_MAX; i++) { + if (libevdev_has_event_code(dev, EV_ABS, i)) + dev->abs_info[i].value = dev->mt_slot_vals[dev->current_slot][i - ABS_MT_MIN]; + } + return 0; } else if (dev->current_slot == -1) return 1; @@ -527,7 +534,7 @@ update_abs_state(struct libevdev *dev, const struct input_event *e) return 1; if (e->code >= ABS_MT_MIN && e->code <= ABS_MT_MAX) - return update_mt_state(dev, e); + update_mt_state(dev, e); dev->abs_info[e->code].value = e->value; |
