From d61ea5fd5de005647d150b3514d8ba50c3eda6cf Mon Sep 17 00:00:00 2001 From: Maschell Date: Mon, 6 Jan 2025 11:47:23 +0100 Subject: [PATCH] ConfigMenu: Show wiimote button when the last input was on a wiimote --- source/main.cpp | 2 +- source/utils/config/ConfigRenderer.cpp | 26 +++++++++++++++++++++++--- source/utils/config/ConfigRenderer.h | 7 ++++--- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/source/main.cpp b/source/main.cpp index 3581bf1..f82fd76 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -88,7 +88,7 @@ WUMS_INITIALIZE() { message = "To enable them again, open the plugin config menu (\ue004 + \ue07a + \ue046)."; DrawUtils::print(SCREEN_WIDTH / 2 + DrawUtils::getTextWidth(message) / 2, SCREEN_HEIGHT / 2 + 24, message, true); - message = "Then press \ue002 to manage active plugins"; + message = "Then press \ue002 or \uE048 to manage active plugins"; DrawUtils::print(SCREEN_WIDTH / 2 + DrawUtils::getTextWidth(message) / 2, SCREEN_HEIGHT / 2 + 48, message, true); // draw bottom bar diff --git a/source/utils/config/ConfigRenderer.cpp b/source/utils/config/ConfigRenderer.cpp index c29280c..9ab4500 100644 --- a/source/utils/config/ConfigRenderer.cpp +++ b/source/utils/config/ConfigRenderer.cpp @@ -25,6 +25,25 @@ ConfigRenderer::ConfigRenderer(std::vector &&vec) : mConfigs( ConfigRenderer::~ConfigRenderer() = default; ConfigSubState ConfigRenderer::Update(Input &input, const WUPSConfigSimplePadData &simpleInputData, const WUPSConfigComplexPadData &complexInputData) { + // Check if the last input was on a wiimote + for (uint32_t i = 0; i < std::size(complexInputData.kpad.data); i++) { + const KPADError &kpadError = complexInputData.kpad.kpadError[i]; + const KPADStatus &status = complexInputData.kpad.data[i]; + + const bool isWiimote = status.extensionType == WPAD_EXT_CORE || status.extensionType == WPAD_EXT_NUNCHUK || + status.extensionType == WPAD_EXT_MPLUS || status.extensionType == WPAD_EXT_MPLUS_NUNCHUK; + + if (kpadError == KPAD_ERROR_OK) { + if (isWiimote && status.hold != 0) { + mLastInputWasOnWiimote = true; + } else if (!isWiimote && status.classic.hold != 0) { + mLastInputWasOnWiimote = false; + } + } + } + if (complexInputData.vpad.vpadError == VPAD_READ_SUCCESS && complexInputData.vpad.data.hold != 0) { + mLastInputWasOnWiimote = false; + } switch (mState) { case STATE_MAIN: return UpdateStateMain(input); @@ -183,8 +202,8 @@ void ConfigRenderer::RenderStateMain() const { uint32_t szNoConfig = DrawUtils::getTextWidth(noConfigText.data()); if (!mAllConfigs.empty()) { - std::string activateHint = "Press \ue002 to activate inactive plugins"; - auto szHint = DrawUtils::getTextWidth(activateHint.c_str()); + const auto activateHint = string_format("Press %s to activate inactive plugins", mLastInputWasOnWiimote ? "\uE048" : "\uE002"); + const auto szHint = DrawUtils::getTextWidth(activateHint.c_str()); DrawUtils::print((SCREEN_WIDTH / 2) - (szNoConfig / 2), (SCREEN_HEIGHT / 2) - 16, noConfigText.data()); DrawUtils::print((SCREEN_WIDTH / 2) - (szHint / 2), (SCREEN_HEIGHT / 2) + 16, activateHint.data()); @@ -226,7 +245,8 @@ void ConfigRenderer::RenderStateMain() const { if (mSetActivePluginsMode) { DrawUtils::print(SCREEN_WIDTH - 16, SCREEN_HEIGHT - 10, "\ue000 Activate | \uE045 Apply", true); } else if (totalElementSize > 0) { - DrawUtils::print(SCREEN_WIDTH - 16, SCREEN_HEIGHT - 10, "\ue000 Select | \uE002 Manage plugins", true); + const auto text = string_format("\ue000 Select | %s Manage plugins", mLastInputWasOnWiimote ? "\uE048" : "\uE002"); + DrawUtils::print(SCREEN_WIDTH - 16, SCREEN_HEIGHT - 10, text.c_str(), true); } // draw scroll indicator diff --git a/source/utils/config/ConfigRenderer.h b/source/utils/config/ConfigRenderer.h index 1600e85..7b15154 100644 --- a/source/utils/config/ConfigRenderer.h +++ b/source/utils/config/ConfigRenderer.h @@ -63,7 +63,8 @@ class ConfigRenderer { int32_t mRenderOffset = 0; int32_t mCurrentOpen = -1; - bool mNeedRedraw = true; - bool mSetActivePluginsMode = false; - bool mActivePluginsDirty = false; + bool mNeedRedraw = true; + bool mSetActivePluginsMode = false; + bool mActivePluginsDirty = false; + bool mLastInputWasOnWiimote = false; };