2013-04-19 19:10:16 -04:00
|
|
|
from cinput import *
|
|
|
|
import ctypes
|
|
|
|
|
|
|
|
import sys
|
|
|
|
|
2013-04-20 05:54:17 -04:00
|
|
|
#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
|
|
|
|
2013-04-20 05:54:17 -04:00
|
|
|
print 'Version:', f.get_version()
|
|
|
|
print f.get_name()
|
2013-04-19 19:10:16 -04:00
|
|
|
|
2013-04-20 05:54:17 -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:
|
2013-04-20 05:54:17 -04:00
|
|
|
ev = f.next_event()
|
2013-04-19 19:10:16 -04:00
|
|
|
|
|
|
|
try:
|
2013-04-20 05:54:17 -04:00
|
|
|
print ev.time.tv_sec, ev.time.tv_usec
|
2013-04-20 19:46:44 -04:00
|
|
|
s = '%s %s %d' % (rev_events[ev.type], rev_event_keys[ev.type][ev.code], ev.value)
|
2013-04-20 05:54:17 -04:00
|
|
|
print 'Event type:', s
|
2013-04-19 19:10:16 -04:00
|
|
|
except KeyError:
|
|
|
|
pass
|