summaryrefslogtreecommitdiff
path: root/joystick/test-joystick.py
diff options
context:
space:
mode:
authorRobert Scheibe <robert.scheibe@mailbox.org>2020-06-18 11:37:11 +0200
committerRobert Scheibe <robert.scheibe@mailbox.org>2020-06-18 11:37:11 +0200
commitd3a4e5b0e664aea57c4cce59631785ff5b61eabf (patch)
treeebfb8bddea356b72410ba9c2ead488deae2dfdf1 /joystick/test-joystick.py
initial commit
Diffstat (limited to 'joystick/test-joystick.py')
-rwxr-xr-xjoystick/test-joystick.py22
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 ()