Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python2
- import pygame
- from subprocess import call
- pygame.init()
- pygame.joystick.init()
- while True:
- # EVENT PROCESSING STEP
- pygame.event.get()
- # Get count of joysticks
- joystick_count = pygame.joystick.get_count()
- # For each joystick:
- for i in range(joystick_count):
- joystick = pygame.joystick.Joystick(i)
- joystick.init()
- #textPrint.print(screen, "Joystick {}".format(i) )
- #textPrint.indent()
- # Get the name from the OS for the controller/joystick
- name = joystick.get_name()
- buttons = joystick.get_numbuttons()
- for i in range( buttons ):
- button = joystick.get_button( i )
- if button:
- if i == 8: #pressed X button
- call(["kodi", "&"])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement