aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordaoge_cmd <3523206925@qq.com>2026-03-05 01:49:38 +0800
committerdaoge_cmd <3523206925@qq.com>2026-03-05 01:49:38 +0800
commit4108ed142b82443c9c50f440b931d7589d22eeda (patch)
tree74714903c89133b1bc8df7e153f62670ccb6f855
parent7b35df871444842976e3b8389825f39a4267a270 (diff)
fix: restore KBM sprint on either Ctrl key
-rw-r--r--Minecraft.Client/Input.cpp2
-rw-r--r--Minecraft.Client/Windows64/KeyboardMouseInput.cpp24
-rw-r--r--Minecraft.Client/Windows64/KeyboardMouseInput.h2
3 files changed, 26 insertions, 2 deletions
diff --git a/Minecraft.Client/Input.cpp b/Minecraft.Client/Input.cpp
index 5e41da29..4d931d3e 100644
--- a/Minecraft.Client/Input.cpp
+++ b/Minecraft.Client/Input.cpp
@@ -104,7 +104,7 @@ void Input::tick(LocalPlayer *player)
}
}
- // Left Ctrl + forward = sprint (hold to sprint)
+ // Ctrl + forward = sprint (hold to sprint)
if (!player->abilities.flying)
{
bool ctrlHeld = g_KBMInput.IsKeyDown(KeyboardMouseInput::KEY_SPRINT);
diff --git a/Minecraft.Client/Windows64/KeyboardMouseInput.cpp b/Minecraft.Client/Windows64/KeyboardMouseInput.cpp
index 95c3f4fc..6206db87 100644
--- a/Minecraft.Client/Windows64/KeyboardMouseInput.cpp
+++ b/Minecraft.Client/Windows64/KeyboardMouseInput.cpp
@@ -12,6 +12,21 @@ extern HWND g_hWnd;
// Forward declaration
static void ClipCursorToWindow(HWND hWnd);
+static bool IsModifierKeyDown(const bool* keyState, int vkCode)
+{
+ switch (vkCode)
+ {
+ case VK_SHIFT:
+ return keyState[VK_LSHIFT] || keyState[VK_RSHIFT];
+ case VK_CONTROL:
+ return keyState[VK_LCONTROL] || keyState[VK_RCONTROL];
+ case VK_MENU:
+ return keyState[VK_LMENU] || keyState[VK_RMENU];
+ default:
+ return false;
+ }
+}
+
void KeyboardMouseInput::Init()
{
memset(m_keyDown, 0, sizeof(m_keyDown));
@@ -189,6 +204,9 @@ void KeyboardMouseInput::OnRawMouseDelta(int dx, int dy)
bool KeyboardMouseInput::IsKeyDown(int vkCode) const
{
+ if (vkCode == VK_SHIFT || vkCode == VK_CONTROL || vkCode == VK_MENU)
+ return IsModifierKeyDown(m_keyDown, vkCode);
+
if (vkCode >= 0 && vkCode < MAX_KEYS)
return m_keyDown[vkCode];
return false;
@@ -196,6 +214,9 @@ bool KeyboardMouseInput::IsKeyDown(int vkCode) const
bool KeyboardMouseInput::IsKeyPressed(int vkCode) const
{
+ if (vkCode == VK_SHIFT || vkCode == VK_CONTROL || vkCode == VK_MENU)
+ return IsModifierKeyDown(m_keyPressed, vkCode);
+
if (vkCode >= 0 && vkCode < MAX_KEYS)
return m_keyPressed[vkCode];
return false;
@@ -203,6 +224,9 @@ bool KeyboardMouseInput::IsKeyPressed(int vkCode) const
bool KeyboardMouseInput::IsKeyReleased(int vkCode) const
{
+ if (vkCode == VK_SHIFT || vkCode == VK_CONTROL || vkCode == VK_MENU)
+ return IsModifierKeyDown(m_keyReleased, vkCode);
+
if (vkCode >= 0 && vkCode < MAX_KEYS)
return m_keyReleased[vkCode];
return false;
diff --git a/Minecraft.Client/Windows64/KeyboardMouseInput.h b/Minecraft.Client/Windows64/KeyboardMouseInput.h
index 05067055..89a028b1 100644
--- a/Minecraft.Client/Windows64/KeyboardMouseInput.h
+++ b/Minecraft.Client/Windows64/KeyboardMouseInput.h
@@ -20,7 +20,7 @@ public:
static const int KEY_RIGHT = 'D';
static const int KEY_JUMP = VK_SPACE;
static const int KEY_SNEAK = VK_LSHIFT;
- static const int KEY_SPRINT = VK_LCONTROL;
+ static const int KEY_SPRINT = VK_CONTROL;
static const int KEY_INVENTORY = 'E';
static const int KEY_DROP = 'Q';
static const int KEY_CRAFTING = 'C';