Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions port/src/optionsmenu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1295,13 +1295,13 @@ static MenuItemHandlerResult menuhandlerCrosshairEdgeBoundary(s32 operation, str
{
switch (operation) {
case MENUOP_GETSLIDER:
data->slider.value = (s32)(g_PlayerExtCfg[g_ExtMenuPlayer].crosshairedgeboundary * 10.f + 0.5f);
data->slider.value = (s32)(g_PlayerExtCfg[g_ExtMenuPlayer].crosshairedgeboundary * 100.f + 0.5f);
break;
case MENUOP_SET:
g_PlayerExtCfg[g_ExtMenuPlayer].crosshairedgeboundary = (f32)data->slider.value / 10.f;
g_PlayerExtCfg[g_ExtMenuPlayer].crosshairedgeboundary = (f32)data->slider.value / 100.f;
break;
case MENUOP_GETSLIDERLABEL:
sprintf(data->slider.label, "%d", (s32)data->slider.value);
sprintf(data->slider.label, "%d%%", (s32)data->slider.value);
break;
}
return 0;
Expand Down Expand Up @@ -1533,7 +1533,7 @@ struct menuitem g_ExtendedGameMenuItems[] = {
0,
MENUITEMFLAG_LITERAL_TEXT | MENUITEMFLAG_SLIDER_WIDE,
(uintptr_t)"Crosshair Edge Deadzone",
10,
100,
menuhandlerCrosshairEdgeBoundary,
},
{
Expand Down
50 changes: 34 additions & 16 deletions src/game/bondmove.c
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,19 @@ static void bmoveApplyCrosshairSwivel(struct movedata *movedata, f32 mlookscale,
#endif
}

/**
* Calculate the joystick edge threshold for crosshair edge boundary
*/
static f32 bmoveCalculateJoyEdgeThreshold(void)
{
f32 boundary = PLAYER_EXTCFG().crosshairedgeboundary;
if (boundary <= 0.6f) {
return boundary * 100.0f; // 0-60% -> 0-60
} else {
return 60.0f + (boundary - 0.6f) * 170.0f; // 60-100% -> 60-128
}
}

/**
* Calculate the lookahead angle.
*
Expand Down Expand Up @@ -743,6 +756,7 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i
u32 stack;
f32 increment2;
f32 newverta;
f32 joy_edge_threshold;
#ifndef PLATFORM_N64
const f32 mlookscale = g_Vars.lvupdate240 ? (4.f / (f32)g_Vars.lvupdate240) : 4.f;
const bool allowmlook = (g_Vars.currentplayernum == 0) && (allowc1x || allowc1y);
Expand Down Expand Up @@ -974,8 +988,10 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i
movedata.cannaturalpitch = !g_Vars.currentplayer->insightaimmode;

// Handle turning while aiming
if (g_Vars.currentplayer->insightaimmode && movedata.c1stickyraw > 60) {
movedata.speedvertadown = (movedata.c1stickyraw - 60) / 10.0f;
f32 joy_edge_threshold = bmoveCalculateJoyEdgeThreshold();

if (g_Vars.currentplayer->insightaimmode && movedata.c1stickyraw > joy_edge_threshold) {
movedata.speedvertadown = (movedata.c1stickyraw - joy_edge_threshold) / (127.0f - joy_edge_threshold);

if (movedata.speedvertadown > 1) {
movedata.speedvertadown = 1;
Expand All @@ -984,8 +1000,8 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i
movedata.speedvertadown = 0;
}

if (g_Vars.currentplayer->insightaimmode && movedata.c1stickyraw < -60) {
movedata.speedvertaup = (-60 - movedata.c1stickyraw) / 10.0f;
if (g_Vars.currentplayer->insightaimmode && movedata.c1stickyraw < -joy_edge_threshold) {
movedata.speedvertaup = (-joy_edge_threshold - movedata.c1stickyraw) / (127.0f - joy_edge_threshold);

if (movedata.speedvertaup > 1) {
movedata.speedvertaup = 1;
Expand All @@ -994,8 +1010,8 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i
movedata.speedvertaup = 0;
}

if (g_Vars.currentplayer->insightaimmode && movedata.c1stickxraw < -60) {
movedata.aimturnleftspeed = (-60 - movedata.c1stickxraw) / 10.0f;
if (g_Vars.currentplayer->insightaimmode && movedata.c1stickxraw < -joy_edge_threshold) {
movedata.aimturnleftspeed = (-joy_edge_threshold - movedata.c1stickxraw) / (127.0f - joy_edge_threshold);

if (movedata.aimturnleftspeed > 1) {
movedata.aimturnleftspeed = 1;
Expand All @@ -1004,8 +1020,8 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i
movedata.aimturnleftspeed = 0;
}

if (g_Vars.currentplayer->insightaimmode && movedata.c1stickxraw > 60) {
movedata.aimturnrightspeed = (movedata.c1stickxraw - 60) / 10.0f;
if (g_Vars.currentplayer->insightaimmode && movedata.c1stickxraw > joy_edge_threshold) {
movedata.aimturnrightspeed = (movedata.c1stickxraw - joy_edge_threshold) / (127.0f - joy_edge_threshold);

if (movedata.aimturnrightspeed > 1) {
movedata.aimturnrightspeed = 1;
Expand Down Expand Up @@ -1414,29 +1430,31 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i
}

// Handle looking up/down while aiming
if (g_Vars.currentplayer->insightaimmode && movedata.c1stickyraw > 60) {
movedata.speedvertadown = (movedata.c1stickyraw - 60) / 10.0f;
f32 joy_edge_threshold = bmoveCalculateJoyEdgeThreshold();

if (g_Vars.currentplayer->insightaimmode && movedata.c1stickyraw > joy_edge_threshold) {
movedata.speedvertadown = (movedata.c1stickyraw - joy_edge_threshold) / (127.0f - joy_edge_threshold);

if (movedata.speedvertadown > 1) {
movedata.speedvertadown = 1;
}
} else if (g_Vars.currentplayer->insightaimmode && movedata.c1stickyraw < -60) {
movedata.speedvertaup = (-60 - movedata.c1stickyraw) / 10.0f;
} else if (g_Vars.currentplayer->insightaimmode && movedata.c1stickyraw < -joy_edge_threshold) {
movedata.speedvertaup = (-joy_edge_threshold - movedata.c1stickyraw) / (127.0f - joy_edge_threshold);

if (movedata.speedvertaup > 1) {
movedata.speedvertaup = 1;
}
}

// Handle looking left/right while aiming
if (g_Vars.currentplayer->insightaimmode && movedata.c1stickxraw < -60) {
movedata.aimturnleftspeed = (-60 - movedata.c1stickxraw) / 10.0f;
if (g_Vars.currentplayer->insightaimmode && movedata.c1stickxraw < -joy_edge_threshold) {
movedata.aimturnleftspeed = (-joy_edge_threshold - movedata.c1stickxraw) / (127.0f - joy_edge_threshold);

if (movedata.aimturnleftspeed > 1) {
movedata.aimturnleftspeed = 1;
}
} else if (g_Vars.currentplayer->insightaimmode && movedata.c1stickxraw > 60) {
movedata.aimturnrightspeed = (movedata.c1stickxraw - 60) / 10.0f;
} else if (g_Vars.currentplayer->insightaimmode && movedata.c1stickxraw > joy_edge_threshold) {
movedata.aimturnrightspeed = (movedata.c1stickxraw - joy_edge_threshold) / (127.0f - joy_edge_threshold);

if (movedata.aimturnrightspeed > 1) {
movedata.aimturnrightspeed = 1;
Expand Down
2 changes: 1 addition & 1 deletion src/game/mplayer/mplayer.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ struct mpweapon g_MpWeapons[NUM_MPWEAPONS] = {
.extcontrols = true, \
.crosshaircolour = 0x00ff0028, \
.crosshairsize = 2, \
.crosshairedgeboundary = 0.7f, \
.crosshairedgeboundary = 0.60f, \
.crosshairhealth = CROSSHAIR_HEALTH_OFF, \
.usereloads = false, \
}
Expand Down