From 7e523a1e350ace2394a00eedf2924b7df6b7191a Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 3 Dec 2018 06:32:26 -0500 Subject: [PATCH] Reset vertical look when toggling joyaiming --- src/g_game.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 919ec3f7..29387d23 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -960,13 +960,14 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics) INT32 tspeed, forward, side, axis, i; const INT32 speed = 1; // these ones used for multiple conditions - boolean turnleft, turnright, mouseaiming, joyaiming, analogjoystickmove, gamepadjoystickmove; + boolean turnleft, turnright, mouseaiming, analogjoystickmove, gamepadjoystickmove, thisjoyaiming; player_t *player = &players[consoleplayer]; camera_t *thiscam = &camera; static INT32 turnheld; // for accelerative turning static boolean keyboard_look; // true if lookup/down using keyboard static boolean resetdown; // don't cam reset every frame + static boolean joyaiming; // check the last frame's value if we need to reset the camera G_CopyTiccmd(cmd, I_BaseTiccmd(), 1); // empty, or external driver @@ -986,6 +987,15 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics) analogjoystickmove = cv_usejoystick.value && !Joystick.bGamepadStyle; gamepadjoystickmove = cv_usejoystick.value && Joystick.bGamepadStyle; + // todo joystick-juggling next + //thisjoyaiming = (cv_chasecam.value) ? cv_chasefreelook.value : cv_alwaysfreelook.value; + thisjoyaiming = cv_alwaysfreelook.value; + + // Reset the vertical look if we're no longer joyaiming + if (!thisjoyaiming && joyaiming) + localaiming = 0; + joyaiming = thisjoyaiming; + axis = JoyAxis(AXISTURN); if (gamepadjoystickmove && axis != 0) { @@ -1252,13 +1262,14 @@ void G_BuildTiccmd2(ticcmd_t *cmd, INT32 realtics) INT32 tspeed, forward, side, axis, i; const INT32 speed = 1; // these ones used for multiple conditions - boolean turnleft, turnright, mouseaiming, joyaiming, analogjoystickmove, gamepadjoystickmove; + boolean turnleft, turnright, mouseaiming, analogjoystickmove, gamepadjoystickmove, thisjoyaiming; player_t *player = &players[secondarydisplayplayer]; camera_t *thiscam = (player->bot == 2 ? &camera : &camera2); static INT32 turnheld; // for accelerative turning static boolean keyboard_look; // true if lookup/down using keyboard static boolean resetdown; // don't cam reset every frame + static boolean joyaiming; // check the last frame's value if we need to reset the camera G_CopyTiccmd(cmd, I_BaseTiccmd2(), 1); // empty, or external driver @@ -1278,6 +1289,15 @@ void G_BuildTiccmd2(ticcmd_t *cmd, INT32 realtics) analogjoystickmove = cv_usejoystick2.value && !Joystick2.bGamepadStyle; gamepadjoystickmove = cv_usejoystick2.value && Joystick2.bGamepadStyle; + // todo joystick-juggling next + //thisjoyaiming = (cv_chasecam.value) ? cv_chasefreelook2.value : cv_alwaysfreelook2.value; + thisjoyaiming = cv_alwaysfreelook2.value; + + // Reset the vertical look if we're no longer joyaiming + if (!thisjoyaiming && joyaiming) + localaiming2 = 0; + joyaiming = thisjoyaiming; + axis = Joy2Axis(AXISTURN); if (gamepadjoystickmove && axis != 0) {