summaryrefslogtreecommitdiff
path: root/src/devices/IKeyboard.hpp
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2024-05-03 22:34:10 +0100
committerVaxry <vaxry@vaxry.net>2024-05-03 22:40:27 +0100
commit1237732b97fcf21a19aed16f2ef966118a3ca2aa (patch)
tree15a3a29377af7f0ce3dd428229587e476ce92db3 /src/devices/IKeyboard.hpp
parent1d2acbe19355c8640d54a4b6cba225c6f4370c85 (diff)
input: Introduce basic hyprland HID classes
Implements an intermediary HID class for mice, keyboards and touch devices, removing the old structs from WLClasses.hpp Yes, virtual ones are duplicated a bit, but will likely be de-duped once wlr_input_device is not used anymore.
Diffstat (limited to 'src/devices/IKeyboard.hpp')
-rw-r--r--src/devices/IKeyboard.hpp61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/devices/IKeyboard.hpp b/src/devices/IKeyboard.hpp
new file mode 100644
index 00000000..35ccd8cb
--- /dev/null
+++ b/src/devices/IKeyboard.hpp
@@ -0,0 +1,61 @@
+#pragma once
+
+#include "IHID.hpp"
+#include "../helpers/WLListener.hpp"
+#include "../macros.hpp"
+#include "../helpers/Vector2D.hpp"
+
+#include <xkbcommon/xkbcommon.h>
+
+struct wlr_keyboard;
+
+class IKeyboard : public IHID {
+ public:
+ virtual ~IKeyboard();
+ virtual uint32_t getCapabilities();
+ virtual bool isVirtual() = 0;
+ virtual wlr_keyboard* wlr() = 0;
+
+ struct SKeyEvent {
+ uint32_t timeMs = 0;
+ uint32_t keycode = 0;
+ bool updateMods = false;
+ wl_keyboard_key_state state = WL_KEYBOARD_KEY_STATE_PRESSED;
+ };
+
+ struct {
+ CSignal key;
+ CSignal modifiers;
+ CSignal keymap;
+ CSignal repeatInfo;
+ } keyboardEvents;
+
+ struct SStringRuleNames {
+ std::string layout = "";
+ std::string model = "";
+ std::string variant = "";
+ std::string options = "";
+ std::string rules = "";
+ };
+
+ void updateXKBTranslationState(xkb_keymap* const keymap = nullptr);
+ std::string getActiveLayout();
+ void updateLEDs();
+
+ bool active = false;
+ bool enabled = true;
+
+ xkb_layout_index_t activeLayout = 0;
+ xkb_state* xkbTranslationState = nullptr;
+
+ std::string hlName = "";
+ std::string xkbFilePath = "";
+
+ SStringRuleNames currentRules;
+ int repeatRate = 0;
+ int repeatDelay = 0;
+ int numlockOn = -1;
+ bool resolveBindsBySym = false;
+
+ WP<IKeyboard> self;
+};