I have just tried this tutorial on a raspberry PI running Buster, python 3.5.3 and it does not work.
import evdev
devices = [evdev.InputDevice(path) for path in evdev.list_devices()]
for device in devices:
print(device.path, device.name, device.phys)
Idle gives the following error:
Traceback (most recent call last):
File "<pyshell#4>", line 2, in
print(device.path, device.name, device.phys)
AttributeError: "InputDevice" object has no attribute "path"
I have looked at help(evdev.device.InputDevice) and found an attribute fspath
If I now run
for device in devices:
print(device.__fspath__, device.name, device.phys)
<bound method InputDevice.fspath of InputDevice('/dev/input/event1')> Logitech USB Optical Mouse usb-3f980000.usb-1.5/input0
<bound method InputDevice.fspath of InputDevice('/dev/input/event0')> DELL DELL USB Keyboard usb-3f980000.usb-1.4/input0
There are no errors and it outputs the path along with other information.
I am not sure if this is the "best" fix for the example, assuming there is an error.
As a newcomer to evdev and relatively new to python I am quite pleased I managed to find a fix.
I have just tried this tutorial on a raspberry PI running Buster, python 3.5.3 and it does not work.
Idle gives the following error:
Traceback (most recent call last):
File "<pyshell#4>", line 2, in
print(device.path, device.name, device.phys)
AttributeError: "InputDevice" object has no attribute "path"
I have looked at help(evdev.device.InputDevice) and found an attribute fspath
If I now run
<bound method InputDevice.fspath of InputDevice('/dev/input/event1')> Logitech USB Optical Mouse usb-3f980000.usb-1.5/input0
<bound method InputDevice.fspath of InputDevice('/dev/input/event0')> DELL DELL USB Keyboard usb-3f980000.usb-1.4/input0
There are no errors and it outputs the path along with other information.
I am not sure if this is the "best" fix for the example, assuming there is an error.
As a newcomer to evdev and relatively new to python I am quite pleased I managed to find a fix.