Skip to content

Instantly share code, notes, and snippets.

@t184256
Last active Jan 17, 2018
Embed
What would you like to do?
example of evdev/uinput based remapping, probably not the best one
import os
import atexit
import uinput
import evdev
#os.system('sudo modprobe uinput')
MAPPING = {
evdev.ecodes.KEY_A: uinput.KEY_ESC,
evdev.ecodes.KEY_B: uinput.KEY_END,
evdev.ecodes.KEY_C: uinput.KEY_ENTER,
}
device = uinput.Device(MAPPING.values(), name='Pedal keys')
PATH = '/dev/input/by-id/usb-PCsensor_FootSwitch3-F1.8-event-mouse'
in_dev = evdev.InputDevice(PATH)
atexit.register(in_dev.ungrab)
in_dev.grab()
for event in in_dev.read_loop():
if event.type == evdev.ecodes.EV_KEY:
device.emit(MAPPING[event.code], event.value)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment