Refactored dataref manipulation operations to the DataManager class.
This commit is contained in:
551
xpcPlugin/DataManager.cpp
Normal file
551
xpcPlugin/DataManager.cpp
Normal file
@@ -0,0 +1,551 @@
|
||||
//Copyright (c) 2013-2015 United States Government as represented by the Administrator of the
|
||||
//National Aeronautics and Space Administration. All Rights Reserved.
|
||||
//
|
||||
//X-Plane API
|
||||
//Copyright(c) 2008, Sandy Barbour and Ben Supnik All rights reserved.
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
//associated documentation files(the "Software"), to deal in the Software without restriction,
|
||||
//including without limitation the rights to use, copy, modify, merge, publish, distribute,
|
||||
//sublicense, and / or sell copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions :
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
// * Neither the names of the authors nor that of X - Plane or Laminar Research
|
||||
// may be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission from the authors or
|
||||
// Laminar Research, respectively.
|
||||
#include "DataManager.h"
|
||||
#include "Log.h"
|
||||
|
||||
#include "XPLMDataAccess.h"
|
||||
#include "XPLMGraphics.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace XPC
|
||||
{
|
||||
static std::unordered_map<DREF, XPLMDataRef> drefs;
|
||||
static std::unordered_map<DREF, XPLMDataRef> mdrefs[20];
|
||||
static std::unordered_map<std::string, XPLMDataRef> sdrefs;
|
||||
|
||||
void DataManager::Initialize()
|
||||
{
|
||||
drefs = std::unordered_map<DREF, XPLMDataRef>(
|
||||
{
|
||||
{ DREF::None, XPLMFindDataRef("sim/test/test_float") },
|
||||
|
||||
{ DREF::Pause, XPLMFindDataRef("sim/operation/override/override_planepath") },
|
||||
{ DREF::PauseAI, XPLMFindDataRef("sim/operation/override/override_plane_ai_autopilot") },
|
||||
|
||||
{ DREF::TotalRuntime, XPLMFindDataRef("sim/time/total_running_time_sec") },
|
||||
{ DREF::TotalFlighttime, XPLMFindDataRef("sim/time/total_flight_time_sec") },
|
||||
{ DREF::TimerElapsedtime, XPLMFindDataRef("sim/time/timer_elapsed_time_sec") },
|
||||
|
||||
{ DREF::IndicatedAirspeed, XPLMFindDataRef("sim/flightmodel/position/indicated_airspeed") },
|
||||
{ DREF::TrueAirspeed, XPLMFindDataRef("sim/flightmodel/position/true_airspeed") },
|
||||
{ DREF::GroundSpeed, XPLMFindDataRef("sim/flightmodel/position/groundspeed") },
|
||||
|
||||
{ DREF::MachNumber, XPLMFindDataRef("sim/flightmodel/misc/machno") },
|
||||
{ DREF::GForceNormal, XPLMFindDataRef("sim/flightmodel2/misc/gforce_normal") },
|
||||
{ DREF::GForceAxial, XPLMFindDataRef("sim/flightmodel2/misc/gforce_axial") },
|
||||
{ DREF::GForceSide, XPLMFindDataRef("sim/flightmodel2/misc/gforce_side") },
|
||||
|
||||
{ DREF::BarometerSealevelInHg, XPLMFindDataRef("sim/weather/barometer_sealevel_inhg") },
|
||||
{ DREF::TemperaturSealevelC, XPLMFindDataRef("sim/weather/temperature_sealevel_c") },
|
||||
{ DREF::WindSpeedKts, XPLMFindDataRef("sim/cockpit2/gauges/indicators/wind_speed_kts") },
|
||||
|
||||
{ DREF::YokePitch, XPLMFindDataRef("sim/joystick/yoke_pitch_ratio") },
|
||||
{ DREF::YokeRoll, XPLMFindDataRef("sim/joystick/yoke_roll_ratio") },
|
||||
{ DREF::YokeHeading, XPLMFindDataRef("sim/joystick/yoke_heading_ratio") },
|
||||
|
||||
{ DREF::Elevator, XPLMFindDataRef("sim/cockpit2/controls/yoke_pitch_ratio") },
|
||||
{ DREF::Aileron, XPLMFindDataRef("sim/cockpit2/controls/yoke_roll_ratio") },
|
||||
{ DREF::Rudder, XPLMFindDataRef("sim/cockpit2/controls/yoke_heading_ratio") },
|
||||
|
||||
{ DREF::FlapSetting, XPLMFindDataRef("sim/flightmodel/controls/flaprqst") },
|
||||
{ DREF::FlapActual, XPLMFindDataRef("sim/flightmodel/controls/flaprat") },
|
||||
|
||||
{ DREF::GearDeploy, XPLMFindDataRef("sim/aircraft/parts/acf_gear_deploy") },
|
||||
{ DREF::GearHandle, XPLMFindDataRef("sim/cockpit/switches/gear_handle_status") },
|
||||
{ DREF::BrakeParking, XPLMFindDataRef("sim/flightmodel/controls/parkbrakel") },
|
||||
{ DREF::BrakeLeft, XPLMFindDataRef("sim/cockpit2/controls/left_brake_ratio") },
|
||||
{ DREF::BrakeRight, XPLMFindDataRef("sim/cockpit2/controls/right_brake_ratio") },
|
||||
|
||||
{ DREF::M, XPLMFindDataRef("sim/flightmodel/position/M") },
|
||||
{ DREF::L, XPLMFindDataRef("sim/flightmodel/position/L") },
|
||||
{ DREF::N, XPLMFindDataRef("sim/flightmodel/position/N") },
|
||||
|
||||
{ DREF::QRad, XPLMFindDataRef("sim/flightmodel/position/Qrad") },
|
||||
{ DREF::PRad, XPLMFindDataRef("sim/flightmodel/position/Prad") },
|
||||
{ DREF::RRad, XPLMFindDataRef("sim/flightmodel/position/Rrad") },
|
||||
{ DREF::Q, XPLMFindDataRef("sim/flightmodel/position/Q") },
|
||||
{ DREF::P, XPLMFindDataRef("sim/flightmodel/position/P") },
|
||||
{ DREF::R, XPLMFindDataRef("sim/flightmodel/position/R") },
|
||||
|
||||
{ DREF::Pitch, XPLMFindDataRef("sim/flightmodel/position/theta") },
|
||||
{ DREF::Roll, XPLMFindDataRef("sim/flightmodel/position/phi") },
|
||||
{ DREF::HeadingTrue, XPLMFindDataRef("sim/flightmodel/position/psi") },
|
||||
{ DREF::HeadingMag, XPLMFindDataRef("sim/flightmodel/position/magpsi") },
|
||||
{ DREF::Quaternion, XPLMFindDataRef("sim/flightmodel/position/q") },
|
||||
|
||||
{ DREF::AngleOfAttack, XPLMFindDataRef("sim/flightmodel/position/alpha") },
|
||||
{ DREF::Sideslip, XPLMFindDataRef("sim/cockpit2/gauges/indicators/sideslip_degrees") },
|
||||
{ DREF::HPath, XPLMFindDataRef("sim/flightmodel/position/hpath") },
|
||||
{ DREF::VPath, XPLMFindDataRef("sim/flightmodel/position/vpath") },
|
||||
|
||||
{ DREF::VPath, XPLMFindDataRef("sim/flightmodel/position/magnetic_variation") },
|
||||
|
||||
{ DREF::Latitude, XPLMFindDataRef("sim/flightmodel/position/latitude") },
|
||||
{ DREF::Longitude, XPLMFindDataRef("sim/flightmodel/position/longitude") },
|
||||
{ DREF::AGL, XPLMFindDataRef("sim/flightmodel/position/y_agl") },
|
||||
|
||||
{ DREF::LocalX, XPLMFindDataRef("sim/flightmodel/position/local_x") },
|
||||
{ DREF::LocalY, XPLMFindDataRef("sim/flightmodel/position/local_y") },
|
||||
{ DREF::LocalZ, XPLMFindDataRef("sim/flightmodel/position/local_z") },
|
||||
{ DREF::LocalVX, XPLMFindDataRef("sim/flightmodel/position/local_vx") },
|
||||
{ DREF::LocalVY, XPLMFindDataRef("sim/flightmodel/position/local_vy") },
|
||||
{ DREF::LocalVZ, XPLMFindDataRef("sim/flightmodel/position/local_vz") },
|
||||
|
||||
{ DREF::ThrottleSet, XPLMFindDataRef("sim/flightmodel/engine/ENGN_thro") },
|
||||
{ DREF::ThrottleActual, XPLMFindDataRef("sim/flightmodel2/engines/throttle_used_ratio") },
|
||||
|
||||
{ DREF::MP1Lat, XPLMFindDataRef("sim/multiplayer/position/plane1_lat") },
|
||||
{ DREF::MP2Lat, XPLMFindDataRef("sim/multiplayer/position/plane2_lat") },
|
||||
{ DREF::MP3Lat, XPLMFindDataRef("sim/multiplayer/position/plane3_lat") },
|
||||
{ DREF::MP4Lat, XPLMFindDataRef("sim/multiplayer/position/plane4_lat") },
|
||||
{ DREF::MP5Lat, XPLMFindDataRef("sim/multiplayer/position/plane5_lat") },
|
||||
{ DREF::MP6Lat, XPLMFindDataRef("sim/multiplayer/position/plane6_lat") },
|
||||
{ DREF::MP7Lat, XPLMFindDataRef("sim/multiplayer/position/plane7_lat") },
|
||||
|
||||
{ DREF::MP1Lon, XPLMFindDataRef("sim/multiplayer/position/plane1_lon") },
|
||||
{ DREF::MP2Lon, XPLMFindDataRef("sim/multiplayer/position/plane2_lon") },
|
||||
{ DREF::MP3Lon, XPLMFindDataRef("sim/multiplayer/position/plane3_lon") },
|
||||
{ DREF::MP4Lon, XPLMFindDataRef("sim/multiplayer/position/plane4_lon") },
|
||||
{ DREF::MP5Lon, XPLMFindDataRef("sim/multiplayer/position/plane5_lon") },
|
||||
{ DREF::MP6Lon, XPLMFindDataRef("sim/multiplayer/position/plane6_lon") },
|
||||
{ DREF::MP7Lon, XPLMFindDataRef("sim/multiplayer/position/plane7_lon") },
|
||||
|
||||
{ DREF::MP1Alt, XPLMFindDataRef("sim/multiplayer/position/plane1_el") },
|
||||
{ DREF::MP2Alt, XPLMFindDataRef("sim/multiplayer/position/plane2_el") },
|
||||
{ DREF::MP3Alt, XPLMFindDataRef("sim/multiplayer/position/plane3_el") },
|
||||
{ DREF::MP4Alt, XPLMFindDataRef("sim/multiplayer/position/plane4_el") },
|
||||
{ DREF::MP5Alt, XPLMFindDataRef("sim/multiplayer/position/plane5_el") },
|
||||
{ DREF::MP6Alt, XPLMFindDataRef("sim/multiplayer/position/plane6_el") },
|
||||
{ DREF::MP7Alt, XPLMFindDataRef("sim/multiplayer/position/plane7_el") },
|
||||
});
|
||||
|
||||
char multi[256];
|
||||
for (int i = 1; i < 20; i++)
|
||||
{
|
||||
sprintf(multi, "sim/multiplayer/position/plane%i_x", i); // X
|
||||
mdrefs[i][DREF::LocalX] = XPLMFindDataRef(multi);
|
||||
sprintf(multi, "sim/multiplayer/position/plane%i_y", i); // Y
|
||||
mdrefs[i][DREF::LocalY] = XPLMFindDataRef(multi);
|
||||
sprintf(multi, "sim/multiplayer/position/plane%i_z", i); // Z
|
||||
mdrefs[i][DREF::LocalZ] = XPLMFindDataRef(multi);
|
||||
sprintf(multi, "sim/multiplayer/position/plane%i_the", i); // Theta (Pitch)
|
||||
mdrefs[i][DREF::Pitch] = XPLMFindDataRef(multi);
|
||||
sprintf(multi, "sim/multiplayer/position/plane%i_phi", i); // Phi (Roll)
|
||||
mdrefs[i][DREF::Roll] = XPLMFindDataRef(multi);
|
||||
sprintf(multi, "sim/multiplayer/position/plane%i_psi", i); // Psi (Heading-True)
|
||||
mdrefs[i][DREF::HeadingTrue] = XPLMFindDataRef(multi);
|
||||
sprintf(multi, "sim/multiplayer/position/plane%i_gear_deploy", i); // Landing Gear
|
||||
mdrefs[i][DREF::GearDeploy] = XPLMFindDataRef(multi);
|
||||
sprintf(multi, "sim/multiplayer/position/plane%i_flap_ratio", i);
|
||||
mdrefs[i][DREF::FlapSetting] = XPLMFindDataRef(multi); // Can't set the actual flap setting on npc aircraft
|
||||
mdrefs[i][DREF::FlapActual] = XPLMFindDataRef(multi);
|
||||
sprintf(multi, "sim/multiplayer/position/plane%i_flap_ratio2", i);
|
||||
mdrefs[i][DREF::FlapActual2] = XPLMFindDataRef(multi);
|
||||
sprintf(multi, "sim/multiplayer/position/plane%i_spoiler_ratio", i);
|
||||
mdrefs[i][DREF::Spoiler] = XPLMFindDataRef(multi);
|
||||
sprintf(multi, "sim/multiplayer/position/plane%i_speedbrake_ratio", i);
|
||||
mdrefs[i][DREF::BrakeSpeed] = XPLMFindDataRef(multi);
|
||||
sprintf(multi, "sim/multiplayer/position/plane%i_slat_ratio", i);
|
||||
mdrefs[i][DREF::Slats] = XPLMFindDataRef(multi);
|
||||
sprintf(multi, "sim/multiplayer/position/plane%i_wing_sweep", i);
|
||||
mdrefs[i][DREF::Sweep] = XPLMFindDataRef(multi);
|
||||
sprintf(multi, "sim/multiplayer/position/plane%i_throttle", i);
|
||||
mdrefs[i][DREF::ThrottleActual] = XPLMFindDataRef(multi);
|
||||
sprintf(multi, "sim/multiplayer/position/plane%i_yolk_pitch", i);
|
||||
mdrefs[i][DREF::YokePitch] = XPLMFindDataRef(multi);
|
||||
sprintf(multi, "sim/multiplayer/position/plane%i_yolk_roll", i);
|
||||
mdrefs[i][DREF::YokeRoll] = XPLMFindDataRef(multi);
|
||||
sprintf(multi, "sim/multiplayer/position/plane%i_yolk_yaw", i);
|
||||
mdrefs[i][DREF::YokeHeading] = XPLMFindDataRef(multi);
|
||||
}
|
||||
}
|
||||
|
||||
std::size_t DataManager::Get(std::string dref, float values[], std::size_t size)
|
||||
{
|
||||
XPLMDataRef& xdref = sdrefs[dref];
|
||||
if (xdref == nullptr)
|
||||
{
|
||||
xdref = XPLMFindDataRef(dref.c_str());
|
||||
}
|
||||
if (!xdref)
|
||||
{
|
||||
// DREF does not exist
|
||||
#if LOG_VERBOSITY > 0
|
||||
Log::WriteLine("[DMAN] ERROR: invalid DREF");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
XPLMDataTypeID dataType = XPLMGetDataRefTypes(xdref);
|
||||
#if LOG_VERBOSITY > 4
|
||||
Log::FormatLine("[DMAN] Get DREF %s (x:%X) type %i", dref.c_str(), xdref, dataType);
|
||||
#endif
|
||||
switch (dataType)
|
||||
{
|
||||
case 1: // Integer
|
||||
{
|
||||
values[0] = XPLMGetDatai(xdref);
|
||||
#if LOG_VERBOSITY > 4
|
||||
Log::FormatLine(" value was %i", (int)values[0]);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
case 4: // Double
|
||||
{
|
||||
values[0] = XPLMGetDatad(xdref);
|
||||
#if LOG_VERBOSITY > 4
|
||||
Log::FormatLine(" value was %f", values[0]);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
case 8: // Float Array
|
||||
{
|
||||
int drefSize = XPLMGetDatavf(xdref, NULL, 0, 0);
|
||||
drefSize = min(drefSize, size);
|
||||
XPLMGetDatavf(xdref, values, 0, drefSize);
|
||||
#if LOG_VERBOSITY > 4
|
||||
Log::FormatLine(" value count was %i", drefSize);
|
||||
#endif
|
||||
return drefSize;
|
||||
}
|
||||
case 16: // Integer Array
|
||||
{
|
||||
int iValues[64];
|
||||
int drefSize = XPLMGetDatavi(xdref, NULL, 0, 0);
|
||||
drefSize = min(drefSize, size);
|
||||
drefSize = min(drefSize, 64);
|
||||
XPLMGetDatavi(xdref, iValues, 0, drefSize);
|
||||
for (int i = 0; i < drefSize; ++i)
|
||||
{
|
||||
values[i] = iValues[i];
|
||||
}
|
||||
#if LOG_VERBOSITY > 4
|
||||
Log::FormatLine(" value count was %i", drefSize);
|
||||
#endif
|
||||
return drefSize;
|
||||
}
|
||||
default: // Assume float
|
||||
{
|
||||
values[0] = XPLMGetDataf(xdref);
|
||||
#if LOG_VERBOSITY > 4
|
||||
Log::FormatLine(" value was %f", values[0]);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
double DataManager::GetDouble(DREF dref, std::uint8_t aircraft)
|
||||
{
|
||||
const XPLMDataRef& xdref = aircraft == 0 ? drefs[dref] : mdrefs[aircraft][dref];
|
||||
double value = XPLMGetDatad(xdref);
|
||||
#if LOG_VERBOSITY > 4
|
||||
Log::FormatLine("[DMAN] Get DREF %i (x:%X) result %f for a/c %i", dref, xdref, value, aircraft);
|
||||
#endif
|
||||
return value;
|
||||
}
|
||||
|
||||
float DataManager::GetFloat(DREF dref, std::uint8_t aircraft)
|
||||
{
|
||||
const XPLMDataRef& xdref = aircraft == 0 ? drefs[dref] : mdrefs[aircraft][dref];
|
||||
float value = XPLMGetDataf(xdref);
|
||||
#if LOG_VERBOSITY > 4
|
||||
Log::FormatLine("[DMAN] Get DREF %i (x:%X) result %f for a/c %i", dref, xdref, value, aircraft);
|
||||
#endif
|
||||
return value;
|
||||
}
|
||||
|
||||
int DataManager::GetInt(DREF dref, std::uint8_t aircraft)
|
||||
{
|
||||
const XPLMDataRef& xdref = aircraft == 0 ? drefs[dref] : mdrefs[aircraft][dref];
|
||||
int value = XPLMGetDatai(xdref);
|
||||
#if LOG_VERBOSITY > 4
|
||||
Log::FormatLine("[DMAN] Get DREF %i (x:%X) result %i for a/c %i", dref, xdref, value, aircraft);
|
||||
#endif
|
||||
return value;
|
||||
}
|
||||
|
||||
std::size_t DataManager::GetFloatArray(DREF dref, float values[], std::size_t size, std::uint8_t aircraft)
|
||||
{
|
||||
const XPLMDataRef& xdref = aircraft == 0 ? drefs[dref] : mdrefs[aircraft][dref];
|
||||
int resultSize = XPLMGetDatavf(xdref, values, 0, size);
|
||||
#if LOG_VERBOSITY > 4
|
||||
Log::FormatLine("[DMAN] Get DREF %i (x:%X) result size %i for a/c %i", dref, xdref, resultSize, aircraft);
|
||||
#endif
|
||||
return resultSize;
|
||||
}
|
||||
|
||||
std::size_t DataManager::GetIntArray(DREF dref, int values[], std::size_t size, std::uint8_t aircraft)
|
||||
{
|
||||
const XPLMDataRef& xdref = aircraft == 0 ? drefs[dref] : mdrefs[aircraft][dref];
|
||||
int resultSize = XPLMGetDatavi(xdref, values, 0, size);
|
||||
#if LOG_VERBOSITY > 4
|
||||
Log::FormatLine("[DMAN] Get DREF %i (x:%X) result size %i for a/c %i", dref, xdref, resultSize, aircraft);
|
||||
#endif
|
||||
return resultSize;
|
||||
}
|
||||
|
||||
void DataManager::Set(DREF dref, double value, std::uint8_t aircraft)
|
||||
{
|
||||
const XPLMDataRef& xdref = aircraft == 0 ? drefs[dref] : mdrefs[aircraft][dref];
|
||||
#if LOG_VERBOSITY > 4
|
||||
Log::FormatLine("[DMAN] Setting DREF %i (x:%X) to %f for a/c %i", dref, xdref, value, aircraft);
|
||||
#endif
|
||||
XPLMSetDatad(xdref, value);
|
||||
}
|
||||
|
||||
void DataManager::Set(DREF dref, float value, std::uint8_t aircraft)
|
||||
{
|
||||
const XPLMDataRef& xdref = aircraft == 0 ? drefs[dref] : mdrefs[aircraft][dref];
|
||||
#if LOG_VERBOSITY > 4
|
||||
Log::FormatLine("[DMAN] Set DREF %i (x:%X) to %f for a/c %i", dref, xdref, value, aircraft);
|
||||
#endif
|
||||
XPLMSetDataf(xdref, value);
|
||||
}
|
||||
|
||||
void DataManager::Set(DREF dref, int value, std::uint8_t aircraft)
|
||||
{
|
||||
const XPLMDataRef& xdref = aircraft == 0 ? drefs[dref] : mdrefs[aircraft][dref];
|
||||
#if LOG_VERBOSITY > 4
|
||||
Log::FormatLine("[DMAN] Set DREF %i (x:%X) to %i for a/c %i", dref, xdref, value, aircraft);
|
||||
#endif
|
||||
XPLMSetDatai(xdref, value);
|
||||
}
|
||||
|
||||
void DataManager::Set(DREF dref, float values[], std::size_t size, std::uint8_t aircraft)
|
||||
{
|
||||
const XPLMDataRef& xdref = aircraft == 0 ? drefs[dref] : mdrefs[aircraft][dref];
|
||||
#if LOG_VERBOSITY > 4
|
||||
Log::FormatLine("[DMAN] Set DREF %i (x:%X) (%i values) for a/c %i", dref, xdref, size, aircraft);
|
||||
#endif
|
||||
std::size_t drefSize = XPLMGetDatavf(xdref, NULL, 0, 0);
|
||||
drefSize = min(drefSize, size);
|
||||
XPLMSetDatavf(xdref, values, 0, drefSize);
|
||||
}
|
||||
|
||||
void DataManager::Set(DREF dref, int values[], std::size_t size, std::uint8_t aircraft)
|
||||
{
|
||||
const XPLMDataRef& xdref = aircraft == 0 ? drefs[dref] : mdrefs[aircraft][dref];
|
||||
#if LOG_VERBOSITY > 4
|
||||
Log::FormatLine("[DMAN] Setting DREF %i (x:%X) (%i values) for a/c %i", dref, xdref, size, aircraft);
|
||||
#endif
|
||||
std::size_t drefSize = XPLMGetDatavi(xdref, NULL, 0, 0);
|
||||
drefSize = min(drefSize, size);
|
||||
XPLMSetDatavi(xdref, values, 0, drefSize);
|
||||
}
|
||||
|
||||
void DataManager::Set(std::string dref, float values[], std::size_t size)
|
||||
{
|
||||
XPLMDataRef& xdref = sdrefs[dref];
|
||||
if (xdref == nullptr)
|
||||
{
|
||||
xdref = XPLMFindDataRef(dref.c_str());
|
||||
}
|
||||
#if LOG_VERBOSITY > 4
|
||||
Log::FormatLine("[DMAN] Setting DREF %s (x:%X) (%i values)", dref.c_str(), xdref, size);
|
||||
#endif
|
||||
if (!xdref)
|
||||
{
|
||||
// DREF does not exist
|
||||
#if LOG_VERBOSITY > 0
|
||||
Log::WriteLine("[DMAN] ERROR: invalid DREF");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
if (std::isnan(values[0]))
|
||||
{
|
||||
#if LOG_VERBOSITY > 0
|
||||
Log::WriteLine("[DMAN] ERROR: Value must be a number (NaN received)");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
XPLMDataTypeID dataType = XPLMGetDataRefTypes(xdref);
|
||||
switch (dataType)
|
||||
{
|
||||
case 1: // Integer
|
||||
{
|
||||
XPLMSetDatai(xdref, (int)values[0]);
|
||||
break;
|
||||
}
|
||||
case 4: // Double
|
||||
{
|
||||
XPLMSetDatad(xdref, values[0]);
|
||||
break;
|
||||
}
|
||||
case 8: // Float Array
|
||||
{
|
||||
int drefSize = XPLMGetDatavf(xdref, NULL, 0, 0);
|
||||
drefSize = min(drefSize, size);
|
||||
XPLMSetDatavf(xdref, values, 0, drefSize);
|
||||
break;
|
||||
}
|
||||
case 16: // Integer Array
|
||||
{
|
||||
int iValues[64];
|
||||
int drefSize = XPLMGetDatavi(xdref, NULL, 0, 0);
|
||||
drefSize = min(drefSize, size);
|
||||
drefSize = min(drefSize, 64);
|
||||
for (int i = 0; i < drefSize; ++i)
|
||||
{
|
||||
iValues[i] = (int)values[i];
|
||||
}
|
||||
XPLMSetDatavi(xdref, iValues, 0, drefSize);
|
||||
break;
|
||||
}
|
||||
default: // Assume float
|
||||
{
|
||||
XPLMSetDataf(xdref, values[0]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DataManager::SetGear(float gear, bool immediate, std::uint8_t aircraft)
|
||||
{
|
||||
#if LOG_VERBOSITY > 3
|
||||
Log::FormatLine("[DMAN] Setting gear (value:%f, immediate:%i) for aircraft %i", gear, immediate, aircraft);
|
||||
#endif
|
||||
float gearArray[10];
|
||||
|
||||
if ((gear < -8.5f && gear > 9.5f) || (gear < -997.9f && gear > -999.1f))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (std::isnan(gear) || gear < 0 || gear > 1)
|
||||
{
|
||||
Log::WriteLine("[GEAR] ERROR: Value must be 0 or 1");
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
gearArray[i] = gear;
|
||||
}
|
||||
|
||||
if (aircraft == 0) // Own aircraft
|
||||
{
|
||||
Set(DREF::GearHandle, (int)gear);
|
||||
if (immediate)
|
||||
{
|
||||
Set(DREF::GearDeploy, gearArray, 10);
|
||||
}
|
||||
}
|
||||
else // Multiplayer aircraft
|
||||
{
|
||||
XPLMSetDatavf(mdrefs[aircraft][DREF::GearDeploy], gearArray, 0, 10);
|
||||
}
|
||||
}
|
||||
|
||||
void DataManager::SetPosition(float pos[3], std::uint8_t aircraft)
|
||||
{
|
||||
#if LOG_VERBOSITY > 3
|
||||
Log::FormatLine("[DMAN] Setting position (%f, %f, %f) for aircraft %i", pos[0], pos[1], pos[2], aircraft);
|
||||
#endif
|
||||
if (std::isnan(pos[0] + pos[1] + pos[2]))
|
||||
{
|
||||
#if LOG_VERBOSITY > 0
|
||||
Log::WriteLine("[DMAN] ERROR: Position must be a number (NaN received)");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
double local[3] = { 0 };
|
||||
XPLMWorldToLocal(pos[0], pos[1], pos[2], &local[0], &local[1], &local[2]);
|
||||
if (aircraft == 0) // Player aircraft
|
||||
{
|
||||
// If the sim is paused, setting global position won't update the
|
||||
// local position, so set them just in case.
|
||||
Set(DREF::LocalX, local[0]);
|
||||
Set(DREF::LocalY, local[1]);
|
||||
Set(DREF::LocalZ, local[2]);
|
||||
// If the sim is unpaused, this will override the above settings.
|
||||
Set(DREF::Latitude, (double)pos[0]);
|
||||
Set(DREF::Longitude, (double)pos[1]);
|
||||
Set(DREF::AGL, (double)pos[2]);
|
||||
}
|
||||
else // Multiplayer
|
||||
{
|
||||
XPLMSetDatad(mdrefs[aircraft][DREF::LocalX], local[0]);
|
||||
XPLMSetDatad(mdrefs[aircraft][DREF::LocalY], local[1]);
|
||||
XPLMSetDatad(mdrefs[aircraft][DREF::LocalZ], local[2]);
|
||||
}
|
||||
}
|
||||
|
||||
void DataManager::SetOrientation(float orient[3], std::uint8_t aircraft)
|
||||
{
|
||||
#if LOG_VERBOSITY > 3
|
||||
Log::FormatLine("[DMAN] Setting orientation (%f, %f, %f) for aircraft %i",
|
||||
orient[0], orient[1], orient[2], aircraft);
|
||||
#endif
|
||||
if (std::isnan(orient[0] + orient[1] + orient[2]))
|
||||
{
|
||||
#if LOG_VERBOSITY > 0
|
||||
Log::WriteLine("[DMAN] ERROR: Orientation must be a number (NaN received)");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
if (aircraft == 0) // Player aircraft
|
||||
{
|
||||
// If the sim is paused, setting the quaternion won't update these values,
|
||||
// so we set them here just in case.
|
||||
Set(DREF::Pitch, orient[0]);
|
||||
Set(DREF::Roll, orient[1]);
|
||||
Set(DREF::HeadingTrue, orient[2]);
|
||||
|
||||
// Convert to Quaternions
|
||||
// from: http://www.xsquawkbox.net/xpsdk/mediawiki/MovingThePlane
|
||||
// http://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/19770024290.pdf
|
||||
float q[4] = { 0 };
|
||||
float halfRad = 0.00872664625997F;
|
||||
orient[2] = halfRad * orient[2];
|
||||
orient[0] = halfRad * orient[0];
|
||||
orient[1] = halfRad * orient[1];
|
||||
q[0] = cos(orient[2]) * cos(orient[0]) * cos(orient[1]) + sin(orient[2]) * sin(orient[0]) * sin(orient[1]);
|
||||
q[1] = cos(orient[2]) * cos(orient[0]) * sin(orient[1]) - sin(orient[2]) * sin(orient[0]) * cos(orient[1]);
|
||||
q[2] = cos(orient[2]) * sin(orient[0]) * cos(orient[1]) + sin(orient[2]) * cos(orient[0]) * sin(orient[1]);
|
||||
q[3] = sin(orient[2]) * cos(orient[0]) * cos(orient[1]) - cos(orient[2]) * sin(orient[0]) * sin(orient[1]);
|
||||
|
||||
// If the sim is un-paused, this will overwrite the pitch/roll/yaw
|
||||
// values set above.
|
||||
Set(DREF::Quaternion, q, 4);
|
||||
}
|
||||
else // Multiplayer
|
||||
{
|
||||
XPLMSetDataf(mdrefs[aircraft][DREF::Pitch], orient[0]);
|
||||
XPLMSetDataf(mdrefs[aircraft][DREF::Roll], orient[1]);
|
||||
XPLMSetDataf(mdrefs[aircraft][DREF::HeadingTrue], orient[2]);
|
||||
}
|
||||
}
|
||||
|
||||
void DataManager::SetFlaps(float value)
|
||||
{
|
||||
if (std::isnan(value))
|
||||
{
|
||||
Log::WriteLine("[FLAP] ERROR: Value must be a number (NaN received)");
|
||||
return;
|
||||
}
|
||||
value = max(value, 0);
|
||||
value = min(value, 1);
|
||||
|
||||
Set(DREF::FlapSetting, value);
|
||||
Set(DREF::FlapActual, value);
|
||||
}
|
||||
}
|
||||
176
xpcPlugin/DataManager.h
Normal file
176
xpcPlugin/DataManager.h
Normal file
@@ -0,0 +1,176 @@
|
||||
//Copyright (c) 2013-2015 United States Government as represented by the Administrator of the
|
||||
//National Aeronautics and Space Administration. All Rights Reserved.
|
||||
#ifndef XPC_DATAMANAGER_H
|
||||
#define XPC_DATAMANAGER_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
namespace XPC
|
||||
{
|
||||
enum class DREF
|
||||
{
|
||||
None = 0,
|
||||
|
||||
Pause,
|
||||
PauseAI,
|
||||
|
||||
// Times
|
||||
TotalRuntime = 100,
|
||||
TotalFlighttime,
|
||||
TimerElapsedtime,
|
||||
|
||||
// Velocities
|
||||
IndicatedAirspeed = 300,
|
||||
TrueAirspeed,
|
||||
GroundSpeed,
|
||||
|
||||
// Mach, VVI, G-loads
|
||||
MachNumber = 400,
|
||||
GForceNormal,
|
||||
GForceAxial,
|
||||
GForceSide,
|
||||
|
||||
// Atmosphere: Weather
|
||||
BarometerSealevelInHg = 500,
|
||||
TemperaturSealevelC,
|
||||
WindSpeedKts,
|
||||
|
||||
// Joystick
|
||||
YokePitch = 800,
|
||||
YokeRoll,
|
||||
YokeHeading,
|
||||
|
||||
// Control Surfaces
|
||||
Elevator = 1100,
|
||||
Aileron,
|
||||
Rudder,
|
||||
|
||||
// Flaps
|
||||
FlapSetting = 1300,
|
||||
FlapActual,
|
||||
|
||||
// Gear & Brakes
|
||||
GearDeploy = 1400,
|
||||
GearHandle,
|
||||
BrakeParking,
|
||||
BrakeLeft,
|
||||
BrakeRight,
|
||||
|
||||
// MNR (Angular Moments)
|
||||
M = 1500,
|
||||
L,
|
||||
N,
|
||||
|
||||
//PQR (Angular Velocities)
|
||||
QRad = 1600,
|
||||
PRad,
|
||||
RRad,
|
||||
Q,
|
||||
P,
|
||||
R,
|
||||
|
||||
// Orientation: pitch, roll, yaw, heading
|
||||
Pitch = 1700,
|
||||
Roll,
|
||||
HeadingTrue,
|
||||
HeadingMag,
|
||||
Quaternion,
|
||||
|
||||
// Orientation: alpha beta hpath vpath slip
|
||||
AngleOfAttack = 1800,
|
||||
Sideslip,
|
||||
HPath,
|
||||
VPath,
|
||||
|
||||
MagneticVariation = 1901,
|
||||
|
||||
// Global Position
|
||||
Latitude = 2000,
|
||||
Longitude,
|
||||
AGL,
|
||||
|
||||
// Local Postion & Velocity
|
||||
LocalX = 2100,
|
||||
LocalY,
|
||||
LocalZ,
|
||||
LocalVX,
|
||||
LocalVY,
|
||||
LocalVZ,
|
||||
|
||||
ThrottleSet = 2200,
|
||||
ThrottleActual = 2300,
|
||||
|
||||
// Multiplayer Aircraft
|
||||
FlapActual2,
|
||||
Spoiler,
|
||||
BrakeSpeed,
|
||||
Sweep,
|
||||
Slats,
|
||||
|
||||
// Mulitplayer positon
|
||||
MP1Lat,
|
||||
MP2Lat,
|
||||
MP3Lat,
|
||||
MP4Lat,
|
||||
MP5Lat,
|
||||
MP6Lat,
|
||||
MP7Lat,
|
||||
|
||||
MP1Lon,
|
||||
MP2Lon,
|
||||
MP3Lon,
|
||||
MP4Lon,
|
||||
MP5Lon,
|
||||
MP6Lon,
|
||||
MP7Lon,
|
||||
|
||||
MP1Alt,
|
||||
MP2Alt,
|
||||
MP3Alt,
|
||||
MP4Alt,
|
||||
MP5Alt,
|
||||
MP6Alt,
|
||||
MP7Alt,
|
||||
};
|
||||
|
||||
class DataManager
|
||||
{
|
||||
public:
|
||||
static void Initialize();
|
||||
|
||||
static std::size_t Get(std::string dref, float values[], std::size_t size);
|
||||
|
||||
static double GetDouble(DREF dref, std::uint8_t aircraft = 0);
|
||||
|
||||
static float GetFloat(DREF dref, std::uint8_t aircraft = 0);
|
||||
|
||||
static int GetInt(DREF dref, std::uint8_t aircraft = 0);
|
||||
|
||||
static std::size_t GetFloatArray(DREF dref, float values[], std::size_t size, std::uint8_t aircraft = 0);
|
||||
|
||||
static std::size_t GetIntArray(DREF dref, int values[], std::size_t size, std::uint8_t aircraft = 0);
|
||||
|
||||
static void Set(DREF dref, double value, std::uint8_t aircraft = 0);
|
||||
|
||||
static void Set(DREF dref, float value, std::uint8_t aircraft = 0);
|
||||
|
||||
static void Set(DREF dref, int value, std::uint8_t aircraft = 0);
|
||||
|
||||
static void Set(DREF dref, float values[], std::size_t size, std::uint8_t aircraft = 0);
|
||||
|
||||
static void Set(DREF dref, int values[], std::size_t size, std::uint8_t aircraft = 0);
|
||||
|
||||
static void Set(std::string dref, float values[], std::size_t size);
|
||||
|
||||
static void SetGear(float gear, bool immediate, std::uint8_t aircraft = 0);
|
||||
|
||||
static void SetPosition(float pos[3], std::uint8_t aircraft = 0);
|
||||
|
||||
static void SetOrientation(float orient[3], std::uint8_t aircraft = 0);
|
||||
|
||||
static void SetFlaps(float value);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
80
xpcPlugin/DataMaps.cpp
Normal file
80
xpcPlugin/DataMaps.cpp
Normal file
@@ -0,0 +1,80 @@
|
||||
//Copyright (c) 2013-2015 United States Government as represented by the Administrator of the
|
||||
//National Aeronautics and Space Administration. All Rights Reserved.
|
||||
#include "DataManager.h"
|
||||
|
||||
namespace XPC
|
||||
{
|
||||
DREF XPData[134][8]
|
||||
{
|
||||
{}, // Row 0: Frame Rates
|
||||
{ // Row 1: Times
|
||||
DREF::None, DREF::TotalRuntime, DREF::TotalFlighttime, DREF::TimerElapsedtime,
|
||||
},
|
||||
{}, // Row 2: Sim stats
|
||||
{ // Row 3: Velocities
|
||||
DREF::IndicatedAirspeed, DREF::None, DREF::TrueAirspeed, DREF::GroundSpeed
|
||||
},
|
||||
{ // Row 4: Mach, VVI, G-Loads
|
||||
DREF::MachNumber, DREF::None, DREF::None, DREF::None,
|
||||
DREF::GForceNormal, DREF::GForceAxial, DREF::GForceSide
|
||||
},
|
||||
{ // Row 5: Atmosphere: Weather
|
||||
DREF::BarometerSealevelInHg, DREF::TemperaturSealevelC, DREF::None, DREF::WindSpeedKts
|
||||
},
|
||||
{}, // Row 6: Atmosphere: Aircraft
|
||||
{}, // Row 7: System Pressures
|
||||
{ // Row 8: Joystick
|
||||
DREF::YokePitch, DREF::YokeRoll, DREF::YokeHeading
|
||||
},
|
||||
{}, // Row 9: Other Flight Controls
|
||||
{}, // Row 10: Art stab ail/elv/rud
|
||||
{ // Row 11: Control Surfaces
|
||||
DREF::Elevator, DREF::Aileron, DREF::Rudder
|
||||
},
|
||||
{}, // Row 12: Wing Sweep/Trust Vec
|
||||
{ // Row 13: trip/flap/slat/s-brakes
|
||||
DREF::None, DREF::None, DREF::None, DREF::FlapSetting, DREF::FlapActual
|
||||
},
|
||||
{ // Row 14: Gear, Braks
|
||||
DREF::GearDeploy, DREF::BrakeParking, DREF::BrakeLeft, DREF::BrakeRight,
|
||||
DREF::None, DREF::None, DREF::None,
|
||||
DREF::GearHandle
|
||||
},
|
||||
{ // Row 15: MNR (Angular Moments)
|
||||
DREF::M, DREF::L, DREF::N
|
||||
},
|
||||
{ // Row 16: PQR (Angular Velocities)
|
||||
DREF::QRad, DREF::PRad, DREF::RRad, DREF::Q, DREF::P, DREF::R
|
||||
},
|
||||
{ // Row 17: Orientation: pitch, roll, yaw, heading
|
||||
DREF::Pitch, DREF::Roll, DREF::HeadingTrue, DREF::HeadingMag, DREF::Quaternion
|
||||
},
|
||||
{ // Row 18: Orientation: alpha beta hpath vpath slip
|
||||
DREF::AngleOfAttack, DREF::Sideslip, DREF::HPath, DREF::VPath, DREF::Sideslip
|
||||
},
|
||||
{ // Row 19: Mag Compass
|
||||
DREF::HeadingMag, DREF::MagneticVariation
|
||||
},
|
||||
{ // Row 20: Global Position
|
||||
DREF::Latitude, DREF::Longitude, DREF::AGL
|
||||
},
|
||||
{ // Row 21: Local Position, Velocity
|
||||
DREF::LocalX, DREF::LocalY, DREF::LocalZ, DREF::LocalVX, DREF::LocalVY, DREF::LocalVZ
|
||||
},
|
||||
{ // Row 22: All Planes: Lat
|
||||
DREF::Latitude, DREF::MP1Lat, DREF::MP2Lat, DREF::MP3Lat, DREF::MP4Lat, DREF::MP5Lat, DREF::MP6Lat, DREF::MP7Lat
|
||||
},
|
||||
{ // Row 23: All Planes: Lon
|
||||
DREF::Longitude, DREF::MP1Lon, DREF::MP2Lon, DREF::MP3Lon, DREF::MP4Lon, DREF::MP5Lon, DREF::MP6Lon, DREF::MP7Lon
|
||||
},
|
||||
{ // Row 24: All Planes: Alt
|
||||
DREF::AGL, DREF::MP1Alt, DREF::MP2Alt, DREF::MP3Alt, DREF::MP4Alt, DREF::MP5Alt, DREF::MP6Alt, DREF::MP7Alt
|
||||
},
|
||||
{ // Row 25: Throttle Command
|
||||
DREF::ThrottleSet
|
||||
},
|
||||
{ // Row 26: Throttle Actual
|
||||
DREF::ThrottleActual
|
||||
}
|
||||
};
|
||||
}
|
||||
12
xpcPlugin/DataMaps.h
Normal file
12
xpcPlugin/DataMaps.h
Normal file
@@ -0,0 +1,12 @@
|
||||
//Copyright (c) 2013-2015 United States Government as represented by the Administrator of the
|
||||
//National Aeronautics and Space Administration. All Rights Reserved.
|
||||
#ifndef XPC_DATAMAPS_H
|
||||
#define XPC_DATAMAPS_H
|
||||
#include "DataManager.h"
|
||||
|
||||
namespace XPC
|
||||
{
|
||||
extern DREF XPData[134][8];
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -4,7 +4,7 @@
|
||||
#define XPC_LOG_H
|
||||
#include <string>
|
||||
|
||||
#define LOG_VERBOSITY 2
|
||||
#define LOG_VERBOSITY 999
|
||||
|
||||
namespace XPC
|
||||
{
|
||||
|
||||
@@ -72,17 +72,17 @@ namespace XPC
|
||||
Log::WriteLine(ss.str());
|
||||
|
||||
ss.str("");
|
||||
ss << "[" << GetHead() << "-DEBUG](" << buffer[4] << ")";
|
||||
switch (GetMagicNumber())
|
||||
ss << "[" << GetHead() << "-DEBUG] (" << GetSize() << ")";
|
||||
switch (GetMagicNumber()) // Binary version of head
|
||||
{
|
||||
case 0x434F4E4E: // CONN
|
||||
case 0x57595054: // WYPT
|
||||
case 0x54455854: // TEXT
|
||||
case 0x4E4EF443: // CONN
|
||||
case 0x54505957: // WYPT
|
||||
case 0x54584554: // TEXT
|
||||
{
|
||||
Log::WriteLine(ss.str());
|
||||
break;
|
||||
}
|
||||
case 0x4354524C: // CTRL
|
||||
case 0x4C525443: // CTRL
|
||||
{
|
||||
xpcCtrl ctrl = parseCTRL((char*)buffer);
|
||||
ss << " (" << ctrl.pitch << " " << ctrl.roll << " " << ctrl.yaw << ") ";
|
||||
@@ -90,7 +90,7 @@ namespace XPC
|
||||
Log::WriteLine(ss.str());
|
||||
break;
|
||||
}
|
||||
case 0x44415441: // DATA
|
||||
case 0x41544144: // DATA
|
||||
{
|
||||
float dataRef[30][9];
|
||||
short numCols = parseDATA((char*)buffer, size, dataRef);
|
||||
@@ -108,7 +108,7 @@ namespace XPC
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 0x44524546: // DREF
|
||||
case 0x46455244: // DREF
|
||||
{
|
||||
Log::WriteLine(ss.str());
|
||||
std::string dref((char*)buffer + 6, buffer[5]);
|
||||
@@ -123,19 +123,19 @@ namespace XPC
|
||||
Log::WriteLine(ss.str());
|
||||
break;
|
||||
}
|
||||
case 0x47455444: // GETD
|
||||
case 0x44544547: // GETD
|
||||
{
|
||||
Log::WriteLine(ss.str());
|
||||
int cur = 6;
|
||||
for (int i = 0; i < buffer[5]; ++i)
|
||||
{
|
||||
std::string dref((char*)buffer + cur + 1, buffer[cur]);
|
||||
Log::FormatLine("\t#%i/%i (size:%i) %s", i + 1, buffer[5], dref.length(), dref);
|
||||
Log::FormatLine("\t#%i/%i (size:%i) %s", i + 1, buffer[5], dref.length(), dref.c_str());
|
||||
cur += 1 + buffer[cur];
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 0x504F5349: // POSI
|
||||
case 0x49534F50: // POSI
|
||||
{
|
||||
float position[6] = { 0.0 };
|
||||
short aircraft = 0;
|
||||
@@ -148,15 +148,15 @@ namespace XPC
|
||||
Log::WriteLine(ss.str());
|
||||
break;
|
||||
}
|
||||
case 0x53494D55: // SIMU
|
||||
case 0x554D4953: // SIMU
|
||||
{
|
||||
ss << ' ' << buffer[5];
|
||||
ss << ' ' << (int)buffer[5];
|
||||
Log::WriteLine(ss.str());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
ss << " UNKNOWN HEADER";
|
||||
ss << " UNKNOWN HEADER ";
|
||||
Log::WriteLine(ss.str());
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -62,6 +62,8 @@
|
||||
|
||||
// XPC Includes
|
||||
#include "Log.h"
|
||||
#include "DataManager.h"
|
||||
#include "DataMaps.h"
|
||||
#include "Drawing.h"
|
||||
#include "Message.h"
|
||||
#include "UDPSocket.h"
|
||||
@@ -88,7 +90,6 @@
|
||||
#define SENDPORT 49097 // Port that the plugin sends on
|
||||
#define OPS_PER_CYCLE 20 // Max Number of operations per cycle
|
||||
|
||||
static XPLMDataRef XPLMSwitch; // for turning on/off simulation
|
||||
XPC::UDPSocket* recvSocket = nullptr;
|
||||
XPC::UDPSocket* sendSocket = nullptr;
|
||||
|
||||
@@ -109,7 +110,7 @@ struct connectionHistory
|
||||
unsigned short recPort;
|
||||
unsigned short fromPort;
|
||||
short requestLength;
|
||||
XPLMDataRef XPLMRequestedDRefs[100];
|
||||
std::string XPLMRequestedDRefs[100];
|
||||
};
|
||||
|
||||
connectionHistory connectionList[MAXCONN];
|
||||
@@ -133,11 +134,6 @@ int handleDATA(char *buf, int buflen);
|
||||
int handleTEXT(char *buf, int len);
|
||||
short handleInput(XPC::Message& msg);
|
||||
|
||||
char setPOSI(short aircraft, float pos[3]);
|
||||
char setORIENT(short aircraft, float orient[3]);
|
||||
char setDREF(XPLMDataRef theDREF, float floatarray[], short arrayStart, short arraySize);
|
||||
char setGEAR(short aircraft, float gear, char posi);
|
||||
char setFLAP(float flap);
|
||||
void sendBUF(char buf[], int buflen);
|
||||
|
||||
PLUGIN_API int XPluginStart( char * outName,
|
||||
@@ -168,12 +164,7 @@ PLUGIN_API int XPluginStart( char * outName,
|
||||
1000000000.0;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Build the DataRef Array
|
||||
buildXPLMDataRefs();
|
||||
|
||||
//On/Off Switch for simulation
|
||||
XPLMSwitch = XPLMFindDataRef("sim/operation/override/override_planepath");
|
||||
XPC::DataManager::Initialize();
|
||||
|
||||
XPLMRegisterFlightLoopCallback(
|
||||
MyFlightLoopCallback, /* Callback */
|
||||
@@ -470,7 +461,8 @@ int handleSIMU(char buf[])
|
||||
return 1;
|
||||
}
|
||||
|
||||
XPLMSetDatavi(XPLMSwitch, SIMUArray, 0, 1);
|
||||
int value = buf[5];
|
||||
XPC::DataManager::Set(XPC::DREF::Pause, &value, 1);
|
||||
|
||||
if (buf[5] == 0)
|
||||
{
|
||||
@@ -509,197 +501,6 @@ int handleTEXT(char *buf, int len)
|
||||
return 0;
|
||||
}
|
||||
|
||||
char setDREF(XPLMDataRef theDREF, float floatarray[], short arrayStart, short arraySize)
|
||||
{
|
||||
XPLMDataTypeID dataType;
|
||||
short i=arrayStart;
|
||||
|
||||
if ((floatarray[i]<-997.5 && floatarray[i]>-999.5))
|
||||
{
|
||||
return 0; // Do not change
|
||||
}
|
||||
|
||||
if (theDREF == XPLMDataRefs[0][0])
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (theDREF) // VALID POINTER
|
||||
{
|
||||
if (floatarray[i] != floatarray[i]) // Is NaN
|
||||
{
|
||||
goto NANMessage;
|
||||
}
|
||||
|
||||
dataType = XPLMGetDataRefTypes(theDREF);
|
||||
switch (dataType)
|
||||
{
|
||||
{case 1: //Integer
|
||||
XPLMSetDatai(theDREF,(int) floatarray[i]);
|
||||
break;}
|
||||
|
||||
{case 4: //Double
|
||||
XPLMSetDatad(theDREF,(double) floatarray[i]);
|
||||
break;}
|
||||
|
||||
{case 8: //Float Array
|
||||
fmini(XPLMGetDatavf(theDREF,NULL,0,8),arraySize); //find size of array
|
||||
if ( floatarray[0] != floatarray[0] ) // NaN Check
|
||||
{
|
||||
goto NANMessage;
|
||||
}
|
||||
|
||||
XPLMSetDatavf(theDREF,floatarray,arrayStart,arraySize);
|
||||
break;}
|
||||
|
||||
{case 16: //Integer Array
|
||||
int intArray[20];
|
||||
short length;
|
||||
length = fmini(XPLMGetDatavi(theDREF,NULL,0,8),arraySize); //find size of array
|
||||
for (i=arrayStart; i < arrayStart+length; i++)
|
||||
{
|
||||
intArray[i] = (int) floatarray[i];
|
||||
}
|
||||
XPLMSetDatavi(theDREF,intArray,0,length);
|
||||
break;}
|
||||
|
||||
{default: //Float
|
||||
XPLMSetDataf(theDREF,floatarray[i]);
|
||||
break;}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
XPC::Log::WriteLine("[DREF] ERROR: invalid DREF");
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
||||
NANMessage:
|
||||
XPC::Log::WriteLine("[DREF] ERROR: Value must be a number (NaN received)");
|
||||
return 1;
|
||||
}
|
||||
|
||||
char setGEAR(short aircraft, float gear, char posi)
|
||||
{
|
||||
int i;
|
||||
float gearArray[8];
|
||||
|
||||
if ((gear < - 8.5f && gear > 9.5f) || (gear < -997.9f && gear > -999.1f))
|
||||
{
|
||||
return -1; // Don't change command
|
||||
}
|
||||
|
||||
if ( ( gear != gear ) || ( gear < -1.f ) || ( gear > 1.f ) ) // NaN & Positive test
|
||||
{
|
||||
XPC::Log::WriteLine("[GEAR] ERROR: Value must be 0 or 1");
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (i=0;i<8;i++)
|
||||
{
|
||||
gearArray[i] = gear;
|
||||
}
|
||||
|
||||
if (!aircraft)
|
||||
{ // Own Aircraft
|
||||
setDREF(XPLMDataRefs[14][7], gearArray, 0, 8);
|
||||
}
|
||||
else
|
||||
{ // Multiplayer
|
||||
setDREF(multiplayer[aircraft][6], gearArray, 0, 8);
|
||||
}
|
||||
|
||||
if (posi)
|
||||
{
|
||||
XPLMSetDatavf(XPLMDataRefs[14][0], gearArray, 0, 1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
char setPOSI(short aircraft, float pos[3])
|
||||
{
|
||||
double local[3] = {0};
|
||||
int i;
|
||||
float tPos = pos[0] + pos[1] + pos[2];
|
||||
|
||||
if (tPos != tPos) // Is NaN
|
||||
{
|
||||
XPC::Log::WriteLine("[POSI] ERROR: Position must be a number (NaN received)");
|
||||
return 1;
|
||||
}
|
||||
|
||||
XPLMWorldToLocal(pos[0],pos[1],pos[2],&local[0],&local[1],&local[2]);
|
||||
if (aircraft <= 0)
|
||||
{ // Main aircraft
|
||||
for (i=0; i<3; i++)
|
||||
{
|
||||
XPLMSetDatad(XPLMDataRefs[21][i],local[i]);
|
||||
XPLMSetDatad(XPLMDataRefs[20][i], pos[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // Multiplayer
|
||||
for (i=0; i<3; i++)
|
||||
{
|
||||
XPLMSetDatad(multiplayer[aircraft][i], local[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
char setORIENT(short aircraft, float orient[3])
|
||||
{
|
||||
int i;
|
||||
float q[4] = {0};
|
||||
float pi = (float) 0.00872664625997; // 1/2 rad
|
||||
float tOrient = orient[0] + orient[1] + orient[2];
|
||||
|
||||
if ( tOrient != tOrient ) // Is NaN
|
||||
{
|
||||
XPC::Log::WriteLine("[ORIENT] ERROR: Orientation must be a number (NaN received)");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ( aircraft <= 0 ) // Main aircraft
|
||||
{
|
||||
XPLMSetDataf(XPLMDataRefs[17][0],orient[0]);
|
||||
XPLMSetDataf(XPLMDataRefs[17][1],orient[1]);
|
||||
XPLMSetDataf(XPLMDataRefs[17][2],orient[2]);
|
||||
|
||||
//Convert to Quartonians (from: http://www.xsquawkbox.net/xpsdk/mediawiki/MovingThePlane), http://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/19770024290.pdf pA2)
|
||||
orient[2] = pi * orient[2]; // 1/2 raidians
|
||||
orient[0] = pi * orient[0]; // 1/2 raidians
|
||||
orient[1] = pi * orient[1]; // 1/2 raidians
|
||||
q[0] = cos(orient[2]) * cos(orient[0]) * cos(orient[1]) + sin(orient[2]) * sin(orient[0]) * sin(orient[1]);
|
||||
q[1] = cos(orient[2]) * cos(orient[0]) * sin(orient[1]) - sin(orient[2]) * sin(orient[0]) * cos(orient[1]);
|
||||
q[2] = cos(orient[2]) * sin(orient[0]) * cos(orient[1]) + sin(orient[2]) * cos(orient[0]) * sin(orient[1]);
|
||||
q[3] = sin(orient[2]) * cos(orient[0]) * cos(orient[1]) - cos(orient[2]) * sin(orient[0]) * sin(orient[1]);
|
||||
|
||||
XPLMSetDatavf(XPLMDataRefs[17][4],q,0,4);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i=0; i<3; i++)
|
||||
{
|
||||
XPLMSetDataf(multiplayer[aircraft][i+3],orient[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
char setFLAP(float flap)
|
||||
{
|
||||
float floatArray[1] = {flap};
|
||||
setDREF(XPLMDataRefs[13][3],floatArray,0,1);
|
||||
setDREF(XPLMDataRefs[13][4],floatArray,0,1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int handlePOSI(char buf[])
|
||||
{
|
||||
float position[8] = {0.0};
|
||||
@@ -713,26 +514,30 @@ int handlePOSI(char buf[])
|
||||
|
||||
aircraft = fmini(parsePOSI(buf,position,6, &gear),19);
|
||||
|
||||
//ADD AIRCRAFT HANDLING- (-1 = single aircraft for player)
|
||||
if (aircraft > 0) // Multiplayer aircraft
|
||||
if (aircraft > 0)
|
||||
{
|
||||
XPLMGetDatavi(AIswitch, autopilot, 0, 20);
|
||||
autopilot[aircraft] = 1;
|
||||
XPLMSetDatavi(AIswitch, autopilot, 0, 20);
|
||||
// Enable AI for the aircraft we are setting
|
||||
float ai[20];
|
||||
std::size_t result = XPC::DataManager::GetFloatArray(XPC::DREF::PauseAI, ai, 20);
|
||||
if (result == 20) // Only set values if they were retrieved successfully.
|
||||
{
|
||||
ai[aircraft] = 1;
|
||||
XPC::DataManager::Set(XPC::DREF::PauseAI, ai, 0, 20);
|
||||
}
|
||||
}
|
||||
|
||||
// Position
|
||||
memcpy(pos,position,3*sizeof(float));
|
||||
setPOSI(aircraft, pos);
|
||||
XPC::DataManager::SetPosition(pos, aircraft);
|
||||
|
||||
// Orientation
|
||||
memcpy(orient,&position[3],3*sizeof(float));
|
||||
setORIENT(aircraft, orient);
|
||||
XPC::DataManager::SetOrientation(orient, aircraft);
|
||||
|
||||
//Landing Gear
|
||||
if (gear != -1)
|
||||
{
|
||||
setGEAR(aircraft, gear, 1);
|
||||
XPC::DataManager::SetGear(gear, false, aircraft);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -756,62 +561,32 @@ int handleCTRL(char buf[])
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
if (ctrl.aircraft == 0) //player aircraft
|
||||
// SET CONTROLS
|
||||
XPC::DataManager::Set(XPC::DREF::YokePitch, ctrl.pitch, ctrl.aircraft);
|
||||
XPC::DataManager::Set(XPC::DREF::YokeRoll, ctrl.roll, ctrl.aircraft);
|
||||
XPC::DataManager::Set(XPC::DREF::YokeHeading, ctrl.yaw, ctrl.aircraft);
|
||||
|
||||
// SET Throttle
|
||||
for (i = 0; i<8; i++)
|
||||
{
|
||||
// SET CONTROLS
|
||||
XPLMSetDataf(XPLMDataRefs[11][0], ctrl.pitch);
|
||||
XPLMSetDataf(XPLMDataRefs[11][1], ctrl.roll);
|
||||
XPLMSetDataf(XPLMDataRefs[11][2], ctrl.yaw);
|
||||
|
||||
// SET Throttle
|
||||
for (i = 0; i<8; i++)
|
||||
{
|
||||
thr[i] = ctrl.throttle;
|
||||
}
|
||||
XPLMSetDatavf(XPLMDataRefs[25][0], thr, 0, 8);
|
||||
XPLMSetDatavf(XPLMDataRefs[26][0], thr, 0, 8);
|
||||
setDREF(XPLMFindDataRef("sim/flightmodel/engine/ENGN_thro_override"), thr, 0, 1);
|
||||
|
||||
// SET Gear/Flaps
|
||||
if (ctrl.gear != -1)
|
||||
{
|
||||
setGEAR(0, ctrl.gear, 0); // Gear
|
||||
}
|
||||
if (ctrl.flaps < -999.5 || ctrl.flaps > -997.5) // Flaps
|
||||
{
|
||||
XPLMSetDataf(XPLMDataRefs[13][3], ctrl.flaps);
|
||||
}
|
||||
thr[i] = ctrl.throttle;
|
||||
}
|
||||
else //non-player aircraft
|
||||
XPC::DataManager::Set(XPC::DREF::ThrottleSet, thr, 8, ctrl.aircraft);
|
||||
XPC::DataManager::Set(XPC::DREF::ThrottleActual, thr, 8, ctrl.aircraft);
|
||||
if (ctrl.aircraft == 0)
|
||||
{
|
||||
// SET CONTROLS
|
||||
XPLMSetDataf(multiplayer[ctrl.aircraft][14], ctrl.pitch);
|
||||
XPLMSetDataf(multiplayer[ctrl.aircraft][15], ctrl.roll);
|
||||
XPLMSetDataf(multiplayer[ctrl.aircraft][16], ctrl.yaw);
|
||||
XPC::DataManager::Set("sim/flightmodel/engine/ENGN_thro_override", thr, 1);
|
||||
}
|
||||
|
||||
// SET Throttle
|
||||
for (i = 0; i<8; i++)
|
||||
{
|
||||
thr[i] = ctrl.throttle;
|
||||
}
|
||||
XPLMSetDatavf(multiplayer[ctrl.aircraft][13], thr, 0, 8);
|
||||
|
||||
// SET Gear/Flaps
|
||||
if (ctrl.gear != -1)
|
||||
{
|
||||
float gear[10];
|
||||
for (int i = 0; i < 10; ++i)
|
||||
{
|
||||
gear[i] = ctrl.gear;
|
||||
}
|
||||
XPLMSetDatavf(multiplayer[ctrl.aircraft][6], gear, 0, 10);
|
||||
}
|
||||
if (ctrl.flaps < -999.5 || ctrl.flaps > -997.5) // Flaps
|
||||
{
|
||||
XPLMSetDataf(multiplayer[ctrl.aircraft][7], ctrl.flaps);
|
||||
XPLMSetDataf(multiplayer[ctrl.aircraft][8], ctrl.flaps);
|
||||
}
|
||||
}
|
||||
// SET Gear/Flaps
|
||||
if (ctrl.gear != -1)
|
||||
{
|
||||
XPC::DataManager::SetGear(ctrl.gear, false, ctrl.aircraft);
|
||||
}
|
||||
if (ctrl.flaps < -999.5 || ctrl.flaps > -997.5) // Flaps
|
||||
{
|
||||
XPC::DataManager::Set(XPC::DREF::FlapSetting, ctrl.flaps, ctrl.aircraft);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -850,21 +625,10 @@ int handleWYPT(char buf[], int len)
|
||||
|
||||
int handleGETD(char buf[])
|
||||
{
|
||||
int length,i,k;
|
||||
XPLMDataTypeID dataType;
|
||||
int listLength = buf[5];
|
||||
char the_message[5000];
|
||||
char header[5] = {0};
|
||||
int count = 6;
|
||||
float values[100] = {-998};
|
||||
int intArray[100] = {-998};
|
||||
int DREFSizes[100] = {0};
|
||||
int DREFSizes[100] = { 0 };
|
||||
char *DREFArray[100];
|
||||
|
||||
strncpy(header,"RESP",4);
|
||||
memcpy(&the_message,&header,4);
|
||||
|
||||
if (listLength == 0) // USE LAST REQUEST
|
||||
std::uint8_t drefCount = buf[5];
|
||||
if (drefCount == 0) // USE LAST REQUEST
|
||||
{
|
||||
XPC::Log::FormatLine("[GETD] DATA Requested- repeat last request from connection %i (%i data refs)",
|
||||
current_connection + 1,
|
||||
@@ -876,83 +640,41 @@ int handleGETD(char buf[])
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if (listLength > 0) // NEW REQUEST
|
||||
else if (drefCount > 0) // NEW REQUEST
|
||||
{
|
||||
connectionList[current_connection].requestLength = (short) listLength;
|
||||
|
||||
connectionList[current_connection].requestLength = (short)drefCount;
|
||||
|
||||
for (int i = 0; i < connectionList[current_connection].requestLength; i++)
|
||||
{
|
||||
DREFArray[i] = (char *) malloc(100);
|
||||
memset(DREFArray[i],0,100);
|
||||
DREFArray[i] = (char *)malloc(100);
|
||||
memset(DREFArray[i], 0, 100);
|
||||
}
|
||||
|
||||
parseGETD(buf,DREFArray,DREFSizes);
|
||||
|
||||
parseGETD(buf, DREFArray, DREFSizes);
|
||||
XPC::Log::FormatLine("[GETD] DATA Requested- New Request for connection %i [%i]:",
|
||||
current_connection + 1,
|
||||
listLength);
|
||||
drefCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i=0;i<connectionList[current_connection].requestLength;i++)
|
||||
{
|
||||
if (listLength > 0)
|
||||
{
|
||||
connectionList[current_connection].XPLMRequestedDRefs[i] = XPLMFindDataRef(DREFArray[i]);
|
||||
}
|
||||
|
||||
if (connectionList[current_connection].XPLMRequestedDRefs[i]) //Valid Pointer
|
||||
{
|
||||
dataType = XPLMGetDataRefTypes(connectionList[current_connection].XPLMRequestedDRefs[i]);
|
||||
switch (dataType)
|
||||
{
|
||||
{case 1: //Integer
|
||||
length = 1;
|
||||
values[0] = (float) XPLMGetDatai(connectionList[current_connection].XPLMRequestedDRefs[i]);
|
||||
break;}
|
||||
|
||||
{case 4: //Double
|
||||
length = 1;
|
||||
values[0] = (float) XPLMGetDatad(connectionList[current_connection].XPLMRequestedDRefs[i]);
|
||||
break;}
|
||||
|
||||
{case 8: //Float Array
|
||||
length = XPLMGetDatavf(connectionList[current_connection].XPLMRequestedDRefs[i],NULL,0,8); //find size of array
|
||||
XPLMGetDatavf(connectionList[current_connection].XPLMRequestedDRefs[i],values,0,fminl(length,100));
|
||||
break;}
|
||||
|
||||
{case 16: //Integer Array
|
||||
length = XPLMGetDatavi(connectionList[current_connection].XPLMRequestedDRefs[i],NULL,0,8); //find size of array
|
||||
XPLMGetDatavi(connectionList[current_connection].XPLMRequestedDRefs[i],intArray,0,fminl(length,100));
|
||||
for (k=0; k < length; k++) {
|
||||
values[k]=(float) intArray[k];
|
||||
}
|
||||
break;}
|
||||
|
||||
{default: //Float
|
||||
length = 1;
|
||||
values[0] = XPLMGetDataf(connectionList[current_connection].XPLMRequestedDRefs[i]);
|
||||
break;}
|
||||
}
|
||||
the_message[count] = length;
|
||||
memcpy(&the_message[count+1],&values,length*sizeof(float));
|
||||
count += 1 + length*sizeof(float);
|
||||
}
|
||||
else
|
||||
{
|
||||
XPC::Log::FormatLine("%s-ERROR: invalid DREF", DREFArray[i]);
|
||||
}
|
||||
}
|
||||
the_message[5] = (char) connectionList[current_connection].requestLength;
|
||||
|
||||
if (count > 6)
|
||||
std::uint8_t response[4096] = "RESP";
|
||||
response[5] = drefCount;
|
||||
std::size_t cur = 6;
|
||||
for (int i = 0; i < drefCount; ++i)
|
||||
{
|
||||
char* host = connectionList[current_connection].IP;
|
||||
std::uint16_t port = connectionList[current_connection].recPort;
|
||||
sendSocket->SendTo((std::uint8_t*)the_message, count, host, port);
|
||||
float values[255];
|
||||
std::size_t count = XPC::DataManager::Get(DREFArray[i], values, 255);
|
||||
response[cur] = count;
|
||||
memcpy(response + 1 + cur, values, count * sizeof(float));
|
||||
cur += 1 + count * sizeof(float);
|
||||
}
|
||||
|
||||
char* host = connectionList[current_connection].IP;
|
||||
std::uint16_t port = connectionList[current_connection].recPort;
|
||||
sendSocket->SendTo(response, cur, host, port);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -963,7 +685,6 @@ int handleDREF(char buf[])
|
||||
unsigned short lenDREF = 0;
|
||||
unsigned short lenVALUE = 0;
|
||||
float values[40] = {0.0};
|
||||
XPLMDataRef theDREF;
|
||||
|
||||
parseDREF(buf, DREF, &lenDREF,values,&lenVALUE);
|
||||
|
||||
@@ -976,8 +697,7 @@ int handleDREF(char buf[])
|
||||
// Handle DREF
|
||||
XPC::Log::FormatLine("[DREF] Request to set DREF value received (Conn %i): %s", current_connection + 1, DREF);
|
||||
|
||||
theDREF = XPLMFindDataRef(DREF);
|
||||
setDREF(theDREF, values, 0, lenVALUE);
|
||||
XPC::DataManager::Set(DREF, values, lenVALUE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1028,17 +748,17 @@ int handleDATA(char buf[], int buflen)
|
||||
|
||||
float theta, alpha, hpath,v;
|
||||
int ind[3] = {1,3,4};
|
||||
theta = XPLMGetDataf(XPLMDataRefs[17][0]); //Theta
|
||||
theta = XPC::DataManager::GetFloat(XPC::DREF::Pitch);
|
||||
|
||||
if (savedAlpha != -998)
|
||||
alpha = savedAlpha;
|
||||
else
|
||||
alpha = XPLMGetDataf(XPLMDataRefs[18][0]); //Alpha
|
||||
alpha = XPC::DataManager::GetFloat(XPC::DREF::AngleOfAttack);
|
||||
|
||||
if (savedHPath != -998)
|
||||
hpath = savedHPath;
|
||||
else
|
||||
hpath = XPLMGetDataf(XPLMDataRefs[18][2]); //Velocity Heading
|
||||
hpath = XPC::DataManager::GetFloat(XPC::DREF::HPath); //Velocity Heading
|
||||
|
||||
if ( ( hpath != hpath ) && ( alpha != alpha ) && ( theta != theta ) ) // NaN Check
|
||||
{
|
||||
@@ -1051,24 +771,21 @@ int handleDATA(char buf[], int buflen)
|
||||
if (recValues[i][ind[j]] != -998)
|
||||
{
|
||||
v = recValues[i][ind[j]];
|
||||
|
||||
XPLMSetDataf(XPLMDataRefs[21][3],v*cos((theta-alpha)*deg2rad)*sin(hpath*deg2rad));
|
||||
XPLMSetDataf(XPLMDataRefs[21][4],v*sin((theta-alpha)*deg2rad));
|
||||
XPLMSetDataf(XPLMDataRefs[21][5],-v*cos((theta-alpha)*deg2rad)*cos(hpath*deg2rad));
|
||||
|
||||
XPC::DataManager::Set(XPC::DREF::LocalVX, v*cos((theta - alpha)*deg2rad)*sin(hpath*deg2rad));
|
||||
XPC::DataManager::Set(XPC::DREF::LocalVY, v*sin((theta - alpha)*deg2rad));
|
||||
XPC::DataManager::Set(XPC::DREF::LocalVZ, -v*cos((theta - alpha)*deg2rad)*cos(hpath*deg2rad));
|
||||
}
|
||||
}
|
||||
break;}
|
||||
{case 17: // Orientation
|
||||
float orient[3] = {0};
|
||||
|
||||
for (j=1; j<4; j++)
|
||||
if (recValues[i][j] == -998)
|
||||
recValues[i][j] = XPLMGetDataf(XPLMDataRefs[17][j-1]);
|
||||
|
||||
memcpy(orient,&recValues[i][1],3*sizeof(float));
|
||||
|
||||
setORIENT(0, orient);
|
||||
|
||||
float orient[3]
|
||||
{
|
||||
recValues[i][1] == -998 ? XPC::DataManager::GetFloat(XPC::DREF::Pitch) : recValues[i][1],
|
||||
recValues[i][2] == -998 ? XPC::DataManager::GetFloat(XPC::DREF::Roll) : recValues[i][2],
|
||||
recValues[i][3] == -998 ? XPC::DataManager::GetFloat(XPC::DREF::HeadingTrue) : recValues[i][3]
|
||||
};
|
||||
XPC::DataManager::SetOrientation(orient);
|
||||
break;}
|
||||
|
||||
{case 18: // Alpha, hpath etc.
|
||||
@@ -1087,15 +804,13 @@ int handleDATA(char buf[], int buflen)
|
||||
break;}
|
||||
|
||||
{case 20: // Position
|
||||
float local[3] = {0};
|
||||
|
||||
for (j=1; j<4; j++)
|
||||
if (recValues[i][j+1] == -998)
|
||||
recValues[i][j+1] = XPLMGetDataf(XPLMDataRefs[20][j]);
|
||||
|
||||
memcpy(local,&recValues[i][1],3*sizeof(float));
|
||||
setPOSI(0, local);
|
||||
|
||||
float pos[3]
|
||||
{
|
||||
recValues[i][2] == -998 ? XPC::DataManager::GetFloat(XPC::DREF::Latitude) : recValues[i][2],
|
||||
recValues[i][3] == -998 ? XPC::DataManager::GetFloat(XPC::DREF::Longitude) : recValues[i][3],
|
||||
recValues[i][4] == -998 ? XPC::DataManager::GetFloat(XPC::DREF::AGL) : recValues[i][4]
|
||||
};
|
||||
XPC::DataManager::SetPosition(pos);
|
||||
break;}
|
||||
|
||||
{case 25: // Throttle
|
||||
@@ -1108,7 +823,7 @@ int handleDATA(char buf[], int buflen)
|
||||
for (j=0; j<8; j++)
|
||||
floatArray[j] = recValues[i][1];
|
||||
|
||||
XPLMSetDatavf(XPLMDataRefs[25][0],floatArray,0,8);
|
||||
XPC::DataManager::Set(XPC::DREF::ThrottleSet, floatArray, 8);
|
||||
break;}
|
||||
|
||||
{default: // Non-Special dataRefs (everything else)
|
||||
@@ -1122,13 +837,19 @@ int handleDATA(char buf[], int buflen)
|
||||
|
||||
if (dataRef==14 && j==0)
|
||||
{
|
||||
setGEAR(0, recValues[i][j+1], 1); // Landing Gear
|
||||
XPC::DataManager::SetGear(recValues[i][j + 1], false);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Set DATAREF
|
||||
if (setDREF(XPLMDataRefs[dataRef][j],floatArray,j,8) == -1)
|
||||
sendBUF(buf,buflen);
|
||||
|
||||
XPC::DREF dref = XPC::XPData[dataRef][j];
|
||||
if (dref == XPC::DREF::None)
|
||||
{
|
||||
sendBUF(buf, buflen);
|
||||
}
|
||||
else
|
||||
{
|
||||
XPC::DataManager::Set(dref, floatArray, 8);
|
||||
}
|
||||
} //End for j=1:8
|
||||
break;}
|
||||
} // End switch(dataRef)
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -99,6 +99,8 @@
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\C\src\xplaneConnect.h" />
|
||||
<ClInclude Include="..\DataManager.h" />
|
||||
<ClInclude Include="..\DataMaps.h" />
|
||||
<ClInclude Include="..\Drawing.h" />
|
||||
<ClInclude Include="..\Log.h" />
|
||||
<ClInclude Include="..\Message.h" />
|
||||
@@ -107,6 +109,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\C\src\xplaneConnect.c" />
|
||||
<ClCompile Include="..\DataManager.cpp" />
|
||||
<ClCompile Include="..\Drawing.cpp" />
|
||||
<ClCompile Include="..\Log.cpp" />
|
||||
<ClCompile Include="..\Message.cpp" />
|
||||
|
||||
@@ -18,9 +18,6 @@
|
||||
<ClInclude Include="..\..\C\src\xplaneConnect.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\xpcPluginTools.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Log.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
@@ -33,6 +30,15 @@
|
||||
<ClInclude Include="..\Message.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\DataManager.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\DataMaps.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\xpcPluginTools.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\C\src\xplaneConnect.c">
|
||||
@@ -41,9 +47,6 @@
|
||||
<ClCompile Include="..\XPCPlugin.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\xpcPluginTools.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Log.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
@@ -56,6 +59,12 @@
|
||||
<ClCompile Include="..\Message.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\DataManager.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\xpcPluginTools.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Library Include="..\SDK\Libraries\Win\XPLM.lib">
|
||||
|
||||
@@ -32,233 +32,6 @@
|
||||
#include <math.h>
|
||||
#include "xpcPluginTools.h"
|
||||
|
||||
XPLMDataRef XPLMDataRefs[134][8];
|
||||
XPLMDataRef multiplayer[20][17];
|
||||
XPLMDataRef AIswitch;
|
||||
|
||||
void buildXPLMDataRefs()
|
||||
{
|
||||
int i, j;
|
||||
char multi[50] = {0};
|
||||
|
||||
for (i=0; i<134; i++)
|
||||
{
|
||||
for (j=0; j<8; j++)
|
||||
{
|
||||
XPLMDataRefs[i][j] = XPLMFindDataRef("sim/test/test_float");
|
||||
}
|
||||
}
|
||||
|
||||
/* Prefetch the sim variables we will use. */
|
||||
//Row 0: Frame Rates
|
||||
|
||||
//Row 1: Times
|
||||
XPLMDataRefs[1][1] = XPLMFindDataRef("sim/time/total_running_time_sec");
|
||||
XPLMDataRefs[1][2] = XPLMFindDataRef("sim/time/total_flight_time_sec");
|
||||
XPLMDataRefs[1][3] = XPLMFindDataRef("sim/time/timer_elapsed_time_sec");
|
||||
|
||||
//cockpit2/clock_time/zulu_time_hours
|
||||
//cockpit2/clock_time/zulu_time_minutes
|
||||
//cockpit2/clock_time/zulu_time_seconds
|
||||
|
||||
//cockpit2/clock_time/local_time_hours
|
||||
|
||||
//cockpit2/clock_time/hobbs_time_hours
|
||||
|
||||
//Row 2: Sim Stats
|
||||
|
||||
//Row 3: Velocities
|
||||
//READ ONLY
|
||||
XPLMDataRefs[3][0] = XPLMFindDataRef("sim/flightmodel/position/indicated_airspeed"); //Vind knots indicated airspeed TEST
|
||||
|
||||
//Vind knots equivilent airspeed (considering compressible flow)
|
||||
XPLMDataRefs[3][2] = XPLMFindDataRef("sim/flightmodel/position/true_airspeed"); //Vtrue knots true airspeed
|
||||
XPLMDataRefs[3][3] = XPLMFindDataRef("sim/flightmodel/position/groundspeed"); //Vtrue Knots true ground speed
|
||||
|
||||
//XPLMDataRefs[3][5] = Vind mph
|
||||
//XPLMDataRefs[3][6] = Vtrue mphas
|
||||
//XPLMDataRefs[3][7] = Vtre mphgs
|
||||
|
||||
//Row 4: Mach, VVI, G-loads
|
||||
XPLMDataRefs[4][0] = XPLMFindDataRef("sim/flightmodel/misc/machno"); // Mach Number
|
||||
XPLMDataRefs[4][4] = XPLMFindDataRef("sim/flightmodel2/misc/gforce_normal");
|
||||
XPLMDataRefs[4][5] = XPLMFindDataRef("sim/flightmodel2/misc/gforce_axial");
|
||||
XPLMDataRefs[4][6] = XPLMFindDataRef("sim/flightmodel2/misc/gforce_side");
|
||||
|
||||
//Row 5: Atmosphere: Weather
|
||||
XPLMDataRefs[5][0] = XPLMFindDataRef("sim/weather/barometer_sealevel_inhg");
|
||||
XPLMDataRefs[5][1] = XPLMFindDataRef("sim/weather/temperature_sealevel_c");
|
||||
XPLMDataRefs[5][3] = XPLMFindDataRef("sim/cockpit2/gauges/indicators/wind_speed_kts");
|
||||
|
||||
//Row 6: Atmosphere: Aircraft
|
||||
|
||||
//Row 7: System Pressures
|
||||
|
||||
//Row 8: Joystick
|
||||
XPLMDataRefs[8][0] = XPLMFindDataRef("sim/joystick/yoke_pitch_ratio");
|
||||
XPLMDataRefs[8][1] = XPLMFindDataRef("sim/joystick/yoke_roll_ratio");
|
||||
XPLMDataRefs[8][2] = XPLMFindDataRef("sim/joystick/yoke_heading_ratio");
|
||||
|
||||
//Row 9: Other Flight Controls
|
||||
|
||||
//Row 10: Art stab ail/elv/rud
|
||||
|
||||
//Row 11: Control Surfaces
|
||||
XPLMDataRefs[11][0] = XPLMFindDataRef("sim/cockpit2/controls/yoke_pitch_ratio"); //Elevator Position
|
||||
XPLMDataRefs[11][1] = XPLMFindDataRef("sim/cockpit2/controls/yoke_roll_ratio"); //Aileron Position
|
||||
XPLMDataRefs[11][2] = XPLMFindDataRef("sim/cockpit2/controls/yoke_heading_ratio"); //Rudder Position
|
||||
XPLMDataRefs[11][3] = NULL;
|
||||
XPLMDataRefs[11][4] = NULL;
|
||||
XPLMDataRefs[11][5] = NULL;
|
||||
XPLMDataRefs[11][6] = NULL;
|
||||
XPLMDataRefs[11][7] = NULL;
|
||||
|
||||
//Row 12: Wing Sweep/Trust Vec
|
||||
|
||||
//Row 13: trip/flap/slat/s-brakes
|
||||
XPLMDataRefs[13][3] = XPLMFindDataRef("sim/flightmodel/controls/flaprqst");
|
||||
XPLMDataRefs[13][4] = XPLMFindDataRef("sim/flightmodel/controls/flaprat");// should be equal to flap2rat
|
||||
|
||||
//Row 14: Gear, Brakes
|
||||
XPLMDataRefs[14][0] = XPLMFindDataRef("sim/aircraft/parts/acf_gear_deploy"); //Landing Gear-SPECIAL (Float[10])
|
||||
XPLMDataRefs[14][1] = XPLMFindDataRef("sim/flightmodel/controls/parkbrake"); //Parking Brake
|
||||
XPLMDataRefs[14][2] = XPLMFindDataRef("sim/cockpit2/controls/left_brake_ratio");
|
||||
XPLMDataRefs[14][3] = XPLMFindDataRef("sim/cockpit2/controls/right_brake_ratio");
|
||||
|
||||
XPLMDataRefs[14][7] = XPLMFindDataRef("sim/cockpit/switches/gear_handle_status"); //Landing Gear Handle
|
||||
|
||||
//Row 15: MNR (Angular Moments)
|
||||
//READ ONLY
|
||||
XPLMDataRefs[15][0] = XPLMFindDataRef("sim/flightmodel/position/M");
|
||||
XPLMDataRefs[15][1] = XPLMFindDataRef("sim/flightmodel/position/L");
|
||||
XPLMDataRefs[15][2] = XPLMFindDataRef("sim/flightmodel/position/N");
|
||||
|
||||
//Row 16: PQR (Angular Velocities)
|
||||
XPLMDataRefs[16][0] = XPLMFindDataRef("sim/flightmodel/position/Qrad");
|
||||
XPLMDataRefs[16][1] = XPLMFindDataRef("sim/flightmodel/position/Prad");
|
||||
XPLMDataRefs[16][2] = XPLMFindDataRef("sim/flightmodel/position/Rrad");
|
||||
XPLMDataRefs[16][3] = XPLMFindDataRef("sim/flightmodel/position/Q");
|
||||
XPLMDataRefs[16][4] = XPLMFindDataRef("sim/flightmodel/position/P");
|
||||
XPLMDataRefs[16][5] = XPLMFindDataRef("sim/flightmodel/position/R");
|
||||
|
||||
//Row 17: Orientation: pitch, roll, yaw, heading
|
||||
XPLMDataRefs[17][0] = XPLMFindDataRef("sim/flightmodel/position/theta"); //Pitch
|
||||
XPLMDataRefs[17][1] = XPLMFindDataRef("sim/flightmodel/position/phi"); //roll
|
||||
XPLMDataRefs[17][2] = XPLMFindDataRef("sim/flightmodel/position/psi"); //true heading (where nose is pointing)
|
||||
|
||||
//READ ONLY (always)
|
||||
XPLMDataRefs[17][3] = XPLMFindDataRef("sim/flightmodel/position/magpsi"); //magnetic heading
|
||||
|
||||
//WRITABLE
|
||||
XPLMDataRefs[17][4] = XPLMFindDataRef("sim/flightmodel/position/q"); //Quartonian
|
||||
|
||||
//Row 18: Orientation: alpha beta hpath vpath slip
|
||||
XPLMDataRefs[18][0] = XPLMFindDataRef("sim/flightmodel/position/alpha"); //Angle of Attack
|
||||
XPLMDataRefs[18][1] = XPLMFindDataRef("sim/cockpit2/gauges/indicators/sideslip_degrees"); //fix to beta
|
||||
XPLMDataRefs[18][2] = XPLMFindDataRef("sim/flightmodel/position/hpath"); //Heading the aircraft flies (velocity vector) TEST
|
||||
XPLMDataRefs[18][3] = XPLMFindDataRef("sim/flightmodel/position/vpath"); //VPath TEST
|
||||
XPLMDataRefs[18][7] = XPLMFindDataRef("sim/cockpit2/gauges/indicators/sideslip_degrees");
|
||||
|
||||
//Row 19: Mag Compass
|
||||
XPLMDataRefs[19][0] = XPLMFindDataRef("sim/flightmodel/position/magpsi");
|
||||
|
||||
//READ ONLY
|
||||
XPLMDataRefs[19][1] = XPLMFindDataRef("sim/flightmodel/position/magnetic_variation");
|
||||
|
||||
//Row 20: Global Position
|
||||
//READ ONLY
|
||||
XPLMDataRefs[20][0] = XPLMFindDataRef("sim/flightmodel/position/latitude"); // Read Only
|
||||
XPLMDataRefs[20][1] = XPLMFindDataRef("sim/flightmodel/position/longitude"); // Read Only
|
||||
XPLMDataRefs[20][3] = XPLMFindDataRef("sim/flightmodel/position/y_agl"); // Read Only
|
||||
|
||||
//Row 21: Local Position, Velocity
|
||||
XPLMDataRefs[21][0] = XPLMFindDataRef("sim/flightmodel/position/local_x");
|
||||
XPLMDataRefs[21][1] = XPLMFindDataRef("sim/flightmodel/position/local_y");
|
||||
XPLMDataRefs[21][2] = XPLMFindDataRef("sim/flightmodel/position/local_z");
|
||||
XPLMDataRefs[21][3] = XPLMFindDataRef("sim/flightmodel/position/local_vx");
|
||||
XPLMDataRefs[21][4] = XPLMFindDataRef("sim/flightmodel/position/local_vy");
|
||||
XPLMDataRefs[21][5] = XPLMFindDataRef("sim/flightmodel/position/local_vz");
|
||||
|
||||
//Row 22: All Planes: Lat (READ ONLY)
|
||||
XPLMDataRefs[22][0] = XPLMDataRefs[20][0];
|
||||
XPLMDataRefs[22][1] = XPLMFindDataRef("sim/multiplayer/position/plane1_lat");
|
||||
XPLMDataRefs[22][2] = XPLMFindDataRef("sim/multiplayer/position/plane2_lat");
|
||||
XPLMDataRefs[22][3] = XPLMFindDataRef("sim/multiplayer/position/plane3_lat");
|
||||
XPLMDataRefs[22][4] = XPLMFindDataRef("sim/multiplayer/position/plane4_lat");
|
||||
XPLMDataRefs[22][5] = XPLMFindDataRef("sim/multiplayer/position/plane5_lat");
|
||||
XPLMDataRefs[22][6] = XPLMFindDataRef("sim/multiplayer/position/plane6_lat");
|
||||
XPLMDataRefs[22][7] = XPLMFindDataRef("sim/multiplayer/position/plane7_lat");
|
||||
|
||||
//Row 23: All Planes: Lon
|
||||
XPLMDataRefs[23][0] = XPLMDataRefs[20][1];
|
||||
XPLMDataRefs[23][1] = XPLMFindDataRef("sim/multiplayer/position/plane1_lon");
|
||||
XPLMDataRefs[23][2] = XPLMFindDataRef("sim/multiplayer/position/plane2_lon");
|
||||
XPLMDataRefs[23][3] = XPLMFindDataRef("sim/multiplayer/position/plane3_lon");
|
||||
XPLMDataRefs[23][4] = XPLMFindDataRef("sim/multiplayer/position/plane4_lon");
|
||||
XPLMDataRefs[23][5] = XPLMFindDataRef("sim/multiplayer/position/plane5_lon");
|
||||
XPLMDataRefs[23][6] = XPLMFindDataRef("sim/multiplayer/position/plane6_lon");
|
||||
XPLMDataRefs[23][7] = XPLMFindDataRef("sim/multiplayer/position/plane7_lon");
|
||||
|
||||
//Row 24: All Planes: Alt
|
||||
XPLMDataRefs[24][0] = XPLMDataRefs[20][2];
|
||||
XPLMDataRefs[24][1] = XPLMFindDataRef("sim/multiplayer/position/plane1_el");
|
||||
XPLMDataRefs[24][2] = XPLMFindDataRef("sim/multiplayer/position/plane2_el");
|
||||
XPLMDataRefs[24][3] = XPLMFindDataRef("sim/multiplayer/position/plane3_el");
|
||||
XPLMDataRefs[24][4] = XPLMFindDataRef("sim/multiplayer/position/plane4_el");
|
||||
XPLMDataRefs[24][5] = XPLMFindDataRef("sim/multiplayer/position/plane5_el");
|
||||
XPLMDataRefs[24][6] = XPLMFindDataRef("sim/multiplayer/position/plane6_el");
|
||||
XPLMDataRefs[24][7] = XPLMFindDataRef("sim/multiplayer/position/plane7_el");
|
||||
|
||||
//Row 25: Throttle Command
|
||||
XPLMDataRefs[25][0] = XPLMFindDataRef("sim/flightmodel/engine/ENGN_thro"); //Throttle (array 8)
|
||||
|
||||
//Row 26: Throttle Actual
|
||||
XPLMDataRefs[26][0] = XPLMFindDataRef("sim/flightmodel2/engines/throttle_used_ratio"); // Trottle Actual (array 8) (Read Only)
|
||||
|
||||
//Row 27:
|
||||
|
||||
|
||||
// Multiplayer
|
||||
for ( i = 1; i < 20; i++ )
|
||||
{
|
||||
sprintf(multi, "sim/multiplayer/position/plane%i_x", i); // X
|
||||
multiplayer[i][0] = XPLMFindDataRef(multi);
|
||||
sprintf(multi, "sim/multiplayer/position/plane%i_y", i); // Y
|
||||
multiplayer[i][1] = XPLMFindDataRef(multi);
|
||||
sprintf(multi,"sim/multiplayer/position/plane%i_z", i); // Z
|
||||
multiplayer[i][2] = XPLMFindDataRef(multi);
|
||||
sprintf(multi,"sim/multiplayer/position/plane%i_the", i); // Theta (Pitch)
|
||||
multiplayer[i][3] = XPLMFindDataRef(multi);
|
||||
sprintf(multi,"sim/multiplayer/position/plane%i_phi", i); // Phi (Roll)
|
||||
multiplayer[i][4] = XPLMFindDataRef(multi);
|
||||
sprintf(multi,"sim/multiplayer/position/plane%i_psi", i); // Psi (Heading-True)
|
||||
multiplayer[i][5] = XPLMFindDataRef(multi);
|
||||
sprintf(multi, "sim/multiplayer/position/plane%i_gear_deploy", i); // Landing Gear
|
||||
multiplayer[i][6] = XPLMFindDataRef(multi);
|
||||
sprintf(multi, "sim/multiplayer/position/plane%i_flap_ratio", i);
|
||||
multiplayer[i][7] = XPLMFindDataRef(multi);
|
||||
sprintf(multi, "sim/multiplayer/position/plane%i_flap_ratio2", i);
|
||||
multiplayer[i][8] = XPLMFindDataRef(multi);
|
||||
sprintf(multi, "sim/multiplayer/position/plane%i_spoiler_ratio", i);
|
||||
multiplayer[i][9] = XPLMFindDataRef(multi);
|
||||
sprintf(multi, "sim/multiplayer/position/plane%i_speedbrake_ratio", i);
|
||||
multiplayer[i][10] = XPLMFindDataRef(multi);
|
||||
sprintf(multi, "sim/multiplayer/position/plane%i_slat_ratio", i);
|
||||
multiplayer[i][11] = XPLMFindDataRef(multi);
|
||||
sprintf(multi, "sim/multiplayer/position/plane%i_wing_sweep", i);
|
||||
multiplayer[i][12] = XPLMFindDataRef(multi);
|
||||
sprintf(multi, "sim/multiplayer/position/plane%i_throttle", i);
|
||||
multiplayer[i][13] = XPLMFindDataRef(multi);
|
||||
sprintf(multi, "sim/multiplayer/position/plane%i_yolk_pitch", i);
|
||||
multiplayer[i][14] = XPLMFindDataRef(multi);
|
||||
sprintf(multi, "sim/multiplayer/position/plane%i_yolk_roll", i);
|
||||
multiplayer[i][15] = XPLMFindDataRef(multi);
|
||||
sprintf(multi, "sim/multiplayer/position/plane%i_yolk_yaw", i);
|
||||
multiplayer[i][16] = XPLMFindDataRef(multi);
|
||||
}
|
||||
AIswitch = XPLMFindDataRef("sim/operation/override/override_plane_ai_autopilot");
|
||||
}
|
||||
|
||||
int fmini(int a, int b)
|
||||
{
|
||||
// Returns the minimum value of two integers
|
||||
|
||||
@@ -8,18 +8,9 @@
|
||||
|
||||
#ifndef xpcPlugin_xpcPluginTools_h
|
||||
#define xpcPlugin_xpcPluginTools_h
|
||||
|
||||
#include "UDPSocket.h"
|
||||
|
||||
#include <time.h>
|
||||
#include "xplaneConnect.h"
|
||||
#include "XPLMDataAccess.h"
|
||||
|
||||
extern XPLMDataRef XPLMDataRefs[134][8];
|
||||
extern XPLMDataRef multiplayer[20][17];
|
||||
extern XPLMDataRef AIswitch;
|
||||
|
||||
void buildXPLMDataRefs(void);
|
||||
|
||||
int almostequal(float arg1, float arg2, float tol);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user