[PATCH evemu 09/10] python: add top-level wrappers for getting code/type names and values

Peter Hutterer peter.hutterer at who-t.net
Mon Aug 4 21:01:51 PDT 2014


Rather than having those hidden in a submodule, expose them as evemu
functions, with a defined behaviour and different naming for getting
values vs names.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 python/evemu/__init__.py | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/python/evemu/__init__.py b/python/evemu/__init__.py
index 5b857b6..656b744 100644
--- a/python/evemu/__init__.py
+++ b/python/evemu/__init__.py
@@ -4,6 +4,7 @@ raw events.
 """
 
 # Copyright 2011-2012 Canonical Ltd.
+# Copyright 2014 Red Hat, Inc.
 #
 # This library is free software: you can redistribute it and/or modify it 
 # under the terms of the GNU Lesser General Public License version 3 
@@ -30,6 +31,25 @@ import evemu.event_names
 
 __all__ = ["Device"]
 
+def event_get_value(event_type, event_code = None):
+    """
+    Return the integer-value for the given event type and/or code string
+    e.g. "EV_ABS" returns 0x03, ("EV_ABS", "ABS_Y") returns 0x01
+
+    If an event code is passed, the event type may be given as integer or
+    string.
+    """
+    return evemu.event_names.event_get_value(event_type, event_code)
+
+def event_get_name(event_type, event_code = None):
+    """
+    Return the string-value for the given event type and/or code value
+    e.g. 0x03 returns "EV_ABS", ("EV_ABS", 0x01) returns "ABS_Y"
+
+    If an event code is passed, the event type may be given as integer or
+    string.
+    """
+    return evemu.event_names.event_get_name(event_type, event_code)
 
 class InputEvent(object):
     __slots__ = 'sec', 'usec', 'type', 'code', 'value'
-- 
1.9.3



More information about the Input-tools mailing list