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
27 int (WINAPI *qwglChoosePixelFormat)(HDC, CONST PIXELFORMATDESCRIPTOR *);
28 int (WINAPI *qwglDescribePixelFormat)(HDC, int, UINT, LPPIXELFORMATDESCRIPTOR);
29 //int (WINAPI *qwglGetPixelFormat)(HDC);
30 BOOL (WINAPI *qwglSetPixelFormat)(HDC, int, CONST PIXELFORMATDESCRIPTOR *);
31 BOOL (WINAPI *qwglSwapBuffers)(HDC);
32 HGLRC (WINAPI *qwglCreateContext)(HDC);
33 BOOL (WINAPI *qwglDeleteContext)(HGLRC);
34 HGLRC (WINAPI *qwglGetCurrentContext)(VOID);
35 HDC (WINAPI *qwglGetCurrentDC)(VOID);
36 PROC (WINAPI *qwglGetProcAddress)(LPCSTR);
37 BOOL (WINAPI *qwglMakeCurrent)(HDC, HGLRC);
38 BOOL (WINAPI *qwglSwapIntervalEXT)(int interval);
39 const char *(WINAPI *qwglGetExtensionsStringARB)(HDC hdc);
41 static dllfunction_t wglfuncs[] =
43 {"wglChoosePixelFormat", (void **) &qwglChoosePixelFormat},
44 {"wglDescribePixelFormat", (void **) &qwglDescribePixelFormat},
45 // {"wglGetPixelFormat", (void **) &qwglGetPixelFormat},
46 {"wglSetPixelFormat", (void **) &qwglSetPixelFormat},
47 {"wglSwapBuffers", (void **) &qwglSwapBuffers},
48 {"wglCreateContext", (void **) &qwglCreateContext},
49 {"wglDeleteContext", (void **) &qwglDeleteContext},
50 {"wglGetProcAddress", (void **) &qwglGetProcAddress},
51 {"wglMakeCurrent", (void **) &qwglMakeCurrent},
52 {"wglGetCurrentContext", (void **) &qwglGetCurrentContext},
53 {"wglGetCurrentDC", (void **) &qwglGetCurrentDC},
57 static dllfunction_t wglswapintervalfuncs[] =
59 {"wglSwapIntervalEXT", (void **) &qwglSwapIntervalEXT},
63 qboolean scr_skipupdate;
65 static DEVMODE gdevmode;
66 static qboolean vid_initialized = false;
67 static qboolean vid_wassuspended = false;
68 static int vid_usingmouse;
69 extern qboolean mouseactive; // from in_win.c
74 //HWND WINAPI InitializeWindow (HINSTANCE hInstance, int nCmdShow);
76 static int vid_isfullscreen;
78 //void VID_MenuDraw (void);
79 //void VID_MenuKey (int key);
81 //LONG WINAPI MainWndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
82 //void AppActivate(BOOL fActive, BOOL minimize);
83 //void ClearAllStates (void);
84 //void VID_UpdateWindowStatus (void);
86 //====================================
88 int window_x, window_y, window_width, window_height;
89 int window_center_x, window_center_y;
91 void IN_ShowMouse (void);
92 void IN_DeactivateMouse (void);
93 void IN_HideMouse (void);
94 void IN_ActivateMouse (void);
95 void IN_MouseEvent (int mstate);
96 void IN_UpdateClipCursor (void);
98 qboolean mouseinitialized;
99 static qboolean dinput;
105 #define DINPUT_BUFFERSIZE 16
106 #define iDirectInputCreate(a,b,c,d) pDirectInputCreate(a,b,c,d)
108 HRESULT (WINAPI *pDirectInputCreate)(HINSTANCE hinst, DWORD dwVersion,
109 LPDIRECTINPUT * lplpDirectInput, LPUNKNOWN punkOuter);
111 // LordHavoc: thanks to backslash for this support for mouse buttons 4 and 5
112 /* backslash :: imouse explorer buttons */
113 /* These are #ifdefed out for non-Win2K in the February 2001 version of
114 MS's platform SDK, but we need them for compilation. . . */
115 #ifndef WM_XBUTTONDOWN
116 #define WM_XBUTTONDOWN 0x020B
117 #define WM_XBUTTONUP 0x020C
120 #define MK_XBUTTON1 0x0020
121 #define MK_XBUTTON2 0x0040
122 // LordHavoc: lets hope this allows more buttons in the future...
123 #define MK_XBUTTON3 0x0080
124 #define MK_XBUTTON4 0x0100
125 #define MK_XBUTTON5 0x0200
126 #define MK_XBUTTON6 0x0400
127 #define MK_XBUTTON7 0x0800
133 int mouse_oldbuttonstate;
135 int mouse_x, mouse_y, old_mouse_x, old_mouse_y, mx_accum, my_accum;
137 static qboolean restore_spi;
138 static int originalmouseparms[3], newmouseparms[3] = {0, 0, 1};
140 unsigned int uiWheelMessage;
141 qboolean mouseactive;
142 //qboolean mouseinitialized;
143 static qboolean mouseparmsvalid, mouseactivatetoggle;
144 static qboolean mouseshowtoggle = 1;
145 static qboolean dinput_acquired;
147 static unsigned int mstate_di;
149 // joystick defines and variables
150 // where should defines be moved?
151 #define JOY_ABSOLUTE_AXIS 0x00000000 // control like a joystick
152 #define JOY_RELATIVE_AXIS 0x00000010 // control like a mouse, spinner, trackball
153 #define JOY_MAX_AXES 6 // X, Y, Z, R, U, V
163 AxisNada = 0, AxisForward, AxisLook, AxisSide, AxisTurn
166 DWORD dwAxisFlags[JOY_MAX_AXES] =
168 JOY_RETURNX, JOY_RETURNY, JOY_RETURNZ, JOY_RETURNR, JOY_RETURNU, JOY_RETURNV
171 DWORD dwAxisMap[JOY_MAX_AXES];
172 DWORD dwControlMap[JOY_MAX_AXES];
173 PDWORD pdwRawValue[JOY_MAX_AXES];
175 // none of these cvars are saved over a session
176 // this means that advanced controller configuration needs to be executed
177 // each time. this avoids any problems with getting back to a default usage
178 // or when changing from one controller to another. this way at least something
180 cvar_t in_joystick = {CVAR_SAVE, "joystick","0"};
181 cvar_t joy_name = {0, "joyname", "joystick"};
182 cvar_t joy_advanced = {0, "joyadvanced", "0"};
183 cvar_t joy_advaxisx = {0, "joyadvaxisx", "0"};
184 cvar_t joy_advaxisy = {0, "joyadvaxisy", "0"};
185 cvar_t joy_advaxisz = {0, "joyadvaxisz", "0"};
186 cvar_t joy_advaxisr = {0, "joyadvaxisr", "0"};
187 cvar_t joy_advaxisu = {0, "joyadvaxisu", "0"};
188 cvar_t joy_advaxisv = {0, "joyadvaxisv", "0"};
189 cvar_t joy_forwardthreshold = {0, "joyforwardthreshold", "0.15"};
190 cvar_t joy_sidethreshold = {0, "joysidethreshold", "0.15"};
191 cvar_t joy_pitchthreshold = {0, "joypitchthreshold", "0.15"};
192 cvar_t joy_yawthreshold = {0, "joyyawthreshold", "0.15"};
193 cvar_t joy_forwardsensitivity = {0, "joyforwardsensitivity", "-1.0"};
194 cvar_t joy_sidesensitivity = {0, "joysidesensitivity", "-1.0"};
195 cvar_t joy_pitchsensitivity = {0, "joypitchsensitivity", "1.0"};
196 cvar_t joy_yawsensitivity = {0, "joyyawsensitivity", "-1.0"};
197 cvar_t joy_wwhack1 = {0, "joywwhack1", "0.0"};
198 cvar_t joy_wwhack2 = {0, "joywwhack2", "0.0"};
200 qboolean joy_avail, joy_advancedinit, joy_haspov;
201 DWORD joy_oldbuttonstate, joy_oldpovstate;
205 DWORD joy_numbuttons;
207 static LPDIRECTINPUT g_pdi;
208 static LPDIRECTINPUTDEVICE g_pMouse;
212 static HINSTANCE hInstDI;
214 //static qboolean dinput;
216 typedef struct MYDATA {
217 LONG lX; // X axis goes here
218 LONG lY; // Y axis goes here
219 LONG lZ; // Z axis goes here
220 BYTE bButtonA; // One button goes here
221 BYTE bButtonB; // Another button goes here
222 BYTE bButtonC; // Another button goes here
223 BYTE bButtonD; // Another button goes here
226 static DIOBJECTDATAFORMAT rgodf[] = {
227 { &GUID_XAxis, FIELD_OFFSET(MYDATA, lX), DIDFT_AXIS | DIDFT_ANYINSTANCE, 0,},
228 { &GUID_YAxis, FIELD_OFFSET(MYDATA, lY), DIDFT_AXIS | DIDFT_ANYINSTANCE, 0,},
229 { &GUID_ZAxis, FIELD_OFFSET(MYDATA, lZ), 0x80000000 | DIDFT_AXIS | DIDFT_ANYINSTANCE, 0,},
230 { 0, FIELD_OFFSET(MYDATA, bButtonA), DIDFT_BUTTON | DIDFT_ANYINSTANCE, 0,},
231 { 0, FIELD_OFFSET(MYDATA, bButtonB), DIDFT_BUTTON | DIDFT_ANYINSTANCE, 0,},
232 { 0, FIELD_OFFSET(MYDATA, bButtonC), 0x80000000 | DIDFT_BUTTON | DIDFT_ANYINSTANCE, 0,},
233 { 0, FIELD_OFFSET(MYDATA, bButtonD), 0x80000000 | DIDFT_BUTTON | DIDFT_ANYINSTANCE, 0,},
236 #define NUM_OBJECTS (sizeof(rgodf) / sizeof(rgodf[0]))
238 static DIDATAFORMAT df = {
239 sizeof(DIDATAFORMAT), // this structure
240 sizeof(DIOBJECTDATAFORMAT), // size of object data format
241 DIDF_RELAXIS, // absolute axis coordinates
242 sizeof(MYDATA), // device data size
243 NUM_OBJECTS, // number of objects
244 rgodf, // and here they are
247 // forward-referenced functions
248 void IN_StartupJoystick (void);
249 void Joy_AdvancedUpdate_f (void);
250 void IN_JoyMove (usercmd_t *cmd);
251 void IN_StartupMouse (void);
255 VID_UpdateWindowStatus
258 void VID_UpdateWindowStatus (void)
260 window_center_x = window_x + window_width / 2;
261 window_center_y = window_y + window_height / 2;
263 if (mouseinitialized && mouseactive && !dinput)
266 window_rect.left = window_x;
267 window_rect.top = window_y;
268 window_rect.right = window_x + window_width;
269 window_rect.bottom = window_y + window_height;
270 ClipCursor (&window_rect);
275 //====================================
282 void VID_GetWindowSize (int *x, int *y, int *width, int *height)
286 *width = window_width;
287 *height = window_height;
291 void VID_Finish (void)
295 if (r_render.integer && !scr_skipupdate)
298 hdc = GetDC(mainwindow);
300 ReleaseDC(mainwindow, hdc);
303 // handle the mouse state when windowed if that's changed
304 vid_usemouse = false;
305 if (vid_mouse.integer && !key_consoleactive)
307 if (vid_isfullscreen)
309 if (!vid_activewindow)
310 vid_usemouse = false;
315 vid_usingmouse = true;
324 vid_usingmouse = false;
325 IN_DeactivateMouse ();
331 //==========================================================================
336 qbyte scantokey[128] =
338 // 0 1 2 3 4 5 6 7 8 9 A B C D E F
339 0 ,27 ,'1' ,'2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' ,'0' ,'-' ,'=' ,K_BACKSPACE,9 ,//0
340 'q' ,'w' ,'e' ,'r' ,'t' ,'y' ,'u' ,'i' ,'o' ,'p' ,'[' ,']' ,13 ,K_CTRL ,'a' ,'s' ,//1
341 'd' ,'f' ,'g' ,'h' ,'j' ,'k' ,'l' ,';' ,'\'' ,'`' ,K_SHIFT ,'\\' ,'z' ,'x' ,'c' ,'v' ,//2
342 'b' ,'n' ,'m' ,',' ,'.' ,'/' ,K_SHIFT,'*' ,K_ALT ,' ' ,0 ,K_F1 ,K_F2 ,K_F3 ,K_F4 ,K_F5 ,//3
343 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
344 K_DOWNARROW,K_PGDN,K_INS,K_DEL,0 ,0 ,0 ,K_F11 ,K_F12 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,//5
345 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,//6
346 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 //7
354 Map from windows to quake keynums
357 int MapKey (int key, int virtualkey)
360 int modified = (key >> 16) & 255;
361 qboolean is_extended = false;
363 if (modified < 128 && scantokey[modified])
364 result = scantokey[modified];
368 Con_DPrintf("key 0x%02x (0x%8x, 0x%8x) has no translation\n", modified, key, virtualkey);
385 return K_KP_LEFTARROW;
387 return K_KP_RIGHTARROW;
391 return K_KP_DOWNARROW;
418 ===================================================================
422 ===================================================================
430 void ClearAllStates (void)
436 extern qboolean host_loopactive;
438 void AppActivate(BOOL fActive, BOOL minimize)
439 /****************************************************************************
441 * Function: AppActivate
442 * Parameters: fActive - True if app is activating
444 * Description: If the application is activating, then swap the system
445 * into SYSPAL_NOSTATIC mode so that our palettes will display
448 ****************************************************************************/
450 static BOOL sound_active;
452 vid_activewindow = fActive;
453 vid_hidden = minimize;
455 // enable/disable sound on focus gain/loss
456 if (!vid_activewindow && sound_active)
459 sound_active = false;
461 else if (vid_activewindow && !sound_active)
469 if (vid_isfullscreen)
471 if (vid_wassuspended)
473 vid_wassuspended = false;
474 ChangeDisplaySettings (&gdevmode, CDS_FULLSCREEN);
475 ShowWindow(mainwindow, SW_SHOWNORMAL);
478 // LordHavoc: from dabb, fix for alt-tab bug in NVidia drivers
479 MoveWindow(mainwindow,0,0,gdevmode.dmPelsWidth,gdevmode.dmPelsHeight,false);
485 vid_usingmouse = false;
486 IN_DeactivateMouse ();
488 if (vid_isfullscreen)
490 ChangeDisplaySettings (NULL, 0);
491 vid_wassuspended = true;
493 VID_RestoreSystemGamma();
497 LONG CDAudio_MessageHandler(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
499 /* main window procedure */
500 LONG WINAPI MainWndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
503 int fActive, fMinimized, temp;
507 qboolean down = false;
509 extern unsigned int uiWheelMessage;
511 if ( uMsg == uiWheelMessage )
512 uMsg = WM_MOUSEWHEEL;
517 if (vid_isfullscreen)
518 ShowWindow(mainwindow, SW_SHOWMINNOACTIVE);
525 window_x = (int) LOWORD(lParam);
526 window_y = (int) HIWORD(lParam);
527 VID_UpdateWindowStatus ();
535 vkey = MapKey(lParam, wParam);
536 GetKeyboardState (state);
537 ToAscii (wParam, vkey, state, &ascchar, 0);
538 Key_Event (vkey, (char)(ascchar & 0xFF), down);
542 // keep Alt-Space from happening
545 // this is complicated because Win32 seems to pack multiple mouse events into
546 // one update sometimes, so we always check all states and look for events
553 case WM_XBUTTONDOWN: // backslash :: imouse explorer buttons
554 case WM_XBUTTONUP: // backslash :: imouse explorer buttons
558 if (wParam & MK_LBUTTON)
561 if (wParam & MK_RBUTTON)
564 if (wParam & MK_MBUTTON)
567 /* backslash :: imouse explorer buttons */
568 if (wParam & MK_XBUTTON1)
571 if (wParam & MK_XBUTTON2)
575 // LordHavoc: lets hope this allows more buttons in the future...
576 if (wParam & MK_XBUTTON3)
578 if (wParam & MK_XBUTTON4)
580 if (wParam & MK_XBUTTON5)
582 if (wParam & MK_XBUTTON6)
584 if (wParam & MK_XBUTTON7)
587 IN_MouseEvent (temp);
591 // JACK: This is the mouse wheel with the Intellimouse
592 // Its delta is either positive or neg, and we generate the proper
595 if ((short) HIWORD(wParam) > 0) {
596 Key_Event(K_MWHEELUP, 0, true);
597 Key_Event(K_MWHEELUP, 0, false);
599 Key_Event(K_MWHEELDOWN, 0, true);
600 Key_Event(K_MWHEELDOWN, 0, false);
608 if (MessageBox (mainwindow, "Are you sure you want to quit?", "Confirm Exit", MB_YESNO | MB_SETFOREGROUND | MB_ICONQUESTION) == IDYES)
614 fActive = LOWORD(wParam);
615 fMinimized = (BOOL) HIWORD(wParam);
616 AppActivate(!(fActive == WA_INACTIVE), fMinimized);
618 // fix the leftover Alt from any Alt-Tab or the like that switched us away
624 // PostQuitMessage (0);
628 lRet = CDAudio_MessageHandler (hWnd, uMsg, wParam, lParam);
632 /* pass all unhandled messages to DefWindowProc */
633 lRet = DefWindowProc (hWnd, uMsg, wParam, lParam);
637 /* return 1 if handled message, 0 if not */
641 int VID_SetGamma(unsigned short *ramps)
643 HDC hdc = GetDC (NULL);
644 int i = SetDeviceGammaRamp(hdc, ramps);
645 ReleaseDC (NULL, hdc);
646 return i; // return success or failure
649 int VID_GetGamma(unsigned short *ramps)
651 HDC hdc = GetDC (NULL);
652 int i = GetDeviceGammaRamp(hdc, ramps);
653 ReleaseDC (NULL, hdc);
654 return i; // return success or failure
657 static HINSTANCE gldll;
659 int GL_OpenLibrary(const char *name)
661 Con_Printf("Loading OpenGL driver %s\n", name);
663 if (!(gldll = LoadLibrary(name)))
665 Con_Printf("Unable to LoadLibrary %s\n", name);
668 strcpy(gl_driver, name);
672 void GL_CloseLibrary(void)
677 qwglGetProcAddress = NULL;
680 gl_platformextensions = "";
683 void *GL_GetProcAddress(const char *name)
686 if (qwglGetProcAddress != NULL)
687 p = (void *) qwglGetProcAddress(name);
689 p = (void *) GetProcAddress(gldll, name);
693 static void IN_Init(void);
698 InitCommonControls();
699 hIcon = LoadIcon (global_hInstance, MAKEINTRESOURCE (IDI_ICON2));
701 // Register the frame class
703 wc.lpfnWndProc = (WNDPROC)MainWndProc;
706 wc.hInstance = global_hInstance;
708 wc.hCursor = LoadCursor (NULL,IDC_ARROW);
709 wc.hbrBackground = NULL;
711 wc.lpszClassName = "DarkPlacesWindowClass";
713 if (!RegisterClass (&wc))
714 Sys_Error("Couldn't register window class\n");
719 int VID_InitMode (int fullscreen, int width, int height, int bpp)
725 PIXELFORMATDESCRIPTOR pfd =
727 sizeof(PIXELFORMATDESCRIPTOR), // size of this pfd
729 PFD_DRAW_TO_WINDOW // support window
730 | PFD_SUPPORT_OPENGL // support OpenGL
731 | PFD_DOUBLEBUFFER , // double buffered
732 PFD_TYPE_RGBA, // RGBA type
733 24, // 24-bit color depth
734 0, 0, 0, 0, 0, 0, // color bits ignored
735 0, // no alpha buffer
736 0, // shift bit ignored
737 0, // no accumulation buffer
738 0, 0, 0, 0, // accum bits ignored
739 32, // 32-bit z-buffer
740 0, // no stencil buffer
741 0, // no auxiliary buffer
742 PFD_MAIN_PLANE, // main layer
744 0, 0, 0 // layer masks ignored
747 DWORD WindowStyle, ExWindowStyle;
749 int CenterX, CenterY;
750 const char *gldrivername;
753 Sys_Error("VID_InitMode called when video is already initialised\n");
755 // if stencil is enabled, ask for alpha too
758 pfd.cStencilBits = 8;
763 pfd.cStencilBits = 0;
767 gldrivername = "opengl32.dll";
768 i = COM_CheckParm("-gl_driver");
769 if (i && i < com_argc - 1)
770 gldrivername = com_argv[i + 1];
771 if (!GL_OpenLibrary(gldrivername))
773 Con_Printf("Unable to load GL driver %s\n", gldrivername);
777 memset(&gdevmode, 0, sizeof(gdevmode));
779 vid_isfullscreen = false;
782 gdevmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
783 gdevmode.dmBitsPerPel = bpp;
784 gdevmode.dmPelsWidth = width;
785 gdevmode.dmPelsHeight = height;
786 gdevmode.dmSize = sizeof (gdevmode);
787 if (ChangeDisplaySettings (&gdevmode, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
790 Con_Printf("Unable to change to requested mode %dx%dx%dbpp\n", width, height, bpp);
794 vid_isfullscreen = true;
795 WindowStyle = WS_POPUP;
796 ExWindowStyle = WS_EX_TOPMOST;
801 i = GetDeviceCaps(hdc, RASTERCAPS);
802 ReleaseDC (NULL, hdc);
806 Con_Printf ("Can't run in non-RGB mode\n");
810 WindowStyle = WS_OVERLAPPED | WS_BORDER | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX;
817 rect.bottom = height;
818 AdjustWindowRectEx(&rect, WindowStyle, false, 0);
827 CenterX = (GetSystemMetrics(SM_CXSCREEN) - (rect.right - rect.left)) / 2;
828 CenterY = (GetSystemMetrics(SM_CYSCREEN) - (rect.bottom - rect.top)) / 2;
830 CenterX = max(0, CenterX);
831 CenterY = max(0, CenterY);
833 // x and y may be changed by WM_MOVE messages
836 window_width = width;
837 window_height = height;
838 rect.left += CenterX;
839 rect.right += CenterX;
841 rect.bottom += CenterY;
843 mainwindow = CreateWindowEx (ExWindowStyle, "DarkPlacesWindowClass", gamename, WindowStyle, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, NULL, NULL, global_hInstance, NULL);
846 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);
853 SetWindowPos (mainwindow, NULL, CenterX, CenterY, 0, 0,SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW | SWP_DRAWFRAME);
856 ShowWindow (mainwindow, SW_SHOWDEFAULT);
857 UpdateWindow (mainwindow);
859 SendMessage (mainwindow, WM_SETICON, (WPARAM)true, (LPARAM)hIcon);
860 SendMessage (mainwindow, WM_SETICON, (WPARAM)false, (LPARAM)hIcon);
862 VID_UpdateWindowStatus ();
864 // now we try to make sure we get the focus on the mode switch, because
865 // sometimes in some systems we don't. We grab the foreground, then
866 // finish setting up, pump all our messages, and sleep for a little while
867 // to let messages finish bouncing around the system, then we put
868 // ourselves at the top of the z order, then grab the foreground again,
869 // Who knows if it helps, but it probably doesn't hurt
870 SetForegroundWindow (mainwindow);
872 while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
874 TranslateMessage (&msg);
875 DispatchMessage (&msg);
880 SetWindowPos (mainwindow, HWND_TOP, 0, 0, 0, 0, SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW | SWP_NOCOPYBITS);
882 SetForegroundWindow (mainwindow);
884 // fix the leftover Alt from any Alt-Tab or the like that switched us away
887 hdc = GetDC(mainwindow);
889 if ((pixelformat = ChoosePixelFormat(hdc, &pfd)) == 0)
892 Con_Printf("ChoosePixelFormat(%d, %p) failed\n", hdc, &pfd);
896 if (SetPixelFormat(hdc, pixelformat, &pfd) == false)
899 Con_Printf("SetPixelFormat(%d, %d, %p) failed\n", hdc, pixelformat, &pfd);
903 if (!GL_CheckExtension("wgl", wglfuncs, NULL, false))
906 Con_Printf("wgl functions not found\n");
910 baseRC = qwglCreateContext(hdc);
914 Con_Printf("Could not initialize GL (wglCreateContext failed).\n\nMake sure you are in 65536 color mode, and try running -window.\n");
917 if (!qwglMakeCurrent(hdc, baseRC))
920 Con_Printf("wglMakeCurrent(%d, %d) failed\n", hdc, baseRC);
924 qglGetString = GL_GetProcAddress("glGetString");
925 qwglGetExtensionsStringARB = GL_GetProcAddress("wglGetExtensionsStringARB");
926 if (qglGetString == NULL)
929 Con_Printf("glGetString not found\n");
932 gl_renderer = qglGetString(GL_RENDERER);
933 gl_vendor = qglGetString(GL_VENDOR);
934 gl_version = qglGetString(GL_VERSION);
935 gl_extensions = qglGetString(GL_EXTENSIONS);
937 gl_platformextensions = "";
939 if (qwglGetExtensionsStringARB)
940 gl_platformextensions = qwglGetExtensionsStringARB(hdc);
942 gl_videosyncavailable = GL_CheckExtension("WGL_EXT_swap_control", wglswapintervalfuncs, NULL, false);
943 ReleaseDC(mainwindow, hdc);
947 // LordHavoc: special differences for ATI (broken 8bit color when also using 32bit? weird!)
948 if (strncasecmp(gl_vendor,"ATI",3)==0)
950 if (strncasecmp(gl_renderer,"Rage Pro",8)==0)
953 if (strncasecmp(gl_renderer,"Matrox G200 Direct3D",20)==0) // a D3D driver for GL? sigh...
956 //vid_menudrawfn = VID_MenuDraw;
957 //vid_menukeyfn = VID_MenuKey;
959 vid_initialized = true;
962 IN_StartupJoystick ();
967 static void IN_Shutdown(void);
968 void VID_Shutdown (void)
973 if(vid_initialized == false)
976 VID_RestoreSystemGamma();
978 vid_initialized = false;
980 if (qwglGetCurrentContext)
981 hRC = qwglGetCurrentContext();
982 if (qwglGetCurrentDC)
983 hDC = qwglGetCurrentDC();
985 qwglMakeCurrent(NULL, NULL);
986 if (hRC && qwglDeleteContext)
987 qwglDeleteContext(hRC);
988 // close the library before we get rid of the window
990 if (hDC && mainwindow)
991 ReleaseDC(mainwindow, hDC);
992 AppActivate(false, false);
994 DestroyWindow(mainwindow);
996 if (vid_isfullscreen)
997 ChangeDisplaySettings (NULL, 0);
998 vid_isfullscreen = false;
1007 void IN_ShowMouse (void)
1009 if (!mouseshowtoggle)
1012 mouseshowtoggle = 1;
1022 void IN_HideMouse (void)
1024 if (mouseshowtoggle)
1027 mouseshowtoggle = 0;
1037 void IN_ActivateMouse (void)
1040 mouseactivatetoggle = true;
1042 if (mouseinitialized)
1048 if (!dinput_acquired)
1050 IDirectInputDevice_Acquire(g_pMouse);
1051 dinput_acquired = true;
1062 window_rect.left = window_x;
1063 window_rect.top = window_y;
1064 window_rect.right = window_x + window_width;
1065 window_rect.bottom = window_y + window_height;
1067 if (mouseparmsvalid)
1068 restore_spi = SystemParametersInfo (SPI_SETMOUSE, 0, newmouseparms, 0);
1070 SetCursorPos (window_center_x, window_center_y);
1071 SetCapture (mainwindow);
1072 ClipCursor (&window_rect);
1085 void IN_DeactivateMouse (void)
1088 mouseactivatetoggle = false;
1090 if (mouseinitialized)
1096 if (dinput_acquired)
1098 IDirectInputDevice_Unacquire(g_pMouse);
1099 dinput_acquired = false;
1106 SystemParametersInfo (SPI_SETMOUSE, 0, originalmouseparms, 0);
1112 mouseactive = false;
1122 qboolean IN_InitDInput (void)
1125 DIPROPDWORD dipdw = {
1127 sizeof(DIPROPDWORD), // diph.dwSize
1128 sizeof(DIPROPHEADER), // diph.dwHeaderSize
1130 DIPH_DEVICE, // diph.dwHow
1132 DINPUT_BUFFERSIZE, // dwData
1137 hInstDI = LoadLibrary("dinput.dll");
1139 if (hInstDI == NULL)
1141 Con_SafePrintf ("Couldn't load dinput.dll\n");
1146 if (!pDirectInputCreate)
1148 pDirectInputCreate = (void *)GetProcAddress(hInstDI,"DirectInputCreateA");
1150 if (!pDirectInputCreate)
1152 Con_SafePrintf ("Couldn't get DI proc addr\n");
1157 // register with DirectInput and get an IDirectInput to play with.
1158 hr = iDirectInputCreate(global_hInstance, DIRECTINPUT_VERSION, &g_pdi, NULL);
1165 // obtain an interface to the system mouse device.
1166 hr = IDirectInput_CreateDevice(g_pdi, &GUID_SysMouse, &g_pMouse, NULL);
1170 Con_SafePrintf ("Couldn't open DI mouse device\n");
1174 // set the data format to "mouse format".
1175 hr = IDirectInputDevice_SetDataFormat(g_pMouse, &df);
1179 Con_SafePrintf ("Couldn't set DI mouse format\n");
1183 // set the cooperativity level.
1184 hr = IDirectInputDevice_SetCooperativeLevel(g_pMouse, mainwindow,
1185 DISCL_EXCLUSIVE | DISCL_FOREGROUND);
1189 Con_SafePrintf ("Couldn't set DI coop level\n");
1194 // set the buffer size to DINPUT_BUFFERSIZE elements.
1195 // the buffer size is a DWORD property associated with the device
1196 hr = IDirectInputDevice_SetProperty(g_pMouse, DIPROP_BUFFERSIZE, &dipdw.diph);
1200 Con_SafePrintf ("Couldn't set DI buffersize\n");
1213 void IN_StartupMouse (void)
1215 if (COM_CheckParm ("-nomouse") || COM_CheckParm("-safe"))
1218 mouseinitialized = true;
1220 if (COM_CheckParm ("-dinput"))
1222 dinput = IN_InitDInput ();
1226 Con_SafePrintf ("DirectInput initialized\n");
1230 Con_SafePrintf ("DirectInput not initialized\n");
1236 mouseparmsvalid = SystemParametersInfo (SPI_GETMOUSE, 0, originalmouseparms, 0);
1238 if (mouseparmsvalid)
1240 if ( COM_CheckParm ("-noforcemspd") )
1241 newmouseparms[2] = originalmouseparms[2];
1243 if ( COM_CheckParm ("-noforcemaccel") )
1245 newmouseparms[0] = originalmouseparms[0];
1246 newmouseparms[1] = originalmouseparms[1];
1249 if ( COM_CheckParm ("-noforcemparms") )
1251 newmouseparms[0] = originalmouseparms[0];
1252 newmouseparms[1] = originalmouseparms[1];
1253 newmouseparms[2] = originalmouseparms[2];
1260 // if a fullscreen video mode was set before the mouse was initialized,
1261 // set the mouse state appropriately
1262 if (mouseactivatetoggle)
1263 IN_ActivateMouse ();
1272 void IN_MouseEvent (int mstate)
1276 if (mouseactive && !dinput)
1278 // perform button actions
1279 for (i=0 ; i<mouse_buttons ; i++)
1281 if ( (mstate & (1<<i)) &&
1282 !(mouse_oldbuttonstate & (1<<i)) )
1284 Key_Event (K_MOUSE1 + i, 0, true);
1287 if ( !(mstate & (1<<i)) &&
1288 (mouse_oldbuttonstate & (1<<i)) )
1290 Key_Event (K_MOUSE1 + i, 0, false);
1294 mouse_oldbuttonstate = mstate;
1304 void IN_MouseMove (usercmd_t *cmd)
1307 DIDEVICEOBJECTDATA od;
1313 GetCursorPos (¤t_pos);
1314 //ui_mouseupdate(current_pos.x - window_x, current_pos.y - window_y);
1315 in_mouse_x = in_mouse_y = 0;
1328 hr = IDirectInputDevice_GetDeviceData(g_pMouse,
1329 sizeof(DIDEVICEOBJECTDATA), &od, &dwElements, 0);
1331 if ((hr == DIERR_INPUTLOST) || (hr == DIERR_NOTACQUIRED))
1333 dinput_acquired = true;
1334 IDirectInputDevice_Acquire(g_pMouse);
1338 /* Unable to read data or no data available */
1339 if (FAILED(hr) || dwElements == 0)
1342 /* Look at the element to see what happened */
1354 case DIMOFS_BUTTON0:
1355 if (od.dwData & 0x80)
1361 case DIMOFS_BUTTON1:
1362 if (od.dwData & 0x80)
1363 mstate_di |= (1<<1);
1365 mstate_di &= ~(1<<1);
1368 case DIMOFS_BUTTON2:
1369 if (od.dwData & 0x80)
1370 mstate_di |= (1<<2);
1372 mstate_di &= ~(1<<2);
1377 // perform button actions
1378 for (i=0 ; i<mouse_buttons ; i++)
1380 if ( (mstate_di & (1<<i)) &&
1381 !(mouse_oldbuttonstate & (1<<i)) )
1383 Key_Event (K_MOUSE1 + i, 0, true);
1386 if ( !(mstate_di & (1<<i)) &&
1387 (mouse_oldbuttonstate & (1<<i)) )
1389 Key_Event (K_MOUSE1 + i, 0, false);
1393 mouse_oldbuttonstate = mstate_di;
1397 GetCursorPos (¤t_pos);
1398 mx = current_pos.x - window_center_x + mx_accum;
1399 my = current_pos.y - window_center_y + my_accum;
1404 IN_Mouse(cmd, mx, my);
1406 // if the mouse has moved, force it to the center, so there's room to move
1407 if (!dinput && (mx || my))
1408 SetCursorPos (window_center_x, window_center_y);
1417 void IN_Move (usercmd_t *cmd)
1419 if (vid_activewindow && !vid_hidden)
1432 void IN_Accumulate (void)
1438 GetCursorPos (¤t_pos);
1440 mx_accum += current_pos.x - window_center_x;
1441 my_accum += current_pos.y - window_center_y;
1443 // force the mouse to the center, so there's room to move
1444 SetCursorPos (window_center_x, window_center_y);
1455 void IN_ClearStates (void)
1461 mouse_oldbuttonstate = 0;
1471 void IN_StartupJoystick (void)
1478 // assume no joystick
1481 // abort startup if user requests no joystick
1482 if (COM_CheckParm ("-nojoy") || COM_CheckParm("-safe"))
1485 // verify joystick driver is present
1486 if ((numdevs = joyGetNumDevs ()) == 0)
1488 Con_Printf ("\njoystick not found -- driver not present\n\n");
1492 // cycle through the joystick ids for the first valid one
1493 for (joy_id=0 ; joy_id<numdevs ; joy_id++)
1495 memset (&ji, 0, sizeof(ji));
1496 ji.dwSize = sizeof(ji);
1497 ji.dwFlags = JOY_RETURNCENTERED;
1499 if ((mmr = joyGetPosEx (joy_id, &ji)) == JOYERR_NOERROR)
1503 // abort startup if we didn't find a valid joystick
1504 if (mmr != JOYERR_NOERROR)
1506 Con_Printf ("\njoystick not found -- no valid joysticks (%x)\n\n", mmr);
1510 // get the capabilities of the selected joystick
1511 // abort startup if command fails
1512 memset (&jc, 0, sizeof(jc));
1513 if ((mmr = joyGetDevCaps (joy_id, &jc, sizeof(jc))) != JOYERR_NOERROR)
1515 Con_Printf ("\njoystick not found -- invalid joystick capabilities (%x)\n\n", mmr);
1519 // save the joystick's number of buttons and POV status
1520 joy_numbuttons = jc.wNumButtons;
1521 joy_haspov = jc.wCaps & JOYCAPS_HASPOV;
1523 // old button and POV states default to no buttons pressed
1524 joy_oldbuttonstate = joy_oldpovstate = 0;
1526 // mark the joystick as available and advanced initialization not completed
1527 // this is needed as cvars are not available during initialization
1530 joy_advancedinit = false;
1532 Con_Printf ("\njoystick detected\n\n");
1541 PDWORD RawValuePointer (int axis)
1558 return NULL; // LordHavoc: hush compiler warning
1564 Joy_AdvancedUpdate_f
1567 void Joy_AdvancedUpdate_f (void)
1570 // called once by IN_ReadJoystick and by user whenever an update is needed
1571 // cvars are now available
1575 // initialize all the maps
1576 for (i = 0; i < JOY_MAX_AXES; i++)
1578 dwAxisMap[i] = AxisNada;
1579 dwControlMap[i] = JOY_ABSOLUTE_AXIS;
1580 pdwRawValue[i] = RawValuePointer(i);
1583 if( joy_advanced.integer == 0)
1585 // default joystick initialization
1586 // 2 axes only with joystick control
1587 dwAxisMap[JOY_AXIS_X] = AxisTurn;
1588 // dwControlMap[JOY_AXIS_X] = JOY_ABSOLUTE_AXIS;
1589 dwAxisMap[JOY_AXIS_Y] = AxisForward;
1590 // dwControlMap[JOY_AXIS_Y] = JOY_ABSOLUTE_AXIS;
1594 if (strcmp (joy_name.string, "joystick") != 0)
1596 // notify user of advanced controller
1597 Con_Printf ("\n%s configured\n\n", joy_name.string);
1600 // advanced initialization here
1601 // data supplied by user via joy_axisn cvars
1602 dwTemp = (DWORD) joy_advaxisx.value;
1603 dwAxisMap[JOY_AXIS_X] = dwTemp & 0x0000000f;
1604 dwControlMap[JOY_AXIS_X] = dwTemp & JOY_RELATIVE_AXIS;
1605 dwTemp = (DWORD) joy_advaxisy.value;
1606 dwAxisMap[JOY_AXIS_Y] = dwTemp & 0x0000000f;
1607 dwControlMap[JOY_AXIS_Y] = dwTemp & JOY_RELATIVE_AXIS;
1608 dwTemp = (DWORD) joy_advaxisz.value;
1609 dwAxisMap[JOY_AXIS_Z] = dwTemp & 0x0000000f;
1610 dwControlMap[JOY_AXIS_Z] = dwTemp & JOY_RELATIVE_AXIS;
1611 dwTemp = (DWORD) joy_advaxisr.value;
1612 dwAxisMap[JOY_AXIS_R] = dwTemp & 0x0000000f;
1613 dwControlMap[JOY_AXIS_R] = dwTemp & JOY_RELATIVE_AXIS;
1614 dwTemp = (DWORD) joy_advaxisu.value;
1615 dwAxisMap[JOY_AXIS_U] = dwTemp & 0x0000000f;
1616 dwControlMap[JOY_AXIS_U] = dwTemp & JOY_RELATIVE_AXIS;
1617 dwTemp = (DWORD) joy_advaxisv.value;
1618 dwAxisMap[JOY_AXIS_V] = dwTemp & 0x0000000f;
1619 dwControlMap[JOY_AXIS_V] = dwTemp & JOY_RELATIVE_AXIS;
1622 // compute the axes to collect from DirectInput
1623 joy_flags = JOY_RETURNCENTERED | JOY_RETURNBUTTONS | JOY_RETURNPOV;
1624 for (i = 0; i < JOY_MAX_AXES; i++)
1626 if (dwAxisMap[i] != AxisNada)
1628 joy_flags |= dwAxisFlags[i];
1638 void IN_Commands (void)
1641 DWORD buttonstate, povstate;
1649 // loop through the joystick buttons
1650 // key a joystick event or auxillary event for higher number buttons for each state change
1651 buttonstate = ji.dwButtons;
1652 for (i=0 ; i < (int) joy_numbuttons ; i++)
1654 if ( (buttonstate & (1<<i)) && !(joy_oldbuttonstate & (1<<i)) )
1656 key_index = (i < 4) ? K_JOY1 : K_AUX1;
1657 Key_Event (key_index + i, 0, true);
1660 if ( !(buttonstate & (1<<i)) && (joy_oldbuttonstate & (1<<i)) )
1662 key_index = (i < 4) ? K_JOY1 : K_AUX1;
1663 Key_Event (key_index + i, 0, false);
1666 joy_oldbuttonstate = buttonstate;
1670 // convert POV information into 4 bits of state information
1671 // this avoids any potential problems related to moving from one
1672 // direction to another without going through the center position
1674 if(ji.dwPOV != JOY_POVCENTERED)
1676 if (ji.dwPOV == JOY_POVFORWARD)
1678 if (ji.dwPOV == JOY_POVRIGHT)
1680 if (ji.dwPOV == JOY_POVBACKWARD)
1682 if (ji.dwPOV == JOY_POVLEFT)
1685 // determine which bits have changed and key an auxillary event for each change
1686 for (i=0 ; i < 4 ; i++)
1688 if ( (povstate & (1<<i)) && !(joy_oldpovstate & (1<<i)) )
1690 Key_Event (K_AUX29 + i, 0, true);
1693 if ( !(povstate & (1<<i)) && (joy_oldpovstate & (1<<i)) )
1695 Key_Event (K_AUX29 + i, 0, false);
1698 joy_oldpovstate = povstate;
1708 qboolean IN_ReadJoystick (void)
1711 memset (&ji, 0, sizeof(ji));
1712 ji.dwSize = sizeof(ji);
1713 ji.dwFlags = joy_flags;
1715 if (joyGetPosEx (joy_id, &ji) == JOYERR_NOERROR)
1717 // this is a hack -- there is a bug in the Logitech WingMan Warrior DirectInput Driver
1718 // rather than having 32768 be the zero point, they have the zero point at 32668
1719 // go figure -- anyway, now we get the full resolution out of the device
1720 if (joy_wwhack1.integer != 0.0)
1728 // read error occurred
1729 // turning off the joystick seems too harsh for 1 read error,
1730 // but what should be done?
1741 void IN_JoyMove (usercmd_t *cmd)
1743 float speed, aspeed;
1744 float fAxisValue, fTemp;
1745 int i, mouselook = (in_mlook.state & 1) || freelook.integer;
1747 // complete initialization if first time in
1748 // this is needed as cvars are not available at initialization time
1749 if( joy_advancedinit != true )
1751 Joy_AdvancedUpdate_f();
1752 joy_advancedinit = true;
1755 // verify joystick is available and that the user wants to use it
1756 if (!joy_avail || !in_joystick.integer)
1761 // collect the joystick data, if possible
1762 if (IN_ReadJoystick () != true)
1767 if (in_speed.state & 1)
1768 speed = cl_movespeedkey.value;
1771 // LordHavoc: viewzoom affects sensitivity for sniping
1772 aspeed = speed * host_realframetime * cl.viewzoom;
1774 // loop through the axes
1775 for (i = 0; i < JOY_MAX_AXES; i++)
1777 // get the floating point zero-centered, potentially-inverted data for the current axis
1778 fAxisValue = (float) *pdwRawValue[i];
1779 // move centerpoint to zero
1780 fAxisValue -= 32768.0;
1782 if (joy_wwhack2.integer != 0.0)
1784 if (dwAxisMap[i] == AxisTurn)
1786 // this is a special formula for the Logitech WingMan Warrior
1787 // y=ax^b; where a = 300 and b = 1.3
1788 // also x values are in increments of 800 (so this is factored out)
1789 // then bounds check result to level out excessively high spin rates
1790 fTemp = 300.0 * pow(abs(fAxisValue) / 800.0, 1.3);
1791 if (fTemp > 14000.0)
1793 // restore direction information
1794 fAxisValue = (fAxisValue > 0.0) ? fTemp : -fTemp;
1798 // convert range from -32768..32767 to -1..1
1799 fAxisValue /= 32768.0;
1801 switch (dwAxisMap[i])
1804 if ((joy_advanced.integer == 0) && mouselook)
1806 // user wants forward control to become look control
1807 if (fabs(fAxisValue) > joy_pitchthreshold.value)
1809 // if mouse invert is on, invert the joystick pitch value
1810 // only absolute control support here (joy_advanced is false)
1811 if (m_pitch.value < 0.0)
1813 cl.viewangles[PITCH] -= (fAxisValue * joy_pitchsensitivity.value) * aspeed * cl_pitchspeed.value;
1817 cl.viewangles[PITCH] += (fAxisValue * joy_pitchsensitivity.value) * aspeed * cl_pitchspeed.value;
1823 // no pitch movement
1824 // disable pitch return-to-center unless requested by user
1825 // *** this code can be removed when the lookspring bug is fixed
1826 // *** the bug always has the lookspring feature on
1827 if(lookspring.value == 0.0)
1833 // user wants forward control to be forward control
1834 if (fabs(fAxisValue) > joy_forwardthreshold.value)
1836 cmd->forwardmove += (fAxisValue * joy_forwardsensitivity.value) * speed * cl_forwardspeed.value;
1842 if (fabs(fAxisValue) > joy_sidethreshold.value)
1844 cmd->sidemove += (fAxisValue * joy_sidesensitivity.value) * speed * cl_sidespeed.value;
1849 if ((in_strafe.state & 1) || (lookstrafe.integer && mouselook))
1851 // user wants turn control to become side control
1852 if (fabs(fAxisValue) > joy_sidethreshold.value)
1854 cmd->sidemove -= (fAxisValue * joy_sidesensitivity.value) * speed * cl_sidespeed.value;
1859 // user wants turn control to be turn control
1860 if (fabs(fAxisValue) > joy_yawthreshold.value)
1862 if(dwControlMap[i] == JOY_ABSOLUTE_AXIS)
1864 cl.viewangles[YAW] += (fAxisValue * joy_yawsensitivity.value) * aspeed * cl_yawspeed.value;
1868 cl.viewangles[YAW] += (fAxisValue * joy_yawsensitivity.value) * speed * 180.0;
1878 if (fabs(fAxisValue) > joy_pitchthreshold.value)
1880 // pitch movement detected and pitch movement desired by user
1881 if(dwControlMap[i] == JOY_ABSOLUTE_AXIS)
1883 cl.viewangles[PITCH] += (fAxisValue * joy_pitchsensitivity.value) * aspeed * cl_pitchspeed.value;
1887 cl.viewangles[PITCH] += (fAxisValue * joy_pitchsensitivity.value) * speed * 180.0;
1893 // no pitch movement
1894 // disable pitch return-to-center unless requested by user
1895 // *** this code can be removed when the lookspring bug is fixed
1896 // *** the bug always has the lookspring feature on
1897 if(lookspring.integer == 0)
1909 static void IN_Init(void)
1911 uiWheelMessage = RegisterWindowMessage ( "MSWHEEL_ROLLMSG" );
1913 // joystick variables
1914 Cvar_RegisterVariable (&in_joystick);
1915 Cvar_RegisterVariable (&joy_name);
1916 Cvar_RegisterVariable (&joy_advanced);
1917 Cvar_RegisterVariable (&joy_advaxisx);
1918 Cvar_RegisterVariable (&joy_advaxisy);
1919 Cvar_RegisterVariable (&joy_advaxisz);
1920 Cvar_RegisterVariable (&joy_advaxisr);
1921 Cvar_RegisterVariable (&joy_advaxisu);
1922 Cvar_RegisterVariable (&joy_advaxisv);
1923 Cvar_RegisterVariable (&joy_forwardthreshold);
1924 Cvar_RegisterVariable (&joy_sidethreshold);
1925 Cvar_RegisterVariable (&joy_pitchthreshold);
1926 Cvar_RegisterVariable (&joy_yawthreshold);
1927 Cvar_RegisterVariable (&joy_forwardsensitivity);
1928 Cvar_RegisterVariable (&joy_sidesensitivity);
1929 Cvar_RegisterVariable (&joy_pitchsensitivity);
1930 Cvar_RegisterVariable (&joy_yawsensitivity);
1931 Cvar_RegisterVariable (&joy_wwhack1);
1932 Cvar_RegisterVariable (&joy_wwhack2);
1933 Cmd_AddCommand ("joyadvancedupdate", Joy_AdvancedUpdate_f);
1936 static void IN_Shutdown(void)
1938 IN_DeactivateMouse ();
1942 IDirectInputDevice_Release(g_pMouse);
1946 IDirectInput_Release(g_pdi);