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

Method touch

source/MaaPlayCoverControlUnit/Client/PlayToolsClient.cpp:232–260  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

230}
231
232bool PlayToolsClient::touch(TouchPhase phase, int x, int y)
233{
234 if (!open()) {
235 return false;
236 }
237
238 uint16_t nx = htons(static_cast<uint16_t>(x));
239 uint16_t ny = htons(static_cast<uint16_t>(y));
240 uint8_t payload[5] = { static_cast<uint8_t>(phase), 0, 0, 0, 0 };
241 std::memcpy(payload + 1, &nx, sizeof(nx));
242 std::memcpy(payload + 3, &ny, sizeof(ny));
243
244 constexpr char request[6] = { 0, 9, 'T', 'U', 'C', 'H' };
245 boost::system::error_code ec;
246 boost::asio::write(socket_, boost::asio::buffer(request), ec);
247 if (ec) {
248 LogError << "Cannot send touch request:" << ec.message();
249 close();
250 return false;
251 }
252 boost::asio::write(socket_, boost::asio::buffer(payload, 5), ec);
253 if (ec) {
254 LogError << "Cannot send touch payload:" << ec.message();
255 close();
256 return false;
257 }
258
259 return true;
260}
261
262bool PlayToolsClient::terminate()
263{

Callers 3

touch_downMethod · 0.80
touch_moveMethod · 0.80
touch_upMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected