Home > Blockchain >  I need to find the event ID of an android emulator
I need to find the event ID of an android emulator

Time:03-27

I'm working on an emulator and control it though the module ppadb. The swipes not being precise enough, i found a script to use sendevent but to do so i need the "event id".

self.device.shell(f'sendevent /dev/input/event{self.eventId} {event}')

There is a shell command named getevent to be able to view it but i have no clue on how to write that in python. I would like the getevent result to be printed in the pycharm console.

Would you please help me?

CodePudding user response:

You can run getevent in a shell once and find out the device name and use that in your Python script to do the sendevent commands. Or you can use the self.device.shell command in Python to do it as well. To find out the name of the device you can run this command in an adb shell session:

getevent -pl 2>&1 | sed -n '/^add/{h}/ABS_MT_TOUCH/{x;s/[^/]*//p}'

Now it will return something like /dev/input/event0 and you can use that with the command you already have to send events to that specific device.

If the adb command is not working in your terminal you can navigate to the platform-tools folder in your Android SDK folder and run it from there (in my case, my emulator was event1): enter image description here

  • Related