From 5aad68400c91dcc32deb55db6fede02795ba2828 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaakko=20Ker=C3=A4nen?= Date: Wed, 29 May 2019 21:22:50 +0300 Subject: [PATCH] Windows|MinGW: Further changes for MinGW Use the FMOD C API instead of C++. --- doomsday/apps/client/CMakeLists.txt | 2 +- doomsday/apps/client/include/ui/mouse_qt.h | 45 ---- .../client/libs/fluidsynth/CMakeLists.txt | 4 +- .../client/libs/fmod/include/driver_fmod.h | 9 +- .../client/libs/fmod/include/fmod_music.h | 2 +- .../apps/client/libs/fmod/src/driver_fmod.cpp | 57 ++--- .../apps/client/libs/fmod/src/fmod_music.cpp | 37 +-- .../apps/client/libs/fmod/src/fmod_sfx.cpp | 100 ++++---- .../apps/client/src/audio/audiodriver.cpp | 1 + doomsday/apps/client/src/main_client.cpp | 1 + doomsday/apps/client/src/ui/clientwindow.cpp | 2 - .../apps/client/src/{unix => ui}/joystick.cpp | 0 doomsday/apps/client/src/ui/mouse_qt.cpp | 240 ------------------ doomsday/apps/client/src/ui/sys_input.cpp | 10 +- .../client/src/updater/processcheckdialog.cpp | 21 +- .../apps/client/src/windows/directinput.cpp | 107 -------- doomsday/libs/core/include/de/legacy/aabox.h | 32 +-- 17 files changed, 130 insertions(+), 540 deletions(-) delete mode 100644 doomsday/apps/client/include/ui/mouse_qt.h rename doomsday/apps/client/src/{unix => ui}/joystick.cpp (100%) delete mode 100644 doomsday/apps/client/src/ui/mouse_qt.cpp delete mode 100644 doomsday/apps/client/src/windows/directinput.cpp diff --git a/doomsday/apps/client/CMakeLists.txt b/doomsday/apps/client/CMakeLists.txt index f2d89f1e61..aa54c3f060 100644 --- a/doomsday/apps/client/CMakeLists.txt +++ b/doomsday/apps/client/CMakeLists.txt @@ -214,7 +214,7 @@ elseif (APPLE) endif () endif () if (TARGET SDL2) - target_link_libraries (client PUBLIC SDL2) + target_link_libraries (client PUBLIC mingw32 SDL2) endif () if (TARGET SDL2_mixer) target_link_libraries (client PUBLIC SDL2_mixer) diff --git a/doomsday/apps/client/include/ui/mouse_qt.h b/doomsday/apps/client/include/ui/mouse_qt.h deleted file mode 100644 index 61194ce404..0000000000 --- a/doomsday/apps/client/include/ui/mouse_qt.h +++ /dev/null @@ -1,45 +0,0 @@ -#if 0 -#ifndef MOUSE_QT_H -#define MOUSE_QT_H - -#include "sys_input.h" - -#ifdef __cplusplus -extern "C" { -#endif - -extern mouseinterface_t qtMouse; - -/** - * Submits a new mouse event for preprocessing. The event has likely just been - * received from the windowing system. - * - * @param button Which button. - * @param isDown Is the button pressed or released. - */ -void Mouse_Qt_SubmitButton(int button, dd_bool isDown); - -/** - * Submits a new motion event for preprocessing. - * - * @param axis Which axis. - * @param deltaX Horizontal delta. - * @param deltaY Vertical delta. - */ -void Mouse_Qt_SubmitMotion(int axis, int deltaX, int deltaY); - -/** - * Submits an absolute mouse position for the UI mouse mode. - * - * @param x X coordinate. 0 is at the left edge of the window. - * @param y Y coordinate. 0 is at the top edge of the window. - */ -void Mouse_Qt_SubmitWindowPosition(int x, int y); - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // MOUSE_QT_H -#endif - diff --git a/doomsday/apps/client/libs/fluidsynth/CMakeLists.txt b/doomsday/apps/client/libs/fluidsynth/CMakeLists.txt index 5a10da8104..45155b1563 100644 --- a/doomsday/apps/client/libs/fluidsynth/CMakeLists.txt +++ b/doomsday/apps/client/libs/fluidsynth/CMakeLists.txt @@ -8,12 +8,12 @@ include (../ExtensionConfig.cmake) set (tgt audio_fluidsynth) # Make an embedded build by default? -if (APPLE OR MSYS2_LIBS_DIR) +if (APPLE) set (embed ON) elseif (UNIX) set (embed OFF) endif () -if (WIN32 AND NOT MSYS2_LIBS_DIR) +if (WIN32 AND NOT MINGW) message (STATUS "Not building ${tgt} because the MSYS2 version of glib-2.0 is required on Windows (set MSYS2_LIBS_DIR)") return () endif () diff --git a/doomsday/apps/client/libs/fmod/include/driver_fmod.h b/doomsday/apps/client/libs/fmod/include/driver_fmod.h index bd6d224de9..86cddfd19a 100644 --- a/doomsday/apps/client/libs/fmod/include/driver_fmod.h +++ b/doomsday/apps/client/libs/fmod/include/driver_fmod.h @@ -48,7 +48,6 @@ #define __DSFMOD_DRIVER_H__ #include -#include #include #include #include @@ -56,11 +55,6 @@ #include #include "api_console.h" -//DE_ENTRYPOINT int DS_Init(void); -//DE_ENTRYPOINT void DS_Shutdown(void); -//DE_ENTRYPOINT void DS_Event(int type); -//DE_ENTRYPOINT int DS_Set(int prop, const void* ptr); - #define DSFMOD_TRACE(args) LOGDEV_AUDIO_XVERBOSE("[FMOD] ", args) #define DSFMOD_ERRCHECK(result) \ @@ -68,11 +62,10 @@ LOGDEV_AUDIO_WARNING("[FMOD] Error at %s, line %i: (%d) %s") << __FILE__ << __LINE__ << result << FMOD_ErrorString(result); \ } -extern FMOD::System *fmodSystem; +extern FMOD_SYSTEM *fmodSystem; #include "fmod_sfx.h" #include "fmod_music.h" -//#include "fmod_cd.h" #include "fmod_util.h" DE_USING_API(Con); diff --git a/doomsday/apps/client/libs/fmod/include/fmod_music.h b/doomsday/apps/client/libs/fmod/include/fmod_music.h index e5c5b9d7f4..384ae1e5ff 100644 --- a/doomsday/apps/client/libs/fmod/include/fmod_music.h +++ b/doomsday/apps/client/libs/fmod/include/fmod_music.h @@ -59,7 +59,7 @@ int fmod_DM_Music_PlayFile(const char *filename, int looped); // Internal: void fmod_Music_Shutdown(void); -bool fmod_Music_PlaySound(FMOD::Sound* customSound, bool needRelease); +bool fmod_Music_PlaySound(FMOD_SOUND *customSound, bool needRelease); void fmod_Music_Pause(int setPause); void fmod_Music_Stop(void); void fmod_Music_Set(int prop, float value); diff --git a/doomsday/apps/client/libs/fmod/src/driver_fmod.cpp b/doomsday/apps/client/libs/fmod/src/driver_fmod.cpp index c51e993481..aa255e66ca 100644 --- a/doomsday/apps/client/libs/fmod/src/driver_fmod.cpp +++ b/doomsday/apps/client/libs/fmod/src/driver_fmod.cpp @@ -46,7 +46,6 @@ #include #include #include -#include #include "doomsday.h" #include @@ -67,7 +66,7 @@ struct Driver int speakerModeChannels; }; -FMOD::System * fmodSystem; +FMOD_SYSTEM * fmodSystem; static de::List fmodDrivers; static const char *speakerModeText(FMOD_SPEAKERMODE mode) @@ -101,7 +100,7 @@ static int DS_Init(void) // Create the FMOD audio system. FMOD_RESULT result; - if ((result = FMOD::System_Create(&fmodSystem)) != FMOD_OK) + if ((result = FMOD_System_Create(&fmodSystem)) != FMOD_OK) { LOGDEV_AUDIO_ERROR("FMOD::System_Create failed (%d) %s") << result << FMOD_ErrorString(result); fmodSystem = 0; @@ -114,7 +113,7 @@ static int DS_Init(void) // Check what kind of drivers are available. { int numDrivers = 0; - fmodSystem->getNumDrivers(&numDrivers); + FMOD_System_GetNumDrivers(fmodSystem, &numDrivers); fmodDrivers.resize(numDrivers); std::unique_ptr names(new de::ArrayValue); for (int i = 0; i < numDrivers; ++i) @@ -122,7 +121,7 @@ static int DS_Init(void) auto &drv = fmodDrivers[i]; char nameBuf[512]; zap(nameBuf); - fmodSystem->getDriverInfo(i, nameBuf, sizeof(nameBuf), + FMOD_System_GetDriverInfo(fmodSystem, i, nameBuf, sizeof(nameBuf), &drv.guid, &drv.systemRate, &drv.speakerMode, &drv.speakerModeChannels); drv.name = String::format("%s (%s)", nameBuf, speakerModeText(drv.speakerMode)); @@ -143,7 +142,7 @@ static int DS_Init(void) int configuredDriverIndex = Config::get().geti("audio.output", 0); if (configuredDriverIndex < fmodDrivers.size()) { - result = fmodSystem->setDriver(configuredDriverIndex); + result = FMOD_System_SetDriver(fmodSystem, configuredDriverIndex); if (result != FMOD_OK) { LOG_AUDIO_ERROR("Failed to select FMOD audio driver: %s") @@ -153,54 +152,44 @@ static int DS_Init(void) } #if 0 -#ifdef WIN32 - { - // Figure out the system's configured default speaker mode. - FMOD_SPEAKERMODE speakerMode; - result = fmodSystem->getDriverCaps(0, 0, 0, &speakerMode); - if (result == FMOD_OK) - { - fmodSystem->setSpeakerMode(speakerMode); - } - } -#endif - de::String const speakerMode = de::Config::get().gets("audio.fmod.speakerMode", ""); if (speakerMode == "5.1") { - fmodSystem->setSpeakerMode(FMOD_SPEAKERMODE_5POINT1); + FMOD_System_SetSpeakerMode(fmodSystem, FMOD_SPEAKERMODE_5POINT1); } else if (speakerMode == "7.1") { - fmodSystem->setSpeakerMode(FMOD_SPEAKERMODE_7POINT1); + FMOD_System_SetSpeakerMode(fmodSystem, FMOD_SPEAKERMODE_7POINT1); } else if (speakerMode == "prologic") { - fmodSystem->setSpeakerMode(FMOD_SPEAKERMODE_SRS5_1_MATRIX); + FMOD_System_SetSpeakerMode(fmodSystem, FMOD_SPEAKERMODE_SRS5_1_MATRIX); } // Manual overrides. if (CommandLine_Exists("-speaker51")) { - fmodSystem->setSpeakerMode(FMOD_SPEAKERMODE_5POINT1); + FMOD_System_SetSpeakerMode(fmodSystem, FMOD_SPEAKERMODE_5POINT1); } if (CommandLine_Exists("-speaker71")) { - fmodSystem->setSpeakerMode(FMOD_SPEAKERMODE_7POINT1); + FMOD_System_SetSpeakerMode(fmodSystem, FMOD_SPEAKERMODE_7POINT1); } if (CommandLine_Exists("-speakerprologic")) { - fmodSystem->setSpeakerMode(FMOD_SPEAKERMODE_SRS5_1_MATRIX); + FMOD_System_SetSpeakerMode(fmodSystem, FMOD_SPEAKERMODE_SRS5_1_MATRIX); } #endif // Initialize FMOD. - if ((result = fmodSystem->init( - 50, FMOD_INIT_NORMAL | FMOD_INIT_3D_RIGHTHANDED | FMOD_INIT_CHANNEL_LOWPASS, 0)) != - FMOD_OK) + if ((result = FMOD_System_Init(fmodSystem, + 50, + FMOD_INIT_NORMAL | + FMOD_INIT_3D_RIGHTHANDED | + FMOD_INIT_CHANNEL_LOWPASS, 0)) != FMOD_OK) { LOGDEV_AUDIO_ERROR("FMOD init failed: (%d) %s") << result << FMOD_ErrorString(result); - fmodSystem->release(); + FMOD_System_Release(fmodSystem); fmodSystem = 0; return false; } @@ -212,21 +201,21 @@ static int DS_Init(void) settings.HRTFMaxAngle = 360; settings.HRTFMinAngle = 180; settings.HRTFFreq = 11000; - fmodSystem->setAdvancedSettings(&settings); + FMOD_System_SetAdvancedSettings(fmodSystem, &settings); #ifdef _DEBUG int numPlugins = 0; - fmodSystem->getNumPlugins(FMOD_PLUGINTYPE_CODEC, &numPlugins); + FMOD_System_GetNumPlugins(fmodSystem, FMOD_PLUGINTYPE_CODEC, &numPlugins); DSFMOD_TRACE("Plugins loaded: " << numPlugins); for (int i = 0; i < numPlugins; i++) { unsigned int handle; - fmodSystem->getPluginHandle(FMOD_PLUGINTYPE_CODEC, i, &handle); + FMOD_System_GetPluginHandle(fmodSystem, FMOD_PLUGINTYPE_CODEC, i, &handle); FMOD_PLUGINTYPE pType; char pName[100]; unsigned int pVer = 0; - fmodSystem->getPluginInfo(handle, &pType, pName, sizeof(pName), &pVer); + FMOD_System_GetPluginInfo(fmodSystem, handle, &pType, pName, sizeof(pName), &pVer); DSFMOD_TRACE("Plugin " << i << ", handle " << handle << ": type " << pType << ", name:'" << pName << "', ver:" << pVer); @@ -246,7 +235,7 @@ static void DS_Shutdown(void) //DMFmod_CDAudio_Shutdown(); DSFMOD_TRACE("DS_Shutdown."); - fmodSystem->release(); + FMOD_System_Release(fmodSystem); fmodSystem = 0; } @@ -261,7 +250,7 @@ static void DS_Event(int type) if (type == SFXEV_END) { // End of frame, do an update. - fmodSystem->update(); + FMOD_System_Update(fmodSystem); } } diff --git a/doomsday/apps/client/libs/fmod/src/fmod_music.cpp b/doomsday/apps/client/libs/fmod/src/fmod_music.cpp index e1952534f5..04b2c4ec1a 100644 --- a/doomsday/apps/client/libs/fmod/src/fmod_music.cpp +++ b/doomsday/apps/client/libs/fmod/src/fmod_music.cpp @@ -58,8 +58,8 @@ struct SongBuffer } }; -static FMOD::Sound * song; -static FMOD::Channel *music; +static FMOD_SOUND * song; +static FMOD_CHANNEL * music; static bool needReleaseSong; static float musicVolume; static SongBuffer * songBuffer; @@ -74,7 +74,7 @@ musicCallback(FMOD_CHANNELCONTROL *channelcontrol, if (controltype != FMOD_CHANNELCONTROL_CHANNEL) return FMOD_OK; - if (reinterpret_cast(channelcontrol) != music) + if (reinterpret_cast(channelcontrol) != music) return FMOD_OK; // Safety check. switch (callbacktype) @@ -97,7 +97,7 @@ static void releaseSong() if (needReleaseSong) { DSFMOD_TRACE("releaseSong: Song " << song << " will be released."); - song->release(); + FMOD_Sound_Release(song); } else { @@ -123,7 +123,9 @@ static void setDefaultStreamBufferSize() if (!fmodSystem) return; FMOD_RESULT result; - result = fmodSystem->setStreamBufferSize(16*1024, FMOD_TIMEUNIT_RAWBYTES); + result = FMOD_System_SetStreamBufferSize(fmodSystem, + 16 * 1024, + FMOD_TIMEUNIT_RAWBYTES); DSFMOD_ERRCHECK(result); } @@ -177,7 +179,7 @@ void fmod_Music_Set(int prop, float value) { case MUSIP_VOLUME: musicVolume = value; - if (music) music->setVolume(musicVolume); + if (music) FMOD_Channel_SetVolume(music, musicVolume); DSFMOD_TRACE("Music_Set: MUSIP_VOLUME = " << musicVolume); break; @@ -230,7 +232,7 @@ void fmod_Music_Stop(void) DSFMOD_TRACE("Music_Stop."); - music->stop(); + FMOD_Channel_Stop(music); } void fmod_DM_Music_Stop(void) @@ -242,23 +244,23 @@ static bool startSong() { if (!fmodSystem || !song) return false; - if (music) music->stop(); + if (music) FMOD_Channel_Stop(music); // Start playing the song. FMOD_RESULT result; - result = fmodSystem->playSound(song, nullptr, true, &music); + result = FMOD_System_PlaySound(fmodSystem, song, nullptr, true, &music); DSFMOD_ERRCHECK(result); // Properties. - music->setVolume(musicVolume); - music->setCallback(musicCallback); + FMOD_Channel_SetVolume(music, musicVolume); + FMOD_Channel_SetCallback(music, musicCallback); // Start playing. - music->setPaused(false); + FMOD_Channel_SetPaused(music, false); return true; } -bool fmod_Music_PlaySound(FMOD::Sound* customSound, bool needRelease) +bool fmod_Music_PlaySound(FMOD_SOUND* customSound, bool needRelease) { releaseSong(); releaseSongBuffer(); @@ -290,7 +292,8 @@ int fmod_DM_Music_Play(int looped) // Load a new song. FMOD_RESULT result; - result = fmodSystem->createSound(songBuffer->data, + result = FMOD_System_CreateSound(fmodSystem, + songBuffer->data, FMOD_CREATESTREAM | FMOD_OPENMEMORY | (looped? FMOD_LOOP_NORMAL : 0), &extra, &song); @@ -308,7 +311,7 @@ void fmod_Music_Pause(int setPause) { if (!fmodSystem || !music) return; - music->setPaused(setPause != 0); + FMOD_Channel_SetPaused(music, setPause != 0); } void fmod_DM_Music_Pause(int setPause) @@ -348,7 +351,9 @@ int fmod_DM_Music_PlayFile(const char *filename, int looped) } FMOD_RESULT result; - result = fmodSystem->createSound(filename, FMOD_CREATESTREAM | (looped? FMOD_LOOP_NORMAL : 0), + result = FMOD_System_CreateSound(fmodSystem, + filename, + FMOD_CREATESTREAM | (looped? FMOD_LOOP_NORMAL : 0), &extra, &song); DSFMOD_TRACE("Music_Play: loaded '" << filename << "' => Sound " << song); DSFMOD_ERRCHECK(result); diff --git a/doomsday/apps/client/libs/fmod/src/fmod_sfx.cpp b/doomsday/apps/client/libs/fmod/src/fmod_sfx.cpp index 0555e317e5..a0299d49b4 100644 --- a/doomsday/apps/client/libs/fmod/src/fmod_sfx.cpp +++ b/doomsday/apps/client/libs/fmod/src/fmod_sfx.cpp @@ -48,13 +48,13 @@ #include #include -typedef std::map Streams; +typedef std::map Streams; typedef std::vector RawSamplePCM8; struct BufferInfo { - FMOD::Channel* channel; - FMOD::Sound* sound; + FMOD_CHANNEL* channel; + FMOD_SOUND* sound; FMOD_MODE mode; float pan; float volume; @@ -82,7 +82,7 @@ struct BufferInfo mode |= FMOD_3D_WORLDRELATIVE; mode &= ~FMOD_3D_HEADRELATIVE; } - if (channel) channel->setMode(mode); + if (channel) FMOD_Channel_SetMode(channel, mode); } }; @@ -154,14 +154,14 @@ static FMOD_RESULT F_CALLBACK channelCallback(FMOD_CHANNELCONTROL *channelcontro return FMOD_OK; } - FMOD::Channel *channel = reinterpret_cast(channelcontrol); + FMOD_CHANNEL *channel = reinterpret_cast(channelcontrol); sfxbuffer_t *buf = 0; switch (callbacktype) { case FMOD_CHANNELCONTROL_CALLBACK_END: // The sound has ended, mark the channel. - channel->getUserData(reinterpret_cast(&buf)); + FMOD_Channel_GetUserData(channel, reinterpret_cast(&buf)); if (buf) { LOGDEV_AUDIO_XVERBOSE("[FMOD] channelCallback: sfxbuffer %p stops", buf); @@ -169,8 +169,8 @@ static FMOD_RESULT F_CALLBACK channelCallback(FMOD_CHANNELCONTROL *channelcontro // The channel becomes invalid after the sound stops. bufferInfo(buf).channel = 0; } - channel->setCallback(0); - channel->setUserData(0); + FMOD_Channel_SetCallback(channel, 0); + FMOD_Channel_SetUserData(channel, 0); break; default: @@ -217,7 +217,7 @@ void fmod_DS_SFX_DestroyBuffer(sfxbuffer_t* buf) if (info.sound) { DE_GUARD(streams); - info.sound->release(); + FMOD_Sound_Release(info.sound); streams.value.erase(info.sound); } @@ -240,7 +240,7 @@ static void toSigned8bit(const unsigned char* source, int size, RawSamplePCM8& o static FMOD_RESULT F_CALLBACK pcmReadCallback(FMOD_SOUND* soundPtr, void* data, unsigned int datalen) { - FMOD::Sound *sound = reinterpret_cast(soundPtr); + FMOD_SOUND *sound = reinterpret_cast(soundPtr); sfxbuffer_t *buf = nullptr; { @@ -301,7 +301,7 @@ void fmod_DS_SFX_Load(sfxbuffer_t* buf, struct sfxsample_s* sample) { DE_GUARD(streams); LOGDEV_AUDIO_XVERBOSE("[FMOD] SFX_Load: Releasing buffer's old Sound %p", info.sound); - info.sound->release(); + FMOD_Sound_Release(info.sound); streams.value.erase(info.sound); } @@ -339,7 +339,7 @@ void fmod_DS_SFX_Load(sfxbuffer_t* buf, struct sfxsample_s* sample) // Pass the sample to FMOD. FMOD_RESULT result; - result = fmodSystem->createSound(sampleData, info.mode, ¶ms, &info.sound); + result = FMOD_System_CreateSound(fmodSystem, sampleData, info.mode, ¶ms, &info.sound); DSFMOD_ERRCHECK(result); LOGDEV_AUDIO_XVERBOSE("[FMOD] SFX_Load: created Sound %p%s", info.sound << (streaming? " as streaming" : "")); @@ -360,7 +360,7 @@ void fmod_DS_SFX_Load(sfxbuffer_t* buf, struct sfxsample_s* sample) // Check memory. int currentAlloced = 0; int maxAlloced = 0; - FMOD::Memory_GetStats(¤tAlloced, &maxAlloced, false); + FMOD_Memory_GetStats(¤tAlloced, &maxAlloced, false); DSFMOD_TRACE("SFX_Load: FMOD memory alloced:" << currentAlloced << ", max:" << maxAlloced); #endif @@ -386,14 +386,14 @@ void fmod_DS_SFX_Reset(sfxbuffer_t* buf) { DE_GUARD(streams); LOGDEV_AUDIO_XVERBOSE("[FMOD] SFX_Reset: releasing Sound %p", info.sound); - info.sound->release(); + FMOD_Sound_Release(info.sound); streams.value.erase(info.sound); } if (info.channel) { - info.channel->setCallback(0); - info.channel->setUserData(0); - info.channel->setMute(true); + FMOD_Channel_SetCallback(info.channel, 0); + FMOD_Channel_SetUserData(info.channel, 0); + FMOD_Channel_SetMute(info.channel, true); } info = BufferInfo(); } @@ -408,31 +408,36 @@ void fmod_DS_SFX_Play(sfxbuffer_t* buf) assert(info.sound != 0); FMOD_RESULT result; - result = fmodSystem->playSound(info.sound, nullptr, true, &info.channel); + result = FMOD_System_PlaySound(fmodSystem, + info.sound, + nullptr, + true, + &info.channel); DSFMOD_ERRCHECK(result); if (!info.channel) return; // Set the properties of the sound. - info.channel->setPan(info.pan); - info.channel->setFrequency(float(buf->freq)); - info.channel->setVolume(info.volume); - info.channel->setUserData(buf); - info.channel->setCallback(channelCallback); + FMOD_Channel_SetPan(info.channel, info.pan); + FMOD_Channel_SetFrequency(info.channel, float(buf->freq)); + FMOD_Channel_SetVolume(info.channel, info.volume); + FMOD_Channel_SetUserData(info.channel, buf); + FMOD_Channel_SetCallback(info.channel, channelCallback); if (buf->flags & SFXBF_3D) { // 3D properties. - info.channel->set3DMinMaxDistance(info.minDistanceMeters, - info.maxDistanceMeters); - info.channel->set3DAttributes(&info.position, &info.velocity); - info.channel->setMode(info.mode); + FMOD_Channel_Set3DMinMaxDistance(info.channel, + info.minDistanceMeters, + info.maxDistanceMeters); + FMOD_Channel_Set3DAttributes(info.channel, &info.position, &info.velocity, 0); + FMOD_Channel_SetMode(info.channel, info.mode); } LOGDEV_AUDIO_XVERBOSE("[FMOD] SFX_Play: sfxbuffer %p, pan:%f, freq:%i, vol:%f, loop:%b", buf << info.pan << buf->freq << info.volume << ((buf->flags & SFXBF_REPEAT) != 0)); // Start playing it. - info.channel->setPaused(false); + FMOD_Channel_SetPaused(info.channel, false); // The buffer is now playing. buf->flags |= SFXBF_PLAYING; @@ -450,14 +455,14 @@ void fmod_DS_SFX_Stop(sfxbuffer_t* buf) Streams::iterator found = streams.value.find(info.sound); if (found != streams.value.end() && info.channel) { - info.channel->setPaused(true); + FMOD_Channel_SetPaused(info.channel, true); } } if (info.channel) { - info.channel->setUserData(0); - info.channel->setCallback(0); - info.channel->setMute(true); + FMOD_Channel_SetUserData(info.channel, 0); + FMOD_Channel_SetCallback(info.channel, 0); + FMOD_Channel_SetMute(info.channel, true); info.channel = 0; } @@ -493,31 +498,33 @@ void fmod_DS_SFX_Set(sfxbuffer_t* buf, int prop, float value) if (FEQUAL(info.volume, value)) return; // No change. assert(value >= 0); info.volume = value; - if (info.channel) info.channel->setVolume(info.volume); + if (info.channel) FMOD_Channel_SetVolume(info.channel, info.volume); break; case SFXBP_FREQUENCY: { unsigned int newFreq = (unsigned int) (buf->rate * value); if (buf->freq == newFreq) return; // No change. buf->freq = newFreq; - if (info.channel) info.channel->setFrequency(float(buf->freq)); + if (info.channel) FMOD_Channel_SetFrequency(info.channel, float(buf->freq)); break; } case SFXBP_PAN: if (FEQUAL(info.pan, value)) return; // No change. info.pan = value; - if (info.channel) info.channel->setPan(info.pan); + if (info.channel) FMOD_Channel_SetPan(info.channel, info.pan); break; case SFXBP_MIN_DISTANCE: info.minDistanceMeters = value; - if (info.channel) info.channel->set3DMinMaxDistance(info.minDistanceMeters, + if (info.channel) FMOD_Channel_Set3DMinMaxDistance(info.channel, + info.minDistanceMeters, info.maxDistanceMeters); break; case SFXBP_MAX_DISTANCE: info.maxDistanceMeters = value; - if (info.channel) info.channel->set3DMinMaxDistance(info.minDistanceMeters, + if (info.channel) FMOD_Channel_Set3DMinMaxDistance(info.channel, + info.minDistanceMeters, info.maxDistanceMeters); break; @@ -549,12 +556,16 @@ void fmod_DS_SFX_Setv(sfxbuffer_t* buf, int prop, float* values) { case SFXBP_POSITION: info.position.set(values); - if (info.channel) info.channel->set3DAttributes(&info.position, &info.velocity); + if (info.channel) + FMOD_Channel_Set3DAttributes(info.channel, &info.position, + &info.velocity, 0); break; case SFXBP_VELOCITY: info.velocity.set(values); - if (info.channel) info.channel->set3DAttributes(&info.position, &info.velocity); + if (info.channel) + FMOD_Channel_Set3DAttributes(info.channel, &info.position, + &info.velocity, 0); break; default: @@ -573,19 +584,20 @@ void fmod_DS_SFX_Listener(int prop, float value) { case SFXLP_UNITS_PER_METER: unitsPerMeter = value; - fmodSystem->set3DSettings(dopplerScale, unitsPerMeter, 1.0f); + FMOD_System_Set3DSettings(fmodSystem, dopplerScale, unitsPerMeter, 1.0f); DSFMOD_TRACE("SFX_Listener: Units per meter = " << unitsPerMeter); break; case SFXLP_DOPPLER: dopplerScale = value; - fmodSystem->set3DSettings(dopplerScale, unitsPerMeter, 1.0f); + FMOD_System_Set3DSettings(fmodSystem, dopplerScale, unitsPerMeter, 1.0f); DSFMOD_TRACE("SFX_Listener: Doppler factor = " << value); break; case SFXLP_UPDATE: // Update the properties set with Listenerv. - fmodSystem->set3DListenerAttributes(0, &listener.position, &listener.velocity, + FMOD_System_Set3DListenerAttributes(fmodSystem, 0, + &listener.position, &listener.velocity, &listener.front, &listener.up); break; @@ -633,7 +645,7 @@ static void updateListenerEnvironmentSettings(float *reverb) reverb[SFXLP_REVERB_DECAY] == 0 && reverb[SFXLP_REVERB_DAMPING] == 0) { FMOD_REVERB_PROPERTIES noReverb = FMOD_PRESET_OFF; - fmodSystem->setReverbProperties(0, &noReverb); + FMOD_System_SetReverbProperties(fmodSystem, 0, &noReverb); return; } @@ -693,7 +705,7 @@ static void updateListenerEnvironmentSettings(float *reverb) // A slightly increased roll-off. (Not in FMOD?) //props.RoomRolloffFactor = 1.3f; - fmodSystem->setReverbProperties(0, &props); + FMOD_System_SetReverbProperties(fmodSystem, 0, &props); } /** diff --git a/doomsday/apps/client/src/audio/audiodriver.cpp b/doomsday/apps/client/src/audio/audiodriver.cpp index 991b14d7d8..a0c4fac953 100644 --- a/doomsday/apps/client/src/audio/audiodriver.cpp +++ b/doomsday/apps/client/src/audio/audiodriver.cpp @@ -203,6 +203,7 @@ String AudioDriver::statusAsText() const case Loaded: return "Loaded"; case Initialized: return "Initialized"; } + return ""; } void AudioDriver::load(String const &identifier) diff --git a/doomsday/apps/client/src/main_client.cpp b/doomsday/apps/client/src/main_client.cpp index 653f27d324..766b4fc540 100644 --- a/doomsday/apps/client/src/main_client.cpp +++ b/doomsday/apps/client/src/main_client.cpp @@ -46,6 +46,7 @@ #include "dd_version.h" #include +#include #include #if defined (DE_STATIC_LINK) diff --git a/doomsday/apps/client/src/ui/clientwindow.cpp b/doomsday/apps/client/src/ui/clientwindow.cpp index dbd779e381..1bf7697522 100644 --- a/doomsday/apps/client/src/ui/clientwindow.cpp +++ b/doomsday/apps/client/src/ui/clientwindow.cpp @@ -46,7 +46,6 @@ #include #include #include -//#include #include #include #include @@ -66,7 +65,6 @@ #include "ui/inputsystem.h" #include "ui/clientwindowsystem.h" #include "CommandAction" -#include "ui/mouse_qt.h" #include "dd_main.h" #include "render/vr.h" diff --git a/doomsday/apps/client/src/unix/joystick.cpp b/doomsday/apps/client/src/ui/joystick.cpp similarity index 100% rename from doomsday/apps/client/src/unix/joystick.cpp rename to doomsday/apps/client/src/ui/joystick.cpp diff --git a/doomsday/apps/client/src/ui/mouse_qt.cpp b/doomsday/apps/client/src/ui/mouse_qt.cpp deleted file mode 100644 index 94465a5b81..0000000000 --- a/doomsday/apps/client/src/ui/mouse_qt.cpp +++ /dev/null @@ -1,240 +0,0 @@ -#if 0 -/** @file mouse_qt.cpp - * - * Mouse driver that gets mouse input from the Qt based canvas widget. - * @ingroup input - * - * @authors Copyright © 2012-2017 Jaakko Keränen - * @authors Copyright © 2013 Daniel Swanson - * - * @par License - * GPL: http://www.gnu.org/licenses/gpl.html - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. This program is distributed in the hope that it - * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General - * Public License for more details. You should have received a copy of the GNU - * General Public License along with this program; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - */ - -#include "de_base.h" -#include "ui/sys_input.h" -#include "ui/clientwindowsystem.h" -#include "ui/clientwindow.h" -#include "ui/mouse_qt.h" -#include - -#include -#include -#include -#include - -#ifdef MACOSX -# include "cursor_macx.h" -#endif - -typedef struct clicker_s { - int down; // Count for down events. - int up; // Count for up events. -} clicker_t; - -//static int mousePosX, mousePosY; // Window position. -static struct { int dx, dy; } mouseDelta[IMA_MAXAXES]; -static clicker_t mouseClickers[IMB_MAXBUTTONS]; -static bool mouseTrapped = false; -static bool cursorHidden = false; -static QPoint prevMousePos; - -static int Mouse_Qt_Init(void) -{ - memset(&mouseDelta, 0, sizeof(mouseDelta)); - memset(&mouseClickers, 0, sizeof(mouseClickers)); - mouseTrapped = false; - cursorHidden = false; - prevMousePos = QPoint(); - return true; -} - -static void Mouse_Qt_Shutdown(void) -{ - // nothing to do -} - -static void Mouse_Qt_Poll() -{ - if (!mouseTrapped) return; - -#if !defined (DE_MOBILE) - ClientWindow *win = ClientWindowSystem::mainPtr(); - if (!win) return; // Hmm? - - QPoint curPos = win->mapFromGlobal(QCursor::pos()); - if (!prevMousePos.isNull()) - { - QPoint delta = curPos - prevMousePos; - if (!delta.isNull()) - { - Mouse_Qt_SubmitMotion(IMA_POINTER, delta.x(), delta.y()); - - // Keep the cursor centered. - QPoint mid(win->pointWidth() / 2, win->pointHeight() / 2); - QCursor::setPos(win->mapToGlobal(mid)); - prevMousePos = mid; - } - } - else - { - prevMousePos = curPos; - } -#endif -} - -static void Mouse_Qt_GetState(mousestate_t *state) -{ - int i; - - memset(state, 0, sizeof(*state)); - - // Position and wheel. - for (i = 0; i < IMA_MAXAXES; ++i) - { - state->axis[i].x = mouseDelta[i].dx; - state->axis[i].y = mouseDelta[i].dy; - - // Reset. - mouseDelta[i].dx = mouseDelta[i].dy = 0; - } - - // Button presses and releases. - for (i = 0; i < IMB_MAXBUTTONS; ++i) - { - state->buttonDowns[i] = mouseClickers[i].down; - state->buttonUps[i] = mouseClickers[i].up; - - // Reset counters. - mouseClickers[i].down = mouseClickers[i].up = 0; - } -} - -static void Mouse_Qt_ShowCursor(bool yes) -{ - LOG_INPUT_VERBOSE("%s cursor (presently visible? %b)") - << (yes? "showing" : "hiding") << !cursorHidden; - - if (!yes && !cursorHidden) - { - cursorHidden = true; -#ifdef MACOSX - Cursor_Show(false); -#else - qApp->setOverrideCursor(QCursor(Qt::BlankCursor)); -#endif - } - else if (yes && cursorHidden) - { - cursorHidden = false; -#ifdef MACOSX - Cursor_Show(true); -#else - qApp->restoreOverrideCursor(); -#endif - } -} - -static void Mouse_Qt_InitTrap() -{ -#if !defined (DE_MOBILE) - auto &window = ClientWindowSystem::main(); - - QCursor::setPos(window.mapToGlobal(window.geometry().center())); - window.setMouseGrabEnabled(true); - window.setKeyboardGrabEnabled(true); - - Mouse_Qt_ShowCursor(false); -#endif -} - -static void Mouse_Qt_DeinitTrap() -{ -#if !defined (DE_MOBILE) - auto &window = ClientWindowSystem::main(); - window.setMouseGrabEnabled(false); - window.setKeyboardGrabEnabled(false); - - Mouse_Qt_ShowCursor(true); -#endif -} - -static void Mouse_Qt_Trap(dd_bool enabled) -{ - if (mouseTrapped == CPP_BOOL(enabled)) return; - - mouseTrapped = enabled; - prevMousePos = QPoint(); - - if (enabled) - { - Mouse_Qt_InitTrap(); - } - else - { - Mouse_Qt_DeinitTrap(); - } -} - -void Mouse_Qt_SubmitButton(int button, dd_bool isDown) -{ - if (button < 0 || button >= IMB_MAXBUTTONS) return; // Ignore... - - if (isDown) - mouseClickers[button].down++; - else - mouseClickers[button].up++; -} - -void Mouse_Qt_SubmitMotion(int axis, int deltaX, int deltaY) -{ - if (axis < 0 || axis >= IMA_MAXAXES) return; // Ignore... - - /// @todo It would likely be better to directly post a ddevent out of this. - - if (axis == IMA_WHEEL) - { - int idx = ( deltaX < 0? IMB_MWHEELLEFT - : deltaX > 0? IMB_MWHEELRIGHT - : deltaY < 0? IMB_MWHEELUP - : IMB_MWHEELDOWN); - - // We are not yet equipped to handle finer wheel motions. - Mouse_Qt_SubmitButton(idx, true); - Mouse_Qt_SubmitButton(idx, false); - } - else - { - mouseDelta[axis].dx += deltaX; - mouseDelta[axis].dy += deltaY; - } -} - -void Mouse_Qt_SubmitWindowPosition(int x, int y) -{ - // Absolute coordintes. - mouseDelta[IMA_POINTER].dx = x; - mouseDelta[IMA_POINTER].dy = y; -} - -// The global interface. -mouseinterface_t qtMouse = { - Mouse_Qt_Init, - Mouse_Qt_Shutdown, - Mouse_Qt_Poll, - Mouse_Qt_GetState, - Mouse_Qt_Trap -}; -#endif - diff --git a/doomsday/apps/client/src/ui/sys_input.cpp b/doomsday/apps/client/src/ui/sys_input.cpp index 5f68ac428c..38a6adba0d 100644 --- a/doomsday/apps/client/src/ui/sys_input.cpp +++ b/doomsday/apps/client/src/ui/sys_input.cpp @@ -28,11 +28,11 @@ #include "sys_system.h" -#include "ui/mouse_qt.h" // portable -#ifdef WIN32 -# include "directinput.h" -# include "mouse_win32.h" -#endif +// #include "ui/mouse_qt.h" // portable +// #ifdef WIN32 +// # include "directinput.h" +// # include "mouse_win32.h" +// #endif #define EVBUFSIZE 64 #define KEYBUFSIZE 32 diff --git a/doomsday/apps/client/src/updater/processcheckdialog.cpp b/doomsday/apps/client/src/updater/processcheckdialog.cpp index 2fdd8fac5b..7d47d56469 100644 --- a/doomsday/apps/client/src/updater/processcheckdialog.cpp +++ b/doomsday/apps/client/src/updater/processcheckdialog.cpp @@ -1,7 +1,7 @@ /** @file processcheckdialog.cpp Dialog for checking running processes on Windows. * @ingroup updater * - * @authors Copyright © 2012-2017 Jaakko Keränen + * @authors Copyright © 2012-2019 Jaakko Keränen * * @par License * GPL: http://www.gnu.org/licenses/gpl.html @@ -23,6 +23,7 @@ //#include #include +#include #include using namespace de; @@ -31,16 +32,16 @@ using namespace de; static bool isProcessRunning(char const *name) { + String result; CommandLine wmic; wmic << "wmic.exe" << "PROCESS" << "get" << "Caption"; - if (!wmic.waitForStarted()) return false; - if (!wmic.waitForFinished()) return false; - - QByteArray result = wmic.readAll(); - for (QString p : QString(result).split("\n", QString::SkipEmptyParts)) + if (wmic.executeAndWait(&result)) { - if (!p.trimmed().compare(QLatin1String(name), Qt::CaseInsensitive)) - return true; + for (String p : result.split("\n")) + { + if (!p.strip().compare(name, CaseInsensitive)) + return true; + } } return false; } @@ -57,8 +58,8 @@ dd_bool Updater_AskToStopProcess(char const *processName, char const *message) processName)); msg->buttons() - << new DialogButtonItem(DialogWidget::Accept | DialogWidget::Default, QObject::tr("Retry")) - << new DialogButtonItem(DialogWidget::Reject, QObject::tr("Ignore")); + << new DialogButtonItem(DialogWidget::Accept | DialogWidget::Default, "Retry") + << new DialogButtonItem(DialogWidget::Reject, "Ignore"); // Show a notification dialog. if (!msg->exec(ClientWindow::main().root())) diff --git a/doomsday/apps/client/src/windows/directinput.cpp b/doomsday/apps/client/src/windows/directinput.cpp deleted file mode 100644 index 7495eb4f97..0000000000 --- a/doomsday/apps/client/src/windows/directinput.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/** @file directinput.cpp DirectInput for Windows. - * @ingroup input - * - * @authors Copyright © 2003-2017 Jaakko Keränen - * @authors Copyright © 2005-2013 Daniel Swanson - * - * @par License - * GPL: http://www.gnu.org/licenses/gpl.html - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. This program is distributed in the hope that it - * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General - * Public License for more details. You should have received a copy of the GNU - * General Public License along with this program; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - */ - -#ifdef __CLIENT__ - -#include "directinput.h" -#include "dd_winit.h" -#include -#include - -static LPDIRECTINPUT8 dInput; -static LPDIRECTINPUT dInput3; - -const char* DirectInput_ErrorMsg(HRESULT hr) -{ - return hr == DI_OK ? "OK" : hr == DIERR_GENERIC ? "Generic error" : hr == - DI_PROPNOEFFECT ? "Property has no effect" : hr == - DIERR_INVALIDPARAM ? "Invalid parameter" : hr == - DIERR_NOTINITIALIZED ? "Not initialized" : hr == - DIERR_UNSUPPORTED ? "Unsupported" : hr == - DIERR_NOTFOUND ? "Not found" : "?"; -} - -int DirectInput_Init(void) -{ - HRESULT hr; - - if(dInput || dInput3) return true; - - // Create the DirectInput interface instance. Try version 8 first. - if(FAILED(hr = CoCreateInstance(CLSID_DirectInput8, NULL, CLSCTX_INPROC_SERVER, - IID_IDirectInput8, (LPVOID*)&dInput)) || - FAILED(hr = dInput->Initialize((HINSTANCE) DoomsdayApp::app().moduleHandle(), DIRECTINPUT_VERSION))) - { - LOGDEV_INPUT_ERROR("DirectInput 8 init failed (0x%x)") << hr; - - // Try the older version 3 interface instead. - // I'm not sure if this works correctly. - if(FAILED(hr = CoCreateInstance(CLSID_DirectInput, NULL, CLSCTX_INPROC_SERVER, - IID_IDirectInput2W, (LPVOID*)&dInput3)) || - FAILED(hr = dInput3->Initialize((HINSTANCE) DoomsdayApp::app().moduleHandle(), 0x0300))) - { - LOGDEV_INPUT_ERROR("Failed to create DirectInput 3 object (0x%x)") << hr; - return false; - } - - LOG_INPUT_NOTE("Using DirectInput 3 as fallback"); - } - - if(!dInput && !dInput3) - { - LOG_INPUT_ERROR("DirectInput init failed"); - return false; - } - - return true; -} - -void DirectInput_Shutdown(void) -{ - if(dInput) - { - IDirectInput_Release(dInput); - dInput = 0; - } - if(dInput3) - { - IDirectInput_Release(dInput3); - dInput3 = 0; - } -} - -LPDIRECTINPUT8 DirectInput_IVersion8() -{ - return dInput; -} - -LPDIRECTINPUT DirectInput_IVersion3() -{ - return dInput3; -} - -void DirectInput_KillDevice(LPDIRECTINPUTDEVICE8* dev) -{ - if(*dev) (*dev)->Unacquire(); - I_SAFE_RELEASE(*dev); -} - -#endif // __CLIENT__ diff --git a/doomsday/libs/core/include/de/legacy/aabox.h b/doomsday/libs/core/include/de/legacy/aabox.h index 811125dcd9..f611e9c874 100644 --- a/doomsday/libs/core/include/de/legacy/aabox.h +++ b/doomsday/libs/core/include/de/legacy/aabox.h @@ -52,14 +52,8 @@ typedef struct aabox_s { aabox_s() : minX(DDMAXINT), minY(DDMAXINT), maxX(DDMININT), maxY(DDMININT) {} aabox_s(int _minX, int _minY, int _maxX, int _maxY) : minX(_minX), minY(_minY), maxX(_maxX), maxY(_maxY) {} - aabox_s& operator = (aabox_s const& other) - { - minX = other.minX; - minY = other.minY; - maxX = other.maxX; - maxY = other.maxY; - return *this; - } + aabox_s(const aabox_s &) = default; + aabox_s &operator=(const aabox_s &) = default; aabox_s& clear() { @@ -99,14 +93,8 @@ typedef struct aaboxf_s { aaboxf_s() : minX(DDMAXFLOAT), minY(DDMAXFLOAT), maxX(DDMINFLOAT), maxY(DDMINFLOAT) {} aaboxf_s(float _minX, float _minY, float _maxX, float _maxY) : minX(_minX), minY(_minY), maxX(_maxX), maxY(_maxY) {} - aaboxf_s& operator = (aaboxf_s const& other) - { - minX = other.minX; - minY = other.minY; - maxX = other.maxX; - maxY = other.maxY; - return *this; - } + aaboxf_s(const aaboxf_s &) = default; + aaboxf_s &operator=(const aaboxf_s &) = default; aaboxf_s& clear() { @@ -146,15 +134,9 @@ typedef struct aaboxd_s { aaboxd_s() : minX(DDMAXFLOAT), minY(DDMAXFLOAT), maxX(DDMINFLOAT), maxY(DDMINFLOAT) {} aaboxd_s(double _minX, double _minY, double _maxX, double _maxY) : minX(_minX), minY(_minY), maxX(_maxX), maxY(_maxY) {} - aaboxd_s& operator = (aaboxd_s const& other) - { - minX = other.minX; - minY = other.minY; - maxX = other.maxX; - maxY = other.maxY; - return *this; - } - + aaboxd_s(const aaboxd_s &) = default; + aaboxd_s &operator=(const aaboxd_s &) = default; + aaboxd_s& clear() { minX = minY = DDMAXFLOAT;