2 Copyright (C) 1996-1997 Id Software, Inc.
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 // gl_vidnt.c -- NT GL vid component
28 extern void S_BlockSound (void);
29 extern HINSTANCE global_hInstance;
33 #define WM_MOUSEWHEEL 0x020A
36 // Tell startup code that we have a client
37 int cl_available = true;
39 int (WINAPI *qwglChoosePixelFormat)(HDC, CONST PIXELFORMATDESCRIPTOR *);
40 int (WINAPI *qwglDescribePixelFormat)(HDC, int, UINT, LPPIXELFORMATDESCRIPTOR);
41 //int (WINAPI *qwglGetPixelFormat)(HDC);
42 BOOL (WINAPI *qwglSetPixelFormat)(HDC, int, CONST PIXELFORMATDESCRIPTOR *);
43 BOOL (WINAPI *qwglSwapBuffers)(HDC);
44 HGLRC (WINAPI *qwglCreateContext)(HDC);
45 BOOL (WINAPI *qwglDeleteContext)(HGLRC);
46 HGLRC (WINAPI *qwglGetCurrentContext)(VOID);
47 HDC (WINAPI *qwglGetCurrentDC)(VOID);
48 PROC (WINAPI *qwglGetProcAddress)(LPCSTR);
49 BOOL (WINAPI *qwglMakeCurrent)(HDC, HGLRC);
50 BOOL (WINAPI *qwglSwapIntervalEXT)(int interval);
51 const char *(WINAPI *qwglGetExtensionsStringARB)(HDC hdc);
53 static dllfunction_t wglfuncs[] =
55 {"wglChoosePixelFormat", (void **) &qwglChoosePixelFormat},
56 {"wglDescribePixelFormat", (void **) &qwglDescribePixelFormat},
57 // {"wglGetPixelFormat", (void **) &qwglGetPixelFormat},
58 {"wglSetPixelFormat", (void **) &qwglSetPixelFormat},
59 {"wglSwapBuffers", (void **) &qwglSwapBuffers},
60 {"wglCreateContext", (void **) &qwglCreateContext},
61 {"wglDeleteContext", (void **) &qwglDeleteContext},
62 {"wglGetProcAddress", (void **) &qwglGetProcAddress},
63 {"wglMakeCurrent", (void **) &qwglMakeCurrent},
64 {"wglGetCurrentContext", (void **) &qwglGetCurrentContext},
65 {"wglGetCurrentDC", (void **) &qwglGetCurrentDC},
69 static dllfunction_t wglswapintervalfuncs[] =
71 {"wglSwapIntervalEXT", (void **) &qwglSwapIntervalEXT},
75 qboolean scr_skipupdate;
77 static DEVMODE gdevmode;
78 static qboolean vid_initialized = false;
79 static qboolean vid_wassuspended = false;
80 static int vid_usingmouse;
81 extern qboolean mouseactive; // from in_win.c
86 //HWND WINAPI InitializeWindow (HINSTANCE hInstance, int nCmdShow);
88 static int vid_isfullscreen;
90 //void VID_MenuDraw (void);
91 //void VID_MenuKey (int key);
93 //LONG WINAPI MainWndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
94 //void AppActivate(BOOL fActive, BOOL minimize);
95 //void ClearAllStates (void);
96 //void VID_UpdateWindowStatus (void);
98 //====================================
100 int window_x, window_y, window_width, window_height;
101 int window_center_x, window_center_y;
103 void IN_ShowMouse (void);
104 void IN_DeactivateMouse (void);
105 void IN_HideMouse (void);
106 void IN_ActivateMouse (void);
107 void IN_MouseEvent (int mstate);
108 void IN_UpdateClipCursor (void);
110 qboolean mouseinitialized;
111 static qboolean dinput;
117 #define DINPUT_BUFFERSIZE 16
118 #define iDirectInputCreate(a,b,c,d) pDirectInputCreate(a,b,c,d)
120 HRESULT (WINAPI *pDirectInputCreate)(HINSTANCE hinst, DWORD dwVersion,
121 LPDIRECTINPUT * lplpDirectInput, LPUNKNOWN punkOuter);
123 // LordHavoc: thanks to backslash for this support for mouse buttons 4 and 5
124 /* backslash :: imouse explorer buttons */
125 /* These are #ifdefed out for non-Win2K in the February 2001 version of
126 MS's platform SDK, but we need them for compilation. . . */
127 #ifndef WM_XBUTTONDOWN
128 #define WM_XBUTTONDOWN 0x020B
129 #define WM_XBUTTONUP 0x020C
132 #define MK_XBUTTON1 0x0020
133 #define MK_XBUTTON2 0x0040
134 // LordHavoc: lets hope this allows more buttons in the future...
135 #define MK_XBUTTON3 0x0080
136 #define MK_XBUTTON4 0x0100
137 #define MK_XBUTTON5 0x0200
138 #define MK_XBUTTON6 0x0400
139 #define MK_XBUTTON7 0x0800
145 int mouse_oldbuttonstate;
147 int mouse_x, mouse_y, old_mouse_x, old_mouse_y, mx_accum, my_accum;
149 static qboolean restore_spi;
150 static int originalmouseparms[3], newmouseparms[3] = {0, 0, 1};
152 unsigned int uiWheelMessage;
153 qboolean mouseactive;
154 //qboolean mouseinitialized;
155 static qboolean mouseparmsvalid, mouseactivatetoggle;
156 static qboolean mouseshowtoggle = 1;
157 static qboolean dinput_acquired;
159 static unsigned int mstate_di;
161 // joystick defines and variables
162 // where should defines be moved?
163 #define JOY_ABSOLUTE_AXIS 0x00000000 // control like a joystick
164 #define JOY_RELATIVE_AXIS 0x00000010 // control like a mouse, spinner, trackball
165 #define JOY_MAX_AXES 6 // X, Y, Z, R, U, V
175 AxisNada = 0, AxisForward, AxisLook, AxisSide, AxisTurn
178 DWORD dwAxisFlags[JOY_MAX_AXES] =
180 JOY_RETURNX, JOY_RETURNY, JOY_RETURNZ, JOY_RETURNR, JOY_RETURNU, JOY_RETURNV
183 DWORD dwAxisMap[JOY_MAX_AXES];
184 DWORD dwControlMap[JOY_MAX_AXES];
185 PDWORD pdwRawValue[JOY_MAX_AXES];
187 // none of these cvars are saved over a session
188 // this means that advanced controller configuration needs to be executed
189 // each time. this avoids any problems with getting back to a default usage
190 // or when changing from one controller to another. this way at least something
192 cvar_t in_joystick = {CVAR_SAVE, "joystick","0"};
193 cvar_t joy_name = {0, "joyname", "joystick"};
194 cvar_t joy_advanced = {0, "joyadvanced", "0"};
195 cvar_t joy_advaxisx = {0, "joyadvaxisx", "0"};
196 cvar_t joy_advaxisy = {0, "joyadvaxisy", "0"};
197 cvar_t joy_advaxisz = {0, "joyadvaxisz", "0"};
198 cvar_t joy_advaxisr = {0, "joyadvaxisr", "0"};
199 cvar_t joy_advaxisu = {0, "joyadvaxisu", "0"};
200 cvar_t joy_advaxisv = {0, "joyadvaxisv", "0"};
201 cvar_t joy_forwardthreshold = {0, "joyforwardthreshold", "0.15"};
202 cvar_t joy_sidethreshold = {0, "joysidethreshold", "0.15"};
203 cvar_t joy_pitchthreshold = {0, "joypitchthreshold", "0.15"};
204 cvar_t joy_yawthreshold = {0, "joyyawthreshold", "0.15"};
205 cvar_t joy_forwardsensitivity = {0, "joyforwardsensitivity", "-1.0"};
206 cvar_t joy_sidesensitivity = {0, "joysidesensitivity", "-1.0"};
207 cvar_t joy_pitchsensitivity = {0, "joypitchsensitivity", "1.0"};
208 cvar_t joy_yawsensitivity = {0, "joyyawsensitivity", "-1.0"};
209 cvar_t joy_wwhack1 = {0, "joywwhack1", "0.0"};
210 cvar_t joy_wwhack2 = {0, "joywwhack2", "0.0"};
212 qboolean joy_avail, joy_advancedinit, joy_haspov;
213 DWORD joy_oldbuttonstate, joy_oldpovstate;
217 DWORD joy_numbuttons;
219 static LPDIRECTINPUT g_pdi;
220 static LPDIRECTINPUTDEVICE g_pMouse;
224 static HINSTANCE hInstDI;
226 //static qboolean dinput;
228 typedef struct MYDATA {
229 LONG lX; // X axis goes here
230 LONG lY; // Y axis goes here
231 LONG lZ; // Z axis goes here
232 BYTE bButtonA; // One button goes here
233 BYTE bButtonB; // Another button goes here
234 BYTE bButtonC; // Another button goes here
235 BYTE bButtonD; // Another button goes here
238 static DIOBJECTDATAFORMAT rgodf[] = {
239 { &GUID_XAxis, FIELD_OFFSET(MYDATA, lX), DIDFT_AXIS | DIDFT_ANYINSTANCE, 0,},
240 { &GUID_YAxis, FIELD_OFFSET(MYDATA, lY), DIDFT_AXIS | DIDFT_ANYINSTANCE, 0,},
241 { &GUID_ZAxis, FIELD_OFFSET(MYDATA, lZ), 0x80000000 | DIDFT_AXIS | DIDFT_ANYINSTANCE, 0,},
242 { 0, FIELD_OFFSET(MYDATA, bButtonA), DIDFT_BUTTON | DIDFT_ANYINSTANCE, 0,},
243 { 0, FIELD_OFFSET(MYDATA, bButtonB), DIDFT_BUTTON | DIDFT_ANYINSTANCE, 0,},
244 { 0, FIELD_OFFSET(MYDATA, bButtonC), 0x80000000 | DIDFT_BUTTON | DIDFT_ANYINSTANCE, 0,},
245 { 0, FIELD_OFFSET(MYDATA, bButtonD), 0x80000000 | DIDFT_BUTTON | DIDFT_ANYINSTANCE, 0,},
248 #define NUM_OBJECTS (sizeof(rgodf) / sizeof(rgodf[0]))
250 static DIDATAFORMAT df = {
251 sizeof(DIDATAFORMAT), // this structure
252 sizeof(DIOBJECTDATAFORMAT), // size of object data format
253 DIDF_RELAXIS, // absolute axis coordinates
254 sizeof(MYDATA), // device data size
255 NUM_OBJECTS, // number of objects
256 rgodf, // and here they are
259 // forward-referenced functions
260 void IN_StartupJoystick (void);
261 void Joy_AdvancedUpdate_f (void);
262 void IN_JoyMove (usercmd_t *cmd);
263 void IN_StartupMouse (void);
267 VID_UpdateWindowStatus
270 void VID_UpdateWindowStatus (void)
272 window_center_x = window_x + window_width / 2;
273 window_center_y = window_y + window_height / 2;
275 if (mouseinitialized && mouseactive && !dinput)
278 window_rect.left = window_x;
279 window_rect.top = window_y;
280 window_rect.right = window_x + window_width;
281 window_rect.bottom = window_y + window_height;
282 ClipCursor (&window_rect);
287 //====================================
294 void VID_GetWindowSize (int *x, int *y, int *width, int *height)
298 *width = window_width;
299 *height = window_height;
303 void VID_Finish (void)
307 if (r_render.integer && !scr_skipupdate)
310 hdc = GetDC(mainwindow);
312 ReleaseDC(mainwindow, hdc);
315 // handle the mouse state when windowed if that's changed
316 vid_usemouse = false;
317 if (vid_mouse.integer && !key_consoleactive)
319 if (vid_isfullscreen)
321 if (!vid_activewindow)
322 vid_usemouse = false;
327 vid_usingmouse = true;
336 vid_usingmouse = false;
337 IN_DeactivateMouse ();
343 //==========================================================================
348 qbyte scantokey[128] =
350 // 0 1 2 3 4 5 6 7 8 9 A B C D E F
351 0 ,27 ,'1' ,'2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' ,'0' ,'-' ,'=' ,K_BACKSPACE,9 ,//0
352 'q' ,'w' ,'e' ,'r' ,'t' ,'y' ,'u' ,'i' ,'o' ,'p' ,'[' ,']' ,13 ,K_CTRL ,'a' ,'s' ,//1
353 'd' ,'f' ,'g' ,'h' ,'j' ,'k' ,'l' ,';' ,'\'' ,'`' ,K_SHIFT ,'\\' ,'z' ,'x' ,'c' ,'v' ,//2
354 'b' ,'n' ,'m' ,',' ,'.' ,'/' ,K_SHIFT,'*' ,K_ALT ,' ' ,0 ,K_F1 ,K_F2 ,K_F3 ,K_F4 ,K_F5 ,//3
355 K_F6 ,K_F7 ,K_F8 ,K_F9 ,K_F10,K_PAUSE,0 ,K_HOME,K_UPARROW,K_PGUP,K_KP_MINUS,K_LEFTARROW,K_KP_5,K_RIGHTARROW,K_KP_PLUS ,K_END,//4
356 K_DOWNARROW,K_PGDN,K_INS,K_DEL,0 ,0 ,0 ,K_F11 ,K_F12 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,//5
357 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,//6
358 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 //7
366 Map from windows to quake keynums
369 int MapKey (int key, int virtualkey)
372 int modified = (key >> 16) & 255;
373 qboolean is_extended = false;
375 if (modified < 128 && scantokey[modified])
376 result = scantokey[modified];
380 Con_DPrintf("key 0x%02x (0x%8x, 0x%8x) has no translation\n", modified, key, virtualkey);
397 return K_KP_LEFTARROW;
399 return K_KP_RIGHTARROW;
403 return K_KP_DOWNARROW;
430 ===================================================================
434 ===================================================================
442 void ClearAllStates (void)
448 extern qboolean host_loopactive;
450 void AppActivate(BOOL fActive, BOOL minimize)
451 /****************************************************************************
453 * Function: AppActivate
454 * Parameters: fActive - True if app is activating
456 * Description: If the application is activating, then swap the system
457 * into SYSPAL_NOSTATIC mode so that our palettes will display
460 ****************************************************************************/
462 static BOOL sound_active;
464 vid_activewindow = fActive;
465 vid_hidden = minimize;
467 // enable/disable sound on focus gain/loss
468 if (!vid_activewindow && sound_active)
471 sound_active = false;
473 else if (vid_activewindow && !sound_active)
481 if (vid_isfullscreen)
483 if (vid_wassuspended)
485 vid_wassuspended = false;
486 ChangeDisplaySettings (&gdevmode, CDS_FULLSCREEN);
487 ShowWindow(mainwindow, SW_SHOWNORMAL);
490 // LordHavoc: from dabb, fix for alt-tab bug in NVidia drivers
491 MoveWindow(mainwindow,0,0,gdevmode.dmPelsWidth,gdevmode.dmPelsHeight,false);
497 vid_usingmouse = false;
498 IN_DeactivateMouse ();
500 if (vid_isfullscreen)
502 ChangeDisplaySettings (NULL, 0);
503 vid_wassuspended = true;
505 VID_RestoreSystemGamma();
509 LONG CDAudio_MessageHandler(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
511 /* main window procedure */
512 LONG WINAPI MainWndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
515 int fActive, fMinimized, temp;
519 qboolean down = false;
521 extern unsigned int uiWheelMessage;
523 if ( uMsg == uiWheelMessage )
524 uMsg = WM_MOUSEWHEEL;
529 if (vid_isfullscreen)
530 ShowWindow(mainwindow, SW_SHOWMINNOACTIVE);
537 window_x = (int) LOWORD(lParam);
538 window_y = (int) HIWORD(lParam);
539 VID_UpdateWindowStatus ();
547 vkey = MapKey(lParam, wParam);
548 GetKeyboardState (state);
549 // alt/ctrl/shift tend to produce funky ToAscii values,
550 // and if it's not a single character we don't know care about it
551 if (vkey == K_ALT || vkey == K_CTRL || vkey == K_SHIFT || ToAscii (wParam, lParam >> 16, state, (unsigned short *)asciichar, 0) != 1)
553 Key_Event (vkey, asciichar[0], down);
557 // keep Alt-Space from happening
560 // this is complicated because Win32 seems to pack multiple mouse events into
561 // one update sometimes, so we always check all states and look for events
568 case WM_XBUTTONDOWN: // backslash :: imouse explorer buttons
569 case WM_XBUTTONUP: // backslash :: imouse explorer buttons
573 if (wParam & MK_LBUTTON)
576 if (wParam & MK_RBUTTON)
579 if (wParam & MK_MBUTTON)
582 /* backslash :: imouse explorer buttons */
583 if (wParam & MK_XBUTTON1)
586 if (wParam & MK_XBUTTON2)
590 // LordHavoc: lets hope this allows more buttons in the future...
591 if (wParam & MK_XBUTTON3)
593 if (wParam & MK_XBUTTON4)
595 if (wParam & MK_XBUTTON5)
597 if (wParam & MK_XBUTTON6)
599 if (wParam & MK_XBUTTON7)
602 IN_MouseEvent (temp);
606 // JACK: This is the mouse wheel with the Intellimouse
607 // Its delta is either positive or neg, and we generate the proper
610 if ((short) HIWORD(wParam) > 0) {
611 Key_Event(K_MWHEELUP, 0, true);
612 Key_Event(K_MWHEELUP, 0, false);
614 Key_Event(K_MWHEELDOWN, 0, true);
615 Key_Event(K_MWHEELDOWN, 0, false);
623 if (MessageBox (mainwindow, "Are you sure you want to quit?", "Confirm Exit", MB_YESNO | MB_SETFOREGROUND | MB_ICONQUESTION) == IDYES)
629 fActive = LOWORD(wParam);
630 fMinimized = (BOOL) HIWORD(wParam);
631 AppActivate(!(fActive == WA_INACTIVE), fMinimized);
633 // fix the leftover Alt from any Alt-Tab or the like that switched us away
639 // PostQuitMessage (0);
643 lRet = CDAudio_MessageHandler (hWnd, uMsg, wParam, lParam);
647 /* pass all unhandled messages to DefWindowProc */
648 lRet = DefWindowProc (hWnd, uMsg, wParam, lParam);
652 /* return 1 if handled message, 0 if not */
656 int VID_SetGamma(unsigned short *ramps)
658 HDC hdc = GetDC (NULL);
659 int i = SetDeviceGammaRamp(hdc, ramps);
660 ReleaseDC (NULL, hdc);
661 return i; // return success or failure
664 int VID_GetGamma(unsigned short *ramps)
666 HDC hdc = GetDC (NULL);
667 int i = GetDeviceGammaRamp(hdc, ramps);
668 ReleaseDC (NULL, hdc);
669 return i; // return success or failure
672 static HINSTANCE gldll;
674 int GL_OpenLibrary(const char *name)
676 Con_Printf("Loading OpenGL driver %s\n", name);
678 if (!(gldll = LoadLibrary(name)))
680 Con_Printf("Unable to LoadLibrary %s\n", name);
683 strcpy(gl_driver, name);
687 void GL_CloseLibrary(void)
692 qwglGetProcAddress = NULL;
695 gl_platformextensions = "";
698 void *GL_GetProcAddress(const char *name)
701 if (qwglGetProcAddress != NULL)
702 p = (void *) qwglGetProcAddress(name);
704 p = (void *) GetProcAddress(gldll, name);
708 static void IN_Init(void);
713 InitCommonControls();
714 hIcon = LoadIcon (global_hInstance, MAKEINTRESOURCE (IDI_ICON2));
716 // Register the frame class
718 wc.lpfnWndProc = (WNDPROC)MainWndProc;
721 wc.hInstance = global_hInstance;
723 wc.hCursor = LoadCursor (NULL,IDC_ARROW);
724 wc.hbrBackground = NULL;
726 wc.lpszClassName = "DarkPlacesWindowClass";
728 if (!RegisterClass (&wc))
729 Sys_Error("Couldn't register window class\n");
734 int VID_InitMode (int fullscreen, int width, int height, int bpp)
740 PIXELFORMATDESCRIPTOR pfd =
742 sizeof(PIXELFORMATDESCRIPTOR), // size of this pfd
744 PFD_DRAW_TO_WINDOW // support window
745 | PFD_SUPPORT_OPENGL // support OpenGL
746 | PFD_DOUBLEBUFFER , // double buffered
747 PFD_TYPE_RGBA, // RGBA type
748 24, // 24-bit color depth
749 0, 0, 0, 0, 0, 0, // color bits ignored
750 0, // no alpha buffer
751 0, // shift bit ignored
752 0, // no accumulation buffer
753 0, 0, 0, 0, // accum bits ignored
754 32, // 32-bit z-buffer
755 0, // no stencil buffer
756 0, // no auxiliary buffer
757 PFD_MAIN_PLANE, // main layer
759 0, 0, 0 // layer masks ignored
762 DWORD WindowStyle, ExWindowStyle;
764 int CenterX, CenterY;
765 const char *gldrivername;
769 Sys_Error("VID_InitMode called when video is already initialised\n");
771 // if stencil is enabled, ask for alpha too
774 pfd.cStencilBits = 8;
779 pfd.cStencilBits = 0;
783 gldrivername = "opengl32.dll";
784 i = COM_CheckParm("-gl_driver");
785 if (i && i < com_argc - 1)
786 gldrivername = com_argv[i + 1];
787 if (!GL_OpenLibrary(gldrivername))
789 Con_Printf("Unable to load GL driver %s\n", gldrivername);
793 memset(&gdevmode, 0, sizeof(gdevmode));
795 vid_isfullscreen = false;
798 gdevmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
799 gdevmode.dmBitsPerPel = bpp;
800 gdevmode.dmPelsWidth = width;
801 gdevmode.dmPelsHeight = height;
802 gdevmode.dmSize = sizeof (gdevmode);
803 if (ChangeDisplaySettings (&gdevmode, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
806 Con_Printf("Unable to change to requested mode %dx%dx%dbpp\n", width, height, bpp);
810 vid_isfullscreen = true;
811 WindowStyle = WS_POPUP;
812 ExWindowStyle = WS_EX_TOPMOST;
817 i = GetDeviceCaps(hdc, RASTERCAPS);
818 depth = GetDeviceCaps(hdc, PLANES) * GetDeviceCaps(hdc, BITSPIXEL);
819 ReleaseDC (NULL, hdc);
823 Con_Printf ("Can't run in non-RGB mode\n");
829 Con_Printf ("A higher desktop depth is required to run this video mode\n");
833 WindowStyle = WS_OVERLAPPED | WS_BORDER | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX;
840 rect.bottom = height;
841 AdjustWindowRectEx(&rect, WindowStyle, false, 0);
850 CenterX = (GetSystemMetrics(SM_CXSCREEN) - (rect.right - rect.left)) / 2;
851 CenterY = (GetSystemMetrics(SM_CYSCREEN) - (rect.bottom - rect.top)) / 2;
853 CenterX = max(0, CenterX);
854 CenterY = max(0, CenterY);
856 // x and y may be changed by WM_MOVE messages
859 window_width = width;
860 window_height = height;
861 rect.left += CenterX;
862 rect.right += CenterX;
864 rect.bottom += CenterY;
866 mainwindow = CreateWindowEx (ExWindowStyle, "DarkPlacesWindowClass", gamename, WindowStyle, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, NULL, NULL, global_hInstance, NULL);
869 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);
876 SetWindowPos (mainwindow, NULL, CenterX, CenterY, 0, 0,SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW | SWP_DRAWFRAME);
879 ShowWindow (mainwindow, SW_SHOWDEFAULT);
880 UpdateWindow (mainwindow);
882 SendMessage (mainwindow, WM_SETICON, (WPARAM)true, (LPARAM)hIcon);
883 SendMessage (mainwindow, WM_SETICON, (WPARAM)false, (LPARAM)hIcon);
885 VID_UpdateWindowStatus ();
887 // now we try to make sure we get the focus on the mode switch, because
888 // sometimes in some systems we don't. We grab the foreground, then
889 // finish setting up, pump all our messages, and sleep for a little while
890 // to let messages finish bouncing around the system, then we put
891 // ourselves at the top of the z order, then grab the foreground again,
892 // Who knows if it helps, but it probably doesn't hurt
893 SetForegroundWindow (mainwindow);
895 while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
897 TranslateMessage (&msg);
898 DispatchMessage (&msg);
903 SetWindowPos (mainwindow, HWND_TOP, 0, 0, 0, 0, SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW | SWP_NOCOPYBITS);
905 SetForegroundWindow (mainwindow);
907 // fix the leftover Alt from any Alt-Tab or the like that switched us away
910 hdc = GetDC(mainwindow);
912 if ((pixelformat = ChoosePixelFormat(hdc, &pfd)) == 0)
915 Con_Printf("ChoosePixelFormat(%d, %p) failed\n", hdc, &pfd);
919 if (SetPixelFormat(hdc, pixelformat, &pfd) == false)
922 Con_Printf("SetPixelFormat(%d, %d, %p) failed\n", hdc, pixelformat, &pfd);
926 if (!GL_CheckExtension("wgl", wglfuncs, NULL, false))
929 Con_Printf("wgl functions not found\n");
933 baseRC = qwglCreateContext(hdc);
937 Con_Printf("Could not initialize GL (wglCreateContext failed).\n\nMake sure you are in 65536 color mode, and try running -window.\n");
940 if (!qwglMakeCurrent(hdc, baseRC))
943 Con_Printf("wglMakeCurrent(%d, %d) failed\n", hdc, baseRC);
947 qglGetString = GL_GetProcAddress("glGetString");
948 qwglGetExtensionsStringARB = GL_GetProcAddress("wglGetExtensionsStringARB");
949 if (qglGetString == NULL)
952 Con_Printf("glGetString not found\n");
955 gl_renderer = qglGetString(GL_RENDERER);
956 gl_vendor = qglGetString(GL_VENDOR);
957 gl_version = qglGetString(GL_VERSION);
958 gl_extensions = qglGetString(GL_EXTENSIONS);
960 gl_platformextensions = "";
962 if (qwglGetExtensionsStringARB)
963 gl_platformextensions = qwglGetExtensionsStringARB(hdc);
965 gl_videosyncavailable = GL_CheckExtension("WGL_EXT_swap_control", wglswapintervalfuncs, NULL, false);
966 ReleaseDC(mainwindow, hdc);
970 // LordHavoc: special differences for ATI (broken 8bit color when also using 32bit? weird!)
971 if (strncasecmp(gl_vendor,"ATI",3)==0)
973 if (strncasecmp(gl_renderer,"Rage Pro",8)==0)
976 if (strncasecmp(gl_renderer,"Matrox G200 Direct3D",20)==0) // a D3D driver for GL? sigh...
979 //vid_menudrawfn = VID_MenuDraw;
980 //vid_menukeyfn = VID_MenuKey;
982 vid_initialized = true;
985 IN_StartupJoystick ();
990 static void IN_Shutdown(void);
991 void VID_Shutdown (void)
996 if(vid_initialized == false)
999 VID_RestoreSystemGamma();
1001 vid_initialized = false;
1003 if (qwglGetCurrentContext)
1004 hRC = qwglGetCurrentContext();
1005 if (qwglGetCurrentDC)
1006 hDC = qwglGetCurrentDC();
1007 if (qwglMakeCurrent)
1008 qwglMakeCurrent(NULL, NULL);
1009 if (hRC && qwglDeleteContext)
1010 qwglDeleteContext(hRC);
1011 // close the library before we get rid of the window
1013 if (hDC && mainwindow)
1014 ReleaseDC(mainwindow, hDC);
1015 AppActivate(false, false);
1017 DestroyWindow(mainwindow);
1019 if (vid_isfullscreen)
1020 ChangeDisplaySettings (NULL, 0);
1021 vid_isfullscreen = false;
1030 void IN_ShowMouse (void)
1032 if (!mouseshowtoggle)
1035 mouseshowtoggle = 1;
1045 void IN_HideMouse (void)
1047 if (mouseshowtoggle)
1050 mouseshowtoggle = 0;
1060 void IN_ActivateMouse (void)
1063 mouseactivatetoggle = true;
1065 if (mouseinitialized)
1071 if (!dinput_acquired)
1073 IDirectInputDevice_Acquire(g_pMouse);
1074 dinput_acquired = true;
1085 window_rect.left = window_x;
1086 window_rect.top = window_y;
1087 window_rect.right = window_x + window_width;
1088 window_rect.bottom = window_y + window_height;
1090 if (mouseparmsvalid)
1091 restore_spi = SystemParametersInfo (SPI_SETMOUSE, 0, newmouseparms, 0);
1093 SetCursorPos (window_center_x, window_center_y);
1094 SetCapture (mainwindow);
1095 ClipCursor (&window_rect);
1108 void IN_DeactivateMouse (void)
1111 mouseactivatetoggle = false;
1113 if (mouseinitialized)
1119 if (dinput_acquired)
1121 IDirectInputDevice_Unacquire(g_pMouse);
1122 dinput_acquired = false;
1129 SystemParametersInfo (SPI_SETMOUSE, 0, originalmouseparms, 0);
1135 mouseactive = false;
1145 qboolean IN_InitDInput (void)
1148 DIPROPDWORD dipdw = {
1150 sizeof(DIPROPDWORD), // diph.dwSize
1151 sizeof(DIPROPHEADER), // diph.dwHeaderSize
1153 DIPH_DEVICE, // diph.dwHow
1155 DINPUT_BUFFERSIZE, // dwData
1160 hInstDI = LoadLibrary("dinput.dll");
1162 if (hInstDI == NULL)
1164 Con_SafePrintf ("Couldn't load dinput.dll\n");
1169 if (!pDirectInputCreate)
1171 pDirectInputCreate = (void *)GetProcAddress(hInstDI,"DirectInputCreateA");
1173 if (!pDirectInputCreate)
1175 Con_SafePrintf ("Couldn't get DI proc addr\n");
1180 // register with DirectInput and get an IDirectInput to play with.
1181 hr = iDirectInputCreate(global_hInstance, DIRECTINPUT_VERSION, &g_pdi, NULL);
1188 // obtain an interface to the system mouse device.
1189 hr = IDirectInput_CreateDevice(g_pdi, &GUID_SysMouse, &g_pMouse, NULL);
1193 Con_SafePrintf ("Couldn't open DI mouse device\n");
1197 // set the data format to "mouse format".
1198 hr = IDirectInputDevice_SetDataFormat(g_pMouse, &df);
1202 Con_SafePrintf ("Couldn't set DI mouse format\n");
1206 // set the cooperativity level.
1207 hr = IDirectInputDevice_SetCooperativeLevel(g_pMouse, mainwindow,
1208 DISCL_EXCLUSIVE | DISCL_FOREGROUND);
1212 Con_SafePrintf ("Couldn't set DI coop level\n");
1217 // set the buffer size to DINPUT_BUFFERSIZE elements.
1218 // the buffer size is a DWORD property associated with the device
1219 hr = IDirectInputDevice_SetProperty(g_pMouse, DIPROP_BUFFERSIZE, &dipdw.diph);
1223 Con_SafePrintf ("Couldn't set DI buffersize\n");
1236 void IN_StartupMouse (void)
1238 if (COM_CheckParm ("-nomouse") || COM_CheckParm("-safe"))
1241 mouseinitialized = true;
1243 if (COM_CheckParm ("-dinput"))
1245 dinput = IN_InitDInput ();
1249 Con_SafePrintf ("DirectInput initialized\n");
1253 Con_SafePrintf ("DirectInput not initialized\n");
1259 mouseparmsvalid = SystemParametersInfo (SPI_GETMOUSE, 0, originalmouseparms, 0);
1261 if (mouseparmsvalid)
1263 if ( COM_CheckParm ("-noforcemspd") )
1264 newmouseparms[2] = originalmouseparms[2];
1266 if ( COM_CheckParm ("-noforcemaccel") )
1268 newmouseparms[0] = originalmouseparms[0];
1269 newmouseparms[1] = originalmouseparms[1];
1272 if ( COM_CheckParm ("-noforcemparms") )
1274 newmouseparms[0] = originalmouseparms[0];
1275 newmouseparms[1] = originalmouseparms[1];
1276 newmouseparms[2] = originalmouseparms[2];
1283 // if a fullscreen video mode was set before the mouse was initialized,
1284 // set the mouse state appropriately
1285 if (mouseactivatetoggle)
1286 IN_ActivateMouse ();
1295 void IN_MouseEvent (int mstate)
1299 if (mouseactive && !dinput)
1301 // perform button actions
1302 for (i=0 ; i<mouse_buttons ; i++)
1304 if ( (mstate & (1<<i)) &&
1305 !(mouse_oldbuttonstate & (1<<i)) )
1307 Key_Event (K_MOUSE1 + i, 0, true);
1310 if ( !(mstate & (1<<i)) &&
1311 (mouse_oldbuttonstate & (1<<i)) )
1313 Key_Event (K_MOUSE1 + i, 0, false);
1317 mouse_oldbuttonstate = mstate;
1327 void IN_MouseMove (usercmd_t *cmd)
1330 DIDEVICEOBJECTDATA od;
1336 GetCursorPos (¤t_pos);
1337 //ui_mouseupdate(current_pos.x - window_x, current_pos.y - window_y);
1338 in_mouse_x = in_mouse_y = 0;
1351 hr = IDirectInputDevice_GetDeviceData(g_pMouse,
1352 sizeof(DIDEVICEOBJECTDATA), &od, &dwElements, 0);
1354 if ((hr == DIERR_INPUTLOST) || (hr == DIERR_NOTACQUIRED))
1356 dinput_acquired = true;
1357 IDirectInputDevice_Acquire(g_pMouse);
1361 /* Unable to read data or no data available */
1362 if (FAILED(hr) || dwElements == 0)
1365 /* Look at the element to see what happened */
1377 case DIMOFS_BUTTON0:
1378 if (od.dwData & 0x80)
1384 case DIMOFS_BUTTON1:
1385 if (od.dwData & 0x80)
1386 mstate_di |= (1<<1);
1388 mstate_di &= ~(1<<1);
1391 case DIMOFS_BUTTON2:
1392 if (od.dwData & 0x80)
1393 mstate_di |= (1<<2);
1395 mstate_di &= ~(1<<2);
1400 // perform button actions
1401 for (i=0 ; i<mouse_buttons ; i++)
1403 if ( (mstate_di & (1<<i)) &&
1404 !(mouse_oldbuttonstate & (1<<i)) )
1406 Key_Event (K_MOUSE1 + i, 0, true);
1409 if ( !(mstate_di & (1<<i)) &&
1410 (mouse_oldbuttonstate & (1<<i)) )
1412 Key_Event (K_MOUSE1 + i, 0, false);
1416 mouse_oldbuttonstate = mstate_di;
1420 GetCursorPos (¤t_pos);
1421 mx = current_pos.x - window_center_x + mx_accum;
1422 my = current_pos.y - window_center_y + my_accum;
1427 IN_Mouse(cmd, mx, my);
1429 // if the mouse has moved, force it to the center, so there's room to move
1430 if (!dinput && (mx || my))
1431 SetCursorPos (window_center_x, window_center_y);
1440 void IN_Move (usercmd_t *cmd)
1442 if (vid_activewindow && !vid_hidden)
1455 void IN_Accumulate (void)
1461 GetCursorPos (¤t_pos);
1463 mx_accum += current_pos.x - window_center_x;
1464 my_accum += current_pos.y - window_center_y;
1466 // force the mouse to the center, so there's room to move
1467 SetCursorPos (window_center_x, window_center_y);
1478 void IN_ClearStates (void)
1484 mouse_oldbuttonstate = 0;
1494 void IN_StartupJoystick (void)
1501 // assume no joystick
1504 // abort startup if user requests no joystick
1505 if (COM_CheckParm ("-nojoy") || COM_CheckParm("-safe"))
1508 // verify joystick driver is present
1509 if ((numdevs = joyGetNumDevs ()) == 0)
1511 Con_Printf ("\njoystick not found -- driver not present\n\n");
1515 // cycle through the joystick ids for the first valid one
1516 for (joy_id=0 ; joy_id<numdevs ; joy_id++)
1518 memset (&ji, 0, sizeof(ji));
1519 ji.dwSize = sizeof(ji);
1520 ji.dwFlags = JOY_RETURNCENTERED;
1522 if ((mmr = joyGetPosEx (joy_id, &ji)) == JOYERR_NOERROR)
1526 // abort startup if we didn't find a valid joystick
1527 if (mmr != JOYERR_NOERROR)
1529 Con_Printf ("\njoystick not found -- no valid joysticks (%x)\n\n", mmr);
1533 // get the capabilities of the selected joystick
1534 // abort startup if command fails
1535 memset (&jc, 0, sizeof(jc));
1536 if ((mmr = joyGetDevCaps (joy_id, &jc, sizeof(jc))) != JOYERR_NOERROR)
1538 Con_Printf ("\njoystick not found -- invalid joystick capabilities (%x)\n\n", mmr);
1542 // save the joystick's number of buttons and POV status
1543 joy_numbuttons = jc.wNumButtons;
1544 joy_haspov = jc.wCaps & JOYCAPS_HASPOV;
1546 // old button and POV states default to no buttons pressed
1547 joy_oldbuttonstate = joy_oldpovstate = 0;
1549 // mark the joystick as available and advanced initialization not completed
1550 // this is needed as cvars are not available during initialization
1553 joy_advancedinit = false;
1555 Con_Printf ("\njoystick detected\n\n");
1564 PDWORD RawValuePointer (int axis)
1581 return NULL; // LordHavoc: hush compiler warning
1587 Joy_AdvancedUpdate_f
1590 void Joy_AdvancedUpdate_f (void)
1593 // called once by IN_ReadJoystick and by user whenever an update is needed
1594 // cvars are now available
1598 // initialize all the maps
1599 for (i = 0; i < JOY_MAX_AXES; i++)
1601 dwAxisMap[i] = AxisNada;
1602 dwControlMap[i] = JOY_ABSOLUTE_AXIS;
1603 pdwRawValue[i] = RawValuePointer(i);
1606 if( joy_advanced.integer == 0)
1608 // default joystick initialization
1609 // 2 axes only with joystick control
1610 dwAxisMap[JOY_AXIS_X] = AxisTurn;
1611 // dwControlMap[JOY_AXIS_X] = JOY_ABSOLUTE_AXIS;
1612 dwAxisMap[JOY_AXIS_Y] = AxisForward;
1613 // dwControlMap[JOY_AXIS_Y] = JOY_ABSOLUTE_AXIS;
1617 if (strcmp (joy_name.string, "joystick") != 0)
1619 // notify user of advanced controller
1620 Con_Printf ("\n%s configured\n\n", joy_name.string);
1623 // advanced initialization here
1624 // data supplied by user via joy_axisn cvars
1625 dwTemp = (DWORD) joy_advaxisx.value;
1626 dwAxisMap[JOY_AXIS_X] = dwTemp & 0x0000000f;
1627 dwControlMap[JOY_AXIS_X] = dwTemp & JOY_RELATIVE_AXIS;
1628 dwTemp = (DWORD) joy_advaxisy.value;
1629 dwAxisMap[JOY_AXIS_Y] = dwTemp & 0x0000000f;
1630 dwControlMap[JOY_AXIS_Y] = dwTemp & JOY_RELATIVE_AXIS;
1631 dwTemp = (DWORD) joy_advaxisz.value;
1632 dwAxisMap[JOY_AXIS_Z] = dwTemp & 0x0000000f;
1633 dwControlMap[JOY_AXIS_Z] = dwTemp & JOY_RELATIVE_AXIS;
1634 dwTemp = (DWORD) joy_advaxisr.value;
1635 dwAxisMap[JOY_AXIS_R] = dwTemp & 0x0000000f;
1636 dwControlMap[JOY_AXIS_R] = dwTemp & JOY_RELATIVE_AXIS;
1637 dwTemp = (DWORD) joy_advaxisu.value;
1638 dwAxisMap[JOY_AXIS_U] = dwTemp & 0x0000000f;
1639 dwControlMap[JOY_AXIS_U] = dwTemp & JOY_RELATIVE_AXIS;
1640 dwTemp = (DWORD) joy_advaxisv.value;
1641 dwAxisMap[JOY_AXIS_V] = dwTemp & 0x0000000f;
1642 dwControlMap[JOY_AXIS_V] = dwTemp & JOY_RELATIVE_AXIS;
1645 // compute the axes to collect from DirectInput
1646 joy_flags = JOY_RETURNCENTERED | JOY_RETURNBUTTONS | JOY_RETURNPOV;
1647 for (i = 0; i < JOY_MAX_AXES; i++)
1649 if (dwAxisMap[i] != AxisNada)
1651 joy_flags |= dwAxisFlags[i];
1661 void IN_Commands (void)
1664 DWORD buttonstate, povstate;
1672 // loop through the joystick buttons
1673 // key a joystick event or auxillary event for higher number buttons for each state change
1674 buttonstate = ji.dwButtons;
1675 for (i=0 ; i < (int) joy_numbuttons ; i++)
1677 if ( (buttonstate & (1<<i)) && !(joy_oldbuttonstate & (1<<i)) )
1679 key_index = (i < 4) ? K_JOY1 : K_AUX1;
1680 Key_Event (key_index + i, 0, true);
1683 if ( !(buttonstate & (1<<i)) && (joy_oldbuttonstate & (1<<i)) )
1685 key_index = (i < 4) ? K_JOY1 : K_AUX1;
1686 Key_Event (key_index + i, 0, false);
1689 joy_oldbuttonstate = buttonstate;
1693 // convert POV information into 4 bits of state information
1694 // this avoids any potential problems related to moving from one
1695 // direction to another without going through the center position
1697 if(ji.dwPOV != JOY_POVCENTERED)
1699 if (ji.dwPOV == JOY_POVFORWARD)
1701 if (ji.dwPOV == JOY_POVRIGHT)
1703 if (ji.dwPOV == JOY_POVBACKWARD)
1705 if (ji.dwPOV == JOY_POVLEFT)
1708 // determine which bits have changed and key an auxillary event for each change
1709 for (i=0 ; i < 4 ; i++)
1711 if ( (povstate & (1<<i)) && !(joy_oldpovstate & (1<<i)) )
1713 Key_Event (K_AUX29 + i, 0, true);
1716 if ( !(povstate & (1<<i)) && (joy_oldpovstate & (1<<i)) )
1718 Key_Event (K_AUX29 + i, 0, false);
1721 joy_oldpovstate = povstate;
1731 qboolean IN_ReadJoystick (void)
1734 memset (&ji, 0, sizeof(ji));
1735 ji.dwSize = sizeof(ji);
1736 ji.dwFlags = joy_flags;
1738 if (joyGetPosEx (joy_id, &ji) == JOYERR_NOERROR)
1740 // this is a hack -- there is a bug in the Logitech WingMan Warrior DirectInput Driver
1741 // rather than having 32768 be the zero point, they have the zero point at 32668
1742 // go figure -- anyway, now we get the full resolution out of the device
1743 if (joy_wwhack1.integer != 0.0)
1751 // read error occurred
1752 // turning off the joystick seems too harsh for 1 read error,
1753 // but what should be done?
1764 void IN_JoyMove (usercmd_t *cmd)
1766 float speed, aspeed;
1767 float fAxisValue, fTemp;
1768 int i, mouselook = (in_mlook.state & 1) || freelook.integer;
1770 // complete initialization if first time in
1771 // this is needed as cvars are not available at initialization time
1772 if( joy_advancedinit != true )
1774 Joy_AdvancedUpdate_f();
1775 joy_advancedinit = true;
1778 // verify joystick is available and that the user wants to use it
1779 if (!joy_avail || !in_joystick.integer)
1784 // collect the joystick data, if possible
1785 if (IN_ReadJoystick () != true)
1790 if (in_speed.state & 1)
1791 speed = cl_movespeedkey.value;
1794 // LordHavoc: viewzoom affects sensitivity for sniping
1795 aspeed = speed * host_realframetime * cl.viewzoom;
1797 // loop through the axes
1798 for (i = 0; i < JOY_MAX_AXES; i++)
1800 // get the floating point zero-centered, potentially-inverted data for the current axis
1801 fAxisValue = (float) *pdwRawValue[i];
1802 // move centerpoint to zero
1803 fAxisValue -= 32768.0;
1805 if (joy_wwhack2.integer != 0.0)
1807 if (dwAxisMap[i] == AxisTurn)
1809 // this is a special formula for the Logitech WingMan Warrior
1810 // y=ax^b; where a = 300 and b = 1.3
1811 // also x values are in increments of 800 (so this is factored out)
1812 // then bounds check result to level out excessively high spin rates
1813 fTemp = 300.0 * pow(abs(fAxisValue) / 800.0, 1.3);
1814 if (fTemp > 14000.0)
1816 // restore direction information
1817 fAxisValue = (fAxisValue > 0.0) ? fTemp : -fTemp;
1821 // convert range from -32768..32767 to -1..1
1822 fAxisValue /= 32768.0;
1824 switch (dwAxisMap[i])
1827 if ((joy_advanced.integer == 0) && mouselook)
1829 // user wants forward control to become look control
1830 if (fabs(fAxisValue) > joy_pitchthreshold.value)
1832 // if mouse invert is on, invert the joystick pitch value
1833 // only absolute control support here (joy_advanced is false)
1834 if (m_pitch.value < 0.0)
1836 cl.viewangles[PITCH] -= (fAxisValue * joy_pitchsensitivity.value) * aspeed * cl_pitchspeed.value;
1840 cl.viewangles[PITCH] += (fAxisValue * joy_pitchsensitivity.value) * aspeed * cl_pitchspeed.value;
1846 // no pitch movement
1847 // disable pitch return-to-center unless requested by user
1848 // *** this code can be removed when the lookspring bug is fixed
1849 // *** the bug always has the lookspring feature on
1850 if(lookspring.value == 0.0)
1856 // user wants forward control to be forward control
1857 if (fabs(fAxisValue) > joy_forwardthreshold.value)
1859 cmd->forwardmove += (fAxisValue * joy_forwardsensitivity.value) * speed * cl_forwardspeed.value;
1865 if (fabs(fAxisValue) > joy_sidethreshold.value)
1867 cmd->sidemove += (fAxisValue * joy_sidesensitivity.value) * speed * cl_sidespeed.value;
1872 if ((in_strafe.state & 1) || (lookstrafe.integer && mouselook))
1874 // user wants turn control to become side control
1875 if (fabs(fAxisValue) > joy_sidethreshold.value)
1877 cmd->sidemove -= (fAxisValue * joy_sidesensitivity.value) * speed * cl_sidespeed.value;
1882 // user wants turn control to be turn control
1883 if (fabs(fAxisValue) > joy_yawthreshold.value)
1885 if(dwControlMap[i] == JOY_ABSOLUTE_AXIS)
1887 cl.viewangles[YAW] += (fAxisValue * joy_yawsensitivity.value) * aspeed * cl_yawspeed.value;
1891 cl.viewangles[YAW] += (fAxisValue * joy_yawsensitivity.value) * speed * 180.0;
1901 if (fabs(fAxisValue) > joy_pitchthreshold.value)
1903 // pitch movement detected and pitch movement desired by user
1904 if(dwControlMap[i] == JOY_ABSOLUTE_AXIS)
1906 cl.viewangles[PITCH] += (fAxisValue * joy_pitchsensitivity.value) * aspeed * cl_pitchspeed.value;
1910 cl.viewangles[PITCH] += (fAxisValue * joy_pitchsensitivity.value) * speed * 180.0;
1916 // no pitch movement
1917 // disable pitch return-to-center unless requested by user
1918 // *** this code can be removed when the lookspring bug is fixed
1919 // *** the bug always has the lookspring feature on
1920 if(lookspring.integer == 0)
1932 static void IN_Init(void)
1934 uiWheelMessage = RegisterWindowMessage ( "MSWHEEL_ROLLMSG" );
1936 // joystick variables
1937 Cvar_RegisterVariable (&in_joystick);
1938 Cvar_RegisterVariable (&joy_name);
1939 Cvar_RegisterVariable (&joy_advanced);
1940 Cvar_RegisterVariable (&joy_advaxisx);
1941 Cvar_RegisterVariable (&joy_advaxisy);
1942 Cvar_RegisterVariable (&joy_advaxisz);
1943 Cvar_RegisterVariable (&joy_advaxisr);
1944 Cvar_RegisterVariable (&joy_advaxisu);
1945 Cvar_RegisterVariable (&joy_advaxisv);
1946 Cvar_RegisterVariable (&joy_forwardthreshold);
1947 Cvar_RegisterVariable (&joy_sidethreshold);
1948 Cvar_RegisterVariable (&joy_pitchthreshold);
1949 Cvar_RegisterVariable (&joy_yawthreshold);
1950 Cvar_RegisterVariable (&joy_forwardsensitivity);
1951 Cvar_RegisterVariable (&joy_sidesensitivity);
1952 Cvar_RegisterVariable (&joy_pitchsensitivity);
1953 Cvar_RegisterVariable (&joy_yawsensitivity);
1954 Cvar_RegisterVariable (&joy_wwhack1);
1955 Cvar_RegisterVariable (&joy_wwhack2);
1956 Cmd_AddCommand ("joyadvancedupdate", Joy_AdvancedUpdate_f);
1959 static void IN_Shutdown(void)
1961 IN_DeactivateMouse ();
1965 IDirectInputDevice_Release(g_pMouse);
1969 IDirectInput_Release(g_pdi);