Hello everyone π I'm just starting to learn python and I'd like to ask is there any method to receiving input from touchpad? I've seen an Asus laptop with their touchpad become numberpad (Like the photo below) and I'm interested to know if I can do it too but for different purposes. Because I think like this. If I could access certain parts of the touchpad wouldn't it be like I can expand my keyboard to the touchpad that I rarely used ? Thank you for your attention Attachment
I have tried to look for some tutorial, video, Library, or even AI assistant like chatgpt or google bard but I can't find any solution to my problem wish anyone can help me to start appreciate your help π
-
I am also looking for this solution, but I found that similar functions are written in C#, and it seems that C# provides relevant API information. Python should also be able to call it, but maybe it will do more things, and the encapsulation related to Windows should be in the dynamic link library hid.dll.Autumn– Autumn2024εΉ΄08ζ13ζ₯ 06:46:46 +00:00Commented Aug 13, 2024 at 6:46
1 Answer 1
I've done this on Linux, I don't know about Microsoft, Mac etc.
You can use evdev:
pip install evdev
Example of using it:
import evdev
from evdev import InputDevice, categorize, ecodes
# Replace this path with the path to your touchpad device
device_path = '/dev/input/eventX'
# Open the device
device = InputDevice(device_path)
# Loop to continuously read touchpad events
for event in device.read_loop():
if event.type == ecodes.EV_ABS:
# Handle absolute axis events
abs_event = categorize(event)
if abs_event.event.code == ecodes.ABS_X:
print(f"X Axis: {abs_event.event.value}")
elif abs_event.event.code == ecodes.ABS_Y:
print(f"Y Axis: {abs_event.event.value}")
elif abs_event.event.code == ecodes.ABS_PRESSURE:
print(f"Pressure: {abs_event.event.value}")
elif event.type == ecodes.EV_KEY:
# Handle key events (like tapping)
key_event = categorize(event)
if key_event.keystate == 1: # Key press
print(f"Key {key_event.keycode} pressed")