[PATCH libinput 05/11] evdev: apply calibration to multitouch values as well
Hans de Goede
hdegoede at redhat.com
Fri Aug 29 05:59:28 PDT 2014
Hi,
On 08/29/2014 01:50 AM, Peter Hutterer wrote:
> On Thu, Aug 28, 2014 at 03:02:33PM +0200, Hans de Goede wrote:
>> Hi,
>>
>> On 08/27/2014 06:31 AM, Peter Hutterer wrote:
>>> We apply calibration to single-touch and absolute devices, but we might as
>>> well do so for multitouch events.
>>>
>>> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
>>> ---
>>> src/evdev.c | 31 +++++++++++++++++++------------
>>> 1 file changed, 19 insertions(+), 12 deletions(-)
>>>
>>> diff --git a/src/evdev.c b/src/evdev.c
>>> index 9c53e32..a029887 100644
>>> --- a/src/evdev.c
>>> +++ b/src/evdev.c
>>> @@ -150,19 +150,20 @@ evdev_device_led_update(struct evdev_device *device, enum libinput_led leds)
>>> static void
>>> transform_absolute(struct evdev_device *device, int32_t *x, int32_t *y)
>>> {
>>> - if (!device->abs.apply_calibration) {
>>> - *x = device->abs.x;
>>> - *y = device->abs.y;
>>> + int32_t tx, ty;
>>> +
>>> + if (!device->abs.apply_calibration)
>>> return;
>>> - } else {
>>> - *x = device->abs.x * device->abs.calibration[0] +
>>> - device->abs.y * device->abs.calibration[1] +
>>> - device->abs.calibration[2];
>>>
>>> - *y = device->abs.x * device->abs.calibration[3] +
>>> - device->abs.y * device->abs.calibration[4] +
>>> - device->abs.calibration[5];
>>> - }
>>> + tx = *x * device->abs.calibration[0] +
>>> + *y * device->abs.calibration[1] +
>>> + device->abs.calibration[2];
>>> +
>>> + ty = *x * device->abs.calibration[3] +
>>> + *y * device->abs.calibration[4] +
>>> + device->abs.calibration[5];
>>> + *x = tx;
>>> + *y = ty;
>>
>> Why not simple write:
>>
>> *x = (long calculation);
>> *y = (long calculation);
>>
>> And get rid of tx and ty?
>
> it's easy to overlook but x is used in the calculation of ty, so we can't
> change it yet.
Ah missed that, in that case this is:
Reviewed-by: Hans de Goede <hdegoede at redhat.com>
Regards,
Hans
>
> Cheers,
> Peter
>
>>
>>> }
>>>
>>> static inline double
>>> @@ -194,7 +195,7 @@ evdev_flush_pending_event(struct evdev_device *device, uint64_t time)
>>> struct libinput *libinput = device->base.seat->libinput;
>>> struct motion_params motion;
>>> int32_t cx, cy;
>>> - double x, y;
>>> + int32_t x, y;
>>> int slot;
>>> int seat_slot;
>>> struct libinput_device *base = &device->base;
>>> @@ -239,6 +240,7 @@ evdev_flush_pending_event(struct evdev_device *device, uint64_t time)
>>> seat->slot_map |= 1 << seat_slot;
>>> x = device->mt.slots[slot].x;
>>> y = device->mt.slots[slot].y;
>>> + transform_absolute(device, &x, &y);
>>>
>>> touch_notify_touch_down(base, time, slot, seat_slot, x, y);
>>> break;
>>> @@ -253,6 +255,7 @@ evdev_flush_pending_event(struct evdev_device *device, uint64_t time)
>>> if (seat_slot == -1)
>>> break;
>>>
>>> + transform_absolute(device, &x, &y);
>>> touch_notify_touch_motion(base, time, slot, seat_slot, x, y);
>>> break;
>>> case EVDEV_ABSOLUTE_MT_UP:
>>> @@ -288,11 +291,15 @@ evdev_flush_pending_event(struct evdev_device *device, uint64_t time)
>>>
>>> seat->slot_map |= 1 << seat_slot;
>>>
>>> + cx = device->abs.x;
>>> + cy = device->abs.y;
>>> transform_absolute(device, &cx, &cy);
>>>
>>> touch_notify_touch_down(base, time, -1, seat_slot, cx, cy);
>>> break;
>>> case EVDEV_ABSOLUTE_MOTION:
>>> + cx = device->abs.x;
>>> + cy = device->abs.y;
>>> transform_absolute(device, &cx, &cy);
>>> x = cx;
>>> y = cy;
>>>
> _______________________________________________
> 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