Fix incorrect scaling for absolute mouse coordinates
This commit is contained in:
@@ -106,8 +106,6 @@ inline std::string_view from_pix_fmt(pix_fmt_e pix_fmt) {
|
||||
// Dimensions for touchscreen input
|
||||
struct touch_port_t {
|
||||
int offset_x, offset_y;
|
||||
int env_width, env_height;
|
||||
|
||||
int width, height;
|
||||
};
|
||||
|
||||
|
||||
@@ -145,8 +145,8 @@ public:
|
||||
void abs_mouse(input_t &input, const touch_port_t &touch_port, float x, float y) {
|
||||
auto touchscreen = ((input_raw_t *)input.get())->touch_input.get();
|
||||
|
||||
auto scaled_x = (int)std::lround((x + touch_port.offset_x) * ((float)target_touch_port.env_width / (float)touch_port.env_width));
|
||||
auto scaled_y = (int)std::lround((y + touch_port.offset_y) * ((float)target_touch_port.env_height / (float)touch_port.env_height));
|
||||
auto scaled_x = (int)std::lround((x + touch_port.offset_x) * ((float)target_touch_port.width / (float)touch_port.width));
|
||||
auto scaled_y = (int)std::lround((y + touch_port.offset_y) * ((float)target_touch_port.height / (float)touch_port.height));
|
||||
|
||||
libevdev_uinput_write_event(touchscreen, EV_ABS, ABS_X, scaled_x);
|
||||
libevdev_uinput_write_event(touchscreen, EV_ABS, ABS_Y, scaled_y);
|
||||
@@ -470,7 +470,7 @@ evdev_t touchscreen() {
|
||||
input_absinfo absx {
|
||||
0,
|
||||
0,
|
||||
target_touch_port.env_width,
|
||||
target_touch_port.width,
|
||||
1,
|
||||
0,
|
||||
28
|
||||
@@ -479,7 +479,7 @@ evdev_t touchscreen() {
|
||||
input_absinfo absy {
|
||||
0,
|
||||
0,
|
||||
target_touch_port.env_height,
|
||||
target_touch_port.height,
|
||||
1,
|
||||
0,
|
||||
28
|
||||
|
||||
@@ -123,8 +123,8 @@ void abs_mouse(input_t &input, const touch_port_t &touch_port, float x, float y)
|
||||
// MOUSEEVENTF_VIRTUALDESK maps to the entirety of the desktop rather than the primary desktop
|
||||
MOUSEEVENTF_VIRTUALDESK;
|
||||
|
||||
auto scaled_x = std::lround((x + touch_port.offset_x) * ((float)target_touch_port.env_width / (float)touch_port.env_width));
|
||||
auto scaled_y = std::lround((y + touch_port.offset_y) * ((float)target_touch_port.env_height / (float)touch_port.env_height));
|
||||
auto scaled_x = std::lround((x + touch_port.offset_x) * ((float)target_touch_port.width / (float)touch_port.width));
|
||||
auto scaled_y = std::lround((y + touch_port.offset_y) * ((float)target_touch_port.height / (float)touch_port.height));
|
||||
|
||||
mi.dx = scaled_x;
|
||||
mi.dy = scaled_y;
|
||||
|
||||
Reference in New Issue
Block a user