From e701091d8c4a9f73b36021b1ac02dcb7a77490a7 Mon Sep 17 00:00:00 2001 From: ERR0RPR0MPT Date: Sun, 14 Apr 2024 01:05:07 +0800 Subject: [PATCH] =?UTF-8?q?update=20v0.0.7=20-=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E9=83=A8=E5=88=86=E5=AE=89=E5=8D=93=E8=AE=BE=E5=A4=87=E8=A7=A6?= =?UTF-8?q?=E6=91=B8=E5=8F=AA=E5=9C=A8=E5=B1=8F=E5=B9=95=E5=B7=A6=E4=B8=8A?= =?UTF-8?q?=E8=A7=92=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 ++-- main.py | 12 ++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index edf1517..f8d64df 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ 放置到该图片圆形触摸区域的位置(或者可以参考`./image/image_monitor_edit3.png`的做法), 编辑好的图片放到脚本 `image` 目录下取名 `image_monitor.png`. 2. 编辑 `main.py` 脚本文件, 修改脚本内 `exp_image_dict` 变量, 将各区块对应的 R 通道颜色值改为刚P的图的对应区块颜色值(一般不用改默认就行) 3. 编辑 `main.py` 脚本文件, 修改脚本内 `IMAGE_PATH` `COM_PORT`, `COM_BAUDRATE`, `MAX_SLOT` 四个配置 -4. 下一个 `VSPD` 虚拟串口工具, 将 `COM3` 和 `COM33` 建立转发 +4. 下一个 `VSPD` 或 `com0com` 虚拟串口工具, 将 `COM3` 和 `COM33` 建立转发 5. 电脑安装 ADB 调试工具, 安装路径添加到系统环境变量里面 6. 手机打开 USB 调试, 强烈建议同时使用 USB 网络共享连接电脑, 串流走 WLAN 可能不是很稳定 7. 电脑画面可使用 `IddSampleDriver`, `Sunshine` 和 `Moonlight` 等串流到 Android 设备, 这里不再赘述 @@ -24,7 +24,7 @@ Q: 在安卓高版本(13,14)上测试触摸区域完全对不上,只有点屏幕左上角有用,图片用的是平板实际分辨率,在一台安卓10设备测试是正常的 -A: 在控制台输入 `adb shell getevent -l` 然后在点一下触摸屏幕的左上角和右下角,找到 `ABS_MT_POSITION_X` 和 `ABS_MT_POSITION_Y` 对应的十六进制数值,转换为十进制后计算一下长宽的数值,重新生成一个对应长宽的图片就可以了 +A: 在脚本设置中修改 `USE_ANDROID_NEW_POSITION` 配置为 True ## 注意 diff --git a/main.py b/main.py index 4ee4d15..676ece2 100644 --- a/main.py +++ b/main.py @@ -16,6 +16,8 @@ COM_BAUDRATE = 9600 MAX_SLOT = 12 # 检测区域的像素值范围 AREA_SCOPE = 65 +# 在部分 Android 设备上位置数据会精准到小数点后一位, 是否适配新版本位置数据, 默认不开启 +USE_ANDROID_NEW_POSITION = False # touch_thread 是否启用sleep, 默认开启, 如果程序 CPU 占用较高则开启, 如果滑动时延迟极大请关闭 TOUCH_THREAD_SLEEP_MODE = True # 每次 sleep 的延迟, 单位: 微秒, 默认 100 微秒 @@ -229,10 +231,16 @@ def getevent(): _, _, event_type, event_value = event.split() if event_type == 'ABS_MT_POSITION_X': key_is_changed = True - touch_data[touch_index]["x"] = int(event_value, 16) + if USE_ANDROID_NEW_POSITION: + touch_data[touch_index]["x"] = int(int(event_value, 16) / 10) + else: + touch_data[touch_index]["x"] = int(event_value, 16) elif event_type == 'ABS_MT_POSITION_Y': key_is_changed = True - touch_data[touch_index]["y"] = int(event_value, 16) + if USE_ANDROID_NEW_POSITION: + touch_data[touch_index]["y"] = int(int(event_value, 16) / 10) + else: + touch_data[touch_index]["y"] = int(event_value, 16) elif event_type == 'SYN_REPORT': if not key_is_changed: continue