Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.91 KB | None | 0 0
  1. import pyglet
  2. from pyglet.gl import *
  3. #from pyglet.input.darwin_hid import PygletDevice
  4.  
  5. window = pyglet.window.Window()
  6.  
  7. def on_joybutton_press(joystick, button):
  8.     print(joystick.device.name + " " + str(hash(joystick)))
  9.     print("button %s pressed" % button)
  10.  
  11. def on_joybutton_release(joystick, button):
  12.     print(joystick.device.name + " " + str(hash(joystick)))
  13.     print("button %s released" % button)
  14.  
  15. def on_joyaxis_motion(joystick, axis, value):
  16.     print(joystick.device.name + " " + str(hash(joystick)))
  17.     print("axis %s @ val %s" % (axis, format(value, '.3f')))
  18.  
  19. joysticks = pyglet.input.get_joysticks()
  20. if joysticks:
  21.     for j in joysticks:
  22.         print(hash(j))
  23.         j.open()
  24.         j.on_joybutton_press = on_joybutton_press
  25.         j.on_joybutton_release = on_joybutton_release
  26.         j.on_joyaxis_motion = on_joyaxis_motion
  27.  
  28. pyglet.clock.schedule(lambda dt: None)
  29. pyglet.app.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement