Skip to content

Commit

Permalink
Cleanup code, improve variable naming
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew1Hawes committed Dec 3, 2023
1 parent 37704fd commit b376ca6
Showing 1 changed file with 15 additions and 19 deletions.
34 changes: 15 additions & 19 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,25 +229,24 @@ DECL_FUNCTION(int32_t, ACPGetLaunchMetaXml, ACPMetaXml *metaXml)
const bool DRC_USE = metaXml->drc_use == 65537;

//check if A button held, if so then skip autolaunch check
VPADStatus vpadStatus {};
VPADStatus vpadStatus{};
VPADReadError vpadError = VPAD_READ_UNINITIALIZED;
KPADStatus kpadStatus[4];
KPADError kpadError[4];
uint32_t buttonsHeld = 0;
bool activateCursor = true;

VPADRead(VPAD_CHAN_0, &vpadStatus, 1, &vpadError);
if (vpadError == VPAD_READ_SUCCESS) {
if (VPADRead(VPAD_CHAN_0, &vpadStatus, 1, &vpadError) > 0 && vpadError == VPAD_READ_SUCCESS) {
buttonsHeld = vpadStatus.hold;
}

for (int32_t i = 0; i < 4; i++) {
if (KPADReadEx((KPADChan) i, &kpadStatus[i], 1, &kpadError[i]) > 0) {
if (kpadError[i] == KPAD_ERROR_OK && kpadStatus[i].extensionType != 0xFF) {
if (kpadStatus[i].extensionType == WPAD_EXT_CORE || kpadStatus[i].extensionType == WPAD_EXT_NUNCHUK) {
buttonsHeld |= remapWiiMoteButtons(kpadStatus[i].hold);
for (int32_t chan = 0; chan < 4; chan++) {
if (KPADReadEx((KPADChan) chan, &kpadStatus[chan], 1, &kpadError[chan]) > 0) {
if (kpadError[chan] == KPAD_ERROR_OK && kpadStatus[chan].extensionType != 0xFF) {
if (kpadStatus[chan].extensionType == WPAD_EXT_CORE || kpadStatus[chan].extensionType == WPAD_EXT_NUNCHUK) {
buttonsHeld |= remapWiiMoteButtons(kpadStatus[chan].hold);
} else {
buttonsHeld |= remapClassicButtons(kpadStatus[i].classic.hold);
buttonsHeld |= remapClassicButtons(kpadStatus[chan].classic.hold);
}
}
}
Expand All @@ -257,11 +256,9 @@ DECL_FUNCTION(int32_t, ACPGetLaunchMetaXml, ACPMetaXml *metaXml)
//check autolaunch
if (DRC_USE && gAutolaunchDRCSupported != DISPLAY_OPTION_CHOOSE) {
setDisplay(gAutolaunchDRCSupported);

return result;
} else if (!DRC_USE && gAutolaunchNoDRCSupport != DISPLAY_OPTION_CHOOSE) {
setDisplay(gAutolaunchNoDRCSupport);

return result;
}
} else {
Expand Down Expand Up @@ -382,18 +379,17 @@ DECL_FUNCTION(int32_t, ACPGetLaunchMetaXml, ACPMetaXml *metaXml)

buttonsHeld = 0;

VPADRead(VPAD_CHAN_0, &vpadStatus, 1, &vpadError);
if (vpadError == VPAD_READ_SUCCESS) {
if (VPADRead(VPAD_CHAN_0, &vpadStatus, 1, &vpadError) > 0 && vpadError == VPAD_READ_SUCCESS) {
buttonsHeld = vpadStatus.hold;
}

for (int32_t i = 0; i < 4; i++) {
if (KPADReadEx((KPADChan) i, &kpadStatus[i], 1, &kpadError[i]) > 0) {
if (kpadError[i] == KPAD_ERROR_OK && kpadStatus[i].extensionType != 0xFF) {
if (kpadStatus[i].extensionType == WPAD_EXT_CORE || kpadStatus[i].extensionType == WPAD_EXT_NUNCHUK) {
buttonsHeld |= remapWiiMoteButtons(kpadStatus[i].hold);
for (int32_t chan = 0; chan < 4; chan++) {
if (KPADReadEx((KPADChan) chan, &kpadStatus[chan], 1, &kpadError[chan]) > 0) {
if (kpadError[chan] == KPAD_ERROR_OK && kpadStatus[chan].extensionType != 0xFF) {
if (kpadStatus[chan].extensionType == WPAD_EXT_CORE || kpadStatus[chan].extensionType == WPAD_EXT_NUNCHUK) {
buttonsHeld |= remapWiiMoteButtons(kpadStatus[chan].hold);
} else {
buttonsHeld |= remapClassicButtons(kpadStatus[i].classic.hold);
buttonsHeld |= remapClassicButtons(kpadStatus[chan].classic.hold);
}
}
}
Expand Down

0 comments on commit b376ca6

Please sign in to comment.