diff --git a/src/game/bondmove.c b/src/game/bondmove.c index 2c07016686..548ade1b17 100644 --- a/src/game/bondmove.c +++ b/src/game/bondmove.c @@ -436,6 +436,38 @@ void bmoveUpdateSpeedThetaControl(f32 value) } } +/** + * Apply crosshair swivel based on camera movement with input detection + */ +static void bmoveApplyCrosshairSwivel(struct movedata *movedata, f32 mlookscale, f32 *x, f32 *y) +{ +#ifdef PLATFORM_N64 + *x = g_Vars.currentplayer->speedtheta * 0.3f + g_Vars.currentplayer->gunextraaimx; + *y = -g_Vars.currentplayer->speedverta * 0.1f + g_Vars.currentplayer->gunextraaimy; +#else + f32 xscale, yscale; + bool mouse_active = (movedata->freelookdx || movedata->freelookdy); + bool joystick_active = (movedata->c1stickxraw != 0 || movedata->c1stickyraw != 0); + + if ((mouse_active) && joystick_active) { + // Mouse + joystick sway + xscale = PLAYER_EXTCFG().crosshairsway * 0.80f; // 80% for precision+joystick sway + yscale = PLAYER_EXTCFG().crosshairsway * 0.80f; // 80% for precision+joystick sway + } else if (mouse_active) { + // Mouse sway + xscale = PLAYER_EXTCFG().crosshairsway * 0.20f; // 20% for mouse sway + yscale = PLAYER_EXTCFG().crosshairsway * 0.30f; // 30% for mouse sway + } else { + // Joystick only or no input - full sway + xscale = yscale = PLAYER_EXTCFG().crosshairsway; + } + // Joystick x/y scaling + // 0.3f for x, 0.1f for y + *x = g_Vars.currentplayer->speedtheta * 0.3f * xscale + g_Vars.currentplayer->gunextraaimx; + *y = -g_Vars.currentplayer->speedverta * 0.1f * yscale + g_Vars.currentplayer->gunextraaimy; +#endif +} + /** * Calculate the lookahead angle. * @@ -2186,15 +2218,8 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i x = g_Vars.currentplayer->speedtheta * 0.3f + g_Vars.currentplayer->gunextraaimx; y = -g_Vars.currentplayer->speedverta * 0.1f + g_Vars.currentplayer->gunextraaimy; #else - f32 xscale, yscale; - if (movedata.freelookdx || movedata.freelookdy) { - xscale = PLAYER_EXTCFG().crosshairsway * 0.20f; - yscale = PLAYER_EXTCFG().crosshairsway * 0.30f; - } else { - xscale = yscale = PLAYER_EXTCFG().crosshairsway; - } - x = g_Vars.currentplayer->speedtheta * 0.3f * xscale + g_Vars.currentplayer->gunextraaimx; - y = -g_Vars.currentplayer->speedverta * 0.1f * yscale + g_Vars.currentplayer->gunextraaimy; + // Crosshair swivel movement system + bmoveApplyCrosshairSwivel(&movedata, mlookscale, &x, &y); #endif bgunSwivelWithDamp(x, y, PAL ? 0.955f : 0.963f);