Skip to content

fix(linux): steamdeck pointer orientation #3893

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ namespace config {

bool high_resolution_scrolling;
bool native_pen_touch;
int output_rotation;
};

namespace flag {
Expand Down
19 changes: 18 additions & 1 deletion src/platform/linux/input/inputtino.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,26 @@ namespace platf {
delete input;
}

std::pair<int, int> 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) {
Expand Down
8 changes: 5 additions & 3 deletions src/platform/linux/kmsgrab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.";
Expand Down Expand Up @@ -695,13 +697,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;
}

Expand Down
Loading