From 3fae02c7d342981c9910db7715305bc57b261a8b Mon Sep 17 00:00:00 2001 From: salmonik Date: Tue, 27 Oct 2026 18:09:19 +0100 Subject: GUI: allow movement while open; freeze look and block bind capture Feedback pass on the preview shell: - Freeze the rendered view explicitly in CreateMove and again at FRAME_RENDER_START; CInput was still letting mouse look move the camera. - Allow normal WASD/jump/duck movement while the GUI is open; strip attack/use/impulse/weapon selection so GUI clicks do not fire. - While bind capture is active, block all game input. - Esc no longer closes the GUI; it only cancels bind capture. F2 or the title-bar X close the preview. - Interpose SDL_ShowCursor / SDL_SetRelativeMouseMode / warp / window grab so the game cannot re-capture or hide the native cursor while the GUI is open. --- src/hl2h.cpp | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) (limited to 'src/hl2h.cpp') diff --git a/src/hl2h.cpp b/src/hl2h.cpp index c0c27af..a0e6b53 100644 --- a/src/hl2h.cpp +++ b/src/hl2h.cpp @@ -546,10 +546,23 @@ static void do_move(int seq, float frametime) { cmd->viewangles[0] = f.x; cmd->viewangles[1] = f.y; cmd->viewangles[2] = f.z; - cmd->forwardmove = 0.0f; - cmd->sidemove = 0.0f; - cmd->upmove = 0.0f; - cmd->buttons = 0; + // Freeze the rendered view explicitly: CInput may not push the modified + // command view back to the engine if the client mode returns false. + if (g_iface.engine) { + QAngle set = f; + using SetViewFn = void (*)(void *, QAngle *); + vfunc(g_iface.engine, 20)(g_iface.engine, &set); + } + if (gui_bind_capture_active()) { + // Bind capture must not move/act in the game while keys are sampled. + cmd->forwardmove = 0.0f; + cmd->sidemove = 0.0f; + cmd->upmove = 0.0f; + cmd->buttons = 0; + } else { + // Movement is allowed while the GUI is open, but not look/attack/use. + cmd->buttons &= (IN_JUMP | IN_DUCK); + } cmd->impulse = 0; cmd->weaponselect = 0; cmd->weaponsubtype = 0; @@ -670,12 +683,19 @@ void set_silent_restore(const QAngle &angles) { static void hkdFrameStageNotify(void *self, int stage) { if (oFrameStageNotify) oFrameStageNotify(self, stage); - if (stage == 5 && g_silent_restore_pending) { - g_silent_restore_pending = false; - if (g_iface.engine) { - QAngle a = g_silent_restore_angles; + if (stage == 5) { + if (g_silent_restore_pending) { + g_silent_restore_pending = false; + if (g_iface.engine) { + QAngle a = g_silent_restore_angles; + using SetViewFn = void (*)(void *, QAngle *); + vfunc(g_iface.engine, 20)(g_iface.engine, &a); + } + } + if (gui_is_open() && g_iface.engine) { + QAngle f = gui_frozen_view(); using SetViewFn = void (*)(void *, QAngle *); - vfunc(g_iface.engine, 20)(g_iface.engine, &a); + vfunc(g_iface.engine, 20)(g_iface.engine, &f); } } } -- cgit v1.2.3