MCPcopy Create free account
hub / github.com/MaaXYZ/MaaFramework / create_adb_controller

Function create_adb_controller

sample/cpp/MaaAgent/agent_main.cpp:81–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79}
80
81MaaController* create_adb_controller()
82{
83 auto list_handle = MaaToolkitAdbDeviceListCreate();
84 auto destroy = [&]() {
85 MaaToolkitAdbDeviceListDestroy(list_handle);
86 };
87
88 MaaToolkitAdbDeviceFind(list_handle);
89
90 size_t size = MaaToolkitAdbDeviceListSize(list_handle);
91 if (size == 0) {
92 std::cout << "No device found" << std::endl;
93
94 destroy();
95 return nullptr;
96 }
97
98 const int kIndex = 0; // for demo, we just use the first device
99 auto device_handle = MaaToolkitAdbDeviceListAt(list_handle, kIndex);
100
101 std::string agent_path = "share/MaaAgentBinary";
102 auto controller_handle = MaaAdbControllerCreate(
103 MaaToolkitAdbDeviceGetAdbPath(device_handle),
104 MaaToolkitAdbDeviceGetAddress(device_handle),
105 MaaToolkitAdbDeviceGetScreencapMethods(device_handle),
106 MaaToolkitAdbDeviceGetInputMethods(device_handle),
107 MaaToolkitAdbDeviceGetConfig(device_handle),
108 agent_path.c_str());
109
110 destroy();
111
112 return controller_handle;
113}

Callers 1

mainFunction · 0.70

Tested by

no test coverage detected