diff options
author | Simon Ser <[email protected]> | 2021-02-08 19:24:20 +0100 |
---|---|---|
committer | Tudor Brindus <[email protected]> | 2021-02-25 09:38:00 -0500 |
commit | eea9c6331f01729d5feb8f86a4c0bbb53012d292 (patch) | |
tree | 087cd3b7341c8ddddca3425613858a6a4281ee49 /sway/input/libinput.c | |
parent | 641b8719ad7238cbc423c5575a58ac509bfcad02 (diff) |
Automatically map built-in touchscreens/tablets to built-in panels
Detect whether an output is built-in via its type. Detect whether
a touchscreen or tablet tool is built-in via its ID_PATH property.
Diffstat (limited to 'sway/input/libinput.c')
-rw-r--r-- | sway/input/libinput.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/sway/input/libinput.c b/sway/input/libinput.c index 54520f9e..060a584a 100644 --- a/sway/input/libinput.c +++ b/sway/input/libinput.c @@ -1,5 +1,6 @@ #include <float.h> #include <libinput.h> +#include <libudev.h> #include <limits.h> #include <wlr/backend/libinput.h> #include "log.h" @@ -312,3 +313,25 @@ void sway_input_reset_libinput_device(struct sway_input_device *input_device) { ipc_event_input("libinput_config", input_device); } } + +bool sway_libinput_device_is_builtin(struct sway_input_device *sway_device) { + if (!wlr_input_device_is_libinput(sway_device->wlr_device)) { + return false; + } + + struct libinput_device *device = + wlr_libinput_get_device_handle(sway_device->wlr_device); + struct udev_device *udev_device = + libinput_device_get_udev_device(device); + if (!udev_device) { + return false; + } + + const char *id_path = udev_device_get_property_value(udev_device, "ID_PATH"); + if (!id_path) { + return false; + } + + const char prefix[] = "platform-"; + return strncmp(id_path, prefix, strlen(prefix)) == 0; +} |