mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-02-04 19:50:25 +01:00
Fix normalization functions
We need to *subtract*, not *add* the minimum to determine the range-effective value. For example: if (min, current, max) is (100, 100, 1000) then the normalized value would be 0.0, not 0.2. Signed-off-by: Jason Gerecke <killertofu@gmail.com> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
cd5c9dce3b
commit
297cbe4808
1 changed files with 2 additions and 2 deletions
|
|
@ -106,7 +106,7 @@ tablet_update_tool(struct tablet_dispatch *tablet,
|
|||
static inline double
|
||||
normalize_pressure_or_dist(const struct input_absinfo * absinfo) {
|
||||
double range = absinfo->maximum - absinfo->minimum + 1;
|
||||
double value = (absinfo->value + absinfo->minimum) / range;
|
||||
double value = (absinfo->value - absinfo->minimum) / range;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
|
@ -114,7 +114,7 @@ normalize_pressure_or_dist(const struct input_absinfo * absinfo) {
|
|||
static inline double
|
||||
normalize_tilt(const struct input_absinfo * absinfo) {
|
||||
double range = absinfo->maximum - absinfo->minimum + 1;
|
||||
double value = (absinfo->value + absinfo->minimum) / range;
|
||||
double value = (absinfo->value - absinfo->minimum) / range;
|
||||
|
||||
/* Map to the (-1, 1) range */
|
||||
return (value * 2) - 1;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue