summaryrefslogtreecommitdiffstats
path: root/src/hl2h.cpp
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-10-27 18:09:19 +0100
committersalmonik <salmonik@tuta.io>2026-10-27 18:09:19 +0100
commit3fae02c7d342981c9910db7715305bc57b261a8b (patch)
treef221907effb1f84dfa3e639e3c2966e432e15c10 /src/hl2h.cpp
parentGUI: add F2 preview shell with dummy controls (diff)
downloadhl2h-3fae02c7d342981c9910db7715305bc57b261a8b.tar.gz
hl2h-3fae02c7d342981c9910db7715305bc57b261a8b.zip
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.
Diffstat (limited to '')
-rw-r--r--src/hl2h.cpp38
1 files changed, 29 insertions, 9 deletions
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) {
546 cmd->viewangles[0] = f.x; 546 cmd->viewangles[0] = f.x;
547 cmd->viewangles[1] = f.y; 547 cmd->viewangles[1] = f.y;
548 cmd->viewangles[2] = f.z; 548 cmd->viewangles[2] = f.z;
549 cmd->forwardmove = 0.0f; 549 // Freeze the rendered view explicitly: CInput may not push the modified
550 cmd->sidemove = 0.0f; 550 // command view back to the engine if the client mode returns false.
551 cmd->upmove = 0.0f; 551 if (g_iface.engine) {
552 cmd->buttons = 0; 552 QAngle set = f;
553 using SetViewFn = void (*)(void *, QAngle *);
554 vfunc<SetViewFn>(g_iface.engine, 20)(g_iface.engine, &set);
555 }
556 if (gui_bind_capture_active()) {
557 // Bind capture must not move/act in the game while keys are sampled.
558 cmd->forwardmove = 0.0f;
559 cmd->sidemove = 0.0f;
560 cmd->upmove = 0.0f;
561 cmd->buttons = 0;
562 } else {
563 // Movement is allowed while the GUI is open, but not look/attack/use.
564 cmd->buttons &= (IN_JUMP | IN_DUCK);
565 }
553 cmd->impulse = 0; 566 cmd->impulse = 0;
554 cmd->weaponselect = 0; 567 cmd->weaponselect = 0;
555 cmd->weaponsubtype = 0; 568 cmd->weaponsubtype = 0;
@@ -670,12 +683,19 @@ void set_silent_restore(const QAngle &angles) {
670static void hkdFrameStageNotify(void *self, int stage) { 683static void hkdFrameStageNotify(void *self, int stage) {
671 if (oFrameStageNotify) 684 if (oFrameStageNotify)
672 oFrameStageNotify(self, stage); 685 oFrameStageNotify(self, stage);
673 if (stage == 5 && g_silent_restore_pending) { 686 if (stage == 5) {
674 g_silent_restore_pending = false; 687 if (g_silent_restore_pending) {
675 if (g_iface.engine) { 688 g_silent_restore_pending = false;
676 QAngle a = g_silent_restore_angles; 689 if (g_iface.engine) {
690 QAngle a = g_silent_restore_angles;
691 using SetViewFn = void (*)(void *, QAngle *);
692 vfunc<SetViewFn>(g_iface.engine, 20)(g_iface.engine, &a);
693 }
694 }
695 if (gui_is_open() && g_iface.engine) {
696 QAngle f = gui_frozen_view();
677 using SetViewFn = void (*)(void *, QAngle *); 697 using SetViewFn = void (*)(void *, QAngle *);
678 vfunc<SetViewFn>(g_iface.engine, 20)(g_iface.engine, &a); 698 vfunc<SetViewFn>(g_iface.engine, 20)(g_iface.engine, &f);
679 } 699 }
680 } 700 }
681} 701}