Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
3b929f1
initial attempt at decoupling mouse crosshair aim
AL2009man May 29, 2025
f1e7989
Decoupled Mouse Crosshair Speed entirely
AL2009man May 29, 2025
3193976
removed mouse sens cap code leftover
AL2009man May 29, 2025
9dbdbec
cleaned up Mouse Crosshair code
AL2009man May 29, 2025
e27c703
changed default Mouse Crosshair Speed to 3.50, changed scaling method
AL2009man May 29, 2025
94a9173
Merge branch 'port' into MouseCrosshairFix
AL2009man May 29, 2025
1757044
Introduced unified Camera Sensitivity Scale, changed overall Crosshai…
AL2009man May 29, 2025
6a0c3f9
slightly revised notes on scaling factor
AL2009man May 29, 2025
976bccb
Reverting Unified camera scaling for now
AL2009man May 29, 2025
99097a4
restored leftover from older fix
AL2009man May 29, 2025
682490e
fix regression on MouseSpeedX/Y slider
AL2009man May 30, 2025
f73b06e
Merge branch 'fgsfdsfgs:port' into MouseCrosshairFix
AL2009man Jun 1, 2025
397ddf5
Merge branch 'fgsfdsfgs:port' into MouseCrosshairFix
AL2009man Jun 11, 2025
99d0034
whitespace fix yet again
AL2009man Jun 11, 2025
8c4e77b
fixed `inputMouseGetAbsScaledDelta` regression during the git push/sc…
AL2009man Jun 11, 2025
b63d3d5
replaced old mouse aim code with the new system
AL2009man Jun 15, 2025
d879fa9
Crosshair Sensitivity is no longer tied to framerate
AL2009man Jun 25, 2025
553119a
completely nuke "extcfg struct" on old variable
AL2009man Jul 13, 2025
645f312
fixed Mouse Crosshair Sens forcing to 0 if Mouse Speed is set to 0
AL2009man Jul 13, 2025
c7dfb9d
change Y and X to match original repository format
AL2009man Jul 22, 2025
e83781c
Centralized Crosshair logic
AL2009man Jul 24, 2025
5334ebf
reverted framerate-tied centralized
AL2009man Jul 24, 2025
707f245
Restored movedata.freelook joystick code
AL2009man Aug 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions port/include/input.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,19 @@ void inputMouseGetRawDelta(s32 *dx, s32 *dy);
// returns 0, 0 when the mouse is not locked into the window
void inputMouseGetScaledDelta(f32 *dx, f32 *dy);

// returns changes in mouse position since last frame, scaled by sensitivity and crosshair size
void inputMouseGetScaledDeltaCrosshair(f32* dx, f32* dy);

// returns changes in mouse position since last frame, scaled by absolute sensitivity
// returns 0, 0 when the mouse is not locked into the window
void inputMouseGetAbsScaledDelta(f32 *dx, f32 *dy);

void inputMouseGetSpeed(f32 *x, f32 *y);
void inputMouseSetSpeed(f32 x, f32 y);

void inputMouseGetAimSpeed(f32* x, f32* y);
void inputMouseSetAimSpeed(f32 x, f32 y);

s32 inputMouseIsEnabled(void);
void inputMouseEnable(s32 enabled);

Expand Down
24 changes: 24 additions & 0 deletions port/src/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "utils.h"
#include "system.h"
#include "fs.h"
#include "data.h"

#if !SDL_VERSION_ATLEAST(2, 0, 14)
// this was added in 2.0.14
Expand Down Expand Up @@ -1273,6 +1274,29 @@ void inputMouseSetSpeed(f32 x, f32 y)
mouseSensY = y;
}

void inputMouseGetScaledDeltaCrosshair(f32* dx, f32* dy)
{
f32 mdx = 0.f, mdy = 0.f;
if (mouseLocked) {
mdx = mouseDX * (0.022f / 20.0f) * g_PlayerExtCfg[0].mouseaimsensx;
mdy = mouseDY * (0.022f / 20.0f) * g_PlayerExtCfg[0].mouseaimsensy;
}
if (dx) *dx = mdx;
if (dy) *dy = mdy;
}

void inputMouseGetAimSpeed(f32* x, f32* y)
{
if (x) *x = g_PlayerExtCfg[0].mouseaimsensx;
if (y) *y = g_PlayerExtCfg[0].mouseaimsensy;
}

void inputMouseSetAimSpeed(f32 x, f32 y)
{
g_PlayerExtCfg[0].mouseaimsensx = x;
g_PlayerExtCfg[0].mouseaimsensy = y;
}

s32 inputMouseIsEnabled(void)
{
return mouseEnabled;
Expand Down
4 changes: 2 additions & 2 deletions port/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ PD_CONSTRUCTOR static void gameConfigInit(void)
configRegisterFloat(strFmt("Game.Player%d.FovY", i), &g_PlayerExtCfg[j].fovy, 5.f, 175.f);
configRegisterInt(strFmt("Game.Player%d.FovAffectsZoom", i), &g_PlayerExtCfg[j].fovzoom, 0, 1);
configRegisterInt(strFmt("Game.Player%d.MouseAimMode", i), &g_PlayerExtCfg[j].mouseaimmode, 0, 1);
configRegisterFloat(strFmt("Game.Player%d.MouseAimSpeedX", i), &g_PlayerExtCfg[j].mouseaimspeedx, 0.f, 10.f);
configRegisterFloat(strFmt("Game.Player%d.MouseAimSpeedY", i), &g_PlayerExtCfg[j].mouseaimspeedy, 0.f, 10.f);
configRegisterFloat(strFmt("Game.Player%d.MouseAimSensX", i), &g_PlayerExtCfg[j].mouseaimsensx, 0.f, 10.f);
configRegisterFloat(strFmt("Game.Player%d.MouseAimSensY", i), &g_PlayerExtCfg[j].mouseaimsensy, 0.f, 10.f);
configRegisterFloat(strFmt("Game.Player%d.RadialMenuSpeed", i), &g_PlayerExtCfg[j].radialmenuspeed, 0.f, 10.f);
configRegisterFloat(strFmt("Game.Player%d.CrosshairSway", i), &g_PlayerExtCfg[j].crosshairsway, 0.f, 10.f);
configRegisterInt(strFmt("Game.Player%d.CrouchMode", i), &g_PlayerExtCfg[j].crouchmode, 0, CROUCHMODE_TOGGLE_ANALOG);
Expand Down
26 changes: 16 additions & 10 deletions port/src/optionsmenu.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,45 +213,51 @@ static MenuItemHandlerResult menuhandlerMouseSpeedY(s32 operation, struct menuit

static MenuItemHandlerResult menuhandlerMouseAimSpeedX(s32 operation, struct menuitem *item, union handlerdata *data)
{
f32 x, y;
switch (operation) {
case MENUOP_GETSLIDER:
if (g_PlayerExtCfg[g_ExtMenuPlayer].mouseaimspeedx < 0.f) {
inputMouseGetAimSpeed(&x, &y);
if (x < 0.f) {
data->slider.value = 0;
} else if (g_PlayerExtCfg[g_ExtMenuPlayer].mouseaimspeedx > 10.f) {
} else if (x > 10.f) {
data->slider.value = 1000;
} else {
data->slider.value = g_PlayerExtCfg[g_ExtMenuPlayer].mouseaimspeedx * 100.f + 0.5f;
data->slider.value = x * 100.f + 0.5f;
}
break;
case MENUOP_SET:
g_PlayerExtCfg[g_ExtMenuPlayer].mouseaimspeedx = (f32)data->slider.value / 100.f;
inputMouseGetAimSpeed(&x, &y);
inputMouseSetAimSpeed((f32)data->slider.value / 100.f, y);
break;
case MENUOP_GETSLIDERLABEL:
sprintf(data->slider.label, "%.2f", (f32)data->slider.value / 100.f);
break;
}

return 0;
}

static MenuItemHandlerResult menuhandlerMouseAimSpeedY(s32 operation, struct menuitem *item, union handlerdata *data)
{
f32 x, y;
switch (operation) {
case MENUOP_GETSLIDER:
if (g_PlayerExtCfg[g_ExtMenuPlayer].mouseaimspeedy < 0.f) {
inputMouseGetAimSpeed(&x, &y);
if (y < 0.f) {
data->slider.value = 0;
} else if (g_PlayerExtCfg[g_ExtMenuPlayer].mouseaimspeedy > 10.f) {
} else if (y > 10.f) {
data->slider.value = 1000;
} else {
data->slider.value = g_PlayerExtCfg[g_ExtMenuPlayer].mouseaimspeedy * 100.f + 0.5f;
data->slider.value = y * 100.f + 0.5f;
}
break;
case MENUOP_SET:
g_PlayerExtCfg[g_ExtMenuPlayer].mouseaimspeedy = (f32)data->slider.value / 100.f;
inputMouseGetAimSpeed(&x, &y);
inputMouseSetAimSpeed(x, (f32)data->slider.value / 100.f);
break;
case MENUOP_GETSLIDERLABEL:
sprintf(data->slider.label, "%.2f", (f32)data->slider.value / 100.f);
break;
}

return 0;
}

Expand Down
41 changes: 26 additions & 15 deletions src/game/bondmove.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,24 @@ void bmoveUpdateSpeedThetaControl(f32 value)
}
}

/**
* Apply crosshair movement with scaling and clamping
*/
static void bmoveApplyCrosshairMovement(f32 aimspeedx, f32 aimspeedy, f32 dx, f32 dy)
{
const f32 xcoeff = 320.f / 1080.f;
const f32 ycoeff = 240.f / 1080.f;
const f32 xscale = (aimspeedx * xcoeff) / g_Vars.currentplayer->aspect;
const f32 yscale = aimspeedy * ycoeff;
f32 x = g_Vars.currentplayer->swivelpos[0] + (dx * xscale);
f32 y = g_Vars.currentplayer->swivelpos[1] + (dy * yscale);
x = (x < -1.f) ? -1.f : ((x > 1.f) ? 1.f : x);
y = (y < -1.f) ? -1.f : ((y > 1.f) ? 1.f : y);
g_Vars.currentplayer->swivelpos[0] = x;
g_Vars.currentplayer->swivelpos[1] = y;
bgunSwivelWithDamp(x, y, 0.01f);
}

/**
* Calculate the lookahead angle.
*
Expand Down Expand Up @@ -2204,21 +2222,14 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i
// when holding aim and moving stick
bgunSetAimType(0);
#ifndef PLATFORM_N64
if (allowmcross) {
// joystick is inactive, move crosshair using the mouse
const f32 xcoeff = 320.f / 1080.f;
const f32 ycoeff = 240.f / 1080.f;
const f32 xscale = (PLAYER_EXTCFG().mouseaimspeedx * xcoeff) / g_Vars.currentplayer->aspect;
const f32 yscale = PLAYER_EXTCFG().mouseaimspeedy * ycoeff;
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);
y = (y < -1.f) ? -1.f : ((y > 1.f) ? 1.f : y);
g_Vars.currentplayer->swivelpos[0] = x;
g_Vars.currentplayer->swivelpos[1] = y;
bgunSwivelWithDamp(x, y, 0.01f);
return;
}
if (allowmcross) {
// joystick is inactive, move crosshair using the mouse
f32 dx, dy;
inputMouseGetScaledDeltaCrosshair(&dx, &dy);
const f32 norm = g_Vars.lvupdate60freal;
bmoveApplyCrosshairMovement(PLAYER_EXTCFG().mouseaimsensx, PLAYER_EXTCFG().mouseaimsensy, dx, dy);
return;
}
#endif
bgunSwivelWithoutDamp((movedata.c1stickxraw * 0.65f) / 80.0f, (movedata.c1stickyraw * 0.65f) / 80.0f);
}
Expand Down
4 changes: 2 additions & 2 deletions src/game/mplayer/mplayer.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ struct mpweapon g_MpWeapons[NUM_MPWEAPONS] = {
.fovzoommult = 1.f, \
.fovzoom = true, \
.mouseaimmode = MOUSEAIM_CLASSIC, \
.mouseaimspeedx = 0.7f, \
.mouseaimspeedy = 0.7f, \
.mouseaimsensx = 2.5f, \
.mouseaimsensy = 2.5f, \
.radialmenuspeed = 4.f, \
.crosshairsway = 1.f, \
.crouchmode = CROUCHMODE_TOGGLE_ANALOG, \
Expand Down
4 changes: 2 additions & 2 deletions src/include/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -6150,8 +6150,8 @@ struct extplayerconfig {
f32 fovzoommult;
s32 fovzoom;
s32 mouseaimmode;
f32 mouseaimspeedx;
f32 mouseaimspeedy;
f32 mouseaimsensx;
f32 mouseaimsensy;
s32 crouchmode;
f32 radialmenuspeed;
f32 crosshairsway;
Expand Down
Loading