input: add custom accel profiles

This commit is contained in:
vaxerski 2023-05-05 16:06:13 +01:00
parent c0be1e2fd8
commit 0859944c9a

View file

@ -955,6 +955,19 @@ void CInputManager::setPointerConfigs() {
libinput_device_config_accel_set_profile(LIBINPUTDEV, LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE); libinput_device_config_accel_set_profile(LIBINPUTDEV, LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE);
} else if (ACCELPROFILE == "flat") { } else if (ACCELPROFILE == "flat") {
libinput_device_config_accel_set_profile(LIBINPUTDEV, LIBINPUT_CONFIG_ACCEL_PROFILE_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 { } else {
Debug::log(WARN, "Unknown acceleration profile, falling back to default"); Debug::log(WARN, "Unknown acceleration profile, falling back to default");
} }