#include <commctrl.h>
#include <dinput.h>
-extern void S_BlockSound (void);
-extern void S_UnblockSound (void);
extern HINSTANCE global_hInstance;
static int mouse_buttons;
static int mouse_oldbuttonstate;
-static qboolean restore_spi;
-static int originalmouseparms[3], newmouseparms[3] = {0, 0, 0};
-
static unsigned int uiWheelMessage;
-static qboolean mouseparmsvalid;
static qboolean dinput_acquired;
static unsigned int mstate_di;
// handle the mouse state when windowed if that's changed
vid_usemouse = false;
- if (allowmousegrab && vid_mouse.integer && !key_consoleactive && !cls.demoplayback)
+ if (allowmousegrab && vid_mouse.integer && !key_consoleactive && (key_dest != key_game || !cls.demoplayback))
vid_usemouse = true;
if (vid_isfullscreen)
vid_usemouse = true;
if (r_render.integer && !vid_hidden)
{
+ CHECKGLERROR
if (r_speeds.integer || gl_finish.integer)
- qglFinish();
+ {
+ qglFinish();CHECKGLERROR
+ }
SwapBuffers(baseDC);
}
+
+ VID_UpdateGamma(false, 256);
}
//==========================================================================
*
****************************************************************************/
{
- static BOOL sound_active;
+ static qboolean sound_active = false; // initially blocked by Sys_InitConsole()
vid_activewindow = fActive;
vid_hidden = minimize;
while (PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE))
{
if (!GetMessage (&msg, NULL, 0, 0))
- Sys_Quit ();
+ Sys_Quit (1);
TranslateMessage (&msg);
DispatchMessage (&msg);
case WM_CLOSE:
if (MessageBox (mainwindow, "Are you sure you want to quit?", "Confirm Exit", MB_YESNO | MB_SETFOREGROUND | MB_ICONQUESTION) == IDYES)
- Sys_Quit ();
+ Sys_Quit (0);
break;
return lRet;
}
-int VID_SetGamma(unsigned short *ramps)
+int VID_SetGamma(unsigned short *ramps, int rampsize)
{
HDC hdc = GetDC (NULL);
int i = SetDeviceGammaRamp(hdc, ramps);
return i; // return success or failure
}
-int VID_GetGamma(unsigned short *ramps)
+int VID_GetGamma(unsigned short *ramps, int rampsize)
{
HDC hdc = GetDC (NULL);
int i = GetDeviceGammaRamp(hdc, ramps);
Con_Printf("Unable to LoadLibrary %s\n", name);
return false;
}
- strcpy(gl_driver, name);
+ strlcpy(gl_driver, name, sizeof(gl_driver));
return true;
}
IN_Init();
}
-int VID_InitMode (int fullscreen, int width, int height, int bpp, int refreshrate)
+int VID_InitMode (int fullscreen, int width, int height, int bpp, int refreshrate, int stereobuffer)
{
int i;
HDC hdc;
pfd.cAlphaBits = 0;
}
+ if (stereobuffer)
+ pfd.dwFlags |= PFD_STEREO;
+
gldrivername = "opengl32.dll";
// COMMANDLINEOPTION: Windows WGL: -gl_driver <drivername> selects a GL driver library, default is opengl32.dll, useful only for 3dfxogl.dll or 3dfxvgl.dll, if you don't know what this is for, you don't need it
i = COM_CheckParm("-gl_driver");
mainwindow = CreateWindowEx (ExWindowStyle, "DarkPlacesWindowClass", gamename, WindowStyle, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, NULL, NULL, global_hInstance, NULL);
if (!mainwindow)
{
- Con_Printf("CreateWindowEx(%d, %s, %s, %d, %d, %d, %d, %d, %p, %p, %d, %p) failed\n", ExWindowStyle, "DarkPlacesWindowClass", gamename, WindowStyle, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, NULL, NULL, global_hInstance, NULL);
+ Con_Printf("CreateWindowEx(%d, %s, %s, %d, %d, %d, %d, %d, %p, %p, %d, %p) failed\n", (int)ExWindowStyle, "DarkPlacesWindowClass", gamename, (int)WindowStyle, (int)(rect.left), (int)(rect.top), (int)(rect.right - rect.left), (int)(rect.bottom - rect.top), NULL, NULL, (int)global_hInstance, NULL);
VID_Shutdown();
return false;
}
if ((pixelformat = ChoosePixelFormat(baseDC, &pfd)) == 0)
{
VID_Shutdown();
- Con_Printf("ChoosePixelFormat(%d, %p) failed\n", baseDC, &pfd);
+ Con_Printf("ChoosePixelFormat(%d, %p) failed\n", (int)baseDC, &pfd);
return false;
}
if (SetPixelFormat(baseDC, pixelformat, &pfd) == false)
{
VID_Shutdown();
- Con_Printf("SetPixelFormat(%d, %d, %p) failed\n", baseDC, pixelformat, &pfd);
+ Con_Printf("SetPixelFormat(%d, %d, %p) failed\n", (int)baseDC, pixelformat, &pfd);
return false;
}
if (!qwglMakeCurrent(baseDC, baseRC))
{
VID_Shutdown();
- Con_Printf("wglMakeCurrent(%d, %d) failed\n", baseDC, baseRC);
+ Con_Printf("wglMakeCurrent(%d, %d) failed\n", (int)baseDC, (int)baseRC);
return false;
}
static void IN_Activate (qboolean grab)
{
+ static qboolean restore_spi;
+ static int originalmouseparms[3];
+
if (!mouseinitialized)
return;
window_rect.top = window_y;
window_rect.right = window_x + vid.width;
window_rect.bottom = window_y + vid.height;
- if (mouseparmsvalid)
+
+ // change mouse settings to turn off acceleration
+// COMMANDLINEOPTION: Windows GDI Input: -noforcemparms disables setting of mouse parameters (not used with -dinput, windows only)
+ if (!COM_CheckParm ("-noforcemparms") && SystemParametersInfo (SPI_GETMOUSE, 0, originalmouseparms, 0))
+ {
+ int newmouseparms[3];
+ newmouseparms[0] = 0; // threshold to double movement (only if accel level is >= 1)
+ newmouseparms[1] = 0; // threshold to quadruple movement (only if accel level is >= 2)
+ newmouseparms[2] = 0; // maximum level of acceleration (0 = off)
restore_spi = SystemParametersInfo (SPI_SETMOUSE, 0, newmouseparms, 0);
+ }
+ else
+ restore_spi = false;
SetCursorPos ((window_x + vid.width / 2), (window_y + vid.height / 2));
+
SetCapture (mainwindow);
ClipCursor (&window_rect);
}
}
else
{
+ // restore system mouseparms if we changed them
if (restore_spi)
SystemParametersInfo (SPI_SETMOUSE, 0, originalmouseparms, 0);
+ restore_spi = false;
ClipCursor (NULL);
ReleaseCapture ();
}
*/
static void IN_StartupMouse (void)
{
- if (COM_CheckParm ("-nomouse") || COM_CheckParm("-safe"))
+ if (COM_CheckParm ("-nomouse"))
return;
mouseinitialized = true;
else
Con_Print("DirectInput not initialized\n");
- mouseparmsvalid = SystemParametersInfo (SPI_GETMOUSE, 0, originalmouseparms, 0);
-
- if (mouseparmsvalid)
- {
-// COMMANDLINEOPTION: Windows GDI Input: -noforcemspd disables setting of mouse speed (not used with -dinput, windows only)
- if ( COM_CheckParm ("-noforcemspd") )
- newmouseparms[2] = originalmouseparms[2];
-
-// COMMANDLINEOPTION: Windows GDI Input: -noforcemaccel disables setting of mouse acceleration (not used with -dinput, windows only)
- if ( COM_CheckParm ("-noforcemaccel") )
- {
- newmouseparms[0] = originalmouseparms[0];
- newmouseparms[1] = originalmouseparms[1];
- }
-
-// COMMANDLINEOPTION: Windows GDI Input: -noforcemparms disables setting of mouse parameters (not used with -dinput, windows only)
- if ( COM_CheckParm ("-noforcemparms") )
- {
- newmouseparms[0] = originalmouseparms[0];
- newmouseparms[1] = originalmouseparms[1];
- newmouseparms[2] = originalmouseparms[2];
- }
- }
-
mouse_buttons = 10;
}
// abort startup if user requests no joystick
// COMMANDLINEOPTION: Windows Input: -nojoy disables joystick support, may be a small speed increase
- if (COM_CheckParm ("-nojoy") || COM_CheckParm("-safe"))
+ if (COM_CheckParm ("-nojoy"))
return;
// verify joystick driver is present
else
speed = 1;
// LordHavoc: viewzoom affects sensitivity for sniping
- aspeed = speed * host_realframetime * cl.viewzoom;
+ aspeed = speed * cl.realframetime * cl.viewzoom;
// loop through the axes
for (i = 0; i < JOY_MAX_AXES; i++)