mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-26 13:45:58 +01:00
Added keyboard configuration
This commit is contained in:
parent
ccd691a88b
commit
7eb2a1023b
4 changed files with 56 additions and 0 deletions
|
@ -6,6 +6,14 @@
|
||||||
monitor=,1280x720@60,0x0,0.5,1
|
monitor=,1280x720@60,0x0,0.5,1
|
||||||
workspace=DP-1,1
|
workspace=DP-1,1
|
||||||
|
|
||||||
|
input {
|
||||||
|
kb_layout=en
|
||||||
|
kb_variant=
|
||||||
|
kb_model=
|
||||||
|
kb_options=
|
||||||
|
kb_rules=
|
||||||
|
}
|
||||||
|
|
||||||
general {
|
general {
|
||||||
max_fps=240
|
max_fps=240
|
||||||
sensitivity=0.25
|
sensitivity=0.25
|
||||||
|
|
|
@ -27,6 +27,12 @@ CConfigManager::CConfigManager() {
|
||||||
configValues["animations:windows"].intValue = 1;
|
configValues["animations:windows"].intValue = 1;
|
||||||
configValues["animations:borders"].intValue = 1;
|
configValues["animations:borders"].intValue = 1;
|
||||||
configValues["animations:fadein"].intValue = 1;
|
configValues["animations:fadein"].intValue = 1;
|
||||||
|
|
||||||
|
configValues["input:kb_layout"].strValue = "en";
|
||||||
|
configValues["input:kb_variant"].strValue = "";
|
||||||
|
configValues["input:kb_options"].strValue = "";
|
||||||
|
configValues["input:kb_rules"].strValue = "";
|
||||||
|
configValues["input:kb_model"].strValue = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
void CConfigManager::init() {
|
void CConfigManager::init() {
|
||||||
|
@ -312,6 +318,9 @@ void CConfigManager::loadConfigLoadVars() {
|
||||||
for (auto& m : g_pCompositor->m_lMonitors)
|
for (auto& m : g_pCompositor->m_lMonitors)
|
||||||
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m.ID);
|
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m.ID);
|
||||||
|
|
||||||
|
// Update the keyboard layout to the cfg'd one
|
||||||
|
g_pInputManager->setKeyboardLayout();
|
||||||
|
|
||||||
// Calculate the mod mask for main_mod
|
// Calculate the mod mask for main_mod
|
||||||
configValues["general:main_mod_internal"].intValue = g_pKeybindManager->stringToModMask(configValues["general:main_mod"].strValue);
|
configValues["general:main_mod_internal"].intValue = g_pKeybindManager->stringToModMask(configValues["general:main_mod"].strValue);
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,6 +144,43 @@ void CInputManager::newKeyboard(wlr_input_device* keyboard) {
|
||||||
wlr_seat_set_keyboard(g_pCompositor->m_sSeat.seat, keyboard->keyboard);
|
wlr_seat_set_keyboard(g_pCompositor->m_sSeat.seat, keyboard->keyboard);
|
||||||
|
|
||||||
Debug::log(LOG, "New keyboard created, pointers Hypr: %x and WLR: %x", PNEWKEYBOARD, keyboard);
|
Debug::log(LOG, "New keyboard created, pointers Hypr: %x and WLR: %x", PNEWKEYBOARD, keyboard);
|
||||||
|
|
||||||
|
setKeyboardLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CInputManager::setKeyboardLayout() {
|
||||||
|
|
||||||
|
const auto RULES = g_pConfigManager->getString("input:kb_rules");
|
||||||
|
const auto MODEL = g_pConfigManager->getString("input:kb_model");
|
||||||
|
const auto LAYOUT = g_pConfigManager->getString("input:kb_layout");
|
||||||
|
const auto VARIANT = g_pConfigManager->getString("input:kb_variant");
|
||||||
|
const auto OPTIONS = g_pConfigManager->getString("input:kb_options");
|
||||||
|
|
||||||
|
xkb_rule_names rules = {
|
||||||
|
.rules = RULES.c_str(),
|
||||||
|
.model = MODEL.c_str(),
|
||||||
|
.layout = LAYOUT.c_str(),
|
||||||
|
.variant = VARIANT.c_str(),
|
||||||
|
.options = OPTIONS.c_str()
|
||||||
|
};
|
||||||
|
|
||||||
|
const auto CONTEXT = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
|
||||||
|
const auto KEYMAP = xkb_keymap_new_from_names(CONTEXT, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS);
|
||||||
|
|
||||||
|
if (!KEYMAP) {
|
||||||
|
Debug::log(ERR, "Keyboard layout %s with variant %s (rules: %s, model: %s, options: %s) couldn't have been loaded.", rules.layout, rules.variant, rules.rules, rules.model, rules.options);
|
||||||
|
xkb_context_unref(CONTEXT);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: configure devices one by one
|
||||||
|
for (auto& k : m_lKeyboards)
|
||||||
|
wlr_keyboard_set_keymap(k.keyboard->keyboard, KEYMAP);
|
||||||
|
|
||||||
|
xkb_keymap_unref(KEYMAP);
|
||||||
|
xkb_context_unref(CONTEXT);
|
||||||
|
|
||||||
|
Debug::log(LOG, "Set the keyboard layout to %s and variant to %s", rules.layout, rules.variant);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInputManager::newMouse(wlr_input_device* mouse) {
|
void CInputManager::newMouse(wlr_input_device* mouse) {
|
||||||
|
|
|
@ -22,6 +22,8 @@ public:
|
||||||
Vector2D getMouseCoordsInternal();
|
Vector2D getMouseCoordsInternal();
|
||||||
void refocus();
|
void refocus();
|
||||||
|
|
||||||
|
void setKeyboardLayout();
|
||||||
|
|
||||||
|
|
||||||
// for dragging floating windows
|
// for dragging floating windows
|
||||||
CWindow* currentlyDraggedWindow = nullptr;
|
CWindow* currentlyDraggedWindow = nullptr;
|
||||||
|
|
Loading…
Reference in a new issue