Skip to content

Instantly share code, notes, and snippets.

@sunnyone
Created April 7, 2015 10:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sunnyone/c669539aa2f903f5b6de to your computer and use it in GitHub Desktop.
Save sunnyone/c669539aa2f903f5b6de to your computer and use it in GitHub Desktop.
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