Skip to content

Instantly share code, notes, and snippets.

@asquelt
Created September 6, 2020 14:40
Show Gist options
  • Save asquelt/998da4fe15341296cea3428b81a9a11b to your computer and use it in GitHub Desktop.
Save asquelt/998da4fe15341296cea3428b81a9a11b to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import re
import evdev
from evdev import InputDevice,categorize,ecodes
from select import select
from pythonosc import udp_client
debug = 0
devices = [evdev.InputDevice(path) for path in evdev.list_devices()]
devices = map(InputDevice, devices)
devices = { dev.fd: dev for dev in devices }
client = udp_client.SimpleUDPClient('127.0.0.1',12321)
print('Main Loop Start')
while True:
r, w, x = select(devices, [], [])
for fd in r:
for event in devices[fd].read():
if event.type == ecodes.EV_KEY and event.value == 1:
print(categorize(event)) if debug else None
if event.code == 190:
print('F20') if debug else None
client.send_message('/press/bank/1/2',1)
if event.code == 191:
print('F21') if debug else None
client.send_message('/press/bank/1/3',1)
if event.code == 192:
print('F22') if debug else None
client.send_message('/press/bank/1/4',1)
if event.code == 193:
print('F23') if debug else None
client.send_message('/press/bank/1/5',1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment