| 12 | #include "MaaUtils/Logger.h" |
| 13 | |
| 14 | MAA_CTRL_UNIT_NS_BEGIN |
| 15 | |
| 16 | InputAgent::InputAgent(MaaAdbInputMethod methods, const std::filesystem::path& agent_path) |
| 17 | { |
| 18 | std::vector<Method> method_vector; |
| 19 | if (methods & MaaAdbInputMethod_EmulatorExtras) { |
| 20 | #ifdef _WIN32 |
| 21 | method_vector.emplace_back(InputAgent::Method::MuMuPlayerExtras); |
| 22 | method_vector.emplace_back(InputAgent::Method::AndrowsExtras); |
| 23 | #else |
| 24 | LogWarn << "EmulatorExtras is not supported on this platform"; |
| 25 | #endif |
| 26 | } |
| 27 | if (methods & MaaAdbInputMethod_Maatouch) { |
| 28 | method_vector.emplace_back(InputAgent::Method::Maatouch); |
| 29 | } |
| 30 | if (methods & MaaAdbInputMethod_MinitouchAndAdbKey) { |
| 31 | method_vector.emplace_back(InputAgent::Method::MinitouchAndAdbKey); |
| 32 | } |
| 33 | if (methods & MaaAdbInputMethod_AdbShell) { |
| 34 | method_vector.emplace_back(InputAgent::Method::AdbShell); |
| 35 | } |
| 36 | |
| 37 | LogInfo << VAR(methods) << VAR(method_vector) << VAR(agent_path); |
| 38 | |
| 39 | for (Method method : method_vector) { |
| 40 | std::shared_ptr<InputBase> unit = nullptr; |
| 41 | switch (method) { |
| 42 | case Method::AdbShell: |
| 43 | unit = std::make_shared<AdbShellInput>(); |
| 44 | break; |
| 45 | |
| 46 | case Method::Maatouch: { |
| 47 | auto maatouch_path = agent_path / "maatouch"; |
| 48 | if (!std::filesystem::exists(maatouch_path)) { |
| 49 | LogWarn << "maatouch path not exists" << VAR(maatouch_path); |
| 50 | break; |
| 51 | } |
| 52 | unit = std::make_shared<MaatouchInput>(maatouch_path); |
| 53 | } break; |
| 54 | |
| 55 | case Method::MinitouchAndAdbKey: { |
| 56 | auto minitouch_path = agent_path / "minitouch"; |
| 57 | if (!std::filesystem::exists(minitouch_path)) { |
| 58 | LogWarn << "minitouch path not exists" << VAR(minitouch_path); |
| 59 | break; |
| 60 | } |
| 61 | unit = std::make_shared<MinitouchInput>(minitouch_path); |
| 62 | } break; |
| 63 | |
| 64 | #ifdef _WIN32 |
| 65 | case Method::MuMuPlayerExtras: |
| 66 | unit = std::make_shared<MuMuPlayerExtras>(); |
| 67 | break; |
| 68 | |
| 69 | case Method::AndrowsExtras: { |
| 70 | auto minitouch_path = agent_path / "minitouch"; |
| 71 | if (!std::filesystem::exists(minitouch_path)) { |
nothing calls this directly
no outgoing calls
no test coverage detected