*/
// gl_vidnt.c -- NT GL vid component
+// we don't need a very new dinput
+#define DIRECTINPUT_VERSION 0x0300
+
#include "quakedef.h"
#include <windows.h>
+#include <mmsystem.h>
#include <dsound.h>
#include "resource.h"
#include <commctrl.h>
+#include <dinput.h>
-extern void S_BlockSound (void);
-extern void S_UnblockSound (void);
extern HINSTANCE global_hInstance;
// Tell startup code that we have a client
int cl_available = true;
+qboolean vid_supportrefreshrate = true;
+
static int (WINAPI *qwglChoosePixelFormat)(HDC, CONST PIXELFORMATDESCRIPTOR *);
static int (WINAPI *qwglDescribePixelFormat)(HDC, int, UINT, LPPIXELFORMATDESCRIPTOR);
//static int (WINAPI *qwglGetPixelFormat)(HDC);
static qboolean vid_wassuspended = false;
static qboolean vid_usingmouse = false;
static qboolean vid_usingvsync = false;
-static qboolean vid_usemouse = false;
static qboolean vid_usevsync = false;
static HICON hIcon;
//====================================
-static int window_x, window_y, window_width, window_height;
-static int window_center_x, window_center_y;
+static int window_x, window_y;
static void IN_Activate (qboolean grab);
// input code
-#include <dinput.h>
-
#define DINPUT_BUFFERSIZE 16
#define iDirectInputCreate(a,b,c,d) pDirectInputCreate(a,b,c,d)
#ifndef MK_XBUTTON1
#define MK_XBUTTON1 0x0020
#define MK_XBUTTON2 0x0040
+#endif
+#ifndef MK_XBUTTON3
// LordHavoc: lets hope this allows more buttons in the future...
#define MK_XBUTTON3 0x0080
#define MK_XBUTTON4 0x0100
static int mouse_buttons;
static int mouse_oldbuttonstate;
-static qboolean restore_spi;
-static int originalmouseparms[3], newmouseparms[3] = {0, 0, 1};
-
static unsigned int uiWheelMessage;
-static qboolean mouseparmsvalid, mouseactivatetoggle;
static qboolean dinput_acquired;
static unsigned int mstate_di;
// 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.
-static cvar_t in_joystick = {CVAR_SAVE, "joystick","0"};
-static cvar_t joy_name = {0, "joyname", "joystick"};
-static cvar_t joy_advanced = {0, "joyadvanced", "0"};
-static cvar_t joy_advaxisx = {0, "joyadvaxisx", "0"};
-static cvar_t joy_advaxisy = {0, "joyadvaxisy", "0"};
-static cvar_t joy_advaxisz = {0, "joyadvaxisz", "0"};
-static cvar_t joy_advaxisr = {0, "joyadvaxisr", "0"};
-static cvar_t joy_advaxisu = {0, "joyadvaxisu", "0"};
-static cvar_t joy_advaxisv = {0, "joyadvaxisv", "0"};
-static cvar_t joy_forwardthreshold = {0, "joyforwardthreshold", "0.15"};
-static cvar_t joy_sidethreshold = {0, "joysidethreshold", "0.15"};
-static cvar_t joy_pitchthreshold = {0, "joypitchthreshold", "0.15"};
-static cvar_t joy_yawthreshold = {0, "joyyawthreshold", "0.15"};
-static cvar_t joy_forwardsensitivity = {0, "joyforwardsensitivity", "-1.0"};
-static cvar_t joy_sidesensitivity = {0, "joysidesensitivity", "-1.0"};
-static cvar_t joy_pitchsensitivity = {0, "joypitchsensitivity", "1.0"};
-static cvar_t joy_yawsensitivity = {0, "joyyawsensitivity", "-1.0"};
-static cvar_t joy_wwhack1 = {0, "joywwhack1", "0.0"};
-static cvar_t joy_wwhack2 = {0, "joywwhack2", "0.0"};
+static cvar_t in_joystick = {CVAR_SAVE, "joystick","0", "enables joysticks"};
+static cvar_t joy_name = {0, "joyname", "joystick", "name of joystick to use (informational only, used only by joyadvanced 1 mode)"};
+static cvar_t joy_advanced = {0, "joyadvanced", "0", "use more than 2 axis joysticks (configuring this is very technical)"};
+static cvar_t joy_advaxisx = {0, "joyadvaxisx", "0", "axis mapping for joyadvanced 1 mode"};
+static cvar_t joy_advaxisy = {0, "joyadvaxisy", "0", "axis mapping for joyadvanced 1 mode"};
+static cvar_t joy_advaxisz = {0, "joyadvaxisz", "0", "axis mapping for joyadvanced 1 mode"};
+static cvar_t joy_advaxisr = {0, "joyadvaxisr", "0", "axis mapping for joyadvanced 1 mode"};
+static cvar_t joy_advaxisu = {0, "joyadvaxisu", "0", "axis mapping for joyadvanced 1 mode"};
+static cvar_t joy_advaxisv = {0, "joyadvaxisv", "0", "axis mapping for joyadvanced 1 mode"};
+static cvar_t joy_forwardthreshold = {0, "joyforwardthreshold", "0.15", "minimum joystick movement necessary to move forward"};
+static cvar_t joy_sidethreshold = {0, "joysidethreshold", "0.15", "minimum joystick movement necessary to move sideways (strafing)"};
+static cvar_t joy_pitchthreshold = {0, "joypitchthreshold", "0.15", "minimum joystick movement necessary to look up/down"};
+static cvar_t joy_yawthreshold = {0, "joyyawthreshold", "0.15", "minimum joystick movement necessary to turn left/right"};
+static cvar_t joy_forwardsensitivity = {0, "joyforwardsensitivity", "-1.0", "how fast the joystick moves forward"};
+static cvar_t joy_sidesensitivity = {0, "joysidesensitivity", "-1.0", "how fast the joystick moves sideways (strafing)"};
+static cvar_t joy_pitchsensitivity = {0, "joypitchsensitivity", "1.0", "how fast the joystick looks up/down"};
+static cvar_t joy_yawsensitivity = {0, "joyyawsensitivity", "-1.0", "how fast the joystick turns left/right"};
+static cvar_t joy_wwhack1 = {0, "joywwhack1", "0.0", "special hack for wingman warrior"};
+static cvar_t joy_wwhack2 = {0, "joywwhack2", "0.0", "special hack for wingman warrior"};
static qboolean joy_avail, joy_advancedinit, joy_haspov;
static DWORD joy_oldbuttonstate, joy_oldpovstate;
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,},
-};
-
-#define NUM_OBJECTS (sizeof(rgodf) / sizeof(rgodf[0]))
-
-static DIDATAFORMAT df = {
- sizeof(DIDATAFORMAT), // this structure
- sizeof(DIOBJECTDATAFORMAT), // size of object data format
- DIDF_RELAXIS, // absolute axis coordinates
- sizeof(MYDATA), // device data size
- NUM_OBJECTS, // number of objects
- rgodf, // and here they are
-};
-
// forward-referenced functions
static void IN_StartupJoystick (void);
static void Joy_AdvancedUpdate_f (void);
static void IN_JoyMove (void);
static void IN_StartupMouse (void);
-/*
-================
-VID_UpdateWindowStatus
-================
-*/
-static void VID_UpdateWindowStatus (void)
-{
- window_center_x = window_x + window_width / 2;
- window_center_y = window_y + window_height / 2;
-
- if (mouseinitialized && vid_usingmouse && !dinput_acquired)
- {
- RECT window_rect;
- window_rect.left = window_x;
- window_rect.top = window_y;
- window_rect.right = window_x + window_width;
- window_rect.bottom = window_y + window_height;
- ClipCursor (&window_rect);
- }
-}
-
//====================================
-/*
-=================
-VID_GetWindowSize
-=================
-*/
-void VID_GetWindowSize (int *x, int *y, int *width, int *height)
+void VID_Finish (qboolean allowmousegrab)
{
- *x = 0;
- *y = 0;
- *width = window_width;
- *height = window_height;
-}
+ qboolean vid_usemouse;
-
-void VID_Finish (void)
-{
vid_usevsync = vid_vsync.integer && !cls.timedemo && gl_videosyncavailable;
if (vid_usingvsync != vid_usevsync && gl_videosyncavailable)
{
// handle the mouse state when windowed if that's changed
vid_usemouse = false;
- if (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 (!vid_activewindow)
vid_usemouse = false;
- if (vid_usemouse)
- {
- if (!vid_usingmouse)
- {
- vid_usingmouse = true;
- IN_Activate (true);
- }
- }
- else
- {
- if (vid_usingmouse)
- {
- vid_usingmouse = false;
- IN_Activate (false);
- }
- }
+ IN_Activate(vid_usemouse);
if (r_render.integer && !vid_hidden)
{
+ CHECKGLERROR
if (r_speeds.integer || gl_finish.integer)
- qglFinish();
+ {
+ qglFinish();CHECKGLERROR
+ }
SwapBuffers(baseDC);
}
+
+ VID_UpdateGamma(false, 256);
}
//==========================================================================
-static qbyte scantokey[128] =
+static unsigned char scantokey[128] =
{
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
0 ,27 ,'1' ,'2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' ,'0' ,'-' ,'=' ,K_BACKSPACE,9 ,//0
*
****************************************************************************/
{
- static BOOL sound_active;
+ static qboolean sound_active = false; // initially blocked by Sys_InitConsole()
vid_activewindow = fActive;
vid_hidden = minimize;
-// enable/disable sound on focus gain/loss
- if (!vid_activewindow && sound_active)
+ // enable/disable sound on focus gain/loss
+ if (!vid_hidden && (vid_activewindow || !snd_mutewhenidle.integer))
{
- S_BlockSound ();
- sound_active = false;
+ if (!sound_active)
+ {
+ S_UnblockSound ();
+ sound_active = true;
+ }
}
- else if (vid_activewindow && !sound_active)
+ else
{
- S_UnblockSound ();
- sound_active = true;
+ if (sound_active)
+ {
+ S_BlockSound ();
+ sound_active = false;
+ }
}
if (fActive)
if (!fActive)
{
- vid_usingmouse = false;
IN_Activate (false);
if (vid_isfullscreen)
{
while (PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE))
{
if (!GetMessage (&msg, NULL, 0, 0))
- Sys_Quit ();
+ Sys_Quit (1);
TranslateMessage (&msg);
DispatchMessage (&msg);
LONG CDAudio_MessageHandler(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
+static keynum_t buttonremap[16] =
+{
+ K_MOUSE1,
+ K_MOUSE2,
+ K_MOUSE3,
+ K_MOUSE4,
+ K_MOUSE5,
+ K_MOUSE6,
+ K_MOUSE7,
+ K_MOUSE8,
+ K_MOUSE9,
+ K_MOUSE10,
+ K_MOUSE11,
+ K_MOUSE12,
+ K_MOUSE13,
+ K_MOUSE14,
+ K_MOUSE15,
+ K_MOUSE16,
+};
+
/* main window procedure */
LONG WINAPI MainWndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
char state[256];
char asciichar[4];
int vkey;
+ int charlength;
qboolean down = false;
if ( uMsg == uiWheelMessage )
case WM_MOVE:
window_x = (int) LOWORD(lParam);
window_y = (int) HIWORD(lParam);
- VID_UpdateWindowStatus ();
+ IN_Activate(false);
break;
case WM_KEYDOWN:
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
- if (vkey == K_ALT || vkey == K_CTRL || vkey == K_SHIFT || ToAscii (wParam, lParam >> 16, state, (unsigned short *)asciichar, 0) != 1)
+ charlength = ToAscii (wParam, lParam >> 16, state, (unsigned short *)asciichar, 0);
+ if (vkey == K_ALT || vkey == K_CTRL || vkey == K_SHIFT || charlength == 0)
asciichar[0] = 0;
+ else if( charlength == 2 ) {
+ asciichar[0] = asciichar[1];
+ }
Key_Event (vkey, asciichar[0], down);
break;
{
// perform button actions
int i;
- for (i=0 ; i<mouse_buttons ; i++)
+ for (i=0 ; i<mouse_buttons && i < 16 ; i++)
if ((temp ^ mouse_oldbuttonstate) & (1<<i))
- Key_Event (K_MOUSE1 + i, 0, (temp & (1<<i)) != 0);
+ Key_Event (buttonremap[i], 0, (temp & (1<<i)) != 0);
mouse_oldbuttonstate = temp;
}
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;
}
wc.lpszClassName = "DarkPlacesWindowClass";
if (!RegisterClass (&wc))
- Sys_Error("Couldn't register window class\n");
+ Con_Printf ("Couldn't register window class\n");
IN_Init();
}
-int VID_InitMode (int fullscreen, int width, int height, int bpp)
+int VID_InitMode (int fullscreen, int width, int height, int bpp, int refreshrate, int stereobuffer)
{
int i;
HDC hdc;
int depth;
if (vid_initialized)
- Sys_Error("VID_InitMode called when video is already initialised\n");
+ Sys_Error("VID_InitMode called when video is already initialised");
// if stencil is enabled, ask for alpha too
if (bpp >= 32)
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");
vid_isfullscreen = false;
if (fullscreen)
{
- gdevmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
+ gdevmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY;
gdevmode.dmBitsPerPel = bpp;
gdevmode.dmPelsWidth = width;
gdevmode.dmPelsHeight = height;
+ gdevmode.dmDisplayFrequency = refreshrate;
gdevmode.dmSize = sizeof (gdevmode);
if (ChangeDisplaySettings (&gdevmode, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
{
// x and y may be changed by WM_MOVE messages
window_x = CenterX;
window_y = CenterY;
- window_width = width;
- window_height = height;
rect.left += CenterX;
rect.right += CenterX;
rect.top += CenterY;
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;
}
ShowWindow (mainwindow, SW_SHOWDEFAULT);
UpdateWindow (mainwindow);
- VID_UpdateWindowStatus ();
-
// now we try to make sure we get the focus on the mode switch, because
// sometimes in some systems we don't. We grab the foreground, then
// finish setting up, pump all our messages, and sleep for a little while
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;
}
- qglGetString = GL_GetProcAddress("glGetString");
- qwglGetExtensionsStringARB = GL_GetProcAddress("wglGetExtensionsStringARB");
- if (qglGetString == NULL)
+ if ((qglGetString = (const GLubyte* (GLAPIENTRY *)(GLenum name))GL_GetProcAddress("glGetString")) == NULL)
{
VID_Shutdown();
Con_Print("glGetString not found\n");
return false;
}
+ 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);
IN_StartupMouse ();
IN_StartupJoystick ();
+ if (gl_videosyncavailable)
+ {
+ vid_usevsync = vid_vsync.integer;
+ vid_usingvsync = vid_vsync.integer;
+ qwglSwapIntervalEXT (vid_usevsync);
+ }
+
return true;
}
vid_isfullscreen = false;
}
-
-/*
-===========
-IN_Activate
-===========
-*/
static void IN_Activate (qboolean grab)
{
+ static qboolean restore_spi;
+ static int originalmouseparms[3];
+
if (!mouseinitialized)
return;
if (grab)
{
- mouseactivatetoggle = true;
- if (dinput && g_pMouse)
- {
- IDirectInputDevice_Acquire(g_pMouse);
- dinput_acquired = true;
- }
- else
+ if (!vid_usingmouse)
{
- RECT window_rect;
- window_rect.left = window_x;
- window_rect.top = window_y;
- window_rect.right = window_x + window_width;
- window_rect.bottom = window_y + window_height;
- if (mouseparmsvalid)
- restore_spi = SystemParametersInfo (SPI_SETMOUSE, 0, newmouseparms, 0);
- SetCursorPos (window_center_x, window_center_y);
- SetCapture (mainwindow);
- ClipCursor (&window_rect);
+ vid_usingmouse = true;
+ cl_ignoremousemove = true;
+ if (dinput && g_pMouse)
+ {
+ IDirectInputDevice_Acquire(g_pMouse);
+ dinput_acquired = true;
+ }
+ else
+ {
+ RECT window_rect;
+ window_rect.left = window_x;
+ window_rect.top = window_y;
+ window_rect.right = window_x + vid.width;
+ window_rect.bottom = window_y + vid.height;
+
+ // 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);
+ }
+ ShowCursor (false);
}
- vid_usingmouse = true;
- ShowCursor (false);
}
else
{
- mouseactivatetoggle = false;
- if (dinput_acquired)
- {
- IDirectInputDevice_Unacquire(g_pMouse);
- dinput_acquired = false;
- }
- else
+ if (vid_usingmouse)
{
- if (restore_spi)
- SystemParametersInfo (SPI_SETMOUSE, 0, originalmouseparms, 0);
- ClipCursor (NULL);
- ReleaseCapture ();
+ vid_usingmouse = false;
+ cl_ignoremousemove = true;
+ if (dinput_acquired)
+ {
+ IDirectInputDevice_Unacquire(g_pMouse);
+ dinput_acquired = false;
+ }
+ else
+ {
+ // restore system mouseparms if we changed them
+ if (restore_spi)
+ SystemParametersInfo (SPI_SETMOUSE, 0, originalmouseparms, 0);
+ restore_spi = false;
+ ClipCursor (NULL);
+ ReleaseCapture ();
+ }
+ ShowCursor (true);
}
- vid_usingmouse = false;
- ShowCursor (true);
}
}
}
// set the data format to "mouse format".
- hr = IDirectInputDevice_SetDataFormat(g_pMouse, &df);
+ hr = IDirectInputDevice_SetDataFormat(g_pMouse, &c_dfDIMouse);
if (FAILED(hr))
{
*/
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;
-
-// if a fullscreen video mode was set before the mouse was initialized,
-// set the mouse state appropriately
- if (mouseactivatetoggle)
- IN_Activate (true);
}
switch (od.dwOfs)
{
case DIMOFS_X:
- mx += od.dwData;
+ mx += (LONG) od.dwData;
break;
case DIMOFS_Y:
- my += od.dwData;
+ my += (LONG) od.dwData;
+ break;
+
+ case DIMOFS_Z:
+ if((LONG) od.dwData < 0)
+ {
+ Key_Event (K_MWHEELDOWN, 0, true);
+ Key_Event (K_MWHEELDOWN, 0, false);
+ }
+ else if((LONG) od.dwData > 0)
+ {
+ Key_Event (K_MWHEELUP, 0, true);
+ Key_Event (K_MWHEELUP, 0, false);
+ }
break;
case DIMOFS_BUTTON0:
else
mstate_di &= ~(1<<2);
break;
+
+ case DIMOFS_BUTTON3:
+ if (od.dwData & 0x80)
+ mstate_di |= (1<<3);
+ else
+ mstate_di &= ~(1<<3);
+ break;
}
}
// perform button actions
- for (i=0 ; i<mouse_buttons ; i++)
+ for (i=0 ; i<mouse_buttons && i < 16 ; i++)
if ((mstate_di ^ mouse_oldbuttonstate) & (1<<i))
- Key_Event (K_MOUSE1 + i, 0, (mstate_di & (1<<i)) != 0);
+ Key_Event (buttonremap[i], 0, (mstate_di & (1<<i)) != 0);
mouse_oldbuttonstate = mstate_di;
in_mouse_x = mx;
else
{
GetCursorPos (¤t_pos);
- mx = current_pos.x - window_center_x;
- my = current_pos.y - window_center_y;
+ mx = current_pos.x - (window_x + vid.width / 2);
+ my = current_pos.y - (window_y + vid.height / 2);
in_mouse_x = mx;
in_mouse_y = my;
// if the mouse has moved, force it to the center, so there's room to move
+ if (!cl.csqc_wantsmousemove)
if (mx || my)
- SetCursorPos (window_center_x, window_center_y);
+ SetCursorPos ((window_x + vid.width / 2), (window_y + vid.height / 2));
}
}
// 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++)
Cvar_RegisterVariable (&joy_yawsensitivity);
Cvar_RegisterVariable (&joy_wwhack1);
Cvar_RegisterVariable (&joy_wwhack2);
- Cmd_AddCommand ("joyadvancedupdate", Joy_AdvancedUpdate_f);
+ Cmd_AddCommand ("joyadvancedupdate", Joy_AdvancedUpdate_f, "applies current joyadv* cvar settings to the joystick driver");
}
static void IN_Shutdown(void)