From 32c5fde0a89bb6f377dc0652b81cccb5c5099bec Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 8 Jul 2025 17:32:58 +1000 Subject: [PATCH] Make the model quirk check available on the libinput device Moves things one level higher to be able to use it from a plugin. Part-of: --- src/evdev.h | 10 +--------- src/libinput-private.h | 4 ++++ src/libinput.c | 14 ++++++++++++++ 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/evdev.h b/src/evdev.h index 9be84df3..766df563 100644 --- a/src/evdev.h +++ b/src/evdev.h @@ -392,15 +392,7 @@ evdev_libinput_context(const struct evdev_device *device) static inline bool evdev_device_has_model_quirk(struct evdev_device *device, enum quirk model_quirk) { - assert(quirk_get_name(model_quirk) != NULL); - - _unref_(quirks) *q = libinput_device_get_quirks(&device->base); - bool result = false; - - if (q) - quirks_get_bool(q, model_quirk, &result); - - return result; + return libinput_device_has_model_quirk(&device->base, model_quirk); } void diff --git a/src/libinput-private.h b/src/libinput-private.h index 1fd918b3..4d6511dc 100644 --- a/src/libinput-private.h +++ b/src/libinput-private.h @@ -44,6 +44,7 @@ #include "libinput-version.h" #include "libinput.h" #include "linux/input.h" +#include "quirks.h" struct libinput_source; @@ -720,6 +721,9 @@ libinput_seat_init(struct libinput_seat *seat, void libinput_device_init(struct libinput_device *device, struct libinput_seat *seat); +bool +libinput_device_has_model_quirk(struct libinput_device *device, enum quirk model_quirk); + struct libinput_device_group * libinput_device_group_create(struct libinput *libinput, const char *identifier); diff --git a/src/libinput.c b/src/libinput.c index eef19a4f..d2412f21 100644 --- a/src/libinput.c +++ b/src/libinput.c @@ -2230,6 +2230,20 @@ libinput_device_remove_event_listener(struct libinput_event_listener *listener) list_remove(&listener->link); } +bool +libinput_device_has_model_quirk(struct libinput_device *device, enum quirk model_quirk) +{ + assert(quirk_get_name(model_quirk) != NULL); + + _unref_(quirks) *q = libinput_device_get_quirks(device); + bool result = false; + + if (q) + quirks_get_bool(q, model_quirk, &result); + + return result; +} + static uint32_t update_seat_key_count(struct libinput_seat *seat, keycode_t keycode,