[FS9] Implement time synchronisation

This commit is contained in:
Roland Rossgotterer
2019-03-12 16:26:34 +01:00
committed by Mat Sutcliffe
parent 464528da9a
commit 6a5e59b76a
5 changed files with 51 additions and 0 deletions

View File

@@ -53,6 +53,9 @@ namespace BlackSimPlugin
//! Write weather grid to simulator
bool write(const BlackMisc::Weather::CWeatherGrid &weatherGrid);
//! Set simulator time
bool setSimulatorTime(int hour, int minute);
//! Get the version
QString getVersion() const;

View File

@@ -66,6 +66,13 @@ namespace BlackSimPlugin
return false;
}
bool CFsuipc::setSimulatorTime(int hour, int minute)
{
Q_UNUSED(hour);
Q_UNUSED(minute);
return false;
}
QString CFsuipc::getVersion() const
{
return QStringLiteral("N/A");

View File

@@ -330,6 +330,23 @@ namespace BlackSimPlugin
return true;
}
bool CFsuipc::setSimulatorTime(int hour, int minute)
{
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "Open not threadsafe");
if (!this->isOpened()) { return false; }
// should be the same as writing via SimConnect data area
DWORD dwResult;
quint8 hourRaw = hour;
quint8 minuteRaw = minute;
const bool ok =
FSUIPC_Write(0x023b, 1, &hourRaw, &dwResult) &&
FSUIPC_Write(0x023c, 1, &minuteRaw, &dwResult);
if (ok) { FSUIPC_Process(&dwResult); }
return ok && dwResult == 0;
}
QString CFsuipc::getVersion() const
{
return m_fsuipcVersion;