Merge pull request #677 from AL2009man/CrosshairSwivelFix

fixed Crosshair Swivel conflicting when using Mixed Input
This commit is contained in:
fgsfds authored and GitHub committed 2025-12-05 12:55:07 +01:00
commit 8165b5005e
1 file changed
+34 -9
+34 -9
View File
@@ -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);