diff --git a/source/main.cpp b/source/main.cpp index f422bd6..1d443a0 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -50,7 +50,7 @@ WUMS_INITIALIZE() { vpadInput.update(1280, 720); auto buttomComboSafeMode = Input::eButtons::BUTTON_L | Input::eButtons::BUTTON_UP | Input::eButtons::BUTTON_MINUS; if ((vpadInput.data.buttons_h & (buttomComboSafeMode)) == buttomComboSafeMode) { - DrawUtils::RenderScreen([] { + DrawUtils::RenderScreen([&vpadInput] { DrawUtils::beginDraw(); DrawUtils::clear(COLOR_BACKGROUND_WARN); DrawUtils::setFontColor(COLOR_WARNING); @@ -69,18 +69,24 @@ 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 = "Press then \ue002 to manage active plugins"; + message = "Then press \ue002 to manage active plugins"; DrawUtils::print(SCREEN_WIDTH / 2 + DrawUtils::getTextWidth(message) / 2, SCREEN_HEIGHT / 2 + 48, message, true); // draw bottom bar DrawUtils::drawRectFilled(8, SCREEN_HEIGHT - 24 - 8 - 4, SCREEN_WIDTH - 8 * 2, 3, COLOR_WHITE); DrawUtils::setFontSize(18); - const char *exitHints = "The console will continue to boot in 10 seconds."; + const char *exitHints = "Continuing in 10 seconds."; DrawUtils::print(SCREEN_WIDTH / 2 + DrawUtils::getTextWidth(exitHints) / 2, SCREEN_HEIGHT - 8, exitHints, true); DrawUtils::endDraw(); - std::this_thread::sleep_for(10s); + for (int i = 0; i < 10000 / 16; i++) { + vpadInput.update(1280, 720); + if ((vpadInput.data.buttons_d & (ANY_BUTTON_MASK))) { + break; + } + std::this_thread::sleep_for(16ms); + } }); DEBUG_FUNCTION_LINE_INFO("Safe Mode activated!"); auto tobeIgnoredFilePath = getNonBaseAromaPluginFilenames(getPluginPath()); diff --git a/source/utils/config/ConfigRenderer.cpp b/source/utils/config/ConfigRenderer.cpp index 86a8ab3..91720e5 100644 --- a/source/utils/config/ConfigRenderer.cpp +++ b/source/utils/config/ConfigRenderer.cpp @@ -211,7 +211,7 @@ void ConfigRenderer::RenderStateMain() const { DrawUtils::setFontSize(18); DrawUtils::print(16, SCREEN_HEIGHT - 10, "\ue07d Navigate "); if (mSetActivePluginsMode) { - DrawUtils::print(SCREEN_WIDTH - 16, SCREEN_HEIGHT - 10, "\ue000 Activate | \uE045 Apply", true); + 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); } diff --git a/source/utils/config/ConfigUtils.cpp b/source/utils/config/ConfigUtils.cpp index 199c034..9ee5f06 100644 --- a/source/utils/config/ConfigUtils.cpp +++ b/source/utils/config/ConfigUtils.cpp @@ -161,7 +161,8 @@ void ConfigUtils::displayMenu() { OSTime startTime; bool skipFirstInput = true; - gOnlyAcceptFromThread = OSGetCurrentThread(); + gOnlyAcceptFromThread = OSGetCurrentThread(); + ConfigSubState subStateReturnValue = SUB_STATE_ERROR; while (true) { startTime = OSGetTime(); if (gConfigMenuShouldClose) { @@ -201,8 +202,8 @@ void ConfigUtils::displayMenu() { complexData.kpad.data[i] = wpadInputs[i].kpad; } - auto subState = renderer.Update(baseInput, simpleData, complexData); - if (subState != SUB_STATE_RUNNING) { + subStateReturnValue = renderer.Update(baseInput, simpleData, complexData); + if (subStateReturnValue != SUB_STATE_RUNNING) { break; } if (renderer.NeedsRedraw() || baseInput.data.buttons_d || baseInput.data.buttons_r) { @@ -220,7 +221,7 @@ void ConfigUtils::displayMenu() { std::vector newActivePluginsList; - if (renderer.GetActivePluginsIfChanged(newActivePluginsList)) { + if (subStateReturnValue == SUB_STATE_RETURN_WITH_PLUGIN_RELOAD && renderer.GetActivePluginsIfChanged(newActivePluginsList)) { startTime = OSGetTime(); renderBasicScreen("Applying changes, app will now restart..."); @@ -230,9 +231,7 @@ void ConfigUtils::displayMenu() { for (const auto &cur : newActivePluginsList) { if (!cur.isLoadAndLink()) { auto &source = cur.getPluginData()->getSource(); - // TODO: Make sure to only use plugins from the actual plugin directory? - // atm nothing (to my knowledge) is using the WUPS API to load any plugin from a path though - if (source.ends_with(".wps")) { + if (source.starts_with(getPluginPath()) && source.ends_with(".wps")) { std::size_t found = source.find_last_of("/\\"); std::string filename = source.substr(found + 1); newInactivePluginsList.push_back(filename); @@ -241,7 +240,9 @@ void ConfigUtils::displayMenu() { } gLoadOnNextLaunch = newActivePluginsList; WUPSBackendSettings::SetInactivePluginFilenames(newInactivePluginsList); - WUPSBackendSettings::SaveSettings(); + if (!WUPSBackendSettings::SaveSettings()) { + DEBUG_FUNCTION_LINE_WARN("Failed to save WUPSBackendSettings"); + } _SYSLaunchTitleWithStdArgsInNoSplash(OSGetTitleID(), nullptr); // Make sure to wait at least 2 seconds so user can read the screen and @@ -252,18 +253,19 @@ void ConfigUtils::displayMenu() { } } else { renderBasicScreen("Saving configs..."); - for (const auto &plugin : gLoadedPlugins) { - const auto configData = plugin.getConfigData(); - if (configData) { - if (configData->CallMenuClosedCallback() == WUPSCONFIG_API_RESULT_MISSING_CALLBACK) { - DEBUG_FUNCTION_LINE_WARN("CallMenuClosedCallback is missing for %s", plugin.getMetaInformation().getName().c_str()); - } - } else { - CallHook(plugin, WUPS_LOADER_HOOK_CONFIG_CLOSED_DEPRECATED); + } + for (const auto &plugin : gLoadedPlugins) { + const auto configData = plugin.getConfigData(); + if (configData) { + if (configData->CallMenuClosedCallback() == WUPSCONFIG_API_RESULT_MISSING_CALLBACK) { + DEBUG_FUNCTION_LINE_WARN("CallMenuClosedCallback is missing for %s", plugin.getMetaInformation().getName().c_str()); } + } else { + CallHook(plugin, WUPS_LOADER_HOOK_CONFIG_CLOSED_DEPRECATED); } } + WUPSConfigAPIBackend::Intern::CleanAllHandles(); // we want wait at least 300ms to avoid leaking inputs from the config menu to the application diff --git a/source/utils/input/Input.h b/source/utils/input/Input.h index 1b2f44e..d8afde6 100644 --- a/source/utils/input/Input.h +++ b/source/utils/input/Input.h @@ -45,6 +45,19 @@ public: STICK_L_DOWN = 0x08000000 }; +#define ANY_BUTTON_MASK (Input::eButtons::BUTTON_L | \ + Input::eButtons::BUTTON_R | \ + Input::eButtons::BUTTON_PLUS | \ + Input::eButtons::BUTTON_MINUS | \ + Input::eButtons::BUTTON_A | \ + Input::eButtons::BUTTON_B | \ + Input::eButtons::BUTTON_X | \ + Input::eButtons::BUTTON_Y | \ + Input::eButtons::BUTTON_DOWN | \ + Input::eButtons::BUTTON_LEFT | \ + Input::eButtons::BUTTON_RIGHT | \ + Input::eButtons::BUTTON_UP) + typedef struct { uint32_t buttons_h; uint32_t buttons_d; diff --git a/source/utils/utils.cpp b/source/utils/utils.cpp index ddc81a5..5cd464c 100644 --- a/source/utils/utils.cpp +++ b/source/utils/utils.cpp @@ -34,6 +34,7 @@ std::string getEnvironmentPath() { sEnvironmentPath = environmentPath; return sEnvironmentPath; } + std::string getPluginPath() { if (!sPluginPath.empty()) { return sPluginPath;