Add initial simulator plugin support for FS2020

This adds simulator plugin support for FS2020. It still pretends to be FSX until full integration is completed.
This commit is contained in:
Roland Rossgotterer
2020-09-12 13:19:38 +02:00
committed by Mat Sutcliffe
parent aa32544b53
commit 3baab2ae4d
15 changed files with 298 additions and 5 deletions

View File

@@ -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)

View File

@@ -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

View File

@@ -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

View File

@@ -0,0 +1,6 @@
{
"identifier" : "org.swift-project.plugins.simulator.fs2020",
"name" : "Flight Simulator 2020",
"simulator" : "fsx",
"description" : "Microsoft Flight Simulator 2020"
}

View File

@@ -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

View File

@@ -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 <QObject>
#include <QtPlugin>
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

View File

@@ -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;
}

View File

@@ -34,4 +34,7 @@ swiftConfig(sims.fg) {
SUBDIRS += flightgear
SUBDIRS += flightgearconfig
}
swiftConfig(sims.fs2020) {
SUBDIRS += fs2020
}
load(common_post)