chiark / gitweb /
Remove src/libsystemd-network
[elogind.git] / src / libsystemd-terminal / idev.h
index 0ae044cfd57d8c654976835054b24eea4a8a8a15..0e846179e6093c061cb9cde2b7ca0704cbdf4901 100644 (file)
 
 #pragma once
 
-#include <inttypes.h>
 #include <libudev.h>
 #include <linux/input.h>
 #include <stdbool.h>
-#include <stdlib.h>
 #include <systemd/sd-bus.h>
 #include <systemd/sd-event.h>
 #include <xkbcommon/xkbcommon.h>
-#include "util.h"
 
 typedef struct idev_data                idev_data;
 typedef struct idev_data_evdev          idev_data_evdev;
@@ -110,6 +107,28 @@ struct idev_data_keyboard {
         uint32_t *codepoints;
 };
 
+static inline bool idev_kbdmatch(idev_data_keyboard *kdata,
+                                 uint32_t mods, uint32_t n_syms,
+                                 const uint32_t *syms) {
+        const uint32_t significant = IDEV_KBDMOD_SHIFT |
+                                     IDEV_KBDMOD_CTRL |
+                                     IDEV_KBDMOD_ALT |
+                                     IDEV_KBDMOD_LINUX;
+        uint32_t real;
+
+        if (n_syms != kdata->n_syms)
+                return false;
+
+        real = kdata->mods & ~kdata->consumed_mods & significant;
+        if (real != mods)
+                return false;
+
+        return !memcmp(syms, kdata->keysyms, n_syms * sizeof(*syms));
+}
+
+#define IDEV_KBDMATCH(_kdata, _mods, _sym) \
+        idev_kbdmatch((_kdata), (_mods), 1, (const uint32_t[]){ (_sym) })
+
 /*
  * Data Packets
  */