Last active
October 12, 2017 17:35
-
-
Save PierrePaul/6a295ed4553e27399462f047be8d499a to your computer and use it in GitHub Desktop.
pedals analog input to keystroke
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
#!/usr/bin/python3 | |
import evdev | |
from pykeyboard import PyKeyboard | |
device = evdev.InputDevice('/dev/input/event2') | |
k = PyKeyboard() | |
pressing_alt = False | |
pressing_ctrl = False | |
pressing_super = False | |
for event in device.read_loop(): | |
if event.code != 0 and event.value != 0: | |
pass | |
#print(event) | |
if event.code == 2 and event.value < 200 and pressing_alt is False: | |
k.press_key(k.alt_key) | |
pressing_alt = True | |
if event.code == 2 and event.value > 200 and pressing_alt is True: | |
k.release_key(k.alt_key) | |
pressing_alt = False | |
if event.code == 5 and event.value < 200 and pressing_super is False: | |
k.press_key(k.super_l_key) | |
pressing_super = True | |
if event.code == 5 and event.value > 200 and pressing_super is True: | |
k.release_key(k.super_l_key) | |
pressing_super = False | |
if event.code == 1 and event.value < 200 and pressing_ctrl is False: | |
k.press_key(k.control_key) | |
pressing_ctrl = True | |
if event.code == 1 and event.value > 200 and pressing_ctrl is True: | |
k.release_key(k.control_key) | |
pressing_ctrl = False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment