mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-05 17:55:45 +08:00
@@ -15,7 +15,7 @@ contains(BLACK_CONFIG, BlackSim) {
|
||||
SUBDIRS += src/blacksim
|
||||
|
||||
contains(BLACK_CONFIG, FSX) {
|
||||
SUBDIRS += src/blacksim/fsx/plugin_fsx.pro
|
||||
SUBDIRS += src/plugins/simulator/fsx/plugin_fsx.pro
|
||||
}
|
||||
|
||||
contains(BLACK_CONFIG, XPlane) {
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace BlackCore
|
||||
|
||||
void CContextSimulator::loadPlugins()
|
||||
{
|
||||
m_pluginsDir = QDir(qApp->applicationDirPath().append("/plugins"));
|
||||
m_pluginsDir = QDir(qApp->applicationDirPath().append("/plugins/simulator"));
|
||||
if (!m_pluginsDir.exists())
|
||||
{
|
||||
qWarning() << "No plugin directory" << m_pluginsDir.currentPath();
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
include (../../../config.pri)
|
||||
include (../../../build.pri)
|
||||
|
||||
QT += core dbus gui network
|
||||
|
||||
TARGET = simulator_fsx
|
||||
TEMPLATE = lib
|
||||
|
||||
CONFIG += plugin shared
|
||||
CONFIG += blackmisc blackcore blacksim
|
||||
|
||||
LIBS += -lSimConnect
|
||||
|
||||
DEPENDPATH += . ../../../src
|
||||
INCLUDEPATH += . ../../../src
|
||||
|
||||
SOURCES += *.cpp
|
||||
HEADERS += *.h
|
||||
|
||||
win32:!win32-g++*: PRE_TARGETDEPS += ../../../lib/blackmisc.lib \
|
||||
../../../lib/blacksim.lib \
|
||||
../../../lib/blackcore.lib
|
||||
else: PRE_TARGETDEPS += ../../../lib/libblackmisc.a \
|
||||
../../../lib/libblacksim.a \
|
||||
../../../lib/libblackcore.a
|
||||
|
||||
DESTDIR = ../../../bin/plugins
|
||||
include (../../../libraries.pri)
|
||||
28
src/plugins/simulator/fsx/plugin_fsx.pro
Normal file
28
src/plugins/simulator/fsx/plugin_fsx.pro
Normal file
@@ -0,0 +1,28 @@
|
||||
include (../../../../config.pri)
|
||||
include (../../../../build.pri)
|
||||
|
||||
QT += core dbus gui network
|
||||
|
||||
TARGET = simulator_fsx
|
||||
TEMPLATE = lib
|
||||
|
||||
CONFIG += plugin shared
|
||||
CONFIG += blackmisc blackcore blacksim
|
||||
|
||||
LIBS += -lSimConnect
|
||||
|
||||
DEPENDPATH += . ../../../../src
|
||||
INCLUDEPATH += . ../../../../src
|
||||
|
||||
SOURCES += *.cpp
|
||||
HEADERS += *.h
|
||||
|
||||
win32:!win32-g++*: PRE_TARGETDEPS += ../../../../lib/blackmisc.lib \
|
||||
../../../../lib/blacksim.lib \
|
||||
../../../../lib/blackcore.lib
|
||||
else: PRE_TARGETDEPS += ../../../../lib/libblackmisc.a \
|
||||
../../../../lib/libblacksim.a \
|
||||
../../../../lib/libblackcore.a
|
||||
|
||||
DESTDIR = ../../../../bin/plugins/simulator
|
||||
include (../../../../libraries.pri)
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
namespace BlackSimPlugin
|
||||
{
|
||||
namespace FSX
|
||||
namespace Fsx
|
||||
{
|
||||
|
||||
CSimConnectDataDefinition::CSimConnectDataDefinition()
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
namespace BlackSimPlugin
|
||||
{
|
||||
namespace FSX
|
||||
namespace Fsx
|
||||
{
|
||||
//! \brief Data struct of our own aircraft
|
||||
struct DataDefinitionOwnAircraft
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
namespace BlackSimPlugin
|
||||
{
|
||||
namespace FSX
|
||||
namespace Fsx
|
||||
{
|
||||
CSimConnectException::CSimConnectException()
|
||||
{
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
namespace BlackSimPlugin
|
||||
{
|
||||
namespace FSX
|
||||
namespace Fsx
|
||||
{
|
||||
//! \brief Handles SimConnect exceptions
|
||||
class CSimConnectException
|
||||
@@ -18,14 +18,14 @@ using namespace BlackSim::Fsx;
|
||||
|
||||
namespace BlackSimPlugin
|
||||
{
|
||||
namespace FSX
|
||||
namespace Fsx
|
||||
{
|
||||
BlackCore::ISimulator *CSimulatorFsxFactory::create(QObject *parent)
|
||||
{
|
||||
return new FSX::CSimulatorFSX(parent);
|
||||
return new Fsx::CSimulatorFsx(parent);
|
||||
}
|
||||
|
||||
CSimulatorFSX::CSimulatorFSX(QObject *parent) :
|
||||
CSimulatorFsx::CSimulatorFsx(QObject *parent) :
|
||||
ISimulator(parent),
|
||||
m_isConnected(false),
|
||||
m_simRunning(false),
|
||||
@@ -39,12 +39,12 @@ namespace BlackSimPlugin
|
||||
QTimer::singleShot(5000, this, SLOT(checkConnection()));
|
||||
}
|
||||
|
||||
bool CSimulatorFSX::isConnected() const
|
||||
bool CSimulatorFsx::isConnected() const
|
||||
{
|
||||
return m_isConnected;
|
||||
}
|
||||
|
||||
void CSimulatorFSX::addRemoteAircraft(const CCallsign &callsign, const QString &type, const CAircraftSituation &initialSituation)
|
||||
void CSimulatorFsx::addRemoteAircraft(const CCallsign &callsign, const QString &type, const CAircraftSituation &initialSituation)
|
||||
{
|
||||
Q_UNUSED(type);
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace BlackSimPlugin
|
||||
Q_UNUSED(hr);
|
||||
}
|
||||
|
||||
void CSimulatorFSX::addAircraftSituation(const CCallsign &callsign, const CAircraftSituation &situation)
|
||||
void CSimulatorFsx::addAircraftSituation(const CCallsign &callsign, const CAircraftSituation &situation)
|
||||
{
|
||||
if (!m_simConnectObjects.contains(callsign))
|
||||
{
|
||||
@@ -83,19 +83,19 @@ namespace BlackSimPlugin
|
||||
m_simConnectObjects.insert(callsign, simObj);
|
||||
}
|
||||
|
||||
void CSimulatorFSX::removeRemoteAircraft(const CCallsign &/*callsign*/)
|
||||
void CSimulatorFsx::removeRemoteAircraft(const CCallsign &/*callsign*/)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
CSimulatorInfo CSimulatorFSX::getSimulatorInfo() const
|
||||
CSimulatorInfo CSimulatorFsx::getSimulatorInfo() const
|
||||
{
|
||||
return this->m_simulatorInfo;
|
||||
}
|
||||
|
||||
void CALLBACK CSimulatorFSX::SimConnectProc(SIMCONNECT_RECV *pData, DWORD /* cbData */, void *pContext)
|
||||
void CALLBACK CSimulatorFsx::SimConnectProc(SIMCONNECT_RECV *pData, DWORD /* cbData */, void *pContext)
|
||||
{
|
||||
CSimulatorFSX *simulatorFsx = static_cast<CSimulatorFSX *>(pContext);
|
||||
CSimulatorFsx *simulatorFsx = static_cast<CSimulatorFsx *>(pContext);
|
||||
|
||||
switch (pData->dwID)
|
||||
{
|
||||
@@ -168,7 +168,7 @@ namespace BlackSimPlugin
|
||||
}
|
||||
}
|
||||
|
||||
void CSimulatorFSX::onSimRunning()
|
||||
void CSimulatorFsx::onSimRunning()
|
||||
{
|
||||
m_simRunning = true;
|
||||
SimConnect_RequestDataOnSimObject(m_hSimConnect, CSimConnectDataDefinition::RequestOwnAircraft,
|
||||
@@ -176,21 +176,21 @@ namespace BlackSimPlugin
|
||||
SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_PERIOD_VISUAL_FRAME);
|
||||
}
|
||||
|
||||
void CSimulatorFSX::onSimStopped()
|
||||
void CSimulatorFsx::onSimStopped()
|
||||
{
|
||||
m_simRunning = false;
|
||||
}
|
||||
|
||||
void CSimulatorFSX::onSimFrame()
|
||||
void CSimulatorFsx::onSimFrame()
|
||||
{
|
||||
}
|
||||
|
||||
void CSimulatorFSX::onSimExit()
|
||||
void CSimulatorFsx::onSimExit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CSimulatorFSX::setOwnAircraft(DataDefinitionOwnAircraft aircraft)
|
||||
void CSimulatorFsx::setOwnAircraft(DataDefinitionOwnAircraft aircraft)
|
||||
{
|
||||
BlackMisc::Geo::CCoordinateGeodetic position;
|
||||
position.setLatitude(CLatitude(aircraft.latitude, CAngleUnit::deg()));
|
||||
@@ -220,7 +220,7 @@ namespace BlackSimPlugin
|
||||
m_ownAircraft.setTransponder(transponder);
|
||||
}
|
||||
|
||||
void CSimulatorFSX::setSimconnectObjectID(DWORD requestID, DWORD objectID)
|
||||
void CSimulatorFsx::setSimconnectObjectID(DWORD requestID, DWORD objectID)
|
||||
{
|
||||
SimConnect_AIReleaseControl(m_hSimConnect, objectID, requestID);
|
||||
SimConnect_TransmitClientEvent(m_hSimConnect, objectID, EVENT_FREEZELAT, 1,
|
||||
@@ -251,13 +251,13 @@ namespace BlackSimPlugin
|
||||
|
||||
}
|
||||
|
||||
void CSimulatorFSX::timerEvent(QTimerEvent * /* event */)
|
||||
void CSimulatorFsx::timerEvent(QTimerEvent * /* event */)
|
||||
{
|
||||
dispatch();
|
||||
update();
|
||||
}
|
||||
|
||||
void CSimulatorFSX::checkConnection()
|
||||
void CSimulatorFsx::checkConnection()
|
||||
{
|
||||
if (FAILED(SimConnect_Open(&m_hSimConnect, "BlackBox", nullptr, 0, 0, 0)))
|
||||
{
|
||||
@@ -273,12 +273,12 @@ namespace BlackSimPlugin
|
||||
emit connectionChanged(true);
|
||||
}
|
||||
|
||||
void CSimulatorFSX::dispatch()
|
||||
void CSimulatorFsx::dispatch()
|
||||
{
|
||||
SimConnect_CallDispatch(m_hSimConnect, SimConnectProc, this);
|
||||
}
|
||||
|
||||
HRESULT CSimulatorFSX::initSystemEvents()
|
||||
HRESULT CSimulatorFsx::initSystemEvents()
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
// System events
|
||||
@@ -292,12 +292,12 @@ namespace BlackSimPlugin
|
||||
return hr;
|
||||
}
|
||||
|
||||
HRESULT CSimulatorFSX::initDataDefinitions()
|
||||
HRESULT CSimulatorFsx::initDataDefinitions()
|
||||
{
|
||||
return CSimConnectDataDefinition::initDataDefinitions(m_hSimConnect);
|
||||
}
|
||||
|
||||
void CSimulatorFSX::update()
|
||||
void CSimulatorFsx::update()
|
||||
{
|
||||
foreach(SimConnectObject simObj, m_simConnectObjects)
|
||||
{
|
||||
@@ -23,9 +23,9 @@
|
||||
|
||||
namespace BlackSimPlugin
|
||||
{
|
||||
namespace FSX
|
||||
namespace Fsx
|
||||
{
|
||||
//! \brief Factory implementation to create CSimulatorFSX instances
|
||||
//! \brief Factory implementation to create CSimulatorFsx instances
|
||||
class Q_DECL_EXPORT CSimulatorFsxFactory : public QObject, public BlackCore::ISimulatorFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -51,12 +51,12 @@ namespace BlackSimPlugin
|
||||
};
|
||||
|
||||
//! \brief FSX Simulator Implementation
|
||||
class CSimulatorFSX : public BlackCore::ISimulator
|
||||
class CSimulatorFsx : public BlackCore::ISimulator
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
//! \brief Constructor
|
||||
CSimulatorFSX(QObject *parent = nullptr);
|
||||
CSimulatorFsx(QObject *parent = nullptr);
|
||||
|
||||
//! \copydoc ISimulator::isConnected()
|
||||
virtual bool isConnected() const override;
|
||||
Reference in New Issue
Block a user