SHOW:
|
|
- or go back to the newest paste.
| 1 | #!/usr/bin/python2 | |
| 2 | ||
| 3 | import pygame | |
| 4 | from subprocess import call | |
| 5 | ||
| 6 | pygame.init() | |
| 7 | pygame.joystick.init() | |
| 8 | ||
| 9 | while True: | |
| 10 | # EVENT PROCESSING STEP | |
| 11 | pygame.event.get() | |
| 12 | ||
| 13 | # Get count of joysticks | |
| 14 | joystick_count = pygame.joystick.get_count() | |
| 15 | ||
| 16 | # For each joystick: | |
| 17 | for i in range(joystick_count): | |
| 18 | joystick = pygame.joystick.Joystick(i) | |
| 19 | joystick.init() | |
| 20 | ||
| 21 | #textPrint.print(screen, "Joystick {}".format(i) )
| |
| 22 | #textPrint.indent() | |
| 23 | ||
| 24 | # Get the name from the OS for the controller/joystick | |
| 25 | name = joystick.get_name() | |
| 26 | ||
| 27 | buttons = joystick.get_numbuttons() | |
| 28 | ||
| 29 | for i in range( buttons ): | |
| 30 | button = joystick.get_button( i ) | |
| 31 | if button: | |
| 32 | if i == 8: #pressed X button | |
| 33 | call(["kodi", "&"]) |