Last active
January 17, 2018 16:20
-
-
Save t184256/3234302966f64a0c9095c663cdc616cb to your computer and use it in GitHub Desktop.
example of evdev/uinput based remapping, probably not the best one
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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