|
|
|
@ -67,6 +67,7 @@ class TypingPool(Bureau):
|
|
|
|
|
def run_io(self):
|
|
|
|
|
val = ""
|
|
|
|
|
upper = False
|
|
|
|
|
ctrl = False
|
|
|
|
|
#TODO: this is crap, needs to be multi-threaded and have one
|
|
|
|
|
# such loop for each active device
|
|
|
|
|
self.active_devices[0].grab()
|
|
|
|
@ -74,7 +75,7 @@ class TypingPool(Bureau):
|
|
|
|
|
for ev in self.active_devices[0].read_loop():
|
|
|
|
|
if ev.type == evdev.ecodes.EV_KEY:
|
|
|
|
|
data = evdev.categorize(ev)
|
|
|
|
|
if data.keystate == 1:
|
|
|
|
|
if data.keystate == 1: # key-down
|
|
|
|
|
if data.scancode == 28:
|
|
|
|
|
print("sending barcode:", val)
|
|
|
|
|
self.send(val[0:2], val[2:])
|
|
|
|
@ -82,15 +83,27 @@ class TypingPool(Bureau):
|
|
|
|
|
else:
|
|
|
|
|
try:
|
|
|
|
|
new_key = KEYS[data.scancode]
|
|
|
|
|
if new_key == "LSHFT" or new_key == "RSHFT":
|
|
|
|
|
if ctrl and (new_key == "j"):
|
|
|
|
|
self.log.debug("ignoring line-feed")
|
|
|
|
|
elif new_key == "LSHFT" or new_key == "RSHFT":
|
|
|
|
|
upper = True
|
|
|
|
|
elif new_key == "LCTRL" or new_key == "RCTRL":
|
|
|
|
|
ctrl = True
|
|
|
|
|
else:
|
|
|
|
|
if upper:
|
|
|
|
|
new_key = new_key.upper()
|
|
|
|
|
upper = False
|
|
|
|
|
val += new_key
|
|
|
|
|
except KeyError:
|
|
|
|
|
print("Error invalid keycode:", data.scancode)
|
|
|
|
|
if data.keystate == 0: # key-up for mod-keys
|
|
|
|
|
try:
|
|
|
|
|
new_key = KEYS[data.scancode]
|
|
|
|
|
if new_key == "LSHFT" or new_key == "RSHFT":
|
|
|
|
|
upper = False
|
|
|
|
|
if new_key == "LCTRL" or new_key == "RCTRL":
|
|
|
|
|
ctrl = False
|
|
|
|
|
except KeyError:
|
|
|
|
|
print("Error invalid keycode:", data.scancode)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
|