Search code examples
androidshelleventsadbcoords

Cannot get mouse clicked coord on adb shell getevent


I have an Android TV box which I want to control it by ADB commands. Particularly, I want to send "tap" events on it. So far I've been doing it by "adb shell input tap x,y", which works fine but is sooo slow. So I'm trying to do it by "adb shell sendevent ..." which I think is faster.

I've followed several tutorials on how to do this, but I'm facing the problem that I'm not able to record which is the event sequence in order to send a simple and single tap to my device.

This is what I have done so far. In order to get the events sequence, I tried to get them with "getevent" command:

q201:/ # getevent -l
add device 1: /dev/input/event4
  name:     "HID 04b3:310b"
could not get driver version for /dev/input/mouse1, Not a typewriter
add device 2: /dev/input/event3
  name:     "cec_input"
could not get driver version for /dev/input/mice, Not a typewriter
add device 3: /dev/input/event2
  name:     "gpio_keypad"
add device 4: /dev/input/event1
  name:     "adc_keypad"
could not get driver version for /dev/input/mouse0, Not a typewriter
add device 5: /dev/input/event0
  name:     "aml_keypad"

When I click the mouse left button, then I see this event:

/dev/input/event4: EV_MSC       MSC_SCAN             00090001
/dev/input/event4: EV_KEY       BTN_MOUSE            DOWN
/dev/input/event4: EV_SYN       SYN_REPORT           00000000
/dev/input/event4: EV_MSC       MSC_SCAN             00090001
/dev/input/event4: EV_KEY       BTN_MOUSE            UP
/dev/input/event4: EV_SYN       SYN_REPORT           00000000

No more events are generated. Each time I click the mouse, the same event is generated. Same codes. Same values. Always the same !

So ... where are the coords where I clicked?? Why I'm not getting any event regarding the position I'm clicking on? Actually, the click works on device, so .. where is the event? Without the event I won't be able to reproduce the click with the sendevent command.

Thanks for your support! Gram


Solution

  • I finally used monkey (not monkeyrunner) to simulate taps. Much faster.