fixed Crosshair Swivel conflicting when using Mixed Input

Addresses the issue with Crosshair Swivel conflciting with each other when using both Mouse and Camera at the same time.
This commit is contained in:
AL2009man committed 2025-12-04 14:55:31 -05:00
1 parent 4bcfeddca7
commit 2d0375da2e
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);