I'm trying to make a small Python script that executes another function (opens steam) when I press 2 buttons at the same time.
Here's the problem: the buttons 6 and 7 aren't working. When I print the values of them they return 0 even if I'm pressing the keys on my controller.
Does anyone know what's wrong here:
import os
import pygame
pygame.init()
#j = pygame.joystick.Joystick(0)
#j.init()
clock = pygame.time.Clock()
discon = False
def check_pad():
global discon
pygame.joystick.quit()
pygame.joystick.init()
joystick_count = pygame.joystick.get_count()
for i in range(joystick_count):
joystick = pygame.joystick.Joystick(i)
joystick.init()
istarted = pygame.joystick.get_init()
if not joystick_count:
if not discon:
print ("Controller Disconnected")
discon = True
clock.tick(20)
check_pad()
else:
print("Controller Connected")
print(joystick.get_button(6))
print(joystick.get_button(7))
print(istarted)
print(pygame.joystick.get_count())
discon = False
if(joystick.get_button(6) and joystick.get_button(7)):
initiate_steam()
while True:
check_pad()