GautierD
GautierD

Reputation: 83

Simulate multitouch events with uinput

Hi everyone and thanks for reading.

I am trying to use uinput interface to perform some touches. Eventually, these data will be interpreted from a serial connection through UART.

I can open, close, etc. uinput and it works fine for mono-touch.

EV_KEY BTN_TOUCH 1
EV_ABS ABS_X 400
EV_ABS ABS_Y 400
EV_SYN SYN_REPORT 0

performs a touch. Swipe, double tap, works fine with ABS_X and ABS_Y.

Then, I wanted to implement multitouch support, so I implemented ABS_MT_POSITION_X, ABS_MT_POSITION_Y, ABS_MT_TRACKING_ID, ABS_MT_SLOT.

I managed to perform a touch and a swipe :

EV_ABS ABS_MT_TRACKING_ID 20
EV_KEY BTN_TOUCH 1
EV_ABS ABS_MT_POSITION_X 425
EV_ABS ABS_MT_POSITION_Y 400
EV_SYN SYN_REPORT 0

But... I can't use the slots. I'm trying to perform a pinch (dezoomer).

EV_ABS ABS_MT_SLOT 0
EV_ABS ABS_MT_TRACKING_ID 20
EV_KEY BTN_TOUCH 1
EV_ABS ABS_MT_POSITION_X 425
EV_ABS ABS_MT_POSITION_Y 400
EV_ABS ABS_MT_SLOT 1
EV_ABS ABS_MT_TRACKING_ID 21
EV_ABS ABS_MT_POSITION_X 650
EV_ABS ABS_MT_POSITION_Y 400
EV_SYN SYN_REPORT 0
EV_ABS ABS_MT_SLOT 0
EV_ABS ABS_MT_POSITION_X 450
EV_ABS ABS_MT_POSITION_Y 400
EV_ABS ABS_MT_SLOT 1
EV_ABS ABS_MT_POSITION_X 550
EV_ABS ABS_MT_POSITION_Y 400
EV_ABS ABS_MT_SLOT 0
EV_ABS ABS_MT_TRACKING_ID -1
EV_ABS ABS_MT_SLOT 1
EV_ABS ABS_MT_TRACKING_ID -1
EV_KEY BTN_TOUCH 0
EV_SYN SYN_REPORT 0

This sequence does not work, but according to Linux Multi Touch Protocol, it should be. I can't see where that problem comes from. Is it time-dependent ? As I send these instructions with no delay between them, it might need some time between.

Does anyone know how to simulate a multitouch event following protocol B ? What sequence should work ?

NB: These touches are performed on an Android device, in a C executable made with the Android NDK.

Upvotes: 2

Views: 2110

Answers (1)

GautierD
GautierD

Reputation: 83

So I finally found the answer. The sequence above is correct, but :

  1. You need to add a delay. From the sequence I can gather from an old Samsung Edge on Android, 8000 microseconds between each refresh of ABS_MT_POSITION_X/Y.
  2. You need to send more events. So I basically implemented a for loop.

Gautier

Upvotes: 3

Related Questions