diff --git a/src/function_patcher.cpp b/src/function_patcher.cpp index 2d74cf4..fffe1d6 100644 --- a/src/function_patcher.cpp +++ b/src/function_patcher.cpp @@ -79,7 +79,14 @@ DECL_FUNCTION(void, WPADRead, WPADChan chan, WPADStatusProController *data) { uint32_t curButtonTrigger = (curButtonHold & (~(sWPADLastButtonHold[chan]))); - if (buttonComboConverted != 0 && curButtonTrigger == buttonComboConverted) { + bool forceScreenshot = false; + if (gReservedBitUsage && data[0].extensionType == WPAD_EXT_PRO_CONTROLLER) { + if (curButtonTrigger == WPAD_PRO_RESERVED) { + forceScreenshot = true; + } + } + + if (forceScreenshot || (buttonComboConverted != 0 && curButtonTrigger == buttonComboConverted)) { if (gImageSource == IMAGE_SOURCE_TV_AND_DRC || gImageSource == IMAGE_SOURCE_TV) { if (gTakeScreenshotTV == SCREENSHOT_STATE_READY) { DEBUG_FUNCTION_LINE("Requested screenshot for TV!"); diff --git a/src/main.cpp b/src/main.cpp index 7fa0186..65d595f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -25,11 +25,12 @@ WUPS_USE_WUT_DEVOPTAB(); WUPS_USE_STORAGE("screenshot_plugin"); -#define ENABLED_CONFIG_STRING "enabled" -#define BUTTON_COMBO_CONFIG_STRING "buttonCombo" -#define FORMAT_CONFIG_STRING "format" -#define QUALITY_CONFIG_STRING "quality" -#define SCREEN_CONFIG_STRING "screen" +#define ENABLED_CONFIG_STRING "enabled" +#define BUTTON_COMBO_CONFIG_STRING "buttonCombo" +#define FORMAT_CONFIG_STRING "format" +#define QUALITY_CONFIG_STRING "quality" +#define SCREEN_CONFIG_STRING "screen" +#define RESERVED_BIT_USAGE_CONFIG_STRING "reservedBitUsage" // Gets called once the loader exists. INITIALIZE_PLUGIN() { @@ -91,6 +92,16 @@ INITIALIZE_PLUGIN() { DEBUG_FUNCTION_LINE_ERR("Failed to get value %s (%d)", WUPS_GetStorageStatusStr(storageRes), storageRes); } + // Try to get value from storage + if ((storageRes = WUPS_GetBool(nullptr, RESERVED_BIT_USAGE_CONFIG_STRING, &gReservedBitUsage)) == WUPS_STORAGE_ERROR_NOT_FOUND) { + // Add the value to the storage if it's missing. + if (WUPS_StoreBool(nullptr, RESERVED_BIT_USAGE_CONFIG_STRING, gReservedBitUsage) != WUPS_STORAGE_ERROR_SUCCESS) { + DEBUG_FUNCTION_LINE_ERR("Failed to store value"); + } + } else if (storageRes != WUPS_STORAGE_ERROR_SUCCESS) { + DEBUG_FUNCTION_LINE_ERR("Failed to get value %s (%d)", WUPS_GetStorageStatusStr(storageRes), storageRes); + } + // Close storage if (WUPS_CloseStorage() != WUPS_STORAGE_ERROR_SUCCESS) { DEBUG_FUNCTION_LINE_ERR("Failed to close storage"); @@ -150,8 +161,11 @@ void boolItemCallback(ConfigItemBoolean *item, bool newValue) { if (item && item->configId) { DEBUG_FUNCTION_LINE("New value in %s changed: %d", item->configId, newValue); if (std::string_view(item->configId) == ENABLED_CONFIG_STRING) { - gEnabled = (ImageOutputFormatEnum) newValue; + gEnabled = newValue; WUPS_StoreBool(nullptr, item->configId, gEnabled); + } else if (std::string_view(item->configId) == RESERVED_BIT_USAGE_CONFIG_STRING) { + gReservedBitUsage = newValue; + WUPS_StoreBool(nullptr, item->configId, gReservedBitUsage); } } } @@ -232,6 +246,8 @@ WUPS_GET_CONFIG() { WUPSConfigItemIntegerRange_AddToCategoryHandled(config, setting, QUALITY_CONFIG_STRING, "JPEG quality", gQuality, 10, 100, &integerRangeItemCallback); + WUPSConfigItemBoolean_AddToCategoryHandled(config, setting, RESERVED_BIT_USAGE_CONFIG_STRING, "Check ReservedBit for taking Screenshots", gReservedBitUsage, &boolItemCallback); + return config; } diff --git a/src/retain_vars.cpp b/src/retain_vars.cpp index 229cba4..72f8291 100644 --- a/src/retain_vars.cpp +++ b/src/retain_vars.cpp @@ -11,4 +11,6 @@ ImageOutputFormatEnum gOutputFormat = IMAGE_OUTPUT_FORMAT_JPEG; std::string gShortNameEn; ScreenshotState gTakeScreenshotTV = SCREENSHOT_STATE_READY; -ScreenshotState gTakeScreenshotDRC = SCREENSHOT_STATE_READY; \ No newline at end of file +ScreenshotState gTakeScreenshotDRC = SCREENSHOT_STATE_READY; + +bool gReservedBitUsage = true; \ No newline at end of file diff --git a/src/retain_vars.hpp b/src/retain_vars.hpp index f553314..2ed50b3 100644 --- a/src/retain_vars.hpp +++ b/src/retain_vars.hpp @@ -13,4 +13,6 @@ extern ImageOutputFormatEnum gOutputFormat; extern std::string gShortNameEn; extern ScreenshotState gTakeScreenshotTV; -extern ScreenshotState gTakeScreenshotDRC; \ No newline at end of file +extern ScreenshotState gTakeScreenshotDRC; + +extern bool gReservedBitUsage; \ No newline at end of file