From 6e38084cf97cc850f455b416add4279d47632f9a Mon Sep 17 00:00:00 2001 From: Agent X <44549182+AgentXLP@users.noreply.github.com> Date: Sat, 31 Aug 2024 22:27:06 -0400 Subject: [PATCH] Make C buttons work for moving the first person player camera --- src/game/first_person_cam.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/game/first_person_cam.c b/src/game/first_person_cam.c index 8f59744c..b6215ce9 100644 --- a/src/game/first_person_cam.c +++ b/src/game/first_person_cam.c @@ -69,18 +69,28 @@ static void first_person_camera_update(void) { s16 invY = camera_config_is_y_inverted() ? 1 : -1; if (mouse_relative_enabled) { + // hack: make c buttons work for moving the camera + s16 extStickX = m->controller->extStickX; + s16 extStickY = m->controller->extStickY; + if (extStickX == 0) { + extStickX = (CLAMP(m->controller->buttonDown & R_CBUTTONS, 0, 1) - CLAMP(m->controller->buttonDown & L_CBUTTONS, 0, 1)) * 32; + } + if (extStickY == 0) { + extStickY = (CLAMP(m->controller->buttonDown & U_CBUTTONS, 0, 1) - CLAMP(m->controller->buttonDown & D_CBUTTONS, 0, 1)) * 24; + } + // update pitch if (!gFirstPersonCamera.forcePitch) { - gFirstPersonCamera.pitch -= sensY * (invY * m->controller->extStickY - 1.5f * mouse_y); + gFirstPersonCamera.pitch -= sensY * (invY * extStickY - 1.5f * mouse_y); gFirstPersonCamera.pitch = CLAMP(gFirstPersonCamera.pitch, -0x3F00, 0x3F00); } // update yaw if (!gFirstPersonCamera.forceYaw) { - if (m->controller->buttonPressed & L_TRIG && gFirstPersonCamera.centerL) { + if (m->controller->buttonDown & L_TRIG && gFirstPersonCamera.centerL) { gFirstPersonCamera.yaw = m->faceAngle[1] + 0x8000; } else { - gFirstPersonCamera.yaw += sensX * (invX * m->controller->extStickX - 1.5f * mouse_x); + gFirstPersonCamera.yaw += sensX * (invX * extStickX - 1.5f * mouse_x); } } }