uinput-mapper/py/read.py

25 lines
583 B
Python
Raw Normal View History

2013-04-19 19:10:16 -04:00
from cinput import *
import ctypes
import sys
#f = open(sys.argv[1] if len(sys.argv) == 2 else "/dev/input/event3")
f = InputDevice(sys.argv[1] if len(sys.argv) == 2 else "/dev/input/event3")
2013-04-19 19:10:16 -04:00
print 'Version:', f.get_version()
print f.get_name()
2013-04-19 19:10:16 -04:00
d = f.get_exposed_events()
for k, v in d.iteritems():
print k + ':', ', '.join(v)
2013-04-19 19:10:16 -04:00
while True:
ev = f.next_event()
2013-04-19 19:10:16 -04:00
try:
print ev.time.tv_sec, ev.time.tv_usec
s = '%s %s %d' % (rev_events[ev.type], rev_event_keys[ev.type][ev.code], ev.value)
print 'Event type:', s
2013-04-19 19:10:16 -04:00
except KeyError:
pass