uinput-mapper/py/create.py

41 lines
697 B
Python
Raw Normal View History

import linux_uinput, ctypes, fcntl, os, sys
2013-04-18 19:11:56 -04:00
2013-04-19 19:10:16 -04:00
from cinput import *
2013-04-18 19:11:56 -04:00
2013-04-21 06:42:51 -04:00
from mapper import KeyMapper, parse_conf
2013-04-21 06:42:51 -04:00
from example_conf import config
2013-04-21 06:42:51 -04:00
clone = False
2013-04-21 06:42:51 -04:00
f = InputDevice(sys.argv[1] if len(sys.argv) == 2 else "/dev/input/event3")
d = UInputDevice()
if clone:
2013-04-21 06:42:51 -04:00
conf = parse_conf(f)
m = KeyMapper(conf)
else:
2013-04-21 06:42:51 -04:00
m = KeyMapper(config)
2013-04-21 06:42:51 -04:00
m.expose(d)
d.setup('Example input device' )
while True:
ev = f.next_event()
2013-04-18 19:11:56 -04:00
2013-04-21 06:42:51 -04:00
ev = m.map_event(ev)
2013-04-18 19:11:56 -04:00
d.fire_event(ev)
2013-04-18 19:11:56 -04:00
2013-04-21 06:42:51 -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 18:51:46 -04:00
2013-04-21 06:42:51 -04:00
#except KeyError:
# pass