diff --git a/src/blackmisc/simulation/settings/simulatorsettings.h b/src/blackmisc/simulation/settings/simulatorsettings.h index 51ad80161..223cc74a4 100644 --- a/src/blackmisc/simulation/settings/simulatorsettings.h +++ b/src/blackmisc/simulation/settings/simulatorsettings.h @@ -188,7 +188,7 @@ namespace BlackMisc CSimulatorInfo m_simulator; //!< represented simulator }; - //! Allows to have specific utility functions for each simulator + //! XPlane specific settings class BLACKMISC_EXPORT CXPlaneSimulatorSettings : public CSpecializedSimulatorSettings { public: @@ -234,6 +234,23 @@ namespace BlackMisc static const QString &humanReadable() { static const QString name("P3D settings"); return name; } }; + //! Selected P3D version (64bit) + struct TP3DVersion : public TSettingTrait + { + //! \copydoc BlackMisc::TSettingTrait::key + static const char *key() { return "simulator/p3dversion"; } + + //! \copydoc BlackCore::TSettingTrait::humanReadable + static const QString &humanReadable() { static const QString name("P3D version"); return name; } + + //! \copydoc BlackMisc::TSettingTrait::defaultValue + static const QString &defaultValue() + { + static const QString version("4.2"); + return version; + } + }; + //! Trait for simulator settings struct TSimulatorXP : public TSettingTrait { diff --git a/src/plugins/simulator/p3d/simulatorp3d.cpp b/src/plugins/simulator/p3d/simulatorp3d.cpp index 892778afc..8fecd5ae5 100644 --- a/src/plugins/simulator/p3d/simulatorp3d.cpp +++ b/src/plugins/simulator/p3d/simulatorp3d.cpp @@ -31,10 +31,6 @@ namespace BlackSimPlugin { namespace P3D { - #ifdef Q_OS_WIN64 - static P3DSimConnectVersion gP3DSimConnectVersion = P3DSimConnectv42; - #endif - CSimulatorP3D::CSimulatorP3D(const CSimulatorPluginInfo &info, IOwnAircraftProvider *ownAircraftProvider, IRemoteAircraftProvider *remoteAircraftProvider, @@ -57,7 +53,7 @@ namespace BlackSimPlugin bool CSimulatorP3D::connectTo() { #ifdef Q_OS_WIN64 - if (!loadAndResolveP3DSimConnect(gP3DSimConnectVersion)) { return false; } + if (!loadAndResolveP3DSimConnectByString(m_p3dVersion.get())) { return false; } return CSimulatorFsxCommon::connectTo(); #else if (!loadAndResolveFsxSimConnect(true)) { return false; } @@ -297,7 +293,7 @@ namespace BlackSimPlugin void CSimulatorP3DListener::startImpl() { #ifdef Q_OS_WIN64 - if (!loadAndResolveP3DSimConnect(gP3DSimConnectVersion)) { return; } + if (!loadAndResolveP3DSimConnectByString(m_p3dVersion.get())) { return; } return CSimulatorFsxCommonListener::startImpl(); #else if (!loadAndResolveFsxSimConnect(true)) { return; } diff --git a/src/plugins/simulator/p3d/simulatorp3d.h b/src/plugins/simulator/p3d/simulatorp3d.h index afe94da93..92694a75f 100644 --- a/src/plugins/simulator/p3d/simulatorp3d.h +++ b/src/plugins/simulator/p3d/simulatorp3d.h @@ -14,6 +14,8 @@ #include "../fsxcommon/simulatorfsxcommon.h" #include "../fsxcommon/simconnectobject.h" +#include "blackmisc/simulation/settings/simulatorsettings.h" +#include "blackmisc/settingscache.h" namespace BlackSimPlugin { @@ -70,9 +72,11 @@ namespace BlackSimPlugin //! \remark P3D API release of control virtual bool releaseAIControl(const FsxCommon::CSimConnectObject &simObject, SIMCONNECT_DATA_REQUEST_ID requestId) override; #endif - //! SimConnect Callback static void CALLBACK SimConnectProc(SIMCONNECT_RECV *pData, DWORD cbData, void *pContext); + + private: + BlackMisc::CSettingReadOnly m_p3dVersion { this }; }; //! Listener for P3D @@ -86,6 +90,9 @@ namespace BlackSimPlugin protected: virtual void startImpl() override; + + private: + BlackMisc::CSettingReadOnly m_p3dVersion { this }; }; } // ns } // ns