diff options
Diffstat (limited to 'joystick/test-joystick.py')
-rwxr-xr-x | joystick/test-joystick.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/joystick/test-joystick.py b/joystick/test-joystick.py new file mode 100755 index 0000000..a8ed6f1 --- /dev/null +++ b/joystick/test-joystick.py @@ -0,0 +1,22 @@ +#!/usr/bin/python3 + +import pygame + +pygame.display.init() +pygame.joystick.init() + +print ("Joystics: ", pygame.joystick.get_count()) +my_joystick = pygame.joystick.Joystick(0) +my_joystick.init() +clock = pygame.time.Clock() + +print (my_joystick.get_numbuttons()) +print (my_joystick.get_numhats()) +while 1: + for event in pygame.event.get(): + print (my_joystick.get_axis(0), my_joystick.get_axis(1)) + for i in range(my_joystick.get_numbuttons()): + print(i, my_joystick.get_button(i)) + clock.tick(40) + +pygame.quit () |