Hermes 0.7.0
Linux game streaming host
Loading...
Searching...
No Matches
virtualhid_mouse.cpp
Go to the documentation of this file.
1
5#include "virtualhid_mouse.h"
6
7#include "src/logging.h"
8
9namespace platf::mouse {
10 void move(input_raw_t *raw, int delta_x, int delta_y) {
11 if (raw && raw->mouse) {
12 virtualhid::log_failure("relative mouse move", raw->mouse->move_relative(delta_x, delta_y));
13 }
14 }
15
16 void move_abs(input_raw_t *raw, const touch_port_t &touch_port, float x, float y) {
17 if (!raw || !raw->mouse) {
18 return;
19 }
20
21 virtualhid::log_failure(
22 "absolute mouse move",
23 raw->mouse->move_absolute(
24 static_cast<float>(touch_port.offset_x) + x,
25 static_cast<float>(touch_port.offset_y) + y,
26 touch_port.width,
27 touch_port.height
28 )
29 );
30 }
31
32 void button(input_raw_t *raw, int button, bool release) {
33 if (!raw || !raw->mouse) {
34 return;
35 }
36
37 lvh::MouseButton translated;
38 switch (button) {
39 case BUTTON_LEFT:
40 translated = lvh::MouseButton::left;
41 break;
42 case BUTTON_MIDDLE:
43 translated = lvh::MouseButton::middle;
44 break;
45 case BUTTON_RIGHT:
46 translated = lvh::MouseButton::right;
47 break;
48 case BUTTON_X1:
49 translated = lvh::MouseButton::side;
50 break;
51 case BUTTON_X2:
52 translated = lvh::MouseButton::extra;
53 break;
54 default:
55 BOOST_LOG(warning) << "Unknown mouse button: " << button;
56 return;
57 }
58
59 virtualhid::log_failure("mouse button", raw->mouse->button(translated, !release));
60 }
61
62 void scroll(input_raw_t *raw, int high_resolution_distance) {
63 if (raw && raw->mouse) {
64 virtualhid::log_failure("vertical mouse scroll", raw->mouse->vertical_scroll(high_resolution_distance));
65 }
66 }
67
68 void hscroll(input_raw_t *raw, int high_resolution_distance) {
69 if (raw && raw->mouse) {
70 virtualhid::log_failure("horizontal mouse scroll", raw->mouse->horizontal_scroll(high_resolution_distance));
71 }
72 }
73
74 util::point_t get_location(input_raw_t * /*raw*/) {
75 // Neither uinput nor the former Linux backend can query the
76 // compositor's global cursor position.
77 return {0, 0};
78 }
79} // namespace platf::mouse
Declarations for logging related functions.
Mouse translation for the Linux libvirtualhid backend.