aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/Common/UI/IUIScene_AbstractContainerMenu.cpp
diff options
context:
space:
mode:
authordaoge_cmd <3523206925@qq.com>2026-03-04 21:19:40 +0800
committerdaoge_cmd <3523206925@qq.com>2026-03-05 01:12:48 +0800
commit1dc8a005ed111463c22c17b487e5ec8a3e2d30f3 (patch)
tree8f1825364bf14178f720ee124b01de78afa16d40 /Minecraft.Client/Common/UI/IUIScene_AbstractContainerMenu.cpp
parentac03b88a907bb49f5159f08de07398f3fce32991 (diff)
refactor: refactor KBM input code
Diffstat (limited to 'Minecraft.Client/Common/UI/IUIScene_AbstractContainerMenu.cpp')
-rw-r--r--Minecraft.Client/Common/UI/IUIScene_AbstractContainerMenu.cpp42
1 files changed, 40 insertions, 2 deletions
diff --git a/Minecraft.Client/Common/UI/IUIScene_AbstractContainerMenu.cpp b/Minecraft.Client/Common/UI/IUIScene_AbstractContainerMenu.cpp
index 667431b2..88258421 100644
--- a/Minecraft.Client/Common/UI/IUIScene_AbstractContainerMenu.cpp
+++ b/Minecraft.Client/Common/UI/IUIScene_AbstractContainerMenu.cpp
@@ -13,6 +13,12 @@
#include <pad.h>
#endif
+#ifdef _WINDOWS64
+#include "..\..\Windows64\KeyboardMouseInput.h"
+
+SavedInventoryCursorPos g_savedInventoryCursorPos = { 0.0f, 0.0f, false };
+#endif
+
IUIScene_AbstractContainerMenu::IUIScene_AbstractContainerMenu()
{
m_menu = NULL;
@@ -474,6 +480,34 @@ void IUIScene_AbstractContainerMenu::onMouseTick()
}
#endif
+#ifdef _WINDOWS64
+ if (!g_KBMInput.IsMouseGrabbed() && g_KBMInput.IsKBMActive())
+ {
+ int deltaX = g_KBMInput.GetMouseDeltaX();
+ int deltaY = g_KBMInput.GetMouseDeltaY();
+
+ extern HWND g_hWnd;
+ RECT rc;
+ GetClientRect(g_hWnd, &rc);
+ int winW = rc.right - rc.left;
+ int winH = rc.bottom - rc.top;
+
+ if (winW > 0 && winH > 0)
+ {
+ float scaleX = (float)getMovieWidth() / (float)winW;
+ float scaleY = (float)getMovieHeight() / (float)winH;
+
+ vPointerPos.x += (float)deltaX * scaleX;
+ vPointerPos.y += (float)deltaY * scaleY;
+ }
+
+ if (deltaX != 0 || deltaY != 0)
+ {
+ bStickInput = true;
+ }
+ }
+#endif
+
// Determine which slot the pointer is currently over.
ESceneSection eSectionUnderPointer = eSectionNone;
int iNewSlotX = -1;
@@ -694,7 +728,11 @@ void IUIScene_AbstractContainerMenu::onMouseTick()
// If there is no stick input, and we are over a slot, then snap pointer to slot centre.
// 4J - TomK - only if this particular component allows so!
- if(!m_bPointerDrivenByMouse && CanHaveFocus(eSectionUnderPointer))
+#ifdef _WINDOWS64
+ if((g_KBMInput.IsMouseGrabbed() || !g_KBMInput.IsKBMActive()) && CanHaveFocus(eSectionUnderPointer))
+#else
+ if(CanHaveFocus(eSectionUnderPointer))
+#endif
{
vPointerPos.x = vSnapPos.x;
vPointerPos.y = vSnapPos.y;
@@ -1329,7 +1367,7 @@ bool IUIScene_AbstractContainerMenu::handleKeyDown(int iPad, int iAction, bool b
// Standard left click
buttonNum = 0;
- if (KMInput.IsKeyDown(VK_SHIFT))
+ if (g_KBMInput.IsKeyDown(VK_LSHIFT))
{
{
validKeyPress = TRUE;