From 1237732b97fcf21a19aed16f2ef966118a3ca2aa Mon Sep 17 00:00:00 2001 From: Vaxry Date: Fri, 3 May 2024 22:34:10 +0100 Subject: 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. --- src/devices/IKeyboard.hpp | 61 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 src/devices/IKeyboard.hpp (limited to 'src/devices/IKeyboard.hpp') 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 + +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 self; +}; -- cgit v1.2.3