mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-26 15:45:58 +01:00
Add accel profile and scroll method
This commit is contained in:
parent
11ce468996
commit
477ad2dd82
4 changed files with 39 additions and 10 deletions
|
@ -125,6 +125,7 @@ void CConfigManager::setDefaultVars() {
|
||||||
configValues["animations:workspaces"].intValue = 1;
|
configValues["animations:workspaces"].intValue = 1;
|
||||||
|
|
||||||
configValues["input:sensitivity"].floatValue = 0.f;
|
configValues["input:sensitivity"].floatValue = 0.f;
|
||||||
|
configValues["input:accel_profile"].strValue = STRVAL_EMPTY;
|
||||||
configValues["input:kb_file"].strValue = STRVAL_EMPTY;
|
configValues["input:kb_file"].strValue = STRVAL_EMPTY;
|
||||||
configValues["input:kb_layout"].strValue = "us";
|
configValues["input:kb_layout"].strValue = "us";
|
||||||
configValues["input:kb_variant"].strValue = STRVAL_EMPTY;
|
configValues["input:kb_variant"].strValue = STRVAL_EMPTY;
|
||||||
|
@ -138,6 +139,7 @@ void CConfigManager::setDefaultVars() {
|
||||||
configValues["input:force_no_accel"].intValue = 0;
|
configValues["input:force_no_accel"].intValue = 0;
|
||||||
configValues["input:float_switch_override_focus"].intValue = 1;
|
configValues["input:float_switch_override_focus"].intValue = 1;
|
||||||
configValues["input:left_handed"].intValue = 0;
|
configValues["input:left_handed"].intValue = 0;
|
||||||
|
configValues["input:scroll_method"].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;
|
||||||
|
@ -166,6 +168,7 @@ void CConfigManager::setDeviceDefaultVars(const std::string& dev) {
|
||||||
auto& cfgValues = deviceConfigs[dev];
|
auto& cfgValues = deviceConfigs[dev];
|
||||||
|
|
||||||
cfgValues["sensitivity"].floatValue = 0.f;
|
cfgValues["sensitivity"].floatValue = 0.f;
|
||||||
|
cfgValues["accel_profile"].strValue = STRVAL_EMPTY;
|
||||||
cfgValues["kb_file"].strValue = STRVAL_EMPTY;
|
cfgValues["kb_file"].strValue = STRVAL_EMPTY;
|
||||||
cfgValues["kb_layout"].strValue = "us";
|
cfgValues["kb_layout"].strValue = "us";
|
||||||
cfgValues["kb_variant"].strValue = STRVAL_EMPTY;
|
cfgValues["kb_variant"].strValue = STRVAL_EMPTY;
|
||||||
|
@ -182,6 +185,7 @@ void CConfigManager::setDeviceDefaultVars(const std::string& dev) {
|
||||||
cfgValues["tap-to-click"].intValue = 1;
|
cfgValues["tap-to-click"].intValue = 1;
|
||||||
cfgValues["drag_lock"].intValue = 0;
|
cfgValues["drag_lock"].intValue = 0;
|
||||||
cfgValues["left_handed"].intValue = 0;
|
cfgValues["left_handed"].intValue = 0;
|
||||||
|
cfgValues["scroll_method"].strValue = STRVAL_EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CConfigManager::setDefaultAnimationVars() {
|
void CConfigManager::setDefaultAnimationVars() {
|
||||||
|
@ -1126,7 +1130,7 @@ void CConfigManager::loadConfigLoadVars() {
|
||||||
// Update the keyboard layout to the cfg'd one if this is not the first launch
|
// Update the keyboard layout to the cfg'd one if this is not the first launch
|
||||||
if (!isFirstLaunch) {
|
if (!isFirstLaunch) {
|
||||||
g_pInputManager->setKeyboardLayout();
|
g_pInputManager->setKeyboardLayout();
|
||||||
g_pInputManager->setMouseConfigs();
|
g_pInputManager->setPointerConfigs();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate the internal vars
|
// Calculate the internal vars
|
||||||
|
@ -1411,7 +1415,7 @@ void CConfigManager::dispatchExecOnce() {
|
||||||
|
|
||||||
// set input, fixes some certain issues
|
// set input, fixes some certain issues
|
||||||
g_pInputManager->setKeyboardLayout();
|
g_pInputManager->setKeyboardLayout();
|
||||||
g_pInputManager->setMouseConfigs();
|
g_pInputManager->setPointerConfigs();
|
||||||
|
|
||||||
// set ws names again
|
// set ws names again
|
||||||
for (auto& ws : g_pCompositor->m_vWorkspaces) {
|
for (auto& ws : g_pCompositor->m_vWorkspaces) {
|
||||||
|
|
|
@ -561,7 +561,7 @@ std::string dispatchKeyword(std::string in) {
|
||||||
|
|
||||||
if (COMMAND.contains("input") || COMMAND.contains("device:")) {
|
if (COMMAND.contains("input") || COMMAND.contains("device:")) {
|
||||||
g_pInputManager->setKeyboardLayout(); // update kb layout
|
g_pInputManager->setKeyboardLayout(); // update kb layout
|
||||||
g_pInputManager->setMouseConfigs(); // update mouse cfgs
|
g_pInputManager->setPointerConfigs(); // update mouse cfgs
|
||||||
}
|
}
|
||||||
|
|
||||||
if (COMMAND.contains("general:layout"))
|
if (COMMAND.contains("general:layout"))
|
||||||
|
|
|
@ -662,7 +662,7 @@ void CInputManager::newMouse(wlr_input_device* mouse, bool virt) {
|
||||||
Debug::log(LOG, "New mouse has libinput sens %.2f (%.2f) with accel profile %i (%i)", libinput_device_config_accel_get_speed(LIBINPUTDEV), libinput_device_config_accel_get_default_speed(LIBINPUTDEV), libinput_device_config_accel_get_profile(LIBINPUTDEV), libinput_device_config_accel_get_default_profile(LIBINPUTDEV));
|
Debug::log(LOG, "New mouse has libinput sens %.2f (%.2f) with accel profile %i (%i)", libinput_device_config_accel_get_speed(LIBINPUTDEV), libinput_device_config_accel_get_default_speed(LIBINPUTDEV), libinput_device_config_accel_get_profile(LIBINPUTDEV), libinput_device_config_accel_get_default_profile(LIBINPUTDEV));
|
||||||
}
|
}
|
||||||
|
|
||||||
setMouseConfigs();
|
setPointerConfigs();
|
||||||
|
|
||||||
PMOUSE->hyprListener_destroyMouse.initCallback(&mouse->events.destroy, &Events::listener_destroyMouse, PMOUSE, "Mouse");
|
PMOUSE->hyprListener_destroyMouse.initCallback(&mouse->events.destroy, &Events::listener_destroyMouse, PMOUSE, "Mouse");
|
||||||
|
|
||||||
|
@ -675,11 +675,11 @@ void CInputManager::newMouse(wlr_input_device* mouse, bool virt) {
|
||||||
Debug::log(LOG, "New mouse created, pointer WLR: %x", mouse);
|
Debug::log(LOG, "New mouse created, pointer WLR: %x", mouse);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInputManager::setMouseConfigs() {
|
void CInputManager::setPointerConfigs() {
|
||||||
for (auto& m : m_lMice) {
|
for (auto& m : m_lMice) {
|
||||||
const auto PMOUSE = &m;
|
const auto PPOINTER = &m;
|
||||||
|
|
||||||
auto devname = PMOUSE->name;
|
auto devname = PPOINTER->name;
|
||||||
transform(devname.begin(), devname.end(), devname.begin(), ::tolower);
|
transform(devname.begin(), devname.end(), devname.begin(), ::tolower);
|
||||||
|
|
||||||
const auto HASCONFIG = g_pConfigManager->deviceConfigExists(devname);
|
const auto HASCONFIG = g_pConfigManager->deviceConfigExists(devname);
|
||||||
|
@ -704,6 +704,21 @@ void CInputManager::setMouseConfigs() {
|
||||||
libinput_device_config_middle_emulation_set_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED);
|
libinput_device_config_middle_emulation_set_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto SCROLLMETHOD = HASCONFIG ? g_pConfigManager->getDeviceString(devname, "scroll_method") : g_pConfigManager->getString("input:scroll_method");
|
||||||
|
if (SCROLLMETHOD == "" || SCROLLMETHOD == STRVAL_EMPTY) {
|
||||||
|
libinput_device_config_scroll_set_method(LIBINPUTDEV, libinput_device_config_scroll_get_default_method(LIBINPUTDEV));
|
||||||
|
} else if (SCROLLMETHOD == "no_scroll") {
|
||||||
|
libinput_device_config_scroll_set_method(LIBINPUTDEV, LIBINPUT_CONFIG_SCROLL_NO_SCROLL);
|
||||||
|
} else if (SCROLLMETHOD == "2fg") {
|
||||||
|
libinput_device_config_scroll_set_method(LIBINPUTDEV, LIBINPUT_CONFIG_SCROLL_2FG);
|
||||||
|
} else if (SCROLLMETHOD == "edge") {
|
||||||
|
libinput_device_config_scroll_set_method(LIBINPUTDEV, LIBINPUT_CONFIG_SCROLL_EDGE);
|
||||||
|
} else if (SCROLLMETHOD == "on_button_down") {
|
||||||
|
libinput_device_config_scroll_set_method(LIBINPUTDEV, LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN);
|
||||||
|
} else {
|
||||||
|
Debug::log(WARN, "Scroll method unknown");
|
||||||
|
}
|
||||||
|
|
||||||
if ((HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "drag_lock") : g_pConfigManager->getInt("input:touchpad:drag_lock")) == 0)
|
if ((HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "drag_lock") : g_pConfigManager->getInt("input:touchpad:drag_lock")) == 0)
|
||||||
libinput_device_config_tap_set_drag_lock_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_DRAG_LOCK_DISABLED);
|
libinput_device_config_tap_set_drag_lock_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_DRAG_LOCK_DISABLED);
|
||||||
else
|
else
|
||||||
|
@ -728,10 +743,20 @@ void CInputManager::setMouseConfigs() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto LIBINPUTSENS = std::clamp((HASCONFIG ? g_pConfigManager->getDeviceFloat(devname, "sensitivity") : g_pConfigManager->getFloat("input:sensitivity")), -1.f, 1.f);
|
const auto LIBINPUTSENS = std::clamp((HASCONFIG ? g_pConfigManager->getDeviceFloat(devname, "sensitivity") : g_pConfigManager->getFloat("input:sensitivity")), -1.f, 1.f);
|
||||||
|
|
||||||
libinput_device_config_accel_set_profile(LIBINPUTDEV, LIBINPUT_CONFIG_ACCEL_PROFILE_NONE);
|
|
||||||
libinput_device_config_accel_set_speed(LIBINPUTDEV, LIBINPUTSENS);
|
libinput_device_config_accel_set_speed(LIBINPUTDEV, LIBINPUTSENS);
|
||||||
|
|
||||||
|
const auto ACCELPROFILE = HASCONFIG ? g_pConfigManager->getDeviceString(devname, "accel_profile") : g_pConfigManager->getString("input:accel_profile");
|
||||||
|
|
||||||
|
if (ACCELPROFILE == "" || ACCELPROFILE == STRVAL_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 {
|
||||||
|
Debug::log(WARN, "Unknown acceleration profile, falling back to default");
|
||||||
|
}
|
||||||
|
|
||||||
Debug::log(LOG, "Applied config to mouse %s, sens %.2f", m.name.c_str(), LIBINPUTSENS);
|
Debug::log(LOG, "Applied config to mouse %s, sens %.2f", m.name.c_str(), LIBINPUTSENS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ public:
|
||||||
void refocus();
|
void refocus();
|
||||||
|
|
||||||
void setKeyboardLayout();
|
void setKeyboardLayout();
|
||||||
void setMouseConfigs();
|
void setPointerConfigs();
|
||||||
|
|
||||||
void updateDragIcon();
|
void updateDragIcon();
|
||||||
void updateCapabilities(wlr_input_device*);
|
void updateCapabilities(wlr_input_device*);
|
||||||
|
|
Loading…
Reference in a new issue