From 88e044dcd3710092bc6d48cf14a7eee9a196a249 Mon Sep 17 00:00:00 2001 From: Wellington Dias Date: Sun, 1 Nov 2026 13:53:53 -0300 Subject: [PATCH] Mark a per-stick dead zone row as default at the shared value, and unset it when stepped back onto that value. --- runtime/ui/option_rows.cpp | 8 ++++++-- runtime/ui/option_rows.h | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/runtime/ui/option_rows.cpp b/runtime/ui/option_rows.cpp index 78725fd3..6074ca12 100644 --- a/runtime/ui/option_rows.cpp +++ b/runtime/ui/option_rows.cpp @@ -353,7 +353,10 @@ bool opt_slider(const char *key, UiTextId label, float lo, float hi, UiTextId de const char *set = cfg_get(key); const char *src = fallback && !(set && *set) ? fallback : key; // unset: show the value in effect, the fallback's const CfgMeta *m = cfg_meta(src); - double v = cfg_double(src), def = m ? strtod(m->def, NULL) : lo; + // A key without a table default of its own (the per-stick dead zones) defaults to its fallback: the "default" mark + // follows the fallback's default, not 0, even once the key is set. + if (fallback && m && !m->def[0]) m = cfg_meta(fallback); + double v = cfg_double(src), def = m && m->def[0] ? strtod(m->def, NULL) : lo; char shown[48]; snprintf(shown, sizeof shown, fmt, v); RowView rv = {shown, fabs(v - def) < step * 0.01, true, note}; @@ -367,7 +370,8 @@ bool opt_slider(const char *key, UiTextId label, float lo, float hi, UiTextId de char out[32]; if (step >= 1) snprintf(out, sizeof out, "%d", (int)lround(n)); else snprintf(out, sizeof out, "%g", round(n / step) * step); - apply(key, out); + // Landing on the fallback's value unsets the key (its line leaves totk.ini), so the row follows the fallback again. + apply(key, fallback && fabs(n - cfg_double(fallback)) < step * 0.01 ? "" : out); return true; } diff --git a/runtime/ui/option_rows.h b/runtime/ui/option_rows.h index 83cf4f87..b15933b3 100644 --- a/runtime/ui/option_rows.h +++ b/runtime/ui/option_rows.h @@ -61,7 +61,8 @@ void opt_group_text(const char *title); void opt_text_str(const char *text, bool warn = false); // lo..hi in steps of step (left and right held for a second go ten times as fast); fmt formats the value ("%.0f %%"). // note: a short line under the value in place of the "default" mark (NULL: none). fallback: the setting that applies -// while key is unset; the row shows its value then, and a change sets key. +// while key is unset; the row shows its value then, and a change sets key. A key with no table default of its own takes +// the "default" mark from the fallback's default, and a step onto the fallback's value unsets key again. bool opt_slider(const char *key, UiTextId label, float lo, float hi, UiTextId desc, float step = 1, const char *fmt = "%g", const char *note = nullptr, const char *fallback = nullptr);