From 24ced381de0e146177014539d627b5cda19f31e8 Mon Sep 17 00:00:00 2001 From: fgsfds Date: Thu, 31 Aug 2023 01:21:33 +0200 Subject: [PATCH] port: add separate mouse aim sensitivity Game.MouseAimSpeedX and Game.MouseAimSpeedY --- port/src/main.c | 2 ++ src/game/bondmove.c | 16 +++++++--------- src/game/player.c | 2 ++ src/include/data.h | 2 ++ 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/port/src/main.c b/port/src/main.c index 4707998ee..777e0e70e 100644 --- a/port/src/main.c +++ b/port/src/main.c @@ -66,6 +66,8 @@ static void gameLoadConfig(void) g_PlayerCrosshairSway = configGetFloatClamped("Game.CrosshairSway", g_PlayerCrosshairSway, 0.f, 10.f); g_PlayerDefaultFovY = configGetFloatClamped("Game.FovY", g_PlayerDefaultFovY, 5.f, 175.f); g_PlayerMouseAimMode = configGetIntClamped("Game.MouseAimMode", g_PlayerMouseAimMode, 0, 1); + g_PlayerMouseAimSpeedX = configGetFloatClamped("Game.MouseAimSpeedX", g_PlayerMouseAimSpeedX, 0.f, 10.f); + g_PlayerMouseAimSpeedY = configGetFloatClamped("Game.MouseAimSpeedY", g_PlayerMouseAimSpeedY, 0.f, 10.f); } int main(int argc, const char **argv) diff --git a/src/game/bondmove.c b/src/game/bondmove.c index 541c680e0..62d42ee54 100644 --- a/src/game/bondmove.c +++ b/src/game/bondmove.c @@ -2019,16 +2019,14 @@ 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; + f32 scale; if (movedata.freelookdx || movedata.freelookdy) { - xscale = 320.f / (f32)videoGetWidth(); - yscale = 240.f / (f32)videoGetHeight(); + scale = g_PlayerCrosshairSway * 240.f / (f32)videoGetHeight(); } else { - xscale = 1.f; - yscale = 1.f; + scale = g_PlayerCrosshairSway; } - x = g_Vars.currentplayer->speedtheta * 0.3f * g_PlayerCrosshairSway * xscale + g_Vars.currentplayer->gunextraaimx; - y = -g_Vars.currentplayer->speedverta * 0.1f * g_PlayerCrosshairSway * yscale + g_Vars.currentplayer->gunextraaimy; + x = g_Vars.currentplayer->speedtheta * 0.3f * scale + g_Vars.currentplayer->gunextraaimx; + y = -g_Vars.currentplayer->speedverta * 0.1f * scale + g_Vars.currentplayer->gunextraaimy; #endif bgunSwivelWithDamp(x, y, PAL ? 0.955f : 0.963f); @@ -2040,8 +2038,8 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i #ifndef PLATFORM_N64 if (allowmcross) { // joystick is inactive, move crosshair using the mouse - const f32 xscale = 320.f / (f32)videoGetWidth(); - const f32 yscale = 240.f / (f32)videoGetHeight(); + const f32 xscale = g_PlayerMouseAimSpeedX * 320.f / (f32)videoGetWidth(); + const f32 yscale = g_PlayerMouseAimSpeedY * 240.f / (f32)videoGetHeight(); f32 x = g_Vars.currentplayer->swivelpos[0] + movedata.freelookdx * xscale; f32 y = g_Vars.currentplayer->swivelpos[1] + movedata.freelookdy * yscale; x = (x < -1.f) ? -1.f : ((x > 1.f) ? 1.f : x); diff --git a/src/game/player.c b/src/game/player.c index 5d08b8abc..e68aede10 100644 --- a/src/game/player.c +++ b/src/game/player.c @@ -206,6 +206,8 @@ s32 g_NumDeathAnimations = 0; f32 g_PlayerDefaultFovY = 60.f; f32 g_PlayerCrosshairSway = 1.f; s32 g_PlayerMouseAimMode = MOUSEAIM_CLASSIC; +f32 g_PlayerMouseAimSpeedX = 0.75f; +f32 g_PlayerMouseAimSpeedY = 0.75f; #endif /** diff --git a/src/include/data.h b/src/include/data.h index 38779304a..c70056c8c 100644 --- a/src/include/data.h +++ b/src/include/data.h @@ -532,6 +532,8 @@ extern struct menudialogdef g_HangarListMenuDialog; extern f32 g_PlayerCrosshairSway; extern f32 g_PlayerDefaultFovY; extern s32 g_PlayerMouseAimMode; +extern f32 g_PlayerMouseAimSpeedX; +extern f32 g_PlayerMouseAimSpeedY; #endif #endif