Skip to content

Instantly share code, notes, and snippets.

@Ademking
Last active November 5, 2023 15:48
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save Ademking/e9141c8336de77c3ea1c390dc666bfaa to your computer and use it in GitHub Desktop.
Save Ademking/e9141c8336de77c3ea1c390dc666bfaa 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

@DiegoCarvalho75
Copy link

Hi Adem, thanks for you tips on recording events in Android with Adb.
I can record events and play then, but only one at a time.
Is it possible to record and run a series of events?
Thanks

@Ademking
Copy link
Author

Ademking commented Nov 5, 2019

@Caballero75 Thank you β™₯
please take a look
https://github.com/tzutalin/adb-event-record

@gabriel7771
Copy link

gabriel7771 commented Oct 30, 2020

Hi Adem, your guide is working like a charm, thanks for the tips! The recorded event is executed very fast, do you know if there's a way of doing it a little bit slow?

@Ademking
Copy link
Author

@gabriel7771 Thank you so much ❀️
I don't know if there is a method how to make it slow

@stoefln
Copy link

stoefln commented Dec 15, 2021

Easier way to record and play back: https://www.repeato.app
There is a free version too.

@dicko3022
Copy link

Delicious for a 'doubleclick' event

Thanks a bunch

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