From 177ee27654db0ba796e16c73be3fa4033b058cb4 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Mon, 1 Oct 2018 23:29:23 +0200 Subject: [PATCH] Make FSUIPC/SB offsets configurable * based https://swift-project.slack.com/archives/CC6THKCAZ/p1538387046000100 * "dot" commands added * Plugin settings --- .../simulator/fscommon/simulatorfscommon.h | 2 +- .../fsxcommon/fsxsettingscomponent.cpp | 18 ++++++ .../fsxcommon/fsxsettingscomponent.h | 6 ++ .../fsxcommon/fsxsettingscomponent.ui | 61 +++++++++++++++---- .../fsxcommon/simulatorfsxcommon.cpp | 11 ++++ .../simulator/fsxcommon/simulatorfsxcommon.h | 12 +++- 6 files changed, 93 insertions(+), 17 deletions(-) diff --git a/src/plugins/simulator/fscommon/simulatorfscommon.h b/src/plugins/simulator/fscommon/simulatorfscommon.h index c48b6cdee..4453e6d84 100644 --- a/src/plugins/simulator/fscommon/simulatorfscommon.h +++ b/src/plugins/simulator/fscommon/simulatorfscommon.h @@ -75,7 +75,7 @@ namespace BlackSimPlugin static void registerHelp(); std::unique_ptr m_fsuipc; //!< FSUIPC - bool m_useFsuipc = true; //!< use FSUIPC + bool m_useFsuipc = false; //!< use FSUIPC bool m_simPaused = false; //!< Simulator paused? bool m_simTimeSynced = false; //!< Time synchronized? BlackMisc::PhysicalQuantities::CTime m_syncTimeOffset; //!< time offset diff --git a/src/plugins/simulator/fsxcommon/fsxsettingscomponent.cpp b/src/plugins/simulator/fsxcommon/fsxsettingscomponent.cpp index f509304c8..6babf7f17 100644 --- a/src/plugins/simulator/fsxcommon/fsxsettingscomponent.cpp +++ b/src/plugins/simulator/fsxcommon/fsxsettingscomponent.cpp @@ -33,6 +33,8 @@ namespace BlackSimPlugin connect(ui->cb_TraceSimConnectCalls, &QCheckBox::released, this, &CFsxSettingsComponent::onSimConnectTraceChanged); connect(ui->cb_EnableTerrainProbe, &QCheckBox::released, this, &CFsxSettingsComponent::onEnableTerrainProbeChanged); + connect(ui->cb_UseFsuipc, &QCheckBox::released, this, &CFsxSettingsComponent::onFsuipcChanged); + connect(ui->cb_SBOffsets, &QCheckBox::released, this, &CFsxSettingsComponent::onSBOffsetsChanged); connect(ui->pb_CopyTerrainProbe, &QPushButton::released, this, &CFsxSettingsComponent::copyTerrainProbe); const CSimulatorFsxCommon *fsx = this->getFsxSimulator(); @@ -40,6 +42,8 @@ namespace BlackSimPlugin { ui->cb_TraceSimConnectCalls->setChecked(fsx->isTracingSendId()); ui->cb_EnableTerrainProbe->setChecked(fsx->isUsingFsxTerrainProbe()); + ui->cb_SBOffsets->setChecked(fsx->isUsingSbOffsetValues()); + ui->cb_UseFsuipc->setChecked(fsx->isFsuipcConnected()); } } @@ -66,6 +70,20 @@ namespace BlackSimPlugin fsx->setUsingFsxTerrainProbe(ui->cb_EnableTerrainProbe->isChecked()); } + void CFsxSettingsComponent::onFsuipcChanged() + { + CSimulatorFsxCommon *fsx = this->getFsxSimulator(); + if (!fsx) { return; } + fsx->useFsuipc(ui->cb_UseFsuipc->isChecked()); + } + + void CFsxSettingsComponent::onSBOffsetsChanged() + { + CSimulatorFsxCommon *fsx = this->getFsxSimulator(); + if (!fsx) { return; } + fsx->setUsingSbOffsetValues(ui->cb_SBOffsets->isChecked()); + } + void CFsxSettingsComponent::copyTerrainProbe() { if (!sGui || !sGui->getIContextSimulator() || sGui->isShuttingDown()) { return; } diff --git a/src/plugins/simulator/fsxcommon/fsxsettingscomponent.h b/src/plugins/simulator/fsxcommon/fsxsettingscomponent.h index df269ec70..a5f69b051 100644 --- a/src/plugins/simulator/fsxcommon/fsxsettingscomponent.h +++ b/src/plugins/simulator/fsxcommon/fsxsettingscomponent.h @@ -49,6 +49,12 @@ namespace BlackSimPlugin //! Terrain probe checkbox changed void onEnableTerrainProbeChanged(); + //! FSUIPC setting changed + void onFsuipcChanged(); + + //! Offsets on/off + void onSBOffsetsChanged(); + //! Copy the terrain probe void copyTerrainProbe(); diff --git a/src/plugins/simulator/fsxcommon/fsxsettingscomponent.ui b/src/plugins/simulator/fsxcommon/fsxsettingscomponent.ui index e40aa2de8..e19d43838 100644 --- a/src/plugins/simulator/fsxcommon/fsxsettingscomponent.ui +++ b/src/plugins/simulator/fsxcommon/fsxsettingscomponent.ui @@ -7,20 +7,13 @@ 0 0 180 - 87 + 121 FSX/P3D settings - - - - - Use the terrain probe - - - + @@ -28,10 +21,10 @@ - - + + - copy terrain probe + @@ -45,15 +38,57 @@ - + + + + Enable SB SimConnect offsets + + + + + + + Use the terrain probe + + + + + + + + + + + + + + + Enable FSUIPC support + + + + + + + copy terrain probe + + + + + cb_TraceSimConnectCalls + cb_UseFsuipc + cb_SBOffsets + cb_EnableTerrainProbe + pb_CopyTerrainProbe + diff --git a/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp b/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp index f8d97774b..210c18f44 100644 --- a/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp +++ b/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp @@ -1198,6 +1198,16 @@ namespace BlackSimPlugin CLogMessage(this, CLogCategory::cmdLine()).info("Tracing %1 driver sendIds is '%2'") << this->getSimulatorPluginInfo().getIdentifier() << boolToOnOff(trace); return true; } + + // .driver sboffsets on|off + if (parser.matchesPart(1, "sboffsets") && parser.hasPart(2)) + { + const bool on = parser.toBool(2); + this->setUsingSbOffsetValues(on); + CLogMessage(this, CLogCategory::cmdLine()).info("SB offsets is '%1'") << boolToOnOff(on); + return true; + } + return CSimulatorFsCommon::parseDetails(parser); } @@ -1206,6 +1216,7 @@ namespace BlackSimPlugin if (CSimpleCommandParser::registered("BlackSimPlugin::CSimulatorFsxCommon::CSimulatorFsxCommon")) { return; } CSimpleCommandParser::registerCommand({".drv", "alias: .driver .plugin"}); CSimpleCommandParser::registerCommand({".drv sendid on|off", "Trace simConnect sendId on|off"}); + CSimpleCommandParser::registerCommand({".drv sboffsets on|off", "SB offsets via simConnect on|off"}); } CCallsign CSimulatorFsxCommon::getCallsignForPendingProbeRequests(DWORD requestId, bool remove) diff --git a/src/plugins/simulator/fsxcommon/simulatorfsxcommon.h b/src/plugins/simulator/fsxcommon/simulatorfsxcommon.h index c7d9824c7..89ad9ed3d 100644 --- a/src/plugins/simulator/fsxcommon/simulatorfsxcommon.h +++ b/src/plugins/simulator/fsxcommon/simulatorfsxcommon.h @@ -168,6 +168,12 @@ namespace BlackSimPlugin //! FSX terrain probe void setUsingFsxTerrainProbe(bool use) { m_useFsxTerrainProbe = use; } + //! Using the SB offsets? + bool isUsingSbOffsetValues() const { return m_useSbOffsets; } + + //! Use SB offset values + void setUsingSbOffsetValues(bool use) { m_useSbOffsets = use; } + //! Request for sim data (request in range of sim data)? static bool isRequestForSimObjAircraft(DWORD requestId) { return requestId >= RequestSimObjAircraftStart && requestId <= RequestSimObjAircraftRangeEnd; } @@ -220,7 +226,7 @@ namespace BlackSimPlugin //! \addtogroup swiftdotcommands //! @{ //!
-            //! .drv sendid  on|off      tracing simCOnnect sendId on/off
+            //! .drv sendid  on|off      tracing simConnect sendId on/off
             //! 
//! @} virtual bool parseDetails(const BlackMisc::CSimpleCommandParser &parser) override; @@ -272,9 +278,9 @@ namespace BlackSimPlugin CSimConnectObjects m_simConnectObjects; //!< AI objects and their object and request ids // probes - bool m_useFsxTerrainProbe = true; //!< Use FSX Terrain probe? + bool m_useFsxTerrainProbe = true; //!< Use FSX Terrain probe? bool m_initFsxTerrainProbes = false; //!< initialized terrain probes - int m_addedProbes = 0; //!< added probes + int m_addedProbes = 0; //!< added probes QMap m_pendingProbeRequests; //!< pending elevation requests: requestId/aircraft callsign private: