Closed moomiji closed 1 year ago
可以参考下之前有个同学《基于pytorch框架用resnet101加GPT搭建AI玩王者荣耀》的源码; 他的驱动就是pyminitouch,也是横屏,似乎没收到其他该类反馈;
了解了,传递给minitouch的是触摸坐标而不是屏幕坐标,需要坐标映射。 要不要考虑把坐标映射也封装进去,类似STFService.apk那样?
Use of screen coordinates requires coordinate mapping when device is rotated, like this case.
def coordinate_mapping(self, x: int, y: int) -> tuple:
"""
Mapping from screen coordinates to touch coordinates
x: x-coordinate of screen
y: y-coordinate of screen
return: touch coordinates for minitouch
"""
max_x = int(self.connection.max_x)
max_y = int(self.connection.max_y)
w = self.device.window_size().width
h = self.device.window_size().height
if self.need_coordinate_mapping:
r = self.device.rotation()
else:
return (x, y)
if 0 == r:
x = int(x/w*max_x)
y = int(y/h*max_y)
return (x, y)
elif 1 == r:
x = int(x/w*max_y)
y = int(y/h*max_x)
return (max_x - y, x)
elif 2 == r:
x = int(x/w*max_x)
y = int(y/h*max_y)
return (max_x - x, max_y - y)
elif 3 == r:
x = int(x/w*max_y)
y = int(y/h*max_x)
return (y, max_y - x)
了解了,传递给minitouch的是触摸坐标而不是屏幕坐标,需要坐标映射。 要不要考虑把坐标映射也封装进去,类似STFService.apk那样?
可以的,不过暂时我这边没什么这种场景,觉得有必要的话欢迎PR哈 :)
想试着给自己写的一个简单脚本从adb input换个模拟库,横屏下XY轴貌似有问题。 麻烦大佬看看是哪里出的问题?
其它信息
内核名及版本:x-base-v2-20221007-1a-test adb shell getprop: