From 0bd1feb1ff970e847bd9893aba15b7fabe04a73c Mon Sep 17 00:00:00 2001 From: Maschell Date: Sun, 22 Jan 2023 14:52:47 +0100 Subject: [PATCH] Support games that use VPADGetButtonProcMode (e.g. Zelda TP HD) --- src/function_patcher.cpp | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/src/function_patcher.cpp b/src/function_patcher.cpp index cd214f8..6b8e594 100644 --- a/src/function_patcher.cpp +++ b/src/function_patcher.cpp @@ -11,6 +11,8 @@ #include #include +extern "C" uint32_t VPADGetButtonProcMode(uint32_t); + DECL_FUNCTION(int32_t, VPADRead, VPADChan chan, VPADStatus *buffer, uint32_t buffer_size, VPADReadError *error) { VPADReadError real_error; @@ -18,23 +20,31 @@ DECL_FUNCTION(int32_t, VPADRead, VPADChan chan, VPADStatus *buffer, uint32_t buf if (gEnabled && (gTakeScreenshotTV == SCREENSHOT_STATE_READY || gTakeScreenshotDRC == SCREENSHOT_STATE_READY)) { if (result > 0 && real_error == VPAD_READ_SUCCESS) { - if (((buffer[0].trigger & 0x000FFFFF) == gButtonCombo)) { - if (!OSIsHomeButtonMenuEnabled()) { - DEBUG_FUNCTION_LINE("Screenshots are disabled"); - } else { - if (gImageSource == IMAGE_SOURCE_TV_AND_DRC || gImageSource == IMAGE_SOURCE_TV) { - if (gTakeScreenshotTV == SCREENSHOT_STATE_READY) { - DEBUG_FUNCTION_LINE("Requested screenshot for TV!"); - gTakeScreenshotTV = SCREENSHOT_STATE_REQUESTED; + uint32_t end = 1; + // Fix games like TP HD + if (VPADGetButtonProcMode(chan) == 1) { + end = result; + } + for (uint32_t i = 0; i < end; i++) { + if (((buffer[i].trigger & 0x000FFFFF) == gButtonCombo)) { + if (!OSIsHomeButtonMenuEnabled()) { + DEBUG_FUNCTION_LINE("Screenshots are disabled"); + } else { + if (gImageSource == IMAGE_SOURCE_TV_AND_DRC || gImageSource == IMAGE_SOURCE_TV) { + if (gTakeScreenshotTV == SCREENSHOT_STATE_READY) { + DEBUG_FUNCTION_LINE("Requested screenshot for TV!"); + gTakeScreenshotTV = SCREENSHOT_STATE_REQUESTED; + } } - } - if (gImageSource == IMAGE_SOURCE_TV_AND_DRC || gImageSource == IMAGE_SOURCE_DRC) { - if (gTakeScreenshotDRC == SCREENSHOT_STATE_READY) { - DEBUG_FUNCTION_LINE("Requested screenshot for DRC!"); - gTakeScreenshotDRC = SCREENSHOT_STATE_REQUESTED; + if (gImageSource == IMAGE_SOURCE_TV_AND_DRC || gImageSource == IMAGE_SOURCE_DRC) { + if (gTakeScreenshotDRC == SCREENSHOT_STATE_READY) { + DEBUG_FUNCTION_LINE("Requested screenshot for DRC!"); + gTakeScreenshotDRC = SCREENSHOT_STATE_REQUESTED; + } } + OSMemoryBarrier(); } - OSMemoryBarrier(); + break; } } }