From 42d4bebde7d3cc7f536dec114ca5a54072b9e21b Mon Sep 17 00:00:00 2001 From: jaseg Date: Thu, 8 Nov 2018 21:53:25 +0900 Subject: Basic input demo working on qubes This commit was typed with it ^_^ --- hexnoise.py | 88 +++++++++++++++++++++--------- keymap.py | 176 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 239 insertions(+), 25 deletions(-) create mode 100644 keymap.py diff --git a/hexnoise.py b/hexnoise.py index 31d7695..df71d93 100755 --- a/hexnoise.py +++ b/hexnoise.py @@ -38,8 +38,8 @@ def send_packet(ser, data, width=16): def receive_packet(ser, width=16): packet = ser.read_until(b'\0') data = cobs.decode(packet[:-1]) - #print(f'\033[93mReceived {len(data)} bytes\033[0m') - #hexdump(print, data, width) + print(f'\033[93mReceived {len(data)} bytes\033[0m') + hexdump(print, data, width) return data if __name__ == '__main__': @@ -54,6 +54,23 @@ if __name__ == '__main__': ser = serial.Serial(args.serial, args.baudrate) + import uinput + ALL_KEYS = [ v for k, v in uinput.ev.__dict__.items() if k.startswith('KEY_') ] + MODIFIERS = [ + uinput.ev.KEY_LEFTCTRL, + uinput.ev.KEY_LEFTSHIFT, + uinput.ev.KEY_LEFTALT, + uinput.ev.KEY_LEFTMETA, + uinput.ev.KEY_RIGHTCTRL, + uinput.ev.KEY_RIGHTSHIFT, + uinput.ev.KEY_RIGHTALT, + uinput.ev.KEY_RIGHTMETA, + ] + map_modifiers = lambda x: [ mod for i, mod in enumerate(MODIFIERS) if x & (1<