static qboolean vid_wassuspended = false;
static qboolean vid_usingmouse = false;
static qboolean vid_usingvsync = false;
-static qboolean vid_usemouse = false;
static qboolean vid_usevsync = false;
static HICON hIcon;
//====================================
-static int window_x, window_y, window_width, window_height;
-static int window_center_x, window_center_y;
+static int window_x, window_y;
static void IN_Activate (qboolean grab);
static int originalmouseparms[3], newmouseparms[3] = {0, 0, 1};
static unsigned int uiWheelMessage;
-static qboolean mouseparmsvalid, mouseactivatetoggle;
+static qboolean mouseparmsvalid;
static qboolean dinput_acquired;
static unsigned int mstate_di;
static void IN_JoyMove (void);
static void IN_StartupMouse (void);
-/*
-================
-VID_UpdateWindowStatus
-================
-*/
-static void VID_UpdateWindowStatus (void)
-{
- window_center_x = window_x + window_width / 2;
- window_center_y = window_y + window_height / 2;
-
- if (mouseinitialized && vid_usingmouse && !dinput_acquired)
- {
- RECT window_rect;
- window_rect.left = window_x;
- window_rect.top = window_y;
- window_rect.right = window_x + window_width;
- window_rect.bottom = window_y + window_height;
- ClipCursor (&window_rect);
- }
-}
-
//====================================
-/*
-=================
-VID_GetWindowSize
-=================
-*/
-void VID_GetWindowSize (int *x, int *y, int *width, int *height)
-{
- *x = 0;
- *y = 0;
- *width = window_width;
- *height = window_height;
-}
-
-
void VID_Finish (void)
{
+ qboolean vid_usemouse;
+
vid_usevsync = vid_vsync.integer && !cls.timedemo && gl_videosyncavailable;
if (vid_usingvsync != vid_usevsync && gl_videosyncavailable)
{
vid_usemouse = true;
if (!vid_activewindow)
vid_usemouse = false;
- if (vid_usemouse)
- {
- if (!vid_usingmouse)
- {
- vid_usingmouse = true;
- IN_Activate (true);
- }
- }
- else
- {
- if (vid_usingmouse)
- {
- vid_usingmouse = false;
- IN_Activate (false);
- }
- }
+ IN_Activate(vid_usemouse);
if (r_render.integer && !vid_hidden)
{
if (!fActive)
{
- vid_usingmouse = false;
IN_Activate (false);
if (vid_isfullscreen)
{
case WM_MOVE:
window_x = (int) LOWORD(lParam);
window_y = (int) HIWORD(lParam);
- VID_UpdateWindowStatus ();
+ IN_Activate(false);
break;
case WM_KEYDOWN:
// x and y may be changed by WM_MOVE messages
window_x = CenterX;
window_y = CenterY;
- window_width = width;
- window_height = height;
rect.left += CenterX;
rect.right += CenterX;
rect.top += CenterY;
ShowWindow (mainwindow, SW_SHOWDEFAULT);
UpdateWindow (mainwindow);
- VID_UpdateWindowStatus ();
-
// now we try to make sure we get the focus on the mode switch, because
// sometimes in some systems we don't. We grab the foreground, then
// finish setting up, pump all our messages, and sleep for a little while
vid_isfullscreen = false;
}
-
-/*
-===========
-IN_Activate
-===========
-*/
static void IN_Activate (qboolean grab)
{
if (!mouseinitialized)
if (grab)
{
- mouseactivatetoggle = true;
- if (dinput && g_pMouse)
- {
- IDirectInputDevice_Acquire(g_pMouse);
- dinput_acquired = true;
- }
- else
+ if (!vid_usingmouse)
{
- RECT window_rect;
- window_rect.left = window_x;
- window_rect.top = window_y;
- window_rect.right = window_x + window_width;
- window_rect.bottom = window_y + window_height;
- if (mouseparmsvalid)
- restore_spi = SystemParametersInfo (SPI_SETMOUSE, 0, newmouseparms, 0);
- SetCursorPos (window_center_x, window_center_y);
- SetCapture (mainwindow);
- ClipCursor (&window_rect);
+ vid_usingmouse = true;
+ cl_ignoremousemove = true;
+ if (dinput && g_pMouse)
+ {
+ IDirectInputDevice_Acquire(g_pMouse);
+ dinput_acquired = true;
+ }
+ else
+ {
+ RECT window_rect;
+ window_rect.left = window_x;
+ window_rect.top = window_y;
+ window_rect.right = window_x + vid.width;
+ window_rect.bottom = window_y + vid.height;
+ if (mouseparmsvalid)
+ restore_spi = SystemParametersInfo (SPI_SETMOUSE, 0, newmouseparms, 0);
+ SetCursorPos ((window_x + vid.width / 2), (window_y + vid.height / 2));
+ SetCapture (mainwindow);
+ ClipCursor (&window_rect);
+ }
+ ShowCursor (false);
}
- vid_usingmouse = true;
- ShowCursor (false);
}
else
{
- mouseactivatetoggle = false;
- if (dinput_acquired)
- {
- IDirectInputDevice_Unacquire(g_pMouse);
- dinput_acquired = false;
- }
- else
+ if (vid_usingmouse)
{
- if (restore_spi)
- SystemParametersInfo (SPI_SETMOUSE, 0, originalmouseparms, 0);
- ClipCursor (NULL);
- ReleaseCapture ();
+ vid_usingmouse = false;
+ cl_ignoremousemove = true;
+ if (dinput_acquired)
+ {
+ IDirectInputDevice_Unacquire(g_pMouse);
+ dinput_acquired = false;
+ }
+ else
+ {
+ if (restore_spi)
+ SystemParametersInfo (SPI_SETMOUSE, 0, originalmouseparms, 0);
+ ClipCursor (NULL);
+ ReleaseCapture ();
+ }
+ ShowCursor (true);
}
- vid_usingmouse = false;
- ShowCursor (true);
}
}
}
mouse_buttons = 10;
-
-// if a fullscreen video mode was set before the mouse was initialized,
-// set the mouse state appropriately
- if (mouseactivatetoggle)
- IN_Activate (true);
}
else
{
GetCursorPos (¤t_pos);
- mx = current_pos.x - window_center_x;
- my = current_pos.y - window_center_y;
+ mx = current_pos.x - (window_x + vid.width / 2);
+ my = current_pos.y - (window_y + vid.height / 2);
in_mouse_x = mx;
in_mouse_y = my;
// if the mouse has moved, force it to the center, so there's room to move
if (mx || my)
- SetCursorPos (window_center_x, window_center_y);
+ SetCursorPos ((window_x + vid.width / 2), (window_y + vid.height / 2));
}
}