overlay: bring back "-" placeholder for unbound io, clean up code (#538)

This commit is contained in:
bicarus
2026-01-29 11:53:16 -08:00
committed by GitHub
parent aa218d5be7
commit 2e52bebd3d
3 changed files with 62 additions and 47 deletions
+10 -2
View File
@@ -11,6 +11,14 @@
// settings
std::string CONFIG_PATH_OVERRIDE = "";
#define CFG_DEBUG_VERBOSE 0
#if CFG_DEBUG_VERBOSE
#define log_debug(module, format_str, ...) logger::push( \
LOG_FORMAT("M", module, format_str, ## __VA_ARGS__), logger::Style::GREY)
#else
#define log_debug(module, format_str, ...)
#endif
///////////////////
/// Constructor ///
@@ -595,7 +603,7 @@ bool Config::updateBinding(const Game &game, const Button &button, int alternati
// found a node for this button, which means to_delete is not the first one
// delete the node for to_delete
if (to_delete != nullptr) {
log_misc("cfg", "deleting excessive button binding for {}", name);
log_debug("cfg", "deleting excessive button binding for {}", name);
gameButtonsNode->DeleteChild(to_delete);
to_delete = nullptr;
}
@@ -812,7 +820,7 @@ bool Config::updateBinding(const Game &game, const Light &light, int alternative
// found a node for this button, which means to_delete is not the first one
// delete the node for to_delete
if (to_delete != nullptr) {
log_misc("cfg", "deleting excessive light binding for {}", name);
log_debug("cfg", "deleting excessive light binding for {}", name);
gameLightsNode->DeleteChild(to_delete);
to_delete = nullptr;
}
+30 -23
View File
@@ -650,6 +650,7 @@ namespace overlay::windows {
// column for key binding display
ImGui::TableNextColumn();
ImGui::AlignTextToFramePadding();
if (button_display.size() > 0) {
if (button_state) {
ImGui::PushStyleColor(ImGuiCol_Text, TEXT_COLOR_GREEN);
}
@@ -659,16 +660,20 @@ namespace overlay::windows {
if (button_state) {
ImGui::PopStyleColor();
}
if (ImGui::IsItemHovered() && button_display.size() > 0) {
if (ImGui::IsItemHovered()) {
ImGui::SameLine();
ImGui::HelpTooltip(button_display.c_str());
}
} else {
// placeholder
ImGui::TextDisabled("-");
}
// clear button
if (button_display.size() > 0) {
ImGui::SameLine();
if (ImGui::DeleteButton("Unbind")) {
clear_button(*button);
clear_button(button);
}
}
@@ -776,18 +781,18 @@ namespace overlay::windows {
ImGui::PopID();
}
void Config::clear_button(Button &button) {
button.setDeviceIdentifier("");
button.setVKey(0xFF);
button.setAnalogType(BAT_NONE);
button.setDebounceUp(0.0);
button.setDebounceDown(0.0);
button.setVelocityThreshold(0);
button.setInvert(false);
button.setLastState(GameAPI::Buttons::BUTTON_NOT_PRESSED);
button.setLastVelocity(0);
void Config::clear_button(Button *button) {
button->setDeviceIdentifier("");
button->setVKey(0xFF);
button->setAnalogType(BAT_NONE);
button->setDebounceUp(0.0);
button->setDebounceDown(0.0);
button->setVelocityThreshold(0);
button->setInvert(false);
button->setLastState(GameAPI::Buttons::BUTTON_NOT_PRESSED);
button->setLastVelocity(0);
::Config::getInstance().updateBinding(
games_list[games_selected], button,
games_list[games_selected], *button,
buttons_page - 1);
}
@@ -1742,13 +1747,17 @@ namespace overlay::windows {
ImGui::TableNextColumn();
ImGui::AlignTextToFramePadding();
if (analog_display.size() > 0) {
std::string analog_text = ImGui::TruncateText(
analog_display, ImGui::GetContentRegionAvail().x - overlay::apply_scaling(20));
ImGui::TextUnformatted(analog_text.c_str());
if (ImGui::IsItemHovered() && analog_display.size() > 0) {
if (ImGui::IsItemHovered()) {
ImGui::SameLine();
ImGui::HelpTooltip(analog_display.c_str());
}
} else {
ImGui::TextDisabled("-");
}
// clear analog
if (analog_display.size() > 0) {
@@ -2191,9 +2200,6 @@ namespace overlay::windows {
auto light_state = GameAPI::Lights::readLight(RI_MGR, *light);
// list entry
if (light_display.empty()) {
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.7f, 0.7f, 0.7f, 1.f));
}
ImGui::PushID(light);
ImGui::TableNextRow();
@@ -2206,13 +2212,17 @@ namespace overlay::windows {
// binding name
ImGui::TableNextColumn();
ImGui::AlignTextToFramePadding();
if (light_display.size() > 0) {
std::string light_text = ImGui::TruncateText(
light_display, ImGui::GetContentRegionAvail().x - overlay::apply_scaling(20));
ImGui::TextUnformatted(light_text.c_str());
if (ImGui::IsItemHovered() && light_display.size() > 0) {
if (ImGui::IsItemHovered()) {
ImGui::SameLine();
ImGui::HelpTooltip(light_display.c_str());
}
} else {
ImGui::TextDisabled("-");
}
// clear light
if (light_display.size() > 0) {
@@ -2228,9 +2238,6 @@ namespace overlay::windows {
// bind button
ImGui::TableNextColumn();
if (light_display.empty()) {
ImGui::PopStyleColor();
}
// light binding
if (ImGui::Button("Set")) {
@@ -2790,8 +2797,8 @@ namespace overlay::windows {
} else {
ImGui::TextColored(TEXT_COLOR_GREEN, "%s", definition.title.c_str());
}
} else if (definition.hidden
|| (!definition.game_name.empty() && definition.game_name != this->games_selected_name)) {
} else if (definition.hidden ||
(!definition.game_name.empty() && definition.game_name != this->games_selected_name)) {
// wrong game - grayed out
ImGui::TextColored(ImVec4(0.5f, 0.5f, 0.5f, 1.f), "%s", definition.title.c_str());
} else {
+1 -1
View File
@@ -88,7 +88,7 @@ namespace overlay::windows {
Button *button,
const GameAPI::Buttons::State button_state,
const float button_velocity);
void clear_button(Button &button);
void clear_button(Button *button);
void build_analogs(const std::string &name, std::vector<Analog> *analogs);
void edit_analog_popup(Analog &analog);