-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
692 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
file(GLOB_RECURSE maa_debugging_control_unit_src *.h *.hpp *.cpp ../include) | ||
|
||
add_library(MaaDebuggingControlUnit SHARED ${maa_debugging_control_unit_src}) | ||
|
||
target_include_directories(MaaDebuggingControlUnit PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../include | ||
${CMAKE_CURRENT_SOURCE_DIR}/../../include) | ||
|
||
target_link_libraries(MaaDebuggingControlUnit MaaUtils HeaderOnlyLibraries ${OpenCV_LIBS}) | ||
|
||
target_compile_definitions(MaaDebuggingControlUnit PRIVATE MAA_CONTROL_UNIT_EXPORTS) | ||
|
||
add_dependencies(MaaDebuggingControlUnit MaaUtils) | ||
|
||
install( | ||
TARGETS MaaDebuggingControlUnit | ||
RUNTIME DESTINATION bin | ||
LIBRARY DESTINATION bin | ||
ARCHIVE DESTINATION lib) | ||
|
||
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${maa_debugging_control_unit_src}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#include "ControlUnitMgr.h" | ||
|
||
#include <meojson/json.hpp> | ||
|
||
#include "General/VirtualInfo.h" | ||
#include "Screencap/ReadIndex.h" | ||
#include "Utils/Logger.h" | ||
|
||
#pragma message("MaaControlUnit MAA_VERSION: " MAA_VERSION) | ||
|
||
MAA_DBG_CTRL_UNIT_NS_BEGIN | ||
|
||
std::shared_ptr<ControlUnitAPI> create_controller_unit(MaaStringView read_path, MaaStringView wirte_path, | ||
MaaDebuggingControllerType type, MaaStringView config) | ||
{ | ||
LogFunc << VAR(read_path) << VAR(wirte_path) << VAR(type); | ||
|
||
auto filepath = MAA_NS::path(read_path); | ||
std::ignore = wirte_path; | ||
|
||
std::shared_ptr<ScreencapAPI> screencap_unit = nullptr; | ||
auto screencap_type = type & MaaDebuggingControllerType_Screencap_Mask; | ||
|
||
switch (screencap_type) { | ||
case MaaDebuggingControllerType_Screencap_ReadIndex: | ||
screencap_unit = std::make_shared<ReadIndex>(filepath); | ||
break; | ||
} | ||
|
||
auto device_info_unit = std::make_shared<VirtualInfo>(filepath); | ||
bool parsed = device_info_unit->parse(config); | ||
if (!parsed) { | ||
LogError << "failed to parse config" << VAR(config); | ||
return nullptr; | ||
} | ||
|
||
auto unit_mgr = std::make_shared<ControlUnitMgr>(); | ||
unit_mgr->set_screencap_obj(std::move(screencap_unit)); | ||
unit_mgr->set_device_info_obj(std::move(device_info_unit)); | ||
|
||
return unit_mgr; | ||
} | ||
|
||
MAA_DBG_CTRL_UNIT_NS_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#pragma once | ||
|
||
#include "ControlUnit/DebuggingControlUnitAPI.h" | ||
|
||
MAA_DBG_CTRL_UNIT_NS_BEGIN | ||
|
||
class ControlUnitMgr : public ControlUnitAPI | ||
{ | ||
public: | ||
virtual ~ControlUnitMgr() override = default; | ||
|
||
public: // from ControlUnitAPI | ||
virtual std::shared_ptr<DeviceInfoAPI> device_info_obj() override { return device_info_; } | ||
virtual std::shared_ptr<ScreencapAPI> screencap_obj() override { return screencap_; } | ||
|
||
public: | ||
void set_device_info_obj(std::shared_ptr<DeviceInfoAPI> obj) { device_info_ = std::move(obj); } | ||
void set_screencap_obj(std::shared_ptr<ScreencapAPI> obj) { screencap_ = std::move(obj); } | ||
|
||
private: | ||
std::shared_ptr<DeviceInfoAPI> device_info_ = nullptr; | ||
std::shared_ptr<ScreencapAPI> screencap_ = nullptr; | ||
}; | ||
|
||
MAA_DBG_CTRL_UNIT_NS_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<Project> | ||
<PropertyGroup> | ||
<MaaDepsPropsFile>$(MSBuildThisFileDirectory)..\..\MaaDeps\msbuild\maadeps.props</MaaDepsPropsFile> | ||
</PropertyGroup> | ||
<Import Condition="Exists('$(MaaDepsPropsFile)')" Project="$(MaaDepsPropsFile)" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<Project> | ||
<PropertyGroup> | ||
<MaaDepsTargetsFile>$(MSBuildThisFileDirectory)..\..\MaaDeps\msbuild\maadeps.targets</MaaDepsTargetsFile> | ||
<MaaDepsDisableFlagFile>$(MSBuildThisFileDirectory)..\..\MSBUILD_DISABLE_MAADEPS</MaaDepsDisableFlagFile> | ||
<MaaDepsExists Condition="Exists('$(MaaDepsTargetsFile)')">true</MaaDepsExists> | ||
<MaaDepsDisableFlagExists Condition="Exists('$(MaaDepsDisableFlagFile)')">true</MaaDepsDisableFlagExists> | ||
<MaaDepsMissingMessage>Missing third-party dependencies, run `python maadeps-download.py`. / 缺少第三方依赖,请运行 `python maadeps-download.py`。 | ||
Alternatively, run `python maadeps-build.py` to build third-party dependencies from source, or create a file named `MSBUILD_DISABLE_MAADEPS` next to MAA.sln file and bring your own libraries to MSBuild.</MaaDepsMissingMessage> | ||
</PropertyGroup> | ||
<Target Name="MessageMaaDepsNotExists" BeforeTargets="ClCompile" Condition="$(MaaDepsExists) != 'true' and '$(MaaDepsDisableFlagExists)' != true"> | ||
<Error Text="$(MaaDepsMissingMessage)" /> | ||
</Target> | ||
<Import Condition="$(MaaDepsExists) == 'true'" Project="$(MaaDepsTargetsFile)" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#include "ControlUnitMgr.h" | ||
|
||
#include "Utils/ImageIo.h" | ||
#include "Utils/Logger.h" | ||
#include "VirtualInfo.h" | ||
|
||
MAA_DBG_CTRL_UNIT_NS_BEGIN | ||
|
||
bool VirtualInfo::parse(const json::value& config) | ||
{ | ||
auto device_info = config.find("device_info"); | ||
if (!device_info) { | ||
LogError << "device_info not found" << VAR(config); | ||
return false; | ||
} | ||
|
||
uuid_ = device_info->get("uuid", path_to_utf8_string(path_)); | ||
resolution_.width = device_info->get("screen_width", 0); | ||
resolution_.height = device_info->get("screen_height", 0); | ||
orientation_ = device_info->get("orientation", 0); | ||
|
||
return true; | ||
} | ||
|
||
MAA_DBG_CTRL_UNIT_NS_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#pragma once | ||
|
||
#include "ControlUnit/DebuggingControlUnitAPI.h" | ||
|
||
#include <filesystem> | ||
|
||
MAA_DBG_CTRL_UNIT_NS_BEGIN | ||
|
||
class VirtualInfo : public DeviceInfoAPI | ||
{ | ||
public: | ||
VirtualInfo(std::filesystem::path path) : path_(std::move(path)) {} | ||
virtual ~VirtualInfo() override = default; | ||
|
||
public: // from DeviceInfoAPI | ||
virtual std::string get_uuid() const override { return uuid_; } | ||
virtual DeviceResolution get_resolution() const override { return resolution_; } | ||
virtual int get_orientation() const override { return orientation_; } | ||
|
||
public: | ||
bool parse(const json::value& config); | ||
|
||
private: | ||
std::filesystem::path path_; | ||
|
||
std::string uuid_; | ||
DeviceResolution resolution_; | ||
int orientation_; | ||
}; | ||
|
||
MAA_DBG_CTRL_UNIT_NS_END |
Oops, something went wrong.