From 41c2cd24e6079e0883c1fde4230864343c7a05e8 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Thu, 2 Feb 2012 20:34:09 +0000 Subject: 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 --- src/i_video.c | 45 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 9 deletions(-) (limited to 'src') 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; -- cgit v1.2.3