mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-30 00:05:59 +01:00
added rules to hyprctl devices and fixed rules
This commit is contained in:
parent
491b99c61e
commit
92e17f2925
3 changed files with 21 additions and 5 deletions
|
@ -87,7 +87,7 @@ std::string devicesRequest() {
|
||||||
result += "\n\nKeyboards:\n";
|
result += "\n\nKeyboards:\n";
|
||||||
|
|
||||||
for (auto& k : g_pInputManager->m_lKeyboards) {
|
for (auto& k : g_pInputManager->m_lKeyboards) {
|
||||||
result += getFormat("\tKeyboard at %x:\n\t\t%s\n", &k, k.keyboard->name);
|
result += getFormat("\tKeyboard at %x:\n\t\t%s\n\t\t\trules: r \"%s\", m \"%s\", l \"%s\", v \"%s\", o \"%s\"\n", &k, k.keyboard->name, k.currentRules.rules.c_str(), k.currentRules.model.c_str(), k.currentRules.layout.c_str(), k.currentRules.variant.c_str(), k.currentRules.options.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
result += "\n\nTablets:\n";
|
result += "\n\nTablets:\n";
|
||||||
|
|
|
@ -69,6 +69,14 @@ struct SRenderData {
|
||||||
bool blur = false;
|
bool blur = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct SStringRuleNames {
|
||||||
|
std::string layout = "";
|
||||||
|
std::string model = "";
|
||||||
|
std::string variant = "";
|
||||||
|
std::string options = "";
|
||||||
|
std::string rules = "";
|
||||||
|
};
|
||||||
|
|
||||||
struct SKeyboard {
|
struct SKeyboard {
|
||||||
wlr_input_device* keyboard;
|
wlr_input_device* keyboard;
|
||||||
|
|
||||||
|
@ -80,7 +88,7 @@ struct SKeyboard {
|
||||||
|
|
||||||
std::string name = "";
|
std::string name = "";
|
||||||
|
|
||||||
xkb_rule_names currentRules = {0};
|
SStringRuleNames currentRules;
|
||||||
int repeatRate = 0;
|
int repeatRate = 0;
|
||||||
int repeatDelay = 0;
|
int repeatDelay = 0;
|
||||||
int numlockOn = -1;
|
int numlockOn = -1;
|
||||||
|
|
|
@ -424,7 +424,7 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) {
|
||||||
const auto OPTIONS = HASCONFIG ? g_pConfigManager->getDeviceString(pKeyboard->name, "kb_options") : g_pConfigManager->getString("input:kb_options");
|
const auto OPTIONS = HASCONFIG ? g_pConfigManager->getDeviceString(pKeyboard->name, "kb_options") : g_pConfigManager->getString("input:kb_options");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (NUMLOCKON == pKeyboard->numlockOn && REPEATDELAY == pKeyboard->repeatDelay && REPEATRATE == pKeyboard->repeatRate && RULES != "" && RULES == std::string(pKeyboard->currentRules.rules) && MODEL == std::string(pKeyboard->currentRules.model) && LAYOUT == std::string(pKeyboard->currentRules.layout) && VARIANT == std::string(pKeyboard->currentRules.variant) && OPTIONS == std::string(pKeyboard->currentRules.options)) {
|
if (NUMLOCKON == pKeyboard->numlockOn && REPEATDELAY == pKeyboard->repeatDelay && REPEATRATE == pKeyboard->repeatRate && RULES != "" && RULES == pKeyboard->currentRules.rules && MODEL == pKeyboard->currentRules.model && LAYOUT == pKeyboard->currentRules.layout && VARIANT == pKeyboard->currentRules.variant && OPTIONS == pKeyboard->currentRules.options) {
|
||||||
Debug::log(LOG, "Not applying config to keyboard, it did not change.");
|
Debug::log(LOG, "Not applying config to keyboard, it did not change.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -446,7 +446,11 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) {
|
||||||
.variant = VARIANT.c_str(),
|
.variant = VARIANT.c_str(),
|
||||||
.options = OPTIONS.c_str()};
|
.options = OPTIONS.c_str()};
|
||||||
|
|
||||||
pKeyboard->currentRules = rules;
|
pKeyboard->currentRules.rules = RULES;
|
||||||
|
pKeyboard->currentRules.model = MODEL;
|
||||||
|
pKeyboard->currentRules.variant = VARIANT;
|
||||||
|
pKeyboard->currentRules.options = OPTIONS;
|
||||||
|
pKeyboard->currentRules.layout = LAYOUT;
|
||||||
|
|
||||||
const auto CONTEXT = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
|
const auto CONTEXT = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
|
||||||
|
|
||||||
|
@ -463,7 +467,11 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) {
|
||||||
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);
|
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);
|
||||||
memset(&rules, 0, sizeof(rules));
|
memset(&rules, 0, sizeof(rules));
|
||||||
|
|
||||||
pKeyboard->currentRules = rules;
|
pKeyboard->currentRules.rules = "";
|
||||||
|
pKeyboard->currentRules.model = "";
|
||||||
|
pKeyboard->currentRules.variant = "";
|
||||||
|
pKeyboard->currentRules.options = "";
|
||||||
|
pKeyboard->currentRules.layout = "";
|
||||||
|
|
||||||
KEYMAP = xkb_keymap_new_from_names(CONTEXT, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS);
|
KEYMAP = xkb_keymap_new_from_names(CONTEXT, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue