I'm experimenting with a controller as an input device using evdev. When I exit the program, I get an error message stating that the delete method (super) requires at least one argument. I have looked, but wer not able to find a solution to handle this properly.
The program:
# 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)
When I use a specific key I break out the loop, resulting in this error message:
Exception TypeError: TypeError('super() takes at least 1 argument (0 given)',) in <bound method InputDevice.__del__ of InputDevice('/dev/input/event5')> ignored
The same happens when I exit using ^C
.
Any ideas how to handle the exit properly?