summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGarrett Cox <garrettjcox@gmail.com>2024-05-21 23:00:22 -0500
committerGarrett Cox <garrettjcox@gmail.com>2024-05-22 09:05:05 -0500
commita8ffb5bcb6605eb86f6d023bb8ea80f6f614d407 (patch)
tree9d0f0bf7065af4e7440e2e0abfc4ced412d1c860
parent0ce2df93e3f766e76e719219fdb4dac82f8ed8fa (diff)
Add gi invert pattern (#441)
-rw-r--r--mm/2s2h/Enhancements/Camera/DebugCam.cpp4
-rw-r--r--mm/2s2h/Enhancements/Camera/FreeLook.cpp4
-rw-r--r--mm/2s2h/Enhancements/GameInteractor/GameInteractor.cpp37
-rw-r--r--mm/2s2h/Enhancements/GameInteractor/GameInteractor.h7
4 files changed, 48 insertions, 4 deletions
diff --git a/mm/2s2h/Enhancements/Camera/DebugCam.cpp b/mm/2s2h/Enhancements/Camera/DebugCam.cpp
index 12c8105db..c38d535cd 100644
--- a/mm/2s2h/Enhancements/Camera/DebugCam.cpp
+++ b/mm/2s2h/Enhancements/Camera/DebugCam.cpp
@@ -151,8 +151,8 @@ void Camera_DebugCam(Camera* camera) {
f32 yawDiff = -sCamPlayState->state.input[controllerPort].cur.right_stick_x * 10.0f * (CVarGetFloat("gEnhancements.Camera.RightStick.CameraSensitivity.X", 1.0f));
f32 pitchDiff = sCamPlayState->state.input[controllerPort].cur.right_stick_y * 10.0f * (CVarGetFloat("gEnhancements.Camera.RightStick.CameraSensitivity.Y", 1.0f));
- yawDiff *= (CVarGetInteger("gEnhancements.Camera.RightStick.InvertXAxis", 0) ? -1 : 1);
- pitchDiff *= (CVarGetInteger("gEnhancements.Camera.RightStick.InvertYAxis", 1) ? 1 : -1);
+ yawDiff *= GameInteractor_InvertControl(GI_INVERT_CAMERA_RIGHT_STICK_X);
+ pitchDiff *= -GameInteractor_InvertControl(GI_INVERT_CAMERA_RIGHT_STICK_Y);
// Setup new camera angle based on the calculations from right stick inputs
if (CVarGetInteger("gEnhancements.Camera.DebugCam.6DOF", 0)) {
diff --git a/mm/2s2h/Enhancements/Camera/FreeLook.cpp b/mm/2s2h/Enhancements/Camera/FreeLook.cpp
index d37585015..5d9a76219 100644
--- a/mm/2s2h/Enhancements/Camera/FreeLook.cpp
+++ b/mm/2s2h/Enhancements/Camera/FreeLook.cpp
@@ -93,8 +93,8 @@ bool Camera_FreeLook(Camera* camera) {
f32 yawDiff = -sCamPlayState->state.input[0].cur.right_stick_x * 10.0f * (CVarGetFloat("gEnhancements.Camera.RightStick.CameraSensitivity.X", 1.0f));
f32 pitchDiff = sCamPlayState->state.input[0].cur.right_stick_y * 10.0f * (CVarGetFloat("gEnhancements.Camera.RightStick.CameraSensitivity.Y", 1.0f));
- yaw += yawDiff * (CVarGetInteger("gEnhancements.Camera.RightStick.InvertXAxis", 0) ? -1 : 1);
- pitch += pitchDiff * (CVarGetInteger("gEnhancements.Camera.RightStick.InvertYAxis", 1) ? 1 : -1);
+ yaw += yawDiff * GameInteractor_InvertControl(GI_INVERT_CAMERA_RIGHT_STICK_X);
+ pitch += pitchDiff * -GameInteractor_InvertControl(GI_INVERT_CAMERA_RIGHT_STICK_Y);
s16 maxPitch = DEG_TO_BINANG(CVarGetFloat("gEnhancements.Camera.FreeLook.MaxPitch", 72.0f));
s16 minPitch = DEG_TO_BINANG(CVarGetFloat("gEnhancements.Camera.FreeLook.MinPitch", -49.0f));
diff --git a/mm/2s2h/Enhancements/GameInteractor/GameInteractor.cpp b/mm/2s2h/Enhancements/GameInteractor/GameInteractor.cpp
index 7a4fde563..a597ed474 100644
--- a/mm/2s2h/Enhancements/GameInteractor/GameInteractor.cpp
+++ b/mm/2s2h/Enhancements/GameInteractor/GameInteractor.cpp
@@ -173,3 +173,40 @@ bool GameInteractor_Should(GIVanillaBehavior flag, bool result, void* opt) {
GameInteractor::Instance->ExecuteHooksForFilter<GameInteractor::ShouldVanillaBehavior>(flag, &result, opt);
return result;
}
+
+// Returns 1 or -1 based on a number of factors like CVars or other game states.
+int GameInteractor_InvertControl(GIInvertType type) {
+ int result = 1;
+
+ switch (type) {
+ case GI_INVERT_CAMERA_RIGHT_STICK_X:
+ if (CVarGetInteger("gEnhancements.Camera.RightStick.InvertXAxis", 0)) {
+ result *= -1;
+ }
+ break;
+ case GI_INVERT_CAMERA_RIGHT_STICK_Y:
+ if (CVarGetInteger("gEnhancements.Camera.RightStick.InvertYAxis", 1)) {
+ result *= -1;
+ }
+ break;
+ }
+
+ /*
+ // Invert all X axis inputs if the Mirrored World mode is enabled
+ if (CVarGetInteger("gModes.MirroredWorld.State", 0)) {
+ switch (type) {
+ case GI_INVERT_CAMERA_RIGHT_STICK_X:
+ result *= -1;
+ break;
+ }
+ }
+ */
+
+ /*
+ if (CrowdControl::State::InvertedInputs) {
+ result *= -1;
+ }
+ */
+
+ return result;
+}
diff --git a/mm/2s2h/Enhancements/GameInteractor/GameInteractor.h b/mm/2s2h/Enhancements/GameInteractor/GameInteractor.h
index 867febe2d..af649297e 100644
--- a/mm/2s2h/Enhancements/GameInteractor/GameInteractor.h
+++ b/mm/2s2h/Enhancements/GameInteractor/GameInteractor.h
@@ -50,6 +50,11 @@ typedef enum {
GI_VB_TATL_INTERUPT_MSG6
} GIVanillaBehavior;
+typedef enum {
+ GI_INVERT_CAMERA_RIGHT_STICK_X,
+ GI_INVERT_CAMERA_RIGHT_STICK_Y,
+} GIInvertType;
+
#ifdef __cplusplus
#include <vector>
@@ -297,6 +302,8 @@ bool GameInteractor_Should(GIVanillaBehavior flag, bool result, void* optionalAr
#define REGISTER_VB_SHOULD(flag, body) \
GameInteractor::Instance->RegisterGameHookForID<GameInteractor::ShouldVanillaBehavior>(flag, [](GIVanillaBehavior _, bool* should, void* opt) body)
+int GameInteractor_InvertControl(GIInvertType type);
+
#ifdef __cplusplus
}
#endif