mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-24 08:50:20 +01:00
Move evdev_convert_to_mm to a more generic helper
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1013>
This commit is contained in:
parent
df242c108d
commit
cfbdca5953
4 changed files with 20 additions and 19 deletions
|
|
@ -2727,8 +2727,8 @@ evdev_device_get_size(const struct evdev_device *device,
|
|||
!x->resolution || !y->resolution)
|
||||
return -1;
|
||||
|
||||
*width = evdev_convert_to_mm(x, x->maximum);
|
||||
*height = evdev_convert_to_mm(y, y->maximum);
|
||||
*width = absinfo_convert_to_mm(x, x->maximum);
|
||||
*height = absinfo_convert_to_mm(y, y->maximum);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
12
src/evdev.h
12
src/evdev.h
|
|
@ -37,6 +37,7 @@
|
|||
#include "timer.h"
|
||||
#include "filter.h"
|
||||
#include "quirks.h"
|
||||
#include "util-input-event.h"
|
||||
|
||||
/* The fake resolution value for abs devices without resolution */
|
||||
#define EVDEV_FAKE_RESOLUTION 1
|
||||
|
|
@ -649,20 +650,13 @@ evdev_middlebutton_is_available(struct libinput_device *device);
|
|||
enum libinput_config_middle_emulation_state
|
||||
evdev_middlebutton_get_default(struct libinput_device *device);
|
||||
|
||||
static inline double
|
||||
evdev_convert_to_mm(const struct input_absinfo *absinfo, double v)
|
||||
{
|
||||
double value = v - absinfo->minimum;
|
||||
return value/absinfo->resolution;
|
||||
}
|
||||
|
||||
static inline struct phys_coords
|
||||
evdev_convert_xy_to_mm(const struct evdev_device *device, int x, int y)
|
||||
{
|
||||
struct phys_coords mm;
|
||||
|
||||
mm.x = evdev_convert_to_mm(device->abs.absinfo_x, x);
|
||||
mm.y = evdev_convert_to_mm(device->abs.absinfo_y, y);
|
||||
mm.x = absinfo_convert_to_mm(device->abs.absinfo_x, x);
|
||||
mm.y = absinfo_convert_to_mm(device->abs.absinfo_y, y);
|
||||
|
||||
return mm;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -626,7 +626,7 @@ libinput_event_pointer_get_absolute_x(struct libinput_event_pointer *event)
|
|||
0,
|
||||
LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE);
|
||||
|
||||
return evdev_convert_to_mm(device->abs.absinfo_x, event->absolute.x);
|
||||
return absinfo_convert_to_mm(device->abs.absinfo_x, event->absolute.x);
|
||||
}
|
||||
|
||||
LIBINPUT_EXPORT double
|
||||
|
|
@ -639,7 +639,7 @@ libinput_event_pointer_get_absolute_y(struct libinput_event_pointer *event)
|
|||
0,
|
||||
LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE);
|
||||
|
||||
return evdev_convert_to_mm(device->abs.absinfo_y, event->absolute.y);
|
||||
return absinfo_convert_to_mm(device->abs.absinfo_y, event->absolute.y);
|
||||
}
|
||||
|
||||
LIBINPUT_EXPORT double
|
||||
|
|
@ -918,7 +918,7 @@ libinput_event_touch_get_x(struct libinput_event_touch *event)
|
|||
LIBINPUT_EVENT_TOUCH_DOWN,
|
||||
LIBINPUT_EVENT_TOUCH_MOTION);
|
||||
|
||||
return evdev_convert_to_mm(device->abs.absinfo_x, event->point.x);
|
||||
return absinfo_convert_to_mm(device->abs.absinfo_x, event->point.x);
|
||||
}
|
||||
|
||||
LIBINPUT_EXPORT double
|
||||
|
|
@ -962,7 +962,7 @@ libinput_event_touch_get_y(struct libinput_event_touch *event)
|
|||
LIBINPUT_EVENT_TOUCH_DOWN,
|
||||
LIBINPUT_EVENT_TOUCH_MOTION);
|
||||
|
||||
return evdev_convert_to_mm(device->abs.absinfo_y, event->point.y);
|
||||
return absinfo_convert_to_mm(device->abs.absinfo_y, event->point.y);
|
||||
}
|
||||
|
||||
LIBINPUT_EXPORT uint32_t
|
||||
|
|
@ -1313,8 +1313,8 @@ libinput_event_tablet_tool_get_x(struct libinput_event_tablet_tool *event)
|
|||
LIBINPUT_EVENT_TABLET_TOOL_BUTTON,
|
||||
LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
|
||||
|
||||
return evdev_convert_to_mm(device->abs.absinfo_x,
|
||||
event->axes.point.x);
|
||||
return absinfo_convert_to_mm(device->abs.absinfo_x,
|
||||
event->axes.point.x);
|
||||
}
|
||||
|
||||
LIBINPUT_EXPORT double
|
||||
|
|
@ -1330,8 +1330,8 @@ libinput_event_tablet_tool_get_y(struct libinput_event_tablet_tool *event)
|
|||
LIBINPUT_EVENT_TABLET_TOOL_BUTTON,
|
||||
LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
|
||||
|
||||
return evdev_convert_to_mm(device->abs.absinfo_y,
|
||||
event->axes.point.y);
|
||||
return absinfo_convert_to_mm(device->abs.absinfo_y,
|
||||
event->axes.point.y);
|
||||
}
|
||||
|
||||
LIBINPUT_EXPORT double
|
||||
|
|
|
|||
|
|
@ -90,3 +90,10 @@ absinfo_scale_axis(const struct input_absinfo *absinfo, double val, double to_ra
|
|||
{
|
||||
return (val - absinfo->minimum) * to_range / absinfo_range(absinfo);
|
||||
}
|
||||
|
||||
static inline double
|
||||
absinfo_convert_to_mm(const struct input_absinfo *absinfo, double v)
|
||||
{
|
||||
double value = v - absinfo->minimum;
|
||||
return value/absinfo->resolution;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue