Created
April 7, 2015 10:59
-
-
Save sunnyone/c669539aa2f903f5b6de to your computer and use it in GitHub Desktop.
jaraco.input sample
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
#!~/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