1

evdevを使用してコントローラーを入力デバイスとして実験しています。プログラムを終了すると、delete メソッド (super) には少なくとも 1 つの引数が必要であることを示すエラー メッセージが表示されます。私は見ましたが、これを適切に処理するための解決策を見つけることができませんでした。

プログラム:

# 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ます。出口を適切に処理する方法はありますか?

4

1 に答える 1