- }
- gl_renderer = qglGetString(GL_RENDERER);
- gl_vendor = qglGetString(GL_VENDOR);
- gl_version = qglGetString(GL_VERSION);
- gl_extensions = qglGetString(GL_EXTENSIONS);
- gl_platform = "WGL";
- gl_platformextensions = "";
-
- if (qwglGetExtensionsStringARB)
- gl_platformextensions = qwglGetExtensionsStringARB(hdc);
-
- gl_videosyncavailable = GL_CheckExtension("WGL_EXT_swap_control", wglswapintervalfuncs, NULL, false);
- ReleaseDC(mainwindow, hdc);
-
- GL_Init ();
-
- // LordHavoc: special differences for ATI (broken 8bit color when also using 32bit? weird!)
- if (strncasecmp(gl_vendor,"ATI",3)==0)
- {
- if (strncasecmp(gl_renderer,"Rage Pro",8)==0)
- isRagePro = true;
- }
- if (strncasecmp(gl_renderer,"Matrox G200 Direct3D",20)==0) // a D3D driver for GL? sigh...
- isG200 = true;
-
- //vid_menudrawfn = VID_MenuDraw;
- //vid_menukeyfn = VID_MenuKey;
- vid_hidden = false;
- vid_initialized = true;
-
- IN_StartupMouse ();
- IN_StartupJoystick ();
-
- return true;
-}
-
-void VID_Shutdown (void)
-{
- HGLRC hRC = 0;
- HDC hDC = 0;
-
- if (vid_initialized)
- {
- vid_initialized = false;
-
- IN_DeactivateMouse ();
- IN_ShowMouse ();
-
- if (g_pMouse)
- IDirectInputDevice_Release(g_pMouse);
- g_pMouse = NULL;
-
- if (g_pdi)
- IDirectInput_Release(g_pdi);
- g_pdi = NULL;
-
- if (qwglGetCurrentContext)
- hRC = qwglGetCurrentContext();
-
- if (qwglGetCurrentDC)
- hDC = qwglGetCurrentDC();
-
- if (qwglMakeCurrent)
- qwglMakeCurrent(NULL, NULL);
-
- if (hRC && qwglDeleteContext)
- qwglDeleteContext(hRC);
-
- // close the library before we get rid of the window
- GL_CloseLibrary();
-
- if (hDC && mainwindow)
- ReleaseDC(mainwindow, hDC);
-
- if (vid_isfullscreen)
- ChangeDisplaySettings (NULL, 0);
-
- AppActivate(false, false);
-
- VID_RestoreSystemGamma();
- }
-}
-
-
-// input code
-
-#include <dinput.h>
-
-#define DINPUT_BUFFERSIZE 16
-#define iDirectInputCreate(a,b,c,d) pDirectInputCreate(a,b,c,d)
-
-HRESULT (WINAPI *pDirectInputCreate)(HINSTANCE hinst, DWORD dwVersion,
- LPDIRECTINPUT * lplpDirectInput, LPUNKNOWN punkOuter);
-
-// mouse variables
-int mouse_buttons;
-int mouse_oldbuttonstate;
-POINT current_pos;
-int mouse_x, mouse_y, old_mouse_x, old_mouse_y, mx_accum, my_accum;
-
-static qboolean restore_spi;
-static int originalmouseparms[3], newmouseparms[3] = {0, 0, 1};
-
-unsigned int uiWheelMessage;
-qboolean mouseactive;
-//qboolean mouseinitialized;
-static qboolean mouseparmsvalid, mouseactivatetoggle;
-static qboolean mouseshowtoggle = 1;
-static qboolean dinput_acquired;
-
-static unsigned int mstate_di;
-
-// joystick defines and variables
-// where should defines be moved?
-#define JOY_ABSOLUTE_AXIS 0x00000000 // control like a joystick
-#define JOY_RELATIVE_AXIS 0x00000010 // control like a mouse, spinner, trackball
-#define JOY_MAX_AXES 6 // X, Y, Z, R, U, V
-#define JOY_AXIS_X 0
-#define JOY_AXIS_Y 1
-#define JOY_AXIS_Z 2
-#define JOY_AXIS_R 3
-#define JOY_AXIS_U 4
-#define JOY_AXIS_V 5
-
-enum _ControlList
-{
- AxisNada = 0, AxisForward, AxisLook, AxisSide, AxisTurn
-};
-
-DWORD dwAxisFlags[JOY_MAX_AXES] =
-{
- JOY_RETURNX, JOY_RETURNY, JOY_RETURNZ, JOY_RETURNR, JOY_RETURNU, JOY_RETURNV
-};
-
-DWORD dwAxisMap[JOY_MAX_AXES];
-DWORD dwControlMap[JOY_MAX_AXES];
-PDWORD pdwRawValue[JOY_MAX_AXES];
-
-// none of these cvars are saved over a session
-// this means that advanced controller configuration needs to be executed
-// each time. this avoids any problems with getting back to a default usage
-// or when changing from one controller to another. this way at least something
-// works.
-cvar_t in_joystick = {CVAR_SAVE, "joystick","0"};
-cvar_t joy_name = {0, "joyname", "joystick"};
-cvar_t joy_advanced = {0, "joyadvanced", "0"};
-cvar_t joy_advaxisx = {0, "joyadvaxisx", "0"};
-cvar_t joy_advaxisy = {0, "joyadvaxisy", "0"};
-cvar_t joy_advaxisz = {0, "joyadvaxisz", "0"};
-cvar_t joy_advaxisr = {0, "joyadvaxisr", "0"};
-cvar_t joy_advaxisu = {0, "joyadvaxisu", "0"};
-cvar_t joy_advaxisv = {0, "joyadvaxisv", "0"};
-cvar_t joy_forwardthreshold = {0, "joyforwardthreshold", "0.15"};
-cvar_t joy_sidethreshold = {0, "joysidethreshold", "0.15"};
-cvar_t joy_pitchthreshold = {0, "joypitchthreshold", "0.15"};
-cvar_t joy_yawthreshold = {0, "joyyawthreshold", "0.15"};
-cvar_t joy_forwardsensitivity = {0, "joyforwardsensitivity", "-1.0"};
-cvar_t joy_sidesensitivity = {0, "joysidesensitivity", "-1.0"};
-cvar_t joy_pitchsensitivity = {0, "joypitchsensitivity", "1.0"};
-cvar_t joy_yawsensitivity = {0, "joyyawsensitivity", "-1.0"};
-cvar_t joy_wwhack1 = {0, "joywwhack1", "0.0"};
-cvar_t joy_wwhack2 = {0, "joywwhack2", "0.0"};
-
-qboolean joy_avail, joy_advancedinit, joy_haspov;
-DWORD joy_oldbuttonstate, joy_oldpovstate;
-
-int joy_id;
-DWORD joy_flags;
-DWORD joy_numbuttons;
-
-static LPDIRECTINPUT g_pdi;
-static LPDIRECTINPUTDEVICE g_pMouse;
-
-static JOYINFOEX ji;
-
-static HINSTANCE hInstDI;
-
-//static qboolean dinput;
-
-typedef struct MYDATA {
- LONG lX; // X axis goes here
- LONG lY; // Y axis goes here
- LONG lZ; // Z axis goes here
- BYTE bButtonA; // One button goes here
- BYTE bButtonB; // Another button goes here
- BYTE bButtonC; // Another button goes here
- BYTE bButtonD; // Another button goes here
-} MYDATA;
-
-static DIOBJECTDATAFORMAT rgodf[] = {
- { &GUID_XAxis, FIELD_OFFSET(MYDATA, lX), DIDFT_AXIS | DIDFT_ANYINSTANCE, 0,},
- { &GUID_YAxis, FIELD_OFFSET(MYDATA, lY), DIDFT_AXIS | DIDFT_ANYINSTANCE, 0,},
- { &GUID_ZAxis, FIELD_OFFSET(MYDATA, lZ), 0x80000000 | DIDFT_AXIS | DIDFT_ANYINSTANCE, 0,},
- { 0, FIELD_OFFSET(MYDATA, bButtonA), DIDFT_BUTTON | DIDFT_ANYINSTANCE, 0,},
- { 0, FIELD_OFFSET(MYDATA, bButtonB), DIDFT_BUTTON | DIDFT_ANYINSTANCE, 0,},
- { 0, FIELD_OFFSET(MYDATA, bButtonC), 0x80000000 | DIDFT_BUTTON | DIDFT_ANYINSTANCE, 0,},
- { 0, FIELD_OFFSET(MYDATA, bButtonD), 0x80000000 | DIDFT_BUTTON | DIDFT_ANYINSTANCE, 0,},
-};