diff options
| author | Mihai Fufezan <fufexan@protonmail.com> | 2023-12-10 18:30:08 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-10 16:30:08 +0000 |
| commit | 0c10b8ab2dad9851b00c0e99bb1fde3f01d5478c (patch) | |
| tree | b9fe4b9bb8c63de79d77b3b2de6a90eb7427abb4 /src/managers/input/InputManager.cpp | |
| parent | 9f5b9053c6fb7942a0ff27dc61fc6874e4354888 (diff) | |
input: Add scroll_points option for device (#4101)
Diffstat (limited to 'src/managers/input/InputManager.cpp')
| -rw-r--r-- | src/managers/input/InputManager.cpp | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 21c9435d..284b4da6 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -1066,23 +1066,40 @@ void CInputManager::setPointerConfigs() { libinput_device_config_accel_set_speed(LIBINPUTDEV, LIBINPUTSENS); const auto ACCELPROFILE = g_pConfigManager->getDeviceString(devname, "accel_profile", "input:accel_profile"); + const auto SCROLLPOINTS = g_pConfigManager->getDeviceString(devname, "scroll_points", "input:scroll_points"); - if (ACCELPROFILE == "") { + if (ACCELPROFILE.empty()) { libinput_device_config_accel_set_profile(LIBINPUTDEV, libinput_device_config_accel_get_default_profile(LIBINPUTDEV)); } else if (ACCELPROFILE == "adaptive") { libinput_device_config_accel_set_profile(LIBINPUTDEV, LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE); } else if (ACCELPROFILE == "flat") { libinput_device_config_accel_set_profile(LIBINPUTDEV, LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT); } else if (ACCELPROFILE.starts_with("custom")) { - CVarList args = {ACCELPROFILE, 0, ' '}; + CVarList accelValues = {ACCELPROFILE, 0, ' '}; + try { - double step = std::stod(args[1]); - std::vector<double> points; - for (size_t i = 2; i < args.size(); ++i) - points.push_back(std::stod(args[i])); + double accelStep = std::stod(accelValues[1]); + std::vector<double> accelPoints; + for (size_t i = 2; i < accelValues.size(); ++i) { + accelPoints.push_back(std::stod(accelValues[i])); + } const auto CONFIG = libinput_config_accel_create(LIBINPUT_CONFIG_ACCEL_PROFILE_CUSTOM); - libinput_config_accel_set_points(CONFIG, LIBINPUT_ACCEL_TYPE_MOTION, step, points.size(), points.data()); + + if (!SCROLLPOINTS.empty()) { + CVarList scrollValues = {SCROLLPOINTS, 0, ' '}; + try { + double scrollStep = std::stod(scrollValues[0]); + std::vector<double> scrollPoints; + for (size_t i = 1; i < scrollValues.size(); ++i) { + scrollPoints.push_back(std::stod(scrollValues[i])); + } + + libinput_config_accel_set_points(CONFIG, LIBINPUT_ACCEL_TYPE_SCROLL, scrollStep, scrollPoints.size(), scrollPoints.data()); + } catch (std::exception& e) { Debug::log(ERR, "Invalid values in scroll_points"); } + } + + libinput_config_accel_set_points(CONFIG, LIBINPUT_ACCEL_TYPE_MOTION, accelStep, accelPoints.size(), accelPoints.data()); libinput_device_config_accel_apply(LIBINPUTDEV, CONFIG); libinput_config_accel_destroy(CONFIG); } catch (std::exception& e) { Debug::log(ERR, "Invalid values in custom accel profile"); } |
