diff options
| author | Vaxry <43317083+vaxerski@users.noreply.github.com> | 2026-03-20 13:52:37 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-20 17:52:37 +0000 |
| commit | 8726a7363eb9213235e6e23657668e0daac39a5b (patch) | |
| tree | 42eeb40f6f81a9ccec1455f308e56173e9dcce4b /src/managers/input/InputManager.cpp | |
| parent | b940b0d2c197841b0f648598ee782dbaf9e0a89b (diff) | |
config: cleanup the entire config infrastructure (#13785)
Massively refactors the config infrastructure, sorely
needed and will be req'd for the lua stuff
Diffstat (limited to 'src/managers/input/InputManager.cpp')
| -rw-r--r-- | src/managers/input/InputManager.cpp | 107 |
1 files changed, 55 insertions, 52 deletions
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 109bce68..81383b58 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -6,7 +6,7 @@ #include <ranges> #include <algorithm> #include "../../config/ConfigValue.hpp" -#include "../../config/ConfigManager.hpp" +#include "../../config/legacy/ConfigManager.hpp" #include "../../desktop/view/WLSurface.hpp" #include "../../desktop/state/FocusState.hpp" #include "../../protocols/CursorShape.hpp" @@ -49,6 +49,10 @@ #include "../cursor/CursorShapeOverrideController.hpp" #include <aquamarine/input/Input.hpp> +#include <hyprutils/string/VarList.hpp> +#include <hyprutils/string/VarList2.hpp> + +using namespace Hyprutils::String; CInputManager::CInputManager() { m_listeners.setCursorShape = PROTO::cursorShape->m_events.setShape.listen([this](const CCursorShapeProtocol::SSetShapeEvent& event) { @@ -1097,25 +1101,25 @@ void CInputManager::setKeyboardLayout() { void CInputManager::applyConfigToKeyboard(SP<IKeyboard> pKeyboard) { auto devname = pKeyboard->m_hlName; - const auto HASCONFIG = g_pConfigManager->deviceConfigExists(devname); + const auto HASCONFIG = Config::mgr()->deviceConfigExists(devname); Log::logger->log(Log::DEBUG, "ApplyConfigToKeyboard for \"{}\", hasconfig: {}", devname, sc<int>(HASCONFIG)); - const auto REPEATRATE = g_pConfigManager->getDeviceInt(devname, "repeat_rate", "input:repeat_rate"); - const auto REPEATDELAY = g_pConfigManager->getDeviceInt(devname, "repeat_delay", "input:repeat_delay"); + const auto REPEATRATE = Config::mgr()->getDeviceInt(devname, "repeat_rate", "input:repeat_rate"); + const auto REPEATDELAY = Config::mgr()->getDeviceInt(devname, "repeat_delay", "input:repeat_delay"); - const auto NUMLOCKON = g_pConfigManager->getDeviceInt(devname, "numlock_by_default", "input:numlock_by_default"); - const auto RESOLVEBINDSBYSYM = g_pConfigManager->getDeviceInt(devname, "resolve_binds_by_sym", "input:resolve_binds_by_sym"); + const auto NUMLOCKON = Config::mgr()->getDeviceInt(devname, "numlock_by_default", "input:numlock_by_default"); + const auto RESOLVEBINDSBYSYM = Config::mgr()->getDeviceInt(devname, "resolve_binds_by_sym", "input:resolve_binds_by_sym"); - const auto FILEPATH = g_pConfigManager->getDeviceString(devname, "kb_file", "input:kb_file"); - const auto RULES = g_pConfigManager->getDeviceString(devname, "kb_rules", "input:kb_rules"); - const auto MODEL = g_pConfigManager->getDeviceString(devname, "kb_model", "input:kb_model"); - const auto LAYOUT = g_pConfigManager->getDeviceString(devname, "kb_layout", "input:kb_layout"); - const auto VARIANT = g_pConfigManager->getDeviceString(devname, "kb_variant", "input:kb_variant"); - const auto OPTIONS = g_pConfigManager->getDeviceString(devname, "kb_options", "input:kb_options"); + const auto FILEPATH = Config::mgr()->getDeviceString(devname, "kb_file", "input:kb_file"); + const auto RULES = Config::mgr()->getDeviceString(devname, "kb_rules", "input:kb_rules"); + const auto MODEL = Config::mgr()->getDeviceString(devname, "kb_model", "input:kb_model"); + const auto LAYOUT = Config::mgr()->getDeviceString(devname, "kb_layout", "input:kb_layout"); + const auto VARIANT = Config::mgr()->getDeviceString(devname, "kb_variant", "input:kb_variant"); + const auto OPTIONS = Config::mgr()->getDeviceString(devname, "kb_options", "input:kb_options"); - const auto ENABLED = HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "enabled") : true; - const auto ALLOWBINDS = HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "keybinds") : true; + const auto ENABLED = HASCONFIG ? Config::mgr()->getDeviceInt(devname, "enabled") : true; + const auto ALLOWBINDS = HASCONFIG ? Config::mgr()->getDeviceInt(devname, "keybinds") : true; pKeyboard->m_enabled = ENABLED; pKeyboard->m_resolveBindsBySym = RESOLVEBINDSBYSYM; @@ -1232,10 +1236,10 @@ void CInputManager::setPointerConfigs() { for (auto const& m : m_pointers) { auto devname = m->m_hlName; - const auto HASCONFIG = g_pConfigManager->deviceConfigExists(devname); + const auto HASCONFIG = Config::mgr()->deviceConfigExists(devname); if (HASCONFIG) { - const auto ENABLED = g_pConfigManager->getDeviceInt(devname, "enabled"); + const auto ENABLED = Config::mgr()->getDeviceInt(devname, "enabled"); if (ENABLED && !m->m_connected) { g_pPointerManager->attachPointer(m); m->m_connected = true; @@ -1245,8 +1249,8 @@ void CInputManager::setPointerConfigs() { } } - if (g_pConfigManager->deviceConfigExplicitlySet(devname, "scroll_factor")) - m->m_scrollFactor = std::clamp(g_pConfigManager->getDeviceFloat(devname, "scroll_factor", "input:scroll_factor"), 0.F, 100.F); + if (Config::mgr()->deviceConfigExplicitlySet(devname, "scroll_factor")) + m->m_scrollFactor = std::clamp(Config::mgr()->getDeviceFloat(devname, "scroll_factor", "input:scroll_factor"), 0.F, 100.F); else m->m_scrollFactor = std::nullopt; @@ -1257,23 +1261,23 @@ void CInputManager::setPointerConfigs() { const auto ISTOUCHPAD = libinput_device_has_capability(LIBINPUTDEV, LIBINPUT_DEVICE_CAP_POINTER) && libinput_device_get_size(LIBINPUTDEV, &touchw, &touchh) == 0; // pointer with size is a touchpad - if (g_pConfigManager->getDeviceInt(devname, "clickfinger_behavior", "input:touchpad:clickfinger_behavior") == 0) // toggle software buttons or clickfinger + if (Config::mgr()->getDeviceInt(devname, "clickfinger_behavior", "input:touchpad:clickfinger_behavior") == 0) // toggle software buttons or clickfinger libinput_device_config_click_set_method(LIBINPUTDEV, LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS); else libinput_device_config_click_set_method(LIBINPUTDEV, LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER); - if (g_pConfigManager->getDeviceInt(devname, "left_handed", "input:left_handed") == 0) + if (Config::mgr()->getDeviceInt(devname, "left_handed", "input:left_handed") == 0) libinput_device_config_left_handed_set(LIBINPUTDEV, 0); else libinput_device_config_left_handed_set(LIBINPUTDEV, 1); if (libinput_device_config_middle_emulation_is_available(LIBINPUTDEV)) { // middleclick on r+l mouse button pressed - if (g_pConfigManager->getDeviceInt(devname, "middle_button_emulation", "input:touchpad:middle_button_emulation") == 1) + if (Config::mgr()->getDeviceInt(devname, "middle_button_emulation", "input:touchpad:middle_button_emulation") == 1) libinput_device_config_middle_emulation_set_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED); else libinput_device_config_middle_emulation_set_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED); - const auto TAP_MAP = g_pConfigManager->getDeviceString(devname, "tap_button_map", "input:touchpad:tap_button_map"); + const auto TAP_MAP = Config::mgr()->getDeviceString(devname, "tap_button_map", "input:touchpad:tap_button_map"); if (TAP_MAP.empty() || TAP_MAP == "lrm") libinput_device_config_tap_set_button_map(LIBINPUTDEV, LIBINPUT_CONFIG_TAP_MAP_LRM); else if (TAP_MAP == "lmr") @@ -1282,7 +1286,7 @@ void CInputManager::setPointerConfigs() { Log::logger->log(Log::WARN, "Tap button mapping unknown"); } - const auto SCROLLMETHOD = g_pConfigManager->getDeviceString(devname, "scroll_method", "input:scroll_method"); + const auto SCROLLMETHOD = Config::mgr()->getDeviceString(devname, "scroll_method", "input:scroll_method"); if (SCROLLMETHOD.empty()) { libinput_device_config_scroll_set_method(LIBINPUTDEV, libinput_device_config_scroll_get_default_method(LIBINPUTDEV)); } else if (SCROLLMETHOD == "no_scroll") { @@ -1297,53 +1301,52 @@ void CInputManager::setPointerConfigs() { Log::logger->log(Log::WARN, "Scroll method unknown"); } - if (g_pConfigManager->getDeviceInt(devname, "tap-and-drag", "input:touchpad:tap-and-drag") == 0) + if (Config::mgr()->getDeviceInt(devname, "tap-and-drag", "input:touchpad:tap-and-drag") == 0) libinput_device_config_tap_set_drag_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_DRAG_DISABLED); else libinput_device_config_tap_set_drag_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_DRAG_ENABLED); - const auto TAP_DRAG_LOCK = g_pConfigManager->getDeviceInt(devname, "drag_lock", "input:touchpad:drag_lock"); + const auto TAP_DRAG_LOCK = Config::mgr()->getDeviceInt(devname, "drag_lock", "input:touchpad:drag_lock"); if (TAP_DRAG_LOCK >= 0 && TAP_DRAG_LOCK <= 2) { libinput_device_config_tap_set_drag_lock_enabled(LIBINPUTDEV, sc<libinput_config_drag_lock_state>(TAP_DRAG_LOCK)); } if (libinput_device_config_tap_get_finger_count(LIBINPUTDEV)) // this is for tapping (like on a laptop) libinput_device_config_tap_set_enabled(LIBINPUTDEV, - g_pConfigManager->getDeviceInt(devname, "tap-to-click", "input:touchpad:tap-to-click") == 1 ? LIBINPUT_CONFIG_TAP_ENABLED : - LIBINPUT_CONFIG_TAP_DISABLED); + Config::mgr()->getDeviceInt(devname, "tap-to-click", "input:touchpad:tap-to-click") == 1 ? LIBINPUT_CONFIG_TAP_ENABLED : + LIBINPUT_CONFIG_TAP_DISABLED); if (libinput_device_config_scroll_has_natural_scroll(LIBINPUTDEV)) { if (ISTOUCHPAD) - libinput_device_config_scroll_set_natural_scroll_enabled(LIBINPUTDEV, - g_pConfigManager->getDeviceInt(devname, "natural_scroll", "input:touchpad:natural_scroll")); + libinput_device_config_scroll_set_natural_scroll_enabled(LIBINPUTDEV, Config::mgr()->getDeviceInt(devname, "natural_scroll", "input:touchpad:natural_scroll")); else - libinput_device_config_scroll_set_natural_scroll_enabled(LIBINPUTDEV, g_pConfigManager->getDeviceInt(devname, "natural_scroll", "input:natural_scroll")); + libinput_device_config_scroll_set_natural_scroll_enabled(LIBINPUTDEV, Config::mgr()->getDeviceInt(devname, "natural_scroll", "input:natural_scroll")); } if (libinput_device_config_3fg_drag_get_finger_count(LIBINPUTDEV) >= 3) { - const auto DRAG_3FG_STATE = sc<libinput_config_3fg_drag_state>(g_pConfigManager->getDeviceInt(devname, "drag_3fg", "input:touchpad:drag_3fg")); + const auto DRAG_3FG_STATE = sc<libinput_config_3fg_drag_state>(Config::mgr()->getDeviceInt(devname, "drag_3fg", "input:touchpad:drag_3fg")); libinput_device_config_3fg_drag_set_enabled(LIBINPUTDEV, DRAG_3FG_STATE); } if (libinput_device_config_dwt_is_available(LIBINPUTDEV)) { - const auto DWT = sc<enum libinput_config_dwt_state>(g_pConfigManager->getDeviceInt(devname, "disable_while_typing", "input:touchpad:disable_while_typing") != 0); + const auto DWT = sc<enum libinput_config_dwt_state>(Config::mgr()->getDeviceInt(devname, "disable_while_typing", "input:touchpad:disable_while_typing") != 0); libinput_device_config_dwt_set_enabled(LIBINPUTDEV, DWT); } - const auto LIBINPUTSENS = std::clamp(g_pConfigManager->getDeviceFloat(devname, "sensitivity", "input:sensitivity"), -1.f, 1.f); + const auto LIBINPUTSENS = std::clamp(Config::mgr()->getDeviceFloat(devname, "sensitivity", "input:sensitivity"), -1.f, 1.f); libinput_device_config_accel_set_speed(LIBINPUTDEV, LIBINPUTSENS); if (libinput_device_config_rotation_is_available(LIBINPUTDEV)) { - const auto ROTATION = std::clamp(g_pConfigManager->getDeviceInt(devname, "rotation", "input:rotation"), 0, 359); + const auto ROTATION = std::clamp(Config::mgr()->getDeviceInt(devname, "rotation", "input:rotation"), 0, 359); libinput_device_config_rotation_set_angle(LIBINPUTDEV, ROTATION); } - m->m_flipX = g_pConfigManager->getDeviceInt(devname, "flip_x", "input:touchpad:flip_x") != 0; - m->m_flipY = g_pConfigManager->getDeviceInt(devname, "flip_y", "input:touchpad:flip_y") != 0; + m->m_flipX = Config::mgr()->getDeviceInt(devname, "flip_x", "input:touchpad:flip_x") != 0; + m->m_flipY = Config::mgr()->getDeviceInt(devname, "flip_y", "input:touchpad:flip_y") != 0; - const auto ACCELPROFILE = g_pConfigManager->getDeviceString(devname, "accel_profile", "input:accel_profile"); - const auto SCROLLPOINTS = g_pConfigManager->getDeviceString(devname, "scroll_points", "input:scroll_points"); + const auto ACCELPROFILE = Config::mgr()->getDeviceString(devname, "accel_profile", "input:accel_profile"); + const auto SCROLLPOINTS = Config::mgr()->getDeviceString(devname, "scroll_points", "input:scroll_points"); if (ACCELPROFILE.empty()) { libinput_device_config_accel_set_profile(LIBINPUTDEV, libinput_device_config_accel_get_default_profile(LIBINPUTDEV)); @@ -1384,11 +1387,11 @@ void CInputManager::setPointerConfigs() { Log::logger->log(Log::WARN, "Unknown acceleration profile, falling back to default"); } - const auto SCROLLBUTTON = g_pConfigManager->getDeviceInt(devname, "scroll_button", "input:scroll_button"); + const auto SCROLLBUTTON = Config::mgr()->getDeviceInt(devname, "scroll_button", "input:scroll_button"); libinput_device_config_scroll_set_button(LIBINPUTDEV, SCROLLBUTTON == 0 ? libinput_device_config_scroll_get_default_button(LIBINPUTDEV) : SCROLLBUTTON); - const auto SCROLLBUTTONLOCK = g_pConfigManager->getDeviceInt(devname, "scroll_button_lock", "input:scroll_button_lock"); + const auto SCROLLBUTTONLOCK = Config::mgr()->getDeviceInt(devname, "scroll_button_lock", "input:scroll_button_lock"); libinput_device_config_scroll_set_button_lock(LIBINPUTDEV, SCROLLBUTTONLOCK == 0 ? LIBINPUT_CONFIG_SCROLL_BUTTON_LOCK_DISABLED : LIBINPUT_CONFIG_SCROLL_BUTTON_LOCK_ENABLED); @@ -1802,7 +1805,7 @@ void CInputManager::setTouchDeviceConfigs(SP<ITouch> dev) { if (PTOUCHDEV->aq() && PTOUCHDEV->aq()->getLibinputHandle()) { const auto LIBINPUTDEV = PTOUCHDEV->aq()->getLibinputHandle(); - const auto ENABLED = g_pConfigManager->getDeviceInt(PTOUCHDEV->m_hlName, "enabled", "input:touchdevice:enabled"); + const auto ENABLED = Config::mgr()->getDeviceInt(PTOUCHDEV->m_hlName, "enabled", "input:touchdevice:enabled"); const auto mode = ENABLED ? LIBINPUT_CONFIG_SEND_EVENTS_ENABLED : LIBINPUT_CONFIG_SEND_EVENTS_DISABLED; if (libinput_device_config_send_events_get_mode(LIBINPUTDEV) != mode) libinput_device_config_send_events_set_mode(LIBINPUTDEV, mode); @@ -1810,12 +1813,12 @@ void CInputManager::setTouchDeviceConfigs(SP<ITouch> dev) { if (libinput_device_config_calibration_has_matrix(LIBINPUTDEV)) { Log::logger->log(Log::DEBUG, "Setting calibration matrix for device {}", PTOUCHDEV->m_hlName); // default value of transform being -1 means it's unset. - const int ROTATION = std::clamp(g_pConfigManager->getDeviceInt(PTOUCHDEV->m_hlName, "transform", "input:touchdevice:transform"), -1, 7); + const int ROTATION = std::clamp(Config::mgr()->getDeviceInt(PTOUCHDEV->m_hlName, "transform", "input:touchdevice:transform"), -1, 7); if (ROTATION > -1) libinput_device_config_calibration_set_matrix(LIBINPUTDEV, MATRICES[ROTATION]); } - auto output = g_pConfigManager->getDeviceString(PTOUCHDEV->m_hlName, "output", "input:touchdevice:output"); + auto output = Config::mgr()->getDeviceString(PTOUCHDEV->m_hlName, "output", "input:touchdevice:output"); bool bound = !output.empty() && output != STRVAL_EMPTY; const bool AUTODETECT = output == "[[Auto]]"; if (!bound && AUTODETECT) { @@ -1852,35 +1855,35 @@ void CInputManager::setTabletConfigs() { const auto NAME = t->m_hlName; const auto LIBINPUTDEV = t->aq()->getLibinputHandle(); - const auto RELINPUT = g_pConfigManager->getDeviceInt(NAME, "relative_input", "input:tablet:relative_input"); + const auto RELINPUT = Config::mgr()->getDeviceInt(NAME, "relative_input", "input:tablet:relative_input"); t->m_relativeInput = RELINPUT; - const int ROTATION = std::clamp(g_pConfigManager->getDeviceInt(NAME, "transform", "input:tablet:transform"), -1, 7); + const int ROTATION = std::clamp(Config::mgr()->getDeviceInt(NAME, "transform", "input:tablet:transform"), -1, 7); Log::logger->log(Log::DEBUG, "Setting calibration matrix for device {}", NAME); if (ROTATION > -1) libinput_device_config_calibration_set_matrix(LIBINPUTDEV, MATRICES[ROTATION]); - if (g_pConfigManager->getDeviceInt(NAME, "left_handed", "input:tablet:left_handed") == 0) + if (Config::mgr()->getDeviceInt(NAME, "left_handed", "input:tablet:left_handed") == 0) libinput_device_config_left_handed_set(LIBINPUTDEV, 0); else libinput_device_config_left_handed_set(LIBINPUTDEV, 1); - const auto OUTPUT = g_pConfigManager->getDeviceString(NAME, "output", "input:tablet:output"); + const auto OUTPUT = Config::mgr()->getDeviceString(NAME, "output", "input:tablet:output"); if (OUTPUT != STRVAL_EMPTY) { Log::logger->log(Log::DEBUG, "Binding tablet {} to output {}", NAME, OUTPUT); t->m_boundOutput = OUTPUT; } else t->m_boundOutput = ""; - const auto REGION_POS = g_pConfigManager->getDeviceVec(NAME, "region_position", "input:tablet:region_position"); - const auto REGION_SIZE = g_pConfigManager->getDeviceVec(NAME, "region_size", "input:tablet:region_size"); + const auto REGION_POS = Config::mgr()->getDeviceVec(NAME, "region_position", "input:tablet:region_position"); + const auto REGION_SIZE = Config::mgr()->getDeviceVec(NAME, "region_size", "input:tablet:region_size"); t->m_boundBox = {REGION_POS, REGION_SIZE}; - const auto ABSOLUTE_REGION_POS = g_pConfigManager->getDeviceInt(NAME, "absolute_region_position", "input:tablet:absolute_region_position"); + const auto ABSOLUTE_REGION_POS = Config::mgr()->getDeviceInt(NAME, "absolute_region_position", "input:tablet:absolute_region_position"); t->m_absolutePos = ABSOLUTE_REGION_POS; - const auto ACTIVE_AREA_SIZE = g_pConfigManager->getDeviceVec(NAME, "active_area_size", "input:tablet:active_area_size"); - const auto ACTIVE_AREA_POS = g_pConfigManager->getDeviceVec(NAME, "active_area_position", "input:tablet:active_area_position"); + const auto ACTIVE_AREA_SIZE = Config::mgr()->getDeviceVec(NAME, "active_area_size", "input:tablet:active_area_size"); + const auto ACTIVE_AREA_POS = Config::mgr()->getDeviceVec(NAME, "active_area_position", "input:tablet:active_area_position"); if (ACTIVE_AREA_SIZE.x != 0 || ACTIVE_AREA_SIZE.y != 0) { // Rotations with an odd index (90 and 270 degrees, and their flipped variants) swap the X and Y axes. // Use swapped dimensions when the axes are rotated, otherwise keep the original ones. |
