From d3a4e5b0e664aea57c4cce59631785ff5b61eabf Mon Sep 17 00:00:00 2001 From: Robert Scheibe Date: Thu, 18 Jun 2020 11:37:11 +0200 Subject: initial commit --- joystick/test-joystick.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 joystick/test-joystick.py (limited to 'joystick/test-joystick.py') 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 () -- cgit v1.2.3