mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-19 10:32:19 +08:00
chore: Add get_controller_type() to discern Android / PlayTools
This commit is contained in:
@@ -49,6 +49,10 @@ size_t asst::Controller::get_version() const noexcept
|
||||
return m_controller->get_version();
|
||||
}
|
||||
|
||||
asst::ControllerType asst::Controller::get_controller_type() const noexcept
|
||||
{
|
||||
return m_controller_type;
|
||||
}
|
||||
|
||||
std::pair<int, int> asst::Controller::get_scale_size() const noexcept
|
||||
{
|
||||
|
||||
@@ -52,6 +52,8 @@ public:
|
||||
|
||||
size_t get_version() const noexcept;
|
||||
|
||||
ControllerType get_controller_type() const noexcept;
|
||||
|
||||
cv::Mat get_image(bool raw = false);
|
||||
cv::Mat get_image_cache() const;
|
||||
bool screencap(bool allow_reconnect = false);
|
||||
|
||||
@@ -9,48 +9,53 @@ bool StartGameTaskPlugin::_run()
|
||||
if (m_client_type.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// check for android version, because it leads to different magic values
|
||||
// https://github.com/MaaAssistantArknights/MaaAssistantArknights/pull/8966#issuecomment-2094369694
|
||||
if (ctrler()->get_version() > 8) {
|
||||
do {
|
||||
if (!ctrler()->start_game(m_client_type)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// https://github.com/MaaAssistantArknights/MaaAssistantArknights/pull/8961#issue-2277568882
|
||||
// 167: magic value needs to be >164 but <172 (as that's max)
|
||||
if (ctrler()->get_pipe_data_size() > 167) {
|
||||
return true;
|
||||
}
|
||||
|
||||
sleep(1500);
|
||||
|
||||
} while (true);
|
||||
// check for MAC / iOS
|
||||
if (ctrler()->get_controller_type() == ControllerType::MacPlayTools) {
|
||||
return ctrler()->start_game(m_client_type);
|
||||
}
|
||||
else {
|
||||
do {
|
||||
if (!ctrler()->start_game(m_client_type)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 145: needs to be >85 but <153 (as that's max)
|
||||
// magic value lowered because of different android version
|
||||
if (ctrler()->get_pipe_data_size() > 145) {
|
||||
// As there's no way to know (in Android < 8) if Ark has correctly started
|
||||
// we run the command a few more times to be sure
|
||||
for (auto _ = 3; _--;) {
|
||||
sleep(1500);
|
||||
if (!ctrler()->start_game(m_client_type)) {
|
||||
return false;
|
||||
}
|
||||
// check for android version, because it leads to different magic values
|
||||
// https://github.com/MaaAssistantArknights/MaaAssistantArknights/pull/8966#issuecomment-2094369694
|
||||
if (ctrler()->get_version() > 8) {
|
||||
do {
|
||||
if (!ctrler()->start_game(m_client_type)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
sleep(1500);
|
||||
// https://github.com/MaaAssistantArknights/MaaAssistantArknights/pull/8961#issue-2277568882
|
||||
// 167: magic value needs to be >164 but <172 (as that's max)
|
||||
if (ctrler()->get_pipe_data_size() > 167) {
|
||||
return true;
|
||||
}
|
||||
|
||||
} while (true);
|
||||
sleep(1500);
|
||||
|
||||
} while (true);
|
||||
}
|
||||
else {
|
||||
do {
|
||||
if (!ctrler()->start_game(m_client_type)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 145: needs to be >85 but <153 (as that's max)
|
||||
// magic value lowered because of different android version
|
||||
if (ctrler()->get_pipe_data_size() > 145) {
|
||||
// As there's no way to know (in Android < 8) if Ark has correctly started
|
||||
// we run the command a few more times to be sure
|
||||
for (auto _ = 3; _--;) {
|
||||
sleep(1500);
|
||||
if (!ctrler()->start_game(m_client_type)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
sleep(1500);
|
||||
|
||||
} while (true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user