Question about simulating a MT device with evemu-event
Peter Hutterer
peter.hutterer at who-t.net
Mon Nov 30 00:25:53 UTC 2020
On Mon, Nov 30, 2020 at 12:13:55AM +0100, input-tools at storiepvtride.it wrote:
>
> Hello,
>
> I'm trying to programmatically simulate the input of Lenovo Thinkpad
> touchpad, identified as:
>
[...]
> function send_event() {
> type=$1; code=$2; value=$3
> evemu-event /dev/input/event6 --type ${type} --code ${code} --value ${value}
> }
>
> send_event EV_ABS ABS_MT_TRACKING_ID 6506
> send_event EV_ABS ABS_MT_POSITION_X 1434
> send_event EV_ABS ABS_MT_POSITION_Y 836
> send_event EV_ABS ABS_MT_ORIENTATION 1
> send_event EV_ABS ABS_MT_PRESSURE 37
> send_event EV_ABS ABS_MT_TOUCH_MINOR 0
> send_event EV_KEY BTN_TOUCH 1
> send_event EV_KEY BTN_TOOL_FINGER 1
> send_event EV_ABS ABS_X 1434
> send_event EV_ABS ABS_Y 836
> # the final event with a sync
> evemu-event /dev/input/event6 --sync --type EV_ABS --code ABS_MT_PRESSURE --value 37
>
> I observe the traffic, but I see nothing happening. The desired
> result would be something like when I actually using the touchpad:
>
> # libinput debug-events
> event5 POINTER_MOTION +4.08s -4.74/ 0.00 ( -9.00/ +0.00)
> event5 POINTER_MOTION +4.09s -4.74/ 0.00 ( -9.00/ +0.00)
> event5 POINTER_MOTION +4.09s -4.21/ 0.53 ( -8.00/ +1.00)
> event5 POINTER_MOTION +4.10s -3.68/ 1.05 ( -7.00/ +2.00)
> ...
>
> I can successfully simulate an external keyboard, for example with:
>
> evemu-event /dev/input/event16 --sync --type EV_KEY --code KEY_PAGEDOWN --value 1
> evemu-event /dev/input/event16 --sync --type EV_KEY --code KEY_PAGEDOWN --value 0
>
> Obviously I'm a newbie and a bit confused on how to make all this work,
> I'd appreciate a bit of light on the matter :-)
the basic problem here: the snippet above is the state of *one* hardware
event - on a touchpad it cannot possibly generate anything. Think of a
touchpad as a touchscreen that is converted to relative events in software.
That one event says: at timestamp T there is one finger down at 1434/836
with orientation 1 and pressure 37. The finger is new (wasn't detected in
the previous scanout).
This is all you're simulating - finger down at that location. To get pointer
events you need to start moving the touch point in consecutive events, and
eventually release it.
Have a read of this post to get a better understanding of how evdev works:
https://who-t.blogspot.com/2016/09/understanding-evdev.html
fwiw, I strongly recommend using python-libevdev over evemu-event. murch
more flexible.
Cheers,
Peter
More information about the Input-tools
mailing list