我正在使用一个pygame.joystick.Joystick
对象,并希望能够打印一条消息,要求用户重新连接USB手柄,一旦手柄被拔掉。
目前我的代码(大致如下):
js = pygame.joystick.Joystick(0)
#... some game code and stuff
pygame.joystick.quit()
pygame.joystick.init()
while pygame.joystick.get_count() == 0:
print 'please reconnect joystick'
pygame.joystick.quit()
pygame.joystick.init()
js = pygame.joystick.Joystick(0)
js.init()
但是它无法正确重新连接,我不知道它到底在做什么,但肯定是错的。对此有任何方向的帮助都将是有益的。