add keyboard/mouse controls for menus and gameplay

wired up keyboard and mouse input for menu navigation, inventory cursor, crafting, and general UI interaction. added WASD movement, mouse look, left ctrl sprint, left shift sneak, and all the keybinds for gameplay. also fixed the sound engine crashing when it cant find a sound asset, and set up the x64 build with proper post-build steps for dlls and redist
This commit is contained in:
coah
2026-03-01 20:02:02 -06:00
parent adfd58807e
commit 7da64d57a8
16 changed files with 335 additions and 41 deletions

View File

@@ -6,6 +6,9 @@ KeyboardMouseInput g_KBMInput;
extern HWND g_hWnd;
// Forward declaration
static void ClipCursorToWindow(HWND hWnd);
// coded by notpies fr
void KeyboardMouseInput::Init()
{
@@ -40,10 +43,6 @@ void KeyboardMouseInput::Init()
rid.hwndTarget = g_hWnd;
RegisterRawInputDevices(&rid, 1, sizeof(rid));
if (g_hWnd)
{
while (ShowCursor(FALSE) >= 0) {}
}
}
void KeyboardMouseInput::ClearAllState()
@@ -226,6 +225,9 @@ void KeyboardMouseInput::SetMouseGrabbed(bool grabbed)
m_mouseGrabbed = grabbed;
if (grabbed && g_hWnd)
{
while (ShowCursor(FALSE) >= 0) {}
ClipCursorToWindow(g_hWnd);
RECT rc;
GetClientRect(g_hWnd, &rc);
POINT center;
@@ -237,6 +239,11 @@ void KeyboardMouseInput::SetMouseGrabbed(bool grabbed)
m_mouseDeltaAccumX = 0;
m_mouseDeltaAccumY = 0;
}
else if (!grabbed && g_hWnd)
{
while (ShowCursor(TRUE) < 0) {}
ClipCursor(NULL);
}
}
static void ClipCursorToWindow(HWND hWnd)
@@ -257,8 +264,16 @@ void KeyboardMouseInput::SetWindowFocused(bool focused)
m_windowFocused = focused;
if (focused)
{
while (ShowCursor(FALSE) >= 0) {}
ClipCursorToWindow(g_hWnd);
if (m_mouseGrabbed)
{
while (ShowCursor(FALSE) >= 0) {}
ClipCursorToWindow(g_hWnd);
}
else
{
while (ShowCursor(TRUE) < 0) {}
ClipCursor(NULL);
}
}
else
{