Merge pull request #694 from Arceveti/develop/2.1.0-four-controllers-base

Fix controller type checking (GCN false positive)
This commit is contained in:
thecozies
2023-09-22 17:18:31 -05:00
committed by GitHub
2 changed files with 7 additions and 7 deletions

View File

@@ -602,7 +602,7 @@ void read_controller_inputs(s32 threadID) {
// if we're receiving inputs, update the controller struct with the new button info.
if (controller->controllerData != NULL) {
// HackerSM64: Swaps Z and L, only on console, and only when playing with a GameCube controller.
if (controller->statusData->type & CONT_CONSOLE_GCN) {
if ((controller->statusData->type & CONT_CONSOLE_MASK) == CONT_CONSOLE_GCN) {
u32 oldButton = controllerData->button;
u32 newButton = oldButton & ~(Z_TRIG | L_TRIG);
if (oldButton & Z_TRIG) {
@@ -694,8 +694,8 @@ void init_controllers(void) {
if (
(gEmulator & EMU_CONSOLE) &&
((gControllerBits & 0b11) == 0b11) && // Only swap if the first two ports both have controllers plugged in.
((gControllerStatuses[0].type & CONT_CONSOLE_MASK) == CONT_CONSOLE_N64) && // If the first port's controller is N64.
((gControllerStatuses[1].type & CONT_CONSOLE_MASK) == CONT_CONSOLE_GCN) // If the second port's controller is GCN.
((gControllerStatuses[0].type & CONT_CONSOLE_MASK) == CONT_CONSOLE_N64) && // If the 1st port's controller is N64.
((gControllerStatuses[1].type & CONT_CONSOLE_MASK) == CONT_CONSOLE_GCN) // If the 2nd port's controller is GCN.
) {
struct Controller temp = gControllers[0];
gControllers[0] = gControllers[1];

View File

@@ -217,7 +217,7 @@ void osContGetReadDataEx(OSContPadEx* data) {
int i;
for (i = 0; i < __osMaxControllers; i++, data++) {
if (gControllerStatuses[i].type & CONT_CONSOLE_GCN) {
if ((gControllerStatuses[i].type & CONT_CONSOLE_MASK) == CONT_CONSOLE_GCN) {
s32 stick_x, stick_y, c_stick_x, c_stick_y;
readformatgcn = *(__OSContGCNShortPollFormat*)ptr;
data->errno = CHNL_ERR(readformatgcn);
@@ -293,7 +293,7 @@ static void __osPackReadData(void) {
readformatgcn.stick_y = -1;
for (i = 0; i < __osMaxControllers; i++) {
if (gControllerStatuses[i].type & CONT_CONSOLE_GCN) {
if ((gControllerStatuses[i].type & CONT_CONSOLE_MASK) == CONT_CONSOLE_GCN) {
readformatgcn.rumble = __osGamecubeRumbleEnabled[i];
*(__OSContGCNShortPollFormat*)ptr = readformatgcn;
ptr += sizeof(__OSContGCNShortPollFormat);
@@ -401,7 +401,7 @@ s32 __osMotorAccessEx(OSPfs* pfs, s32 flag) {
return 5;
}
if (gControllerStatuses[pfs->channel].type & CONT_CONSOLE_GCN) {
if ((gControllerStatuses[pfs->channel].type & CONT_CONSOLE_MASK) == CONT_CONSOLE_GCN) {
__osGamecubeRumbleEnabled[pfs->channel] = flag;
__osContLastCmd = CONT_CMD_END;
} else {
@@ -472,7 +472,7 @@ s32 osMotorInitEx(OSMesgQueue *mq, OSPfs *pfs, int channel)
pfs->activebank = 0xFF;
pfs->status = 0;
if (gControllerStatuses[pfs->channel].type & CONT_CONSOLE_GCN) {
if ((gControllerStatuses[pfs->channel].type & CONT_CONSOLE_MASK) == CONT_CONSOLE_N64) {
ret = __osPfsSelectBank(pfs, 0xFE);
if (ret == PFS_ERR_NEW_PACK) {