uinput-mapper/py/map.py

27 lines
628 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-17 18:48:24 -04:00
f = open(sys.argv[1] if len(sys.argv) else "/dev/input/event8")
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
if ev.type == cinput.EV_KEY:
2013-04-17 18:48:24 -04:00
print cinput.rev_keys[ev.code]
if ev.type == cinput.EV_REL:
print cinput.rev_rel[ev.code]
if ev.type == cinput.EV_ABS:
print cinput.rev_absaxes[ev.code]
if ev.type == cinput.EV_SYN:
print cinput.rev_syn[ev.code]
#print e.contents.type
#print e.contents.code
#print e.contents.value
2013-04-17 18:34:45 -04:00