From a98c9b3bee6eabcffb31bc6e0878b0209c436b09 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 3 Jun 2013 13:35:28 +1000 Subject: [PATCH] Export version fields as well Signed-off-by: Peter Hutterer --- libevdev/libevdev-int.h | 1 + libevdev/libevdev.c | 14 ++++++++++++++ libevdev/libevdev.h | 14 ++++++++++++++ man/libevdev_get_name.txt | 19 ++++++++++++++++--- test/libevdev-print.c | 1 + 5 files changed, 46 insertions(+), 3 deletions(-) diff --git a/libevdev/libevdev-int.h b/libevdev/libevdev-int.h index 492608a..b36450c 100644 --- a/libevdev/libevdev-int.h +++ b/libevdev/libevdev-int.h @@ -54,6 +54,7 @@ struct libevdev { char name[MAX_NAME]; struct input_id ids; + int driver_version; unsigned long bits[NLONGS(EV_CNT)]; unsigned long props[NLONGS(INPUT_PROP_CNT)]; unsigned long key_bits[NLONGS(KEY_CNT)]; diff --git a/libevdev/libevdev.c b/libevdev/libevdev.c index 9604669..0bac662 100644 --- a/libevdev/libevdev.c +++ b/libevdev/libevdev.c @@ -220,6 +220,10 @@ libevdev_set_fd(struct libevdev* dev, int fd) if (rc < 0) goto out; + rc = ioctl(fd, EVIOCGVERSION, &dev->driver_version); + if (rc < 0) + goto out; + rc = ioctl(fd, EVIOCGPROP(sizeof(dev->props)), dev->props); if (rc < 0) goto out; @@ -599,6 +603,16 @@ int libevdev_get_bustype(const struct libevdev *dev) return dev->ids.bustype; } +int libevdev_get_version(const struct libevdev *dev) +{ + return dev->ids.version; +} + +int libevdev_get_driver_version(const struct libevdev *dev) +{ + return dev->driver_version; +} + int libevdev_has_property(const struct libevdev *dev, unsigned int prop) { diff --git a/libevdev/libevdev.h b/libevdev/libevdev.h index 5f58bc0..169c0bc 100644 --- a/libevdev/libevdev.h +++ b/libevdev/libevdev.h @@ -202,6 +202,20 @@ int libevdev_get_vendor_id(const struct libevdev *dev); int libevdev_get_bustype(const struct libevdev *dev); /** + * @return The device's firmware version + * + * @note This function is signal-safe. + */ +int libevdev_get_version(const struct libevdev *dev); + +/** + * @return The driver version for this device + * + * @note This function is signal-safe. + */ +int libevdev_get_driver_version(const struct libevdev *dev); + +/** * @return 1 if the device supports this event type, or 0 otherwise. * * @note This function is signal-safe diff --git a/man/libevdev_get_name.txt b/man/libevdev_get_name.txt index 9b274dc..77db62f 100644 --- a/man/libevdev_get_name.txt +++ b/man/libevdev_get_name.txt @@ -4,7 +4,8 @@ libevdev_get_name(3) NAME ---- -libevdev_get_name, libevdev_get_product_id, libevdev_get_vendor_id, libevdev_get_bustype - retreive information about this device +libevdev_get_name, libevdev_get_product_id, libevdev_get_vendor_id, +libevdev_get_bustype, libevdev_get_version, libevdev_get_driver_version - retreive information about this device SYNOPSIS -------- @@ -19,6 +20,10 @@ int libevdev_get_vendor_id(const struct libevdev *dev); int libevdev_get_bustype(const struct libevdev *dev); +int libevdev_get_version(const struct libevdev *dev); + +int libevdev_get_driver_version(const struct libevdev *dev); + DESCRIPTION ----------- @@ -30,6 +35,11 @@ product and vendor ID as set by the kernel. *libevdev_get_bustype* returns the numeric bus type as set by the kernel. +*libevdev_get_version* returns the firmware or driver version. + +*libevdev_get_driver_version* returns the version of the evdev kernel +driver. + PARAMETERS ---------- *dev*:: @@ -40,8 +50,11 @@ RETURN VALUE *libevdev_get_name* returns a const pointer to the device name. *libevdev_get_product_id*, *libevdev_get_vendor_id* and -*libevdev_get_bustype* return the numeric product ID, vendor ID, or bus -type. +*libevdev_get_bustype*, *libevdev_get_version* return the numeric product +ID, vendor ID, bus type or version. + +*libevdev_get_driver_version* returns the version of the evdev kernel +driver. SEE ALSO -------- diff --git a/test/libevdev-print.c b/test/libevdev-print.c index 89f4b10..5d955a7 100644 --- a/test/libevdev-print.c +++ b/test/libevdev-print.c @@ -135,6 +135,7 @@ main(int argc, char **argv) libevdev_get_bustype(dev), libevdev_get_vendor_id(dev), libevdev_get_product_id(dev)); + printf("Evdev version: %x\n", libevdev_get_driver_version(dev)); printf("Input device name: \"%s\"\n", libevdev_get_name(dev)); print_bits(dev); print_props(dev); -- 2.7.4