#include "quakedef.h"
#include <windows.h>
#include <mmsystem.h>
+#ifdef SUPPORTDIRECTX
#include <dsound.h>
+#endif
#include "resource.h"
#include <commctrl.h>
+#ifdef SUPPORTDIRECTX
#include <dinput.h>
+#endif
extern HINSTANCE global_hInstance;
static void IN_Activate (qboolean grab);
static qboolean mouseinitialized;
-static qboolean dinput;
-
-// input code
+#ifdef SUPPORTDIRECTX
+static qboolean dinput;
#define DINPUT_BUFFERSIZE 16
#define iDirectInputCreate(a,b,c,d) pDirectInputCreate(a,b,c,d)
static HRESULT (WINAPI *pDirectInputCreate)(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUT * lplpDirectInput, LPUNKNOWN punkOuter);
+#endif
// LordHavoc: thanks to backslash for this support for mouse buttons 4 and 5
/* backslash :: imouse explorer buttons */
static int mouse_oldbuttonstate;
static unsigned int uiWheelMessage;
+#ifdef SUPPORTDIRECTX
static qboolean dinput_acquired;
static unsigned int mstate_di;
+#endif
// joystick defines and variables
// where should defines be moved?
static DWORD joy_flags;
static DWORD joy_numbuttons;
+#ifdef SUPPORTDIRECTX
static LPDIRECTINPUT g_pdi;
static LPDIRECTINPUTDEVICE g_pMouse;
+static HINSTANCE hInstDI;
+#endif
static JOYINFOEX ji;
-static HINSTANCE hInstDI;
-
// forward-referenced functions
static void IN_StartupJoystick (void);
static void Joy_AdvancedUpdate_f (void);
SwapBuffers(baseDC);
}
+ // make sure a context switch can happen every frame - Logitech drivers
+ // input drivers sometimes eat cpu time every 3 seconds or lag badly
+ // without this help
+ Sleep(0);
+
VID_UpdateGamma(false, 256);
}
GetKeyboardState (state);
// alt/ctrl/shift tend to produce funky ToAscii values,
// and if it's not a single character we don't know care about it
- charlength = ToAscii (wParam, lParam >> 16, state, (unsigned short *)asciichar, 0);
+ charlength = ToAscii (wParam, lParam >> 16, state, (LPWORD)asciichar, 0);
if (vkey == K_ALT || vkey == K_CTRL || vkey == K_SHIFT || charlength == 0)
asciichar[0] = 0;
else if( charlength == 2 ) {
case WM_SYSCOMMAND:
// prevent screensaver from occuring while the active window
+ // note: password-locked screensavers on Vista still work
if (vid_activewindow && ((wParam & 0xFFF0) == SC_SCREENSAVE || (wParam & 0xFFF0) == SC_MONITORPOWER))
- lRet = 0;; // note: password-locked screensavers on Vista still work
+ lRet = 0;
+ else
+ lRet = DefWindowProc (hWnd, uMsg, wParam, lParam);
break;
// this is complicated because Win32 seems to pack multiple mouse events into
if (wParam & MK_XBUTTON7)
temp |= 512;
+#ifdef SUPPORTDIRECTX
if (vid_usingmouse && !dinput_acquired)
+#else
+ if (vid_usingmouse)
+#endif
{
// perform button actions
int i;
// if stencil is enabled, ask for alpha too
if (bpp >= 32)
{
- pfd.cStencilBits = 8;
+ pfd.cRedBits = 8;
+ pfd.cGreenBits = 8;
+ pfd.cBlueBits = 8;
pfd.cAlphaBits = 8;
+ pfd.cDepthBits = 24;
+ pfd.cStencilBits = 8;
}
else
{
- pfd.cStencilBits = 0;
+ pfd.cRedBits = 5;
+ pfd.cGreenBits = 5;
+ pfd.cBlueBits = 5;
pfd.cAlphaBits = 0;
+ pfd.cDepthBits = 16;
+ pfd.cStencilBits = 0;
}
if (stereobuffer)
*a++ = WGL_BLUE_BITS_ARB;
*a++ = 8;
*a++ = WGL_ALPHA_BITS_ARB;
- *a++ = 1;
+ *a++ = 8;
*a++ = WGL_DEPTH_BITS_ARB;
*a++ = 24;
*a++ = WGL_STENCIL_BITS_ARB;
pixelformat = 0;
newpixelformat = 0;
- for (windowpass = 0;windowpass < 2;windowpass++)
+ // start out at the final windowpass if samples is 1 as it's the only feature we need extended pixel formats for
+ for (windowpass = samples == 1;windowpass < 2;windowpass++)
{
+ gl_extensions = "";
+ gl_platformextensions = "";
+
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)
{
if ((qwglGetExtensionsStringARB = (const char *(WINAPI *)(HDC hdc))GL_GetProcAddress("wglGetExtensionsStringARB")) == NULL)
Con_Print("wglGetExtensionsStringARB not found\n");
- gl_renderer = qglGetString(GL_RENDERER);
- gl_vendor = qglGetString(GL_VENDOR);
- gl_version = qglGetString(GL_VERSION);
- gl_extensions = qglGetString(GL_EXTENSIONS);
+ gl_renderer = (const char *)qglGetString(GL_RENDERER);
+ gl_vendor = (const char *)qglGetString(GL_VENDOR);
+ gl_version = (const char *)qglGetString(GL_VERSION);
+ gl_extensions = (const char *)qglGetString(GL_EXTENSIONS);
gl_platform = "WGL";
gl_platformextensions = "";
if (qwglGetExtensionsStringARB)
- gl_platformextensions = qwglGetExtensionsStringARB(baseDC);
+ gl_platformextensions = (const char *)qwglGetExtensionsStringARB(baseDC);
+
+ if (!gl_extensions)
+ gl_extensions = "";
+ if (!gl_platformextensions)
+ gl_platformextensions = "";
// now some nice Windows pain:
// we have created a window, we needed one to find out if there are
{
vid_usingmouse = true;
cl_ignoremousemoves = 2;
+#ifdef SUPPORTDIRECTX
if (dinput && g_pMouse)
{
IDirectInputDevice_Acquire(g_pMouse);
dinput_acquired = true;
}
else
+#endif
{
RECT window_rect;
window_rect.left = window_x;
{
vid_usingmouse = false;
cl_ignoremousemoves = 2;
+#ifdef SUPPORTDIRECTX
if (dinput_acquired)
{
IDirectInputDevice_Unacquire(g_pMouse);
dinput_acquired = false;
}
else
+#endif
{
// restore system mouseparms if we changed them
if (restore_spi)
}
+#ifdef SUPPORTDIRECTX
/*
===========
IN_InitDInput
return true;
}
+#endif
/*
mouseinitialized = true;
+#ifdef SUPPORTDIRECTX
// COMMANDLINEOPTION: Windows Input: -dinput enables DirectInput for mouse/joystick input
if (COM_CheckParm ("-dinput"))
dinput = IN_InitDInput ();
Con_Print("DirectInput initialized\n");
else
Con_Print("DirectInput not initialized\n");
+#endif
mouse_buttons = 10;
}
*/
static void IN_MouseMove (void)
{
- int i, mx, my;
+ int mx, my;
POINT current_pos;
if (!vid_usingmouse)
return;
}
+#ifdef SUPPORTDIRECTX
if (dinput_acquired)
{
+ int i;
DIDEVICEOBJECTDATA od;
DWORD dwElements;
HRESULT hr;
in_mouse_y = my;
}
else
+#endif
{
GetCursorPos (¤t_pos);
mx = current_pos.x - (window_x + vid.width / 2);
{
IN_Activate (false);
+#ifdef SUPPORTDIRECTX
if (g_pMouse)
IDirectInputDevice_Release(g_pMouse);
g_pMouse = NULL;
if (g_pdi)
IDirectInput_Release(g_pdi);
g_pdi = NULL;
+#endif
}