我正在尝试使用 evdev 将控制器作为输入设备。当我退出程序时,我收到一条错误消息,指出删除方法(超级)至少需要一个参数。我看过,但无法找到正确处理此问题的解决方案。
该程序:
# import evdev
from evdev import InputDevice, categorize, ecodes
# creates object 'gamepad' to store the data
# you can call it whatever you like
gamepad = InputDevice('/dev/input/event5')
# prints out device info at start
print(gamepad)
# evdev takes care of polling the controller in a loop
for event in gamepad.read_loop():
# filters by event type
if event.type == ecodes.EV_KEY and event.code == 308:
break
if event.type == ecodes.EV_ABS and event.code == 1:
print(event.code, event.value)
if event.type == ecodes.EV_ABS and event.code == 0:
print(event.code, event.value)
# print(categorize(event))
if event.type == ecodes.EV_KEY:
print(event.code, event.value)
当我使用特定键时,我会中断循环,从而导致以下错误消息:
Exception TypeError: TypeError('super() takes at least 1 argument (0 given)',) in <bound method InputDevice.__del__ of InputDevice('/dev/input/event5')> ignored
当我退出使用时也会发生同样的情况^C
。任何想法如何正确处理出口?