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

Function main

sample/cpp/main.cpp:29–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27 /* out */ MaaStringBuffer* out_detail);
28
29int main([[maybe_unused]] int argc, char** argv)
30{
31 std::string user_path = "./";
32 MaaToolkitConfigInitOption(user_path.c_str(), "{}");
33
34 auto controller_handle = create_adb_controller();
35 // auto controller_handle = create_win32_controller();
36 // auto controller_handle = create_macos_controller();
37 auto ctrl_id = MaaControllerPostConnection(controller_handle);
38
39 auto resource_handle = MaaResourceCreate();
40 std::string resource_dir = R"(E:\Code\MaaFramework\sample\resource)";
41 auto res_id = MaaResourcePostBundle(resource_handle, resource_dir.c_str());
42
43 MaaControllerWait(controller_handle, ctrl_id);
44 MaaResourceWait(resource_handle, res_id);
45
46 auto tasker_handle = MaaTaskerCreate();
47 MaaTaskerBindResource(tasker_handle, resource_handle);
48 MaaTaskerBindController(tasker_handle, controller_handle);
49
50 auto destroy = [&]() {
51 MaaTaskerDestroy(tasker_handle);
52 MaaResourceDestroy(resource_handle);
53 MaaControllerDestroy(controller_handle);
54 };
55
56 if (!MaaTaskerInited(tasker_handle)) {
57 std::cout << "Failed to init MAA" << std::endl;
58
59 destroy();
60 return -1;
61 }
62
63 MaaResourceRegisterCustomRecognition(resource_handle, "MyReco", my_reco, nullptr);
64
65 auto task_id = MaaTaskerPostTask(tasker_handle, "MyTask", "{}");
66 MaaTaskerWait(tasker_handle, task_id);
67
68 destroy();
69
70 return 0;
71}
72
73MaaController* create_adb_controller()
74{

Callers

nothing calls this directly

Calls 15

MaaResourcePostBundleFunction · 0.85
MaaControllerWaitFunction · 0.85
MaaResourceWaitFunction · 0.85
MaaTaskerBindResourceFunction · 0.85
MaaTaskerBindControllerFunction · 0.85
MaaTaskerInitedFunction · 0.85
destroyFunction · 0.85
MaaTaskerPostTaskFunction · 0.85
MaaTaskerWaitFunction · 0.85

Tested by

no test coverage detected