Feb-14-2022, 01:09 AM
Try initializing the joystick individually. Assuming that it's in the zero position, this should work.
joystick_0 = pg.joystick.Joystick (0) joystick_0 .init()This works on my system when only one joystick is plugged in.
import pygame as pg pg.init() joystick_0 = pg.joystick.Joystick (0) joystick_0 .init() screen = pg.display.set_mode((500,500)) running = True while running: for event in pg.event.get(): if event.type == pg.QUIT: running = False if event.type == pg.JOYBUTTONDOWN: print("button down") if event.type == pg.JOYBUTTONUP: print("button up") screen.fill((255,255,255)) pg.display.update() pg.quit()
Output:pygame 2.0.1 (SDL 2.0.14, Python 3.8.10)
Hello from the pygame community. https://www.pygame.org/contribute.html
button down
button up
button down
button up