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

Method handle_multi_swipe

source/MaaFramework/Controller/ControllerAgent.cpp:553–672  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

551}
552
553bool ControllerAgent::handle_multi_swipe(const MultiSwipeParam& param)
554{
555 if (!control_unit_) {
556 LogError << "control_unit_ is nullptr";
557 return false;
558 }
559
560 if (!(control_unit_->get_features() & MaaControllerFeature_UseMouseDownAndUpInsteadOfClick)) {
561 LogError << "touch is not available";
562 return false;
563 }
564
565 constexpr double kInterval = 10; // ms
566 const std::chrono::milliseconds delay(static_cast<int>(kInterval));
567
568 struct SegmentOperating
569 {
570 cv::Point begin { };
571 cv::Point end { };
572 double total_step = 0;
573 double x_step_len = 0;
574 double y_step_len = 0;
575 size_t step_index = 0;
576 uint duration = 0;
577 uint end_hold = 0;
578 };
579
580 struct CotactOperating
581 {
582 std::vector<SegmentOperating> seg;
583 size_t seg_index = 0;
584 };
585
586 // contact index < end index < op >>
587 std::vector<CotactOperating> operating(param.swipes.size());
588
589 for (size_t s_i = 0; s_i < param.swipes.size(); ++s_i) {
590 const SwipeParam& s = param.swipes.at(s_i);
591
592 cv::Point begin = preproc_touch_point(s.begin);
593 for (size_t e_i = 0; e_i < s.end.size(); ++e_i) {
594 const cv::Point& end = preproc_touch_point(s.end.at(e_i));
595 const uint duration = s.duration.empty() ? 200 : (e_i < s.duration.size()) ? s.duration.at(e_i) : s.duration.back();
596 const uint end_hold = s.end_hold.empty() ? 0 : (e_i < s.end_hold.size()) ? s.end_hold.at(e_i) : s.end_hold.back();
597
598 SegmentOperating o;
599 o.begin = begin;
600 o.end = end;
601 o.total_step = duration / kInterval;
602 o.x_step_len = (end.x - begin.x) / o.total_step;
603 o.y_step_len = (end.y - begin.y) / o.total_step;
604 o.step_index = 0;
605 o.duration = duration;
606 o.end_hold = end_hold;
607
608 operating.at(s_i).seg.emplace_back(std::move(o));
609 operating.at(s_i).seg_index = 0;
610

Callers

nothing calls this directly

Calls 8

moveFunction · 0.85
atMethod · 0.80
get_featuresMethod · 0.65
touch_downMethod · 0.65
touch_moveMethod · 0.65
touch_upMethod · 0.65
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected