mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-02-04 05:50:26 +01:00
evdev: add helper function to normalize delta coordinates
No functional changes. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
parent
abdd86a4c4
commit
9f8edc5fd8
1 changed files with 10 additions and 4 deletions
14
src/evdev.c
14
src/evdev.c
|
|
@ -224,6 +224,13 @@ evdev_device_transform_y(struct evdev_device *device,
|
|||
return scale_axis(device->abs.absinfo_y, y, height);
|
||||
}
|
||||
|
||||
static inline void
|
||||
normalize_delta(struct evdev_device *device, double *dx, double *dy)
|
||||
{
|
||||
*dx = *dx * (double)device->dpi / DEFAULT_MOUSE_DPI;
|
||||
*dy = *dy * (double)device->dpi / DEFAULT_MOUSE_DPI;
|
||||
}
|
||||
|
||||
static void
|
||||
evdev_flush_pending_event(struct evdev_device *device, uint64_t time)
|
||||
{
|
||||
|
|
@ -243,10 +250,9 @@ evdev_flush_pending_event(struct evdev_device *device, uint64_t time)
|
|||
case EVDEV_NONE:
|
||||
return;
|
||||
case EVDEV_RELATIVE_MOTION:
|
||||
dx_unaccel = device->rel.dx / ((double) device->dpi /
|
||||
DEFAULT_MOUSE_DPI);
|
||||
dy_unaccel = device->rel.dy / ((double) device->dpi /
|
||||
DEFAULT_MOUSE_DPI);
|
||||
dx_unaccel = device->rel.dx;
|
||||
dy_unaccel = device->rel.dy;
|
||||
normalize_delta(device, &dx_unaccel, &dy_unaccel);
|
||||
device->rel.dx = 0;
|
||||
device->rel.dy = 0;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue