From ee054e9cf938c508a59b945dc52c7cfcdf2068d2 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 30 May 2013 14:02:17 +1000 Subject: [PATCH] Add a function to retrieve the current slot Signed-off-by: Peter Hutterer --- libevdev/libevdev.c | 6 ++++++ libevdev/libevdev.h | 11 +++++++++++ 2 files changed, 17 insertions(+) diff --git a/libevdev/libevdev.c b/libevdev/libevdev.c index 40bbe37..0523c53 100644 --- a/libevdev/libevdev.c +++ b/libevdev/libevdev.c @@ -677,6 +677,12 @@ libevdev_get_num_slots(const struct libevdev *dev) return dev->num_slots; } +int +libevdev_get_current_slot(const struct libevdev *dev) +{ + return dev->current_slot; +} + const struct input_absinfo* libevdev_get_abs_info(const struct libevdev *dev, unsigned int code) { diff --git a/libevdev/libevdev.h b/libevdev/libevdev.h index b067015..4a6e183 100644 --- a/libevdev/libevdev.h +++ b/libevdev/libevdev.h @@ -309,6 +309,17 @@ int libevdev_fetch_slot_value(const struct libevdev *dev, unsigned int slot, uns int libevdev_get_num_slots(const struct libevdev *dev); /** + * Get the currently active slot. This may differ from the value + * an ioctl may return at this time as events may have been read off the fd + * since changing the slot value but those events are still in the buffer + * waiting to be processed. The returned value is the value a caller would + * see if it were to process events manually one-by-one. + * + * @return the currently active slot (logically) + */ +int libevdev_get_current_slot(const struct libevdev *dev); + +/** * Forcibly enable an event type on this device, even if the underlying * device does not support it. While this cannot make the device actually * report such events, it will now return true for libevdev_has_event_type. -- 2.7.4