mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-15 17:30:27 +08:00
feat: 完成minitouch的push
This commit is contained in:
BIN
3rdparty/resource/minitouch/arm64-v8a/minitouch
vendored
Normal file
BIN
3rdparty/resource/minitouch/arm64-v8a/minitouch
vendored
Normal file
Binary file not shown.
BIN
3rdparty/resource/minitouch/armeabi-v7a/minitouch
vendored
Normal file
BIN
3rdparty/resource/minitouch/armeabi-v7a/minitouch
vendored
Normal file
Binary file not shown.
BIN
3rdparty/resource/minitouch/armeabi/minitouch
vendored
Normal file
BIN
3rdparty/resource/minitouch/armeabi/minitouch
vendored
Normal file
Binary file not shown.
BIN
3rdparty/resource/minitouch/x86/minitouch
vendored
Normal file
BIN
3rdparty/resource/minitouch/x86/minitouch
vendored
Normal file
Binary file not shown.
BIN
3rdparty/resource/minitouch/x86_64/minitouch
vendored
Normal file
BIN
3rdparty/resource/minitouch/x86_64/minitouch
vendored
Normal file
Binary file not shown.
@@ -55,7 +55,10 @@
|
||||
"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[^/]*`\""
|
||||
"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[^/]*`\"",
|
||||
"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]\" [minitouchInput]"
|
||||
},
|
||||
"BlueStacks": {
|
||||
"devices": "[Adb] devices",
|
||||
@@ -73,7 +76,10 @@
|
||||
"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[^/]*`\""
|
||||
"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[^/]*`\"",
|
||||
"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]\" [minitouchInput]"
|
||||
},
|
||||
"MuMuEmulator": {
|
||||
"devices": "[Adb] devices",
|
||||
@@ -91,7 +97,10 @@
|
||||
"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[^/]*`\""
|
||||
"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[^/]*`\"",
|
||||
"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]\" [minitouchInput]"
|
||||
},
|
||||
"LDPlayer": {
|
||||
"devices": "[Adb] devices",
|
||||
@@ -109,7 +118,10 @@
|
||||
"screencapEncode": "[Adb] -s [AdbSerial] shell 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[^/]*`\""
|
||||
"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[^/]*`\"",
|
||||
"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]\" [minitouchInput]"
|
||||
},
|
||||
"Nox": {
|
||||
"devices": "[Adb] devices",
|
||||
@@ -127,7 +139,10 @@
|
||||
"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[^/]*`\""
|
||||
"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[^/]*`\"",
|
||||
"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]\" [minitouchInput]"
|
||||
},
|
||||
"XYAZ": {
|
||||
"devices": "[Adb] devices",
|
||||
@@ -145,7 +160,10 @@
|
||||
"screencapEncode": "[Adb] -s [AdbSerial] shell 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[^/]*`\""
|
||||
"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[^/]*`\"",
|
||||
"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]\" [minitouchInput]"
|
||||
},
|
||||
"WSA": {
|
||||
"devices": "[Adb] devices",
|
||||
@@ -164,7 +182,10 @@
|
||||
"screencapEncode": "[Adb] -s [AdbSerial] shell screencap -d [DisplayId] -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[^/]*`\""
|
||||
"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[^/]*`\"",
|
||||
"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]\" [minitouchInput]"
|
||||
},
|
||||
"Compatible": {
|
||||
"devices": "[Adb] devices",
|
||||
@@ -182,7 +203,10 @@
|
||||
"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[^/]*`\""
|
||||
"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[^/]*`\"",
|
||||
"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]\" [minitouchInput]"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -997,7 +997,7 @@ bool asst::Controller::connect(const std::string& adb_path, const std::string& a
|
||||
}
|
||||
|
||||
auto& uuid_str = uuid_ret.value();
|
||||
std::erase(uuid_str, ' ');
|
||||
std::erase_if(uuid_str, [](char c) { return !std::isdigit(c) && !std::isalpha(c); });
|
||||
m_uuid = std::move(uuid_str);
|
||||
|
||||
json::value info = get_info_json() | json::object {
|
||||
@@ -1166,6 +1166,23 @@ bool asst::Controller::connect(const std::string& adb_path, const std::string& a
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_enable_minitouch) {
|
||||
auto minitouch_cmd_rep = [&](const std::string& cfg_cmd) -> std::string {
|
||||
return utils::string_replace_all(
|
||||
cmd_replace(cfg_cmd),
|
||||
{
|
||||
// TODO: 用 adb shell getprop ro.product.cpu.abilist 来判断该用哪个文件夹里的
|
||||
{ "[minitouchLocalPath]", (m_resource_path / "minitouch" / "armeabi-v7a" / "minitouch").string() },
|
||||
{ "[minitouchWorkingFile]", m_uuid },
|
||||
});
|
||||
};
|
||||
|
||||
call_command(minitouch_cmd_rep(adb_cfg.push_minitouch));
|
||||
call_command(minitouch_cmd_rep(adb_cfg.chmod_minitouch));
|
||||
|
||||
m_adb.call_minitouch = minitouch_cmd_rep(adb_cfg.push_minitouch);
|
||||
}
|
||||
|
||||
// try to find the fastest way
|
||||
if (!screencap()) {
|
||||
Log.error("Cannot find a proper way to screencap!");
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
#include <atomic>
|
||||
#include <condition_variable>
|
||||
#include <filesystem>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <optional>
|
||||
@@ -40,6 +41,7 @@ namespace asst
|
||||
bool connect(const std::string& adb_path, const std::string& address, const std::string& config);
|
||||
bool inited() const noexcept;
|
||||
void set_exit_flag(bool* flag);
|
||||
inline static void set_resource_path(const std::filesystem::path& path) { m_resource_path = path; }
|
||||
|
||||
const std::string& get_uuid() const;
|
||||
cv::Mat get_image(bool raw = false);
|
||||
@@ -133,6 +135,8 @@ namespace asst
|
||||
std::string start;
|
||||
std::string stop;
|
||||
|
||||
std::string call_minitouch;
|
||||
|
||||
/* properties */
|
||||
enum class ScreencapEndOfLine
|
||||
{
|
||||
@@ -152,6 +156,10 @@ namespace asst
|
||||
} screencap_method = ScreencapMethod::UnknownYet;
|
||||
} m_adb;
|
||||
|
||||
bool m_enable_minitouch = true;
|
||||
|
||||
inline static std::filesystem::path m_resource_path;
|
||||
|
||||
std::string m_uuid;
|
||||
inline static std::string m_adb_release; // 开了 adb daemon,但是没连上模拟器的时候,
|
||||
// m_adb 并不会存下 release 的命令,但最后仍然需要一次释放。
|
||||
|
||||
@@ -46,7 +46,9 @@ bool asst::GeneralConfiger::parse(const json::value& json)
|
||||
adb.release = cfg_json.at("release").as_string();
|
||||
adb.start = cfg_json.at("start").as_string();
|
||||
adb.stop = cfg_json.at("stop").as_string();
|
||||
// adb.pullscreen = cfg_json.at("pullscreen").as_string();
|
||||
adb.push_minitouch = cfg_json.at("pushMinitouch").as_string();
|
||||
adb.chmod_minitouch = cfg_json.at("chmodMinitouch").as_string();
|
||||
adb.call_minitouch = cfg_json.at("callMinitouch").as_string();
|
||||
|
||||
m_adb_cfg[name] = std::move(adb);
|
||||
}
|
||||
|
||||
@@ -68,6 +68,9 @@ namespace asst
|
||||
std::string release;
|
||||
std::string start;
|
||||
std::string stop;
|
||||
std::string push_minitouch;
|
||||
std::string chmod_minitouch;
|
||||
std::string call_minitouch;
|
||||
};
|
||||
|
||||
class GeneralConfiger final : public SingletonHolder<GeneralConfiger>, public AbstractConfiger
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "Utils/Logger.hpp"
|
||||
|
||||
#include "Controller.h"
|
||||
#include "Resource/BattleDataConfiger.h"
|
||||
#include "Resource/CopilotConfiger.h"
|
||||
#include "Resource/GeneralConfiger.h"
|
||||
@@ -67,6 +68,10 @@ bool asst::ResourceLoader::load(const std::filesystem::path& path)
|
||||
LoadResourceAndCheckRet(WordOcr, "PaddleOCR"_p);
|
||||
LoadResourceAndCheckRet(CharOcr, "PaddleCharOCR"_p);
|
||||
|
||||
if (!m_loaded) {
|
||||
Controller::set_resource_path(path);
|
||||
}
|
||||
|
||||
m_loaded = true;
|
||||
|
||||
#undef LoadTemplByConfigerAndCheckRet
|
||||
|
||||
Reference in New Issue
Block a user