Pygame 错误地检测到不存在的操纵杆

Pygame wrongly detects joystick that isn't there

我有一个关于 pygame 的奇怪问题 我的笔记本电脑上没有连接操纵杆,但是 pygame.joystick.get_count() returns 1 它甚至可以检测轴输入。连接到我电脑的设备有:鼠标、键盘和wacom intuos。

没有连接其他USB设备。 编辑: 我制作了以下测试脚本

import pygame

pygame.init()
pygame.joystick.init()
print("joystick count:",pygame.joystick.get_count())
gJoystick = pygame.joystick.Joystick(0)
gJoystick.init()
print(gJoystick.get_init())
fGetEvent = True
while fGetEvent:
    for event in pygame.event.get():
        if event.type == pygame.JOYBUTTONDOWN:
            print("joystick button pressed")
            fGetEvent = False

gJoystick.init()
print(gJoystick.get_numaxes())

当我按下 intuos 数位板上的按钮时,它注册为按下操纵杆按钮。我是否必须断开我的平板电脑才能使其正常工作?

是的,包括 python 在内的大量程序将 wacom 数位板输入检测为操纵杆输入。你只需要拔掉它。