mirror of
https://github.com/wiiu-env/ScreenshotWUPS.git
synced 2024-11-26 07:44:15 +01:00
Fix WPAD button combo detection to check if the button was pressed instead of hold
This commit is contained in:
parent
bf8867a107
commit
9032d67c17
@ -56,32 +56,30 @@ DECL_FUNCTION(int32_t, VPADRead, VPADChan chan, VPADStatus *buffer, uint32_t buf
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint32_t sWPADLastButtonHold[4];
|
||||||
DECL_FUNCTION(void, WPADRead, WPADChan chan, WPADStatusProController *data) {
|
DECL_FUNCTION(void, WPADRead, WPADChan chan, WPADStatusProController *data) {
|
||||||
real_WPADRead(chan, data);
|
real_WPADRead(chan, data);
|
||||||
|
|
||||||
if (gEnabled && OSIsHomeButtonMenuEnabled() && (gTakeScreenshotTV == SCREENSHOT_STATE_READY || gTakeScreenshotDRC == SCREENSHOT_STATE_READY)) {
|
if (gEnabled && chan >= 0 && chan < 4 && OSIsHomeButtonMenuEnabled() && (gTakeScreenshotTV == SCREENSHOT_STATE_READY || gTakeScreenshotDRC == SCREENSHOT_STATE_READY)) {
|
||||||
if (data[0].err == 0) {
|
if (data[0].err == 0) {
|
||||||
if (data[0].extensionType != 0xFF) {
|
if (data[0].extensionType != 0xFF) {
|
||||||
bool takeScreenshot = false;
|
uint32_t curButtonHold = 0;
|
||||||
|
uint32_t buttonComboConverted = 0;
|
||||||
if (data[0].extensionType == WPAD_EXT_CORE || data[0].extensionType == WPAD_EXT_NUNCHUK) {
|
if (data[0].extensionType == WPAD_EXT_CORE || data[0].extensionType == WPAD_EXT_NUNCHUK) {
|
||||||
auto buttonCombo = remapVPADtoWiimote(gButtonCombo);
|
buttonComboConverted = remapVPADtoWiimote(gButtonCombo);
|
||||||
// button data is in the first 2 bytes for wiimotes
|
// button data is in the first 2 bytes for wiimotes
|
||||||
if (buttonCombo != 0 && ((uint16_t *) data)[0] == buttonCombo) {
|
curButtonHold = ((uint16_t *) data)[0];
|
||||||
takeScreenshot = true;
|
|
||||||
}
|
|
||||||
} else if (data[0].extensionType == WPAD_EXT_CLASSIC) {
|
} else if (data[0].extensionType == WPAD_EXT_CLASSIC) {
|
||||||
auto buttonCombo = remapVPADtoClassic(gButtonCombo);
|
buttonComboConverted = remapVPADtoClassic(gButtonCombo);
|
||||||
if (buttonCombo != 0 && (((uint32_t *) data)[10] & 0xFFFF) == buttonCombo) {
|
curButtonHold = (((uint32_t *) data)[10] & 0xFFFF);
|
||||||
takeScreenshot = true;
|
|
||||||
}
|
|
||||||
} else if (data[0].extensionType == WPAD_EXT_PRO_CONTROLLER) {
|
} else if (data[0].extensionType == WPAD_EXT_PRO_CONTROLLER) {
|
||||||
auto buttonCombo = remapVPADtoPro(gButtonCombo);
|
buttonComboConverted = remapVPADtoPro(gButtonCombo);
|
||||||
|
curButtonHold = data[0].buttons;
|
||||||
if (buttonCombo != 0 && data[0].buttons == buttonCombo) {
|
|
||||||
takeScreenshot = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (takeScreenshot) {
|
|
||||||
|
uint32_t curButtonTrigger = (curButtonHold & (~(sWPADLastButtonHold[chan])));
|
||||||
|
|
||||||
|
if (buttonComboConverted != 0 && curButtonTrigger == buttonComboConverted) {
|
||||||
if (gImageSource == IMAGE_SOURCE_TV_AND_DRC || gImageSource == IMAGE_SOURCE_TV) {
|
if (gImageSource == IMAGE_SOURCE_TV_AND_DRC || gImageSource == IMAGE_SOURCE_TV) {
|
||||||
if (gTakeScreenshotTV == SCREENSHOT_STATE_READY) {
|
if (gTakeScreenshotTV == SCREENSHOT_STATE_READY) {
|
||||||
DEBUG_FUNCTION_LINE("Requested screenshot for TV!");
|
DEBUG_FUNCTION_LINE("Requested screenshot for TV!");
|
||||||
@ -96,6 +94,8 @@ DECL_FUNCTION(void, WPADRead, WPADChan chan, WPADStatusProController *data) {
|
|||||||
}
|
}
|
||||||
OSMemoryBarrier();
|
OSMemoryBarrier();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sWPADLastButtonHold[chan] = curButtonHold;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user