Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 4 additions & 32 deletions source/MaaWlRootsControlUnit/Manager/WlRootsControlUnitMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include <filesystem>
#include <system_error>
#include <utility>

#include <opencv2/imgproc.hpp>

Expand Down Expand Up @@ -138,14 +137,7 @@ bool WlRootsControlUnitMgr::touch_down(int contact, int x, int y, int pressure)
return false;
}

if (!client_->pointer(WaylandClient::EventPhase::Began, x, y, contact)) {
return false;
}

last_pos_ = { x, y };
has_clicked_ = true;

return true;
return client_->pointer(WaylandClient::EventPhase::Began, x, y, contact);
}

bool WlRootsControlUnitMgr::touch_move(int contact, int x, int y, int pressure)
Expand All @@ -157,14 +149,7 @@ bool WlRootsControlUnitMgr::touch_move(int contact, int x, int y, int pressure)
return false;
}

if (!client_->pointer(WaylandClient::EventPhase::Moved, x, y, contact)) {
return false;
}

last_pos_ = { x, y };
has_clicked_ = true;

return true;
return client_->pointer(WaylandClient::EventPhase::Moved, x, y, contact);
}

bool WlRootsControlUnitMgr::touch_up(int contact)
Expand All @@ -174,21 +159,8 @@ bool WlRootsControlUnitMgr::touch_up(int contact)
return false;
}

std::pair<int, int> up = { 0, 0 };
if (has_clicked_) {
up = last_pos_;
}
else {
auto [width, height] = client_->screen_size();
up = { width / 2, height / 2 };
}

if (!client_->pointer(WaylandClient::EventPhase::Ended, up.first, up.second, contact)) {
return false;
}

has_clicked_ = false;
return true;
// Ended phase only sends button release; WaylandClient ignores x/y. (0,0) is a placeholder.
return client_->pointer(WaylandClient::EventPhase::Ended, 0, 0, contact);
}

bool WlRootsControlUnitMgr::click_key(int key)
Expand Down
3 changes: 0 additions & 3 deletions source/MaaWlRootsControlUnit/Manager/WlRootsControlUnitMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include <filesystem>
#include <memory>
#include <string>
#include <utility>

#include "MaaControlUnit/ControlUnitAPI.h"
#include "MaaFramework/MaaDef.h"
Expand Down Expand Up @@ -55,8 +54,6 @@ class WlRootsControlUnitMgr : public WlRootsControlUnitAPI
private:
std::unique_ptr<WaylandClient> client_;
std::filesystem::path wlr_socket_path_;
std::pair<int, int> last_pos_ = { 0, 0 };
bool has_clicked_ = false;
};

MAA_CTRL_UNIT_NS_END
Loading