aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/Input.cpp
diff options
context:
space:
mode:
authordaoge_cmd <3523206925@qq.com>2026-03-02 01:21:56 +0800
committerdaoge_cmd <3523206925@qq.com>2026-03-02 01:21:56 +0800
commit6cba5705dd24a3266cbfc729af0a96b06234fc34 (patch)
tree31ada76f131a75f8b6a3a617e3a6bfb4d01324b4 /Minecraft.Client/Input.cpp
parentb5111232aa13952f58ed1b3b3525ea825662b95c (diff)
fix: fix sprinting
Diffstat (limited to 'Minecraft.Client/Input.cpp')
-rw-r--r--Minecraft.Client/Input.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/Minecraft.Client/Input.cpp b/Minecraft.Client/Input.cpp
index 7fce9360..c1a3bb31 100644
--- a/Minecraft.Client/Input.cpp
+++ b/Minecraft.Client/Input.cpp
@@ -12,9 +12,11 @@ Input::Input()
{
xa = 0;
ya = 0;
+ sprintForward = 0;
wasJumping = false;
jumping = false;
sneaking = false;
+ usingKeyboardMovement = false;
lReset = false;
rReset = false;
@@ -40,16 +42,18 @@ void Input::tick(LocalPlayer *player)
ya = InputManager.GetJoypadStick_LY(iPad);
else
ya = 0.0f;
+ sprintForward = ya;
+ usingKeyboardMovement = false;
#ifdef _WINDOWS64
// WASD movement (combine with gamepad)
if (iPad == 0)
{
float kbX = 0.0f, kbY = 0.0f;
- if (KMInput.IsKeyDown('W')) kbY += 1.0f;
- if (KMInput.IsKeyDown('S')) kbY -= 1.0f;
- if (KMInput.IsKeyDown('A')) kbX += 1.0f; // inverted like gamepad
- if (KMInput.IsKeyDown('D')) kbX -= 1.0f;
+ if (KMInput.IsKeyDown('W')) { kbY += 1.0f; sprintForward += 1.0f; usingKeyboardMovement = true; }
+ if (KMInput.IsKeyDown('S')) { kbY -= 1.0f; sprintForward -= 1.0f; usingKeyboardMovement = true; }
+ if (KMInput.IsKeyDown('A')) { kbX += 1.0f; usingKeyboardMovement = true; } // inverted like gamepad
+ if (KMInput.IsKeyDown('D')) { kbX -= 1.0f; usingKeyboardMovement = true; }
// Normalize diagonal
if (kbX != 0.0f && kbY != 0.0f) { kbX *= 0.707f; kbY *= 0.707f; }
if (pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_LEFT) || pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_RIGHT))
@@ -58,11 +62,13 @@ void Input::tick(LocalPlayer *player)
ya = max(min(ya + kbY, 1.0f), -1.0f);
}
#endif
+ sprintForward = max(min(sprintForward, 1.0f), -1.0f);
#ifndef _CONTENT_PACKAGE
if (app.GetFreezePlayers())
{
xa = ya = 0.0f;
+ sprintForward = 0.0f;
player->abilities.flying = true;
}
#endif
@@ -74,6 +80,7 @@ void Input::tick(LocalPlayer *player)
lReset = true;
}
xa = ya = 0.0f;
+ sprintForward = 0.0f;
}
// 4J - in flying mode, don't actually toggle sneaking
@@ -168,4 +175,4 @@ void Input::tick(LocalPlayer *player)
#endif
//OutputDebugString("INPUT: End input tick\n");
-} \ No newline at end of file
+}