foxygit / doom Log in
commit 88dd6235bcf78c545796795ac6a1f0732e4fab9e
Author:     Simon Howard <fraggle@gmail.com>
AuthorDate: Thu Oct 9 19:23:50 2008 +0000
Commit:     Simon Howard <fraggle@gmail.com>
CommitDate: Thu Oct 9 19:23:50 2008 +0000

    Add mouse grab callback for Hexen.

    Subversion-branch: /branches/raven-branch
    Subversion-revision: 1347
---
 src/hexen/h2_main.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/src/hexen/h2_main.c b/src/hexen/h2_main.c
index 6c7e4aa4..aadf647c 100644
--- a/src/hexen/h2_main.c
+++ b/src/hexen/h2_main.c
@@ -180,6 +180,24 @@ void D_BindVariables(void)
     }
 }

+//
+// D_GrabMouseCallback
+//
+// Called to determine whether to grab the mouse pointer
+//
+
+static boolean D_GrabMouseCallback(void)
+{
+    // when menu is active or game is paused, release the mouse
+
+    if (MenuActive || paused)
+        return false;
+
+    // only grab mouse when playing levels (but not demos)
+
+    return (gamestate == GS_LEVEL) && !demoplayback;
+}
+
 //==========================================================================
 //
 // H2_Main
@@ -518,6 +536,8 @@ void H2_GameLoop(void)
         debugfile = fopen(filename, "w");
     }
     I_InitGraphics();
+    I_SetGrabMouseCallback(D_GrabMouseCallback);
+
     while (1)
     {
         // Frame syncronous IO operations