aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input/libinput.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/input/libinput.c')
-rw-r--r--sway/input/libinput.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/sway/input/libinput.c b/sway/input/libinput.c
index 54520f9e..3c0f359d 100644
--- a/sway/input/libinput.c
+++ b/sway/input/libinput.c
@@ -1,5 +1,6 @@
1#include <float.h> 1#include <float.h>
2#include <libinput.h> 2#include <libinput.h>
3#include <libudev.h>
3#include <limits.h> 4#include <limits.h>
4#include <wlr/backend/libinput.h> 5#include <wlr/backend/libinput.h>
5#include "log.h" 6#include "log.h"
@@ -312,3 +313,32 @@ void sway_input_reset_libinput_device(struct sway_input_device *input_device) {
312 ipc_event_input("libinput_config", input_device); 313 ipc_event_input("libinput_config", input_device);
313 } 314 }
314} 315}
316
317bool sway_libinput_device_is_builtin(struct sway_input_device *sway_device) {
318 if (!wlr_input_device_is_libinput(sway_device->wlr_device)) {
319 return false;
320 }
321
322 struct libinput_device *device =
323 wlr_libinput_get_device_handle(sway_device->wlr_device);
324 struct udev_device *udev_device =
325 libinput_device_get_udev_device(device);
326 if (!udev_device) {
327 return false;
328 }
329
330 const char *id_path = udev_device_get_property_value(udev_device, "ID_PATH");
331 if (!id_path) {
332 return false;
333 }
334
335 const char prefix_platform[] = "platform-";
336 if (strncmp(id_path, prefix_platform, strlen(prefix_platform)) != 0) {
337 return false;
338 }
339
340 const char prefix_pci[] = "pci-";
341 const char infix_platform[] = "-platform-";
342 return (strncmp(id_path, prefix_pci, strlen(prefix_pci)) == 0) &&
343 strstr(id_path, infix_platform);
344}