Use internal device naming for Hyprctl devices (#1174)

* Use internal naming for Hyprctl devices

* Use c-strings rather than std::string
This commit is contained in:
Paul 2022-12-04 19:32:55 +02:00 committed by GitHub
parent 686d6fc6d1
commit d9998f2ca5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -289,7 +289,7 @@ R"#( {
"defaultSpeed": %f "defaultSpeed": %f
},)#", },)#",
&m, &m,
escapeJSONStrings(m.mouse->name).c_str(), escapeJSONStrings(m.name).c_str(),
wlr_input_device_is_libinput(m.mouse) ? libinput_device_config_accel_get_default_speed((libinput_device*)wlr_libinput_get_device_handle(m.mouse)) : 0.f wlr_input_device_is_libinput(m.mouse) ? libinput_device_config_accel_get_default_speed((libinput_device*)wlr_libinput_get_device_handle(m.mouse)) : 0.f
); );
} }
@ -314,7 +314,7 @@ R"#( {
"main": %s "main": %s
},)#", },)#",
&k, &k,
escapeJSONStrings(k.keyboard->name).c_str(), escapeJSONStrings(k.name).c_str(),
escapeJSONStrings(k.currentRules.rules).c_str(), escapeJSONStrings(k.currentRules.rules).c_str(),
escapeJSONStrings(k.currentRules.model).c_str(), escapeJSONStrings(k.currentRules.model).c_str(),
escapeJSONStrings(k.currentRules.layout).c_str(), escapeJSONStrings(k.currentRules.layout).c_str(),
@ -343,7 +343,7 @@ R"#( {
},)#", },)#",
&d, &d,
d.pTabletParent, d.pTabletParent,
escapeJSONStrings(d.pTabletParent ? d.pTabletParent->wlrDevice ? d.pTabletParent->wlrDevice->name : "" : "").c_str() escapeJSONStrings(d.pTabletParent ? d.pTabletParent->name : "").c_str()
); );
} }
@ -354,7 +354,7 @@ R"#( {
"name": "%s" "name": "%s"
},)#", },)#",
&d, &d,
escapeJSONStrings(d.wlrDevice ? d.wlrDevice->name : "").c_str() escapeJSONStrings(d.name).c_str()
); );
} }
@ -383,7 +383,7 @@ R"#( {
"name": "%s" "name": "%s"
},)#", },)#",
&d, &d,
d.pWlrDevice ? d.pWlrDevice->name : "" d.name.c_str()
); );
} }
@ -416,24 +416,24 @@ R"#( {
result += "mice:\n"; result += "mice:\n";
for (auto& m : g_pInputManager->m_lMice) { for (auto& m : g_pInputManager->m_lMice) {
result += getFormat("\tMouse at %x:\n\t\t%s\n\t\t\tdefault speed: %f\n", &m, m.mouse->name, (wlr_input_device_is_libinput(m.mouse) ? libinput_device_config_accel_get_default_speed((libinput_device*)wlr_libinput_get_device_handle(m.mouse)) : 0.f)); result += getFormat("\tMouse at %x:\n\t\t%s\n\t\t\tdefault speed: %f\n", &m, m.name.c_str(), (wlr_input_device_is_libinput(m.mouse) ? libinput_device_config_accel_get_default_speed((libinput_device*)wlr_libinput_get_device_handle(m.mouse)) : 0.f));
} }
result += "\n\nKeyboards:\n"; result += "\n\nKeyboards:\n";
for (auto& k : g_pInputManager->m_lKeyboards) { for (auto& k : g_pInputManager->m_lKeyboards) {
const auto KM = g_pInputManager->getActiveLayoutForKeyboard(&k); const auto KM = g_pInputManager->getActiveLayoutForKeyboard(&k);
result += getFormat("\tKeyboard at %x:\n\t\t%s\n\t\t\trules: r \"%s\", m \"%s\", l \"%s\", v \"%s\", o \"%s\"\n\t\t\tactive keymap: %s\n\t\t\tmain: %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(), KM.c_str(), (k.active ? "yes" : "no")); result += getFormat("\tKeyboard at %x:\n\t\t%s\n\t\t\trules: r \"%s\", m \"%s\", l \"%s\", v \"%s\", o \"%s\"\n\t\t\tactive keymap: %s\n\t\t\tmain: %s\n", &k, k.name.c_str(), 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(), KM.c_str(), (k.active ? "yes" : "no"));
} }
result += "\n\nTablets:\n"; result += "\n\nTablets:\n";
for (auto& d : g_pInputManager->m_lTabletPads) { for (auto& d : g_pInputManager->m_lTabletPads) {
result += getFormat("\tTablet Pad at %x (belongs to %x -> %s)\n", &d, d.pTabletParent, d.pTabletParent ? d.pTabletParent->wlrDevice ? d.pTabletParent->wlrDevice->name : "" : ""); result += getFormat("\tTablet Pad at %x (belongs to %x -> %s)\n", &d, d.pTabletParent, d.pTabletParent ? d.pTabletParent->name.c_str() : "");
} }
for (auto& d : g_pInputManager->m_lTablets) { for (auto& d : g_pInputManager->m_lTablets) {
result += getFormat("\tTablet at %x:\n\t\t%s\n", &d, d.wlrDevice ? d.wlrDevice->name : ""); result += getFormat("\tTablet at %x:\n\t\t%s\n", &d, d.name.c_str());
} }
for (auto& d : g_pInputManager->m_lTabletTools) { for (auto& d : g_pInputManager->m_lTabletTools) {
@ -443,7 +443,7 @@ R"#( {
result += "\n\nTouch:\n"; result += "\n\nTouch:\n";
for (auto& d : g_pInputManager->m_lTouchDevices) { for (auto& d : g_pInputManager->m_lTouchDevices) {
result += getFormat("\tTouch Device at %x:\n\t\t%s\n", &d, d.pWlrDevice ? d.pWlrDevice->name : ""); result += getFormat("\tTouch Device at %x:\n\t\t%s\n", &d, d.name.c_str());
} }
result += "\n\nSwitches:\n"; result += "\n\nSwitches:\n";