How to use "adb shell input tap" command in a non-touch screen device

5.9k Views Asked by At

I use "adb shell input tap 'x' 'y'" command to tap on a specified location on a touch screen android device. But the device I am working on is a TV(based on android) which can only be used using remote. I am able to enable the pointer location using "adb shell settings put system pointer_location 1" and using bluetooth keyboard connected to the TV found the exact 'x' and 'y' location of the button where i want to tap. But "adb shell input tap" command didn't work as it worked in touch screen device, guess its due to a non-touch screen device. Is there any workaround to tap the intended button on a non-touch screen (TV) device?

1

There are 1 best solutions below

1
On

IIRC shell input tap x y should work even for the amazon firtev.

But in any case you can just emulate the DPAD actions of the firetv remote with

adb shell input keyevent <keyeventcode>

The keyevent codes for the DPAD are

19 -->  "KEYCODE_DPAD_UP" 
20 -->  "KEYCODE_DPAD_DOWN" 
21 -->  "KEYCODE_DPAD_LEFT" 
22 -->  "KEYCODE_DPAD_RIGHT" 
23 -->  "KEYCODE_DPAD_CENTER"

To emulate the Home and back buttons on the remote use

3 -->  "KEYCODE_HOME" 
4 -->  "KEYCODE_BACK"