[PATCH evemu 2/7] python: add wrappers around some libevdev utility functions

Peter Hutterer peter.hutterer at who-t.net
Thu Aug 28 16:44:04 PDT 2014


From: Benjamin Tissoires <benjamin.tissoires at gmail.com>

So we can get rid of the generated mapping tables.

Requires newest libevdev for libevdev_property_from_name()

Signed-off-by: Benjamin Tissoires <benjamin.tissoires at gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 configure.ac         |  2 +-
 python/evemu/base.py | 41 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 36ed15b..c1ee33e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -34,7 +34,7 @@ AC_PROG_INSTALL
 AC_PROG_MKDIR_P
 AM_PATH_PYTHON([2.6])
 
-PKG_CHECK_MODULES([LIBEVDEV], [libevdev >= 0.5])
+PKG_CHECK_MODULES([LIBEVDEV], [libevdev >= 1.2.99.902])
 
 # man page generation
 AC_ARG_VAR([XMLTO], [Path to xmlto command])
diff --git a/python/evemu/base.py b/python/evemu/base.py
index 03c7d5e..5dd2e89 100644
--- a/python/evemu/base.py
+++ b/python/evemu/base.py
@@ -158,6 +158,47 @@ class LibC(LibraryWrapper):
             },
         }
 
+class LibEvdev(LibraryWrapper):
+    """
+    Wrapper for API calls to libevdev
+    """
+
+    @staticmethod
+    def _cdll():
+        return ctypes.CDLL("libevdev.so", use_errno=True)
+
+    _api_prototypes = {
+        #const char *libevdev_event_type_get_name(unsigned int type);
+        "libevdev_event_type_get_name": {
+            "argtypes": (c_uint,),
+            "restype": c_char_p
+            },
+        #int libevdev_event_type_from_name(const char *name);
+        "libevdev_event_type_from_name": {
+            "argtypes": (c_char_p,),
+            "restype": c_int
+            },
+        #const char *libevdev_event_code_get_name(unsigned int type, unsigned int code);
+        "libevdev_event_code_get_name": {
+            "argtypes": (c_uint, c_uint,),
+            "restype": c_char_p
+            },
+        #int libevdev_event_code_from_name(unsigned int type, const char *name);
+        "libevdev_event_code_from_name": {
+            "argtypes": (c_uint, c_char_p,),
+            "restype": c_int
+            },
+        #const char *libevdev_property_get_name(unsigned int prop);
+        "libevdev_property_get_name": {
+            "argtypes": (c_uint,),
+            "restype": c_char_p
+            },
+        #int libevdev_property_from_name(const char *name);
+        "libevdev_property_from_name": {
+            "argtypes": (c_char_p,),
+            "restype": c_int
+            },
+        }
 
 class LibEvemu(LibraryWrapper):
     """
-- 
1.9.3



More information about the Input-tools mailing list