]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
added #ifdef SUPPORTDIRECTX checks around all the dinput and dsound code
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 21 Feb 2008 10:21:41 +0000 (10:21 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 21 Feb 2008 10:21:41 +0000 (10:21 +0000)
- this means that dinput and dsound is not removed but is disabled,
  making it easier to compile with Dev-C++ and stock MSVS, this may have
bad consequences (some people swear by -dinput, and dsound was used by
default unless -wavonly was specified, so this is a behavior change)

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8118 d7cf8633-e32d-0410-b094-e92efae38249

snd_win.c
sys_win.c
vid_wgl.c

index 7f8a4621ff0e599989dcd64003582fc27b3cf196..850806316b0645fef175b6351761c832fbcfee2e 100644 (file)
--- a/snd_win.c
+++ b/snd_win.c
@@ -20,12 +20,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #include "quakedef.h"
 #include "snd_main.h"
 
+#ifdef SUPPORTDIRECTX
 #ifndef DIRECTSOUND_VERSION
 #      define DIRECTSOUND_VERSION 0x0500  /* Version 5.0 */
 #endif
+#endif
 #include <windows.h>
 #include <mmsystem.h>
+#ifdef SUPPORTDIRECTX
 #include <dsound.h>
+#endif
 
 // ==============================================================================
 
@@ -79,7 +83,9 @@ static const GUID MY_KSDATAFORMAT_SUBTYPE_PCM =
 
 extern HWND mainwindow;
 
+#ifdef SUPPORTDIRECTX
 HRESULT (WINAPI *pDirectSoundCreate)(GUID FAR *lpGUID, LPDIRECTSOUND FAR *lplpDS, IUnknown FAR *pUnkOuter);
+#endif
 
 // Wave output: 64KB in 64 buffers of 1KB
 // (64KB is > 1 sec at 16-bit 22050 Hz mono, and is 1/3 sec at 16-bit 44100 Hz stereo)
@@ -94,16 +100,19 @@ static unsigned int wav_buffer_size;
 
 typedef enum sndinitstat_e {SIS_SUCCESS, SIS_FAILURE, SIS_NOTAVAIL} sndinitstat;
 
+#ifdef SUPPORTDIRECTX
 static qboolean        dsound_init;
-static qboolean        wav_init;
+static unsigned int dsound_time;
 static qboolean        primary_format_set;
+#endif
+
+static qboolean        wav_init;
 
 static int     snd_sent, snd_completed;
 
 static int prev_painted;
 static unsigned int paintpot;
 
-static unsigned int dsound_time;
 
 
 /*
@@ -125,13 +134,17 @@ DWORD     gSndBufSize;
 
 DWORD  dwStartTime;
 
+#ifdef SUPPORTDIRECTX
 LPDIRECTSOUND pDS;
 LPDIRECTSOUNDBUFFER pDSBuf, pDSPBuf;
 
 HINSTANCE hInstDS;
+#endif
 
 qboolean SNDDMA_InitWav (void);
+#ifdef SUPPORTDIRECTX
 sndinitstat SNDDMA_InitDirect (void);
+#endif
 
 
 /*
@@ -193,6 +206,7 @@ static qboolean SndSys_BuildWaveFormat (const snd_format_t* requested, WAVEFORMA
 }
 
 
+#ifdef SUPPORTDIRECTX
 /*
 ==================
 SndSys_InitDirectSound
@@ -404,6 +418,7 @@ static sndinitstat SndSys_InitDirectSound (const snd_format_t* requested)
 
        return SIS_SUCCESS;
 }
+#endif
 
 
 /*
@@ -530,18 +545,23 @@ May return a suggested format if the requested format isn't available
 */
 qboolean SndSys_Init (const snd_format_t* requested, snd_format_t* suggested)
 {
+#ifdef SUPPORTDIRECTX
        qboolean wavonly;
+#endif
        sndinitstat     stat;
 
        Con_Print ("SndSys_Init: using the Win32 module\n");
 
+#ifdef SUPPORTDIRECTX
 // COMMANDLINEOPTION: Windows Sound: -wavonly uses wave sound instead of DirectSound
        wavonly = (COM_CheckParm ("-wavonly") != 0);
        dsound_init = false;
+#endif
        wav_init = false;
 
        stat = SIS_FAILURE;     // assume DirectSound won't initialize
 
+#ifdef SUPPORTDIRECTX
        // Init DirectSound
        if (!wavonly)
        {
@@ -552,12 +572,15 @@ qboolean SndSys_Init (const snd_format_t* requested, snd_format_t* suggested)
                else
                        Con_Print("DirectSound failed to init\n");
        }
+#endif
 
        // if DirectSound didn't succeed in initializing, try to initialize
        // waveOut sound, unless DirectSound failed because the hardware is
        // already allocated (in which case the user has already chosen not
        // to have sound)
+#ifdef SUPPORTDIRECTX
        if (!dsound_init && (stat != SIS_NOTAVAIL))
+#endif
        {
                if (SndSys_InitMmsystem (requested))
                        Con_Print("Wave sound (MMSYSTEM) initialized\n");
@@ -565,7 +588,11 @@ qboolean SndSys_Init (const snd_format_t* requested, snd_format_t* suggested)
                        Con_Print("Wave sound failed to init\n");
        }
 
+#ifdef SUPPORTDIRECTX
        return (dsound_init || wav_init);
+#else
+       return wav_init;
+#endif
 }
 
 
@@ -578,6 +605,7 @@ Stop the sound card, delete "snd_renderbuffer" and free its other resources
 */
 void SndSys_Shutdown (void)
 {
+#ifdef SUPPORTDIRECTX
        if (pDSBuf)
        {
                IDirectSoundBuffer_Stop(pDSBuf);
@@ -595,6 +623,7 @@ void SndSys_Shutdown (void)
                IDirectSound_SetCooperativeLevel (pDS, mainwindow, DSSCL_NORMAL);
                IDirectSound_Release(pDS);
        }
+#endif
 
        if (hWaveOut)
        {
@@ -629,15 +658,17 @@ void SndSys_Shutdown (void)
                snd_renderbuffer = NULL;
        }
 
+#ifdef SUPPORTDIRECTX
        pDS = NULL;
        pDSBuf = NULL;
        pDSPBuf = NULL;
+       dsound_init = false;
+#endif
        hWaveOut = 0;
        hData = 0;
        hWaveHdr = 0;
        lpData = NULL;
        lpWaveHdr = NULL;
-       dsound_init = false;
        wav_init = false;
 }
 
@@ -702,6 +733,7 @@ unsigned int SndSys_GetSoundTime (void)
 
        factor = snd_renderbuffer->format.width * snd_renderbuffer->format.channels;
 
+#ifdef SUPPORTDIRECTX
        if (dsound_init)
        {
                DWORD dwTime;
@@ -714,6 +746,7 @@ unsigned int SndSys_GetSoundTime (void)
                dsound_time += diff / factor;
                return dsound_time;
        }
+#endif
 
        if (wav_init)
        {
@@ -739,10 +772,12 @@ unsigned int SndSys_GetSoundTime (void)
 }
 
 
+#ifdef SUPPORTDIRECTX
 static DWORD dsound_dwSize;
 static DWORD dsound_dwSize2;
 static DWORD *dsound_pbuf;
 static DWORD *dsound_pbuf2;
+#endif
 
 /*
 ====================
@@ -753,6 +788,7 @@ Get the exclusive lock on "snd_renderbuffer"
 */
 qboolean SndSys_LockRenderBuffer (void)
 {
+#ifdef SUPPORTDIRECTX
        int reps;
        HRESULT hresult;
        DWORD   dwStatus;
@@ -797,6 +833,7 @@ qboolean SndSys_LockRenderBuffer (void)
                        Sys_Error("SndSys_LockRenderBuffer: the ring address has changed!!!\n");
                return true;
        }
+#endif
 
        return wav_init;
 }
@@ -811,6 +848,8 @@ Release the exclusive lock on "snd_renderbuffer"
 */
 void SndSys_UnlockRenderBuffer (void)
 {
+#ifdef SUPPORTDIRECTX
        if (pDSBuf)
                IDirectSoundBuffer_Unlock(pDSBuf, dsound_pbuf, dsound_dwSize, dsound_pbuf2, dsound_dwSize2);
+#endif
 }
index a6f745638b8d2b918a24e8e725ec333450032ea5..a4c740c990dd0233f11004b9c88ff09e52723c43 100644 (file)
--- a/sys_win.c
+++ b/sys_win.c
@@ -22,7 +22,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #include "quakedef.h"
 #include <windows.h>
 #include <mmsystem.h>
+#ifdef SUPPORTDIRECTX
 #include <dsound.h>
+#endif
 #include "errno.h"
 #include "resource.h"
 #include "conproc.h"
index 603adbfcfa273d476889c545268947113dbb28d9..2c05701adb3c28064fb1bd332db67b2475fc632c 100644 (file)
--- a/vid_wgl.c
+++ b/vid_wgl.c
@@ -25,10 +25,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #include "quakedef.h"
 #include <windows.h>
 #include <mmsystem.h>
+#ifdef SUPPORTDIRECTX
 #include <dsound.h>
+#endif
 #include "resource.h"
 #include <commctrl.h>
+#ifdef SUPPORTDIRECTX
 #include <dinput.h>
+#endif
 
 extern HINSTANCE global_hInstance;
 
@@ -120,14 +124,14 @@ static int window_x, window_y;
 static void IN_Activate (qboolean grab);
 
 static qboolean mouseinitialized;
-static qboolean dinput;
-
-// input code
 
+#ifdef SUPPORTDIRECTX
+static qboolean dinput;
 #define DINPUT_BUFFERSIZE           16
 #define iDirectInputCreate(a,b,c,d)    pDirectInputCreate(a,b,c,d)
 
 static HRESULT (WINAPI *pDirectInputCreate)(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUT * lplpDirectInput, LPUNKNOWN punkOuter);
+#endif
 
 // LordHavoc: thanks to backslash for this support for mouse buttons 4 and 5
 /* backslash :: imouse explorer buttons */
@@ -156,9 +160,11 @@ static int                 mouse_buttons;
 static int                     mouse_oldbuttonstate;
 
 static unsigned int uiWheelMessage;
+#ifdef SUPPORTDIRECTX
 static qboolean        dinput_acquired;
 
 static unsigned int            mstate_di;
+#endif
 
 // joystick defines and variables
 // where should defines be moved?
@@ -220,13 +226,14 @@ static int                        joy_id;
 static DWORD           joy_flags;
 static DWORD           joy_numbuttons;
 
+#ifdef SUPPORTDIRECTX
 static LPDIRECTINPUT           g_pdi;
 static LPDIRECTINPUTDEVICE     g_pMouse;
+static HINSTANCE hInstDI;
+#endif
 
 static JOYINFOEX       ji;
 
-static HINSTANCE hInstDI;
-
 // forward-referenced functions
 static void IN_StartupJoystick (void);
 static void Joy_AdvancedUpdate_f (void);
@@ -581,7 +588,11 @@ LONG WINAPI MainWndProc (HWND hWnd, UINT uMsg, WPARAM  wParam, LPARAM lParam)
                        if (wParam & MK_XBUTTON7)
                                temp |= 512;
 
+#ifdef SUPPORTDIRECTX
                        if (vid_usingmouse && !dinput_acquired)
+#else
+                       if (vid_usingmouse)
+#endif
                        {
                                // perform button actions
                                int i;
@@ -1270,12 +1281,14 @@ static void IN_Activate (qboolean grab)
                {
                        vid_usingmouse = true;
                        cl_ignoremousemoves = 2;
+#ifdef SUPPORTDIRECTX
                        if (dinput && g_pMouse)
                        {
                                IDirectInputDevice_Acquire(g_pMouse);
                                dinput_acquired = true;
                        }
                        else
+#endif
                        {
                                RECT window_rect;
                                window_rect.left = window_x;
@@ -1309,12 +1322,14 @@ static void IN_Activate (qboolean grab)
                {
                        vid_usingmouse = false;
                        cl_ignoremousemoves = 2;
+#ifdef SUPPORTDIRECTX
                        if (dinput_acquired)
                        {
                                IDirectInputDevice_Unacquire(g_pMouse);
                                dinput_acquired = false;
                        }
                        else
+#endif
                        {
                                // restore system mouseparms if we changed them
                                if (restore_spi)
@@ -1329,6 +1344,7 @@ static void IN_Activate (qboolean grab)
 }
 
 
+#ifdef SUPPORTDIRECTX
 /*
 ===========
 IN_InitDInput
@@ -1418,6 +1434,7 @@ static qboolean IN_InitDInput (void)
 
        return true;
 }
+#endif
 
 
 /*
@@ -1432,6 +1449,7 @@ static void IN_StartupMouse (void)
 
        mouseinitialized = true;
 
+#ifdef SUPPORTDIRECTX
 // COMMANDLINEOPTION: Windows Input: -dinput enables DirectInput for mouse/joystick input
        if (COM_CheckParm ("-dinput"))
                dinput = IN_InitDInput ();
@@ -1440,6 +1458,7 @@ static void IN_StartupMouse (void)
                Con_Print("DirectInput initialized\n");
        else
                Con_Print("DirectInput not initialized\n");
+#endif
 
        mouse_buttons = 10;
 }
@@ -1452,7 +1471,7 @@ IN_MouseMove
 */
 static void IN_MouseMove (void)
 {
-       int i, mx, my;
+       int mx, my;
        POINT current_pos;
 
        if (!vid_usingmouse)
@@ -1462,8 +1481,10 @@ static void IN_MouseMove (void)
                return;
        }
 
+#ifdef SUPPORTDIRECTX
        if (dinput_acquired)
        {
+               int i;
                DIDEVICEOBJECTDATA      od;
                DWORD                           dwElements;
                HRESULT                         hr;
@@ -1552,6 +1573,7 @@ static void IN_MouseMove (void)
                in_mouse_y = my;
        }
        else
+#endif
        {
                GetCursorPos (&current_pos);
                mx = current_pos.x - (window_x + vid.width / 2);
@@ -2047,6 +2069,7 @@ static void IN_Shutdown(void)
 {
        IN_Activate (false);
 
+#ifdef SUPPORTDIRECTX
        if (g_pMouse)
                IDirectInputDevice_Release(g_pMouse);
        g_pMouse = NULL;
@@ -2054,4 +2077,5 @@ static void IN_Shutdown(void)
        if (g_pdi)
                IDirectInput_Release(g_pdi);
        g_pdi = NULL;
+#endif
 }