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

Method find

source/binding/NodeJS/src/apis/controller.cpp:421–464  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

419}
420
421maajs::PromiseType AdbControllerImpl::find(maajs::EnvType env, maajs::OptionalParam<std::string> adb)
422{
423#ifdef MAA_JS_WITH_TOOLKIT
424 using Result = std::optional<std::vector<AdbDevice>>;
425 auto worker = new maajs::AsyncWork<Result>(env, [adb]() -> Result {
426 auto lst = MaaToolkitAdbDeviceListCreate();
427 bool succ = false;
428 if (adb) {
429 succ = MaaToolkitAdbDeviceFindSpecified(adb->c_str(), lst);
430 }
431 else {
432 succ = MaaToolkitAdbDeviceFind(lst);
433 }
434 if (!succ) {
435 MaaToolkitAdbDeviceListDestroy(lst);
436 return std::nullopt;
437 }
438
439 std::vector<AdbDevice> result;
440 auto size = MaaToolkitAdbDeviceListSize(lst);
441 result.reserve(size);
442 for (size_t i = 0; i < size; i++) {
443 auto dev = MaaToolkitAdbDeviceListAt(lst, i);
444 result.push_back(
445 std::make_tuple(
446 std::string(MaaToolkitAdbDeviceGetName(dev)),
447 std::string(MaaToolkitAdbDeviceGetAdbPath(dev)),
448 std::string(MaaToolkitAdbDeviceGetAddress(dev)),
449 MaaToolkitAdbDeviceGetScreencapMethods(dev),
450 MaaToolkitAdbDeviceGetInputMethods(dev),
451 std::string(MaaToolkitAdbDeviceGetConfig(dev))));
452 }
453 MaaToolkitAdbDeviceListDestroy(lst);
454
455 return result;
456 });
457 worker->Queue();
458 return worker->Promise();
459#else
460 std::ignore = env;
461 std::ignore = adb;
462 throw_toolkit_unavailable("AdbController.find");
463#endif
464}
465
466AdbControllerImpl* AdbControllerImpl::ctor(const maajs::CallbackInfo& info)
467{

Callers 15

create_win32_controllerFunction · 0.45
create_macos_controllerFunction · 0.45
mainFunction · 0.45
remove_sinkMethod · 0.45
locate_objectMethod · 0.45
remove_sinkMethod · 0.45
locate_objectMethod · 0.45
remove_sinkMethod · 0.45
remove_context_sinkMethod · 0.45
locate_objectMethod · 0.45

Tested by 1

mainFunction · 0.36