aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/Common/UI/UIScene_AbstractContainerMenu.cpp
diff options
context:
space:
mode:
authordaoge_cmd <3523206925@qq.com>2026-03-03 04:59:08 +0800
committerdaoge_cmd <3523206925@qq.com>2026-03-03 04:59:08 +0800
commit8f6647b5d89bbb56eeda727dfee9916d8514104d (patch)
tree38ef3b1a294bfac7d6cf220eaa1b2470cd239a6a /Minecraft.Client/Common/UI/UIScene_AbstractContainerMenu.cpp
parentf917335b132f527c436a32f07636f503614c4e69 (diff)
fix: fix mouse and controller input handling in container menus
Diffstat (limited to 'Minecraft.Client/Common/UI/UIScene_AbstractContainerMenu.cpp')
-rw-r--r--Minecraft.Client/Common/UI/UIScene_AbstractContainerMenu.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/Minecraft.Client/Common/UI/UIScene_AbstractContainerMenu.cpp b/Minecraft.Client/Common/UI/UIScene_AbstractContainerMenu.cpp
index f769622e..5ad275c3 100644
--- a/Minecraft.Client/Common/UI/UIScene_AbstractContainerMenu.cpp
+++ b/Minecraft.Client/Common/UI/UIScene_AbstractContainerMenu.cpp
@@ -187,7 +187,7 @@ void UIScene_AbstractContainerMenu::tick()
#ifdef _WINDOWS64
bool mouseActive = (m_iPad == 0 && !KMInput.IsCaptured());
- bool useRawMousePointer = false;
+ bool drivePointerFromMouse = false;
float rawMouseMovieX = 0, rawMouseMovieY = 0;
int scrollDelta = 0;
// Map Windows mouse position to the virtual pointer in movie coordinates
@@ -215,11 +215,13 @@ void UIScene_AbstractContainerMenu::tick()
rawMouseMovieX = mx;
rawMouseMovieY = my;
- // Only let the OS cursor drive the menu when the mouse is actively being used.
- // Otherwise a stationary mouse will override the controller cursor every tick.
- useRawMousePointer = mouseMoved || KMInput.IsMouseDown(0) || KMInput.IsMouseDown(1) || KMInput.IsMouseDown(2) || scrollDelta != 0;
- if (useRawMousePointer)
+ // Once the mouse has taken over the container cursor, keep following the OS cursor
+ // until explicit controller input takes ownership back.
+ drivePointerFromMouse = m_bPointerDrivenByMouse || mouseMoved || KMInput.IsMouseDown(0) || KMInput.IsMouseDown(1) || KMInput.IsMouseDown(2) || scrollDelta != 0;
+ if (drivePointerFromMouse)
{
+ m_bPointerDrivenByMouse = true;
+ m_eCurrTapState = eTapStateNoInput;
m_pointerPos.x = mx;
m_pointerPos.y = my;
}
@@ -293,7 +295,7 @@ void UIScene_AbstractContainerMenu::tick()
#ifdef _WINDOWS64
S32 x, y;
- if (mouseActive && useRawMousePointer)
+ if (mouseActive && m_bPointerDrivenByMouse)
{
// Send raw mouse position directly as Iggy event to avoid coordinate round-trip errors
// Scale mouse client coords to the Iggy display space (which was set to getRenderDimensions())
@@ -386,6 +388,7 @@ void UIScene_AbstractContainerMenu::handleInput(int iPad, int key, bool repeat,
if(pressed)
{
+ m_bPointerDrivenByMouse = false;
handled = handleKeyDown(m_iPad, key, repeat);
}
}