From 7b35df871444842976e3b8389825f39a4267a270 Mon Sep 17 00:00:00 2001 From: daoge_cmd <3523206925@qq.com> Date: Thu, 5 Mar 2026 01:38:34 +0800 Subject: [PATCH] Fix controller paging regression in creative menu Preserve smooth row-by-row scrolling for mouse wheel input, but restore full-page movement for controller/menu scroll actions in the creative inventory. Commit 3093ca3 changed page indexing to support smooth scrolling, which caused ACTION_MENU_OTHER_STICK_UP/DOWN to advance by one row instead of one page. Track whether the scroll action originated from the mouse wheel and only use single-row steps in that case. Fixes #253 --- .../Common/UI/IUIScene_CreativeMenu.cpp | 22 +++++++++++++++++-- .../Windows64/KeyboardMouseInput.cpp | 5 +++++ .../Windows64/KeyboardMouseInput.h | 4 +++- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp b/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp index 544fedc0..04852e97 100644 --- a/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp +++ b/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp @@ -1098,7 +1098,15 @@ void IUIScene_CreativeMenu::handleAdditionalKeyPress(int iAction) } break; case ACTION_MENU_OTHER_STICK_DOWN: - ++m_tabPage[m_curTab]; + { + int pageStep = TabSpec::rows; +#ifdef _WINDOWS64 + if (g_KBMInput.WasMouseWheelConsumed()) + { + pageStep = 1; + } +#endif + m_tabPage[m_curTab] += pageStep; if(m_tabPage[m_curTab] >= specs[m_curTab]->getPageCount()) { m_tabPage[m_curTab] = specs[m_curTab]->getPageCount() - 1; @@ -1107,9 +1115,18 @@ void IUIScene_CreativeMenu::handleAdditionalKeyPress(int iAction) { switchTab(m_curTab); } + } break; case ACTION_MENU_OTHER_STICK_UP: - --m_tabPage[m_curTab]; + { + int pageStep = TabSpec::rows; +#ifdef _WINDOWS64 + if (g_KBMInput.WasMouseWheelConsumed()) + { + pageStep = 1; + } +#endif + m_tabPage[m_curTab] -= pageStep; if(m_tabPage[m_curTab] < 0) { m_tabPage[m_curTab] = 0; @@ -1118,6 +1135,7 @@ void IUIScene_CreativeMenu::handleAdditionalKeyPress(int iAction) { switchTab(m_curTab); } + } break; } } diff --git a/Minecraft.Client/Windows64/KeyboardMouseInput.cpp b/Minecraft.Client/Windows64/KeyboardMouseInput.cpp index 7ab99a71..95c3f4fc 100644 --- a/Minecraft.Client/Windows64/KeyboardMouseInput.cpp +++ b/Minecraft.Client/Windows64/KeyboardMouseInput.cpp @@ -33,6 +33,7 @@ void KeyboardMouseInput::Init() m_mouseDeltaAccumX = 0; m_mouseDeltaAccumY = 0; m_mouseWheelAccum = 0; + m_mouseWheelConsumed = false; m_mouseGrabbed = false; m_cursorHiddenForUI = false; m_windowFocused = true; @@ -67,6 +68,7 @@ void KeyboardMouseInput::ClearAllState() m_mouseDeltaAccumX = 0; m_mouseDeltaAccumY = 0; m_mouseWheelAccum = 0; + m_mouseWheelConsumed = false; } void KeyboardMouseInput::Tick() @@ -88,6 +90,7 @@ void KeyboardMouseInput::Tick() m_mouseDeltaY = m_mouseDeltaAccumY; m_mouseDeltaAccumX = 0; m_mouseDeltaAccumY = 0; + m_mouseWheelConsumed = false; m_hasInput = (m_mouseDeltaX != 0 || m_mouseDeltaY != 0 || m_mouseWheelAccum != 0); if (!m_hasInput) @@ -172,6 +175,8 @@ void KeyboardMouseInput::OnMouseWheel(int delta) int KeyboardMouseInput::GetMouseWheel() { int val = m_mouseWheelAccum; + if (val != 0) + m_mouseWheelConsumed = true; m_mouseWheelAccum = 0; return val; } diff --git a/Minecraft.Client/Windows64/KeyboardMouseInput.h b/Minecraft.Client/Windows64/KeyboardMouseInput.h index f098ccab..05067055 100644 --- a/Minecraft.Client/Windows64/KeyboardMouseInput.h +++ b/Minecraft.Client/Windows64/KeyboardMouseInput.h @@ -59,7 +59,8 @@ public: int GetMouseWheel(); int PeekMouseWheel() const { return m_mouseWheelAccum; } - void ConsumeMouseWheel() { m_mouseWheelAccum = 0; } + void ConsumeMouseWheel() { if (m_mouseWheelAccum != 0) m_mouseWheelConsumed = true; m_mouseWheelAccum = 0; } + bool WasMouseWheelConsumed() const { return m_mouseWheelConsumed; } // Per-frame delta consumption for low-latency mouse look. // Reads and clears the raw accumulators (not the per-tick snapshot). @@ -114,6 +115,7 @@ private: int m_mouseDeltaAccumY; int m_mouseWheelAccum; + bool m_mouseWheelConsumed; bool m_mouseGrabbed;