Fix pressure / tilt ranges on Linux.

This commit is contained in:
bruvzg 2020-01-31 22:40:14 +02:00
parent ea3733a0ea
commit d552f93f8b
No known key found for this signature in database
GPG Key ID: FCED35F1CECE0D3A
1 changed files with 6 additions and 24 deletions

View File

@ -669,14 +669,8 @@ bool OS_X11::refresh_device_info() {
int range_max_x = 0; int range_max_x = 0;
int range_max_y = 0; int range_max_y = 0;
int pressure_resolution = 0; int pressure_resolution = 0;
int pressure_min = 0;
int pressure_max = 0;
int tilt_resolution_x = 0; int tilt_resolution_x = 0;
int tilt_resolution_y = 0; int tilt_resolution_y = 0;
int tilt_range_min_x = 0;
int tilt_range_min_y = 0;
int tilt_range_max_x = 0;
int tilt_range_max_y = 0;
for (int j = 0; j < dev->num_classes; j++) { for (int j = 0; j < dev->num_classes; j++) {
#ifdef TOUCH_ENABLED #ifdef TOUCH_ENABLED
if (dev->classes[j]->type == XITouchClass && ((XITouchClassInfo *)dev->classes[j])->mode == XIDirectTouch) { if (dev->classes[j]->type == XITouchClass && ((XITouchClassInfo *)dev->classes[j])->mode == XIDirectTouch) {
@ -697,17 +691,14 @@ bool OS_X11::refresh_device_info() {
range_max_y = class_info->max; range_max_y = class_info->max;
absolute_mode = true; absolute_mode = true;
} else if (class_info->number == VALUATOR_PRESSURE && class_info->mode == XIModeAbsolute) { } else if (class_info->number == VALUATOR_PRESSURE && class_info->mode == XIModeAbsolute) {
pressure_resolution = class_info->resolution; pressure_resolution = (class_info->max - class_info->min);
pressure_min = class_info->min; if (pressure_resolution == 0) pressure_resolution = 1;
pressure_max = class_info->max;
} else if (class_info->number == VALUATOR_TILTX && class_info->mode == XIModeAbsolute) { } else if (class_info->number == VALUATOR_TILTX && class_info->mode == XIModeAbsolute) {
tilt_resolution_x = class_info->resolution; tilt_resolution_x = (class_info->max - class_info->min);
tilt_range_min_x = class_info->min; if (tilt_resolution_x == 0) tilt_resolution_x = 1;
tilt_range_max_x = class_info->max;
} else if (class_info->number == VALUATOR_TILTY && class_info->mode == XIModeAbsolute) { } else if (class_info->number == VALUATOR_TILTY && class_info->mode == XIModeAbsolute) {
tilt_resolution_y = class_info->resolution; tilt_resolution_y = (class_info->max - class_info->min);
tilt_range_min_y = class_info->min; if (tilt_resolution_y == 0) tilt_resolution_y = 1;
tilt_range_max_y = class_info->max;
} }
} }
} }
@ -728,15 +719,6 @@ bool OS_X11::refresh_device_info() {
print_verbose("XInput: Absolute pointing device: " + String(dev->name)); print_verbose("XInput: Absolute pointing device: " + String(dev->name));
} }
if (pressure_resolution <= 0) {
pressure_resolution = (pressure_max - pressure_min);
}
if (tilt_resolution_x <= 0) {
tilt_resolution_x = (tilt_range_max_x - tilt_range_min_x);
}
if (tilt_resolution_y <= 0) {
tilt_resolution_y = (tilt_range_max_y - tilt_range_min_y);
}
xi.pressure = 0; xi.pressure = 0;
xi.pen_devices[dev->deviceid] = Vector3(pressure_resolution, tilt_resolution_x, tilt_resolution_y); xi.pen_devices[dev->deviceid] = Vector3(pressure_resolution, tilt_resolution_x, tilt_resolution_y);
} }