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

@@ -25,7 +25,8 @@
"fsuipc": true,
"xplane": true,
"xswiftbus": true,
"fg": true
"fg": true,
"fs2020": true
},
"releaseWithDebugInfo": true,
"profileRelease": false,

View File

@@ -71,6 +71,38 @@ This plugin acts as the interface between swift and FSX.</detailedDescription>
</compareText>
</shouldPackRuleList>
</component>
<component>
<name>fs2020</name>
<description>MS Flight Simulator 2020</description>
<canBeEdited>1</canBeEdited>
<detailedDescription>MS Flight Simulator 2020 Simulator Plugin
This plugin acts as the interface between swift and FS2020.</detailedDescription>
<selected>1</selected>
<show>1</show>
<folderList>
<folder>
<description>bin/plugins/simulator</description>
<destination>${installdir}/bin/plugins/simulator</destination>
<name>bin_plugins_simulator</name>
<platforms>windows</platforms>
<distributionFileList>
<distributionFile>
<origin>../../dist/bin/plugins/simulator/simulatorfs2020.dll</origin>
</distributionFile>
</distributionFileList>
</folder>
</folderList>
<shouldPackRuleList>
<platformTest>
<type>windows</type>
</platformTest>
<compareText>
<logic>equals</logic>
<text>${architecture}</text>
<value>32</value>
</compareText>
</shouldPackRuleList>
</component>
<component>
<name>p3d</name>
<description>PREPAR3D</description>

View File

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

View File

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

View File

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

View File

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

View File

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

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)