summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Howard2012-02-02 20:34:09 +0000
committerSimon Howard2012-02-02 20:34:09 +0000
commit41c2cd24e6079e0883c1fde4230864343c7a05e8 (patch)
tree811017bca7a38499e9a3d5a6ab64a1059539aa8f /src
parent33120be8fa37ddb48ab09c7de955bd54a070e4c1 (diff)
downloadchocolate-doom-41c2cd24e6079e0883c1fde4230864343c7a05e8.tar.gz
chocolate-doom-41c2cd24e6079e0883c1fde4230864343c7a05e8.tar.bz2
chocolate-doom-41c2cd24e6079e0883c1fde4230864343c7a05e8.zip
Only use the SDL mouse lag workaround on Windows - not all systems allow
the cursor to be changed. This fixes Chocolate Doom on AmigaOS (thanks Timo Sievänen). Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2483
Diffstat (limited to 'src')
-rw-r--r--src/i_video.c45
1 files changed, 36 insertions, 9 deletions
diff --git a/src/i_video.c b/src/i_video.c
index d671a228..895043da 100644
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -276,6 +276,37 @@ static void UpdateFocus(void)
screenvisible = (state & SDL_APPACTIVE) != 0;
}
+// Show or hide the mouse cursor. We have to use different techniques
+// depending on the OS.
+
+static void ShowCursor(boolean show)
+{
+ // On Windows, using SDL_ShowCursor() adds lag to the mouse input,
+ // so work around this by setting an invisible cursor instead. On
+ // other systems, it isn't possible to change the cursor, so this
+ // hack has to be Windows-only. (Thanks to entryway for this)
+
+#ifdef _WIN32
+ if (show)
+ {
+ SDL_SetCursor(cursors[1]);
+ }
+ else
+ {
+ SDL_SetCursor(cursors[0]);
+ }
+#else
+ SDL_ShowCursor(show);
+#endif
+
+ // When the cursor is hidden, grab the input.
+
+ if (!screensaver_mode)
+ {
+ SDL_WM_GrabInput(!show);
+ }
+}
+
static void LoadDiskImage(void)
{
patch_t *disk;
@@ -423,12 +454,10 @@ void I_ShutdownGraphics(void)
{
if (initialized)
{
- SDL_SetCursor(cursors[1]);
- SDL_ShowCursor(1);
- SDL_WM_GrabInput(SDL_GRAB_OFF);
+ ShowCursor(true);
SDL_QuitSubSystem(SDL_INIT_VIDEO);
-
+
initialized = false;
}
}
@@ -725,17 +754,15 @@ static void UpdateGrab(void)
{
// Hide the cursor in screensaver mode
- SDL_SetCursor(cursors[0]);
+ ShowCursor(false);
}
else if (grab && !currently_grabbed)
{
- SDL_SetCursor(cursors[0]);
- SDL_WM_GrabInput(SDL_GRAB_ON);
+ ShowCursor(false);
}
else if (!grab && currently_grabbed)
{
- SDL_SetCursor(cursors[1]);
- SDL_WM_GrabInput(SDL_GRAB_OFF);
+ ShowCursor(true);
}
currently_grabbed = grab;