Skip to content

Commit

Permalink
Merge pull request #56438 from madmiraal/fix-56428
Browse files Browse the repository at this point in the history
Fix tablet tilt values returning bad values
  • Loading branch information
akien-mga authored Jan 3, 2022
2 parents fe52458 + 75a5836 commit 1d6f8ad
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions platform/linuxbsd/display_server_x11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ bool DisplayServerX11::_refresh_device_info() {
if (class_info->number == VALUATOR_ABSX && class_info->mode == XIModeAbsolute) {
resolution_x = class_info->resolution;
abs_x_min = class_info->min;
abs_y_max = class_info->max;
abs_x_max = class_info->max;
absolute_mode = true;
} else if (class_info->number == VALUATOR_ABSY && class_info->mode == XIModeAbsolute) {
resolution_y = class_info->resolution;
Expand All @@ -239,8 +239,8 @@ bool DisplayServerX11::_refresh_device_info() {
tilt_x_min = class_info->min;
tilt_x_max = class_info->max;
} else if (class_info->number == VALUATOR_TILTY && class_info->mode == XIModeAbsolute) {
tilt_x_min = class_info->min;
tilt_x_max = class_info->max;
tilt_y_min = class_info->min;
tilt_y_max = class_info->max;
}
}
}
Expand Down Expand Up @@ -3189,8 +3189,10 @@ void DisplayServerX11::process_events() {
Map<int, Vector2>::Element *pen_tilt_x = xi.pen_tilt_x_range.find(device_id);
if (pen_tilt_x) {
Vector2 pen_tilt_x_range = pen_tilt_x->value();
if (pen_tilt_x_range != Vector2()) {
xi.tilt.x = ((*values - pen_tilt_x_range[0]) / (pen_tilt_x_range[1] - pen_tilt_x_range[0])) * 2 - 1;
if (pen_tilt_x_range[0] != 0 && *values < 0) {
xi.tilt.x = *values / -pen_tilt_x_range[0];
} else if (pen_tilt_x_range[1] != 0) {
xi.tilt.x = *values / pen_tilt_x_range[1];
}
}

Expand All @@ -3201,8 +3203,10 @@ void DisplayServerX11::process_events() {
Map<int, Vector2>::Element *pen_tilt_y = xi.pen_tilt_y_range.find(device_id);
if (pen_tilt_y) {
Vector2 pen_tilt_y_range = pen_tilt_y->value();
if (pen_tilt_y_range != Vector2()) {
xi.tilt.y = ((*values - pen_tilt_y_range[0]) / (pen_tilt_y_range[1] - pen_tilt_y_range[0])) * 2 - 1;
if (pen_tilt_y_range[0] != 0 && *values < 0) {
xi.tilt.y = *values / -pen_tilt_y_range[0];
} else if (pen_tilt_y_range[1] != 0) {
xi.tilt.y = *values / pen_tilt_y_range[1];
}
}

Expand Down

0 comments on commit 1d6f8ad

Please sign in to comment.