summaryrefslogtreecommitdiff
path: root/src/managers/input/InputManager.cpp
diff options
context:
space:
mode:
authorvaxerski <43317083+vaxerski@users.noreply.github.com>2023-05-05 16:06:13 +0100
committervaxerski <43317083+vaxerski@users.noreply.github.com>2023-05-05 16:06:13 +0100
commit0859944c9ab7855a68ab9126d0f527f857d9d40d (patch)
treee5fbadf0c30449bbe363bd78f49edf837c3780c4 /src/managers/input/InputManager.cpp
parentc0be1e2fd8221a362252c379811880224eee12a2 (diff)
input: add custom accel profiles
Diffstat (limited to 'src/managers/input/InputManager.cpp')
-rw-r--r--src/managers/input/InputManager.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp
index 7f3f788c..189cdf84 100644
--- a/src/managers/input/InputManager.cpp
+++ b/src/managers/input/InputManager.cpp
@@ -955,6 +955,19 @@ void CInputManager::setPointerConfigs() {
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.find("custom") == 0) {
+ CVarList args = {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]));
+
+ 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());
+ libinput_device_config_accel_set_profile(LIBINPUTDEV, LIBINPUT_CONFIG_ACCEL_PROFILE_CUSTOM);
+ libinput_config_accel_destroy(CONFIG);
+ } catch (std::exception& e) { Debug::log(ERR, "Invalid values in custom accel profile"); }
} else {
Debug::log(WARN, "Unknown acceleration profile, falling back to default");
}