diff options
| author | davc0n <dconti.dev@gmail.com> | 2025-04-29 19:51:07 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-29 19:51:07 +0200 |
| commit | e9c3fcbb64c2df147a176052fb219f0f8a7b89ec (patch) | |
| tree | e95dcd235eff2027cbc7e8269100399d00da858e /src/devices | |
| parent | 40147d3a3f0843b548769e79e4a345d67b9e3c04 (diff) | |
devices: refactor class member vars (#10206)
Diffstat (limited to 'src/devices')
| -rw-r--r-- | src/devices/IHID.hpp | 5 | ||||
| -rw-r--r-- | src/devices/IKeyboard.cpp | 240 | ||||
| -rw-r--r-- | src/devices/IKeyboard.hpp | 50 | ||||
| -rw-r--r-- | src/devices/IPointer.hpp | 14 | ||||
| -rw-r--r-- | src/devices/ITouch.hpp | 6 | ||||
| -rw-r--r-- | src/devices/Keyboard.cpp | 30 | ||||
| -rw-r--r-- | src/devices/Keyboard.hpp | 4 | ||||
| -rw-r--r-- | src/devices/Mouse.cpp | 74 | ||||
| -rw-r--r-- | src/devices/Mouse.hpp | 4 | ||||
| -rw-r--r-- | src/devices/Tablet.cpp | 132 | ||||
| -rw-r--r-- | src/devices/Tablet.hpp | 48 | ||||
| -rw-r--r-- | src/devices/TouchDevice.cpp | 36 | ||||
| -rw-r--r-- | src/devices/TouchDevice.hpp | 4 | ||||
| -rw-r--r-- | src/devices/VirtualKeyboard.cpp | 44 | ||||
| -rw-r--r-- | src/devices/VirtualKeyboard.hpp | 4 | ||||
| -rw-r--r-- | src/devices/VirtualPointer.cpp | 52 | ||||
| -rw-r--r-- | src/devices/VirtualPointer.hpp | 4 |
17 files changed, 378 insertions, 373 deletions
diff --git a/src/devices/IHID.hpp b/src/devices/IHID.hpp index b9cc4212..4de5abe6 100644 --- a/src/devices/IHID.hpp +++ b/src/devices/IHID.hpp @@ -34,7 +34,8 @@ class IHID { struct { CSignal destroy; - } events; + } m_events; - std::string deviceName, hlName; + std::string m_deviceName; + std::string m_hlName; };
\ No newline at end of file diff --git a/src/devices/IKeyboard.cpp b/src/devices/IKeyboard.cpp index b8f9c7dd..597724a6 100644 --- a/src/devices/IKeyboard.cpp +++ b/src/devices/IKeyboard.cpp @@ -28,38 +28,38 @@ eHIDType IKeyboard::getType() { } IKeyboard::~IKeyboard() { - events.destroy.emit(); + m_events.destroy.emit(); clearManuallyAllocd(); } void IKeyboard::clearManuallyAllocd() { - if (xkbStaticState) - xkb_state_unref(xkbStaticState); + if (m_xkbStaticState) + xkb_state_unref(m_xkbStaticState); - if (xkbState) - xkb_state_unref(xkbState); + if (m_xkbState) + xkb_state_unref(m_xkbState); - if (xkbKeymap) - xkb_keymap_unref(xkbKeymap); + if (m_xkbKeymap) + xkb_keymap_unref(m_xkbKeymap); - if (xkbSymState) - xkb_state_unref(xkbSymState); + if (m_xkbSymState) + xkb_state_unref(m_xkbSymState); - xkbSymState = nullptr; - xkbKeymap = nullptr; - xkbState = nullptr; - xkbStaticState = nullptr; - xkbKeymapFD.reset(); + m_xkbSymState = nullptr; + m_xkbKeymap = nullptr; + m_xkbState = nullptr; + m_xkbStaticState = nullptr; + m_xkbKeymapFD.reset(); } void IKeyboard::setKeymap(const SStringRuleNames& rules) { - if (keymapOverridden) { + if (m_keymapOverridden) { Debug::log(LOG, "Ignoring setKeymap: keymap is overridden"); return; } - currentRules = rules; + m_currentRules = rules; xkb_rule_names XKBRULES = { .rules = rules.rules.c_str(), .model = rules.model.c_str(), @@ -80,21 +80,21 @@ void IKeyboard::setKeymap(const SStringRuleNames& rules) { Debug::log(LOG, "Attempting to create a keymap for layout {} with variant {} (rules: {}, model: {}, options: {})", rules.layout, rules.variant, rules.rules, rules.model, rules.options); - if (!xkbFilePath.empty()) { - auto path = absolutePath(xkbFilePath, g_pConfigManager->m_configCurrentPath); + if (!m_xkbFilePath.empty()) { + auto path = absolutePath(m_xkbFilePath, g_pConfigManager->m_configCurrentPath); if (FILE* const KEYMAPFILE = fopen(path.c_str(), "r"); !KEYMAPFILE) Debug::log(ERR, "Cannot open input:kb_file= file for reading"); else { - xkbKeymap = xkb_keymap_new_from_file(CONTEXT, KEYMAPFILE, XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS); + m_xkbKeymap = xkb_keymap_new_from_file(CONTEXT, KEYMAPFILE, XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS); fclose(KEYMAPFILE); } } - if (!xkbKeymap) - xkbKeymap = xkb_keymap_new_from_names(CONTEXT, &XKBRULES, XKB_KEYMAP_COMPILE_NO_FLAGS); + if (!m_xkbKeymap) + m_xkbKeymap = xkb_keymap_new_from_names(CONTEXT, &XKBRULES, XKB_KEYMAP_COMPILE_NO_FLAGS); - if (!xkbKeymap) { + if (!m_xkbKeymap) { g_pConfigManager->addParseError("Invalid keyboard layout passed. ( rules: " + rules.rules + ", model: " + rules.model + ", variant: " + rules.variant + ", options: " + rules.options + ", layout: " + rules.layout + " )"); @@ -102,38 +102,38 @@ void IKeyboard::setKeymap(const SStringRuleNames& rules) { rules.options); memset(&XKBRULES, 0, sizeof(XKBRULES)); - currentRules.rules = ""; - currentRules.model = ""; - currentRules.variant = ""; - currentRules.options = ""; - currentRules.layout = "us"; + m_currentRules.rules = ""; + m_currentRules.model = ""; + m_currentRules.variant = ""; + m_currentRules.options = ""; + m_currentRules.layout = "us"; - xkbKeymap = xkb_keymap_new_from_names(CONTEXT, &XKBRULES, XKB_KEYMAP_COMPILE_NO_FLAGS); + m_xkbKeymap = xkb_keymap_new_from_names(CONTEXT, &XKBRULES, XKB_KEYMAP_COMPILE_NO_FLAGS); } - updateXKBTranslationState(xkbKeymap); + updateXKBTranslationState(m_xkbKeymap); - const auto NUMLOCKON = g_pConfigManager->getDeviceInt(hlName, "numlock_by_default", "input:numlock_by_default"); + const auto NUMLOCKON = g_pConfigManager->getDeviceInt(m_hlName, "numlock_by_default", "input:numlock_by_default"); if (NUMLOCKON == 1) { // lock numlock - const auto IDX = xkb_map_mod_get_index(xkbKeymap, XKB_MOD_NAME_NUM); + const auto IDX = xkb_map_mod_get_index(m_xkbKeymap, XKB_MOD_NAME_NUM); if (IDX != XKB_MOD_INVALID) - modifiersState.locked |= (uint32_t)1 << IDX; + m_modifiersState.locked |= (uint32_t)1 << IDX; // 0 to avoid mods getting stuck if depressed during reload - updateModifiers(0, 0, modifiersState.locked, modifiersState.group); + updateModifiers(0, 0, m_modifiersState.locked, m_modifiersState.group); } - for (size_t i = 0; i < std::min(LEDNAMES.size(), ledIndexes.size()); ++i) { - ledIndexes[i] = xkb_map_led_get_index(xkbKeymap, LEDNAMES[i]); - Debug::log(LOG, "xkb: LED index {} (name {}) got index {}", i, LEDNAMES[i], ledIndexes[i]); + for (size_t i = 0; i < std::min(LEDNAMES.size(), m_ledIndexes.size()); ++i) { + m_ledIndexes[i] = xkb_map_led_get_index(m_xkbKeymap, LEDNAMES[i]); + Debug::log(LOG, "xkb: LED index {} (name {}) got index {}", i, LEDNAMES[i], m_ledIndexes[i]); } - for (size_t i = 0; i < std::min(MODNAMES.size(), modIndexes.size()); ++i) { - modIndexes[i] = xkb_map_mod_get_index(xkbKeymap, MODNAMES[i]); - Debug::log(LOG, "xkb: Mod index {} (name {}) got index {}", i, MODNAMES[i], modIndexes[i]); + for (size_t i = 0; i < std::min(MODNAMES.size(), m_modIndexes.size()); ++i) { + m_modIndexes[i] = xkb_map_mod_get_index(m_xkbKeymap, MODNAMES[i]); + Debug::log(LOG, "xkb: Mod index {} (name {}) got index {}", i, MODNAMES[i], m_modIndexes[i]); } updateKeymapFD(); @@ -144,59 +144,59 @@ void IKeyboard::setKeymap(const SStringRuleNames& rules) { } void IKeyboard::updateKeymapFD() { - Debug::log(LOG, "Updating keymap fd for keyboard {}", deviceName); + Debug::log(LOG, "Updating keymap fd for keyboard {}", m_deviceName); - if (xkbKeymapFD.isValid()) - xkbKeymapFD.reset(); + if (m_xkbKeymapFD.isValid()) + m_xkbKeymapFD.reset(); - auto cKeymapStr = xkb_keymap_get_as_string(xkbKeymap, XKB_KEYMAP_FORMAT_TEXT_V1); - xkbKeymapString = cKeymapStr; + auto cKeymapStr = xkb_keymap_get_as_string(m_xkbKeymap, XKB_KEYMAP_FORMAT_TEXT_V1); + m_xkbKeymapString = cKeymapStr; free(cKeymapStr); CFileDescriptor rw, ro; - if (!allocateSHMFilePair(xkbKeymapString.length() + 1, rw, ro)) + if (!allocateSHMFilePair(m_xkbKeymapString.length() + 1, rw, ro)) Debug::log(ERR, "IKeyboard: failed to allocate shm pair for the keymap"); else { - auto keymapFDDest = mmap(nullptr, xkbKeymapString.length() + 1, PROT_READ | PROT_WRITE, MAP_SHARED, rw.get(), 0); + auto keymapFDDest = mmap(nullptr, m_xkbKeymapString.length() + 1, PROT_READ | PROT_WRITE, MAP_SHARED, rw.get(), 0); rw.reset(); if (keymapFDDest == MAP_FAILED) { Debug::log(ERR, "IKeyboard: failed to mmap a shm pair for the keymap"); ro.reset(); } else { - memcpy(keymapFDDest, xkbKeymapString.c_str(), xkbKeymapString.length()); - munmap(keymapFDDest, xkbKeymapString.length() + 1); - xkbKeymapFD = std::move(ro); + memcpy(keymapFDDest, m_xkbKeymapString.c_str(), m_xkbKeymapString.length()); + munmap(keymapFDDest, m_xkbKeymapString.length() + 1); + m_xkbKeymapFD = std::move(ro); } } - Debug::log(LOG, "Updated keymap fd to {}", xkbKeymapFD.get()); + Debug::log(LOG, "Updated keymap fd to {}", m_xkbKeymapFD.get()); } void IKeyboard::updateXKBTranslationState(xkb_keymap* const keymap) { - if (xkbStaticState) - xkb_state_unref(xkbStaticState); + if (m_xkbStaticState) + xkb_state_unref(m_xkbStaticState); - if (xkbState) - xkb_state_unref(xkbState); + if (m_xkbState) + xkb_state_unref(m_xkbState); - if (xkbSymState) - xkb_state_unref(xkbSymState); + if (m_xkbSymState) + xkb_state_unref(m_xkbSymState); - xkbState = nullptr; - xkbStaticState = nullptr; - xkbSymState = nullptr; + m_xkbState = nullptr; + m_xkbStaticState = nullptr; + m_xkbSymState = nullptr; if (keymap) { Debug::log(LOG, "Updating keyboard {:x}'s translation state from a provided keymap", (uintptr_t)this); - xkbStaticState = xkb_state_new(keymap); - xkbState = xkb_state_new(keymap); - xkbSymState = xkb_state_new(keymap); + m_xkbStaticState = xkb_state_new(keymap); + m_xkbState = xkb_state_new(keymap); + m_xkbSymState = xkb_state_new(keymap); return; } - const auto KEYMAP = xkbKeymap; - const auto STATE = xkbState; + const auto KEYMAP = m_xkbKeymap; + const auto STATE = m_xkbState; const auto LAYOUTSNUM = xkb_keymap_num_layouts(KEYMAP); const auto PCONTEXT = xkb_context_new(XKB_CONTEXT_NO_FLAGS); @@ -205,9 +205,9 @@ void IKeyboard::updateXKBTranslationState(xkb_keymap* const keymap) { if (xkb_state_layout_index_is_active(STATE, i, XKB_STATE_LAYOUT_EFFECTIVE) == 1) { Debug::log(LOG, "Updating keyboard {:x}'s translation state from an active index {}", (uintptr_t)this, i); - CVarList keyboardLayouts(currentRules.layout, 0, ','); - CVarList keyboardModels(currentRules.model, 0, ','); - CVarList keyboardVariants(currentRules.variant, 0, ','); + CVarList keyboardLayouts(m_currentRules.layout, 0, ','); + CVarList keyboardModels(m_currentRules.model, 0, ','); + CVarList keyboardVariants(m_currentRules.variant, 0, ','); xkb_rule_names rules = {.rules = "", .model = "", .layout = "", .variant = "", .options = ""}; @@ -235,9 +235,9 @@ void IKeyboard::updateXKBTranslationState(xkb_keymap* const keymap) { KEYMAP = xkb_keymap_new_from_names(PCONTEXT, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS); } - xkbState = xkb_state_new(KEYMAP); - xkbStaticState = xkb_state_new(KEYMAP); - xkbSymState = xkb_state_new(KEYMAP); + m_xkbState = xkb_state_new(KEYMAP); + m_xkbStaticState = xkb_state_new(KEYMAP); + m_xkbSymState = xkb_state_new(KEYMAP); xkb_keymap_unref(KEYMAP); xkb_context_unref(PCONTEXT); @@ -249,26 +249,26 @@ void IKeyboard::updateXKBTranslationState(xkb_keymap* const keymap) { Debug::log(LOG, "Updating keyboard {:x}'s translation state from an unknown index", (uintptr_t)this); xkb_rule_names rules = { - .rules = currentRules.rules.c_str(), - .model = currentRules.model.c_str(), - .layout = currentRules.layout.c_str(), - .variant = currentRules.variant.c_str(), - .options = currentRules.options.c_str(), + .rules = m_currentRules.rules.c_str(), + .model = m_currentRules.model.c_str(), + .layout = m_currentRules.layout.c_str(), + .variant = m_currentRules.variant.c_str(), + .options = m_currentRules.options.c_str(), }; const auto NEWKEYMAP = xkb_keymap_new_from_names(PCONTEXT, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS); - xkbState = xkb_state_new(NEWKEYMAP); - xkbStaticState = xkb_state_new(NEWKEYMAP); - xkbSymState = xkb_state_new(NEWKEYMAP); + m_xkbState = xkb_state_new(NEWKEYMAP); + m_xkbStaticState = xkb_state_new(NEWKEYMAP); + m_xkbSymState = xkb_state_new(NEWKEYMAP); xkb_keymap_unref(NEWKEYMAP); xkb_context_unref(PCONTEXT); } std::string IKeyboard::getActiveLayout() { - const auto KEYMAP = xkbKeymap; - const auto STATE = xkbState; + const auto KEYMAP = m_xkbKeymap; + const auto STATE = m_xkbState; const auto LAYOUTSNUM = xkb_keymap_num_layouts(KEYMAP); for (uint32_t i = 0; i < LAYOUTSNUM; ++i) { @@ -285,12 +285,12 @@ std::string IKeyboard::getActiveLayout() { } std::optional<uint32_t> IKeyboard::getLEDs() { - if (xkbState == nullptr) + if (m_xkbState == nullptr) return {}; uint32_t leds = 0; - for (uint32_t i = 0; i < std::min((size_t)LED_COUNT, ledIndexes.size()); ++i) { - if (xkb_state_led_index_is_active(xkbState, ledIndexes[i])) + for (uint32_t i = 0; i < std::min((size_t)LED_COUNT, m_ledIndexes.size()); ++i) { + if (xkb_state_led_index_is_active(m_xkbState, m_ledIndexes[i])) leds |= (1 << i); } @@ -307,10 +307,10 @@ void IKeyboard::updateLEDs() { } void IKeyboard::updateLEDs(uint32_t leds) { - if (!xkbState) + if (!m_xkbState) return; - if (isVirtual() && g_pInputManager->shouldIgnoreVirtualKeyboard(self.lock())) + if (isVirtual() && g_pInputManager->shouldIgnoreVirtualKeyboard(m_self.lock())) return; if (!aq()) @@ -320,13 +320,13 @@ void IKeyboard::updateLEDs(uint32_t leds) { } uint32_t IKeyboard::getModifiers() { - uint32_t modMask = modifiersState.depressed | modifiersState.latched; + uint32_t modMask = m_modifiersState.depressed | m_modifiersState.latched; uint32_t mods = 0; - for (size_t i = 0; i < modIndexes.size(); ++i) { - if (modIndexes[i] == XKB_MOD_INVALID) + for (size_t i = 0; i < m_modIndexes.size(); ++i) { + if (m_modIndexes[i] == XKB_MOD_INVALID) continue; - if (!(modMask & (1 << modIndexes[i]))) + if (!(modMask & (1 << m_modIndexes[i]))) continue; mods |= (1 << i); @@ -336,50 +336,50 @@ uint32_t IKeyboard::getModifiers() { } void IKeyboard::updateModifiers(uint32_t depressed, uint32_t latched, uint32_t locked, uint32_t group) { - if (!xkbState) + if (!m_xkbState) return; - xkb_state_update_mask(xkbState, depressed, latched, locked, 0, 0, group); + xkb_state_update_mask(m_xkbState, depressed, latched, locked, 0, 0, group); - if (xkbSymState) - xkb_state_update_mask(xkbSymState, 0, 0, 0, 0, 0, group); + if (m_xkbSymState) + xkb_state_update_mask(m_xkbSymState, 0, 0, 0, 0, 0, group); if (!updateModifiersState()) return; - keyboardEvents.modifiers.emit(SModifiersEvent{ - .depressed = modifiersState.depressed, - .latched = modifiersState.latched, - .locked = modifiersState.locked, - .group = modifiersState.group, + m_keyboardEvents.modifiers.emit(SModifiersEvent{ + .depressed = m_modifiersState.depressed, + .latched = m_modifiersState.latched, + .locked = m_modifiersState.locked, + .group = m_modifiersState.group, }); updateLEDs(); } bool IKeyboard::updateModifiersState() { - if (!xkbState) + if (!m_xkbState) return false; - auto depressed = xkb_state_serialize_mods(xkbState, XKB_STATE_MODS_DEPRESSED); - auto latched = xkb_state_serialize_mods(xkbState, XKB_STATE_MODS_LATCHED); - auto locked = xkb_state_serialize_mods(xkbState, XKB_STATE_MODS_LOCKED); - auto group = xkb_state_serialize_layout(xkbState, XKB_STATE_LAYOUT_EFFECTIVE); + auto depressed = xkb_state_serialize_mods(m_xkbState, XKB_STATE_MODS_DEPRESSED); + auto latched = xkb_state_serialize_mods(m_xkbState, XKB_STATE_MODS_LATCHED); + auto locked = xkb_state_serialize_mods(m_xkbState, XKB_STATE_MODS_LOCKED); + auto group = xkb_state_serialize_layout(m_xkbState, XKB_STATE_LAYOUT_EFFECTIVE); - if (depressed == modifiersState.depressed && latched == modifiersState.latched && locked == modifiersState.locked && group == modifiersState.group) + if (depressed == m_modifiersState.depressed && latched == m_modifiersState.latched && locked == m_modifiersState.locked && group == m_modifiersState.group) return false; - modifiersState.depressed = depressed; - modifiersState.latched = latched; - modifiersState.locked = locked; - modifiersState.group = group; + m_modifiersState.depressed = depressed; + m_modifiersState.latched = latched; + m_modifiersState.locked = locked; + m_modifiersState.group = group; return true; } void IKeyboard::updateXkbStateWithKey(uint32_t xkbKey, bool pressed) { - const auto contains = std::find(pressedXKB.begin(), pressedXKB.end(), xkbKey) != pressedXKB.end(); + const auto contains = std::find(m_pressedXKB.begin(), m_pressedXKB.end(), xkbKey) != m_pressedXKB.end(); if (contains && pressed) return; @@ -387,21 +387,21 @@ void IKeyboard::updateXkbStateWithKey(uint32_t xkbKey, bool pressed) { return; if (contains) - std::erase(pressedXKB, xkbKey); + std::erase(m_pressedXKB, xkbKey); else - pressedXKB.emplace_back(xkbKey); + m_pressedXKB.emplace_back(xkbKey); - xkb_state_update_key(xkbState, xkbKey, pressed ? XKB_KEY_DOWN : XKB_KEY_UP); + xkb_state_update_key(m_xkbState, xkbKey, pressed ? XKB_KEY_DOWN : XKB_KEY_UP); if (updateModifiersState()) { - if (xkbSymState) - xkb_state_update_mask(xkbSymState, 0, 0, 0, 0, 0, modifiersState.group); - - keyboardEvents.modifiers.emit(SModifiersEvent{ - .depressed = modifiersState.depressed, - .latched = modifiersState.latched, - .locked = modifiersState.locked, - .group = modifiersState.group, + if (m_xkbSymState) + xkb_state_update_mask(m_xkbSymState, 0, 0, 0, 0, 0, m_modifiersState.group); + + m_keyboardEvents.modifiers.emit(SModifiersEvent{ + .depressed = m_modifiersState.depressed, + .latched = m_modifiersState.latched, + .locked = m_modifiersState.locked, + .group = m_modifiersState.group, }); } } diff --git a/src/devices/IKeyboard.hpp b/src/devices/IKeyboard.hpp index 7ac71172..3d7b2dd1 100644 --- a/src/devices/IKeyboard.hpp +++ b/src/devices/IKeyboard.hpp @@ -52,7 +52,7 @@ class IKeyboard : public IHID { CSignal modifiers; CSignal keymap; CSignal repeatInfo; - } keyboardEvents; + } m_keyboardEvents; struct SStringRuleNames { std::string layout = ""; @@ -74,42 +74,46 @@ class IKeyboard : public IHID { void updateXkbStateWithKey(uint32_t xkbKey, bool pressed); void updateKeymapFD(); - bool active = false; - bool enabled = true; - bool allowBinds = true; + bool m_active = false; + bool m_enabled = true; + bool m_allowBinds = true; // if the keymap is overridden by the implementation, // don't try to set keyboard rules anymore, to avoid overwriting the requested one. // e.g. Virtual keyboards with custom maps. - bool keymapOverridden = false; + bool m_keymapOverridden = false; - xkb_layout_index_t activeLayout = 0; - xkb_state * xkbState = nullptr, *xkbStaticState /* Static state: never gets modifiers or layout changes sent, used for keybinds. */ = nullptr, - *xkbSymState = nullptr /* Same as static but gets layouts */; - xkb_keymap* xkbKeymap = nullptr; + xkb_layout_index_t m_activeLayout = 0; + xkb_state* m_xkbState = nullptr; + + // never gets modifiers or layout changes sent, used for keybinds + xkb_state* m_xkbStaticState = nullptr; + xkb_state* m_xkbSymState = nullptr; // same as static but gets layouts + + xkb_keymap* m_xkbKeymap = nullptr; struct { uint32_t depressed = 0, latched = 0, locked = 0, group = 0; - } modifiersState; + } m_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::array<xkb_led_index_t, 3> m_ledIndexes = {XKB_MOD_INVALID}; + std::array<xkb_mod_index_t, 8> m_modIndexes = {XKB_MOD_INVALID}; + uint32_t m_leds = 0; - std::string xkbFilePath = ""; - std::string xkbKeymapString = ""; - Hyprutils::OS::CFileDescriptor xkbKeymapFD; + std::string m_xkbFilePath = ""; + std::string m_xkbKeymapString = ""; + Hyprutils::OS::CFileDescriptor m_xkbKeymapFD; - SStringRuleNames currentRules; - int repeatRate = 0; - int repeatDelay = 0; - int numlockOn = -1; - bool resolveBindsBySym = false; + SStringRuleNames m_currentRules; + int m_repeatRate = 0; + int m_repeatDelay = 0; + int m_numlockOn = -1; + bool m_resolveBindsBySym = false; - WP<IKeyboard> self; + WP<IKeyboard> m_self; private: void clearManuallyAllocd(); - std::vector<uint32_t> pressedXKB; + std::vector<uint32_t> m_pressedXKB; }; diff --git a/src/devices/IPointer.hpp b/src/devices/IPointer.hpp index d5541222..993095e0 100644 --- a/src/devices/IPointer.hpp +++ b/src/devices/IPointer.hpp @@ -106,13 +106,13 @@ class IPointer : public IHID { CSignal holdBegin; CSignal holdEnd; - } pointerEvents; + } m_pointerEvents; - bool connected = false; // means connected to the cursor - std::string boundOutput = ""; - bool flipX = false; // decide to invert horizontal movement - bool flipY = false; // decide to invert vertical movement - bool isTouchpad = false; + bool m_connected = false; // means connected to the cursor + std::string m_boundOutput = ""; + bool m_flipX = false; // decide to invert horizontal movement + bool m_flipY = false; // decide to invert vertical movement + bool m_isTouchpad = false; - WP<IPointer> self; + WP<IPointer> m_self; }; diff --git a/src/devices/ITouch.hpp b/src/devices/ITouch.hpp index 766c0510..e5230394 100644 --- a/src/devices/ITouch.hpp +++ b/src/devices/ITouch.hpp @@ -42,9 +42,9 @@ class ITouch : public IHID { CSignal motion; CSignal cancel; CSignal frame; - } touchEvents; + } m_touchEvents; - std::string boundOutput = ""; + std::string m_boundOutput = ""; - WP<ITouch> self; + WP<ITouch> m_self; };
\ No newline at end of file diff --git a/src/devices/Keyboard.cpp b/src/devices/Keyboard.cpp index 191cc6b2..70abe54d 100644 --- a/src/devices/Keyboard.cpp +++ b/src/devices/Keyboard.cpp @@ -6,7 +6,7 @@ SP<CKeyboard> CKeyboard::create(SP<Aquamarine::IKeyboard> keeb) { SP<CKeyboard> pKeeb = SP<CKeyboard>(new CKeyboard(keeb)); - pKeeb->self = pKeeb; + pKeeb->m_self = pKeeb; return pKeeb; } @@ -16,22 +16,22 @@ bool CKeyboard::isVirtual() { } SP<Aquamarine::IKeyboard> CKeyboard::aq() { - return keyboard.lock(); + return m_keyboard.lock(); } -CKeyboard::CKeyboard(SP<Aquamarine::IKeyboard> keeb) : keyboard(keeb) { +CKeyboard::CKeyboard(SP<Aquamarine::IKeyboard> keeb) : m_keyboard(keeb) { if (!keeb) return; - listeners.destroy = keeb->events.destroy.registerListener([this](std::any d) { - keyboard.reset(); - events.destroy.emit(); + m_listeners.destroy = keeb->events.destroy.registerListener([this](std::any d) { + m_keyboard.reset(); + m_events.destroy.emit(); }); - listeners.key = keeb->events.key.registerListener([this](std::any d) { + m_listeners.key = keeb->events.key.registerListener([this](std::any d) { auto E = std::any_cast<Aquamarine::IKeyboard::SKeyEvent>(d); - keyboardEvents.key.emit(SKeyEvent{ + m_keyboardEvents.key.emit(SKeyEvent{ .timeMs = E.timeMs, .keycode = E.key, .state = E.pressed ? WL_KEYBOARD_KEY_STATE_PRESSED : WL_KEYBOARD_KEY_STATE_RELEASED, @@ -40,16 +40,16 @@ CKeyboard::CKeyboard(SP<Aquamarine::IKeyboard> keeb) : keyboard(keeb) { updateXkbStateWithKey(E.key + 8, E.pressed); }); - listeners.modifiers = keeb->events.modifiers.registerListener([this](std::any d) { + m_listeners.modifiers = keeb->events.modifiers.registerListener([this](std::any d) { updateModifiersState(); - keyboardEvents.modifiers.emit(SModifiersEvent{ - .depressed = modifiersState.depressed, - .latched = modifiersState.latched, - .locked = modifiersState.locked, - .group = modifiersState.group, + m_keyboardEvents.modifiers.emit(SModifiersEvent{ + .depressed = m_modifiersState.depressed, + .latched = m_modifiersState.latched, + .locked = m_modifiersState.locked, + .group = m_modifiersState.group, }); }); - deviceName = keeb->getName(); + m_deviceName = keeb->getName(); } diff --git a/src/devices/Keyboard.hpp b/src/devices/Keyboard.hpp index f6de43cb..2ba4626d 100644 --- a/src/devices/Keyboard.hpp +++ b/src/devices/Keyboard.hpp @@ -12,11 +12,11 @@ class CKeyboard : public IKeyboard { private: CKeyboard(SP<Aquamarine::IKeyboard> keeb); - WP<Aquamarine::IKeyboard> keyboard; + WP<Aquamarine::IKeyboard> m_keyboard; struct { CHyprSignalListener destroy; CHyprSignalListener key; CHyprSignalListener modifiers; - } listeners; + } m_listeners; };
\ No newline at end of file diff --git a/src/devices/Mouse.cpp b/src/devices/Mouse.cpp index 600ae5a8..539aecf7 100644 --- a/src/devices/Mouse.cpp +++ b/src/devices/Mouse.cpp @@ -5,51 +5,51 @@ SP<CMouse> CMouse::create(SP<Aquamarine::IPointer> mouse) { SP<CMouse> pMouse = SP<CMouse>(new CMouse(mouse)); - pMouse->self = pMouse; + pMouse->m_self = pMouse; return pMouse; } -CMouse::CMouse(SP<Aquamarine::IPointer> mouse_) : mouse(mouse_) { - if (!mouse) +CMouse::CMouse(SP<Aquamarine::IPointer> mouse_) : m_mouse(mouse_) { + if (!m_mouse) return; - if (auto handle = mouse->getLibinputHandle()) { + if (auto handle = m_mouse->getLibinputHandle()) { double w = 0, h = 0; - isTouchpad = libinput_device_has_capability(handle, LIBINPUT_DEVICE_CAP_POINTER) && libinput_device_get_size(handle, &w, &h) == 0; + m_isTouchpad = libinput_device_has_capability(handle, LIBINPUT_DEVICE_CAP_POINTER) && libinput_device_get_size(handle, &w, &h) == 0; } - listeners.destroy = mouse->events.destroy.registerListener([this](std::any d) { - mouse.reset(); - events.destroy.emit(); + m_listeners.destroy = m_mouse->events.destroy.registerListener([this](std::any d) { + m_mouse.reset(); + m_events.destroy.emit(); }); - listeners.motion = mouse->events.move.registerListener([this](std::any d) { + m_listeners.motion = m_mouse->events.move.registerListener([this](std::any d) { auto E = std::any_cast<Aquamarine::IPointer::SMoveEvent>(d); - pointerEvents.motion.emit(SMotionEvent{ + m_pointerEvents.motion.emit(SMotionEvent{ .timeMs = E.timeMs, .delta = E.delta, .unaccel = E.unaccel, .mouse = true, - .device = self.lock(), + .device = m_self.lock(), }); }); - listeners.motionAbsolute = mouse->events.warp.registerListener([this](std::any d) { + m_listeners.motionAbsolute = m_mouse->events.warp.registerListener([this](std::any d) { auto E = std::any_cast<Aquamarine::IPointer::SWarpEvent>(d); - pointerEvents.motionAbsolute.emit(SMotionAbsoluteEvent{ + m_pointerEvents.motionAbsolute.emit(SMotionAbsoluteEvent{ .timeMs = E.timeMs, .absolute = E.absolute, - .device = self.lock(), + .device = m_self.lock(), }); }); - listeners.button = mouse->events.button.registerListener([this](std::any d) { + m_listeners.button = m_mouse->events.button.registerListener([this](std::any d) { auto E = std::any_cast<Aquamarine::IPointer::SButtonEvent>(d); - pointerEvents.button.emit(SButtonEvent{ + m_pointerEvents.button.emit(SButtonEvent{ .timeMs = E.timeMs, .button = E.button, .state = E.pressed ? WL_POINTER_BUTTON_STATE_PRESSED : WL_POINTER_BUTTON_STATE_RELEASED, @@ -57,10 +57,10 @@ CMouse::CMouse(SP<Aquamarine::IPointer> mouse_) : mouse(mouse_) { }); }); - listeners.axis = mouse->events.axis.registerListener([this](std::any d) { + m_listeners.axis = m_mouse->events.axis.registerListener([this](std::any d) { auto E = std::any_cast<Aquamarine::IPointer::SAxisEvent>(d); - pointerEvents.axis.emit(SAxisEvent{ + m_pointerEvents.axis.emit(SAxisEvent{ .timeMs = E.timeMs, .source = (wl_pointer_axis_source)E.source, .axis = (wl_pointer_axis)E.axis, @@ -71,58 +71,58 @@ CMouse::CMouse(SP<Aquamarine::IPointer> mouse_) : mouse(mouse_) { }); }); - listeners.frame = mouse->events.frame.registerListener([this](std::any d) { pointerEvents.frame.emit(); }); + m_listeners.frame = m_mouse->events.frame.registerListener([this](std::any d) { m_pointerEvents.frame.emit(); }); - listeners.swipeBegin = mouse->events.swipeBegin.registerListener([this](std::any d) { + m_listeners.swipeBegin = m_mouse->events.swipeBegin.registerListener([this](std::any d) { auto E = std::any_cast<Aquamarine::IPointer::SSwipeBeginEvent>(d); - pointerEvents.swipeBegin.emit(SSwipeBeginEvent{ + m_pointerEvents.swipeBegin.emit(SSwipeBeginEvent{ .timeMs = E.timeMs, .fingers = E.fingers, }); }); - listeners.swipeEnd = mouse->events.swipeEnd.registerListener([this](std::any d) { + m_listeners.swipeEnd = m_mouse->events.swipeEnd.registerListener([this](std::any d) { auto E = std::any_cast<Aquamarine::IPointer::SSwipeEndEvent>(d); - pointerEvents.swipeEnd.emit(SSwipeEndEvent{ + m_pointerEvents.swipeEnd.emit(SSwipeEndEvent{ .timeMs = E.timeMs, .cancelled = E.cancelled, }); }); - listeners.swipeUpdate = mouse->events.swipeUpdate.registerListener([this](std::any d) { + m_listeners.swipeUpdate = m_mouse->events.swipeUpdate.registerListener([this](std::any d) { auto E = std::any_cast<Aquamarine::IPointer::SSwipeUpdateEvent>(d); - pointerEvents.swipeUpdate.emit(SSwipeUpdateEvent{ + m_pointerEvents.swipeUpdate.emit(SSwipeUpdateEvent{ .timeMs = E.timeMs, .fingers = E.fingers, .delta = E.delta, }); }); - listeners.pinchBegin = mouse->events.pinchBegin.registerListener([this](std::any d) { + m_listeners.pinchBegin = m_mouse->events.pinchBegin.registerListener([this](std::any d) { auto E = std::any_cast<Aquamarine::IPointer::SPinchBeginEvent>(d); - pointerEvents.pinchBegin.emit(SPinchBeginEvent{ + m_pointerEvents.pinchBegin.emit(SPinchBeginEvent{ .timeMs = E.timeMs, .fingers = E.fingers, }); }); - listeners.pinchEnd = mouse->events.pinchEnd.registerListener([this](std::any d) { + m_listeners.pinchEnd = m_mouse->events.pinchEnd.registerListener([this](std::any d) { auto E = std::any_cast<Aquamarine::IPointer::SPinchEndEvent>(d); - pointerEvents.pinchEnd.emit(SPinchEndEvent{ + m_pointerEvents.pinchEnd.emit(SPinchEndEvent{ .timeMs = E.timeMs, .cancelled = E.cancelled, }); }); - listeners.pinchUpdate = mouse->events.pinchUpdate.registerListener([this](std::any d) { + m_listeners.pinchUpdate = m_mouse->events.pinchUpdate.registerListener([this](std::any d) { auto E = std::any_cast<Aquamarine::IPointer::SPinchUpdateEvent>(d); - pointerEvents.pinchUpdate.emit(SPinchUpdateEvent{ + m_pointerEvents.pinchUpdate.emit(SPinchUpdateEvent{ .timeMs = E.timeMs, .fingers = E.fingers, .delta = E.delta, @@ -131,25 +131,25 @@ CMouse::CMouse(SP<Aquamarine::IPointer> mouse_) : mouse(mouse_) { }); }); - listeners.holdBegin = mouse->events.holdBegin.registerListener([this](std::any d) { + m_listeners.holdBegin = m_mouse->events.holdBegin.registerListener([this](std::any d) { auto E = std::any_cast<Aquamarine::IPointer::SHoldBeginEvent>(d); - pointerEvents.holdBegin.emit(SHoldBeginEvent{ + m_pointerEvents.holdBegin.emit(SHoldBeginEvent{ .timeMs = E.timeMs, .fingers = E.fingers, }); }); - listeners.holdEnd = mouse->events.holdEnd.registerListener([this](std::any d) { + m_listeners.holdEnd = m_mouse->events.holdEnd.registerListener([this](std::any d) { auto E = std::any_cast<Aquamarine::IPointer::SHoldEndEvent>(d); - pointerEvents.holdEnd.emit(SHoldEndEvent{ + m_pointerEvents.holdEnd.emit(SHoldEndEvent{ .timeMs = E.timeMs, .cancelled = E.cancelled, }); }); - deviceName = mouse->getName(); + m_deviceName = m_mouse->getName(); } bool CMouse::isVirtual() { @@ -157,5 +157,5 @@ bool CMouse::isVirtual() { } SP<Aquamarine::IPointer> CMouse::aq() { - return mouse.lock(); + return m_mouse.lock(); } diff --git a/src/devices/Mouse.hpp b/src/devices/Mouse.hpp index 2b51fbe9..f99b663e 100644 --- a/src/devices/Mouse.hpp +++ b/src/devices/Mouse.hpp @@ -12,7 +12,7 @@ class CMouse : public IPointer { private: CMouse(SP<Aquamarine::IPointer> mouse); - WP<Aquamarine::IPointer> mouse; + WP<Aquamarine::IPointer> m_mouse; struct { CHyprSignalListener destroy; @@ -33,5 +33,5 @@ class CMouse : public IPointer { CHyprSignalListener holdBegin; CHyprSignalListener holdEnd; - } listeners; + } m_listeners; }; diff --git a/src/devices/Tablet.cpp b/src/devices/Tablet.cpp index 99e436fb..e4c399c9 100644 --- a/src/devices/Tablet.cpp +++ b/src/devices/Tablet.cpp @@ -7,7 +7,7 @@ SP<CTablet> CTablet::create(SP<Aquamarine::ITablet> tablet) { SP<CTablet> pTab = SP<CTablet>(new CTablet(tablet)); - pTab->self = pTab; + pTab->m_self = pTab; PROTO::tablet->registerDevice(pTab); @@ -17,7 +17,7 @@ SP<CTablet> CTablet::create(SP<Aquamarine::ITablet> tablet) { SP<CTabletTool> CTabletTool::create(SP<Aquamarine::ITabletTool> tablet) { SP<CTabletTool> pTab = SP<CTabletTool>(new CTabletTool(tablet)); - pTab->self = pTab; + pTab->m_self = pTab; PROTO::tablet->registerDevice(pTab); @@ -27,7 +27,7 @@ SP<CTabletTool> CTabletTool::create(SP<Aquamarine::ITabletTool> tablet) { SP<CTabletPad> CTabletPad::create(SP<Aquamarine::ITabletPad> tablet) { SP<CTabletPad> pTab = SP<CTabletPad>(new CTabletPad(tablet)); - pTab->self = pTab; + pTab->m_self = pTab; PROTO::tablet->registerDevice(pTab); @@ -62,24 +62,24 @@ uint32_t CTablet::getCapabilities() { } SP<Aquamarine::ITablet> CTablet::aq() { - return tablet.lock(); + return m_tablet.lock(); } -CTablet::CTablet(SP<Aquamarine::ITablet> tablet_) : tablet(tablet_) { - if (!tablet) +CTablet::CTablet(SP<Aquamarine::ITablet> tablet_) : m_tablet(tablet_) { + if (!m_tablet) return; - listeners.destroy = tablet->events.destroy.registerListener([this](std::any d) { - tablet.reset(); - events.destroy.emit(); + m_listeners.destroy = m_tablet->events.destroy.registerListener([this](std::any d) { + m_tablet.reset(); + m_events.destroy.emit(); }); - listeners.axis = tablet->events.axis.registerListener([this](std::any d) { + m_listeners.axis = m_tablet->events.axis.registerListener([this](std::any d) { auto E = std::any_cast<Aquamarine::ITablet::SAxisEvent>(d); - tabletEvents.axis.emit(SAxisEvent{ + m_tabletEvents.axis.emit(SAxisEvent{ .tool = E.tool, - .tablet = self.lock(), + .tablet = m_self.lock(), .timeMs = E.timeMs, .updatedAxes = aqUpdateToHl(E.updatedAxes), .axis = E.absolute, @@ -93,43 +93,43 @@ CTablet::CTablet(SP<Aquamarine::ITablet> tablet_) : tablet(tablet_) { }); }); - listeners.proximity = tablet->events.proximity.registerListener([this](std::any d) { + m_listeners.proximity = m_tablet->events.proximity.registerListener([this](std::any d) { auto E = std::any_cast<Aquamarine::ITablet::SProximityEvent>(d); - tabletEvents.proximity.emit(SProximityEvent{ + m_tabletEvents.proximity.emit(SProximityEvent{ .tool = E.tool, - .tablet = self.lock(), + .tablet = m_self.lock(), .timeMs = E.timeMs, .proximity = E.absolute, .in = E.in, }); }); - listeners.tip = tablet->events.tip.registerListener([this](std::any d) { + m_listeners.tip = m_tablet->events.tip.registerListener([this](std::any d) { auto E = std::any_cast<Aquamarine::ITablet::STipEvent>(d); - tabletEvents.tip.emit(STipEvent{ + m_tabletEvents.tip.emit(STipEvent{ .tool = E.tool, - .tablet = self.lock(), + .tablet = m_self.lock(), .timeMs = E.timeMs, .tip = E.absolute, .in = E.down, }); }); - listeners.button = tablet->events.button.registerListener([this](std::any d) { + m_listeners.button = m_tablet->events.button.registerListener([this](std::any d) { auto E = std::any_cast<Aquamarine::ITablet::SButtonEvent>(d); - tabletEvents.button.emit(SButtonEvent{ + m_tabletEvents.button.emit(SButtonEvent{ .tool = E.tool, - .tablet = self.lock(), + .tablet = m_self.lock(), .timeMs = E.timeMs, .button = E.button, .down = E.down, }); }); - deviceName = tablet->getName(); + m_deviceName = m_tablet->getName(); } CTablet::~CTablet() { @@ -145,26 +145,26 @@ uint32_t CTabletPad::getCapabilities() { } SP<Aquamarine::ITabletPad> CTabletPad::aq() { - return pad.lock(); + return m_pad.lock(); } eHIDType CTabletPad::getType() { return HID_TYPE_TABLET_PAD; } -CTabletPad::CTabletPad(SP<Aquamarine::ITabletPad> pad_) : pad(pad_) { - if (!pad) +CTabletPad::CTabletPad(SP<Aquamarine::ITabletPad> pad_) : m_pad(pad_) { + if (!m_pad) return; - listeners.destroy = pad->events.destroy.registerListener([this](std::any d) { - pad.reset(); - events.destroy.emit(); + m_listeners.destroy = m_pad->events.destroy.registerListener([this](std::any d) { + m_pad.reset(); + m_events.destroy.emit(); }); - listeners.button = pad->events.button.registerListener([this](std::any d) { + m_listeners.button = m_pad->events.button.registerListener([this](std::any d) { auto E = std::any_cast<Aquamarine::ITabletPad::SButtonEvent>(d); - padEvents.button.emit(SButtonEvent{ + m_padEvents.button.emit(SButtonEvent{ .timeMs = E.timeMs, .button = E.button, .down = E.down, @@ -173,10 +173,10 @@ CTabletPad::CTabletPad(SP<Aquamarine::ITabletPad> pad_) : pad(pad_) { }); }); - listeners.ring = pad->events.ring.registerListener([this](std::any d) { + m_listeners.ring = m_pad->events.ring.registerListener([this](std::any d) { auto E = std::any_cast<Aquamarine::ITabletPad::SRingEvent>(d); - padEvents.ring.emit(SRingEvent{ + m_padEvents.ring.emit(SRingEvent{ .timeMs = E.timeMs, .finger = E.source == Aquamarine::ITabletPad::AQ_TABLET_PAD_RING_SOURCE_FINGER, .ring = E.ring, @@ -185,10 +185,10 @@ CTabletPad::CTabletPad(SP<Aquamarine::ITabletPad> pad_) : pad(pad_) { }); }); - listeners.strip = pad->events.strip.registerListener([this](std::any d) { + m_listeners.strip = m_pad->events.strip.registerListener([this](std::any d) { auto E = std::any_cast<Aquamarine::ITabletPad::SStripEvent>(d); - padEvents.strip.emit(SStripEvent{ + m_padEvents.strip.emit(SStripEvent{ .timeMs = E.timeMs, .finger = E.source == Aquamarine::ITabletPad::AQ_TABLET_PAD_STRIP_SOURCE_FINGER, .strip = E.strip, @@ -197,11 +197,11 @@ CTabletPad::CTabletPad(SP<Aquamarine::ITabletPad> pad_) : pad(pad_) { }); }); - listeners.attach = pad->events.attach.registerListener([](std::any d) { + m_listeners.attach = m_pad->events.attach.registerListener([](std::any d) { ; // TODO: this doesn't do anything in aq atm }); - deviceName = pad->getName(); + m_deviceName = m_pad->getName(); } CTabletPad::~CTabletPad() { @@ -213,36 +213,36 @@ uint32_t CTabletTool::getCapabilities() { } SP<Aquamarine::ITabletTool> CTabletTool::aq() { - return tool.lock(); + return m_tool.lock(); } eHIDType CTabletTool::getType() { return HID_TYPE_TABLET_TOOL; } -CTabletTool::CTabletTool(SP<Aquamarine::ITabletTool> tool_) : tool(tool_) { - if (!tool) +CTabletTool::CTabletTool(SP<Aquamarine::ITabletTool> tool_) : m_tool(tool_) { + if (!m_tool) return; - listeners.destroyTool = tool->events.destroy.registerListener([this](std::any d) { - tool.reset(); - events.destroy.emit(); + m_listeners.destroyTool = m_tool->events.destroy.registerListener([this](std::any d) { + m_tool.reset(); + m_events.destroy.emit(); }); - if (tool->capabilities & Aquamarine::ITabletTool::AQ_TABLET_TOOL_CAPABILITY_TILT) - toolCapabilities |= HID_TABLET_TOOL_CAPABILITY_TILT; - if (tool->capabilities & Aquamarine::ITabletTool::AQ_TABLET_TOOL_CAPABILITY_PRESSURE) - toolCapabilities |= HID_TABLET_TOOL_CAPABILITY_PRESSURE; - if (tool->capabilities & Aquamarine::ITabletTool::AQ_TABLET_TOOL_CAPABILITY_DISTANCE) - toolCapabilities |= HID_TABLET_TOOL_CAPABILITY_DISTANCE; - if (tool->capabilities & Aquamarine::ITabletTool::AQ_TABLET_TOOL_CAPABILITY_ROTATION) - toolCapabilities |= HID_TABLET_TOOL_CAPABILITY_ROTATION; - if (tool->capabilities & Aquamarine::ITabletTool::AQ_TABLET_TOOL_CAPABILITY_SLIDER) - toolCapabilities |= HID_TABLET_TOOL_CAPABILITY_SLIDER; - if (tool->capabilities & Aquamarine::ITabletTool::AQ_TABLET_TOOL_CAPABILITY_WHEEL) - toolCapabilities |= HID_TABLET_TOOL_CAPABILITY_WHEEL; - - deviceName = std::format("{:x}-{:x}", tool->serial, tool->id); + if (m_tool->capabilities & Aquamarine::ITabletTool::AQ_TABLET_TOOL_CAPABILITY_TILT) + m_toolCapabilities |= HID_TABLET_TOOL_CAPABILITY_TILT; + if (m_tool->capabilities & Aquamarine::ITabletTool::AQ_TABLET_TOOL_CAPABILITY_PRESSURE) + m_toolCapabilities |= HID_TABLET_TOOL_CAPABILITY_PRESSURE; + if (m_tool->capabilities & Aquamarine::ITabletTool::AQ_TABLET_TOOL_CAPABILITY_DISTANCE) + m_toolCapabilities |= HID_TABLET_TOOL_CAPABILITY_DISTANCE; + if (m_tool->capabilities & Aquamarine::ITabletTool::AQ_TABLET_TOOL_CAPABILITY_ROTATION) + m_toolCapabilities |= HID_TABLET_TOOL_CAPABILITY_ROTATION; + if (m_tool->capabilities & Aquamarine::ITabletTool::AQ_TABLET_TOOL_CAPABILITY_SLIDER) + m_toolCapabilities |= HID_TABLET_TOOL_CAPABILITY_SLIDER; + if (m_tool->capabilities & Aquamarine::ITabletTool::AQ_TABLET_TOOL_CAPABILITY_WHEEL) + m_toolCapabilities |= HID_TABLET_TOOL_CAPABILITY_WHEEL; + + m_deviceName = std::format("{:x}-{:x}", m_tool->serial, m_tool->id); } CTabletTool::~CTabletTool() { @@ -250,25 +250,25 @@ CTabletTool::~CTabletTool() { } SP<CWLSurfaceResource> CTabletTool::getSurface() { - return pSurface.lock(); + return m_surface.lock(); } void CTabletTool::setSurface(SP<CWLSurfaceResource> surf) { - if (surf == pSurface) + if (surf == m_surface) return; - if (pSurface) { - listeners.destroySurface.reset(); - pSurface.reset(); + if (m_surface) { + m_listeners.destroySurface.reset(); + m_surface.reset(); } - pSurface = surf; + m_surface = surf; if (surf) { - listeners.destroySurface = surf->events.destroy.registerListener([this](std::any d) { - PROTO::tablet->proximityOut(self.lock()); - pSurface.reset(); - listeners.destroySurface.reset(); + m_listeners.destroySurface = surf->events.destroy.registerListener([this](std::any d) { + PROTO::tablet->proximityOut(m_self.lock()); + m_surface.reset(); + m_listeners.destroySurface.reset(); }); } } diff --git a/src/devices/Tablet.hpp b/src/devices/Tablet.hpp index c3a9a2c9..b98c7f85 100644 --- a/src/devices/Tablet.hpp +++ b/src/devices/Tablet.hpp @@ -86,20 +86,20 @@ class CTablet : public IHID { CSignal proximity; CSignal tip; CSignal button; - } tabletEvents; + } m_tabletEvents; - WP<CTablet> self; + WP<CTablet> m_self; - bool relativeInput = false; - bool absolutePos = false; - std::string boundOutput = ""; - CBox activeArea; - CBox boundBox; + bool m_relativeInput = false; + bool m_absolutePos = false; + std::string m_boundOutput = ""; + CBox m_activeArea; + CBox m_boundBox; private: CTablet(SP<Aquamarine::ITablet> tablet); - WP<Aquamarine::ITablet> tablet; + WP<Aquamarine::ITablet> m_tablet; struct { CHyprSignalListener destroy; @@ -107,7 +107,7 @@ class CTablet : public IHID { CHyprSignalListener proximity; CHyprSignalListener tip; CHyprSignalListener button; - } listeners; + } m_listeners; }; class CTabletPad : public IHID { @@ -148,15 +148,15 @@ class CTabletPad : public IHID { CSignal ring; CSignal strip; CSignal attach; - } padEvents; + } m_padEvents; - WP<CTabletPad> self; - WP<CTabletTool> parent; + WP<CTabletPad> m_self; + WP<CTabletTool> m_parent; private: CTabletPad(SP<Aquamarine::ITabletPad> pad); - WP<Aquamarine::ITabletPad> pad; + WP<Aquamarine::ITabletPad> m_pad; struct { CHyprSignalListener destroy; @@ -164,7 +164,7 @@ class CTabletPad : public IHID { CHyprSignalListener strip; CHyprSignalListener button; CHyprSignalListener attach; - } listeners; + } m_listeners; }; class CTabletTool : public IHID { @@ -198,23 +198,23 @@ class CTabletTool : public IHID { SP<CWLSurfaceResource> getSurface(); void setSurface(SP<CWLSurfaceResource>); - WP<CTabletTool> self; - Vector2D tilt; - bool active = false; // true if in proximity - uint32_t toolCapabilities = 0; + WP<CTabletTool> m_self; + Vector2D m_tilt; + bool m_active = false; // true if in proximity + uint32_t m_toolCapabilities = 0; - bool isDown = false; - std::vector<uint32_t> buttonsDown; - Vector2D absolutePos; // last known absolute position. + bool m_isDown = false; + std::vector<uint32_t> m_buttonsDown; + Vector2D m_absolutePos; // last known absolute position. private: CTabletTool(SP<Aquamarine::ITabletTool> tool); - WP<CWLSurfaceResource> pSurface; - WP<Aquamarine::ITabletTool> tool; + WP<CWLSurfaceResource> m_surface; + WP<Aquamarine::ITabletTool> m_tool; struct { CHyprSignalListener destroySurface; CHyprSignalListener destroyTool; - } listeners; + } m_listeners; };
\ No newline at end of file diff --git a/src/devices/TouchDevice.cpp b/src/devices/TouchDevice.cpp index 25b7b503..c2ff4d6f 100644 --- a/src/devices/TouchDevice.cpp +++ b/src/devices/TouchDevice.cpp @@ -5,62 +5,62 @@ SP<CTouchDevice> CTouchDevice::create(SP<Aquamarine::ITouch> touch) { SP<CTouchDevice> pTouch = SP<CTouchDevice>(new CTouchDevice(touch)); - pTouch->self = pTouch; + pTouch->m_self = pTouch; return pTouch; } -CTouchDevice::CTouchDevice(SP<Aquamarine::ITouch> touch_) : touch(touch_) { - if (!touch) +CTouchDevice::CTouchDevice(SP<Aquamarine::ITouch> touch_) : m_touch(touch_) { + if (!m_touch) return; - listeners.destroy = touch->events.destroy.registerListener([this](std::any d) { - events.destroy.emit(); - touch.reset(); + m_listeners.destroy = m_touch->events.destroy.registerListener([this](std::any d) { + m_events.destroy.emit(); + m_touch.reset(); }); - listeners.down = touch->events.down.registerListener([this](std::any d) { + m_listeners.down = m_touch->events.down.registerListener([this](std::any d) { auto E = std::any_cast<Aquamarine::ITouch::SDownEvent>(d); - touchEvents.down.emit(SDownEvent{ + m_touchEvents.down.emit(SDownEvent{ .timeMs = E.timeMs, .touchID = E.touchID, .pos = E.pos, - .device = self.lock(), + .device = m_self.lock(), }); }); - listeners.up = touch->events.up.registerListener([this](std::any d) { + m_listeners.up = m_touch->events.up.registerListener([this](std::any d) { auto E = std::any_cast<Aquamarine::ITouch::SUpEvent>(d); - touchEvents.up.emit(SUpEvent{ + m_touchEvents.up.emit(SUpEvent{ .timeMs = E.timeMs, .touchID = E.touchID, }); }); - listeners.motion = touch->events.move.registerListener([this](std::any d) { + m_listeners.motion = m_touch->events.move.registerListener([this](std::any d) { auto E = std::any_cast<Aquamarine::ITouch::SMotionEvent>(d); - touchEvents.motion.emit(SMotionEvent{ + m_touchEvents.motion.emit(SMotionEvent{ .timeMs = E.timeMs, .touchID = E.touchID, .pos = E.pos, }); }); - listeners.cancel = touch->events.cancel.registerListener([this](std::any d) { + m_listeners.cancel = m_touch->events.cancel.registerListener([this](std::any d) { auto E = std::any_cast<Aquamarine::ITouch::SCancelEvent>(d); - touchEvents.cancel.emit(SCancelEvent{ + m_touchEvents.cancel.emit(SCancelEvent{ .timeMs = E.timeMs, .touchID = E.touchID, }); }); - listeners.frame = touch->events.frame.registerListener([this](std::any d) { touchEvents.frame.emit(); }); + m_listeners.frame = m_touch->events.frame.registerListener([this](std::any d) { m_touchEvents.frame.emit(); }); - deviceName = touch->getName(); + m_deviceName = m_touch->getName(); } bool CTouchDevice::isVirtual() { @@ -68,5 +68,5 @@ bool CTouchDevice::isVirtual() { } SP<Aquamarine::ITouch> CTouchDevice::aq() { - return touch.lock(); + return m_touch.lock(); } diff --git a/src/devices/TouchDevice.hpp b/src/devices/TouchDevice.hpp index b18df2d0..9b32077d 100644 --- a/src/devices/TouchDevice.hpp +++ b/src/devices/TouchDevice.hpp @@ -12,7 +12,7 @@ class CTouchDevice : public ITouch { private: CTouchDevice(SP<Aquamarine::ITouch> touch); - WP<Aquamarine::ITouch> touch; + WP<Aquamarine::ITouch> m_touch; struct { CHyprSignalListener destroy; @@ -21,5 +21,5 @@ class CTouchDevice : public ITouch { CHyprSignalListener motion; CHyprSignalListener cancel; CHyprSignalListener frame; - } listeners; + } m_listeners; };
\ No newline at end of file diff --git a/src/devices/VirtualKeyboard.cpp b/src/devices/VirtualKeyboard.cpp index 548711c2..4fb25b5b 100644 --- a/src/devices/VirtualKeyboard.cpp +++ b/src/devices/VirtualKeyboard.cpp @@ -5,43 +5,43 @@ SP<CVirtualKeyboard> CVirtualKeyboard::create(SP<CVirtualKeyboardV1Resource> keeb) { SP<CVirtualKeyboard> pKeeb = SP<CVirtualKeyboard>(new CVirtualKeyboard(keeb)); - pKeeb->self = pKeeb; + pKeeb->m_self = pKeeb; return pKeeb; } -CVirtualKeyboard::CVirtualKeyboard(SP<CVirtualKeyboardV1Resource> keeb_) : keyboard(keeb_) { +CVirtualKeyboard::CVirtualKeyboard(SP<CVirtualKeyboardV1Resource> keeb_) : m_keyboard(keeb_) { if (!keeb_) return; - listeners.destroy = keeb_->events.destroy.registerListener([this](std::any d) { - keyboard.reset(); - events.destroy.emit(); + m_listeners.destroy = keeb_->events.destroy.registerListener([this](std::any d) { + m_keyboard.reset(); + m_events.destroy.emit(); }); - listeners.key = keeb_->events.key.registerListener([this](std::any d) { keyboardEvents.key.emit(d); }); - listeners.modifiers = keeb_->events.modifiers.registerListener([this](std::any d) { + m_listeners.key = keeb_->events.key.registerListener([this](std::any d) { m_keyboardEvents.key.emit(d); }); + m_listeners.modifiers = keeb_->events.modifiers.registerListener([this](std::any d) { auto E = std::any_cast<SModifiersEvent>(d); updateModifiers(E.depressed, E.latched, E.locked, E.group); - keyboardEvents.modifiers.emit(SModifiersEvent{ - .depressed = modifiersState.depressed, - .latched = modifiersState.latched, - .locked = modifiersState.locked, - .group = modifiersState.group, + m_keyboardEvents.modifiers.emit(SModifiersEvent{ + .depressed = m_modifiersState.depressed, + .latched = m_modifiersState.latched, + .locked = m_modifiersState.locked, + .group = m_modifiersState.group, }); }); - listeners.keymap = keeb_->events.keymap.registerListener([this](std::any d) { + m_listeners.keymap = keeb_->events.keymap.registerListener([this](std::any d) { auto E = std::any_cast<SKeymapEvent>(d); - if (xkbKeymap) - xkb_keymap_unref(xkbKeymap); - xkbKeymap = xkb_keymap_ref(E.keymap); - keymapOverridden = true; - updateXKBTranslationState(xkbKeymap); + if (m_xkbKeymap) + xkb_keymap_unref(m_xkbKeymap); + m_xkbKeymap = xkb_keymap_ref(E.keymap); + m_keymapOverridden = true; + updateXKBTranslationState(m_xkbKeymap); updateKeymapFD(); - keyboardEvents.keymap.emit(d); + m_keyboardEvents.keymap.emit(d); }); - deviceName = keeb_->name; + m_deviceName = keeb_->name; } bool CVirtualKeyboard::isVirtual() { @@ -53,7 +53,7 @@ SP<Aquamarine::IKeyboard> CVirtualKeyboard::aq() { } wl_client* CVirtualKeyboard::getClient() { - if (keyboard.expired()) + if (m_keyboard.expired()) return nullptr; - return keyboard->client(); + return m_keyboard->client(); } diff --git a/src/devices/VirtualKeyboard.hpp b/src/devices/VirtualKeyboard.hpp index 12a3907c..05e0a255 100644 --- a/src/devices/VirtualKeyboard.hpp +++ b/src/devices/VirtualKeyboard.hpp @@ -16,12 +16,12 @@ class CVirtualKeyboard : public IKeyboard { private: CVirtualKeyboard(SP<CVirtualKeyboardV1Resource> keeb); - WP<CVirtualKeyboardV1Resource> keyboard; + WP<CVirtualKeyboardV1Resource> m_keyboard; struct { CHyprSignalListener destroy; CHyprSignalListener key; CHyprSignalListener modifiers; CHyprSignalListener keymap; - } listeners; + } m_listeners; }; diff --git a/src/devices/VirtualPointer.cpp b/src/devices/VirtualPointer.cpp index e98acd04..1aaf8b10 100644 --- a/src/devices/VirtualPointer.cpp +++ b/src/devices/VirtualPointer.cpp @@ -5,46 +5,46 @@ SP<CVirtualPointer> CVirtualPointer::create(SP<CVirtualPointerV1Resource> resource) { SP<CVirtualPointer> pPointer = SP<CVirtualPointer>(new CVirtualPointer(resource)); - pPointer->self = pPointer; + pPointer->m_self = pPointer; return pPointer; } -CVirtualPointer::CVirtualPointer(SP<CVirtualPointerV1Resource> resource) : pointer(resource) { +CVirtualPointer::CVirtualPointer(SP<CVirtualPointerV1Resource> resource) : m_pointer(resource) { if UNLIKELY (!resource->good()) return; - listeners.destroy = pointer->events.destroy.registerListener([this](std::any d) { - pointer.reset(); - events.destroy.emit(); + m_listeners.destroy = m_pointer->events.destroy.registerListener([this](std::any d) { + m_pointer.reset(); + m_events.destroy.emit(); }); - listeners.motion = pointer->events.move.registerListener([this](std::any d) { + m_listeners.motion = m_pointer->events.move.registerListener([this](std::any d) { auto E = std::any_cast<SMotionEvent>(d); - E.device = self.lock(); - pointerEvents.motion.emit(E); + E.device = m_self.lock(); + m_pointerEvents.motion.emit(E); }); - listeners.motionAbsolute = pointer->events.warp.registerListener([this](std::any d) { + m_listeners.motionAbsolute = m_pointer->events.warp.registerListener([this](std::any d) { // we need to unpack the event and add our device here because it's required to calculate the position correctly auto E = std::any_cast<SMotionAbsoluteEvent>(d); - E.device = self.lock(); - pointerEvents.motionAbsolute.emit(E); + E.device = m_self.lock(); + m_pointerEvents.motionAbsolute.emit(E); }); - listeners.button = pointer->events.button.registerListener([this](std::any d) { pointerEvents.button.emit(d); }); - listeners.axis = pointer->events.axis.registerListener([this](std::any d) { pointerEvents.axis.emit(d); }); - listeners.frame = pointer->events.frame.registerListener([this](std::any d) { pointerEvents.frame.emit(); }); - listeners.swipeBegin = pointer->events.swipeBegin.registerListener([this](std::any d) { pointerEvents.swipeBegin.emit(d); }); - listeners.swipeEnd = pointer->events.swipeEnd.registerListener([this](std::any d) { pointerEvents.swipeEnd.emit(d); }); - listeners.swipeUpdate = pointer->events.swipeUpdate.registerListener([this](std::any d) { pointerEvents.swipeUpdate.emit(d); }); - listeners.pinchBegin = pointer->events.pinchBegin.registerListener([this](std::any d) { pointerEvents.pinchBegin.emit(d); }); - listeners.pinchEnd = pointer->events.pinchEnd.registerListener([this](std::any d) { pointerEvents.pinchEnd.emit(d); }); - listeners.pinchUpdate = pointer->events.pinchUpdate.registerListener([this](std::any d) { pointerEvents.pinchUpdate.emit(d); }); - listeners.holdBegin = pointer->events.holdBegin.registerListener([this](std::any d) { pointerEvents.holdBegin.emit(d); }); - listeners.holdEnd = pointer->events.holdEnd.registerListener([this](std::any d) { pointerEvents.holdEnd.emit(d); }); - - boundOutput = resource->boundOutput ? resource->boundOutput->szName : ""; - - deviceName = pointer->name; + m_listeners.button = m_pointer->events.button.registerListener([this](std::any d) { m_pointerEvents.button.emit(d); }); + m_listeners.axis = m_pointer->events.axis.registerListener([this](std::any d) { m_pointerEvents.axis.emit(d); }); + m_listeners.frame = m_pointer->events.frame.registerListener([this](std::any d) { m_pointerEvents.frame.emit(); }); + m_listeners.swipeBegin = m_pointer->events.swipeBegin.registerListener([this](std::any d) { m_pointerEvents.swipeBegin.emit(d); }); + m_listeners.swipeEnd = m_pointer->events.swipeEnd.registerListener([this](std::any d) { m_pointerEvents.swipeEnd.emit(d); }); + m_listeners.swipeUpdate = m_pointer->events.swipeUpdate.registerListener([this](std::any d) { m_pointerEvents.swipeUpdate.emit(d); }); + m_listeners.pinchBegin = m_pointer->events.pinchBegin.registerListener([this](std::any d) { m_pointerEvents.pinchBegin.emit(d); }); + m_listeners.pinchEnd = m_pointer->events.pinchEnd.registerListener([this](std::any d) { m_pointerEvents.pinchEnd.emit(d); }); + m_listeners.pinchUpdate = m_pointer->events.pinchUpdate.registerListener([this](std::any d) { m_pointerEvents.pinchUpdate.emit(d); }); + m_listeners.holdBegin = m_pointer->events.holdBegin.registerListener([this](std::any d) { m_pointerEvents.holdBegin.emit(d); }); + m_listeners.holdEnd = m_pointer->events.holdEnd.registerListener([this](std::any d) { m_pointerEvents.holdEnd.emit(d); }); + + m_boundOutput = resource->boundOutput ? resource->boundOutput->szName : ""; + + m_deviceName = m_pointer->name; } bool CVirtualPointer::isVirtual() { diff --git a/src/devices/VirtualPointer.hpp b/src/devices/VirtualPointer.hpp index 1ecfd842..9eacbd5f 100644 --- a/src/devices/VirtualPointer.hpp +++ b/src/devices/VirtualPointer.hpp @@ -14,7 +14,7 @@ class CVirtualPointer : public IPointer { private: CVirtualPointer(SP<CVirtualPointerV1Resource>); - WP<CVirtualPointerV1Resource> pointer; + WP<CVirtualPointerV1Resource> m_pointer; struct { CHyprSignalListener destroy; @@ -35,5 +35,5 @@ class CVirtualPointer : public IPointer { CHyprSignalListener holdBegin; CHyprSignalListener holdEnd; - } listeners; + } m_listeners; };
\ No newline at end of file |
