Skip to content

Commit

Permalink
Blood: Allow keyboard turn acceleration to be toggled
Browse files Browse the repository at this point in the history
  • Loading branch information
tmyqlfpir committed Sep 9, 2024
1 parent 5e9fa37 commit 2a0c64c
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 1 deletion.
2 changes: 2 additions & 0 deletions source/blood/src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ int32_t useprecache;
char CommbatMacro[MAXRIDECULE][MAXRIDECULELENGTH];
char szPlayerName[MAXPLAYERNAME];
int32_t gTurnSpeed;
int32_t gTurnAcceleration;
int32_t gDetail;
int32_t gMouseAim;
int32_t gAutoAim;
Expand Down Expand Up @@ -384,6 +385,7 @@ void CONFIG_SetDefaults(void)
gDeliriumBlur = 1;
gViewSize = 2;
gTurnSpeed = 92;
gTurnAcceleration = 1;
gDetail = 4;
gAutoRun = 0;
gViewInterpolate = 1;
Expand Down
1 change: 1 addition & 0 deletions source/blood/src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ extern int32_t useprecache;
extern char CommbatMacro[MAXRIDECULE][MAXRIDECULELENGTH];
extern char szPlayerName[MAXPLAYERNAME];
extern int32_t gTurnSpeed;
extern int32_t gTurnAcceleration;
extern int32_t gDetail;
extern int32_t gAutoAim;
extern int32_t gWeaponSwitch;
Expand Down
2 changes: 1 addition & 1 deletion source/blood/src/controls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ void ctrlGetInput(void)
if (turnRight)
input.q16turn = fix16_sadd(input.q16turn, fix16_from_float(scaleAdjustmentToInterval(ClipHigh(12 * turnHeldTime, gTurnSpeed)>>2)));

if ((run2 || run) && turnHeldTime > 24)
if (!gTurnAcceleration || (((gTurnAcceleration == 2) || run2 || run) && (turnHeldTime > 24)))
input.q16turn <<= 1;

if (BUTTON(gamefunc_Strafe))
Expand Down
16 changes: 16 additions & 0 deletions source/blood/src/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ void SetViewSwaying(CGameMenuItemZBool *);
void SetMouseSensitivity(CGameMenuItemSliderFloat *);
void SetMouseAimFlipped(CGameMenuItemZBool *);
void SetTurnSpeed(CGameMenuItemSlider *);
void SetTurnAcceleration(CGameMenuItemZCycle *);
void ResetKeys(CGameMenuItemChain *);
void ResetKeysClassic(CGameMenuItemChain *);
void SetMessages(CGameMenuItemZBool *);
Expand Down Expand Up @@ -716,6 +717,12 @@ void SetJoystickDigitalNeg(CGameMenuItemZCycle* pItem);
void SetJoystickDeadzone(CGameMenuItemSlider* pItem);
void SetJoystickSaturate(CGameMenuItemSlider* pItem);

const char *pzTurnAccelerationStrings[] = {
"OFF",
"ON RUNNING",
"ALWAYS ON",
};

CGameMenuItemTitle itemOptionsControlTitle("CONTROL SETUP", 1, 160, 20, 2038);
CGameMenuItemChain itemOptionsControlKeyboard("KEYBOARD SETUP", 1, 0, 60, 320, 1, &menuOptionsControlKeyboard, -1, NULL, 0);
CGameMenuItemChain itemOptionsControlMouse("MOUSE SETUP", 1, 0, 80, 320, 1, &menuOptionsControlMouse, -1, SetupMouseMenu, 0);
Expand All @@ -724,6 +731,7 @@ CGameMenuItemChain itemOptionsControlJoystickAxes("JOYSTICK AXES SETUP", 1, 0, 1

CGameMenuItemTitle itemOptionsControlKeyboardTitle("KEYBOARD SETUP", 1, 160, 20, 2038);
CGameMenuItemSlider itemOptionsControlKeyboardSliderTurnSpeed("Key Turn Speed:", 1, 18, 50, 280, &gTurnSpeed, 64, 128, 4, SetTurnSpeed, -1, -1);
CGameMenuItemZCycle itemOptionsControlKeyboardCycleTurnAcceleration("Key Turn Acceleration:", 1, 18, 70, 280, 0, SetTurnAcceleration, pzTurnAccelerationStrings, ARRAY_SIZE(pzTurnAccelerationStrings), 0);
CGameMenuItemChain itemOptionsControlKeyboardList("Configure Keys...", 1, 0, 110, 320, 1, &menuKeys, -1, NULL, 0);
CGameMenuItemChain itemOptionsControlKeyboardReset("Reset Keys (default)...", 1, 0, 135, 320, 1, &menuKeys, -1, ResetKeys, 0);
CGameMenuItemChain itemOptionsControlKeyboardResetClassic("Reset Keys (classic)...", 1, 0, 155, 320, 1, &menuKeys, -1, ResetKeysClassic, 0);
Expand Down Expand Up @@ -1436,12 +1444,15 @@ void SetupControlsMenu(void)

menuOptionsControlKeyboard.Add(&itemOptionsControlKeyboardTitle, false);
menuOptionsControlKeyboard.Add(&itemOptionsControlKeyboardSliderTurnSpeed, true);
menuOptionsControlKeyboard.Add(&itemOptionsControlKeyboardCycleTurnAcceleration, false);
menuOptionsControlKeyboard.Add(&itemOptionsControlKeyboardList, false);
menuOptionsControlKeyboard.Add(&itemOptionsControlKeyboardReset, false);
menuOptionsControlKeyboard.Add(&itemOptionsControlKeyboardResetClassic, false);
menuOptionsControlKeyboard.Add(&itemBloodQAV, false);

itemOptionsControlKeyboardSliderTurnSpeed.nValue = gTurnSpeed;
itemOptionsControlKeyboardCycleTurnAcceleration.m_nFocus = gTurnAcceleration;

menuOptionsControlMouse.Add(&itemOptionsControlMouseTitle, false);
menuOptionsControlMouse.Add(&itemOptionsControlMouseButton, true);
menuOptionsControlMouse.Add(&itemOptionsControlMouseSensitivity, false);
Expand Down Expand Up @@ -1793,6 +1804,11 @@ void SetTurnSpeed(CGameMenuItemSlider *pItem)
gTurnSpeed = pItem->nValue;
}

void SetTurnAcceleration(CGameMenuItemZCycle *pItem)
{
gTurnAcceleration = pItem->m_nFocus;
}

void SetAutoAim(CGameMenuItemZCycle *pItem)
{
gAutoAim = pItem->m_nFocus;
Expand Down
1 change: 1 addition & 0 deletions source/blood/src/osdcmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1030,6 +1030,7 @@ int32_t registerosdcommands(void)
{ "in_mousedeadzone", "amount of mouse movement to filter out", (void *)&MouseDeadZone, CVAR_INT, 0, 512 },
{ "in_mouseflip", "invert vertical mouse movement", (void *)&gMouseAimingFlipped, CVAR_BOOL, 0, 1 },
{ "in_mousemode", "toggles vertical mouse view", (void *)&gMouseAim, CVAR_BOOL, 0, 1 },
{ "in_turnacceleration", "set keyboard turning acceleration (0: off, 1: only when running, 2: always on)", (void *)&gTurnAcceleration, CVAR_INT, 0, 2 },
{ "in_turnsensitivity", "keyboard turning sensitivity multiplier", (void *)&gTurnSpeed, CVAR_INT, 64, 124 },
//
{ "mus_enabled", "enables/disables music", (void *)&MusicToggle, CVAR_BOOL, 0, 1 },
Expand Down

0 comments on commit 2a0c64c

Please sign in to comment.