Instantly share code, notes, and snippets.

Embed
What would you like to do?
jaraco.input sample
#!~/opt/venvpy2/bin/python
# after ~/opt/venvpy2/bin/pip install jaraco.input
import jaraco.input
import sys
import os
from pyglet import event
class MyJoy(jaraco.input.Joystick):
def __init__(self, device):
event.EventDispatcher.__init__(self)
self.dev = open(device)
self.ignoreFirst = True
def on_axis(self, axis, value):
#print("axis: %d" % axis)
pass
def on_button(self, button, pressed):
if pressed:
return
if self.ignoreFirst:
self.ignoreFirst = False
return
print(button)
if button == 2:
os.system("xdotool key F8")
elif button == 3:
os.system("xdotool key F7")
joy = MyJoy("/dev/input/js0")
while True:
joy.dispatch_events()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment