Hello I am trying to develop a Linux game in Panda3D which uses python for coding so anything in python would work. The game requires two mouse inputs (movement and mouse clicks). I want to get the info from the files in /dev/input but a more convenient way would help.
I've already got code to get the input file I want (/dev/input/event13 and /dev/input/event14) that works great. I've tried a lot of things but have only been able to get left click right click and a broken middle click which also triggers right click. Thanks!
The code for the thing that can get the input file is this:
import evdev
def dev1():
devices = [evdev.InputDevice(path) for path in evdev.list_devices()]
for device in devices:
print(device.path, device.name)
try:
device1 = float(input('Type number of Mouse1. Not a number to update. '))
except ValueError:
dev1()
def dev2():
devices = [evdev.InputDevice(path) for path in evdev.list_devices()]
for device in devices:
print(device.path, device.name)
try:
device2 = float(input('Type number of Mouse2. Not a number to update. '))
except ValueError:
dev2()
dev1()
dev2()
The pynput
module has a callback-based interface that let's you monitor mouse events such as movement and and clicks.
Check it out
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.