From d9beab0c8b96adc3646f7637cf65247eb376c8d1 Mon Sep 17 00:00:00 2001 From: squiddingme Date: Mon, 21 Aug 2023 16:27:18 +0800 Subject: [PATCH] Add config option to control crosshair/gun sway --- port/src/config.c | 1 + port/src/input.c | 4 ++++ src/game/bondmove.c | 4 ++-- src/include/game/bondmove.h | 4 ++++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/port/src/config.c b/port/src/config.c index 48009d078..0e2c73b8b 100644 --- a/port/src/config.c +++ b/port/src/config.c @@ -55,6 +55,7 @@ struct configentry { { "Input.RumbleScale", CONFIG_F32, { .f32val = 0.333f } }, { "Input.FirstGamepadNum", CONFIG_S32, { .s32val = 0 } }, { "Input.FakeGamepads", CONFIG_S32, { .s32val = 0 } }, + { "Input.CrosshairSway", CONFIG_F32, { .f32val = 1.f } }, /* Game */ { "Game.BaseDir", CONFIG_STR, { .strval = "./data" } }, { "Game.MemorySize", CONFIG_S32, { .s32val = 16 } }, diff --git a/port/src/input.c b/port/src/input.c index a15269e61..daf9a584d 100644 --- a/port/src/input.c +++ b/port/src/input.c @@ -53,6 +53,8 @@ static s32 deadzone[4] = { static s32 stickCButtons = 1; +f32 crosshairSway = 1.f; + void inputSetDefaultKeyBinds(void) { // TODO: make VK constants for all these @@ -243,6 +245,8 @@ s32 inputInit(void) connectedMask = overrideMask; } + crosshairSway = configGetFloat("Input.CrosshairSway", 1.f); + return connectedMask; } diff --git a/src/game/bondmove.c b/src/game/bondmove.c index 1c425466b..f9f0fd57f 100644 --- a/src/game/bondmove.c +++ b/src/game/bondmove.c @@ -1939,8 +1939,8 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i xscale = 1.f; yscale = 1.f; } - x = g_Vars.currentplayer->speedtheta * 0.3f * xscale + g_Vars.currentplayer->gunextraaimx; - y = -g_Vars.currentplayer->speedverta * 0.1f * yscale + g_Vars.currentplayer->gunextraaimy; + x = g_Vars.currentplayer->speedtheta * 0.3f * crosshairSway * xscale + g_Vars.currentplayer->gunextraaimx; + y = -g_Vars.currentplayer->speedverta * 0.1f * crosshairSway * yscale + g_Vars.currentplayer->gunextraaimy; #endif bgunSwivelWithDamp(x, y, PAL ? 0.955f : 0.963f); diff --git a/src/include/game/bondmove.h b/src/include/game/bondmove.h index 7733b613f..beb4f75c5 100644 --- a/src/include/game/bondmove.h +++ b/src/include/game/bondmove.h @@ -4,6 +4,10 @@ #include "data.h" #include "types.h" +#ifndef PLATFORM_N64 +extern f32 crosshairSway; +#endif + void bmoveSetControlDef(u32 controldef); void bmoveSetAutoMoveCentreEnabled(bool enabled); void bmoveSetAutoAimY(bool enabled);