mirror of
https://gitlab.freedesktop.org/libevdev/libevdev.git
synced 2025-12-26 23:50:07 +01:00
Update the MT state properly
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
3e22ef86ab
commit
4ae4f24ef7
2 changed files with 22 additions and 1 deletions
|
|
@ -64,6 +64,7 @@ struct libevdev {
|
|||
struct input_absinfo abs_info[ABS_CNT];
|
||||
unsigned int mt_slot_vals[MAX_SLOTS][ABS_MT_CNT];
|
||||
int num_slots; /**< valid slots in mt_slot_vals */
|
||||
int current_slot;
|
||||
|
||||
int need_sync;
|
||||
int grabbed;
|
||||
|
|
|
|||
|
|
@ -150,6 +150,7 @@ libevdev_new(int fd)
|
|||
|
||||
dev = calloc(1, sizeof(*dev));
|
||||
dev->num_slots = -1;
|
||||
dev->current_slot = -1;
|
||||
dev->log = libevdev_noop_log_func;
|
||||
|
||||
if (fd >= 0)
|
||||
|
|
@ -237,8 +238,10 @@ libevdev_set_fd(struct libevdev* dev, int fd)
|
|||
if (rc < 0)
|
||||
goto out;
|
||||
|
||||
if (i == ABS_MT_SLOT)
|
||||
if (i == ABS_MT_SLOT) {
|
||||
dev->num_slots = abs_info.maximum + 1; /* FIXME: non-zero min? */
|
||||
dev->current_slot = abs_info.value;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -438,6 +441,20 @@ update_key_state(struct libevdev *dev, const struct input_event *e)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
update_mt_state(struct libevdev *dev, const struct input_event *e)
|
||||
{
|
||||
if (e->code == ABS_MT_SLOT) {
|
||||
dev->current_slot = e->value;
|
||||
return 0;
|
||||
} else if (dev->current_slot == -1)
|
||||
return 1;
|
||||
|
||||
dev->mt_slot_vals[dev->current_slot][e->code - ABS_MT_MIN] = e->value;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
update_abs_state(struct libevdev *dev, const struct input_event *e)
|
||||
{
|
||||
|
|
@ -447,6 +464,9 @@ update_abs_state(struct libevdev *dev, const struct input_event *e)
|
|||
if (e->code > ABS_MAX)
|
||||
return 1;
|
||||
|
||||
if (e->code >= ABS_MT_MIN && e->code <= ABS_MT_MAX)
|
||||
return update_mt_state(dev, e);
|
||||
|
||||
dev->abs_info[e->code].value = e->value;
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue