blob: f53433c04b6edab2bf982d38fa9893c636adf897 [file] [log] [blame]
From eec34acf18f7dd7320fc1be6ae2b3efb4ca9783d Mon Sep 17 00:00:00 2001
From: Dennis Kempin <denniskempin@chromium.org>
Date: Tue, 12 Jun 2012 15:56:24 -0700
Subject: [PATCH] api extension: access to raw kernel input_ structures and
bitmasks
This CL adds functions to the api that allow raw access to the
input_id and input_absinfo structures as well as bitmasks.
This allows the regression test suite to use the evemu API for
reading device properties from files.
BUG=chromium-os:31732
TEST=compiles. tested with regression test prototype.
---
include/evemu.h | 46 ++++++++++++++++++++++++++++++++++++++++++++++
src/evemu.c | 26 ++++++++++++++++++++++++++
2 files changed, 72 insertions(+), 0 deletions(-)
diff --git a/include/evemu.h b/include/evemu.h
index 05cef0f..1fb8390 100644
--- a/include/evemu.h
+++ b/include/evemu.h
@@ -329,4 +329,50 @@ int evemu_create(const struct evemu_device *dev, int fd);
*/
void evemu_destroy(int fd);
+/**
+ * evemu_get_id() - raw access to kernel device id structure
+ * @dev: the device in use
+ *
+ * Returns the kernel device id structure.
+ */
+struct input_id* evemu_get_id(const struct evemu_device *dev);
+
+/**
+ * evemu_get_abs() - raw access to kernel absinfo structure
+ * @dev: the device in use
+ * @code: the event type code to query
+ *
+ * Returns the input_absinfo structure for provided event type code
+ */
+const struct info_absinfo*
+evemu_get_abs(const struct evemu_device *dev, int code);
+
+/**
+ * evemu_get_mask_size() - get the bitmask size
+ * @dev: the device in use
+ *
+ * Returns the size of bitmasks as returned by evemu_get_prop_mask
+ * or evemu_get_mask. Size in bytes.
+ * The bitmask size is static and defined at compile time, but might conflict
+ * when evemu and the calling library are using incompatible kernel header.
+ */
+int evemu_get_mask_size(const struct evemu_device *dev);
+
+/**
+ * evemu_get_prop_mask() - raw access to the kernel property bitmask
+ * @dev: the device in use
+ *
+ * Returns a pointer to the property bitmask
+ */
+const unsigned char* evemu_get_prop_mask(const struct evemu_device *dev);
+
+/**
+ * evemu_get_mask() - raw access to event bitmasks
+ * @dev: the device in use
+ * @code: the event type code to query
+ *
+ * Returns a pointer to the queried bitmask.
+ */
+const unsigned char* evemu_get_mask(const struct evemu_device *dev, int code);
+
#endif
diff --git a/src/evemu.c b/src/evemu.c
index 29a2c69..0dd1cab 100644
--- a/src/evemu.c
+++ b/src/evemu.c
@@ -564,3 +564,29 @@ void evemu_destroy(int fd)
int ret;
SYSCALL(ret = ioctl(fd, UI_DEV_DESTROY, NULL));
}
+
+struct input_id* evemu_get_id(const struct evemu_device *dev)
+{
+ return &dev->id;
+}
+
+const struct info_absinfo*
+evemu_get_abs(const struct evemu_device *dev, int code)
+{
+ return &dev->abs[code];
+}
+
+int evemu_get_mask_size(const struct evemu_device *dev)
+{
+ return EVPLAY_NBYTES;
+}
+
+const unsigned char* evemu_get_prop_mask(const struct evemu_device *dev)
+{
+ return dev->prop;
+}
+
+const unsigned char* evemu_get_mask(const struct evemu_device *dev, int code)
+{
+ return dev->mask[code];
+}
--
1.7.7.3