Skip to content

Commit 4862d0a

Browse files
authored
refactor: control unit进一步细分 (#1191)
1 parent 03d060b commit 4862d0a

46 files changed

Lines changed: 81 additions & 201 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/en_us/2.2-IntegratedInterfaceOverview.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,8 @@ Asynchronously scroll. This is an asynchronous operation that immediately return
463463

464464
> [!NOTE]
465465
>
466-
> - Only Win32 Controller supports scroll operations. Adb Controller does not support scrolling.
466+
> - Win32 controllers and custom controllers that implement `scroll` support scroll operations.
467+
> - Posting scroll to a controller that does not implement `scroll` will cause the action to fail.
467468
> - The `dx`/`dy` values are sent directly as scroll increments. The Windows standard wheel increment is 120 (WHEEL_DELTA) per notch. Using multiples of 120 is recommended for best compatibility.
468469
469470
### MaaControllerPostInactive

docs/en_us/3.1-PipelineProtocol.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1094,7 +1094,8 @@ Additional properties for this action:
10941094

10951095
> [!NOTE]
10961096
>
1097-
> - Adb Controller and PlayCover Controller do not support scroll operations. Only Win32 Controller is supported.
1097+
> - Win32 controllers and custom controllers that implement `scroll` support scroll operations.
1098+
> - Posting a `Scroll` action to a controller that does not implement `scroll` will cause the action to fail.
10981099
> - The `dx`/`dy` values are sent directly as scroll increments. The Windows standard wheel increment is 120 (WHEEL_DELTA) per notch. Using multiples of 120 is recommended for best compatibility.
10991100
11001101
### `ClickKey`

docs/zh_cn/2.2-集成接口一览.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@
463463

464464
> [!NOTE]
465465
>
466-
> - Win32 控制器支持滚动操作,Adb 控制器不支持
466+
> - Win32 控制器,以及实现了 `scroll` 的自定义控制器支持滚动操作
467467
> - `dx`/`dy` 的值会直接作为滚动增量发送。Windows 标准滚轮每格增量为 120(WHEEL_DELTA),建议使用 120 的整数倍以获得最佳兼容性。
468468
469469
### MaaControllerPostInactive

docs/zh_cn/3.1-任务流水线协议.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1103,7 +1103,7 @@ Pipeline v2 时,将这些字段放到 `recognition.param` 中即可。
11031103

11041104
> [!NOTE]
11051105
>
1106-
> - Adb 控制器和 PlayCover 控制器不支持滚动操作。仅 Win32 控制器支持
1106+
> - Win32 控制器,以及实现了 `scroll` 的自定义控制器支持滚动操作
11071107
> - `dx`/`dy` 的值会直接作为滚动增量发送。Windows 标准滚轮每格增量为 120(WHEEL_DELTA),建议使用 120 的整数倍以获得最佳兼容性。
11081108
11091109
### `ClickKey`

include/MaaFramework/Instance/MaaController.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,9 @@ extern "C"
171171
* @param dy The vertical scroll delta. Positive values scroll up, negative values scroll down.
172172
* @return The control id of the scroll action.
173173
*
174-
* @note Not all controllers support scroll. If not supported, the action will fail.
174+
* @note Scroll is supported by Win32 controllers and custom controllers that implement scroll.
175+
* @note If the controller does not support scroll, the action will fail. Use MaaControllerStatus or
176+
* MaaControllerWait to check the result.
175177
* @note The dx/dy values are sent directly as scroll increments. Using multiples of 120 (WHEEL_DELTA) is
176178
* recommended for best compatibility.
177179
*/

source/LibraryHolder/ControlUnit/ControlUnit.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ std::shared_ptr<MAA_CTRL_UNIT_NS::ControlUnitAPI>
135135
return std::shared_ptr<MAA_CTRL_UNIT_NS::ControlUnitAPI>(control_unit_handle, destroy_control_unit_func);
136136
}
137137

138-
std::shared_ptr<MAA_CTRL_UNIT_NS::ControlUnitAPI>
138+
std::shared_ptr<MAA_CTRL_UNIT_NS::CustomControlUnitAPI>
139139
CustomControlUnitLibraryHolder::create_control_unit(MaaCustomControllerCallbacks* controller, void* controller_arg)
140140
{
141141
if (!load_library(library_dir() / libname_)) {
@@ -164,7 +164,7 @@ std::shared_ptr<MAA_CTRL_UNIT_NS::ControlUnitAPI>
164164
return nullptr;
165165
}
166166

167-
return std::shared_ptr<MAA_CTRL_UNIT_NS::ControlUnitAPI>(control_unit_handle, destroy_control_unit_func);
167+
return std::shared_ptr<MAA_CTRL_UNIT_NS::CustomControlUnitAPI>(control_unit_handle, destroy_control_unit_func);
168168
}
169169

170170
std::shared_ptr<MAA_CTRL_UNIT_NS::ControlUnitAPI>
@@ -199,7 +199,7 @@ std::shared_ptr<MAA_CTRL_UNIT_NS::ControlUnitAPI>
199199
return std::shared_ptr<MAA_CTRL_UNIT_NS::ControlUnitAPI>(control_unit_handle, destroy_control_unit_func);
200200
}
201201

202-
std::shared_ptr<MAA_CTRL_UNIT_NS::Win32ControlUnitAPI>
202+
std::shared_ptr<MAA_CTRL_UNIT_NS::GamepadControlUnitAPI>
203203
GamepadControlUnitLibraryHolder::create_control_unit(void* hWnd, MaaGamepadType gamepad_type, MaaWin32ScreencapMethod screencap_method)
204204
{
205205
if (!load_library(library_dir() / libname_)) {
@@ -228,7 +228,7 @@ std::shared_ptr<MAA_CTRL_UNIT_NS::Win32ControlUnitAPI>
228228
return nullptr;
229229
}
230230

231-
return std::shared_ptr<MAA_CTRL_UNIT_NS::Win32ControlUnitAPI>(control_unit_handle, destroy_control_unit_func);
231+
return std::shared_ptr<MAA_CTRL_UNIT_NS::GamepadControlUnitAPI>(control_unit_handle, destroy_control_unit_func);
232232
}
233233

234234
std::shared_ptr<MAA_CTRL_UNIT_NS::ControlUnitAPI> WlRootsControlUnitLibraryHolder::create_control_unit(const char* wlr_socket_path)

source/MaaAdbControlUnit/Base/UnitBase.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ class InputBase
9999
virtual bool key_down(int key) = 0;
100100
virtual bool key_up(int key) = 0;
101101

102-
virtual bool scroll(int dx, int dy) = 0;
103102
};
104103

105104
MAA_CTRL_UNIT_NS_END

source/MaaAdbControlUnit/EmulatorExtras/MuMuPlayerExtras.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -379,12 +379,6 @@ bool MuMuPlayerExtras::key_up(int key)
379379
return true;
380380
}
381381

382-
bool MuMuPlayerExtras::scroll(int dx, int dy)
383-
{
384-
LogError << "Scroll is not supported on MuMuPlayerExtras" << VAR(dx) << VAR(dy);
385-
return false;
386-
}
387-
388382
void MuMuPlayerExtras::on_app_started(const std::string& intent)
389383
{
390384
std::string package = string_split(intent, '/').front();

source/MaaAdbControlUnit/EmulatorExtras/MuMuPlayerExtras.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ class MuMuPlayerExtras
4646
virtual bool key_down(int key) override;
4747
virtual bool key_up(int key) override;
4848

49-
virtual bool scroll(int dx, int dy) override;
50-
5149
public: // from ControlUnitSink
5250
virtual void on_app_started(const std::string& intent) override;
5351
virtual void on_app_stopped(const std::string& intent) override;

source/MaaAdbControlUnit/Input/AdbShellInput.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,4 @@ bool AdbShellInput::key_up(int key)
125125
return false;
126126
}
127127

128-
bool AdbShellInput::scroll(int dx, int dy)
129-
{
130-
LogError << "Scroll is not supported on Adb controller" << VAR(dx) << VAR(dy);
131-
return false;
132-
}
133-
134128
MAA_CTRL_UNIT_NS_END

0 commit comments

Comments
 (0)