Added buttonReleased member in the controller struct (#421)

This commit is contained in:
axollyon
2022-06-17 00:46:48 -04:00
committed by Mr-Wiseguy
parent 4a3ef802d5
commit 25b421aaae
2 changed files with 8 additions and 5 deletions

View File

@@ -40,10 +40,11 @@ struct Controller {
/*0x0C*/ f32 stickMag; // distance from center [0, 64]
/*0x10*/ u16 buttonDown;
/*0x12*/ u16 buttonPressed;
/*0x14*/ OSContStatus *statusData;
/*0x18*/ OSContPad *controllerData;
/*0x14*/ u16 buttonReleased;
/*0x18*/ OSContStatus *statusData;
/*0x1C*/ OSContPad *controllerData;
#if ENABLE_RUMBLE
/*0x1C*/ s32 port;
/*0x20*/ s32 port;
#endif
};

View File

@@ -611,8 +611,8 @@ void read_controller_inputs(s32 threadID) {
if (controller->controllerData != NULL) {
controller->rawStickX = controller->controllerData->stick_x;
controller->rawStickY = controller->controllerData->stick_y;
controller->buttonPressed = controller->controllerData->button
& (controller->controllerData->button ^ controller->buttonDown);
controller->buttonPressed = ~controller->buttonDown & controller->controllerData->button;
controller->buttonReleased = ~controller->controllerData->button & controller->buttonDown;
// 0.5x A presses are a good meme
controller->buttonDown = controller->controllerData->button;
adjust_analog_stick(controller);
@@ -620,6 +620,7 @@ void read_controller_inputs(s32 threadID) {
controller->rawStickX = 0;
controller->rawStickY = 0;
controller->buttonPressed = 0;
controller->buttonReleased = 0;
controller->buttonDown = 0;
controller->stickX = 0;
controller->stickY = 0;
@@ -636,6 +637,7 @@ void read_controller_inputs(s32 threadID) {
gPlayer3Controller->stickY = gPlayer1Controller->stickY;
gPlayer3Controller->stickMag = gPlayer1Controller->stickMag;
gPlayer3Controller->buttonPressed = gPlayer1Controller->buttonPressed;
gPlayer3Controller->buttonReleased = gPlayer1Controller->buttonReleased;
gPlayer3Controller->buttonDown = gPlayer1Controller->buttonDown;
}