|
1 |
| -#include "MaaFramework/Instance/MaaController.h" |
| 1 | +#include "MaaFramework/MaaAPI.h" |
2 | 2 |
|
3 |
| -#include "Controller/CustomControllerAgent.h" |
4 |
| -#include "Controller/GeneralControllerAgent.h" |
5 |
| -#include "LibraryHolder/ControlUnit.h" |
| 3 | +#include "Common/MaaTypes.h" |
6 | 4 | #include "Utils/Buffer/ImageBuffer.hpp"
|
7 | 5 | #include "Utils/Buffer/StringBuffer.hpp"
|
8 | 6 | #include "Utils/Logger.h"
|
9 | 7 | #include "Utils/Platform.h"
|
10 | 8 |
|
11 |
| -MaaController* MaaAdbControllerCreate( |
12 |
| - const char* adb_path, |
13 |
| - const char* address, |
14 |
| - MaaAdbScreencapMethod screencap_methods, |
15 |
| - MaaAdbInputMethod input_methods, |
16 |
| - const char* config, |
17 |
| - const char* agent_path, |
18 |
| - MaaNotificationCallback notify, |
19 |
| - void* notify_trans_arg) |
20 |
| -{ |
21 |
| - LogFunc << VAR(adb_path) << VAR(address) << VAR(screencap_methods) << VAR(input_methods) << VAR(config) << VAR(agent_path) |
22 |
| - << VAR_VOIDP(notify) << VAR_VOIDP(notify_trans_arg); |
23 |
| - |
24 |
| - auto control_unit = |
25 |
| - MAA_NS::AdbControlUnitLibraryHolder::create_control_unit(adb_path, address, screencap_methods, input_methods, config, agent_path); |
26 |
| - |
27 |
| - if (!control_unit) { |
28 |
| - LogError << "Failed to create control unit"; |
29 |
| - return nullptr; |
30 |
| - } |
31 |
| - |
32 |
| - return new MAA_CTRL_NS::GeneralControllerAgent(std::move(control_unit), notify, notify_trans_arg); |
33 |
| -} |
34 |
| - |
35 |
| -MaaController* MaaWin32ControllerCreate( |
36 |
| - void* hWnd, |
37 |
| - MaaWin32ScreencapMethod screencap_method, |
38 |
| - MaaWin32InputMethod input_method, |
39 |
| - MaaNotificationCallback notify, |
40 |
| - void* notify_trans_arg) |
41 |
| -{ |
42 |
| - LogFunc << VAR_VOIDP(hWnd) << VAR(screencap_method) << VAR(input_method) << VAR_VOIDP(notify) << VAR_VOIDP(notify_trans_arg); |
43 |
| - |
44 |
| -#ifndef _WIN32 |
45 |
| - |
46 |
| - LogError << "This API" << __FUNCTION__ << "is only available on Windows"; |
47 |
| - return nullptr; |
48 |
| - |
49 |
| -#else |
50 |
| - |
51 |
| - if (!hWnd) { |
52 |
| - LogWarn << "hWnd is nullptr"; |
53 |
| - } |
54 |
| - |
55 |
| - auto control_unit = MAA_NS::Win32ControlUnitLibraryHolder::create_control_unit(hWnd, screencap_method, input_method); |
56 |
| - |
57 |
| - if (!control_unit) { |
58 |
| - LogError << "Failed to create control unit"; |
59 |
| - return nullptr; |
60 |
| - } |
61 |
| - |
62 |
| - return new MAA_CTRL_NS::GeneralControllerAgent(std::move(control_unit), notify, notify_trans_arg); |
63 |
| - |
64 |
| -#endif |
65 |
| -} |
66 |
| - |
67 |
| -MaaController* MaaCustomControllerCreate( |
68 |
| - MaaCustomControllerCallbacks* controller, |
69 |
| - void* controller_arg, |
70 |
| - MaaNotificationCallback notify, |
71 |
| - void* notify_trans_arg) |
72 |
| -{ |
73 |
| - LogFunc << VAR(controller) << VAR(controller_arg) << VAR_VOIDP(notify) << VAR_VOIDP(notify_trans_arg); |
74 |
| - |
75 |
| - if (!controller) { |
76 |
| - LogError << "controller is null"; |
77 |
| - return nullptr; |
78 |
| - } |
79 |
| - |
80 |
| - return new MAA_CTRL_NS::CustomControllerAgent(controller, controller_arg, notify, notify_trans_arg); |
81 |
| -} |
82 |
| - |
83 |
| -MaaController* MaaDbgControllerCreate( |
84 |
| - const char* read_path, |
85 |
| - const char* write_path, |
86 |
| - MaaDbgControllerType type, |
87 |
| - const char* config, |
88 |
| - MaaNotificationCallback notify, |
89 |
| - void* notify_trans_arg) |
90 |
| -{ |
91 |
| - LogFunc << VAR(read_path) << VAR(write_path) << VAR(type) << VAR_VOIDP(notify) << VAR_VOIDP(notify_trans_arg); |
92 |
| - |
93 |
| - std::ignore = write_path; |
94 |
| - std::ignore = config; |
95 |
| - |
96 |
| - auto control_unit = MAA_NS::DbgControlUnitLibraryHolder::create_control_unit(type, read_path); |
97 |
| - |
98 |
| - if (!control_unit) { |
99 |
| - LogError << "Failed to create control unit"; |
100 |
| - return nullptr; |
101 |
| - } |
102 |
| - |
103 |
| - return new MAA_CTRL_NS::GeneralControllerAgent(std::move(control_unit), notify, notify_trans_arg); |
104 |
| -} |
105 |
| - |
106 |
| -void MaaControllerDestroy(MaaController* ctrl) |
107 |
| -{ |
108 |
| - LogFunc << VAR_VOIDP(ctrl); |
109 |
| - |
110 |
| - if (ctrl == nullptr) { |
111 |
| - LogError << "handle is null"; |
112 |
| - return; |
113 |
| - } |
114 |
| - |
115 |
| - delete ctrl; |
116 |
| -} |
117 |
| - |
118 | 9 | MaaBool MaaControllerSetOption(MaaController* ctrl, MaaCtrlOption key, MaaOptionValue value, MaaOptionValueSize val_size)
|
119 | 10 | {
|
120 | 11 | LogFunc << VAR_VOIDP(ctrl) << VAR(key) << VAR_VOIDP(value) << VAR(val_size);
|
|
0 commit comments