Skip to content

Instantly share code, notes, and snippets.

@DiegoCarvalho75
Forked from Ademking/readme.md
Created December 15, 2021 13:13
Show Gist options
  • Save DiegoCarvalho75/fb3d02afa1ef0c3c7c18f01c34da9f26 to your computer and use it in GitHub Desktop.
Save DiegoCarvalho75/fb3d02afa1ef0c3c7c18f01c34da9f26 to your computer and use it in GitHub Desktop.
πŸ’š Android : How to record events and play them using ADB SHELL

1) Know the event name of touchpad :

Run :

adb shell getevent -pl

Search for : "ABS_MT_TRACKING_ID" - example :

add device 2: /dev/input/event5
  name:     "mtk-tpd"
  events:
    KEY (0001): KEY_W                 KEY_E                 KEY_U                 KEY_O
                KEY_S                 KEY_L                 KEY_Z                 KEY_V
                KEY_M                 KEY_UP                KEY_LEFT              KEY_RIGHT
                KEY_DOWN              KEY_MENU              KEY_BACK              KEY_HOMEPAGE
                KEY_SEARCH            BTN_TOUCH
    ABS (0003): ABS_X                 : value 0, min 0, max 720, fuzz 0, flat 0, resolution 720
                ABS_Y                 : value 0, min 0, max 1280, fuzz 0, flat 0, resolution 1280
                ABS_PRESSURE          : value 0, min 0, max 255, fuzz 0, flat 0, resolution 0
                ABS_MT_TOUCH_MAJOR    : value 0, min 0, max 100, fuzz 0, flat 0, resolution 0
                ABS_MT_TOUCH_MINOR    : value 0, min 0, max 100, fuzz 0, flat 0, resolution 0
                ABS_MT_POSITION_X     : value 0, min 0, max 720, fuzz 0, flat 0, resolution 0
                ABS_MT_POSITION_Y     : value 0, min 0, max 1280, fuzz 0, flat 0, resolution 0
                ABS_MT_TRACKING_ID    : value 0, min 0, max 10, fuzz 0, flat 0, resolution 0

As you see, event5 is responsible for Touchpad

2) Record events

2.1 run :

adb shell
$ su
$ cd /mnt/sdcard
$ cat /dev/input/event5 > events

2.2 Make your move! swipe or touch ... it's your game

you can stop recording by pressing Ctrl+C

2.3. Play your recording

to play your events, run

$ cat events > /dev/input/event5 

Tada.. That's it! this method is zeroing the timeval ! No delay



The other method is to use x and y coordinates

adb shell input swipe [X1] [Y1] [X2] [Y2] [duration(ms)]

Example :

adb shell input swipe 500 630 714 722 100

The Problem is adb shell input swipe is so slow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment