From eb6e42eb59cce496a81842924a1c1f4f60c7bbd3 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Sat, 7 Feb 2026 16:05:13 -0800 Subject: [PATCH] Add tilde key toggle for auto-run Pressing ~ toggles auto-run (continuous forward movement). Pressing W or S cancels it. Also cancelled on respawn/teleport. --- include/rendering/camera_controller.hpp | 2 ++ src/rendering/camera_controller.cpp | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/rendering/camera_controller.hpp b/include/rendering/camera_controller.hpp index 0eabf76f..4f23056e 100644 --- a/include/rendering/camera_controller.hpp +++ b/include/rendering/camera_controller.hpp @@ -158,6 +158,8 @@ private: bool xKeyWasDown = false; bool rKeyWasDown = false; bool runPace = false; + bool autoRunning = false; + bool tildeWasDown = false; // Movement state tracking (for sending opcodes on state change) bool wasMovingForward = false; diff --git a/src/rendering/camera_controller.cpp b/src/rendering/camera_controller.cpp index af38f7a1..22071e04 100644 --- a/src/rendering/camera_controller.cpp +++ b/src/rendering/camera_controller.cpp @@ -136,8 +136,18 @@ void CameraController::update(float deltaTime) { keyW = keyS = keyA = keyD = keyQ = keyE = nowJump = false; } + // Tilde toggles auto-run; any forward/backward key cancels it + bool tildeDown = !uiWantsKeyboard && input.isKeyPressed(SDL_SCANCODE_GRAVE); + if (tildeDown && !tildeWasDown) { + autoRunning = !autoRunning; + } + tildeWasDown = tildeDown; + if (keyW || keyS) { + autoRunning = false; + } + bool mouseAutorun = !uiWantsKeyboard && !sitting && leftMouseDown && rightMouseDown; - bool nowForward = keyW || mouseAutorun; + bool nowForward = keyW || mouseAutorun || autoRunning; bool nowBackward = keyS; bool nowStrafeLeft = false; bool nowStrafeRight = false; @@ -1025,6 +1035,7 @@ void CameraController::reset() { grounded = true; swimming = false; sitting = false; + autoRunning = false; // Clear edge-state so movement packets can re-start cleanly after respawn. wasMovingForward = false;