Skip to content

Commit 5281094

Browse files
1 parent 12c5b26 commit 5281094

9 files changed

Lines changed: 40 additions & 47 deletions

File tree

source/LibraryHolder/ControlUnit/ControlUnit.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,8 @@ std::shared_ptr<MAA_CTRL_UNIT_NS::ControlUnitAPI>
198198
return std::shared_ptr<MAA_CTRL_UNIT_NS::ControlUnitAPI>(control_unit_handle, destroy_control_unit_func);
199199
}
200200

201-
std::shared_ptr<MAA_CTRL_UNIT_NS::Win32ControlUnitAPI> GamepadControlUnitLibraryHolder::create_control_unit(
202-
void* hWnd,
203-
MaaGamepadType gamepad_type,
204-
MaaWin32ScreencapMethod screencap_method)
201+
std::shared_ptr<MAA_CTRL_UNIT_NS::Win32ControlUnitAPI>
202+
GamepadControlUnitLibraryHolder::create_control_unit(void* hWnd, MaaGamepadType gamepad_type, MaaWin32ScreencapMethod screencap_method)
205203
{
206204
if (!load_library(library_dir() / libname_)) {
207205
LogError << "Failed to load library" << VAR(library_dir()) << VAR(libname_);

source/MaaAdbControlUnit/Input/MtouchHelper.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,19 @@ bool MtouchHelper::request_display_info()
8787
// 上层 ControllerAgent 会使用 touch_down/touch_up 替代 click/swipe
8888
bool MtouchHelper::click(int x, int y)
8989
{
90-
LogError << type_name() << "deprecated: get_features() returns MaaControllerFeature_UseMouseDownAndUpInsteadOfClick, "
91-
"use touch_down/touch_up instead"
90+
LogError << type_name()
91+
<< "deprecated: get_features() returns MaaControllerFeature_UseMouseDownAndUpInsteadOfClick, "
92+
"use touch_down/touch_up instead"
9293
<< VAR(x) << VAR(y);
9394

9495
return false;
9596
}
9697

9798
bool MtouchHelper::swipe(int x1, int y1, int x2, int y2, int duration)
9899
{
99-
LogError << type_name() << "deprecated: get_features() returns MaaControllerFeature_UseMouseDownAndUpInsteadOfClick, "
100-
"use touch_down/touch_move/touch_up instead"
100+
LogError << type_name()
101+
<< "deprecated: get_features() returns MaaControllerFeature_UseMouseDownAndUpInsteadOfClick, "
102+
"use touch_down/touch_move/touch_up instead"
101103
<< VAR(x1) << VAR(y1) << VAR(x2) << VAR(y2) << VAR(duration);
102104

103105
return false;

source/MaaGamepadControlUnit/API/GamepadControlUnitAPI.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#include "ControlUnit/GamepadControlUnitAPI.h"
22

3-
#include "Manager/GamepadControlUnitMgr.h"
43
#include "MaaUtils/Logger.h"
54
#include "MaaUtils/SafeWindows.hpp"
5+
#include "Manager/GamepadControlUnitMgr.h"
66

77
const char* MaaGamepadControlUnitGetVersion()
88
{
@@ -11,8 +11,7 @@ const char* MaaGamepadControlUnitGetVersion()
1111
return MAA_VERSION;
1212
}
1313

14-
MaaWin32ControlUnitHandle
15-
MaaGamepadControlUnitCreate(void* hWnd, MaaGamepadType gamepad_type, MaaWin32ScreencapMethod screencap_method)
14+
MaaWin32ControlUnitHandle MaaGamepadControlUnitCreate(void* hWnd, MaaGamepadType gamepad_type, MaaWin32ScreencapMethod screencap_method)
1615
{
1716
using namespace MAA_CTRL_UNIT_NS;
1817

source/MaaPiCli/CLI/interactor.cpp

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -365,22 +365,22 @@ void Interactor::select_controller()
365365
int index = 0;
366366
if (all_controllers.size() != 1) {
367367
std::cout << "### Select controller ###\n\n";
368-
for (size_t i = 0; i < all_controllers.size(); ++i) {
369-
const auto& ctrl = all_controllers[i];
370-
std::string display_name = get_display_name(ctrl.name, ctrl.label);
371-
std::cout << MAA_NS::utf8_to_crt(std::format("\t{}. {}", i + 1, display_name));
372-
if (ctrl.type == InterfaceData::Controller::Type::PlayCover && !kPlayCoverSupported) {
373-
std::cout << " (macOS only)";
374-
}
375-
if (ctrl.type == InterfaceData::Controller::Type::Gamepad && !kGamepadSupported) {
376-
std::cout << " (Windows only)";
377-
}
378-
std::cout << "\n";
379-
if (!ctrl.description.empty()) {
380-
std::string desc_text = read_text_content(ctrl.description);
381-
std::cout << "\t " << MAA_NS::utf8_to_crt(desc_text) << "\n";
368+
for (size_t i = 0; i < all_controllers.size(); ++i) {
369+
const auto& ctrl = all_controllers[i];
370+
std::string display_name = get_display_name(ctrl.name, ctrl.label);
371+
std::cout << MAA_NS::utf8_to_crt(std::format("\t{}. {}", i + 1, display_name));
372+
if (ctrl.type == InterfaceData::Controller::Type::PlayCover && !kPlayCoverSupported) {
373+
std::cout << " (macOS only)";
374+
}
375+
if (ctrl.type == InterfaceData::Controller::Type::Gamepad && !kGamepadSupported) {
376+
std::cout << " (Windows only)";
377+
}
378+
std::cout << "\n";
379+
if (!ctrl.description.empty()) {
380+
std::string desc_text = read_text_content(ctrl.description);
381+
std::cout << "\t " << MAA_NS::utf8_to_crt(desc_text) << "\n";
382+
}
382383
}
383-
}
384384
std::cout << "\n";
385385
index = input(all_controllers.size()) - 1;
386386
}
@@ -683,12 +683,13 @@ void Interactor::select_gamepad(const MAA_PROJECT_INTERFACE_NS::InterfaceData::C
683683
std::cout << "### Select HWND for screencap ###\n\n";
684684

685685
for (size_t i = 0; i < matched_size; ++i) {
686-
std::cout << MAA_NS::utf8_to_crt(std::format(
687-
"\t{}. {}\n\t\t{}\n\t\t{}\n",
688-
i + 1,
689-
matched_config.at(i).hwnd,
690-
MAA_NS::from_u16(matched_config.at(i).class_name),
691-
MAA_NS::from_u16(matched_config.at(i).window_name)));
686+
std::cout << MAA_NS::utf8_to_crt(
687+
std::format(
688+
"\t{}. {}\n\t\t{}\n\t\t{}\n",
689+
i + 1,
690+
matched_config.at(i).hwnd,
691+
MAA_NS::from_u16(matched_config.at(i).class_name),
692+
MAA_NS::from_u16(matched_config.at(i).window_name)));
692693
}
693694
std::cout << "\n";
694695

source/MaaPiCli/Impl/Runner.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ bool Runner::run(const RuntimeParam& param)
100100
}
101101
else if (const auto* p_gamepad_param = std::get_if<RuntimeParam::GamepadParam>(&param.controller_param)) {
102102
#if defined(_WIN32)
103-
controller_handle =
104-
MaaGamepadControllerCreate(p_gamepad_param->hwnd, p_gamepad_param->gamepad_type, p_gamepad_param->screencap);
103+
controller_handle = MaaGamepadControllerCreate(p_gamepad_param->hwnd, p_gamepad_param->gamepad_type, p_gamepad_param->screencap);
105104
#else
106105
std::ignore = p_gamepad_param;
107106
LogError << "Gamepad controller is only supported on Windows";

source/include/ControlUnit/GamepadControlUnitAPI.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,8 @@ extern "C"
3232
* - contact 3: Right trigger (pressure: 0~255, x/y ignored)
3333
* @see MaaGamepadButton, MaaGamepadTouch, MaaGamepadType
3434
*/
35-
MAA_CONTROL_UNIT_API MaaWin32ControlUnitHandle MaaGamepadControlUnitCreate(
36-
void* hWnd,
37-
MaaGamepadType gamepad_type,
38-
MaaWin32ScreencapMethod screencap_method);
35+
MAA_CONTROL_UNIT_API MaaWin32ControlUnitHandle
36+
MaaGamepadControlUnitCreate(void* hWnd, MaaGamepadType gamepad_type, MaaWin32ScreencapMethod screencap_method);
3937

4038
MAA_CONTROL_UNIT_API void MaaGamepadControlUnitDestroy(MaaWin32ControlUnitHandle handle);
4139

source/include/LibraryHolder/ControlUnit.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,8 @@ class PlayCoverControlUnitLibraryHolder : public LibraryHolder<PlayCoverControlU
9191
class GamepadControlUnitLibraryHolder : public LibraryHolder<GamepadControlUnitLibraryHolder>
9292
{
9393
public:
94-
static std::shared_ptr<MAA_CTRL_UNIT_NS::Win32ControlUnitAPI> create_control_unit(
95-
void* hWnd,
96-
MaaGamepadType gamepad_type,
97-
MaaWin32ScreencapMethod screencap_method);
94+
static std::shared_ptr<MAA_CTRL_UNIT_NS::Win32ControlUnitAPI>
95+
create_control_unit(void* hWnd, MaaGamepadType gamepad_type, MaaWin32ScreencapMethod screencap_method);
9896

9997
private:
10098
inline static const std::filesystem::path libname_ = MAA_NS::path("MaaGamepadControlUnit");

source/modules/MaaFramework.cppm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,4 +286,4 @@ export using ::MaaRectSet;
286286

287287
export using ::MaaVersion;
288288
export using ::MaaGlobalSetOption;
289-
export using ::MaaGlobalLoadPlugin;
289+
export using ::MaaGlobalLoadPlugin;

test/dlopen/main.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,8 @@ int main()
7474
#ifdef WITH_GAMEPAD_CONTROLLER
7575

7676
std::cout << "********** GamepadControlUnitLibraryHolder::create_control_unit **********" << std::endl;
77-
auto gamepad_handle = MAA_NS::GamepadControlUnitLibraryHolder::create_control_unit(
78-
nullptr,
79-
MaaGamepadType_Xbox360,
80-
MaaWin32ScreencapMethod_None);
77+
auto gamepad_handle =
78+
MAA_NS::GamepadControlUnitLibraryHolder::create_control_unit(nullptr, MaaGamepadType_Xbox360, MaaWin32ScreencapMethod_None);
8179
if (!gamepad_handle) {
8280
std::cerr << "Failed to create gamepad control unit" << std::endl;
8381
return -1;

0 commit comments

Comments
 (0)