uinput-mapper/py/map.py

26 lines
704 B
Python
Raw Normal View History

2013-04-17 18:34:45 -04:00
import cinput
import ctypes
2013-04-17 18:48:24 -04:00
import sys
2013-04-17 18:34:45 -04:00
2013-04-18 12:13:57 -04:00
f = open(sys.argv[1] if len(sys.argv) == 2 else "/dev/input/event3")
print 'Version:', cinput.get_input_version(f)
print cinput.get_input_name(f)
2013-04-18 18:10:15 -04:00
print [cinput.rev_keys[_] for _ in cinput.get_keys(f, cinput.EV_KEY)]
print [cinput.rev_absaxes[_] for _ in cinput.get_keys(f, cinput.EV_ABS)]
print [cinput.rev_rel[_] for _ in cinput.get_keys(f, cinput.EV_REL)]
2013-04-17 18:34:45 -04:00
while True:
2013-04-17 18:48:24 -04:00
estr = f.read(ctypes.sizeof(cinput.input_event))
2013-04-17 18:34:45 -04:00
2013-04-17 18:48:24 -04:00
e = ctypes.cast(estr, ctypes.POINTER(cinput.input_event))
2013-04-17 18:34:45 -04:00
ev = e.contents
2013-04-17 19:38:28 -04:00
print 'Event type:', cinput.rev_events[ev.type]
try:
print 'Code:', cinput.event_keys[ev.type][ev.code]
except KeyError:
2013-04-18 12:13:57 -04:00
pass