From 17883318b5fbbc81aea3cffd6c794230c72e18e3 Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Tue, 20 May 2025 10:53:30 -0300 Subject: [PATCH 1/3] Log the DRM_ROTATION_* found --- src/platform/linux/kmsgrab.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/platform/linux/kmsgrab.cpp b/src/platform/linux/kmsgrab.cpp index 3db74899930..bf1361873ca 100644 --- a/src/platform/linux/kmsgrab.cpp +++ b/src/platform/linux/kmsgrab.cpp @@ -695,13 +695,13 @@ namespace platf { switch (card.get_panel_orientation(plane->plane_id)) { case DRM_MODE_ROTATE_270: - BOOST_LOG(debug) << "Detected panel orientation at 90, swapping width and height."; + BOOST_LOG(warning) << "Detected panel orientation at 90 (DRM_MODE_ROTATE_270), swapping width and height."; width = viewport.height; height = viewport.width; break; case DRM_MODE_ROTATE_90: case DRM_MODE_ROTATE_180: - BOOST_LOG(warning) << "Panel orientation is unsupported, screen capture may not work correctly."; + BOOST_LOG(warning) << "Panel orientation is unsupported (DRM_MODE_ROTATE_{90|180}), screen capture may not work correctly."; break; } From d0b3a0daf566ec274033c6e00b1e9a4c1dfb1e4b Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Tue, 20 May 2025 10:53:55 -0300 Subject: [PATCH 2/3] Do not rotate the reported screen on DRM_ROTATE_270 --- src/platform/linux/kmsgrab.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/platform/linux/kmsgrab.cpp b/src/platform/linux/kmsgrab.cpp index bf1361873ca..5927c5b59aa 100644 --- a/src/platform/linux/kmsgrab.cpp +++ b/src/platform/linux/kmsgrab.cpp @@ -412,7 +412,9 @@ namespace platf { auto props = plane_props(plane_id); auto value = prop_value_by_name(props, "rotation"sv); if (value) { - return *value; + BOOST_LOG(info) << "Found panel orientation ["sv << *value << "]"; + return DRM_MODE_ROTATE_0; + //return *value; } BOOST_LOG(error) << "Failed to determine panel orientation, defaulting to landscape."; From b0aec185cd486ad25f1d02d3a2905cadc3d20c2c Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Wed, 28 May 2025 14:05:34 -0300 Subject: [PATCH 3/3] new config output_rotation:int applies to move_mouse on Linux For now, only to move_mouse. Must improve over time --- src/config.cpp | 2 ++ src/config.h | 1 + src/platform/linux/input/inputtino.cpp | 19 ++++++++++++++++++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/config.cpp b/src/config.cpp index 7147fd6cfdb..aaa3e28dd56 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -561,6 +561,7 @@ namespace config { true, // always send scancodes true, // high resolution scrolling true, // native pen/touch support + 0, // input rotation }; sunshine_t sunshine { @@ -1222,6 +1223,7 @@ namespace config { bool_f(vars, "high_resolution_scrolling", input.high_resolution_scrolling); bool_f(vars, "native_pen_touch", input.native_pen_touch); + int_f(vars, "output_rotation", input.output_rotation); bool_f(vars, "notify_pre_releases", sunshine.notify_pre_releases); diff --git a/src/config.h b/src/config.h index 066b95df182..4cf70822c5b 100644 --- a/src/config.h +++ b/src/config.h @@ -202,6 +202,7 @@ namespace config { bool high_resolution_scrolling; bool native_pen_touch; + int output_rotation; }; namespace flag { diff --git a/src/platform/linux/input/inputtino.cpp b/src/platform/linux/input/inputtino.cpp index 3102fdd9120..7a1721b445e 100644 --- a/src/platform/linux/input/inputtino.cpp +++ b/src/platform/linux/input/inputtino.cpp @@ -34,9 +34,26 @@ namespace platf { delete input; } + std::pair rotate_delta(int delta_x, int delta_y, int rotation) { + switch (rotation) { + case 0: + return {delta_x, delta_y}; + case 90: + return {delta_y, -delta_x}; + case 180: + return {-delta_x, -delta_y}; + case 270: + return {-delta_y, delta_x}; + default: + return {delta_x, delta_y}; + } + } + void move_mouse(input_t &input, int deltaX, int deltaY) { auto raw = (input_raw_t *) input.get(); - platf::mouse::move(raw, deltaX, deltaY); + + auto rotated = rotate_delta(deltaX, deltaY, config::input.output_rotation); + platf::mouse::move(raw, rotated.first, rotated.second); } void abs_mouse(input_t &input, const touch_port_t &touch_port, float x, float y) {