[PATCH libinput] Fix normalization functions

Hans de Goede hdegoede at redhat.com
Thu Oct 9 01:28:54 PDT 2014


Hi,

On 10/09/2014 12:56 AM, Bill Spitzak wrote:
> That certainly looks correct, but this code will return a value less than 1.0 when absinfo->value == absinfo->maximum. Is this correct? If it is supposed to be 1.0 then I would remove the +1 in the line that computes range.

Right, we need to drop the +1, Peter ?

Regards,

Hans



> 
> On 10/08/2014 02:53 PM, Jason Gerecke wrote:
>> 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 at gmail.com>
>> ---
>> This patch should be applied to the 'tablet-support' branch, obviously.
>> ...Re-sending since I messed up the mailinglist address.
>>
>>   src/evdev-tablet.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c
>> index a63b734..ff5f737 100644
>> --- a/src/evdev-tablet.c
>> +++ b/src/evdev-tablet.c
>> @@ -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;
>>
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list