Add option to take screenshot on the Pro Controllers reserved bit, regardless of the mapping

This commit is contained in:
Maschell 2023-01-22 16:36:40 +01:00
parent 3f3c236bb9
commit da7565dbdd
4 changed files with 36 additions and 9 deletions

View File

@ -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!");

View File

@ -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;
}

View File

@ -11,4 +11,6 @@ ImageOutputFormatEnum gOutputFormat = IMAGE_OUTPUT_FORMAT_JPEG;
std::string gShortNameEn;
ScreenshotState gTakeScreenshotTV = SCREENSHOT_STATE_READY;
ScreenshotState gTakeScreenshotDRC = SCREENSHOT_STATE_READY;
ScreenshotState gTakeScreenshotDRC = SCREENSHOT_STATE_READY;
bool gReservedBitUsage = true;

View File

@ -13,4 +13,6 @@ extern ImageOutputFormatEnum gOutputFormat;
extern std::string gShortNameEn;
extern ScreenshotState gTakeScreenshotTV;
extern ScreenshotState gTakeScreenshotDRC;
extern ScreenshotState gTakeScreenshotDRC;
extern bool gReservedBitUsage;