[PATCH evemu 03/10] make-event-names: allow for one-way mappings
Peter Hutterer
peter.hutterer at who-t.net
Mon Aug 4 21:01:45 PDT 2014
BTN_MISC and others are currently dropped, but if we want to support
string->value mappings we need to parse those correctly.
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
src/make-event-names.py | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/src/make-event-names.py b/src/make-event-names.py
index fce39a3..324647c 100755
--- a/src/make-event-names.py
+++ b/src/make-event-names.py
@@ -33,6 +33,10 @@ prefixes = [
blacklist = [
"EV_VERSION",
+]
+
+# These defines only work from string->value, not the other way round
+oneway = [
"BTN_MISC",
"BTN_MOUSE",
"BTN_JOYSTICK",
@@ -51,7 +55,10 @@ def print_python_bits(bits, prefix):
print("%s_map = {" % (prefix))
for val, name in getattr(bits, prefix).items():
- print(" %d : \"%s\", \"%s\" : %d," % (val, name, name, val))
+ if val in oneway:
+ print(" \"%s\" : %d," % (val, name))
+ else:
+ print(" %d : \"%s\", \"%s\" : %d," % (val, name, name, val))
print("}")
print("")
@@ -118,7 +125,10 @@ def parse_define(bits, line):
if not hasattr(bits, attrname):
setattr(bits, attrname, {})
b = getattr(bits, attrname)
- b[value] = name
+ if name in oneway:
+ b[name] = value
+ else:
+ b[value] = name
def parse(path):
fp = open(path)
--
1.9.3
More information about the Input-tools
mailing list