summaryrefslogtreecommitdiff
path: root/soh/src/code
diff options
context:
space:
mode:
authorEric Hoey <121978037+A-Green-Spoon@users.noreply.github.com>2024-01-08 13:21:18 -0500
committerGitHub <noreply@github.com>2024-01-08 12:21:18 -0600
commita0258f0fca8def02c3ea3e723d359b139525c146 (patch)
treee079f30612f0320747e13606c99c3a9fbc85b967 /soh/src/code
parent90648977361bd7997f6cd5856db41532fb0fed9b (diff)
Add Invert Y-Axis and Apply Right-Stick Aiming to Z-Weapon Aiming (#3304)
* Add right-stick aiming to third-person aim * Add Z-aiming CVar and inversion to Z-aiming * Create calculation for rel.right_stick and apply it in Z-aiming * Move option to First-Person section to match shield * Fix max/min aiming heights * Expand min/max + comment * block out vanilla + comments * block vanilla code better * Remove extra space * new documentation formatting * rewrite ==0 and !=0
Diffstat (limited to 'soh/src/code')
-rw-r--r--soh/src/code/padmgr.c10
-rw-r--r--soh/src/code/padutils.c57
2 files changed, 67 insertions, 0 deletions
diff --git a/soh/src/code/padmgr.c b/soh/src/code/padmgr.c
index 4735a259c..3315a9fe8 100644
--- a/soh/src/code/padmgr.c
+++ b/soh/src/code/padmgr.c
@@ -297,6 +297,11 @@ void PadMgr_ProcessInputs(PadMgr* padMgr) {
PadUtils_UpdateRelXY(input);
input->press.stick_x += (s8)(input->cur.stick_x - input->prev.stick_x);
input->press.stick_y += (s8)(input->cur.stick_y - input->prev.stick_y);
+ // #region SOH [Enhancement]
+ PadUtils_UpdateRelRXY(input);
+ input->press.right_stick_x += (s8)(input->cur.right_stick_x - input->prev.right_stick_x);
+ input->press.right_stick_y += (s8)(input->cur.right_stick_y - input->prev.right_stick_y);
+ // #endregion
}
uint8_t rumble = (padMgr->rumbleEnable[0] > 0);
@@ -389,6 +394,11 @@ void PadMgr_RequestPadData(PadMgr* padMgr, Input* inputs, s32 mode) {
PadUtils_UpdateRelXY(newInput);
newInput->press.stick_x += (s8)(newInput->cur.stick_x - newInput->prev.stick_x);
newInput->press.stick_y += (s8)(newInput->cur.stick_y - newInput->prev.stick_y);
+ // #region SOH [Enhancement]
+ PadUtils_UpdateRelRXY(newInput);
+ newInput->press.right_stick_x += (s8)(newInput->cur.right_stick_x - newInput->prev.right_stick_x);
+ newInput->press.right_stick_y += (s8)(newInput->cur.right_stick_y - newInput->prev.right_stick_y);
+ // #endregion
}
ogInput++;
newInput++;
diff --git a/soh/src/code/padutils.c b/soh/src/code/padutils.c
index 6a58b14f6..c4548ae32 100644
--- a/soh/src/code/padutils.c
+++ b/soh/src/code/padutils.c
@@ -92,3 +92,60 @@ void PadUtils_UpdateRelXY(Input* input) {
PadUtils_SetRelXY(input, relX, relY);
}
+
+// #region SOH [Enhancement]
+s8 PadUtils_GetCurRX(Input* input) {
+ return input->cur.right_stick_x;
+}
+
+s8 PadUtils_GetCurRY(Input* input) {
+ return input->cur.right_stick_y;
+}
+
+void PadUtils_SetRelRXY(Input* input, s32 x, s32 y) {
+ input->rel.right_stick_x = x;
+ input->rel.right_stick_y = y;
+}
+
+s8 PadUtils_GetRelRXImpl(Input* input) {
+ return input->rel.right_stick_x;
+}
+
+s8 PadUtils_GetRelRYImpl(Input* input) {
+ return input->rel.right_stick_y;
+}
+
+s8 PadUtils_GetRelRX(Input* input) {
+ return PadUtils_GetRelRXImpl(input);
+}
+
+s8 PadUtils_GetRelRY(Input* input) {
+ return PadUtils_GetRelRYImpl(input);
+}
+
+void PadUtils_UpdateRelRXY(Input* input) {
+ s32 curX = PadUtils_GetCurRX(input);
+ s32 curY = PadUtils_GetCurRY(input);
+ s32 relX;
+ s32 relY;
+
+ if (curX > 7) {
+ relX = (curX < 0x43) ? curX - 7 : 0x43 - 7;
+ } else if (curX < -7) {
+ relX = (curX > -0x43) ? curX + 7 : -0x43 + 7;
+ } else {
+ relX = 0;
+ }
+
+ if (curY > 7) {
+ relY = (curY < 0x43) ? curY - 7 : 0x43 - 7;
+
+ } else if (curY < -7) {
+ relY = (curY > -0x43) ? curY + 7 : -0x43 + 7;
+ } else {
+ relY = 0;
+ }
+
+ PadUtils_SetRelRXY(input, relX, relY);
+}
+// #endregion