mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-16 09:50:40 +08:00
feat: add compile def to disable emulator extras
This commit is contained in:
@@ -8,6 +8,10 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined (ASST_WITH_EMULATOR_EXTRAS)
|
||||
#define ASST_WITH_EMULATOR_EXTRAS 1
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define ASST_DO_PRAGMA(x) __pragma(x)
|
||||
#elif defined(__GNUC__)
|
||||
|
||||
@@ -196,8 +196,11 @@ void asst::AdbController::callback(AsstMsg msg, const json::value& details)
|
||||
}
|
||||
}
|
||||
|
||||
void asst::AdbController::init_mumu_extras(const AdbCfg& adb_cfg)
|
||||
void asst::AdbController::init_mumu_extras(const AdbCfg& adb_cfg [[maybe_unused]])
|
||||
{
|
||||
#if !ASST_WITH_EMULATOR_EXTRAS
|
||||
Log.error("MaaCore is not compiled with ASST_WITH_EMULATOR_EXTRAS");
|
||||
#else
|
||||
if (adb_cfg.extras.empty()) {
|
||||
LogWarn << "adb_cfg.extras is empty";
|
||||
return;
|
||||
@@ -207,6 +210,7 @@ void asst::AdbController::init_mumu_extras(const AdbCfg& adb_cfg)
|
||||
int mumu_index = adb_cfg.extras.get("index", 0);
|
||||
int mumu_display = adb_cfg.extras.get("display", 0);
|
||||
m_mumu_extras.init(mumu_path, mumu_index, mumu_display);
|
||||
#endif
|
||||
}
|
||||
|
||||
void asst::AdbController::close_socket() noexcept
|
||||
@@ -486,6 +490,7 @@ bool asst::AdbController::screencap(cv::Mat& image_payload, bool allow_reconnect
|
||||
Log.info("Encode is not supported");
|
||||
}
|
||||
|
||||
#if ASST_WITH_EMULATOR_EXTRAS
|
||||
if (m_mumu_extras.inited()) {
|
||||
start_time = high_resolution_clock::now();
|
||||
if (m_mumu_extras.screencap()) {
|
||||
@@ -502,13 +507,16 @@ bool asst::AdbController::screencap(cv::Mat& image_payload, bool allow_reconnect
|
||||
Log.info("MumuExtras is not supported");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static const std::unordered_map<AdbProperty::ScreencapMethod, std::string> MethodName = {
|
||||
{ AdbProperty::ScreencapMethod::UnknownYet, "UnknownYet" },
|
||||
{ AdbProperty::ScreencapMethod::RawByNc, "RawByNc" },
|
||||
{ AdbProperty::ScreencapMethod::RawWithGzip, "RawWithGzip" },
|
||||
{ AdbProperty::ScreencapMethod::Encode, "Encode" },
|
||||
#if ASST_WITH_EMULATOR_EXTRAS
|
||||
{ AdbProperty::ScreencapMethod::MumuExtras, "MumuExtras" },
|
||||
#endif
|
||||
};
|
||||
Log.info(
|
||||
"The fastest way is",
|
||||
@@ -545,6 +553,7 @@ bool asst::AdbController::screencap(cv::Mat& image_payload, bool allow_reconnect
|
||||
case AdbProperty::ScreencapMethod::Encode:
|
||||
screencap_ret = screencap(m_adb.screencap_encode, decode_encode, allow_reconnect);
|
||||
break;
|
||||
#if ASST_WITH_EMULATOR_EXTRAS
|
||||
case AdbProperty::ScreencapMethod::MumuExtras: {
|
||||
auto img_opt = m_mumu_extras.screencap();
|
||||
screencap_ret = img_opt.has_value();
|
||||
@@ -552,6 +561,7 @@ bool asst::AdbController::screencap(cv::Mat& image_payload, bool allow_reconnect
|
||||
image_payload = img_opt.value();
|
||||
}
|
||||
} break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Common/AsstConf.h"
|
||||
|
||||
#include "ControllerAPI.h"
|
||||
|
||||
#include <deque>
|
||||
@@ -152,7 +154,9 @@ protected:
|
||||
RawByNc,
|
||||
RawWithGzip,
|
||||
Encode,
|
||||
#if ASST_WITH_EMULATOR_EXTRAS
|
||||
MumuExtras,
|
||||
#endif
|
||||
} screencap_method = ScreencapMethod::UnknownYet;
|
||||
} m_adb;
|
||||
|
||||
@@ -170,6 +174,8 @@ protected:
|
||||
std::deque<long long> m_screencap_cost; // 截图用时
|
||||
int m_screencap_times = 0; // 截图次数
|
||||
|
||||
#if ASST_WITH_EMULATOR_EXTRAS
|
||||
MumuExtras m_mumu_extras;
|
||||
#endif
|
||||
};
|
||||
} // namespace asst
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "MumuExtras.h"
|
||||
|
||||
#if ASST_WITH_EMULATOR_EXTRAS
|
||||
|
||||
#include "Utils/Logger.hpp"
|
||||
#include "Utils/NoWarningCV.h"
|
||||
|
||||
@@ -194,3 +196,4 @@ void MumuExtras::disconnect_mumu()
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "Common/AsstConf.h"
|
||||
|
||||
#if ASST_WITH_EMULATOR_EXTRAS
|
||||
|
||||
#include <filesystem>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
@@ -65,3 +69,4 @@ private:
|
||||
std::function<decltype(nemu_input_event_key_up)> input_event_key_up_func_;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user