mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-05-09 03:38:01 +02:00
Add libinput_device_has_button function
In some cases the compositor will want to know which buttons a device has. E.g. for scrolling we want the compositor to be able to set a button to change a relative device (e.g. a trackball) into scroll mode, so that it sends scroll-axis events instead of pointer motion events. In order for the compositor to be able to present a sane UI for this, it needs to know which buttons a device has. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
5ba5c32813
commit
0ce30935d7
4 changed files with 32 additions and 0 deletions
|
|
@ -1491,6 +1491,15 @@ evdev_device_get_size(struct evdev_device *device,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
evdev_device_has_button(struct evdev_device *device, uint32_t code)
|
||||||
|
{
|
||||||
|
if (!(device->seat_caps & EVDEV_DEVICE_POINTER))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return libevdev_has_event_code(device->evdev, EV_KEY, code);
|
||||||
|
}
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
evdev_is_scrolling(const struct evdev_device *device,
|
evdev_is_scrolling(const struct evdev_device *device,
|
||||||
enum libinput_pointer_axis axis)
|
enum libinput_pointer_axis axis)
|
||||||
|
|
|
||||||
|
|
@ -239,6 +239,9 @@ evdev_device_get_size(struct evdev_device *device,
|
||||||
double *w,
|
double *w,
|
||||||
double *h);
|
double *h);
|
||||||
|
|
||||||
|
int
|
||||||
|
evdev_device_has_button(struct evdev_device *device, uint32_t code);
|
||||||
|
|
||||||
double
|
double
|
||||||
evdev_device_transform_x(struct evdev_device *device,
|
evdev_device_transform_x(struct evdev_device *device,
|
||||||
double x,
|
double x,
|
||||||
|
|
|
||||||
|
|
@ -1254,6 +1254,12 @@ libinput_device_get_size(struct libinput_device *device,
|
||||||
height);
|
height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LIBINPUT_EXPORT int
|
||||||
|
libinput_device_has_button(struct libinput_device *device, uint32_t code)
|
||||||
|
{
|
||||||
|
return evdev_device_has_button((struct evdev_device *)device, code);
|
||||||
|
}
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1440,6 +1440,20 @@ libinput_device_get_size(struct libinput_device *device,
|
||||||
double *width,
|
double *width,
|
||||||
double *height);
|
double *height);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup device
|
||||||
|
*
|
||||||
|
* Check if a @ref LIBINPUT_DEVICE_CAP_POINTER device has a button with the
|
||||||
|
* passed in code (see linux/input.h).
|
||||||
|
*
|
||||||
|
* @param device A current input device
|
||||||
|
* @param code button code to check for
|
||||||
|
*
|
||||||
|
* @return 1 if the device supports this button code, 0 if it does not, -1
|
||||||
|
* on error.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
libinput_device_has_button(struct libinput_device *device, uint32_t code);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @defgroup config Device configuration
|
* @defgroup config Device configuration
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue