diff --git a/3rdparty/resource/minitouch/maatouch/minitouch b/3rdparty/resource/minitouch/maatouch/minitouch new file mode 100644 index 0000000000..02db3af473 Binary files /dev/null and b/3rdparty/resource/minitouch/maatouch/minitouch differ diff --git a/CHANGELOG.md b/CHANGELOG.md index 1daafdcf9b..d180f26d34 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## v4.7.3 + +- 新增 `MaaTouch` 连接配置 项,推荐在 minitouch 无法使用,但又不想用 `兼容触控模式` 时开启 @aa889788 @MistEO +- 修复 minitouch 路径错误无法使用的问题 @MistEO + ## v4.7.2 - 修复 刷理智 掉落识别 在极端情况下疯狂上传的问题 @MistEO diff --git a/resource/config.json b/resource/config.json index 495ad341d0..ec88e08523 100644 --- a/resource/config.json +++ b/resource/config.json @@ -16,6 +16,14 @@ "adbSwipeDurationMultiplier_Doc": "adb 滑动延迟倍数", "minitouchExtraSwipeDist": 100, "minitouchExtraSwipeDuration": 200, + "minitouchProgramsOrder": [ + "x86_64", + "x86", + "arm64-v8a", + "armeabi-v7a", + "armeabi", + "maatouch" + ], "penguinReport": { "Doc": "企鹅物流汇报: https://penguin-stats.cn/", "cmdFormat": "curl -H \"Content-Type: application/json\" -s -S -m 10 -i -d \"[body]\" \"https://penguin-stats.io/PenguinStats/api/v2/report\" --ssl-no-revoke [extra]", @@ -60,7 +68,7 @@ "release": "[Adb] kill-server", "start": "[Adb] -s [AdbSerial] shell am start -n [Intent]", "stop": "[Adb] -s [AdbSerial] shell \"am force-stop `dumpsys activity activities 2>/dev/null | grep Activities= 2>/dev/null | grep -m 1 -i -o -E [^\\ ]*arknights[^/]*`\"", - "abilist": "[Adb] -s [AdbSerial] shell getprop ro.product.cpu.abilist", + "abilist": "[Adb] -s [AdbSerial] shell getprop ro.product.cpu.abilist", "orientation": "[Adb] -s [AdbSerial] shell dumpsys input | grep SurfaceOrientation | grep -m 1 -o -E [0-9]", "pushMinitouch": "[Adb] -s [AdbSerial] push \"[minitouchLocalPath]\" \"/data/local/tmp/[minitouchWorkingFile]\"", "chmodMinitouch": "[Adb] -s [AdbSerial] shell chmod 700 \"/data/local/tmp/[minitouchWorkingFile]\"", @@ -83,7 +91,7 @@ "release": "[Adb] kill-server", "start": "[Adb] -s [AdbSerial] shell am start -n [Intent]", "stop": "[Adb] -s [AdbSerial] shell \"am force-stop `dumpsys activity activities 2>/dev/null | grep Activities= 2>/dev/null | grep -m 1 -i -o -E [^\\ ]*arknights[^/]*`\"", - "abilist": "[Adb] -s [AdbSerial] shell getprop ro.product.cpu.abilist", + "abilist": "[Adb] -s [AdbSerial] shell getprop ro.product.cpu.abilist", "orientation": "[Adb] -s [AdbSerial] shell dumpsys input | grep SurfaceOrientation | grep -m 1 -o -E [0-9]", "pushMinitouch": "[Adb] -s [AdbSerial] push \"[minitouchLocalPath]\" \"/data/local/tmp/[minitouchWorkingFile]\"", "chmodMinitouch": "[Adb] -s [AdbSerial] shell chmod 700 \"/data/local/tmp/[minitouchWorkingFile]\"", @@ -106,7 +114,7 @@ "release": "[Adb] kill-server", "start": "[Adb] -s [AdbSerial] shell am start -n [Intent]", "stop": "[Adb] -s [AdbSerial] shell \"am force-stop `dumpsys activity activities 2>/dev/null | grep Activities= 2>/dev/null | grep -m 1 -i -o -E [^\\ ]*arknights[^/]*`\"", - "abilist": "[Adb] -s [AdbSerial] shell getprop ro.product.cpu.abilist", + "abilist": "[Adb] -s [AdbSerial] shell getprop ro.product.cpu.abilist", "orientation": "[Adb] -s [AdbSerial] shell dumpsys input | grep SurfaceOrientation | grep -m 1 -o -E [0-9]", "pushMinitouch": "[Adb] -s [AdbSerial] push \"[minitouchLocalPath]\" \"/data/local/tmp/[minitouchWorkingFile]\"", "chmodMinitouch": "[Adb] -s [AdbSerial] shell chmod 700 \"/data/local/tmp/[minitouchWorkingFile]\"", @@ -129,7 +137,7 @@ "release": "[Adb] kill-server", "start": "[Adb] -s [AdbSerial] shell am start -n [Intent]", "stop": "[Adb] -s [AdbSerial] shell \"am force-stop `dumpsys activity activities 2>/dev/null | grep Activities= 2>/dev/null | grep -m 1 -i -o -E [^\\ ]*arknights[^/]*`\"", - "abilist": "[Adb] -s [AdbSerial] shell getprop ro.product.cpu.abilist", + "abilist": "[Adb] -s [AdbSerial] shell getprop ro.product.cpu.abilist", "orientation": "[Adb] -s [AdbSerial] shell dumpsys input | grep SurfaceOrientation | grep -m 1 -o -E [0-9]", "pushMinitouch": "[Adb] -s [AdbSerial] push \"[minitouchLocalPath]\" \"/data/local/tmp/[minitouchWorkingFile]\"", "chmodMinitouch": "[Adb] -s [AdbSerial] shell chmod 700 \"/data/local/tmp/[minitouchWorkingFile]\"", @@ -152,7 +160,7 @@ "release": "[Adb] kill-server", "start": "[Adb] -s [AdbSerial] shell am start -n [Intent]", "stop": "[Adb] -s [AdbSerial] shell \"am force-stop `dumpsys activity activities 2>/dev/null | grep Activities= 2>/dev/null | grep -m 1 -i -o -E [^\\ ]*arknights[^/]*`\"", - "abilist": "[Adb] -s [AdbSerial] shell getprop ro.product.cpu.abilist", + "abilist": "[Adb] -s [AdbSerial] shell getprop ro.product.cpu.abilist", "orientation": "[Adb] -s [AdbSerial] shell dumpsys input | grep SurfaceOrientation | grep -m 1 -o -E [0-9]", "pushMinitouch": "[Adb] -s [AdbSerial] push \"[minitouchLocalPath]\" \"/data/local/tmp/[minitouchWorkingFile]\"", "chmodMinitouch": "[Adb] -s [AdbSerial] shell chmod 700 \"/data/local/tmp/[minitouchWorkingFile]\"", @@ -175,7 +183,7 @@ "release": "[Adb] kill-server", "start": "[Adb] -s [AdbSerial] shell am start -n [Intent]", "stop": "[Adb] -s [AdbSerial] shell \"am force-stop `dumpsys activity activities 2>/dev/null | grep Activities= 2>/dev/null | grep -m 1 -i -o -E [^\\ ]*arknights[^/]*`\"", - "abilist": "[Adb] -s [AdbSerial] shell getprop ro.product.cpu.abilist", + "abilist": "[Adb] -s [AdbSerial] shell getprop ro.product.cpu.abilist", "orientation": "[Adb] -s [AdbSerial] shell dumpsys input | grep SurfaceOrientation | grep -m 1 -o -E [0-9]", "pushMinitouch": "[Adb] -s [AdbSerial] push \"[minitouchLocalPath]\" \"/data/local/tmp/[minitouchWorkingFile]\"", "chmodMinitouch": "[Adb] -s [AdbSerial] shell chmod 700 \"/data/local/tmp/[minitouchWorkingFile]\"", @@ -199,7 +207,7 @@ "release": "[Adb] kill-server", "start": "[Adb] -s [AdbSerial] shell am start -n [Intent]", "stop": "[Adb] -s [AdbSerial] shell \"am force-stop `dumpsys activity activities 2>/dev/null | grep Activities= 2>/dev/null | grep -m 1 -i -o -E [^\\ ]*arknights[^/]*`\"", - "abilist": "[Adb] -s [AdbSerial] shell getprop ro.product.cpu.abilist", + "abilist": "[Adb] -s [AdbSerial] shell getprop ro.product.cpu.abilist", "orientation": "[Adb] -s [AdbSerial] shell dumpsys input | grep SurfaceOrientation | grep -m 1 -o -E [0-9]", "pushMinitouch": "[Adb] -s [AdbSerial] push \"[minitouchLocalPath]\" \"/data/local/tmp/[minitouchWorkingFile]\"", "chmodMinitouch": "[Adb] -s [AdbSerial] shell chmod 700 \"/data/local/tmp/[minitouchWorkingFile]\"", @@ -222,7 +230,7 @@ "release": "[Adb] kill-server", "start": "[Adb] -s [AdbSerial] shell am start -n [Intent]", "stop": "[Adb] -s [AdbSerial] shell \"am force-stop `dumpsys activity activities 2>/dev/null | grep Activities= 2>/dev/null | grep -m 1 -i -o -E [^\\ ]*arknights[^/]*`\"", - "abilist": "[Adb] -s [AdbSerial] shell getprop ro.product.cpu.abilist", + "abilist": "[Adb] -s [AdbSerial] shell getprop ro.product.cpu.abilist", "orientation": "[Adb] -s [AdbSerial] shell dumpsys input | grep SurfaceOrientation | grep -m 1 -o -E [0-9]", "pushMinitouch": "[Adb] -s [AdbSerial] push \"[minitouchLocalPath]\" \"/data/local/tmp/[minitouchWorkingFile]\"", "chmodMinitouch": "[Adb] -s [AdbSerial] shell chmod 700 \"/data/local/tmp/[minitouchWorkingFile]\"", @@ -245,11 +253,34 @@ "release": "[Adb] kill-server", "start": "[Adb] -s [AdbSerial] shell am start -n [Intent]", "stop": "[Adb] -s [AdbSerial] shell \"am force-stop `dumpsys activity activities 2>/dev/null | grep Activities= 2>/dev/null | grep -m 1 -i -o -E [^\\ ]*arknights[^/]*`\"", - "abilist": "[Adb] -s [AdbSerial] shell getprop ro.product.cpu.abilist", + "abilist": "[Adb] -s [AdbSerial] shell getprop ro.product.cpu.abilist", "orientation": "[Adb] -s [AdbSerial] shell dumpsys input | grep SurfaceOrientation | grep -m 1 -o -E [0-9]", "pushMinitouch": "[Adb] -s [AdbSerial] push \"[minitouchLocalPath]\" \"/data/local/tmp/[minitouchWorkingFile]\"", "chmodMinitouch": "[Adb] -s [AdbSerial] shell chmod 700 \"/data/local/tmp/[minitouchWorkingFile]\"", "callMinitouch": "[Adb] -s [AdbSerial] shell \"/data/local/tmp/[minitouchWorkingFile]\" -i" + }, + "MaaTouch": { + "devices": "[Adb] devices", + "addressRegex": "(.+)\tdevice", + "connect": "[Adb] connect [AdbSerial]", + "uuid": "[Adb] -s [AdbSerial] shell settings get secure android_id", + "click": "[Adb] -s [AdbSerial] shell input tap [x] [y]", + "swipe": "[Adb] -s [AdbSerial] shell input swipe [x1] [y1] [x2] [y2] [duration]", + "display": "[Adb] -s [AdbSerial] shell dumpsys window displays | grep -o -E cur=+[^\\ ]+ | grep -o -E [0-9]+", + "displayFormat": "%d%d", + "screencapRawByNC": "[Adb] -s [AdbSerial] exec-out \"screencap | nc -w 3 [NcAddress] [NcPort]\"", + "ncAddress": "[Adb] -s [AdbSerial] shell \" cat /proc/net/arp | grep : \"", + "ncPort": 6723, + "screencapRawWithGzip": "[Adb] -s [AdbSerial] exec-out \"screencap | gzip -1\"", + "screencapEncode": "[Adb] -s [AdbSerial] exec-out screencap -p", + "release": "[Adb] kill-server", + "start": "[Adb] -s [AdbSerial] shell am start -n [Intent]", + "stop": "[Adb] -s [AdbSerial] shell \"am force-stop `dumpsys activity activities 2>/dev/null | grep Activities= 2>/dev/null | grep -m 1 -i -o -E [^\\ ]*arknights[^/]*`\"", + "abilist": "[Adb] -s [AdbSerial] shell echo maatouch", + "orientation": "[Adb] -s [AdbSerial] shell echo 0", + "pushMinitouch": "[Adb] -s [AdbSerial] push \"[minitouchLocalPath]\" \"/data/local/tmp/[minitouchWorkingFile]\"", + "chmodMinitouch": "[Adb] -s [AdbSerial] shell chmod 700 \"/data/local/tmp/[minitouchWorkingFile]\"", + "callMinitouch": "[Adb] -s [AdbSerial] shell \"export CLASSPATH=/data/local/tmp/[minitouchWorkingFile]; app_process /data/local/tmp com.shxyke.MaaTouch.App\"" } } } diff --git a/src/MeoAssistant/AsstCaller.cpp b/src/MeoAssistant/AsstCaller.cpp index f55ad3c724..9ecf58ad65 100644 --- a/src/MeoAssistant/AsstCaller.cpp +++ b/src/MeoAssistant/AsstCaller.cpp @@ -48,15 +48,17 @@ bool AsstSetUserDir(const char* path) bool AsstLoadResource(const char* path) { + using namespace asst::utils::path_literals; + auto os_path = asst::utils::path(path); + auto res_path = os_path / "resource"_p; if (asst::ResDir.empty()) { - asst::ResDir.set(os_path); + asst::ResDir.set(res_path); } if (asst::UserDir.empty()) { asst::UserDir.set(os_path); } - using namespace asst::utils::path_literals; - inited = asst::ResourceLoader::get_instance().load(os_path / "resource"_p); + inited = asst::ResourceLoader::get_instance().load(res_path); return inited; } diff --git a/src/MeoAssistant/Controller.cpp b/src/MeoAssistant/Controller.cpp index e2c2bd1cef..052304130b 100644 --- a/src/MeoAssistant/Controller.cpp +++ b/src/MeoAssistant/Controller.cpp @@ -456,7 +456,6 @@ bool asst::Controller::call_and_hup_minitouch(const std::string& cmd) release_minitouch(true); Log.info(cmd); - m_minitouch_avaiable = false; constexpr int PipeReadBuffSize = 4096ULL; constexpr int PipeWriteBuffSize = 64 * 1024ULL; @@ -639,7 +638,6 @@ bool asst::Controller::call_and_hup_minitouch(const std::string& cmd) m_minitouch_props.x_scaling = static_cast(m_minitouch_props.max_x) / m_width; m_minitouch_props.y_scaling = static_cast(m_minitouch_props.max_y) / m_height; - m_minitouch_avaiable = true; return true; } @@ -1506,43 +1504,46 @@ bool asst::Controller::connect(const std::string& adb_path, const std::string& a return false; } - std::string abilist = call_command(cmd_replace(adb_cfg.abilist)).value_or(""); - constexpr std::array OrderedABI = { - "x86_64", "x86", "arm64-v8a", "armeabi-v7a", "armeabi", - }; - std::string_view optimal_abi = "armeabi-v7a"; - for (const auto& abi : OrderedABI) { - if (abilist.find(abi) != std::string::npos) { - optimal_abi = abi; - break; + do { + m_minitouch_avaiable = false; + + std::string abilist = call_command(cmd_replace(adb_cfg.abilist)).value_or("maatouch"); + std::string_view optimal_abi; + for (const auto& abi : Configer.get_options().minitouch_programs_order) { + if (abilist.find(abi) != std::string::npos) { + optimal_abi = abi; + break; + } } - } - Log.info("The optimal abi is", optimal_abi); + Log.info("The optimal abi is", optimal_abi); - auto minitouch_cmd_rep = [&](const std::string& cfg_cmd) -> std::string { - using namespace asst::utils::path_literals; - return utils::string_replace_all( - cmd_replace(cfg_cmd), - { - { "[minitouchLocalPath]", - utils::path_to_utf8_string(ResDir.get() / "minitouch"_p / optimal_abi / "minitouch"_p) }, - { "[minitouchWorkingFile]", m_uuid }, - }); - }; + auto minitouch_cmd_rep = [&](const std::string& cfg_cmd) -> std::string { + using namespace asst::utils::path_literals; + return utils::string_replace_all( + cmd_replace(cfg_cmd), + { + { "[minitouchLocalPath]", + utils::path_to_utf8_string(ResDir.get() / "minitouch"_p / optimal_abi / "minitouch"_p) }, + { "[minitouchWorkingFile]", m_uuid }, + }); + }; - call_command(minitouch_cmd_rep(adb_cfg.push_minitouch)); - call_command(minitouch_cmd_rep(adb_cfg.chmod_minitouch)); + if (!call_command(minitouch_cmd_rep(adb_cfg.push_minitouch))) break; + if (!call_command(minitouch_cmd_rep(adb_cfg.chmod_minitouch))) break; - m_adb.call_minitouch = minitouch_cmd_rep(adb_cfg.call_minitouch); - call_and_hup_minitouch(m_adb.call_minitouch); + m_adb.call_minitouch = minitouch_cmd_rep(adb_cfg.call_minitouch); + if (!call_and_hup_minitouch(m_adb.call_minitouch)) break; - std::string orientation_str = call_command(cmd_replace(adb_cfg.orientation)).value_or("0"); - if (!orientation_str.empty()) { - char first = orientation_str.front(); - if (first == '0' || first == '1' || first == '2' || first == '3') { - m_minitouch_props.orientation = static_cast(first - '0'); + std::string orientation_str = call_command(cmd_replace(adb_cfg.orientation)).value_or("0"); + if (!orientation_str.empty()) { + char first = orientation_str.front(); + if (first == '0' || first == '1' || first == '2' || first == '3') { + m_minitouch_props.orientation = static_cast(first - '0'); + } } - } + + m_minitouch_avaiable = true; + } while (false); // try to find the fastest way if (!screencap()) { diff --git a/src/MeoAssistant/Resource/GeneralConfiger.cpp b/src/MeoAssistant/Resource/GeneralConfiger.cpp index 5ee58a8580..6620fcb83a 100644 --- a/src/MeoAssistant/Resource/GeneralConfiger.cpp +++ b/src/MeoAssistant/Resource/GeneralConfiger.cpp @@ -18,6 +18,11 @@ bool asst::GeneralConfiger::parse(const json::value& json) m_options.adb_swipe_duration_multiplier = options_json.get("adbSwipeDurationMultiplier", 10.0); m_options.minitouch_extra_swipe_dist = options_json.get("minitouchExtraSwipeDist", 100); m_options.minitouch_extra_swipe_duration = options_json.get("minitouchExtraSwipeDuration", -1); + if (auto order = options_json.find("minitouchProgramsOrder")) { + for (const auto& type : *order) { + m_options.minitouch_programs_order.emplace_back(type.as_string()); + } + } m_options.penguin_report.cmd_format = options_json.get("penguinReport", "cmdFormat", std::string()); m_options.yituliu_report.cmd_format = options_json.get("yituliuReport", "cmdFormat", std::string()); m_options.depot_export_template.ark_planner = diff --git a/src/MeoAssistant/Resource/GeneralConfiger.h b/src/MeoAssistant/Resource/GeneralConfiger.h index 66e54a92a9..c86fe7174a 100644 --- a/src/MeoAssistant/Resource/GeneralConfiger.h +++ b/src/MeoAssistant/Resource/GeneralConfiger.h @@ -42,6 +42,7 @@ namespace asst double adb_swipe_duration_multiplier = 0; // adb 滑动持续时间倍数 int minitouch_extra_swipe_dist = 0; int minitouch_extra_swipe_duration = -1; + std::vector minitouch_programs_order; PenguinReportCfg penguin_report; // 企鹅物流汇报: // 每次到结算界面,汇报掉落数据至企鹅物流 https://penguin-stats.cn/ DepotExportTemplate depot_export_template; // 仓库识别结果导出模板 diff --git a/src/MeoAsstGui/Resources/Localizations/en-us.xaml b/src/MeoAsstGui/Resources/Localizations/en-us.xaml index 99800e578e..22e27bc77e 100644 --- a/src/MeoAsstGui/Resources/Localizations/en-us.xaml +++ b/src/MeoAsstGui/Resources/Localizations/en-us.xaml @@ -60,6 +60,7 @@ Nox XYAZ Old version of WSA + MaaTouch Compatible Mode Morale Threshold diff --git a/src/MeoAsstGui/Resources/Localizations/zh-cn.xaml b/src/MeoAsstGui/Resources/Localizations/zh-cn.xaml index 26d59fc0f7..1d45adb250 100644 --- a/src/MeoAsstGui/Resources/Localizations/zh-cn.xaml +++ b/src/MeoAsstGui/Resources/Localizations/zh-cn.xaml @@ -60,6 +60,7 @@ 夜神模拟器 逍遥模拟器 WSA 旧版本 + MaaTouch 兼容模式 基建工作心情阈值 diff --git a/src/MeoAsstGui/ViewModels/SettingsViewModel.cs b/src/MeoAsstGui/ViewModels/SettingsViewModel.cs index 4c59a035b8..a4ebf9cc10 100644 --- a/src/MeoAsstGui/ViewModels/SettingsViewModel.cs +++ b/src/MeoAsstGui/ViewModels/SettingsViewModel.cs @@ -176,6 +176,7 @@ namespace MeoAsstGui new CombData { Display = Localization.GetString("Nox"), Value = "Nox" }, new CombData { Display = Localization.GetString("XYAZ"), Value = "XYAZ" }, new CombData { Display = Localization.GetString("WSA"), Value = "WSA" }, + new CombData { Display = Localization.GetString("MaaTouch"), Value = "MaaTouch" }, new CombData { Display = Localization.GetString("Compatible"), Value = "Compatible" }, };