diff --git a/default.json b/default.json index 8a7e5accf..791c6d2bb 100644 --- a/default.json +++ b/default.json @@ -25,7 +25,8 @@ "fsuipc": true, "xplane": true, "xswiftbus": true, - "fg": true + "fg": true, + "fs2020": true }, "releaseWithDebugInfo": true, "profileRelease": false, diff --git a/installer/installbuilder/swift-plugin-simulators.xml b/installer/installbuilder/swift-plugin-simulators.xml index 21287dbb8..bf0775e3b 100644 --- a/installer/installbuilder/swift-plugin-simulators.xml +++ b/installer/installbuilder/swift-plugin-simulators.xml @@ -71,6 +71,38 @@ This plugin acts as the interface between swift and FSX. + + fs2020 + MS Flight Simulator 2020 + 1 + MS Flight Simulator 2020 Simulator Plugin +This plugin acts as the interface between swift and FS2020. + 1 + 1 + + + bin/plugins/simulator + ${installdir}/bin/plugins/simulator + bin_plugins_simulator + windows + + + ../../dist/bin/plugins/simulator/simulatorfs2020.dll + + + + + + + windows + + + equals + ${architecture} + 32 + + + p3d PREPAR3D diff --git a/mkspecs/features/common_pre.prf b/mkspecs/features/common_pre.prf index 6fa19fdae..99b9e5cd7 100644 --- a/mkspecs/features/common_pre.prf +++ b/mkspecs/features/common_pre.prf @@ -104,7 +104,7 @@ win32-g++: CONFIG += separate_debug_info ################################ !win32: disableSwiftConfig(sims.p3d) -equals(WORD_SIZE,64)|!win32: disableSwiftConfig(sims.fsx, sims.fs9) +equals(WORD_SIZE,64)|!win32: disableSwiftConfig(sims.fsx, sims.fs9, sims.fs2020) # equals(WORD_SIZE,64):win32-g++: disableSwiftConfig(sims.p3d) ################################ diff --git a/src/blackmisc/simulation/simulatorinfo.cpp b/src/blackmisc/simulation/simulatorinfo.cpp index d038b2e5f..063d3b78b 100644 --- a/src/blackmisc/simulation/simulatorinfo.cpp +++ b/src/blackmisc/simulation/simulatorinfo.cpp @@ -84,6 +84,11 @@ namespace BlackMisc return getSimulator().testFlag(FG); } + bool CSimulatorInfo::isFS2020() const + { + return getSimulator().testFlag(FS2020); + } + bool CSimulatorInfo::isAnySimulator() const { return isFSX() || isFS9() || isXPlane() || isP3D() || isFG(); @@ -260,6 +265,7 @@ namespace BlackMisc { s |= P3D; } + if (i.contains("fs2020")) { s |= FS2020; } return s; } diff --git a/src/blackmisc/simulation/simulatorinfo.h b/src/blackmisc/simulation/simulatorinfo.h index 66054f09b..d53f5240e 100644 --- a/src/blackmisc/simulation/simulatorinfo.h +++ b/src/blackmisc/simulation/simulatorinfo.h @@ -54,9 +54,10 @@ namespace BlackMisc XPLANE = 1 << 2, P3D = 1 << 3, FG = 1 << 4, + FS2020 = 1 << 5, FSX_P3D = FSX | P3D, - AllFsFamily = FSX | FS9 | P3D, - All = FSX | FS9 | XPLANE | P3D | FG + AllFsFamily = FSX | FS9 | P3D | FS2020, + All = FSX | FS9 | XPLANE | P3D | FG | FS2020 }; Q_DECLARE_FLAGS(Simulator, SimulatorFlag) @@ -99,6 +100,9 @@ namespace BlackMisc //! FG? bool isFG() const; + //! FS2020? + bool isFS2020() const; + //! Any simulator? bool isAnySimulator() const; diff --git a/src/blackmisc/simulation/simulatorplugininfo.cpp b/src/blackmisc/simulation/simulatorplugininfo.cpp index ed378d385..e62738b73 100644 --- a/src/blackmisc/simulation/simulatorplugininfo.cpp +++ b/src/blackmisc/simulation/simulatorplugininfo.cpp @@ -97,6 +97,12 @@ namespace BlackMisc return s; } + const QString &CSimulatorPluginInfo::fs2020PluginIdentifier() + { + static const QString s("org.swift-project.plugins.simulator.fs2020"); + return s; + } + const QString &CSimulatorPluginInfo::emulatedPluginIdentifier() { static const QString s("org.swift-project.plugins.simulator.emulated"); @@ -112,7 +118,8 @@ namespace BlackMisc xplanePluginIdentifier(), fs9PluginIdentifier(), emulatedPluginIdentifier(), - fgPluginIdentifier() + fgPluginIdentifier(), + fs2020PluginIdentifier() }); return identifiers; } @@ -128,6 +135,7 @@ namespace BlackMisc return QStringList { fsxPluginIdentifier(), + fs2020PluginIdentifier(), p3dPluginIdentifier(), xplanePluginIdentifier(), fgPluginIdentifier() diff --git a/src/blackmisc/simulation/simulatorplugininfo.h b/src/blackmisc/simulation/simulatorplugininfo.h index 92cb99262..ad37ffb02 100644 --- a/src/blackmisc/simulation/simulatorplugininfo.h +++ b/src/blackmisc/simulation/simulatorplugininfo.h @@ -85,6 +85,9 @@ namespace BlackMisc //! Plugin identifier (FlightGear) static const QString &fgPluginIdentifier(); + //! Plugin identifier (FS2020) + static const QString &fs2020PluginIdentifier(); + //! Plugin identifier (emulated simulator plugin) static const QString &emulatedPluginIdentifier(); diff --git a/src/plugins/simulator/fs2020/fs2020.pro b/src/plugins/simulator/fs2020/fs2020.pro new file mode 100644 index 000000000..8c12898a1 --- /dev/null +++ b/src/plugins/simulator/fs2020/fs2020.pro @@ -0,0 +1,30 @@ +load(common_pre) + +QT += core dbus widgets network + +TEMPLATE = lib + +CONFIG += plugin shared +CONFIG += blackconfig blackmisc blackcore blackgui +CONFIG += simulatorfsxcommon simulatorfscommon simulatorplugincommon simconnect + +DEPENDPATH += . $$SourceRoot/src +INCLUDEPATH += . $$SourceRoot/src +DESTDIR = $$DestRoot/bin/plugins/simulator + +SOURCES += *.cpp +HEADERS += *.h + +REQUIRES += swiftConfig(sims.fs2020) +TARGET = simulatorfs2020 +DISTFILES += simulatorfs2020.json + +win32 { + dlltarget.path = $$PREFIX/bin/plugins/simulator + INSTALLS += dlltarget +} else { + target.path = $$PREFIX/bin/plugins/simulator + INSTALLS += target +} + +load(common_post) diff --git a/src/plugins/simulator/fs2020/simulatorfs2020.cpp b/src/plugins/simulator/fs2020/simulatorfs2020.cpp new file mode 100644 index 000000000..6c22a8bd6 --- /dev/null +++ b/src/plugins/simulator/fs2020/simulatorfs2020.cpp @@ -0,0 +1,56 @@ +/* Copyright (C) 2020 + * swift Project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution. No part of swift project, including this file, may be copied, modified, propagated, + * or distributed except according to the terms contained in the LICENSE file. + */ + +#include "simulatorfs2020.h" +#include "../fsxcommon/simconnectsymbols.h" + +using namespace BlackMisc; +using namespace BlackMisc::Aviation; +using namespace BlackMisc::PhysicalQuantities; +using namespace BlackMisc::Geo; +using namespace BlackMisc::Network; +using namespace BlackMisc::Simulation; +using namespace BlackMisc::Simulation::FsCommon; +using namespace BlackMisc::Weather; +using namespace BlackCore; + +namespace BlackSimPlugin +{ + namespace Fs2020 + { + CSimulatorFs2020::CSimulatorFs2020(const CSimulatorPluginInfo &info, + IOwnAircraftProvider *ownAircraftProvider, + IRemoteAircraftProvider *remoteAircraftProvider, + IWeatherGridProvider *weatherGridProvider, + IClientProvider *clientProvider, + QObject *parent) : + CSimulatorFsxCommon(info, ownAircraftProvider, remoteAircraftProvider, weatherGridProvider, clientProvider, parent) + { + this->setDefaultModel( + { + "Airbus A320 Neo Asobo", + CAircraftModel::TypeModelMatchingDefaultModel, + "Airbus A320 default model", + CAircraftIcaoCode("A320", "L2J") + }); + } + + bool CSimulatorFs2020::connectTo() + { + if (!loadAndResolveFsxSimConnect(true)) { return false; } + return CSimulatorFsxCommon::connectTo(); + } + + void CSimulatorFs2020Listener::startImpl() + { + if (!loadAndResolveFsxSimConnect(true)) { return; } + return CSimulatorFsxCommonListener::startImpl(); + } + + } // ns +} // ns diff --git a/src/plugins/simulator/fs2020/simulatorfs2020.h b/src/plugins/simulator/fs2020/simulatorfs2020.h new file mode 100644 index 000000000..a638882bd --- /dev/null +++ b/src/plugins/simulator/fs2020/simulatorfs2020.h @@ -0,0 +1,55 @@ +/* Copyright (C) 2020 + * swift Project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution. No part of swift project, including this file, may be copied, modified, propagated, + * or distributed except according to the terms contained in the LICENSE file. + */ + +//! \file + +#ifndef BLACKSIMPLUGIN_FS2020_SIMULATORFS2020_H +#define BLACKSIMPLUGIN_FS2020_SIMULATORFS2020_H + +#include "../fsxcommon/simulatorfsxcommon.h" + +namespace BlackSimPlugin +{ + namespace Fs2020 + { + //! FSX simulator implementation + class CSimulatorFs2020 : public BlackSimPlugin::FsxCommon::CSimulatorFsxCommon + { + Q_OBJECT + + public: + //! Constructor, parameters as in \sa BlackCore::ISimulatorFactory::create + CSimulatorFs2020(const BlackMisc::Simulation::CSimulatorPluginInfo &info, + BlackMisc::Simulation::IOwnAircraftProvider *ownAircraftProvider, + BlackMisc::Simulation::IRemoteAircraftProvider *remoteAircraftProvider, + BlackMisc::Weather::IWeatherGridProvider *weatherGridProvider, + BlackMisc::Network::IClientProvider *clientProvider, + QObject *parent = nullptr); + + //! \name ISimulator implementations + //! @{ + virtual bool connectTo() override; + //! @} + }; + + //! Listener for FSX + class CSimulatorFs2020Listener : public FsxCommon::CSimulatorFsxCommonListener + { + Q_OBJECT + + public: + //! Constructor + using CSimulatorFsxCommonListener::CSimulatorFsxCommonListener; + + protected: + virtual void startImpl() override; + }; + } // ns +} // ns + +#endif // guard diff --git a/src/plugins/simulator/fs2020/simulatorfs2020.json b/src/plugins/simulator/fs2020/simulatorfs2020.json new file mode 100644 index 000000000..daaabfff4 --- /dev/null +++ b/src/plugins/simulator/fs2020/simulatorfs2020.json @@ -0,0 +1,6 @@ +{ + "identifier" : "org.swift-project.plugins.simulator.fs2020", + "name" : "Flight Simulator 2020", + "simulator" : "fsx", + "description" : "Microsoft Flight Simulator 2020" +} diff --git a/src/plugins/simulator/fs2020/simulatorfs2020factory.cpp b/src/plugins/simulator/fs2020/simulatorfs2020factory.cpp new file mode 100644 index 000000000..a47b6fc3b --- /dev/null +++ b/src/plugins/simulator/fs2020/simulatorfs2020factory.cpp @@ -0,0 +1,37 @@ +/* Copyright (C) 2013 + * swift Project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution. No part of swift project, including this file, may be copied, modified, propagated, + * or distributed except according to the terms contained in the LICENSE file. + */ + +#include "simulatorfs2020factory.h" +#include "simulatorfs2020.h" +#include "blackmisc/simulation/simulatorplugininfo.h" + +using namespace BlackMisc::Network; +using namespace BlackMisc::Simulation; +using namespace BlackMisc::Weather; +using namespace BlackCore; + +namespace BlackSimPlugin +{ + namespace Fs2020 + { + ISimulator *CSimulatorFs2020Factory::create(const CSimulatorPluginInfo &info, + IOwnAircraftProvider *ownAircraftProvider, + IRemoteAircraftProvider *remoteAircraftProvider, + IWeatherGridProvider *weatherGridProvider, + IClientProvider *clientProvider) + { + Q_ASSERT(ownAircraftProvider); + return new CSimulatorFs2020(info, ownAircraftProvider, remoteAircraftProvider, weatherGridProvider, clientProvider, this); + } + + ISimulatorListener *CSimulatorFs2020Factory::createListener(const CSimulatorPluginInfo &info) + { + return new CSimulatorFs2020Listener(info); + } + } // namespace +} // namespace diff --git a/src/plugins/simulator/fs2020/simulatorfs2020factory.h b/src/plugins/simulator/fs2020/simulatorfs2020factory.h new file mode 100644 index 000000000..fcf881e76 --- /dev/null +++ b/src/plugins/simulator/fs2020/simulatorfs2020factory.h @@ -0,0 +1,47 @@ +/* Copyright (C) 2013 + * swift Project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution. No part of swift project, including this file, may be copied, modified, propagated, + * or distributed except according to the terms contained in the LICENSE file. + */ + +//! \file + +#ifndef BLACKSIMPLUGIN_SIMULATOR_FSXFACTORY_H +#define BLACKSIMPLUGIN_SIMULATOR_FSXFACTORY_H + +#include "blackcore/simulator.h" +#include "blackmisc/simulation/simulatorplugininfo.h" + +#include +#include + +namespace BlackSimPlugin +{ + namespace Fs2020 + { + //! Factory implementation to create CSimulatorFsx instances + class CSimulatorFs2020Factory : + public QObject, + public BlackCore::ISimulatorFactory + { + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.swift-project.blackcore.simulatorinterface" FILE "simulatorfs2020.json") + Q_INTERFACES(BlackCore::ISimulatorFactory) + + public: + //! \copydoc BlackCore::ISimulatorFactory::create + virtual BlackCore::ISimulator *create(const BlackMisc::Simulation::CSimulatorPluginInfo &info, + BlackMisc::Simulation::IOwnAircraftProvider *ownAircraftProvider, + BlackMisc::Simulation::IRemoteAircraftProvider *remoteAircraftProvider, + BlackMisc::Weather::IWeatherGridProvider *weatherGridProvider, + BlackMisc::Network::IClientProvider *clientProvider) override; + + //! \copydoc BlackCore::ISimulatorFactory::createListener + virtual BlackCore::ISimulatorListener *createListener(const BlackMisc::Simulation::CSimulatorPluginInfo &info) override; + }; + } // namespace +} // namespace + +#endif // guard diff --git a/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp b/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp index c67b4a965..684385dbb 100644 --- a/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp +++ b/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp @@ -2917,6 +2917,11 @@ namespace BlackSimPlugin // FSX drivers only works with FSX return connectedSimName.contains("fsx") || connectedSimName.contains("microsoft") || connectedSimName.contains("simulator x"); } + else if (pluginSim.isFS2020()) + { + // FS2020 drivers only works with FS2020 + return connectedSimName.contains("kittyhawk"); + } return false; } diff --git a/src/plugins/simulator/simulator.pro b/src/plugins/simulator/simulator.pro index e4b3c12a7..544c8244e 100644 --- a/src/plugins/simulator/simulator.pro +++ b/src/plugins/simulator/simulator.pro @@ -34,4 +34,7 @@ swiftConfig(sims.fg) { SUBDIRS += flightgear SUBDIRS += flightgearconfig } +swiftConfig(sims.fs2020) { + SUBDIRS += fs2020 +} load(common_post)