I use sendevent to simulate complex gestures (clicks, swipes, long clicks with a swipe at the end). the problem is that sendevent is quite slow, 0.1 second per sendevent command in cmd, and click needs 7 sendevent commands. I so understood that sendevent opens the file, writes, closes and so 7 times. how to optimize it?
i know input tap, but input slower than sendevent
my code on python:
import time
from ppadb.client import Client
adb = Client(host='127.0.0.1', port=5037)
devices = adb.devices()
if len(devices) == 0:
print('Devices not found')
quit()
device = devices[0]
def sendevent(_type, _code, _value, _deviceName='/dev/input/event4'):
last_time = time.time()
device.shell(f"su -c 'sendevent {_deviceName} {_type} {_code} {_value}'")
print(time.time()-last_time)
def TapScreen(x, y):
sendevent(EV_ABS, ABS_MT_ID, 0)
sendevent(EV_ABS, ABS_MT_TRACKING_ID, 0)
sendevent(1, 330, 1)
sendevent(1, 325, 1)
sendevent(EV_ABS, ABS_MT_PRESSURE, 5)
sendevent(EV_ABS, ABS_MT_POSITION_X, x)
sendevent(EV_ABS, ABS_MT_POSITION_Y, y)
sendevent(EV_SYN, SYN_REPORT, 0)
sendevent(EV_ABS, ABS_MT_TRACKING_ID, -1)
sendevent(1, 330, 0)
sendevent(1, 325, 0)
sendevent(EV_SYN, SYN_REPORT, 0)
EV_ABS = 3
EV_SYN = 0
SYN_REPORT = 0
ABS_MT_ID = 47
ABS_MT_TOUCH_MAJOR = 48
ABS_MT_POSITION_X = 53
ABS_MT_POSITION_Y = 54
ABS_MT_TRACKING_ID = 57
ABS_MT_PRESSURE = 58
TapScreen(1000, 500)
Is it possible to write all actions into one file and then send them together as one sendevent?
pardon my english, i use google translate :)