summaryrefslogtreecommitdiff
path: root/src/devices/IKeyboard.hpp
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2024-07-21 13:09:54 +0200
committerGitHub <noreply@github.com>2024-07-21 13:09:54 +0200
commit016da234d0e852de3ef20eb2e89ac58d2a85f6e7 (patch)
tree496085987176551b0794fffc069877d44943e2f1 /src/devices/IKeyboard.hpp
parentf642fb97df5c69267a03452533de383ff8023570 (diff)
Core: Move to aquamarine (#6608)
Moves Hyprland from wlroots to aquamarine for the backend. --------- Signed-off-by: Vaxry <vaxry@vaxry.net> Co-authored-by: Mihai Fufezan <mihai@fufexan.net> Co-authored-by: Jan Beich <jbeich@FreeBSD.org> Co-authored-by: vaxerski <vaxerski@users.noreply.github.com> Co-authored-by: UjinT34 <41110182+UjinT34@users.noreply.github.com> Co-authored-by: Tom Englund <tomenglund26@gmail.com> Co-authored-by: Ikalco <73481042+ikalco@users.noreply.github.com> Co-authored-by: diniamo <diniamo53@gmail.com>
Diffstat (limited to 'src/devices/IKeyboard.hpp')
-rw-r--r--src/devices/IKeyboard.hpp73
1 files changed, 58 insertions, 15 deletions
diff --git a/src/devices/IKeyboard.hpp b/src/devices/IKeyboard.hpp
index b1757a18..1ae6c7bc 100644
--- a/src/devices/IKeyboard.hpp
+++ b/src/devices/IKeyboard.hpp
@@ -7,15 +7,26 @@
#include <xkbcommon/xkbcommon.h>
-struct wlr_keyboard;
+AQUAMARINE_FORWARD(IKeyboard);
+
+enum eKeyboardModifiers {
+ HL_MODIFIER_SHIFT = (1 << 0),
+ HL_MODIFIER_CAPS = (1 << 1),
+ HL_MODIFIER_CTRL = (1 << 2),
+ HL_MODIFIER_ALT = (1 << 3),
+ HL_MODIFIER_MOD2 = (1 << 4),
+ HL_MODIFIER_MOD3 = (1 << 5),
+ HL_MODIFIER_META = (1 << 6),
+ HL_MODIFIER_MOD5 = (1 << 7),
+};
class IKeyboard : public IHID {
public:
virtual ~IKeyboard();
- virtual uint32_t getCapabilities();
- virtual eHIDType getType();
- virtual bool isVirtual() = 0;
- virtual wlr_keyboard* wlr() = 0;
+ virtual uint32_t getCapabilities();
+ virtual eHIDType getType();
+ virtual bool isVirtual() = 0;
+ virtual SP<Aquamarine::IKeyboard> aq() = 0;
struct SKeyEvent {
uint32_t timeMs = 0;
@@ -24,6 +35,17 @@ class IKeyboard : public IHID {
wl_keyboard_key_state state = WL_KEYBOARD_KEY_STATE_PRESSED;
};
+ struct SKeymapEvent {
+ xkb_keymap* keymap = nullptr;
+ };
+
+ struct SModifiersEvent {
+ uint32_t depressed = 0;
+ uint32_t latched = 0;
+ uint32_t locked = 0;
+ uint32_t group = 0;
+ };
+
struct {
CSignal key;
CSignal modifiers;
@@ -39,25 +61,46 @@ class IKeyboard : public IHID {
std::string rules = "";
};
+ void setKeymap(const SStringRuleNames& rules);
void updateXKBTranslationState(xkb_keymap* const keymap = nullptr);
std::string getActiveLayout();
void updateLEDs();
void updateLEDs(uint32_t leds);
+ uint32_t getModifiers();
+ void updateModifiers(uint32_t depressed, uint32_t latched, uint32_t locked, uint32_t group);
+ bool updateModifiersState(); // rets whether changed
+ void updateXkbStateWithKey(uint32_t xkbKey, bool pressed);
bool active = false;
bool enabled = true;
- xkb_layout_index_t activeLayout = 0;
- xkb_state* xkbTranslationState = nullptr;
+ xkb_layout_index_t activeLayout = 0;
+ xkb_state * xkbState = nullptr, *xkbStaticState /* Static state: never gets modifiers or layout changes sent, used for keybinds. */ = nullptr;
+ xkb_keymap* xkbKeymap = nullptr;
+
+ struct {
+ uint32_t depressed = 0, latched = 0, locked = 0, group = 0;
+ } modifiersState;
+
+ std::array<xkb_led_index_t, 3> ledIndexes = {XKB_MOD_INVALID};
+ std::array<xkb_mod_index_t, 8> modIndexes = {XKB_MOD_INVALID};
+ uint32_t leds = 0;
+
+ std::string hlName = "";
+ std::string xkbFilePath = "";
+ std::string xkbKeymapString = "";
+ int xkbKeymapFD = -1;
+
+ SStringRuleNames currentRules;
+ int repeatRate = 0;
+ int repeatDelay = 0;
+ int numlockOn = -1;
+ bool resolveBindsBySym = false;
- std::string hlName = "";
- std::string xkbFilePath = "";
+ WP<IKeyboard> self;
- SStringRuleNames currentRules;
- int repeatRate = 0;
- int repeatDelay = 0;
- int numlockOn = -1;
- bool resolveBindsBySym = false;
+ private:
+ void clearManuallyAllocd();
- WP<IKeyboard> self;
+ std::vector<uint32_t> pressedXKB;
};