mGUI: Add variants
Vicki Pfau vi@endrift.com
Sat, 29 Sep 2018 11:09:16 -0700
4 files changed,
110 insertions(+),
2 deletions(-)
M
CHANGES
→
CHANGES
@@ -108,8 +108,10 @@ - PSP2: Fix audio crackling when buffer is full
- 3DS: Fix unused screens not clearing (fixes mgba.io/i/1184) - GBA Video: Fix caching with background toggling (fixes mgba.io/i/1118) - Wii: Fix drawing caching regression (fixes mgba.io/i/1185) + - Switch: Fix incorrect mapping for fast forward cap Misc: - mGUI: Add SGB border configuration option + - mGUI: Add support for different settings types 0.7 beta 1: (2018-09-24) - Initial beta for 0.7
M
src/feature/gui/gui-config.c
→
src/feature/gui/gui-config.c
@@ -162,7 +162,50 @@ item = GUIMenuItemListGetPointer(&menu.items, i);
if (!item->validStates || !item->data) { continue; } - mCoreConfigGetUIntValue(&runner->config, item->data, &item->state); + if (item->stateMappings) { + item->state = 0; + + size_t j; + for (j = 0; j < item->nStates; ++j) { + const struct GUIVariant* v = &item->stateMappings[j]; + struct GUIVariant test; + switch (v->type) { + case GUI_VARIANT_VOID: + if (!mCoreConfigGetValue(&runner->config, item->data)) { + item->state = j; + break; + } + break; + case GUI_VARIANT_UNSIGNED: + if (mCoreConfigGetUIntValue(&runner->config, item->data, &test.v.u) && test.v.u == v->v.u) { + item->state = j; + break; + } + break; + case GUI_VARIANT_INT: + if (mCoreConfigGetIntValue(&runner->config, item->data, &test.v.i) && test.v.i == v->v.i) { + item->state = j; + break; + } + break; + case GUI_VARIANT_FLOAT: + if (mCoreConfigGetFloatValue(&runner->config, item->data, &test.v.f) && fabsf(test.v.f - v->v.f) <= 1e-3f) { + item->state = j; + break; + } + break; + case GUI_VARIANT_STRING: + test.v.s = mCoreConfigGetValue(&runner->config, item->data); + if (test.v.s && strcmp(test.v.s, v->v.s) == 0) { + item->state = j; + break; + } + break; + } + } + } else { + mCoreConfigGetUIntValue(&runner->config, item->data, &item->state); + } } while (true) {@@ -188,7 +231,28 @@ item = GUIMenuItemListGetPointer(&menu.items, i);
if (!item->validStates || !item->data) { continue; } - mCoreConfigSetUIntValue(&runner->config, item->data, item->state); + if (item->stateMappings) { + const struct GUIVariant* v = &item->stateMappings[item->state]; + switch (v->type) { + case GUI_VARIANT_VOID: + mCoreConfigSetValue(&runner->config, item->data, NULL); + break; + case GUI_VARIANT_UNSIGNED: + mCoreConfigSetUIntValue(&runner->config, item->data, v->v.u); + break; + case GUI_VARIANT_INT: + mCoreConfigSetUIntValue(&runner->config, item->data, v->v.i); + break; + case GUI_VARIANT_FLOAT: + mCoreConfigSetFloatValue(&runner->config, item->data, v->v.f); + break; + case GUI_VARIANT_STRING: + mCoreConfigSetValue(&runner->config, item->data, v->v.s); + break; + } + } else { + mCoreConfigSetUIntValue(&runner->config, item->data, item->state); + } } if (runner->keySources) { size_t i;
M
src/platform/switch/main.c
→
src/platform/switch/main.c
@@ -528,6 +528,23 @@ "3", "4", "5", "6", "7", "8", "9",
"10", "11", "12", "13", "14", "15", "20", "30" }, + .stateMappings = (const struct GUIVariant[]) { + GUI_V_U(3), + GUI_V_U(4), + GUI_V_U(5), + GUI_V_U(6), + GUI_V_U(7), + GUI_V_U(8), + GUI_V_U(9), + GUI_V_U(10), + GUI_V_U(11), + GUI_V_U(12), + GUI_V_U(13), + GUI_V_U(14), + GUI_V_U(15), + GUI_V_U(20), + GUI_V_U(30), + }, .nStates = 15 }, },