mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-02-04 22:10:25 +01:00
Introduce libinput_device_has_capability() API
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
This commit is contained in:
parent
0c43efb9bd
commit
d791a7ab09
4 changed files with 39 additions and 0 deletions
16
src/evdev.c
16
src/evdev.c
|
|
@ -693,6 +693,22 @@ evdev_device_calibrate(struct evdev_device *device, float calibration[6])
|
|||
memcpy(device->abs.calibration, calibration, sizeof device->abs.calibration);
|
||||
}
|
||||
|
||||
int
|
||||
evdev_device_has_capability(struct evdev_device *device,
|
||||
enum libinput_device_capability capability)
|
||||
{
|
||||
switch (capability) {
|
||||
case LIBINPUT_DEVICE_CAP_POINTER:
|
||||
return !!(device->seat_caps & EVDEV_DEVICE_POINTER);
|
||||
case LIBINPUT_DEVICE_CAP_KEYBOARD:
|
||||
return !!(device->seat_caps & EVDEV_DEVICE_KEYBOARD);
|
||||
case LIBINPUT_DEVICE_CAP_TOUCH:
|
||||
return !!(device->seat_caps & EVDEV_DEVICE_TOUCH);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
evdev_device_remove(struct evdev_device *device)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -152,6 +152,10 @@ evdev_device_get_output(struct evdev_device *device);
|
|||
void
|
||||
evdev_device_calibrate(struct evdev_device *device, float calibration[6]);
|
||||
|
||||
int
|
||||
evdev_device_has_capability(struct evdev_device *device,
|
||||
enum libinput_device_capability capability);
|
||||
|
||||
void
|
||||
evdev_device_remove(struct evdev_device *device);
|
||||
|
||||
|
|
|
|||
|
|
@ -961,3 +961,11 @@ libinput_device_calibrate(struct libinput_device *device,
|
|||
{
|
||||
evdev_device_calibrate((struct evdev_device *) device, calibration);
|
||||
}
|
||||
|
||||
LIBINPUT_EXPORT int
|
||||
libinput_device_has_capability(struct libinput_device *device,
|
||||
enum libinput_device_capability capability)
|
||||
{
|
||||
return evdev_device_has_capability((struct evdev_device *) device,
|
||||
capability);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -667,4 +667,15 @@ void
|
|||
libinput_device_calibrate(struct libinput_device *device,
|
||||
float calibration[6]);
|
||||
|
||||
/**
|
||||
* @ingroup device
|
||||
*
|
||||
* Check if the given device has the specified capability
|
||||
*
|
||||
* @return 1 if the given device has the capability or 0 if not
|
||||
*/
|
||||
int
|
||||
libinput_device_has_capability(struct libinput_device *device,
|
||||
enum libinput_device_capability capability);
|
||||
|
||||
#endif /* LIBINPUT_H */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue