mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-29 22:26:00 +01:00
input: Add scroll_points option for device (#4101)
This commit is contained in:
parent
9f5b9053c6
commit
0c10b8ab2d
2 changed files with 26 additions and 7 deletions
|
@ -236,6 +236,7 @@ void CConfigManager::setDefaultVars() {
|
||||||
configValues["input:scroll_method"].strValue = STRVAL_EMPTY;
|
configValues["input:scroll_method"].strValue = STRVAL_EMPTY;
|
||||||
configValues["input:scroll_button"].intValue = 0;
|
configValues["input:scroll_button"].intValue = 0;
|
||||||
configValues["input:scroll_button_lock"].intValue = 0;
|
configValues["input:scroll_button_lock"].intValue = 0;
|
||||||
|
configValues["input:scroll_points"].strValue = STRVAL_EMPTY;
|
||||||
configValues["input:touchpad:natural_scroll"].intValue = 0;
|
configValues["input:touchpad:natural_scroll"].intValue = 0;
|
||||||
configValues["input:touchpad:disable_while_typing"].intValue = 1;
|
configValues["input:touchpad:disable_while_typing"].intValue = 1;
|
||||||
configValues["input:touchpad:clickfinger_behavior"].intValue = 0;
|
configValues["input:touchpad:clickfinger_behavior"].intValue = 0;
|
||||||
|
@ -307,6 +308,7 @@ void CConfigManager::setDeviceDefaultVars(const std::string& dev) {
|
||||||
cfgValues["scroll_method"].strValue = STRVAL_EMPTY;
|
cfgValues["scroll_method"].strValue = STRVAL_EMPTY;
|
||||||
cfgValues["scroll_button"].intValue = 0;
|
cfgValues["scroll_button"].intValue = 0;
|
||||||
cfgValues["scroll_button_lock"].intValue = 0;
|
cfgValues["scroll_button_lock"].intValue = 0;
|
||||||
|
cfgValues["scroll_points"].strValue = STRVAL_EMPTY;
|
||||||
cfgValues["transform"].intValue = 0;
|
cfgValues["transform"].intValue = 0;
|
||||||
cfgValues["output"].strValue = STRVAL_EMPTY;
|
cfgValues["output"].strValue = STRVAL_EMPTY;
|
||||||
cfgValues["enabled"].intValue = 1; // only for mice / touchpads
|
cfgValues["enabled"].intValue = 1; // only for mice / touchpads
|
||||||
|
|
|
@ -1066,23 +1066,40 @@ void CInputManager::setPointerConfigs() {
|
||||||
libinput_device_config_accel_set_speed(LIBINPUTDEV, LIBINPUTSENS);
|
libinput_device_config_accel_set_speed(LIBINPUTDEV, LIBINPUTSENS);
|
||||||
|
|
||||||
const auto ACCELPROFILE = g_pConfigManager->getDeviceString(devname, "accel_profile", "input:accel_profile");
|
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));
|
libinput_device_config_accel_set_profile(LIBINPUTDEV, libinput_device_config_accel_get_default_profile(LIBINPUTDEV));
|
||||||
} else if (ACCELPROFILE == "adaptive") {
|
} else if (ACCELPROFILE == "adaptive") {
|
||||||
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.starts_with("custom")) {
|
} else if (ACCELPROFILE.starts_with("custom")) {
|
||||||
CVarList args = {ACCELPROFILE, 0, ' '};
|
CVarList accelValues = {ACCELPROFILE, 0, ' '};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
double step = std::stod(args[1]);
|
double accelStep = std::stod(accelValues[1]);
|
||||||
std::vector<double> points;
|
std::vector<double> accelPoints;
|
||||||
for (size_t i = 2; i < args.size(); ++i)
|
for (size_t i = 2; i < accelValues.size(); ++i) {
|
||||||
points.push_back(std::stod(args[i]));
|
accelPoints.push_back(std::stod(accelValues[i]));
|
||||||
|
}
|
||||||
|
|
||||||
const auto CONFIG = libinput_config_accel_create(LIBINPUT_CONFIG_ACCEL_PROFILE_CUSTOM);
|
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_device_config_accel_apply(LIBINPUTDEV, CONFIG);
|
||||||
libinput_config_accel_destroy(CONFIG);
|
libinput_config_accel_destroy(CONFIG);
|
||||||
} catch (std::exception& e) { Debug::log(ERR, "Invalid values in custom accel profile"); }
|
} catch (std::exception& e) { Debug::log(ERR, "Invalid values in custom accel profile"); }
|
||||||
|
|
Loading…
Reference in a new issue