Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pyglet
- from pyglet.gl import *
- #from pyglet.input.darwin_hid import PygletDevice
- window = pyglet.window.Window()
- def on_joybutton_press(joystick, button):
- print(joystick.device.name + " " + str(hash(joystick)))
- print("button %s pressed" % button)
- def on_joybutton_release(joystick, button):
- print(joystick.device.name + " " + str(hash(joystick)))
- print("button %s released" % button)
- def on_joyaxis_motion(joystick, axis, value):
- print(joystick.device.name + " " + str(hash(joystick)))
- print("axis %s @ val %s" % (axis, format(value, '.3f')))
- joysticks = pyglet.input.get_joysticks()
- if joysticks:
- for j in joysticks:
- print(hash(j))
- j.open()
- j.on_joybutton_press = on_joybutton_press
- j.on_joybutton_release = on_joybutton_release
- j.on_joyaxis_motion = on_joyaxis_motion
- pyglet.clock.schedule(lambda dt: None)
- pyglet.app.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement