#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, 0};
-
static unsigned int uiWheelMessage;
-static qboolean mouseparmsvalid;
static qboolean dinput_acquired;
static unsigned int mstate_di;
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);
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)
while (PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE))
{
if (!GetMessage (&msg, NULL, 0, 0))
- Sys_Quit ();
+ Sys_Quit (1);
TranslateMessage (&msg);
DispatchMessage (&msg);
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;
static void IN_Activate (qboolean grab)
{
+ static qboolean restore_spi;
+ static int originalmouseparms[3];
+
if (!mouseinitialized)
return;
window_rect.top = window_y;
window_rect.right = window_x + vid.width;
window_rect.bottom = window_y + vid.height;
- if (mouseparmsvalid)
+
+ // 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);
}
}
else
{
+ // restore system mouseparms if we changed them
if (restore_spi)
SystemParametersInfo (SPI_SETMOUSE, 0, originalmouseparms, 0);
+ restore_spi = false;
ClipCursor (NULL);
ReleaseCapture ();
}
}
// 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;
}
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;
}
}
// 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