| 230 | } |
| 231 | |
| 232 | bool 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 | |
| 262 | bool PlayToolsClient::terminate() |
| 263 | { |
no outgoing calls
no test coverage detected