return;
// release mouse grab while loading
if (!vid.fullscreen)
- VID_GrabMouse(false);
+ VID_SetMouse(false, false, false);
CHECKGLERROR
qglViewport(0, 0, vid.width, vid.height);CHECKGLERROR
//qglDisable(GL_SCISSOR_TEST);CHECKGLERROR
{
double rendertime1;
float conwidth, conheight;
- qboolean grabmouse;
if (!scr_initialized || !con_initialized)
return; // not initialized yet
else
cl_updatescreen_quality = 1;
- if (key_consoleactive)
- grabmouse = false;
+ if (!vid_activewindow)
+ VID_SetMouse(false, false, false);
+ else if (key_consoleactive)
+ VID_SetMouse(vid.fullscreen, false, false);
else if (key_dest == key_menu_grabbed)
- grabmouse = true;
+ VID_SetMouse(true, !in_client_mouse, true);
else if (key_dest == key_menu)
- grabmouse = !in_client_mouse;
- else if (key_dest == key_game)
- grabmouse = vid_mouse.integer && !cls.demoplayback && !cl.csqc_wantsmousemove;
+ VID_SetMouse(vid.fullscreen, !in_client_mouse, true);
else
- grabmouse = false;
- vid.mouseaim = grabmouse;
- if (vid.fullscreen)
- grabmouse = true;
- if (!vid_activewindow)
- grabmouse = false;
-
- VID_GrabMouse(grabmouse);
+ VID_SetMouse(vid.fullscreen || (vid_mouse.integer && !cls.demoplayback && !cl.csqc_wantsmousemove), vid_mouse.integer && !cls.demoplayback && !cl.csqc_wantsmousemove, true);
VID_Finish();
}
qboolean userefreshrate;
int stereobuffer;
int samples;
-
- // these are used for state tracking
- qboolean mouseaim;
} viddef_t;
// global video state
// (called from various shutdown/deactivation functions)
void VID_RestoreSystemGamma(void);
-void VID_GrabMouse (qboolean grab);
+void VID_SetMouse (qboolean fullscreengrab, qboolean relative, qboolean hidecursor);
void VID_Finish (void);
void VID_Restart_f(void);
static qboolean multithreadedgl;
static qboolean mouse_avail = true;
static qboolean vid_usingmouse = false;
+static qboolean vid_usinghidecursor = false;
static qboolean vid_usingnoaccel = false;
static qboolean vid_isfullscreen = false;
*height = scr_height;
}
-void VID_GrabMouse(qboolean grab)
+void VID_SetMouse(qboolean fullscreengrab, qboolean relative, qboolean hidecursor)
{
- if (grab)
+ if (!mouse_avail || !window)
+ fullscreengrab = relative = hidecursor = false;
+
+ if (relative)
{
if(vid_usingmouse && (vid_usingnoaccel != !!apple_mouse_noaccel.integer))
- VID_GrabMouse(false); // ungrab first!
- if (!vid_usingmouse && mouse_avail && window)
+ VID_SetMouse(false, false, false); // ungrab first!
+ if (!vid_usingmouse)
{
Rect winBounds;
CGPoint winCenter;
SelectWindow(window);
- CGDisplayHideCursor(CGMainDisplayID());
// Put the mouse cursor at the center of the window
GetWindowBounds (window, kWindowContentRgn, &winBounds);
}
CGAssociateMouseAndMouseCursorPosition(true);
- CGDisplayShowCursor(CGMainDisplayID());
vid_usingmouse = false;
}
}
+
+ if (vid_usinghidecursor != hidecursor)
+ {
+ vid_usinghidecursor = hidecursor;
+ if (hidecursor)
+ CGDisplayHideCursor(CGMainDisplayID());
+ else
+ CGDisplayShowCursor(CGMainDisplayID());
+ }
}
#define GAMMA_TABLE_SIZE 256
if (context == NULL && window == NULL)
return;
- VID_GrabMouse(false);
+ VID_SetMouse(false, false, false);
VID_RestoreSystemGamma();
if (context != NULL)
multithreadedgl = false;
vid_isfullscreen = fullscreen;
vid_usingmouse = false;
+ vid_usinghidecursor = false;
vid_hidden = false;
vid_activewindow = true;
sound_active = true;
GetEventParameter(theEvent, kEventParamMouseDelta, typeHIPoint, NULL, sizeof(deltaPos), NULL, &deltaPos);
GetEventParameter(theEvent, kEventParamWindowMouseLocation, typeHIPoint, NULL, sizeof(windowPos), NULL, &windowPos);
- if (vid.mouseaim)
+ if (vid_usingmouse)
{
in_mouse_x += deltaPos.x;
in_mouse_y += deltaPos.y;
static qboolean mouse_avail = true;
+static qboolean vid_usingmousegrab = false;
static qboolean vid_usingmouse = false;
+static qboolean vid_usinghidecursor = false;
static qboolean vid_usingvsync = false;
static qboolean vid_usevsync = false;
static qboolean vid_x11_hardwaregammasupported = false;
return cursor;
}
-void VID_GrabMouse(qboolean grab)
+void VID_SetMouse(qboolean fullscreengrab, qboolean relative, qboolean hidecursor)
{
qboolean usedgamouse;
- if (!vidx11_display)
+
+ if (!vidx11_display || !win)
return;
- usedgamouse = grab && vid.mouseaim && vid_dgamouse.integer;
+
+ if (!mouse_avail)
+ fullscreengrab = relative = hidecursor = false;
+
+ usedgamouse = relative && vid_dgamouse.integer;
#if !defined(__APPLE__) && !defined(SUNOS)
if (!vid_x11_dgasupported)
usedgamouse = false;
+ if (fullscreengrab && vid_usingmouse && (vid_usingdgamouse != usedgamouse))
+ VID_SetMouse(false, false, false); // ungrab first!
#endif
- if (grab)
+
+ if (vid_usingmousegrab != fullscreengrab)
{
-#if !defined(__APPLE__) && !defined(SUNOS)
- if(vid_usingmouse && (vid_usingdgamouse != usedgamouse))
- VID_GrabMouse(false); // ungrab first!
-#endif
- if (!vid_usingmouse && mouse_avail && win)
+ vid_usingmousegrab = fullscreengrab;
+ cl_ignoremousemoves = 2;
+ if (fullscreengrab)
+ {
+ XGrabPointer(vidx11_display, win, True, 0, GrabModeAsync, GrabModeAsync, win, None, CurrentTime);
+ if (vid_grabkeyboard.integer || vid_isfullscreen)
+ XGrabKeyboard(vidx11_display, win, False, GrabModeAsync, GrabModeAsync, CurrentTime);
+ }
+ else
+ {
+ XUngrabPointer(vidx11_display, CurrentTime);
+ XUngrabKeyboard(vidx11_display, CurrentTime);
+ }
+ }
+
+ if (relative)
+ {
+ if (!vid_usingmouse)
{
XWindowAttributes attribs_1;
XSetWindowAttributes attribs_2;
attribs_2.event_mask = attribs_1.your_event_mask | KEY_MASK | MOUSE_MASK;
XChangeWindowAttributes(vidx11_display, win, CWEventMask, &attribs_2);
- // inviso cursor
- XDefineCursor(vidx11_display, win, CreateNullCursor(vidx11_display, win));
-
- XGrabPointer(vidx11_display, win, True, 0, GrabModeAsync, GrabModeAsync, win, None, CurrentTime);
-
#if !defined(__APPLE__) && !defined(SUNOS)
vid_usingdgamouse = usedgamouse;
if (usedgamouse)
#endif
XWarpPointer(vidx11_display, None, win, 0, 0, 0, 0, vid.width / 2, vid.height / 2);
- if (vid_grabkeyboard.integer || vid_isfullscreen)
- XGrabKeyboard(vidx11_display, win, False, GrabModeAsync, GrabModeAsync, CurrentTime);
-
cl_ignoremousemoves = 2;
vid_usingmouse = true;
}
XF86DGADirectVideo(vidx11_display, DefaultScreen(vidx11_display), 0);
vid_usingdgamouse = false;
#endif
-
- XUngrabPointer(vidx11_display, CurrentTime);
- XUngrabKeyboard(vidx11_display, CurrentTime);
-
- // inviso cursor
- if (win)
- XUndefineCursor(vidx11_display, win);
-
cl_ignoremousemoves = 2;
vid_usingmouse = false;
}
}
+
+ if (vid_usinghidecursor != hidecursor)
+ {
+ vid_usinghidecursor = hidecursor;
+ if (hidecursor)
+ XDefineCursor(vidx11_display, win, CreateNullCursor(vidx11_display, win));
+ else
+ XUndefineCursor(vidx11_display, win);
+ }
}
static keynum_t buttonremap[18] =
case MotionNotify:
// mouse moved
- if (vid.mouseaim)
+ if (vid_usingmouse)
{
#if !defined(__APPLE__) && !defined(SUNOS)
if (vid_usingdgamouse)
if (!ctx || !vidx11_display)
return;
- VID_GrabMouse(false);
+ VID_SetMouse(false, false, false);
VID_RestoreSystemGamma();
// FIXME: glXDestroyContext here?
// COMMANDLINEOPTION: MacOSX GLX: -novideosync disables GLX_SGI_swap_control
gl_videosyncavailable = GL_CheckExtension("GLX_SGI_swap_control", swapcontrolfuncs, "-novideosync", false);
+ vid_usingmousegrab = false;
vid_usingmouse = false;
+ vid_usinghidecursor = false;
vid_usingvsync = false;
vid_hidden = false;
vid_activewindow = true;
#endif
}
-void VID_GrabMouse (qboolean grab)
+void VID_SetMouse (qboolean fullscreengrab, qboolean relative, qboolean hidecursor)
{
}
cvar_t joy_sensitivityyaw = {0, "joy_sensitivityyaw", "-1", "movement multiplier"};
cvar_t joy_sensitivityroll = {0, "joy_sensitivityroll", "1", "movement multiplier"};
-static qboolean vid_usingmouse;
+static qboolean vid_usingmouse = false;
+static qboolean vid_usinghidecursor = false;
static qboolean vid_isfullscreen;
static int vid_numjoysticks = 0;
#define MAX_JOYSTICKS 8
return tbl_sdltoquake[ sdlkey ];
}
-void VID_GrabMouse(qboolean grab)
+void VID_SetMouse(qboolean fullscreengrab, qboolean relative, qboolean hidecursor)
{
- //SDL_WM_GrabInput( SDL_GRAB_OFF );
- //Con_Printf("< Turning off input-grabbing. --blub\n");
- if (grab)
+ if (vid_usingmouse != relative)
{
- if (!vid_usingmouse)
- {
- vid_usingmouse = true;
- cl_ignoremousemoves = 2;
- SDL_WM_GrabInput( SDL_GRAB_ON );
- SDL_ShowCursor( SDL_DISABLE );
- }
+ vid_usingmouse = relative;
+ cl_ignoremousemoves = 2;
+ SDL_WM_GrabInput( relative ? SDL_GRAB_ON : SDL_GRAB_OFF );
}
- else
+ if (vid_usinghidecursor != hidecursor)
{
- if (vid_usingmouse)
- {
- vid_usingmouse = false;
- cl_ignoremousemoves = 2;
- SDL_WM_GrabInput( SDL_GRAB_OFF );
- SDL_ShowCursor( SDL_ENABLE );
- }
+ vid_usinghidecursor = hidecursor;
+ SDL_ShowCursor( hidecursor ? SDL_DISABLE : SDL_ENABLE);
}
}
static int old_x = 0, old_y = 0;
static int stuck = 0;
int x, y;
- if (vid.mouseaim)
+ if (vid_usingmouse)
{
if(vid_stick_mouse.integer)
{
vid_hidden = false;
vid_activewindow = false;
vid_usingmouse = false;
+ vid_usinghidecursor = false;
SDL_WM_GrabInput(SDL_GRAB_OFF);
return true;
void VID_Shutdown (void)
{
- VID_GrabMouse(false);
+ VID_SetMouse(false, false, false);
VID_RestoreSystemGamma();
SDL_QuitSubSystem(SDL_INIT_VIDEO);
static qboolean vid_initialized = false;
static qboolean vid_wassuspended = false;
static qboolean vid_usingmouse = false;
+static qboolean vid_usinghidecursor = false;
static qboolean vid_usingvsync = false;
static qboolean vid_usevsync = false;
static HICON hIcon;
if (!fActive)
{
- VID_GrabMouse(false);
+ VID_SetMouse(false, false, false);
if (vid_isfullscreen)
{
ChangeDisplaySettings (NULL, 0);
case WM_MOVE:
window_x = (int) LOWORD(lParam);
window_y = (int) HIWORD(lParam);
- VID_GrabMouse(false);
+ VID_SetMouse(false, false, false);
break;
case WM_KEYDOWN:
//vid_menudrawfn = VID_MenuDraw;
//vid_menukeyfn = VID_MenuKey;
vid_usingmouse = false;
+ vid_usinghidecursor = false;
vid_usingvsync = false;
vid_hidden = false;
vid_initialized = true;
if(vid_initialized == false)
return;
- VID_GrabMouse(false);
+ VID_SetMouse(false, false, false);
VID_RestoreSystemGamma();
vid_initialized = false;
vid_isfullscreen = false;
}
-void VID_GrabMouse(qboolean grab)
+void VID_SetMouse(qboolean fullscreengrab, qboolean relative, qboolean hidecursor)
{
static qboolean restore_spi;
static int originalmouseparms[3];
if (!mouseinitialized)
return;
- if (grab)
+ if (relative)
{
if (!vid_usingmouse)
{
SetCapture (mainwindow);
ClipCursor (&window_rect);
}
- ShowCursor (false);
}
}
else
ClipCursor (NULL);
ReleaseCapture ();
}
- ShowCursor (true);
}
}
+
+ if (vid_usinghidecursor != hidecursor)
+ {
+ vid_usinghidecursor = hidecursor;
+ ShowCursor (!hidecursor);
+ }
}
in_windowmouse_x = current_pos.x - window_x;
in_windowmouse_y = current_pos.y - window_y;
- if (!vid.mouseaim)
+ if (!vid_usingmouse)
return;
#ifdef SUPPORTDIRECTX