mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-05-08 17:08:07 +02:00
Add a function to get the size of a device
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
parent
21cf84a580
commit
41f9176c0a
5 changed files with 60 additions and 1 deletions
19
src/evdev.c
19
src/evdev.c
|
|
@ -871,6 +871,25 @@ evdev_device_has_capability(struct evdev_device *device,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
evdev_device_get_size(struct evdev_device *device,
|
||||||
|
double *width,
|
||||||
|
double *height)
|
||||||
|
{
|
||||||
|
const struct input_absinfo *x, *y;
|
||||||
|
|
||||||
|
x = libevdev_get_abs_info(device->evdev, ABS_X);
|
||||||
|
y = libevdev_get_abs_info(device->evdev, ABS_Y);
|
||||||
|
|
||||||
|
if (!x || !y || !x->resolution || !y->resolution)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
*width = evdev_convert_to_mm(x, x->maximum);
|
||||||
|
*height = evdev_convert_to_mm(y, y->maximum);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
evdev_device_remove(struct evdev_device *device)
|
evdev_device_remove(struct evdev_device *device)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -148,6 +148,11 @@ int
|
||||||
evdev_device_has_capability(struct evdev_device *device,
|
evdev_device_has_capability(struct evdev_device *device,
|
||||||
enum libinput_device_capability capability);
|
enum libinput_device_capability capability);
|
||||||
|
|
||||||
|
int
|
||||||
|
evdev_device_get_size(struct evdev_device *device,
|
||||||
|
double *w,
|
||||||
|
double *h);
|
||||||
|
|
||||||
double
|
double
|
||||||
evdev_device_transform_x(struct evdev_device *device,
|
evdev_device_transform_x(struct evdev_device *device,
|
||||||
double x,
|
double x,
|
||||||
|
|
|
||||||
|
|
@ -1185,6 +1185,16 @@ libinput_device_has_capability(struct libinput_device *device,
|
||||||
capability);
|
capability);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LIBINPUT_EXPORT int
|
||||||
|
libinput_device_get_size(struct libinput_device *device,
|
||||||
|
double *width,
|
||||||
|
double *height)
|
||||||
|
{
|
||||||
|
return evdev_device_get_size((struct evdev_device *)device,
|
||||||
|
width,
|
||||||
|
height);
|
||||||
|
}
|
||||||
|
|
||||||
LIBINPUT_EXPORT struct libinput_event *
|
LIBINPUT_EXPORT struct libinput_event *
|
||||||
libinput_event_device_notify_get_base_event(struct libinput_event_device_notify *event)
|
libinput_event_device_notify_get_base_event(struct libinput_event_device_notify *event)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1303,6 +1303,25 @@ int
|
||||||
libinput_device_has_capability(struct libinput_device *device,
|
libinput_device_has_capability(struct libinput_device *device,
|
||||||
enum libinput_device_capability capability);
|
enum libinput_device_capability capability);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup device
|
||||||
|
*
|
||||||
|
* Get the physical size of a device in mm, where meaningful. This function
|
||||||
|
* only succeeds on devices with the required data, i.e. tablets, touchpads
|
||||||
|
* and touchscreens.
|
||||||
|
*
|
||||||
|
* If this function returns nonzero, width and height are unmodified.
|
||||||
|
*
|
||||||
|
* @param device The device
|
||||||
|
* @param width Set to the width of the device
|
||||||
|
* @param height Set to the height of the device
|
||||||
|
* @return 0 on success, or nonzero otherwise
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
libinput_device_get_size(struct libinput_device *device,
|
||||||
|
double *width,
|
||||||
|
double *height);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -231,10 +231,16 @@ print_device_notify(struct libinput_event *ev)
|
||||||
{
|
{
|
||||||
struct libinput_device *dev = libinput_event_get_device(ev);
|
struct libinput_device *dev = libinput_event_get_device(ev);
|
||||||
struct libinput_seat *seat = libinput_device_get_seat(dev);
|
struct libinput_seat *seat = libinput_device_get_seat(dev);
|
||||||
|
double w, h;
|
||||||
|
|
||||||
printf("%s %s\n",
|
printf("%s %s",
|
||||||
libinput_seat_get_physical_name(seat),
|
libinput_seat_get_physical_name(seat),
|
||||||
libinput_seat_get_logical_name(seat));
|
libinput_seat_get_logical_name(seat));
|
||||||
|
|
||||||
|
if (libinput_device_get_size(dev, &w, &h) == 0)
|
||||||
|
printf("\tsize %.2f/%.2fmm", w, h);
|
||||||
|
|
||||||
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue