diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore index 259148f..c390194 100644 --- a/.gitignore +++ b/.gitignore @@ -24,9 +24,370 @@ *.lai *.la *.a -*.lib # Executables -*.exe *.out -*.app + +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Oo]ut/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd \ No newline at end of file diff --git a/README.md b/README.md index 0ab50b0..9db456b 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ -# XPLPro -XPLPro +# XPLPro Official - GCC +Fork of [XPLPro project by Michael Gerlicher](https://github.com/curiosity-workshop/XPLPro) + +Kept up to date (best effort) by _g.crocic \_at\_ gmail.com_ with changes published (usually on Discord), +occasionally with small corrections added diff --git a/XPLPro_Arduino/XPLPro/XPLEncoderSharedInterrupt.h b/XPLPro_Arduino/XPLPro/XPLEncoderSharedInterrupt.h new file mode 100644 index 0000000..d854699 --- /dev/null +++ b/XPLPro_Arduino/XPLPro/XPLEncoderSharedInterrupt.h @@ -0,0 +1,138 @@ +// XPLEncoderSharedInterrupt.h - XPLPro Add-on Header for rotary encoders sharing an interrupt pin via schottky diode isolation +// // This is NOT FUNCTIONAL AT THIS TIME +// Created by Curiosity Workshop, Michael Gerlicher, 2024 +// +// To report problems, download updates and examples, suggest enhancements or get technical support, please visit: +// discord: https://discord.gg/gzXetjEST4 +// patreon: www.patreon.com/curiosityworkshop + + +// 3 April 2024 -- Initial release + + +// I didn't encapsulate this into a class as the use of interrupt calls makes it complex. + +#ifndef XPLEncoderSharedInterrupt_h +#define XPLEncoderSharedInterrupt_h + +// Parameters around the interface + +#ifndef XPLESI_MAXENCODERS + #define XPLESI_MAXENCODERS 8 //Default to 10. +#endif + + + + //XPLEncoderSharedInterrupt(int interruptPin, void (*esiHandler)(int inEncoder, int inValue)); + +int XPLESIbegin(int inPin, void(*esiHandler)(int esiID, int esiValue)); +int XPLESIaddEncoder(int inPinA, int inPinB); +void _XPLESIcheck(); +void XPEESIwrite(int inEncoder, int inValue); +int XPLESIread(int inEncoder); +void XPLESIclear(void); + +int _XPLESIcount; // how many are registered +int _XPLESIinterruptPin; // which is the shared interrupt pin + +void (*_XPLESIhandler)(int esiID, int esiValue) = NULL; // this function will be called when activity is detected on the pot, if not NULL + + +struct XPLESIencoder +{ + int pinA; // connected pin + int pinB; // connected pin + + byte prevStatusPinA; + byte prevStatusPinB; + byte currentStatusPinA; + byte currentStatusPinB; + + int currentValue; + + +}; + +struct XPLESIencoder _XPLesis[XPLESI_MAXENCODERS]; + + +int XPLESIbegin(int interruptPin, void (*esiHandler)(int esiID, int esiValue)) +{ + _XPLESIhandler = esiHandler; + pinMode(interruptPin, INPUT_PULLUP); + // attach interrupt handler for when the interrupt pin is triggered + attachInterrupt(digitalPinToInterrupt(interruptPin), _XPLESIcheck, CHANGE); + + +}; + + + +void XPLESIclear(void) // call this prior to adding encoders if not the first run +{ + _XPLESIcount = 0; + +} + + + +int XPLESIaddEncoder(int inPinA, int inPinB) +{ + if (_XPLESIcount >= XPLESI_MAXENCODERS) return -1; + + pinMode(inPinA, INPUT_PULLUP); + pinMode(inPinB, INPUT_PULLUP); + + _XPLesis[_XPLESIcount].pinA = inPinA; + _XPLesis[_XPLESIcount].pinB = inPinB; + + _XPLesis[_XPLESIcount].prevStatusPinA = 0; + _XPLesis[_XPLESIcount].prevStatusPinB = 0; + + _XPLesis[_XPLESIcount].currentValue = 0; + + return _XPLESIcount++; + + +} + + +void _XPLESIcheck() +{ + + for (int i = 0; i < _XPLESIcount; i++) // Im doing this first to get the best possible read of the pins + { + _XPLesis[i].currentStatusPinA = digitalRead(_XPLesis[i].pinA); + _XPLesis[i].currentStatusPinB = digitalRead(_XPLesis[i].pinB); + } + + // Now figure out which one moved. + for (int i = 0; i < _XPLESIcount; i++) + { + // If the previous and the current state are different, that means a Pulse has occured + if (_XPLesis[i].currentStatusPinA != _XPLesis[i].prevStatusPinA || _XPLesis[i].currentStatusPinB != _XPLesis[i].prevStatusPinB) + { + // If the outputB state is different to the outputA state, that means the encoder is rotating clockwise + if (_XPLesis[i].currentStatusPinA != _XPLesis[i].currentStatusPinB) _XPLesis[i].currentValue++; + else _XPLesis[i].currentValue--; + _XPLesis[i].prevStatusPinA = _XPLesis[i].currentStatusPinA; + _XPLesis[i].prevStatusPinB = _XPLesis[i].currentStatusPinB; + _XPLESIhandler(i, _XPLesis[i].currentValue); + } + + } + + +} + +void XPLESIwrite(int inEncoder, int inValue) +{ + _XPLesis[inEncoder].currentValue = inValue; + +} +int XPLESIread(int inEncoder) +{ + return _XPLesis[inEncoder].currentValue; + +} +#endif \ No newline at end of file diff --git a/XPLPro_Arduino/XPLPro/XPLLedStrip.h b/XPLPro_Arduino/XPLPro/XPLLedStrip.h new file mode 100644 index 0000000..0bef86a --- /dev/null +++ b/XPLPro_Arduino/XPLPro/XPLLedStrip.h @@ -0,0 +1,196 @@ +// XPLLedStrip.h - Library for LED strips +// Created by Curiosity Workshop, Michael Gerlicher, 2024 +// +// To report problems, download updates and examples, suggest enhancements or get technical support, please visit: +// discord: https://discord.gg/gzXetjEST4 +// patreon: www.patreon.com/curiosityworkshop + + +#ifndef XPLLedStrip_h +#define XPLLedStrip_h + + +#include + + + +// Parameters around the interface + + +#ifndef XPLLEDSTRIP_MAXPIXELS +#define XPLLEDSTRIP_MAXPIXELS 16 //Default to 16. Define this in your main sketch to override +#endif + + +/// @brief Core class for the XPLPro Arduino library +class XPLLedStrip +{ +public: + + XPLLedStrip(void); + + void begin(XPLPro* xplpro, uint16_t inPin); // pin number + void check(inStruct* inData); + void test(void); + int16_t addPixel(dref_handle inHandle, int inElement, uint16_t inNumber, uint8_t inR, uint8_t inG, uint8_t inB); + void writePixel(uint16_t inPixel, float inBrightness); + void check(void); + + void clear(void); + +private: + int16_t _findPixel(dref_handle inHandle, int inElement); + + XPLPro* _XP; + + int16_t _pixelCount; + + Adafruit_NeoPixel _strip; + + struct XPLPixel + { + // uint8_t muxPin; // connected pin + + dref_handle handle; + int element; + uint16_t number; + uint8_t cRed; + uint8_t cGreen; + uint8_t cBlue; + + + }; + + struct XPLPixel _pixels[XPLLEDSTRIP_MAXPIXELS]; + +}; + + +XPLLedStrip::XPLLedStrip(void) +{ + + + +} + +void XPLLedStrip::begin(XPLPro* xplpro, uint16_t inPin) +{ + + + // Parameter 1 = number of pixels in strip + // Parameter 2 = pin number (most are valid) + // Parameter 3 = pixel type flags, add together as needed: + // NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) + // NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) + // NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products) + // NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2) + _strip = Adafruit_NeoPixel(XPLLEDSTRIP_MAXPIXELS, inPin, NEO_GRB + NEO_KHZ800); + _strip.begin(); + _XP = xplpro; + clear(); + +} + +void XPLLedStrip::clear(void) // call this prior to adding pins if not the first run +{ + _pixelCount = 0; + _strip.clear(); + _strip.fill(_strip.Color(0, 0, 0), 0, XPLLEDSTRIP_MAXPIXELS); + _strip.show(); + +} + +void XPLLedStrip::test(void) +{ + _strip.clear(); + + _strip.fill(_strip.Color(200, 0, 0), 0, XPLLEDSTRIP_MAXPIXELS); + _strip.show(); + delay(100); + + _strip.fill(_strip.Color(0, 200, 0), 0, XPLLEDSTRIP_MAXPIXELS); + _strip.show(); + delay(100); + + _strip.fill(_strip.Color(0, 0, 200), 0, XPLLEDSTRIP_MAXPIXELS); + _strip.show(); + delay(100); + + _strip.fill(_strip.Color(0, 0, 0), 0, XPLLEDSTRIP_MAXPIXELS); + _strip.show(); + + +} + +void XPLLedStrip::check(inStruct *inData) +{ + int pixelNum = _findPixel(inData->handle, inData->element); + if (pixelNum >= 0) + switch (inData->type) + { + case xplmType_Int: + case xplmType_IntArray: + if (inData->inLong) writePixel(pixelNum, 1); + else + { + writePixel(pixelNum, 0); + } + + break; + + case xplmType_Float: + case xplmType_FloatArray: + writePixel(pixelNum, inData->inFloat ); + + break; + } + + + + +} + +//strip1.addPixel(drefTemp, 0, 13, 0, 0, 250); +int16_t XPLLedStrip::addPixel(dref_handle inHandle, int inElement, uint16_t inNumber, uint8_t inR, uint8_t inG, uint8_t inB) +{ + if (_pixelCount >= XPLLEDSTRIP_MAXPIXELS) return -1; + + _pixels[_pixelCount].handle = inHandle; + _pixels[_pixelCount].element = inElement; + _pixels[_pixelCount].number = inNumber; + _pixels[_pixelCount].cRed = inR; + _pixels[_pixelCount].cGreen = inG; + _pixels[_pixelCount].cBlue = inB; + + return _pixelCount++; + +} + +void XPLLedStrip::writePixel(uint16_t inPixel, float inBrightness) // brightness is percentage*100 0-100 +{ + + _strip.setPixelColor(_pixels[inPixel].number, + (inBrightness * _pixels[inPixel].cRed) , + (inBrightness * _pixels[inPixel].cGreen) , + (inBrightness * _pixels[inPixel].cBlue) ); + + _strip.show(); + + +} + +int16_t XPLLedStrip::_findPixel(dref_handle inHandle, int inElement) +{ + int16_t i = 0; + while (i < _pixelCount) + { + if (_pixels[i].handle == inHandle && _pixels[i].element == inElement) return i; + i++; + } + + return -1; + +} + +#endif + diff --git a/XPLPro_Arduino/XPLPro/XPLMux4067Switches.h b/XPLPro_Arduino/XPLPro/XPLMux4067Switches.h new file mode 100644 index 0000000..cde8272 --- /dev/null +++ b/XPLPro_Arduino/XPLPro/XPLMux4067Switches.h @@ -0,0 +1,181 @@ +// XPLMux4067Switches.h - Library for 4067 multiplexer +// Created by Curiosity Workshop, Michael Gerlicher, 2024 +// +// To report problems, download updates and examples, suggest enhancements or get technical support, please visit: +// discord: https://discord.gg/gzXetjEST4 +// patreon: www.patreon.com/curiosityworkshop + +// 2024 May 11 update: standardizing type definitions +// 2024 May 7 update: Removed bitmap vector to simplify code. Thanks GioCC! + +#ifndef XPLMux4067Switches_h +#define XPLMux4067Switches_h + +// Parameters around the interface +#define XPLMUX4067_DEBOUNCETIME 50 +#define XPLMUX4067_PRESSED 0 +#define XPLMUX4067_RELEASED 1 + +#define XPLMUX4067_SENDTOHANDLER 0 // Default is to send switch events to the supplied handler. This always occurs regardless. +#define XPLMUX4067_DATAREFWRITE 1 // Update dataref with switch status +#define XPLMUX4067_COMMANDTRIGGER 2 // Trigger command with pressed +#define XPLMUX4067_COMMANDSTARTEND 3 // Start command when pressed, end command when released +#define XPLMUX4067_DATAREFWRITE_INVERT 4 // same as datarefwrite but invert the signal + +/// @brief Core class for the XPLPro Arduino library +class XPLMux4067Switches +{ +public: + /// @brief Constructor + /// @param inPinSig Pin connection for reading + /// @param inPinS0, Pin connection for s0 + /// @param inPinS1, Pin connection for s1 + /// @param inPinS2, Pin connection for s2 + /// @param inPinS3, Pin connection for s3 + /// @param muxHandler, function called when pin activity is detected, or NULL + XPLMux4067Switches(uint8_t inPinSig, uint8_t inPinS0, uint8_t inPinS1, uint8_t inPinS2, uint8_t inPinS3, void (*muxHandler)(uint8_t muxChannel, uint8_t muxValue)); + + void begin(XPLPro* xplpro); + + int8_t addPin(uint8_t inPin, uint8_t inMode, unsigned int inHandle); + + int8_t getHandle(uint8_t inPin); + + + /// @brief Scan mux pins and call handler if any changes are detected. Run regularly + void check(void); + + void clear(void); + +private: + + XPLPro* _XP; + unsigned int _maxSwitches; + unsigned int _switchCount; + + void (*_muxHandler)(uint8_t muxChannel, uint8_t muxValue) = NULL; // this function will be called when activity is detected on the mux + + uint8_t _pinS0; + uint8_t _pinS1; + uint8_t _pinS2; + uint8_t _pinS3; + uint8_t _pinSig; + + struct XPLSwitch + { + uint8_t muxPin; // connected pin + uint8_t prevStatus; // last known status + uint8_t mode; + unsigned int handle; + unsigned long prevTime; // time of last change + + }; + + struct XPLSwitch _switches[16]; + // struct XPLSwitch _switches[]; +}; + + +XPLMux4067Switches::XPLMux4067Switches(uint8_t inPinSig, uint8_t inPinS0, uint8_t inPinS1, uint8_t inPinS2, uint8_t inPinS3, void (*muxHandler)(uint8_t inChannel, uint8_t inValue)) +{ + + _pinSig = inPinSig; pinMode(_pinSig, INPUT_PULLUP); + _pinS0 = inPinS0; pinMode(_pinS0, OUTPUT); digitalWrite(_pinS0, LOW); + _pinS1 = inPinS1; pinMode(_pinS1, OUTPUT); digitalWrite(_pinS1, LOW); + _pinS2 = inPinS2; pinMode(_pinS2, OUTPUT); digitalWrite(_pinS2, LOW); + _pinS3 = inPinS3; pinMode(_pinS3, OUTPUT); digitalWrite(_pinS3, LOW); + + _muxHandler = muxHandler; + // _maxSwitches = inMaxSwitches; + // if (_maxSwitches > 16) _maxSwitches = 16; // max for 4067 mux + _maxSwitches = 16; // my intention is to make this dynamic but it is problematic + //switches = new struct XPLSwitch[ _maxSwitches]; + +}; + +void XPLMux4067Switches::begin(XPLPro* xplpro) +{ + _XP = xplpro; + clear(); + +} + +void XPLMux4067Switches::clear(void) // call this prior to adding pins if not the first run +{ + _switchCount = 0; + +} + +int8_t XPLMux4067Switches::addPin(uint8_t inPin, uint8_t inMode, unsigned int inHandle) +{ + if (_switchCount >= _maxSwitches) return -1; + + _switches[_switchCount].muxPin = inPin; + _switches[_switchCount].mode = inMode; + _switches[_switchCount].handle = inHandle; + _switches[_switchCount].prevStatus = -1; // this will force it to update to the plugin. + + return _switchCount++; + +} + +int8_t XPLMux4067Switches::getHandle(uint8_t inPin) +{ + for (uint8_t i = 0; i < _maxSwitches; i++) if (_switches[i].muxPin == inPin) return _switches[i].handle; + return -1; + +} + + +void XPLMux4067Switches::check(void) +{ + + unsigned long timeNow = millis(); + for (uint8_t i = 0; i < _switchCount; i++) + { + + const byte ch = _switches[i].muxPin; + digitalWrite(_pinS0, ch & 0x01); + digitalWrite(_pinS1, ch & 0x02); + digitalWrite(_pinS2, ch & 0x04); + digitalWrite(_pinS3, ch & 0x08); + + uint8_t pinValue = digitalRead(_pinSig); + + if (pinValue != _switches[i].prevStatus && timeNow - _switches[i].prevTime >= XPLMUX4067_DEBOUNCETIME) + { + _switches[i].prevStatus = pinValue; + _switches[i].prevTime = timeNow; + + switch (_switches[i].mode) + { + + case XPLMUX4067_DATAREFWRITE: + _XP->datarefWrite(_switches[i].handle, pinValue); + break; + + case XPLMUX4067_DATAREFWRITE_INVERT: + _XP->datarefWrite(_switches[i].handle, !pinValue); + break; + + case XPLMUX4067_COMMANDTRIGGER: + if (pinValue == XPLMUX4067_PRESSED) _XP->commandTrigger(_switches[i].handle); + break; + + case XPLMUX4067_COMMANDSTARTEND: + if (pinValue == XPLMUX4067_PRESSED) _XP->commandStart(_switches[i].handle); + if (pinValue == XPLMUX4067_RELEASED) _XP->commandEnd(_switches[i].handle); + break; + + + } + + + if (_muxHandler != NULL) _muxHandler(_switches[i].muxPin, pinValue); + } + + } + +} + +#endif \ No newline at end of file diff --git a/XPLPro_Arduino/XPLPro/XPLMux9685Servos.h b/XPLPro_Arduino/XPLPro/XPLMux9685Servos.h new file mode 100644 index 0000000..be97531 --- /dev/null +++ b/XPLPro_Arduino/XPLPro/XPLMux9685Servos.h @@ -0,0 +1,194 @@ +// XPLMux9685Servos.h - Library for PCA9685 PWM multiplexer +// Created by Curiosity Workshop, Michael Gerlicher, 2024 +// +// To report problems, download updates and examples, suggest enhancements or get technical support, please visit: +// discord: https://discord.gg/gzXetjEST4 +// patreon: www.patreon.com/curiosityworkshop + + +#ifndef XPLMux9685Servos_h +#define XPLMux9685Servos_h + + +#include // This extension relies on the Adafruit PWMServo Driver and Wire libraries so they will need to be installed +#include + +// Parameters around the interface + +// Depending on your servo make, the pulse width min and max may vary, you +// want these to be as small/large as possible without hitting the hard stop +// for max range. You'll have to tweak them as necessary to match the servos you +// have! + +#ifndef XPLMUX9685_MAXSERVOS +#define XPLMUX9685_MAXSERVOS 16 //Default to 16. Define this in your main sketch to override +#endif + +#define XPLMUX9685_SERVOMIN 150 // This is the 'minimum' pulse length count (out of 4096) +#define XPLMUX9685_SERVOMAX 600 // This is the 'maximum' pulse length count (out of 4096) +#define XPLMUX9685_USMIN 600 // This is the rounded 'minimum' microsecond length based on the minimum pulse of 150 +#define XPLMUX9685_USMAX 2400 // This is the rounded 'maximum' microsecond length based on the maximum pulse of 600 +#define XPLMUX9685_SERVO_FREQ 50 // Analog servos run at ~50 Hz updates + +/// @brief Core class for the XPLPro Arduino library +class XPLMux9685Servos +{ +public: + /// @brief Constructor + /// @param inPinSig Pin connection for reading + /// @param inPinS0, Pin connection for s0 + /// @param inPinS1, Pin connection for s1 + /// @param inPinS2, Pin connection for s2 + /// @param inPinS3, Pin connection for s3 + /// @param muxHandler, function called when pin activity is detected, or NULL + XPLMux9685Servos(void); + + void begin(XPLPro* xplpro, uint8_t = 0x40); // 0x40 is the default configuration for the 9685 boards + void check(inStruct* inData); + int8_t addServo(dref_handle inHandle, int inElement, uint8_t inNumber, uint16_t inInitialVal); + void writeServo(uint8_t inServo, uint16_t inValue); + + + + /// @brief Scan mux pins and call handler if any changes are detected. Run regularly + void check(void); + + void clear(void); + +private: + uint8_t _findServo(dref_handle inHandle, int inElement); + + XPLPro* _XP; + + unsigned int _servoCount; + + Adafruit_PWMServoDriver _pwm; + + struct XPLServo + { + // uint8_t muxPin; // connected pin + + dref_handle handle; + int element; + uint8_t number; + uint32_t initialVal; + + unsigned long prevTime; // time of last change + + }; + + struct XPLServo _servos[XPLMUX9685_MAXSERVOS]; + +}; + + +XPLMux9685Servos::XPLMux9685Servos(void) +{ + + + +} + +void XPLMux9685Servos::begin(XPLPro* xplpro, uint8_t inAddress) +{ + + // called this way, it uses the default address 0x40 + _pwm = Adafruit_PWMServoDriver(inAddress); + // you can also call it with a different address you want + //Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x41); + // you can also call it with a different address and I2C interface + //Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x40, Wire); + + _pwm.begin(); + /* + * In theory the internal oscillator (clock) is 25MHz but it really isn't + * that precise. You can 'calibrate' this by tweaking this number until + * you get the PWM update frequency you're expecting! + * The int.osc. for the PCA9685 chip is a range between about 23-27MHz and + * is used for calculating things like writeMicroseconds() + * Analog servos run at ~50 Hz updates, It is importaint to use an + * oscilloscope in setting the int.osc frequency for the I2C PCA9685 chip. + * 1) Attach the oscilloscope to one of the PWM signal pins and ground on + * the I2C PCA9685 chip you are setting the value for. + * 2) Adjust setOscillatorFrequency() until the PWM update frequency is the + * expected value (50Hz for most ESCs) + * Setting the value here is specific to each individual I2C PCA9685 chip and + * affects the calculations for the PWM update frequency. + * Failure to correctly set the int.osc value will cause unexpected PWM results + */ + _pwm.setOscillatorFrequency(27000000); + _pwm.setPWMFreq(XPLMUX9685_SERVO_FREQ); // Analog servos run at ~50 Hz updates + + delay(10); + _XP = xplpro; + clear(); + +} + +void XPLMux9685Servos::clear(void) // call this prior to adding pins if not the first run +{ + _servoCount = 0; + +} + +void XPLMux9685Servos::check(inStruct *inData) +{ + int servoNum = _findServo(inData->handle, inData->element); + if (servoNum >= 0) + switch (inData->type) + { + case xplmType_Int: + case xplmType_IntArray: + writeServo(servoNum, inData->inLong); + break; + + case xplmType_Float: + case xplmType_FloatArray: + writeServo(servoNum, inData->inFloat); + break; + } + + + + +} + +int8_t XPLMux9685Servos::addServo(dref_handle inHandle, int inElement, uint8_t inNumber, uint16_t inInitialVal) +{ + if (_servoCount >= XPLMUX9685_MAXSERVOS) return -1; + + _servos[_servoCount].handle = inHandle; + _servos[_servoCount].element = inElement; + _servos[_servoCount].number = inNumber; + _servos[_servoCount].initialVal = inInitialVal; + + writeServo(inNumber, inInitialVal); + + + return _servoCount++; + +} + +void XPLMux9685Servos::writeServo(uint8_t inServo, uint16_t inMicroSeconds) +{ + _pwm.writeMicroseconds(inServo, inMicroSeconds); + //_pwm.setPWM(inServo, 0, map(inValue, 0, 180, XPLMUX9685_SERVOMIN, XPLMUX9685_SERVOMAX)); + + +} + +uint8_t XPLMux9685Servos::_findServo(dref_handle inHandle, int inElement) +{ + int i = 0; + while (i < _servoCount) + { + if (_servos[i].handle == inHandle && _servos[i].element == inElement) return i; + i++; + } + + return -1; + +} + +#endif + diff --git a/XPLPro_Arduino/XPLPro/XPLPotentiometers.h b/XPLPro_Arduino/XPLPro/XPLPotentiometers.h new file mode 100644 index 0000000..1e0a80e --- /dev/null +++ b/XPLPro_Arduino/XPLPro/XPLPotentiometers.h @@ -0,0 +1,178 @@ +// XPLPotentiometers.h - XPLPro Add-on Library for simple potentiometer connections +// Created by Curiosity Workshop, Michael Gerlicher, 2024 +// +// To report problems, download updates and examples, suggest enhancements or get technical support, please visit: +// discord: https://discord.gg/gzXetjEST4 +// patreon: www.patreon.com/curiosityworkshop + +// 22 March 2024 -- Small bug fix with addpin overload adding pincount twice +// 15 March 2024 -- Added support for dataref arrays + + + +#ifndef XPLPotentiometers_h +#define XPLPotentiometers_h + +// Parameters around the interface +#define XPLPOTS_SENDTOHANDLER 0 // Default is to send switch events to the supplied handler. This always occurs regardless. +#define XPLPOTS_DATAREFWRITE 1 // Update dataref with switch status + +#define XPLPOTS_UPDATERATE 50 // default minimum time between updates in milliseconds + + +#ifndef XPLPOTS_MAXPOTS + #define XPLPOTS_MAXPOTS 10 //Default to 10. +#endif + + +/// @brief Core class for the XPLPro Potentiometers Addon +class XPLPotentiometers +{ +public: + /// @brief Constructor + /// @param potHandler, Function called when pot activity detected, or NULL if not needed + XPLPotentiometers(void (*potHandler)(int pin, float potValue)); + + /// + /// @brief begin + /// + /// + void begin(XPLPro *xplpro); + + int addPin(int inPin, int inMode, int inHandle, int inPrecision, int inLow, int inHigh, int outLow, int outHigh); + int addPin(int inPin, int inMode, int inHandle, int inElement, int inPrecision, int inLow, int inHigh, int outLow, int outHigh); + void setUpdateRate(int inRate); + int getHandle(int inPin); + + + /// @brief Scan pins and call handler if any changes are detected. Run regularly + void check(void); + + void clear(void); + +private: + + XPLPro* _XP; + + int _potCount; // how many are registered + int _updateRate; // in milliseconds + + + void (*_potHandler)(int inSwitchID, float inPotValue) = NULL; // this function will be called when activity is detected on the pot, if not NULL + + + struct XPLPot + { + int arduinoPin; // connected pin + int prevValue; // last known value + int handle; // handle to dataref + int element; // if the dataref is an array, which element + int mode; // what to do with new data + long int prevTime; // time of last change + int precision; // divide by this to reduce data flow + + }; + + struct XPLPot _pots[XPLPOTS_MAXPOTS]; + +}; + + +XPLPotentiometers::XPLPotentiometers(void (*potHandler)(int inPotID, float inValue)) +{ + + _potHandler = potHandler; + _updateRate = XPLPOTS_UPDATERATE; + + +}; + +void XPLPotentiometers::begin(XPLPro* xplpro) +{ + _XP = xplpro; + clear(); + +} + +void XPLPotentiometers::clear(void) // call this prior to adding pins if not the first run +{ + _potCount = 0; + +} + +void XPLPotentiometers::setUpdateRate(int inRate) +{ + _updateRate = inRate; +} + +int XPLPotentiometers::addPin(int inPin, int inMode, int inHandle, int inPrecision, int inLow, int inHigh, int outLow, int outHigh) +{ + return addPin(inPin, inMode, inHandle, -1, inPrecision, inLow, inHigh, outLow, outHigh); + +} + +int XPLPotentiometers::addPin(int inPin, int inMode, int inHandle, int inElement, int inPrecision, int inLow, int inHigh, int outLow, int outHigh) +{ + if (_potCount >= XPLPOTS_MAXPOTS) return -1; + + _pots[_potCount].arduinoPin = inPin; + _pots[_potCount].precision = inPrecision; + _pots[_potCount].mode = inMode; + _pots[_potCount].handle = inHandle; + _pots[_potCount].element = inElement; + _pots[_potCount].prevValue = -1; // This will force update to the plugin + + _XP->setScaling(inHandle, inLow, inHigh, outLow, outHigh); + + return _potCount++; + + +} + +int XPLPotentiometers::getHandle(int inPin) +{ + for (int i = 0; i < XPLPOTS_MAXPOTS; i++) if (_pots[i].arduinoPin == inPin) return _pots[i].handle; + return -1; + +} + + +void XPLPotentiometers::check(void) +{ + + unsigned long timeNow = millis(); + + + for (int i = 0; i < _potCount; i++) + { + int pinValue = analogRead(_pots[i].arduinoPin); + + if (_pots[i].precision) pinValue = ((int)(pinValue / _pots[i].precision) * _pots[i].precision); + + if (pinValue != _pots[i].prevValue && timeNow - _pots[i].prevTime >= XPLPOTS_UPDATERATE) + { + + _pots[i].prevValue = pinValue; + _pots[i].prevTime = timeNow; + + switch (_pots[i].mode) + { + + case XPLPOTS_DATAREFWRITE: + + if (_pots[i].element < 0) _XP->datarefWrite(_pots[i].handle, pinValue); + else _XP->datarefWrite(_pots[i].handle, pinValue, _pots[i].element); + + break; + + + } + + if (_potHandler != NULL) _potHandler(_pots[i].arduinoPin, pinValue); + + } + } + +} + +#endif \ No newline at end of file diff --git a/XPLPro_Arduino/XPLPro.cpp b/XPLPro_Arduino/XPLPro/XPLPro.cpp similarity index 63% rename from XPLPro_Arduino/XPLPro.cpp rename to XPLPro_Arduino/XPLPro/XPLPro.cpp index 4cdea8d..6016d71 100644 --- a/XPLPro_Arduino/XPLPro.cpp +++ b/XPLPro_Arduino/XPLPro/XPLPro.cpp @@ -1,5 +1,5 @@ // XPLPro.cpp -// Created by Curiosity Workshop, Michael Gerlicher, 2023. +// Created by Curiosity Workshop, Michael Gerlicher, 2023-2024. #include "XPLPro.h" XPLPro::XPLPro(Stream *device) @@ -34,7 +34,7 @@ int XPLPro::xloop(void) } // TODO: is a return value necessary? These could also be void like for the datarefs -int XPLPro::commandTrigger(int commandHandle, int triggerCount) +int XPLPro::commandTrigger(cmd_handle commandHandle, int triggerCount) { if (commandHandle < 0) { @@ -45,7 +45,7 @@ int XPLPro::commandTrigger(int commandHandle, int triggerCount) return 0; } -int XPLPro::commandStart(int commandHandle) +int XPLPro::commandStart(cmd_handle commandHandle) { if (commandHandle < 0) { @@ -55,7 +55,7 @@ int XPLPro::commandStart(int commandHandle) return 0; } -int XPLPro::commandEnd(int commandHandle) +int XPLPro::commandEnd(cmd_handle commandHandle) { if (commandHandle < 0) { @@ -64,6 +64,29 @@ int XPLPro::commandEnd(int commandHandle) _sendPacketVoid(XPLCMD_COMMANDEND, commandHandle); return 0; } +void XPLPro::simulateKeyPress(int inKeyType, int inKey) +{ + sprintf(_sendBuffer, "%c%c,%i,%i,i%c", XPL_PACKETHEADER, XPLCMD_SPECIAL, XPLCMD_SPECIAL_SIMKEYPRESS, inKeyType, inKey, XPL_PACKETTRAILER); + _transmitPacket(); +} + +void XPLPro::commandKeyStroke(XPLMCommandKeyID inKey) +{ + sprintf(_sendBuffer, "%c%c,%i,%i%c", XPL_PACKETHEADER, XPLCMD_SPECIAL, XPLCMD_SPECIAL_CMDKEYSTROKE, inKey, XPL_PACKETTRAILER); + _transmitPacket(); +} +void XPLPro::commandButtonPress(XPLMCommandButtonID inButton) +{ + sprintf(_sendBuffer, "%c%c,%i,%i%c", XPL_PACKETHEADER, XPLCMD_SPECIAL, XPLCMD_SPECIAL_CMDBUTTONPRESS, inButton, XPL_PACKETTRAILER); + _transmitPacket(); +} + +void XPLPro::commandButtonRelease(XPLMCommandButtonID inButton) +{ + sprintf(_sendBuffer, "%c%c,%i,%i%c", XPL_PACKETHEADER, XPLCMD_SPECIAL, XPLCMD_SPECIAL_CMDBUTTONRELEASE, inButton, XPL_PACKETTRAILER); + _transmitPacket(); +} + int XPLPro::connectionStatus() { @@ -82,20 +105,32 @@ int XPLPro::sendSpeakMessage(const char *msg) return 1; } -void XPLPro::flightLoopPause(void) // experimental! Do not use! +void XPLPro::dataFlowPause(void) // internal use please +{ + _sendPacketVoid(XPLCMD_DATAFLOWPAUSE, _streamPtr->available()); + +} + +void XPLPro::dataFlowResume(void) { - _sendPacketVoid(XPLCMD_FLIGHTLOOPPAUSE, 0); + _sendPacketVoid(XPLCMD_DATAFLOWRESUME, _streamPtr->available()); +} +int XPLPro::getBufferStatus(void) +{ + return _streamPtr->available(); } -void XPLPro::flightLoopResume(void) +void XPLPro::setDataFlowSpeed(unsigned long inSpeed) { - _sendPacketVoid(XPLCMD_FLIGHTLOOPRESUME, 0); + sprintf(_sendBuffer, "%c%c,%ld%c", XPL_PACKETHEADER, XPLCMD_SETDATAFLOWSPEED, inSpeed, XPL_PACKETTRAILER); + _transmitPacket(); } + // these could be done better: -void XPLPro::datarefWrite(int handle, int value) +void XPLPro::datarefWrite(dref_handle handle, int value) { if (handle < 0) { @@ -105,7 +140,7 @@ void XPLPro::datarefWrite(int handle, int value) _transmitPacket(); } -void XPLPro::datarefWrite(int handle, int value, int arrayElement) +void XPLPro::datarefWrite(dref_handle handle, int value, int arrayElement) { if (handle < 0) { @@ -115,7 +150,7 @@ void XPLPro::datarefWrite(int handle, int value, int arrayElement) _transmitPacket(); } -void XPLPro::datarefWrite(int handle, long value) +void XPLPro::datarefWrite(dref_handle handle, long value) { if (handle < 0) { @@ -125,7 +160,7 @@ void XPLPro::datarefWrite(int handle, long value) _transmitPacket(); } -void XPLPro::datarefWrite(int handle, long value, int arrayElement) +void XPLPro::datarefWrite(dref_handle handle, long value, int arrayElement) { if (handle < 0) { @@ -135,38 +170,43 @@ void XPLPro::datarefWrite(int handle, long value, int arrayElement) _transmitPacket(); } -void XPLPro::datarefWrite(int handle, float value) +void XPLPro::datarefWrite(dref_handle handle, float value) { - if (handle < 0) - { - return; - } - char tBuf[20]; // todo: rewrite to eliminate this buffer. Write directly to _sendBuffer - dtostrf(value, 0, XPL_FLOATPRECISION, tBuf); - sprintf(_sendBuffer, "%c%c,%i,%s%c", - XPL_PACKETHEADER, - XPLCMD_DATAREFUPDATEFLOAT, - handle, - tBuf, - XPL_PACKETTRAILER); + if (handle < 0) return; + + char* s = _sendBuffer; + s += sprintf(_sendBuffer, "%c%c,%i,", + XPL_PACKETHEADER, + XPLCMD_DATAREFUPDATEFLOAT, + handle); + s += Xdtostrf(value, 0, XPL_FLOATPRECISION, s); + sprintf(s, "%c", + XPL_PACKETTRAILER); _transmitPacket(); } -void XPLPro::datarefWrite(int handle, float value, int arrayElement) +void XPLPro::datarefWrite(dref_handle handle, float value, int arrayElement) { - if (handle < 0) - { - return; - } - char tBuf[20]; // todo: rewrite to eliminate this buffer. Write directly to _sendBuffer - dtostrf(value, 0, XPL_FLOATPRECISION, tBuf); - sprintf(_sendBuffer, "%c%c,%i,%s,%i%c", - XPL_PACKETHEADER, - XPLCMD_DATAREFUPDATEFLOATARRAY, - handle, - tBuf, - arrayElement, - XPL_PACKETTRAILER); + if (handle < 0) return; + + char* s = _sendBuffer; + s += sprintf(_sendBuffer, "%c%c,%i,", + XPL_PACKETHEADER, + XPLCMD_DATAREFUPDATEFLOATARRAY, + handle); + s += Xdtostrf(value, 0, XPL_FLOATPRECISION, s); + sprintf(s, ",%i%c", + arrayElement, + XPL_PACKETTRAILER); + + _transmitPacket(); +} + +void XPLPro::datarefTouch(dref_handle handle) +{ + if (handle < 0) return; + + sprintf(_sendBuffer, "%c%c,%i%c", XPL_PACKETHEADER, XPLREQUEST_DATAREFTOUCH, handle, XPL_PACKETTRAILER); _transmitPacket(); } @@ -179,6 +219,17 @@ void XPLPro::_sendname() } } +void XPLPro::_sendVersion() +{ + // register device on request only when we have a valid name + if (_deviceName != NULL) + { + char version[25]; + sprintf(version, "%s %s", __DATE__, __TIME__); + _sendPacketString(XPLRESPONSE_VERSION, version); + } +} + void XPLPro::sendResetRequest() { // request a reset only when we have a valid name @@ -212,9 +263,17 @@ void XPLPro::_processSerial() _receiveBuffer[++_receiveBufferBytesReceived] = XPL_PACKETTRAILER; _receiveBuffer[++_receiveBufferBytesReceived] = 0; // old habits die hard. // at this point we should have a valid frame + _processPacket(); } +int XPLPro::_receiveNSerial(int inSize) +{ + if (inSize > XPLMAX_PACKETSIZE_RECEIVE) inSize = XPLMAX_PACKETSIZE_RECEIVE; + + return Serial.readBytes(_receiveBuffer, inSize); +} + void XPLPro::_processPacket() { @@ -223,7 +282,7 @@ void XPLPro::_processPacket() { return; } - // branch on receiverd command + // branch on received command switch (_receiveBuffer[1]) { // plane unloaded or XP exiting @@ -234,9 +293,11 @@ void XPLPro::_processPacket() // register device case XPLCMD_SENDNAME: + _sendVersion(); _sendname(); _connectionStatus = true; // not considered active till you know my name _registerFlag = 0; + break; // plugin is ready for registrations. @@ -258,6 +319,7 @@ void XPLPro::_processPacket() case XPLCMD_DATAREFUPDATEINT: _parseInt(&_inData.handle, _receiveBuffer, 2); _parseInt(&_inData.inLong, _receiveBuffer, 3); + _inData.type = xplmType_Int; _inData.inFloat = 0; _inData.element = 0; _xplInboundHandler(&_inData); @@ -268,6 +330,7 @@ void XPLPro::_processPacket() _parseInt(&_inData.handle, _receiveBuffer, 2); _parseInt(&_inData.inLong, _receiveBuffer, 3); _parseInt(&_inData.element, _receiveBuffer, 4); + _inData.type = xplmType_IntArray; _inData.inFloat = 0; _xplInboundHandler(&_inData); break; @@ -276,6 +339,7 @@ void XPLPro::_processPacket() case XPLCMD_DATAREFUPDATEFLOAT: _parseInt(&_inData.handle, _receiveBuffer, 2); _parseFloat(&_inData.inFloat, _receiveBuffer, 3); + _inData.type = xplmType_Float; _inData.inLong = 0; _inData.element = 0; _xplInboundHandler(&_inData); @@ -286,13 +350,22 @@ void XPLPro::_processPacket() _parseInt(&_inData.handle, _receiveBuffer, 2); _parseFloat(&_inData.inFloat, _receiveBuffer, 3); _parseInt(&_inData.element, _receiveBuffer, 4); + _inData.type = xplmType_FloatArray; _inData.inLong = 0; _xplInboundHandler(&_inData); break; - // Todo: Still need to deal with inbound strings - // Todo: implement type within struct - + case XPLCMD_DATAREFUPDATESTRING: + _parseInt(&_inData.handle, _receiveBuffer, 2); + _parseInt(&_inData.strLength, _receiveBuffer, 3); + _receiveNSerial(_inData.strLength); + _inData.type = xplmType_Data; + _inData.inStr = _receiveBuffer; + // dataFlowPause(); // 2024 May 23: Pause inbound data while we process + _xplInboundHandler(&_inData); + // dataFlowResume(); // 2024 May 23: Resume inbound data flow + break; + // obsolete? reserve for the time being... // case XPLREQUEST_REFRESH: @@ -316,6 +389,12 @@ void XPLPro::_sendPacketVoid(int command, int handle) // just a command with a h _transmitPacket(); } +void XPLPro::_sendPacketVoid(int command) // Update 2024 May 23: just a command +{ + sprintf(_sendBuffer, "%c%c%c", XPL_PACKETHEADER, command, XPL_PACKETTRAILER); + _transmitPacket(); +} + void XPLPro::_sendPacketString(int command, const char *str) // for a string { sprintf(_sendBuffer, "%c%c,\"%s\"%c", XPL_PACKETHEADER, command, str, XPL_PACKETTRAILER); @@ -325,11 +404,12 @@ void XPLPro::_sendPacketString(int command, const char *str) // for a string void XPLPro::_transmitPacket(void) { _streamPtr->write(_sendBuffer); - if (strlen(_sendBuffer) == 64) + if (strlen(_sendBuffer) == 64) // ToDo: This could be more efficient with sprintf returns instead of measuring the buffer each time... { // apparently a bug in arduino with some boards when we transmit exactly 64 bytes. That took a while to track down... _streamPtr->print(" "); } + _streamPtr->flush(); } int XPLPro::_parseString(char *outBuffer, char *inBuffer, int parameter, int maxSize)// todo: Confirm 0 length strings ("") dont cause issues @@ -364,7 +444,7 @@ int XPLPro::_parseString(char *outBuffer, char *inBuffer, int parameter, int max } strncpy(outBuffer, (char *)&inBuffer[cBeg], len); outBuffer[len] = 0; - // fprintf(errlog, "_parseString, pos: %i, cBeg: %i, deviceName: %s\n", pos, cBeg, target); + return 0; } @@ -417,7 +497,7 @@ int XPLPro::_parseInt(long *outTarget, char *inBuffer, int parameter) } char holdChar = inBuffer[pos]; inBuffer[pos] = 0; - *outTarget = atoi((char *)&inBuffer[cBeg]); + *outTarget = atol((char *)&inBuffer[cBeg]); inBuffer[pos] = holdChar; return 0; } @@ -455,6 +535,9 @@ int XPLPro::registerDataRef(XPString_t *datarefName) { return XPL_HANDLE_INVALID; } + + // while (getBufferStatus) _processSerial(); + #if XPL_USE_PROGMEM sprintf(_sendBuffer, "%c%c,\"%S\"%c", XPL_PACKETHEADER, XPLREQUEST_REGISTERDATAREF, (wchar_t *)datarefName, XPL_PACKETTRAILER); #else @@ -490,36 +573,80 @@ int XPLPro::registerCommand(XPString_t *commandName) void XPLPro::requestUpdates(int handle, int rate, float precision) { - char tBuf[20]; // todo: rewrite to eliminate this buffer. Write directly to _sendBuffer? - dtostrf(precision, 0, XPL_FLOATPRECISION, tBuf); - sprintf(_sendBuffer, "%c%c,%i,%i,%s%c", - XPL_PACKETHEADER, - XPLREQUEST_UPDATES, - handle, - rate, - tBuf, - XPL_PACKETTRAILER); + if (handle < 0) return; + + char* s = _sendBuffer; + s += sprintf(_sendBuffer, "%c%c,%i,%i,", + XPL_PACKETHEADER, + XPLREQUEST_UPDATES, + handle, + rate); + s += Xdtostrf(precision, 0, XPL_FLOATPRECISION, s); + sprintf(s, "%c", + XPL_PACKETTRAILER); _transmitPacket(); } -void XPLPro::requestUpdates(int handle, int rate, float precision, int element) +void XPLPro::requestUpdates(int handle, int rate, float precision, int arrayElement) { - char tBuf[20]; // todo: rewrite to eliminate this buffer. Write directly to _sendBuffer? - dtostrf(precision, 0, XPL_FLOATPRECISION, tBuf); - sprintf(_sendBuffer, "%c%c,%i,%i,%s,%i%c", - XPL_PACKETHEADER, - XPLREQUEST_UPDATESARRAY, - handle, - rate, - tBuf, - element, - XPL_PACKETTRAILER); + if (handle < 0) return; + + char* s = _sendBuffer; + s += sprintf(_sendBuffer, "%c%c,%i,%i,", + XPL_PACKETHEADER, + XPLREQUEST_UPDATESARRAY, + handle, + rate); + s += Xdtostrf(precision, 0, XPL_FLOATPRECISION, s); + sprintf(s, ",%i%c", + arrayElement, + XPL_PACKETTRAILER); + + _transmitPacket(); +} + + +void XPLPro::requestUpdatesType(int handle, int type, int rate, float precision) +{ + if (handle < 0) return; + + char* s = _sendBuffer; + s += sprintf(_sendBuffer, "%c%c,%i,%i,%i,", + XPL_PACKETHEADER, + XPLREQUEST_UPDATES_TYPE, + handle, + type, + rate); + s += Xdtostrf(precision, 0, XPL_FLOATPRECISION, s); + sprintf(s, "%c", + XPL_PACKETTRAILER); _transmitPacket(); } -void XPLPro::setScaling(int handle, int inLow, int inHigh, int outLow, int outHigh) +void XPLPro::requestUpdatesType(int handle, int type, int rate, float precision, int arrayElement) { - sprintf(_sendBuffer, "%c%c,%i,%i,%i,%i,%i%c", + if (handle < 0) return; + + char* s = _sendBuffer; + s += sprintf(_sendBuffer, "%c%c,%i,%i,%i", + XPL_PACKETHEADER, + XPLREQUEST_UPDATES_TYPE_ARRAY, + handle, + type, + rate); + s += Xdtostrf(precision, 0, XPL_FLOATPRECISION, s); + sprintf(s, ",%i%c", + arrayElement, + XPL_PACKETTRAILER); + + _transmitPacket(); +} + + + +void XPLPro::setScaling(int handle, long int inLow, long int inHigh, long int outLow, long int outHigh) // Currently only active for OUTBOUND (from arduino) data +{ + sprintf(_sendBuffer, "%c%c,%i,%li,%li,%li,%li%c", XPL_PACKETHEADER, XPLREQUEST_SCALING, handle, @@ -530,3 +657,17 @@ void XPLPro::setScaling(int handle, int inLow, int inHigh, int outLow, int outHi XPL_PACKETTRAILER); _transmitPacket(); } + +// Re-creation of dtostrf for non-AVR boards +// Returns: number of chars added after ('\0' not included) +int XPLPro::Xdtostrf(double val, signed char width, unsigned char prec, char* sout) +{ +#ifdef __AVR_ARCH__ + dtostrf(val, width, prec, sout); + return strlen(sout); +#else + char fmt[20]; + sprintf(fmt, "%%%d.%df", width, prec); + return sprintf(sout, fmt, val); +#endif +} diff --git a/XPLPro_Arduino/XPLPro.h b/XPLPro_Arduino/XPLPro/XPLPro.h similarity index 62% rename from XPLPro_Arduino/XPLPro.h rename to XPLPro_Arduino/XPLPro/XPLPro.h index 1452847..48f8162 100644 --- a/XPLPro_Arduino/XPLPro.h +++ b/XPLPro_Arduino/XPLPro/XPLPro.h @@ -37,7 +37,7 @@ #else // and off otherwise #define XPL_USE_PROGMEM 0 -#include // this is needed for non-AVR boards to include the dtostrf function +//#include // this is needed for non-AVR boards to include the dtostrf function #endif #endif @@ -45,7 +45,7 @@ // Package buffer size for send and receive buffer each. // If you need a few extra bytes of RAM it could be reduced, but it needs to // be as long as the longest dataref name + 10. If you are using datarefs -// that transfer strings it needs to be big enough for those too. (default 200) +// that transfer strings it needs to be big enough for those too. (default 200, should be less than 256) #ifndef XPLMAX_PACKETSIZE_TRANSMIT #define XPLMAX_PACKETSIZE_TRANSMIT 200 #endif @@ -67,6 +67,11 @@ typedef const __FlashStringHelper XPString_t; typedef const char XPString_t; #endif +typedef int dref_handle; +typedef int cmd_handle; +typedef int XPLMCommandKeyID; +typedef int XPLMCommandButtonID; + // Parameters around the interface #define XPL_BAUDRATE 115200 // Baudrate needed to match plugin #define XPL_RX_TIMEOUT 500 // Timeout for reception of one frame @@ -77,20 +82,43 @@ typedef const char XPString_t; // Items in caps generally come from XPlane. Items in lower case are generally sent from the arduino. #define XPLCMD_SENDNAME 'N' // plugin request name from arduino #define XPLRESPONSE_NAME 'n' // Arduino responds with device name as initialized in the "begin" function +#define XPLRESPONSE_VERSION 'v' // Arduino responds with build date and time (when sketch was compiled) #define XPLCMD_SENDREQUEST 'Q' // plugin sends this when it is ready to register bindings -#define XPLCMD_FLIGHTLOOPPAUSE 'p' // stop flight loop while we register -#define XPLCMD_FLIGHTLOOPRESUME 'q' // +#define XPLCMD_DATAFLOWPAUSE 'p' // pause dataflow from plugin +#define XPLCMD_DATAFLOWRESUME 'q' // +#define XPLCMD_SETDATAFLOWSPEED 'f' // 07/09/2024: Set maximum number of bytes to send per second. #define XPLREQUEST_REGISTERDATAREF 'b' // Register a dataref #define XPLREQUEST_REGISTERCOMMAND 'm' // Register a command #define XPLRESPONSE_DATAREF 'D' // Plugin responds with handle to dataref or - value if not found. dataref handle, dataref name #define XPLRESPONSE_COMMAND 'C' // Plugin responds with handle to command or - value if not found. command handle, command name #define XPLCMD_PRINTDEBUG 'g' // Plugin logs string sent from arduino #define XPLCMD_SPEAK 's' // plugin speaks string through xplane speech -//#define XPLREQUEST_REFRESH 'd' // the plugin will call this once xplane is loaded in order to get fresh updates from arduino handles that write (reserve until we are sure it is unneeded) +#define XPLREQUEST_DATAREFTOUCH 'd' // 05/16/2024 update: force an update to specified dataref. EXPERIMENTAL and possibly redundant #define XPLREQUEST_UPDATES 'r' // arduino is asking the plugin to update the specified dataref with rate and divider parameters #define XPLREQUEST_UPDATESARRAY 't' // arduino is asking the plugin to update the specified array dataref with rate and divider parameters +#define XPLREQUEST_UPDATES_TYPE 'y' // 3/25/2024 update: some datarefs (looking at you Zibo...) return multiple data types, We can force which one to receive here. +#define XPLREQUEST_UPDATES_TYPE_ARRAY 'w' +#define XPLCMD_SPECIAL '$' // 06/02/2024: Special commands that are useful but xplane considers deprecated. Turns out they really are deprecated! +#define XPLCMD_SPECIAL_SIMKEYPRESS 1 // Simulate key press, parameters are inKeyType, inKey as defined with xplane +#define XPLCMD_SPECIAL_CMDKEYSTROKE 2 // Command Keystroke, parameter is XPLMCommandKeyID inKey +#define XPLCMD_SPECIAL_CMDBUTTONPRESS 3 // Command Button Press, parameter isXPLMCommandButtonID inButton +#define XPLCMD_SPECIAL_CMDBUTTONRELEASE 4 // Command Button Release, parameter isXPLMCommandButtonID inButton + // Be sure to close all button presses with button releases! + + +// these are the data types for the above requests that we can send. These values come directly from the Xplane SDK. The Dataref needs to support the type of data +// that we are requesting here, refer to the documentation for the dataref. The XPLDirectError.log also reports the type of data each registered dataref +// returns, if that is helpful. + #define xplmType_Unknown 0 // Data of a type the current XPLM doesn't do. + #define xplmType_Int 1 // A single 4 - byte integer, native endian. + #define xplmType_Float 2 // A single 4 - //byte float, native endian. + #define xplmType_Double 4 // A single 8 - byte double, native endian. + #define xplmType_FloatArray 8 // An array of 4 - byte floats, native endian. + #define xplmType_IntArray 16 // An array of 4 - byte integers, native endian. + #define xplmType_Data 32 // A variable block of data. + #define XPLREQUEST_SCALING 'u' // arduino requests the plugin apply scaling to the dataref values -#define XPLREQUEST_DATAREFVALUE 'e' // one off request for a dataref value. Avoid doing this every loop, better to use REQUEST_UPDATES. Either way, value will be sent via the inbound callback +//#define XPLREQUEST_DATAREFVALUE 'e' // one off request for a dataref value. Avoid doing this every loop, better to use REQUEST_UPDATES. Either way, value will be sent via the inbound callback #define XPLCMD_RESET 'z' // Request a reset and reregistration from the plugin #define XPLCMD_DATAREFUPDATEINT '1' // Int DataRef update #define XPLCMD_DATAREFUPDATEFLOAT '2' // Float DataRef update @@ -104,11 +132,12 @@ typedef const char XPString_t; struct inStruct // potentially 'class' { - int handle; + dref_handle handle; int type; int element; long inLong; float inFloat; + int strLength; // if string data, length of string data char* inStr; }; @@ -134,72 +163,96 @@ class XPLPro /// @brief Trigger a command once /// @param commandHandle of the command to trigger /// @return 0: OK, -1: command was not registered - int commandTrigger(int commandHandle) { return commandTrigger(commandHandle, 1); }; + int commandTrigger(cmd_handle commandHandle) { return commandTrigger(commandHandle, 1); }; /// @brief Trigger a command multiple times /// @param commandHandle Handle of the command to trigger /// @param triggerCount Number of times to trigger the command /// @return 0: OK, -1: command was not registered - int commandTrigger(int commandHandle, int triggerCount); + int commandTrigger(cmd_handle commandHandle, int triggerCount); /// @brief Start a command. All commandStart must be balanced with a commandEnd /// @param commandHandle Handle of the command to start /// @return 0: OK, -1: command was not registered - int commandStart(int commandHandle); + int commandStart(cmd_handle commandHandle); /// @brief End a command. All commandStart must be balanced with a commandEnd /// @param commandHandle Handle of the command to start /// @return 0: OK, -1: command was not registered - int commandEnd(int commandHandle); + int commandEnd(cmd_handle commandHandle); + + void simulateKeyPress(int inKeyType, int inKey); + void commandKeyStroke(XPLMCommandKeyID inKey); + void commandButtonPress(XPLMCommandButtonID inButton); + void commandButtonRelease(XPLMCommandButtonID inButton); /// @brief Write an integer DataRef. /// @param handle Handle of the DataRef to write /// @param value Value to write to the DataRef - void datarefWrite(int handle, long value); + void datarefWrite(dref_handle handle, long value); /// @brief Write an integer DataRef. Maps to long DataRefs. /// @param handle Handle of the DataRef to write /// @param value Value to write to the DataRef - void datarefWrite(int handle, int value); + void datarefWrite(dref_handle handle, int value); /// @brief Write a Integer DataRef to an array element. /// @param handle Handle of the DataRef to write /// @param value Value to write to the DataRef /// @param arrayElement Array element to write to - void datarefWrite(int handle, long value, int arrayElement); + void datarefWrite(dref_handle handle, long value, int arrayElement); /// @brief Write a Integer DataRef to an array element. Maps to long DataRefs. /// @param handle Handle of the DataRef to write /// @param value Value to write to the DataRef /// @param arrayElement Array element to write to - void datarefWrite(int handle, int value, int arrayElement); + void datarefWrite(dref_handle handle, int value, int arrayElement); /// @brief Write a float DataRef. /// @param handle Handle of the DataRef to write /// @param value Value to write to the DataRef - void datarefWrite(int handle, float value); + void datarefWrite(dref_handle handle, float value); /// @brief Write a float DataRef to an array element. /// @param handle Handle of the DataRef to write /// @param value Value to write to the DataRef /// @param arrayElement Array element to write to - void datarefWrite(int handle, float value, int arrayElement); + void datarefWrite(dref_handle handle, float value, int arrayElement); + + /// @brief Force plugin to update dataref value. Experimental and probably redundant, use sparingly! + /// @param handle Handle of the DataRef to write + void datarefTouch(dref_handle handle); + + /// @brief Request DataRef updates from the plugin + /// @param handle Handle of the DataRef to subscribe to + /// @param rate Maximum rate for updates to reduce traffic + /// @param precision Floating point precision + void requestUpdates(dref_handle handle, int rate, float precision); + + /// @brief Request DataRef updates from the plugin for an array DataRef + /// @param handle Handle of the DataRef to subscribe to + /// @param rate Maximum rate for updates to reduce traffic + /// @param precision Floating point precision + /// @param arrayElement Array element to subscribe to + void requestUpdates(dref_handle handle, int rate, float precision, int arrayElement); /// @brief Request DataRef updates from the plugin /// @param handle Handle of the DataRef to subscribe to + /// @param type Specific type of data to request, see header file /// @param rate Maximum rate for updates to reduce traffic /// @param precision Floating point precision - void requestUpdates(int handle, int rate, float precision); + void requestUpdatesType(dref_handle handle, int type, int rate, float precision); /// @brief Request DataRef updates from the plugin for an array DataRef /// @param handle Handle of the DataRef to subscribe to + /// @param type Specific type of data to request, see header file /// @param rate Maximum rate for updates to reduce traffic /// @param precision Floating point precision /// @param arrayElement Array element to subscribe to - void requestUpdates(int handle, int rate, float precision, int arrayElement); + void requestUpdatesType(dref_handle handle, int type, int rate, float precision, int arrayElement); /// @brief set scaling factor for a DataRef (offload mapping to the plugin) - void setScaling(int handle, int inLow, int inHigh, int outLow, int outHigh); + void setScaling(dref_handle handle, long int inLow, long int inHigh, long int outLow, long int outHigh); /// @brief Register a DataRef and obtain a handle /// @param datarefName Name of the DataRef (or abbreviation) @@ -225,8 +278,10 @@ class XPLPro /// @brief Request a reset from the plugin void sendResetRequest(void); - void flightLoopPause(void); - void flightLoopResume(void); + void dataFlowPause(void); // Tell plugin to pause flow of data to device + void dataFlowResume(void); // resume + void setDataFlowSpeed(unsigned long); // request speed throttling on data in bytes per second. Understand that a full packet will always be sent but the throttling occurs between packets. + int getBufferStatus(void); // returns number of bytes in receive buffer /// @brief Cyclic loop handler, must be called in idle task /// @return Connection status @@ -236,31 +291,35 @@ class XPLPro private: void _processSerial(); + int _receiveNSerial(int inSize); void _processPacket(); void _transmitPacket(); void _sendname(); - void _sendPacketVoid(int command, int handle); // just a command with a handle - void _sendPacketString(int command, const char *str); // send a string + void _sendVersion(); + void _sendPacketVoid(int command, int handle); // just a command with a handle + void _sendPacketVoid(int command); // Update 2024 May 23: just a command + void _sendPacketString(int command, const char *str); // send a string int _parseInt(int *outTarget, char *inBuffer, int parameter); int _parseInt(long *outTarget, char *inBuffer, int parameter); int _parseFloat(float *outTarget, char *inBuffer, int parameter); int _parseString(char *outBuffer, char *inBuffer, int parameter, int maxSize); + int Xdtostrf(double val, signed char width, unsigned char prec, char* sout); Stream *_streamPtr; const char *_deviceName; - byte _registerFlag; - byte _connectionStatus; + bool _registerFlag; + bool _connectionStatus; inStruct _inData; char _sendBuffer[XPLMAX_PACKETSIZE_TRANSMIT]; char _receiveBuffer[XPLMAX_PACKETSIZE_RECEIVE]; - int _receiveBufferBytesReceived; + uint8_t _receiveBufferBytesReceived; void (*_xplInitFunction)(void); // this function will be called when the plugin is ready to receive binding requests void (*_xplStopFunction)(void); // this function will be called with the plugin receives message or detects xplane flight model inactive void (*_xplInboundHandler)(inStruct *); // this function will be called when the plugin sends dataref values - int _handleAssignment; + dref_handle _handleAssignment; }; diff --git a/XPLPro_Arduino/XPLPro/XPLProManual.odt b/XPLPro_Arduino/XPLPro/XPLProManual.odt new file mode 100644 index 0000000..f60870f Binary files /dev/null and b/XPLPro_Arduino/XPLPro/XPLProManual.odt differ diff --git a/XPLPro_Arduino/XPLPro/XPLRotarySwitch.h b/XPLPro_Arduino/XPLPro/XPLRotarySwitch.h new file mode 100644 index 0000000..033610b --- /dev/null +++ b/XPLPro_Arduino/XPLPro/XPLRotarySwitch.h @@ -0,0 +1,176 @@ +// XPLRotarySwitch.h - XPLPro Add-on Library for rotary switch connections +// Created by Curiosity Workshop, Michael Gerlicher, 2024 +// +// To report problems, download updates and examples, suggest enhancements or get technical support, please visit: +// discord: https://discord.gg/gzXetjEST4 +// patreon: www.patreon.com/curiosityworkshop + +#ifndef XPLRotarySwitch_h +#define XPLRotarySwitch_h + +// Parameters around the interface + +#define XPLSWITCHES_DEBOUNCETIME 50 +#define XPLSWITCHES_PRESSED 0 +#define XPLSWITCHES_RELEASED 1 + +#ifndef XPLROTARYSWITCH_MAXPINS +#define XPLROTARYSWITCH_MAXPINS 6 //Default to 6. +#endif + + +/// @brief Core class for the XPLPro Switches Addon +class XPLRotarySwitch +{ +public: + /// @brief Constructor + /// @param switchHandler, Function called when pin activity is detected, or NULL if not needed + XPLRotarySwitch(void (*switchHandler)(int pin, int switchValue)); + + /// + /// @brief begin + /// + /// + void begin(XPLPro* xplpro); + + + + int addPin(int inPin, int inValue, int inHandle); + int addPin(int inPin, int inValue, int inHandle, int inElement); + + int getHandle(int inPin); + + + /// @brief Scan pins and call handler if any changes are detected. Run regularly + void check(void); + + void clear(void); + +private: + + XPLPro* _XP; + + int _switchCount; // how many are registered + + + void (*_switchHandler)(int inSwitchID, int inSwitchValue) = NULL; // this function will be called when activity is detected on the mux, if not NULL + + + struct XPLSwitch + { + int arduinoPin; // connected pin + byte prevStatus; // last known status + byte mode; + int handle; + int element; + long int prevTime; // time of last change + + }; + + struct XPLSwitch _switches[XPLSWITCHES_MAXSWITCHES]; + +}; + + +XPLSwitches::XPLSwitches(void (*switchHandler)(int inSwitchID, int inValue)) +{ + + + _switchHandler = switchHandler; + + +}; + +void XPLSwitches::begin(XPLPro* xplpro) +{ + _XP = xplpro; + clear(); + +} + +void XPLSwitches::clear(void) // call this prior to adding pins if not the first run +{ + _switchCount = 0; + +} + +int XPLSwitches::addPin(int inPin, byte inMode, int inHandle) +{ + + + return addPin(inPin, inMode, inHandle, 0); + + +} + +int XPLSwitches::addPin(int inPin, byte inMode, int inHandle, int inElement) +{ + if (_switchCount >= XPLSWITCHES_MAXSWITCHES) return -1; + + _switches[_switchCount].arduinoPin = inPin; + _switches[_switchCount].mode = inMode; + _switches[_switchCount].handle = inHandle; + _switches[_switchCount].element = inElement; + _switches[_switchCount].prevStatus = -1; // This will force update to the plugin + pinMode(inPin, INPUT_PULLUP); + + return _switchCount++; + + +} + +int XPLSwitches::getHandle(int inPin) +{ + for (int i = 0; i < XPLSWITCHES_MAXSWITCHES; i++) if (_switches[i].arduinoPin == inPin) return _switches[i].handle; + return -1; + +} + + +void XPLSwitches::check(void) +{ + + unsigned long timeNow = millis(); + + + for (int i = 0; i < _switchCount; i++) + { + int pinValue = digitalRead(_switches[i].arduinoPin); + + if (pinValue != _switches[i].prevStatus && timeNow - _switches[i].prevTime >= XPLSWITCHES_DEBOUNCETIME) + { + + _switches[i].prevStatus = pinValue; + _switches[i].prevTime = timeNow; + + switch (_switches[i].mode) + { + + case XPLSWITCHES_DATAREFWRITE: + _XP->datarefWrite(_switches[i].handle, pinValue, _switches[i].element); + break; + + case XPLSWITCHES_DATAREFWRITE_INVERT: + _XP->datarefWrite(_switches[i].handle, !pinValue, _switches[i].element); + break; + + case XPLSWITCHES_COMMANDTRIGGER: + if (pinValue == XPLSWITCHES_PRESSED) _XP->commandTrigger(_switches[i].handle); + break; + + case XPLSWITCHES_COMMANDSTARTEND: + if (pinValue == XPLSWITCHES_PRESSED) _XP->commandStart(_switches[i].handle); + if (pinValue == XPLSWITCHES_RELEASED) _XP->commandEnd(_switches[i].handle); + break; + + + } + + if (_switchHandler != NULL) _switchHandler(_switches[i].arduinoPin, pinValue); + + } + } + +} + +#endif \ No newline at end of file diff --git a/XPLPro_Arduino/XPLPro/XPLSequencer.h b/XPLPro_Arduino/XPLPro/XPLSequencer.h new file mode 100644 index 0000000..17ad0c2 --- /dev/null +++ b/XPLPro_Arduino/XPLPro/XPLSequencer.h @@ -0,0 +1,118 @@ +// XPLSequencer.h - XPLPro Add-on Library for event sequencing +// Created by Curiosity Workshop, Michael Gerlicher, 2024 +// +// To report problems, download updates and examples, suggest enhancements or get technical support, please visit: +// discord: https://discord.gg/gzXetjEST4 +// patreon: www.patreon.com/curiosityworkshop +// facebook: https://www.facebook.com/curiosity.workshop42 + +// 23 March 2024 -- Fixed bug where the first event would occur immediately rather than at its scheduled time +// 22 March 2024 -- Initial release + + +#ifndef XPLSequencer_h +#define XPLSequencer_h + + +#ifndef XPLSEQUENCER_MAXEVENTS + #define XPLSEQUENCER_MAXEVENTS 10 // Max amount of events to allow. Default to 10. +#endif + + +/// @brief Core class for the XPLPro Potentiometers Addon +class XPLSequencer +{ +public: + /// @brief Constructor + /// @param potHandler, Function called when pot activity detected, or NULL if not needed + XPLSequencer(void (*eventHandler)(int id)); + + /// + /// @brief begin + /// + /// + void begin(void); + + int addEvent(unsigned long inTime); + + /// @brief Scan pins and call handler if any changes are detected. Run regularly + void check(unsigned long inTimeNow); + void trigger(void); + + void clear(void); + +private: + + + int _eventCount; // how many are registered + int _sequenceCounter; // where are we in the sequence or -1 if not active + unsigned long _previousEventTime; + + + void (*_eventHandler)(int inItem) = NULL; // this function will be called when events are triggered. + + + struct XPLEvents + { + + unsigned long timeSchedule; // when this event will occur after the previous event in the sequence (ms) + + }; + + struct XPLEvents _events[XPLSEQUENCER_MAXEVENTS]; + +}; + + +XPLSequencer::XPLSequencer(void (*eventHandler)(int id)) +{ + + _eventHandler = eventHandler; + _sequenceCounter = -1; // start off inactive + +}; + + +void XPLSequencer::clear(void) +{ + _eventCount = 0; + +} + + +int XPLSequencer::addEvent(unsigned long inTime) +{ + + if (_eventCount >= XPLSEQUENCER_MAXEVENTS) return -1; + + _events[_eventCount].timeSchedule = inTime; + return _eventCount++; +} + + +void XPLSequencer::check(unsigned long inTimeNow) +{ + + if (_sequenceCounter == -1) return; + + if (inTimeNow - _previousEventTime < _events[_sequenceCounter].timeSchedule) return; // not time for the next event yet + + + _previousEventTime = inTimeNow; + + if (_eventHandler != NULL) _eventHandler(_sequenceCounter); + + if (++_sequenceCounter > _eventCount) _sequenceCounter = -1; // end of sequence reached + + + + +} + +void XPLSequencer::trigger() +{ + _sequenceCounter = 0; // start the sequence + _previousEventTime = millis(); +} + +#endif \ No newline at end of file diff --git a/XPLPro_Arduino/XPLPro/XPLSwitches.h b/XPLPro_Arduino/XPLPro/XPLSwitches.h new file mode 100644 index 0000000..106072e --- /dev/null +++ b/XPLPro_Arduino/XPLPro/XPLSwitches.h @@ -0,0 +1,179 @@ +// XPLSwitches.h - XPLPro Add-on Library for simple switch connections +// Created by Curiosity Workshop, Michael Gerlicher, 2024 +// +// To report problems, download updates and examples, suggest enhancements or get technical support, please visit: +// discord: https://discord.gg/gzXetjEST4 +// patreon: www.patreon.com/curiosityworkshop + +#ifndef XPLSwitches_h +#define XPLSwitches_h + +// Parameters around the interface +#define XPLSWITCHES_SENDTOHANDLER 0 // Default is to send switch events to the supplied handler. This always occurs regardless. +#define XPLSWITCHES_DATAREFWRITE 1 // Update dataref with switch status +#define XPLSWITCHES_COMMANDTRIGGER 2 // Trigger command with pressed +#define XPLSWITCHES_COMMANDSTARTEND 3 // Start command when pressed, end command when released +#define XPLSWITCHES_DATAREFWRITE_INVERT 4 // same as datarefwrite but invert the signal + +#define XPLSWITCHES_DEBOUNCETIME 50 +#define XPLSWITCHES_PRESSED 0 +#define XPLSWITCHES_RELEASED 1 + +#ifndef XPLSWITCHES_MAXSWITCHES +#define XPLSWITCHES_MAXSWITCHES 40 //Default to 40. This costs ~400 bytes. +#endif + + +/// @brief Core class for the XPLPro Switches Addon +class XPLSwitches +{ +public: + /// @brief Constructor + /// @param switchHandler, Function called when pin activity is detected, or NULL if not needed + XPLSwitches(void (*switchHandler)(int pin, int switchValue)); + + /// + /// @brief begin + /// + /// + void begin(XPLPro* xplpro); + + int addPin(int inPin, byte inMode, int inHandle); + int addPin(int inPin, byte inMode, int inHandle, int inElement); + + int getHandle(int inPin); + + + /// @brief Scan pins and call handler if any changes are detected. Run regularly + void check(void); + + void clear(void); + +private: + + XPLPro* _XP; + + int _switchCount; // how many are registered + + + void (*_switchHandler)(int inSwitchID, int inSwitchValue) = NULL; // this function will be called when activity is detected on the mux, if not NULL + + + struct XPLSwitch + { + int arduinoPin; // connected pin + byte prevStatus; // last known status + byte mode; + int handle; + int element; + long int prevTime; // time of last change + + }; + + struct XPLSwitch _switches[XPLSWITCHES_MAXSWITCHES]; + +}; + + +XPLSwitches::XPLSwitches(void (*switchHandler)(int inSwitchID, int inValue)) +{ + + + _switchHandler = switchHandler; + + +}; + +void XPLSwitches::begin(XPLPro* xplpro) +{ + _XP = xplpro; + clear(); + +} + +void XPLSwitches::clear(void) // call this prior to adding pins if not the first run +{ + _switchCount = 0; + +} + +int XPLSwitches::addPin(int inPin, byte inMode, int inHandle) +{ + + + return addPin(inPin, inMode, inHandle, 0); + + +} + +int XPLSwitches::addPin(int inPin, byte inMode, int inHandle, int inElement) +{ + if (_switchCount >= XPLSWITCHES_MAXSWITCHES) return -1; + + _switches[_switchCount].arduinoPin = inPin; + _switches[_switchCount].mode = inMode; + _switches[_switchCount].handle = inHandle; + _switches[_switchCount].element = inElement; + _switches[_switchCount].prevStatus = -1; // This will force update to the plugin + pinMode(inPin, INPUT_PULLUP); + + return _switchCount++; + + +} + +int XPLSwitches::getHandle(int inPin) +{ + for (int i = 0; i < XPLSWITCHES_MAXSWITCHES; i++) if (_switches[i].arduinoPin == inPin) return _switches[i].handle; + return -1; + +} + + +void XPLSwitches::check(void) +{ + + unsigned long timeNow = millis(); + + + for (int i = 0; i < _switchCount; i++) + { + int pinValue = digitalRead(_switches[i].arduinoPin); + + if (pinValue != _switches[i].prevStatus && timeNow - _switches[i].prevTime >= XPLSWITCHES_DEBOUNCETIME) + { + + _switches[i].prevStatus = pinValue; + _switches[i].prevTime = timeNow; + + switch (_switches[i].mode) + { + + case XPLSWITCHES_DATAREFWRITE: + _XP->datarefWrite(_switches[i].handle, pinValue, _switches[i].element); + break; + + case XPLSWITCHES_DATAREFWRITE_INVERT: + _XP->datarefWrite(_switches[i].handle, !pinValue, _switches[i].element); + break; + + case XPLSWITCHES_COMMANDTRIGGER: + if (pinValue == XPLSWITCHES_PRESSED) _XP->commandTrigger(_switches[i].handle); + break; + + case XPLSWITCHES_COMMANDSTARTEND: + if (pinValue == XPLSWITCHES_PRESSED) _XP->commandStart(_switches[i].handle); + if (pinValue == XPLSWITCHES_RELEASED) _XP->commandEnd(_switches[i].handle); + break; + + + } + + if (_switchHandler != NULL) _switchHandler(_switches[i].arduinoPin, pinValue); + + } + } + +} + +#endif \ No newline at end of file diff --git a/XPLPro_Arduino/XPLPro/examples/XPLProAbbreviationsDemo/XPLProAbbreviationsDemo.ino b/XPLPro_Arduino/XPLPro/examples/XPLProAbbreviationsDemo/XPLProAbbreviationsDemo.ino new file mode 100644 index 0000000..9d99dca --- /dev/null +++ b/XPLPro_Arduino/XPLPro/examples/XPLProAbbreviationsDemo/XPLProAbbreviationsDemo.ino @@ -0,0 +1,172 @@ + + +/* + * + * XPLProAbbreviationsDemo + * + * Created by Curiosity Workshop for XPL/Pro arduino->XPlane system. + * + * This sketch was developed and tested on an Arduino Mega. + * + To report problems, download updates and examples, suggest enhancements or get technical support: + + discord: https://discord.gg/RacvaRFsMW + patreon: www.patreon.com/curiosityworkshop + YouTube: https://youtube.com/channel/UCISdHdJIundC-OSVAEPzQIQ + * + * + */ + +#include +#include + +#include // include file for the X-plane direct interface +XPLPro XP(&Serial); // create an instance of it + +LiquidCrystal_I2C lcd(0x26,16,2); + + +long int startTime; + + +#define PIN_GOAROUND 22 // go around button +#define PIN_GEARTOGGLE 23 // pin for gear toggle + +#define PIN_PAUSE 9 // pin to pause xplane +#define PIN_NAVLIGHT 24 // pin for nav light switch +#define PIN_LANDINGLIGHT 7 // pin for landing light switch + + + +int drefBeaconLight; +int drefNavLight, navlightPrevious = -1; +int drefLdgLight; +int drefTaxiLight; +int drefStrobeLight; + +int cmdGearToggle; // a handle for toggling landing gear up and down +int cmdPause; // pause the sim +int cmdToga; // take off/go around + + +void setup() +{ + lcd.init(); + lcd.backlight(); + lcd.setCursor(0,0); + lcd.print("XPLPro Demo!"); + + pinMode(PIN_GEARTOGGLE, INPUT_PULLUP); // if you are doing pin handling yourself you will want a pullup resistor or use the built-in one + pinMode(PIN_NAVLIGHT, INPUT_PULLUP); // otherwise the value will be erratic when the pin is open and nobody likes that. + pinMode(PIN_GOAROUND, INPUT_PULLUP); + pinMode(PIN_LANDINGLIGHT, INPUT_PULLUP); + + pinMode(PIN_PAUSE, INPUT_PULLUP); + + pinMode(LED_BUILTIN, OUTPUT); // built in LED on arduino board for debug and demonstration purposes + + + Serial.begin(XPL_BAUDRATE); // start serial interface. Baudrate is specified in the header, dont change + + /* + needed for initialization. Parameters are: + a texual identifier of your device + your function that will be called when xplane and the plugin are ready for dataref and command registrations + your function that will be called when xplane either shuts down or unloads an aircraft model + your function that will be called when we have requested sends of datarefs that have changed + */ + XP.begin("XPLPro Abbreviation Demo!", &xplRegister, &xplShutdown, &xplInboundHandler); + digitalWrite(LED_BUILTIN, LOW); + + +} + + +void loop() +{ + + + + XP.xloop(); // needs to run every cycle. + +/************************************************************************************************************************************ + * everything after the next line will only occur every 100ms. You can also utilize other time values. + * This helps maintain serial data flow and also helps with switch debounce. + * do NOT add delays anywhere in the loop cycle, it will interfere with the reception of serial data from xplane and the plugin. + ************************************************************************************************************************************ +*/ + + if (millis() - startTime > 100) startTime = millis(); else return; + + +/* + * This reads the status of the assigned pins and triggers commands accordingly. It would be best to use a button library for this for debounce and one-shot purposes + * I am not using one for simplicity in the demo. + */ + if (!digitalRead(PIN_GEARTOGGLE)) XP.commandTrigger(cmdGearToggle); + if (!digitalRead(PIN_GOAROUND)) XP.commandTrigger(cmdToga); + if (!digitalRead(PIN_PAUSE)) XP.commandTrigger(cmdPause); + + + if (digitalRead(PIN_NAVLIGHT) != navlightPrevious) // to conserve the flow of data we should keep track of the previously sent value so we don't send a new one every cycle + { + navlightPrevious = digitalRead(PIN_NAVLIGHT); + XP.datarefWrite(drefNavLight, navlightPrevious); + } + + //landingLights = digitalRead(PIN_LANDINGLIGHT); + + + + + +} + +/* + * This function is the callback function we specified that will be called any time our requested data is sent to us. + * handle is the handle to the dataref. The following values are transfered to the callback through inStruct: + * + * int inData->handle The handle of the incoming dataref + * int inData->element If the dataref is an array style dataref, this is the element of the array + * long inData->inLong long value for datarefs that are long values + * float inData->inFloat float value for datarefs that are float values + */ +void xplInboundHandler(inStruct *inData) +{ + if (inData->handle == drefBeaconLight) + { if (inData->inLong) digitalWrite(LED_BUILTIN, HIGH); // if beacon is on set the builtin led on + else digitalWrite(LED_BUILTIN, LOW); + } + + + + +} + +void xplRegister() // this is the function we set as a callback for when the plugin is ready to receive dataref and command bindings requests +{ + + + drefLdgLight = XP.registerDataRef(F("LTland") ); // "LTland" will be converted to "sim/cockpit/electrical/landing_lights_on" + drefTaxiLight = XP.registerDataRef(F("LTtaxi")); // other abbreviations are listed in the abbreviations.txt file in the plugin folder. + drefBeaconLight = XP.registerDataRef(F("LTbcn")); + drefStrobeLight = XP.registerDataRef(F("LTstrobe")); + drefNavLight = XP.registerDataRef(F("LTnav")); + + +/* + * Now register commands. + * + */ + cmdPause = XP.registerCommand(F("CMDpause") ); + cmdToga = XP.registerCommand(F("CMDtoga") ); + cmdGearToggle = XP.registerCommand(F("CMDgearToggle") ); + + +} + +void xplShutdown() +{ + // if you need to do things when xplane shuts down or unloads an aircraft, do it here. + +} diff --git a/XPLPro_Arduino/XPLPro/examples/XPLProAbbreviationsDemo2/XPLProAbbreviationsDemo2.ino b/XPLPro_Arduino/XPLPro/examples/XPLProAbbreviationsDemo2/XPLProAbbreviationsDemo2.ino new file mode 100644 index 0000000..2b88e1c --- /dev/null +++ b/XPLPro_Arduino/XPLPro/examples/XPLProAbbreviationsDemo2/XPLProAbbreviationsDemo2.ino @@ -0,0 +1,238 @@ + +// ARDUINO MEGA + + +#include +#include // include file for the X-plane direct interface +#include + +XPLPro XP(&Serial); // create an instance of it +LiquidCrystal_I2C lcd(0x26,16,2); + +unsigned long startTime; // for timing purposes +bool baroMode; +bool alt1000Mode; + +// =============================== Rotary Encoder vars ====================================================================== +bool RE1_lastStateCLK; bool RE1_lastStateDT; bool RE1_lastStateSW; const int RE1_CLK = 22; const int RE1_DT = 23; const int RE1_SW = 30; +bool RE2_lastStateCLK; bool RE2_lastStateDT; bool RE2_lastStateSW; const int RE2_CLK = 24; const int RE2_DT = 25; const int RE2_SW = 31; +bool RE3_lastStateCLK; bool RE3_lastStateDT; bool RE3_lastStateSW; const int RE3_CLK = 26; const int RE3_DT = 27; const int RE3_SW = 32; + +// ================================== LIGHTS STATUS ========================================================================= +long int beacon; long int landing; long int taxi; long int navLights; long int strobes; + +// ================================== C O M M A N D S ======================================================================= +int cmdBcnToggle; int cmdLandToggle; int cmdTaxiToggle; int cmdNavToggle; int cmdStrobeToggle; +int cmdBattToggle; int cmdAvioToggle; int cmdGenToggle; + +int cmdHeadUp; int cmdHeadDown; int cmdHeadSync; // on Rotaly Encoder 1 +int cmdAltUp; int cmdAltDown; int cmdBaroUp; int cmdBaroDown; // on Rotary Encoder 2 +int cmdAlt100_Up; int cmdAlt100_Down; int cmdAlt1000_Up; int cmdAlt1000_Down; // on Rotary Encoder 2 v.2 +int cmdCrsUp; int cmdCrsDown; // on Rotary Encoder 3 + +// ===================================== pin LEDs and SWITCHES ============================================================ +bool beaconStatus; bool beaconLastStatus = true; const int beaconLed = 12; const int beaconSwitch = 6; +bool landingStatus; bool landingLastStatus = true; const int landingLed = 11; const int landingSwitch = 5; +bool taxiStatus; bool taxiLastStatus = true; const int taxiLed = 10; const int taxiSwitch = 4; +bool navLightsStatus; bool navLightsLastStatus = true; const int navLightsLed = 9; const int navLightsSwitch = 3; +bool strobesStatus; bool strobesLastStatus = true; const int strobesLed = 8; const int strobesSwitch = 2; + +bool battStatus; bool battLastStatus = true; const int battSwitch = 48; +bool avioStatus; bool avioLastStatus = true; const int avioSwitch = 49; +bool geneStatus; bool geneLastStatus = true; const int geneSwitch = 50; + +// ======================================= END of VARs DECLARIATIONs and DEFINITIONs ======================================= + + +void setup() +{ + + lcd.init(); + lcd.backlight(); + lcd.setCursor(0,0); + lcd.print("initializing.."); + + pinMode(RE1_CLK,INPUT); pinMode(RE1_DT,INPUT); pinMode(RE1_SW,INPUT_PULLUP); + pinMode(RE2_CLK,INPUT); pinMode(RE2_DT,INPUT); pinMode(RE2_SW,INPUT_PULLUP); + +// ------------- SWITCHes -------------------- + pinMode(beaconSwitch, INPUT_PULLUP); + pinMode(landingSwitch, INPUT_PULLUP); + pinMode(navLightsSwitch, INPUT_PULLUP); + pinMode(strobesSwitch, INPUT_PULLUP); + pinMode(taxiSwitch, INPUT_PULLUP); + pinMode(battSwitch, INPUT_PULLUP); + pinMode(avioSwitch, INPUT_PULLUP); + pinMode(geneSwitch, INPUT_PULLUP); + +// --------------- LEDs ---------------------- + pinMode(beaconLed, OUTPUT); + pinMode(landingLed, OUTPUT); + pinMode(navLightsLed, OUTPUT); + pinMode(strobesLed, OUTPUT); + pinMode(taxiLed, OUTPUT); + + Serial.begin(XPL_BAUDRATE); // start serial interface. Baudrate is specified in the header, dont change + + XP.begin("XPLPro Giorgio Lights & Switches", &xplRegister, &xplShutdown, &xplInboundHandler); + ErrorBlink(LED_BUILTIN, 5); // let everyone know we are awake + + while (!Serial) + { + ErrorBlink(LED_BUILTIN, 2); + delay(300); + } + + digitalWrite(beaconLed, LOW); + digitalWrite(landingLed, LOW); + digitalWrite(navLightsLed, LOW); + digitalWrite(strobesLed, LOW); + digitalWrite(taxiLed, LOW); + + RE1_lastStateCLK = digitalRead(RE1_CLK); RE1_lastStateDT = digitalRead(RE1_DT); RE1_lastStateSW = digitalRead(RE1_SW); + RE2_lastStateCLK = digitalRead(RE2_CLK); RE2_lastStateDT = digitalRead(RE2_DT); RE2_lastStateSW = digitalRead(RE2_SW); + RE3_lastStateCLK = digitalRead(RE3_CLK); RE3_lastStateDT = digitalRead(RE3_DT); RE3_lastStateSW = digitalRead(RE3_SW); + baroMode = false; + alt1000Mode = false; +} + + +void loop() +{ + XP.xloop(); + +// Rotary Encoders: 1 = Heading + Head Sync 2 = Altitude ( + Altitude x 1000 on G1000) 3 = Cursor + Barometer +// ======================================================================================================================= + checkRotaryEnc(1, RE1_CLK, RE1_DT, RE1_lastStateCLK, RE1_lastStateDT, cmdHeadDown, cmdHeadUp, RE1_SW, RE1_lastStateSW, cmdHeadSync); + if (!alt1000Mode) checkRotaryEnc(2, RE2_CLK, RE2_DT, RE2_lastStateCLK, RE2_lastStateDT, cmdAltDown, cmdAltUp, RE2_SW, RE2_lastStateSW, 3); + else checkRotaryEnc(2, RE2_CLK, RE2_DT, RE2_lastStateCLK, RE2_lastStateDT, cmdAlt1000_Down, cmdAlt1000_Up, RE2_SW, RE2_lastStateSW, 3); + if (!baroMode) checkRotaryEnc(3, RE3_CLK, RE3_DT, RE3_lastStateCLK, RE3_lastStateDT, cmdCrsDown, cmdCrsUp, RE3_SW, RE3_lastStateSW, 3); + else checkRotaryEnc(3, RE3_CLK, RE3_DT, RE3_lastStateCLK, RE3_lastStateDT, cmdBaroDown, cmdBaroUp, RE3_SW, RE3_lastStateSW, 3); + + if (millis() - startTime > 100) startTime = millis(); else return; + + checkStatus(beaconSwitch, beaconLastStatus, cmdBcnToggle); + checkStatus(landingSwitch, landingLastStatus, cmdLandToggle); + checkStatus(taxiSwitch, taxiLastStatus, cmdTaxiToggle); + checkStatus(navLightsSwitch, navLightsLastStatus, cmdNavToggle); + checkStatus(strobesSwitch, strobesLastStatus, cmdStrobeToggle); + checkStatus(battSwitch, battLastStatus, cmdBattToggle); + checkStatus(avioSwitch, avioLastStatus, cmdAvioToggle); + checkStatus(geneSwitch, geneLastStatus, cmdGenToggle); +} + +void checkRotaryEnc(int devNum, int pinA, int pinB, bool& lastA, bool& lastB, int cmdCode1, int cmdCode2, int pinSw, bool& lastSw, int cmdCode3) { + bool flagA = !digitalRead(pinA); + bool flagB = !digitalRead(pinB); + if (flagA != lastA) { + if(flagB == flagA) XP.commandTrigger(cmdCode1); + else XP.commandTrigger(cmdCode2); + } + lastA = flagA; + lastB = flagB; + bool flagSw = !digitalRead(pinSw); + if (flagSw == lastSw) return; + if (flagSw) { + switch (devNum) { + case 1: + XP.commandTrigger(cmdCode3); + break; + case 2: + alt1000Mode = !alt1000Mode; + break; + case 3: + baroMode = !baroMode; + break; + } + } + lastSw = flagSw; +} + +void checkStatus(int pin, bool& last, int cmdCode) { + bool flag = !digitalRead(pin); + if(flag == last) return; + if(flag) XP.commandTrigger(cmdCode); + last = flag; +} + +void xplInboundHandler(inStruct *inData) { + +lcd.setCursor(0,0); + + if (inData->handle == beacon) { + lcd.print("Beacon: "); + if (inData->inLong) lcd.print("ON "); //digitalWrite(beaconLed,HIGH); + else lcd.print("OFF"); //digitalWrite(beaconLed,LOW); + } else if (inData->handle == landing) { + lcd.print("Landing: "); + + if (inData->inLong) lcd.print("ON "); // digitalWrite(landingLed,HIGH); + else lcd.print("OFF"); // digitalWrite(landingLed,LOW); + } else if (inData->handle == taxi) { + lcd.print("Taxi: "); + if (inData->inLong) lcd.print("ON "); //digitalWrite(taxiLed,HIGH); + else lcd.print("OFF"); //digitalWrite(taxiLed,LOW); + } else if (inData->handle == navLights) { + lcd.print("Nav: "); + if (inData->inLong) lcd.print("ON "); //digitalWrite(navLightsLed,HIGH); + else lcd.print("OFF"); //digitalWrite(navLightsLed,LOW); + } else if (inData->handle == strobes) { + lcd.print("Strobes: "); + if (inData->inLong) lcd.print("ON "); //digitalWrite(strobesLed,HIGH); + else lcd.print("OFF"); //digitalWrite(strobesLed,LOW); + } +} + +void xplRegister() +{ +beacon = XP.registerDataRef(F("LTbcn") ); + XP.requestUpdates(beacon, 100, 0); + taxi = XP.registerDataRef(F("LTtax") ); + XP.requestUpdates(taxi, 100, 0); + landing = XP.registerDataRef(F("LTlnd") ); + XP.requestUpdates(landing, 100, 0); + navLights = XP.registerDataRef(F("LTnav") ); + XP.requestUpdates(navLights, 100, 0); + strobes = XP.registerDataRef(F("LTstr") ); + XP.requestUpdates(strobes, 100, 0); + + cmdBcnToggle = XP.registerCommand(F("sim/lights/beacon_lights_toggle")); + cmdLandToggle = XP.registerCommand(F("sim/lights/landing_lights_toggle")); + cmdNavToggle = XP.registerCommand(F("sim/lights/nav_lights_toggle")); + cmdTaxiToggle = XP.registerCommand(F("sim/lights/taxi_lights_toggle")); + cmdStrobeToggle = XP.registerCommand(F("sim/lights/strobe_lights_toggle")); + cmdBattToggle = XP.registerCommand(F("sim/electrical/batteries_toggle")); + cmdAvioToggle = XP.registerCommand(F("sim/systems/avionics_toggle")); + cmdAltUp = XP.registerCommand(F("sim/autopilot/altitude_up")); + cmdAltDown = XP.registerCommand(F("sim/autopilot/altitude_down")); + cmdHeadUp = XP.registerCommand(F("sim/autopilot/heading_up")); + cmdHeadDown = XP.registerCommand(F("sim/autopilot/heading_down")); + cmdBaroUp = XP.registerCommand(F("sim/instruments/barometer_up")); + cmdBaroDown = XP.registerCommand(F("sim/instruments/barometer_down")); + cmdHeadSync = XP.registerCommand(F("sim/GPS/g1000n1_hdg_sync")); +// cmdHeadSync = XP.registerCommand(F("sim/autopilot/heading_sync")); + cmdAlt100_Up = XP.registerCommand(F("sim/GPS/g1000n1_alt_inner_up")); + cmdAlt100_Down = XP.registerCommand(F("sim/GPS/g1000n1_alt_inner_down")); + cmdAlt1000_Up = XP.registerCommand(F("sim/GPS/g1000n1_alt_outer_up")); + cmdAlt1000_Down = XP.registerCommand(F("sim/GPS/g1000n1_alt_outer_down")); + cmdGenToggle = XP.registerCommand(F("sim/electrical/generators_toggle")); + cmdCrsUp = XP.registerCommand(F("sim/GPS/g1000n1_crs_up")); + cmdCrsDown = XP.registerCommand(F("sim/GPS/g1000n1_crs_down")); +} + +void xplShutdown() +{ + // if you need to do things when xplane shuts down or unloads an aircraft, do it here. + +} + +void ErrorBlink(int pin, int count) +{ + for (int i = 0; i< count; i++) + { + digitalWrite(pin, HIGH); + delay(200); + digitalWrite(pin, LOW); + delay(100); + } +} diff --git a/XPLPro_Arduino/XPLPro/examples/XPLProArraysExample/Circuit Layout.fzz b/XPLPro_Arduino/XPLPro/examples/XPLProArraysExample/Circuit Layout.fzz new file mode 100644 index 0000000..f5a3237 Binary files /dev/null and b/XPLPro_Arduino/XPLPro/examples/XPLProArraysExample/Circuit Layout.fzz differ diff --git a/XPLPro_Arduino/XPLPro/examples/XPLProArraysExample/Circuit Layout_bb.jpg b/XPLPro_Arduino/XPLPro/examples/XPLProArraysExample/Circuit Layout_bb.jpg new file mode 100644 index 0000000..2e26a8d Binary files /dev/null and b/XPLPro_Arduino/XPLPro/examples/XPLProArraysExample/Circuit Layout_bb.jpg differ diff --git a/XPLPro_Arduino/XPLPro/examples/XPLProArraysExample/XPLProArraysExample.ino b/XPLPro_Arduino/XPLPro/examples/XPLProArraysExample/XPLProArraysExample.ino new file mode 100644 index 0000000..324c0c5 --- /dev/null +++ b/XPLPro_Arduino/XPLPro/examples/XPLProArraysExample/XPLProArraysExample.ino @@ -0,0 +1,138 @@ + +/* + * + * XPLProArraysExample + * + * Created by Curiosity Workshop for XPL/Pro arduino->XPlane system. + * + * This sketch was developed and tested on an Arduino Mega. + * + To report problems, download updates and examples, suggest enhancements or get technical support: + + discord: https://discord.gg/RacvaRFsMW + patreon: www.patreon.com/curiosityworkshop + YouTube: https://youtube.com/channel/UCISdHdJIundC-OSVAEPzQIQ + * + * + */ + +#include + +#include + +#define XPLPOTS_MAXPOTS 3 // adjust this as required for your needs. Higher number of course costs memory. Default is 10 if not specified +#include +#include + + +#define PIN_THROTTLE1 A0 +#define PIN_THROTTLE2 A1 + +#define PIN_GEN1 49 +#define PIN_GEN2 51 + + +int drefRPM; + +XPLPro XP(&Serial); + + +XPLPotentiometers pots(NULL); // Instead of providing a handler we supply NULL if a handler is not needed +XPLSwitches switches(NULL); + +void setup() +{ + Serial.begin(XPL_BAUDRATE); + XP.begin("XPLPro Arrays Example", &xplRegister, &xplShutdown, &xplInboundHandler); + + pots.begin(&XP); + switches.begin(&XP); + +} + +void loop() +{ + XP.xloop(); + pots.check(); + switches.check(); + + + +} + +void xplInboundHandler(inStruct *inData) +{ + /* + * This deals with incoming data that we requested. + */ + + if (inData->handle == drefRPM) + { switch (inData->element ) + { + case 0: // left engine + // inData->inFloat is what will contain the new data (could also be inLong and other types depending on the dataref) + // Do something cool with the data here. + break; + + case 1: // right engine. Maybe print to an lcd? + // lcd.print(inData->inFloat); + break; + + + } + } + +} + +void xplShutdown() +{ + + +} + + +void xplRegister() +{ + pots.clear(); // Reset pots + switches.clear(); // Reset switches + +// throttle_ratio is a dataref that utilizes array elements. Left engine is element 0, right engine is element 1 and is retained by the potentiometer wrapper. +// We can also write manually with XP.datarefWrite(handle, value, element) if not using the wrapper. +int drefThrottleRatio = XP.registerDataRef(F("sim/cockpit2/engine/actuators/throttle_ratio")); // We don't need to save this but temporarily holding the handle value will prevent us from having to query the plugin multiple times for the same datare + + pots.addPin(PIN_THROTTLE1, XPLPOTS_DATAREFWRITE, drefThrottleRatio, + 0, // array element (left engine) + 10, // precision, this rounds the pot value to the closest 10 in this example + 0, 1024, 0, 1); // scaling request. Plugin handles the math for us and converts the analogRead from 0-1024 to 0-1 as the dataref requires. + +// throttle for engine 2, similar but for element 1 (right engine) + pots.addPin(PIN_THROTTLE2, XPLPOTS_DATAREFWRITE, drefThrottleRatio, 1, 10, 0, 1024, 0, 1); // Right engine is element 1 + +// We can also handle them manually without the use of the wrapper. Example: +// int drefMixture; // at the beginning of the code +// drefMixture = XP.registerDataRef(F("sim/cockpit2/engine/actuators/mixture_ratio")) +// +// then in the loop somewhere we can write to the dataref: +// XP.datarefWrite(drefThrottle, .5, 0); // 0 is left engine, set it to 50% +// XP.datarefWrite(drefThrottle, .4, 1); // 1 is right engine, set it to 40% +// + + +// now connect a switch on PIN_GEN1 and PIN_GEN2 to a dataref that controls engine 1 and 2 generators (array elements 0 and 1). +// We also could write to the handle without the switch wrapper of use a switch handler, etc. + + switches.addPin(PIN_GEN1, XPLSWITCHES_DATAREFWRITE, XP.registerDataRef(F("sim/cockpit2/electrical/generator_on")), 0 ); //connect PIN_GEN1 to engine 1 generator + switches.addPin(PIN_GEN2, XPLSWITCHES_DATAREFWRITE_INVERT, XP.registerDataRef(F("sim/cockpit2/electrical/generator_on")), 1 ); //connect PIN_GEN2 to engine 2 generator. I inverted this for demonstration purposes + + +// This examples requests an array dataref for inbound handling. +// See the inbound handler above for how to deal with incoming data +// Be mindful of the time between requests and the precision you need. Some datarefs are very active and this can produce crazy amounts of +// incoming data to deal with. + drefRPM = XP.registerDataRef(F("sim/cockpit2/engine/indicators/engine_speed_rpm")); + XP.requestUpdates(drefRPM, 500, 20, 0); // request drefRPM to be updated every 500ms, 20rpm precision and element 0; + XP.requestUpdates(drefRPM, 500, 20, 1); // same for element 1. + + +} + diff --git a/XPLPro_Arduino/XPLPro/examples/XPLProArraysExample/build1.jpg b/XPLPro_Arduino/XPLPro/examples/XPLProArraysExample/build1.jpg new file mode 100644 index 0000000..df41723 Binary files /dev/null and b/XPLPro_Arduino/XPLPro/examples/XPLProArraysExample/build1.jpg differ diff --git a/XPLPro_Arduino/XPLPro/examples/XPLProArraysExample/build2.jpg b/XPLPro_Arduino/XPLPro/examples/XPLProArraysExample/build2.jpg new file mode 100644 index 0000000..a0f907e Binary files /dev/null and b/XPLPro_Arduino/XPLPro/examples/XPLProArraysExample/build2.jpg differ diff --git a/XPLPro_Arduino/XPLPro/examples/XPLProArraysExample/build3.jpg b/XPLPro_Arduino/XPLPro/examples/XPLProArraysExample/build3.jpg new file mode 100644 index 0000000..8c46d81 Binary files /dev/null and b/XPLPro_Arduino/XPLPro/examples/XPLProArraysExample/build3.jpg differ diff --git a/XPLPro_Arduino/XPLPro/examples/XPLProBeaconDemo/XPLProBeaconDemo.ino b/XPLPro_Arduino/XPLPro/examples/XPLProBeaconDemo/XPLProBeaconDemo.ino new file mode 100644 index 0000000..553b0dc --- /dev/null +++ b/XPLPro_Arduino/XPLPro/examples/XPLProBeaconDemo/XPLProBeaconDemo.ino @@ -0,0 +1,111 @@ + + +/* + * + * XPLProBeaconDemo + * + * Created by Curiosity Workshop for XPL/Pro arduino->XPlane system. + * + * This sketch was developed and tested on an Arduino Mega. + * + To report problems, download updates and examples, suggest enhancements or get technical support: + + discord: https://discord.gg/RacvaRFsMW + patreon: www.patreon.com/curiosityworkshop + YouTube: https://youtube.com/channel/UCISdHdJIundC-OSVAEPzQIQ + * + * + */ + +#include +#include // include file for the X-plane direct interface +XPLPro XP(&Serial); // create an instance of it + + +long int startTime; + +int drefBeacon; // this stores a handle to the beacon light dataref + +void setup() +{ + + pinMode(LED_BUILTIN, OUTPUT); // built in LED on arduino board will turn on and off with the status of the beacon light + + Serial.begin(XPL_BAUDRATE); // start serial interface. Baudrate is specified in the header, dont change + + /* + needed for initialization. Parameters are: + a texual identifier of your device + your function that will be called when xplane and the plugin are ready for dataref and command registrations + your function that will be called when xplane either shuts down or unloads an aircraft model + your function that will be called when we have requested sends of datarefs that have changed + */ + XP.begin("XPLPro Beacon Light Demo!", &xplRegister, &xplShutdown, &xplInboundHandler); + digitalWrite(LED_BUILTIN, LOW); + + +} + + +void loop() +{ + + XP.xloop(); // needs to run every cycle. + +/************************************************************************************************************************************ + * everything after the next line will only occur every 100ms. You can also utilize other time values. + * This helps maintain serial data flow and also helps with switch debounce. + * do NOT add delays anywhere in the loop cycle, it will interfere with the reception of serial data from xplane and the plugin. + ************************************************************************************************************************************ +*/ + + if (millis() - startTime > 100) startTime = millis(); else return; + +} + +/* + * This function is the callback function we specified that will be called any time our requested data is sent to us. + * handle is the handle to the dataref. The following variables within the plugin are how we receive the data: + * + * inStruct *inData is a pointer to a structure that contains information about the incoming dataref. + * + * int inData->handle The handle of the incoming dataref + * int inData->element If the dataref is an array style dataref, this is the element of the array + * long inData->inLong long value for datarefs that are long values + * float inData->inFloat float value for datarefs that are float values + */ + void xplInboundHandler(inStruct *inData) +{ + if (inData->handle == drefBeacon) + { if (inData->inLong) digitalWrite(LED_BUILTIN, HIGH); // if beacon is on set the builtin led on + else digitalWrite(LED_BUILTIN, LOW); + } + + +} + +/* + * this is the function we set as a callback for when the plugin is ready to receive dataref and command bindings requests + * It could be called multiple times if for instance xplane is restarted or loads a different aircraft + */ +void xplRegister() +{ +/* + * This example registers a dataref for the beacon light. + * In the inbound handler section of the code we will turn on/off the LED on the arduino board to represent the status of the beacon light within xplane. + * On non-AVR boards remove the F() macro. + * + */ + drefBeacon = XP.registerDataRef(F("sim/cockpit2/switches/beacon_on") ); + XP.requestUpdates(drefBeacon, 100, 0); // Tell xplane to send us updates when the status of the beacon light changes. + // 100 means don't update more often than every 100ms and 0 is a precision specifier for float variables which is explained in another example, use 0 for now. + + + +} + +void xplShutdown() +{ + // if you need to do things when xplane shuts down or unloads an aircraft, do it here. + +} diff --git a/XPLPro_Arduino/XPLPro/examples/XPLProDualRPMGauge/XPLProDualRPMGauge.ino b/XPLPro_Arduino/XPLPro/examples/XPLProDualRPMGauge/XPLProDualRPMGauge.ino new file mode 100644 index 0000000..7fa6c86 --- /dev/null +++ b/XPLPro_Arduino/XPLPro/examples/XPLProDualRPMGauge/XPLProDualRPMGauge.ino @@ -0,0 +1,107 @@ + + +/* + * + * XPLProDualRPMGauge + * + * Created by Curiosity Workshop for XPL/Pro arduino->XPlane system. + * + * This sketch was developed and tested on an Arduino Mega. + * + To report problems, download updates and examples, suggest enhancements or get technical support: + + discord: https://discord.gg/RacvaRFsMW + patreon: www.patreon.com/curiosityworkshop + YouTube: https://youtube.com/channel/UCISdHdJIundC-OSVAEPzQIQ + * + * + */ + + +#include +#include // servo library by Michael Margolis + +#include // include file for the X-plane direct interface +XPLPro XP(&Serial); // create an instance of it + +Servo servoRPM1; +Servo servoRPM2; + +long int startTime; + + +#define PIN_SERVO_RPM1 8 // RPM Servo Engine 1 +#define PIN_SERVO_RPM2 9 // RPM Servo Engine 2 + + + +unsigned drefRPM; // since this dataref is an array we only need it once for both engines, we can ask for the elements separately + +void setup() +{ + + servoRPM1.attach(PIN_SERVO_RPM1); // engine 1 rpm servo + servoRPM2.attach(PIN_SERVO_RPM2); // engine 2 rpm servo + + Serial.begin(XPL_BAUDRATE); // start serial interface. Baudrate is specified in the header, dont change + + /* + needed for initialization. Parameters are: + a texual identifier of your device + your function that will be called when xplane and the plugin are ready for dataref and command registrations + your function that will be called when xplane either shuts down or unloads an aircraft model + your function that will be called when we have requested sends of datarefs that have changed + */ + XP.begin("XPLPro Dual RPM Servo Gauge", &xplRegister, &xplShutdown, &xplInboundHandler); + digitalWrite(LED_BUILTIN, LOW); + + +} + + +void loop() +{ + + XP.xloop(); // needs to run every cycle. + +} + +/* + * This function is the callback function we specified that will be called any time our requested data is sent to us. + * handle is the handle to the dataref. The following values are transfered to the callback through inStruct: + * + * int inData->handle The handle of the incoming dataref + * int inData->element If the dataref is an array style dataref, this is the element of the array + * long inData->inLong long value for datarefs that are long values + * float inData->inFloat float value for datarefs that are float values + */ +void xplInboundHandler(inStruct *inData) +{ + if (inData->handle == drefRPM) + { + if (inData->element == 0) servoRPM1.write((int)inData->inFloat); // set position of engine 1 rpm servo + if (inData->element == 1) servoRPM2.write((int)inData->inFloat); // set position of engine 2 rpm servo + + } + + + +} + +void xplRegister() // this is the function we set as a callback for when the plugin is ready to receive dataref and command bindings requests +{ + + + drefRPM = XP.registerDataRef(F("sim/cockpit2/engine/indicators/engine_speed_rpm") ); // this will be updated from xplane to tell us the rpm + XP.requestUpdates(drefRPM, 200, 20, 0); // Tell xplane to send us updates when the RPM changes by 20 and no more than every 200milliseconds (5 times per second) + XP.requestUpdates(drefRPM, 200, 20, 1); // and for engine 2 (array element 1) + + XP.setScaling(drefRPM, 0,3500, 180,0); // Have the plugin scale the data to match our servo scale. RPM on the baron is 0 - 3500, servo takes 0 - 180 full scale. Adjust as needed + +} + +void xplShutdown() +{ + // if you need to do things when xplane shuts down or unloads an aircraft, do it here. + +} diff --git a/XPLPro_Arduino/XPLPro/examples/XPLProFlapStatus/XPLProFlapStatus.ino b/XPLPro_Arduino/XPLPro/examples/XPLProFlapStatus/XPLProFlapStatus.ino new file mode 100644 index 0000000..7a6d67c --- /dev/null +++ b/XPLPro_Arduino/XPLPro/examples/XPLProFlapStatus/XPLProFlapStatus.ino @@ -0,0 +1,111 @@ + +/* + * + * XPLProFlapStatus + * + * This example lights LEDs for each position of the flaps on the beechcraft Baron 58, including "In Transit". This + * may or may not work on other aircraft models depending on the values sent at various flap positions, but it should + * work as an example template. + * + * Created by Curiosity Workshop for XPL/Pro arduino->XPlane system. + * + * This sketch was developed and tested on an Arduino Mega. + * + To report problems, download updates and examples, suggest enhancements or get technical support: + + discord: https://discord.gg/RacvaRFsMW + patreon: www.patreon.com/curiosityworkshop + YouTube: https://youtube.com/channel/UCISdHdJIundC-OSVAEPzQIQ + * + * + */ + + +#include + +#include + +XPLPro XP(&Serial); + +#define PINLED_FLAP_TRAN 26 +#define PINLED_FLAP_APP 27 +#define PINLED_FLAP_DOWN 28 + +unsigned drefFlapDeploy; + +void setup() +{ + + + pinMode(PINLED_FLAP_TRAN, OUTPUT); + pinMode(PINLED_FLAP_APP, OUTPUT); + pinMode(PINLED_FLAP_DOWN, OUTPUT); + + Serial.begin(XPL_BAUDRATE); + + XP.begin("Flap LED Example", &xplRegister, &xplShutdown, &xplInboundHandler); + + digitalWrite(PINLED_FLAP_TRAN, LOW); + digitalWrite(PINLED_FLAP_APP, LOW); + digitalWrite(PINLED_FLAP_DOWN, LOW); + } + +void loop() +{ + XP.xloop(); + +} + + +void xplInboundHandler(inStruct *inData) +{ + + if(inData->handle == drefFlapDeploy) + { + + if (inData->inFloat == 0) // Flaps are UP + { setFlapLED(LOW, LOW, LOW); + return; + } + + if (inData->inFloat == 0.5) // Flaps are at APPROACH + { + setFlapLED(LOW, HIGH, LOW); + return; + } + + if (inData->inFloat == 1) // Flaps are DOWN + { setFlapLED(LOW, LOW, HIGH); + return; + } + + setFlapLED(HIGH, LOW, LOW); // In transit is the default + + + } + + + +} + +void setFlapLED(int inTrans, int inApp, int inDown) +{ + digitalWrite(PINLED_FLAP_TRAN, inTrans); + digitalWrite(PINLED_FLAP_APP, inApp); + digitalWrite(PINLED_FLAP_DOWN, inDown); +} + + +void xplRegister() +{ + drefFlapDeploy = XP.registerDataRef(F("sim/cockpit2/controls/flap_handle_deploy_ratio")); + XP.requestUpdates(drefFlapDeploy, 100, .1); + +} + + +void xplShutdown() +{ + +} + diff --git a/XPLPro_Arduino/XPLPro/examples/XPLProGearStatus/XPLProGearStatus.ino b/XPLPro_Arduino/XPLPro/examples/XPLProGearStatus/XPLProGearStatus.ino new file mode 100644 index 0000000..469bc67 --- /dev/null +++ b/XPLPro_Arduino/XPLPro/examples/XPLProGearStatus/XPLProGearStatus.ino @@ -0,0 +1,119 @@ + +/* + * + * XPLProGearStatus + * + * This example lights LEDs for each of the Nose, Left Main, and Right Main landing gear when they are down and locked. + * The dataref associated with the gear position is an array of floats, so this is a good example for that case. + * + * Created by Curiosity Workshop for XPL/Pro arduino->XPlane system. + * + * This sketch was developed and tested on an Arduino Mega. + * + To report problems, download updates and examples, suggest enhancements or get technical support: + + discord: https://discord.gg/RacvaRFsMW + patreon: www.patreon.com/curiosityworkshop + YouTube: https://youtube.com/channel/UCISdHdJIundC-OSVAEPzQIQ + * + * + */ + + +#include + +#include + +XPLPro XP(&Serial); + +#define PIN_GEAR_L 22 +#define PIN_GEAR_R 23 +#define PIN_GEAR_N 24 +#define PIN_GEAR_TRAN 25 + +unsigned drefGearDeploy; +unsigned drefGearUnsafe; + + +void setup() +{ + + pinMode(PIN_GEAR_L, OUTPUT); + pinMode(PIN_GEAR_R, OUTPUT); + pinMode(PIN_GEAR_N, OUTPUT); + pinMode(PIN_GEAR_TRAN, OUTPUT); + + Serial.begin(XPL_BAUDRATE); + + XP.begin("Gear LED", &xplRegister, &xplShutdown, &xplInboundHandler); + digitalWrite(PIN_GEAR_L, LOW); + digitalWrite(PIN_GEAR_R, LOW); + digitalWrite(PIN_GEAR_N, LOW); + digitalWrite(PIN_GEAR_TRAN, LOW); + } + +void loop() +{ + XP.xloop(); + +} + + +void xplInboundHandler(inStruct *inData) +{ + + + //Transition + + if(inData->handle == drefGearUnsafe) + { + if(inData->inLong == 1) digitalWrite(PIN_GEAR_TRAN, HIGH); else digitalWrite(PIN_GEAR_TRAN, LOW); + + } + + //Gear + + if(inData->handle == drefGearDeploy) + { switch (inData->element) + { + case 0: // nose gear + if (inData->inFloat == 1) digitalWrite(PIN_GEAR_N, HIGH); else digitalWrite(PIN_GEAR_N, LOW); + break; + + case 1: // Left Main + if (inData->inFloat == 1) digitalWrite(PIN_GEAR_L, HIGH); else digitalWrite(PIN_GEAR_L, LOW); + break; + + case 2: // Right Main + if (inData->inFloat == 1) digitalWrite(PIN_GEAR_R, HIGH); else digitalWrite(PIN_GEAR_R, LOW); + break; + + } + + } + + + +} + + + +void xplRegister() +{ + + drefGearUnsafe = XP.registerDataRef(F("sim/cockpit2/annunciators/gear_unsafe")); // This dataref is 1 for unsafe, 0 for safe. + XP.requestUpdates(drefGearUnsafe, 100, 1); + + drefGearDeploy = XP.registerDataRef(F("sim/flightmodel2/gear/deploy_ratio")); // This dataref is an array of the position of each landing gear. + XP.requestUpdates(drefGearDeploy, 100, .1, 0); // We are interest in the first 3, 0=Nose, 1 = Left, 2 = Right + XP.requestUpdates(drefGearDeploy, 100, .1, 1); // I am using a precision of .1 so we can tell the difference between Down, Up and somewhere in between. + XP.requestUpdates(drefGearDeploy, 100, .1, 2); + +} + + +void xplShutdown() +{ + +} + diff --git a/XPLPro_Arduino/XPLPro/examples/XPLProMax72XXExample/XPLProMax72XXExample.ino b/XPLPro_Arduino/XPLPro/examples/XPLProMax72XXExample/XPLProMax72XXExample.ino new file mode 100644 index 0000000..427b35e --- /dev/null +++ b/XPLPro_Arduino/XPLPro/examples/XPLProMax72XXExample/XPLProMax72XXExample.ino @@ -0,0 +1,85 @@ + +/* + * + * XPLProMax72XXExample + * + * Created by Curiosity Workshop for XPL/Pro arduino->XPlane system. + * + * This sketch was developed and tested on an Arduino Mega. + * + To report problems, download updates and examples, suggest enhancements or get technical support: + + discord: https://discord.gg/RacvaRFsMW + patreon: www.patreon.com/curiosityworkshop + YouTube: https://youtube.com/channel/UCISdHdJIundC-OSVAEPzQIQ + * + * + */ + +#include +#include // for MAX72xx displays. This is an external library that you need to install. +#include + +XPLPro XP(&Serial); +LedControl myLedDisplays=LedControl(34,36,35,1); // data, clock, cs, number of devices, they can be chained. + +int drefAltitude; // handle to current altitude dataref + +void setup() +{ + Serial.begin(XPL_BAUDRATE); + XP.begin("XPLPro MAX72XX Display Example", &xplRegister, &xplShutdown, &xplInboundHandler); + + myLedDisplays.shutdown(0, false); myLedDisplays.setIntensity(0, 5); // start the LED displays + +} + +void loop() +{ + XP.xloop(); + + //if (millis() % 1000 > 900) digitalWrite(LED_BUILTIN, HIGH); else digitalWrite(LED_BUILTIN, LOW); // Heartbeat +} + +void xplInboundHandler(inStruct *inData) +{ + + if (inData->handle == drefAltitude) { printNumber(0, "% 5.3u", inData->inFloat, 1, &myLedDisplays); return; } + +} + +void xplShutdown() +{ + + myLedDisplays.shutdown(0, true); +} + + +void xplRegister() +{ + + drefAltitude = XP.registerDataRef(F("sim/cockpit2/gauges/indicators/altitude_ft_pilot")); + XP.requestUpdates(drefAltitude, 100, 10); + //XP.registerDataRef(F("sim/cockpit2/switches/strobe_lights_on")) ); + + +} + + + +/* + * prints a number on the MAX 72xx display + */ +void printNumber(int ledDisplay, char *printMask, long int v, int pos, LedControl *lc) +{ +char tString[10]; +int tpos = strlen(tString) + pos; + + sprintf(tString, printMask, v); + for (int i = strlen(tString)-1; i>=0; i--) + { + lc->setChar(ledDisplay, tpos++, tString[i], false); + } + + +} diff --git a/XPLPro_Demo/XPLProMultiDemo.ino b/XPLPro_Arduino/XPLPro/examples/XPLProMultiDemo/XPLProMultiDemo.ino similarity index 92% rename from XPLPro_Demo/XPLProMultiDemo.ino rename to XPLPro_Arduino/XPLPro/examples/XPLProMultiDemo/XPLProMultiDemo.ino index 934be5a..3b54908 100644 --- a/XPLPro_Demo/XPLProMultiDemo.ino +++ b/XPLPro_Arduino/XPLPro/examples/XPLProMultiDemo/XPLProMultiDemo.ino @@ -1,278 +1,281 @@ - - -/* - * - * XPLProMultiDemo - * - * Created by Curiosity Workshop for XPL/Pro arduino->XPlane system. - * - * This sketch was developed and tested on an Arduino Mega. - * - To report problems, download updates and examples, suggest enhancements or get technical support: - - discord: https://discord.gg/RacvaRFsMW - patreon: www.patreon.com/curiosityworkshop - YouTube: https://youtube.com/channel/UCISdHdJIundC-OSVAEPzQIQ - * - * - */ - -#include -#include - -#include // include file for the X-plane direct interface -XPLPro XP(&Serial); // create an instance of it - -LiquidCrystal_I2C lcd(0x26,16,2); -long int startTime; - - -#define PIN_GOAROUND 22 // go around button -#define PIN_GEARTOGGLE 23 // pin for gear toggle - -#define PIN_PAUSE 9 // pin to pause xplane -#define PIN_NAVLIGHT 24 // pin for nav light switch -#define PIN_LANDINGLIGHT 7 // pin for landing light switch -#define PIN_SAYSOMETHING 10 // for demonstration of speech function -#define PIN_THROTTLE1 A0 // throttle 1 -#define PIN_THROTTLE2 A1 // throttle 2 - -#define PIN_LEFTGEARLED 40 // for nose gear LED -#define PIN_NOSEGEARLED 41 // left gear LED -#define PIN_RIGHTGEARLED 42 // right gear LED - - -int drefBeacon; -int drefNavLight, navlightPrevious = -1; -int drefLdgLight; -int drefTaxiLight; -int drefGearDeployed; -int drefThrottle; float throttle1Previous; float throttle2Previous; -int drefEngineRPM; - - -int cmdGearToggle; // a handle for toggling landing gear up and down -int cmdPause; // pause the sim -int cmdToga; // take off/go around - - -void setup() -{ - lcd.init(); - lcd.backlight(); - lcd.setCursor(0,0); - lcd.print("XPLPro Demo!"); - - pinMode(PIN_GEARTOGGLE, INPUT_PULLUP); // if you are doing pin handling yourself you will want a pullup resistor or use the built-in one - pinMode(PIN_NAVLIGHT, INPUT_PULLUP); // otherwise the value will be erratic when the pin is open and nobody likes that. - pinMode(PIN_GOAROUND, INPUT_PULLUP); - pinMode(PIN_LANDINGLIGHT, INPUT_PULLUP); - pinMode(PIN_SAYSOMETHING, INPUT_PULLUP); - pinMode(PIN_PAUSE, INPUT_PULLUP); - - pinMode(LED_BUILTIN, OUTPUT); // built in LED on arduino board for debug and demonstration purposes - pinMode(PIN_LEFTGEARLED, OUTPUT); - pinMode(PIN_NOSEGEARLED, OUTPUT); - pinMode(PIN_RIGHTGEARLED, OUTPUT); - - Serial.begin(XPL_BAUDRATE); // start serial interface. Baudrate is specified in the header, dont change - - /* - needed for initialization. Parameters are: - a texual identifier of your device - your function that will be called when xplane and the plugin are ready for dataref and command registrations - your function that will be called when xplane either shuts down or unloads an aircraft model - your function that will be called when we have requested sends of datarefs that have changed - */ - XP.begin("XPLCore Multi Demo!", ®isterXplaneStuff, &shutdownXplaneStuff, &inboundHandler); - digitalWrite(LED_BUILTIN, LOW); - - -} - - -void loop() -{ - - - - XP.xloop(); // needs to run every cycle. - -/************************************************************************************************************************************ - * everything after the next line will only occur every 100ms. You can also utilize other time values. - * This helps maintain serial data flow and also helps with switch debounce. - * do NOT add delays anywhere in the loop cycle, it will interfere with the reception of serial data from xplane and the plugin. - ************************************************************************************************************************************ -*/ - - if (millis() - startTime > 100) startTime = millis(); else return; - - -/* - * This reads the status of the assigned pins and triggers commands accordingly. It would be best to use a button library for this for debounce and one-shot purposes - * I am not using one for simplicity in the demo. - */ - if (!digitalRead(PIN_GEARTOGGLE)) XP.commandTrigger(cmdGearToggle); - if (!digitalRead(PIN_GOAROUND)) XP.commandTrigger(cmdToga); - if (!digitalRead(PIN_PAUSE)) XP.commandTrigger(cmdPause); - - - if (digitalRead(PIN_NAVLIGHT) != navlightPrevious) // to conserve the flow of data we should keep track of the previously sent value so we don't send a new one every cycle - { - navlightPrevious = digitalRead(PIN_NAVLIGHT); - XP.datarefWrite(drefNavLight, navlightPrevious); - } - - //landingLights = digitalRead(PIN_LANDINGLIGHT); - - - - -/* - * This reads the status of the assigned pin and sends a message to initiation speech. This should probably use a switch library for one-shot so it - * doesnt repeat send/stutter while it is being held down. For now it works for demo purposes. - */ - if (!digitalRead(PIN_SAYSOMETHING)) XP.sendSpeakMessage("speech demonstration"); - -/* - * Read analog position of potentiometers representing throttles. Use the mapfloat function (below) to change the read value 0-1024 to a float 0.0 - 1.0 - * In this case the throttle dataref is an array, so we specify which element of the array as the third parameter of datarefWrite. - * We also should track and compare to the previous value so that we don't send the same value every cycle. - */ - int throttle1Current = analogRead(PIN_THROTTLE1) /10; // I am dividing by 10 here because I don't need 1024 units of resolution for the throttle position and this will reduce dataflow. - if (throttle1Current != throttle1Previous) - { - throttle1Previous = throttle1Current; - XP.datarefWrite(drefThrottle, throttle1Current, 0); // we already requested scaling (map) from the plugin so just send the raw data. - } - - int throttle2Current = analogRead(PIN_THROTTLE2) /10; - if (throttle2Current != throttle2Previous) - { - throttle2Previous = throttle2Current; - XP.datarefWrite(drefThrottle, throttle2Current, 1); - } - - - -} - -/* - * This function is the callback function we specified that will be called any time our requested data is sent to us. - * handle is the handle to the dataref. The following variables within the plugin are how we receive the data: - * - * readValueLong If the dataref is of type INT - * readValueFloat If the dataref is of type FLOAT - * readValueElement If the dataref is an array, this is the element that changed - */ -void inboundHandler(inStruct *inData) -{ - if (inData->handle == drefBeacon) - { if (inData->inLong) digitalWrite(LED_BUILTIN, HIGH); // if beacon is on set the builtin led on - else digitalWrite(LED_BUILTIN, LOW); - } - - if (inData->handle == drefEngineRPM) // display RPM on the LCD - { lcd.setCursor(0,1); - lcd.print("Alt: "); - lcd.print((int)inData->inFloat); // casted to INT to remove decimals - } - -/* - * This reads the status of the landing gear. You could turn on lights as in this example. The position is represented as a float between 0 and 1, 1 representing down and locked. - */ - if (inData->handle == drefGearDeployed) - { switch (inData->element ) - { - case 0: // nose gear - if (inData->inFloat == 1) digitalWrite(PIN_NOSEGEARLED, HIGH); else digitalWrite(PIN_NOSEGEARLED, LOW); - break; - - case 1: // Left Main - if (inData->inFloat == 1) digitalWrite(PIN_LEFTGEARLED, HIGH); else digitalWrite(PIN_LEFTGEARLED, LOW); - break; - - case 2: // Right Main - if (inData->inFloat == 1) digitalWrite(PIN_RIGHTGEARLED, HIGH); else digitalWrite(PIN_RIGHTGEARLED, LOW); - break; - - } - } - - - -} - -void registerXplaneStuff() // this is the function we set as a callback for when the plugin is ready to receive dataref and command bindings requests -{ - - - -/* - * This example registers a dataref for the beacon light. - * In the loop section of the code we will turn on/off the LED on the arduino board to represent the status of the beacon light within xplane. - * On non-AVR boards remove the F() macro. - * - */ - drefBeacon = XP.registerDataRef(F("sim/cockpit2/switches/beacon_on") ); - XP.requestUpdates(drefBeacon, 100, 0); // Tell xplane to send us updates when the status of the beacon light changes. - // 100 means don't update more often than every 100ms and 0 is a resolution divider which is explained in another dataref, use 0 if no divider required - - -/* - * This example registers a dataref for the nav light. This time we will control the status of the light with a switch. - * It is up to you to confirm that the datarefs you utilize are writable. A handy website allows you to search - * for them and understand their attributes: https://developer.x-plane.com/datarefs/ - * - * In the loop section of the code we will check the status of the switch send it to the navLight dataref within Xplane. - * To test this, connect one side of a normal toggle switch to ground and the other to the pin used in the #define for PIN_NAVLIGHT (9) - */ - drefNavLight = XP.registerDataRef(F("sim/cockpit/electrical/nav_lights_on") ); - - -/* - * The text for the names of datarefs and commands can be a large memory hit for many arduino boards. Here are some ways to reduce the impact: - * - * This first one utilizes abbreviations. In the folder where the XPLDirect plugin is installed there is a file called abbreviations.txt. You can add abbreviations to this as you like. - * The plugin will search for the abbreviation string you use for dataref names and command names, then convert them to the full length specified. Example: - * - * LTland = sim/cockpit/electrical/landing_lights_on - * - * This comes preset in the distrubution version of the abbreviations.txt file so we will try it in the example: - */ - drefLdgLight = XP.registerDataRef(F("LTland") ); // "LTland" will be converted to "sim/cockpit/electrical/landing_lights_on" - drefTaxiLight = XP.registerDataRef(F("LTtaxi")); - - -/* - * more examples for the testing box - */ - drefGearDeployed = XP.registerDataRef(F("sim/flightmodel2/gear/deploy_ratio") ); // this will be updated from xplane to tell us what position the landing gear is in - XP.requestUpdates(drefGearDeployed, 100, 1, 0); // Tell xplane to send us updates when the status of the gear position changes. - XP.requestUpdates(drefGearDeployed, 100, 1, 1); // 100 means don't update more often than every 100ms and .1 is a resolution divider to reduce data flow. eg we probably arent interested in .001 of gear position. - XP.requestUpdates(drefGearDeployed, 100, 1, 2); // The additional parameter is the array element to reference, since this dataref is an array of values. 0=nose, 1=left, 2=right - - drefThrottle = XP.registerDataRef(F("sim/cockpit2/engine/actuators/throttle_ratio") ); // This is an array dataref. We will be sending this data from a potentiometer - XP.setScaling(drefThrottle, 0, 102, 0, 1); // this uses a map style function to convert values 0-102 to a float value of 0-1. Since analogRead returns 0-1024, we will divide it - // by 10 when we read it then convert 0-102 to a float value of 0-1. - - drefEngineRPM = XP.registerDataRef(F("sim/cockpit2/gauges/indicators/altitude_ft_pilot") ); // indicated altitude for display on the LCD screen. This is a float - XP.requestUpdates(drefEngineRPM, 100, 10); // divide by 10 to show increments of 10 feet - - -/* - * Now register commands. - * - */ - cmdPause = XP.registerCommand(F("sim/operation/pause_toggle") ); - cmdToga = XP.registerCommand(F("sim/autopilot/take_off_go_around") ); - cmdGearToggle = XP.registerCommand(F("sim/flight_controls/landing_gear_toggle") ); - - -} - -void shutdownXplaneStuff() -{ - // if you need to do things when xplane shuts down or unloads an aircraft, do it here. - -} + + +/* + * + * XPLProMultiDemo + * + * Created by Curiosity Workshop for XPL/Pro arduino->XPlane system. + * + * This sketch was developed and tested on an Arduino Mega. + * + To report problems, download updates and examples, suggest enhancements or get technical support: + + discord: https://discord.gg/RacvaRFsMW + patreon: www.patreon.com/curiosityworkshop + YouTube: https://youtube.com/channel/UCISdHdJIundC-OSVAEPzQIQ + * + * + */ + +#include +#include + +#include // include file for the X-plane direct interface +XPLPro XP(&Serial); // create an instance of it + +LiquidCrystal_I2C lcd(0x26,16,2); + + +long int startTime; + + +#define PIN_GOAROUND 22 // go around button +#define PIN_GEARTOGGLE 23 // pin for gear toggle + +#define PIN_PAUSE 9 // pin to pause xplane +#define PIN_NAVLIGHT 24 // pin for nav light switch +#define PIN_LANDINGLIGHT 7 // pin for landing light switch +#define PIN_SAYSOMETHING 10 // for demonstration of speech function +#define PIN_THROTTLE1 A0 // throttle 1 +#define PIN_THROTTLE2 A1 // throttle 2 + +#define PIN_LEFTGEARLED 40 // for nose gear LED +#define PIN_NOSEGEARLED 41 // left gear LED +#define PIN_RIGHTGEARLED 42 // right gear LED + + +int drefBeacon; +int drefNavLight, navlightPrevious = -1; +int drefLdgLight; +int drefTaxiLight; +int drefGearDeployed; +int drefThrottle; float throttle1Previous; float throttle2Previous; +int drefEngineRPM; + + +int cmdGearToggle; // a handle for toggling landing gear up and down +int cmdPause; // pause the sim +int cmdToga; // take off/go around + + +void setup() +{ + lcd.init(); + lcd.backlight(); + lcd.setCursor(0,0); + lcd.print("XPLPro Demo!"); + + pinMode(PIN_GEARTOGGLE, INPUT_PULLUP); // if you are doing pin handling yourself you will want a pullup resistor or use the built-in one + pinMode(PIN_NAVLIGHT, INPUT_PULLUP); // otherwise the value will be erratic when the pin is open and nobody likes that. + pinMode(PIN_GOAROUND, INPUT_PULLUP); + pinMode(PIN_LANDINGLIGHT, INPUT_PULLUP); + pinMode(PIN_SAYSOMETHING, INPUT_PULLUP); + pinMode(PIN_PAUSE, INPUT_PULLUP); + + pinMode(LED_BUILTIN, OUTPUT); // built in LED on arduino board for debug and demonstration purposes + pinMode(PIN_LEFTGEARLED, OUTPUT); + pinMode(PIN_NOSEGEARLED, OUTPUT); + pinMode(PIN_RIGHTGEARLED, OUTPUT); + + Serial.begin(XPL_BAUDRATE); // start serial interface. Baudrate is specified in the header, dont change + + /* + needed for initialization. Parameters are: + a texual identifier of your device + your function that will be called when xplane and the plugin are ready for dataref and command registrations + your function that will be called when xplane either shuts down or unloads an aircraft model + your function that will be called when we have requested sends of datarefs that have changed + */ + XP.begin("XPLPro Multi Demo!", &xplRegister, &xplShutdown, &xplInboundHandler); + digitalWrite(LED_BUILTIN, LOW); + + +} + + +void loop() +{ + + + + XP.xloop(); // needs to run every cycle. + +/************************************************************************************************************************************ + * everything after the next line will only occur every 100ms. You can also utilize other time values. + * This helps maintain serial data flow and also helps with switch debounce. + * do NOT add delays anywhere in the loop cycle, it will interfere with the reception of serial data from xplane and the plugin. + ************************************************************************************************************************************ +*/ + + if (millis() - startTime > 100) startTime = millis(); else return; + + +/* + * This reads the status of the assigned pins and triggers commands accordingly. It would be best to use a button library for this for debounce and one-shot purposes + * I am not using one for simplicity in the demo. + */ + if (!digitalRead(PIN_GEARTOGGLE)) XP.commandTrigger(cmdGearToggle); + if (!digitalRead(PIN_GOAROUND)) XP.commandTrigger(cmdToga); + if (!digitalRead(PIN_PAUSE)) XP.commandTrigger(cmdPause); + + + if (digitalRead(PIN_NAVLIGHT) != navlightPrevious) // to conserve the flow of data we should keep track of the previously sent value so we don't send a new one every cycle + { + navlightPrevious = digitalRead(PIN_NAVLIGHT); + XP.datarefWrite(drefNavLight, navlightPrevious); + } + + //landingLights = digitalRead(PIN_LANDINGLIGHT); + + + + +/* + * This reads the status of the assigned pin and sends a message to initiation speech. This should probably use a switch library for one-shot so it + * doesnt repeat send/stutter while it is being held down. For now it works for demo purposes. + */ + if (!digitalRead(PIN_SAYSOMETHING)) XP.sendSpeakMessage("speech demonstration"); + +/* + * Read analog position of potentiometers representing throttles. Use the mapfloat function (below) to change the read value 0-1024 to a float 0.0 - 1.0 + * In this case the throttle dataref is an array, so we specify which element of the array as the third parameter of datarefWrite. + * We also should track and compare to the previous value so that we don't send the same value every cycle. + */ + int throttle1Current = analogRead(PIN_THROTTLE1) /10; // I am dividing by 10 here because I don't need 1024 units of resolution for the throttle position and this will reduce dataflow. + if (throttle1Current != throttle1Previous) + { + throttle1Previous = throttle1Current; + XP.datarefWrite(drefThrottle, throttle1Current, 0); // we already requested scaling (map) from the plugin so just send the raw data. + } + + int throttle2Current = analogRead(PIN_THROTTLE2) /10; + if (throttle2Current != throttle2Previous) + { + throttle2Previous = throttle2Current; + XP.datarefWrite(drefThrottle, throttle2Current, 1); + } + + + +} + +/* + * This function is the callback function we specified that will be called any time our requested data is sent to us. + * handle is the handle to the dataref. The following values are transfered to the callback through inStruct: + * + * int inData->handle The handle of the incoming dataref + * int inData->element If the dataref is an array style dataref, this is the element of the array + * long inData->inLong long value for datarefs that are long values + * float inData->inFloat float value for datarefs that are float values + */ +void xplInboundHandler(inStruct *inData) +{ + if (inData->handle == drefBeacon) + { if (inData->inLong) digitalWrite(LED_BUILTIN, HIGH); // if beacon is on set the builtin led on + else digitalWrite(LED_BUILTIN, LOW); + } + + if (inData->handle == drefEngineRPM) // display RPM on the LCD + { lcd.setCursor(0,1); + lcd.print("Alt: "); + lcd.print((int)inData->inFloat); // casted to INT to remove decimals + } + +/* + * This reads the status of the landing gear. You could turn on lights as in this example. The position is represented as a float between 0 and 1, 1 representing down and locked. + */ + if (inData->handle == drefGearDeployed) + { switch (inData->element ) + { + case 0: // nose gear + if (inData->inFloat == 1) digitalWrite(PIN_NOSEGEARLED, HIGH); else digitalWrite(PIN_NOSEGEARLED, LOW); + break; + + case 1: // Left Main + if (inData->inFloat == 1) digitalWrite(PIN_LEFTGEARLED, HIGH); else digitalWrite(PIN_LEFTGEARLED, LOW); + break; + + case 2: // Right Main + if (inData->inFloat == 1) digitalWrite(PIN_RIGHTGEARLED, HIGH); else digitalWrite(PIN_RIGHTGEARLED, LOW); + break; + + } + } + + + +} + +void xplRegister() // this is the function we set as a callback for when the plugin is ready to receive dataref and command bindings requests +{ + + + +/* + * This example registers a dataref for the beacon light. + * In the loop section of the code we will turn on/off the LED on the arduino board to represent the status of the beacon light within xplane. + * On non-AVR boards remove the F() macro. + * + */ + drefBeacon = XP.registerDataRef(F("sim/cockpit2/switches/beacon_on") ); + XP.requestUpdates(drefBeacon, 100, 0); // Tell xplane to send us updates when the status of the beacon light changes. + // 100 means don't update more often than every 100ms and 0 is a resolution divider which is explained in another dataref, use 0 if no divider required + + +/* + * This example registers a dataref for the nav light. This time we will control the status of the light with a switch. + * It is up to you to confirm that the datarefs you utilize are writable. A handy website allows you to search + * for them and understand their attributes: https://developer.x-plane.com/datarefs/ + * + * In the loop section of the code we will check the status of the switch send it to the navLight dataref within Xplane. + * To test this, connect one side of a normal toggle switch to ground and the other to the pin used in the #define for PIN_NAVLIGHT (9) + */ + drefNavLight = XP.registerDataRef(F("sim/cockpit/electrical/nav_lights_on") ); + + +/* + * The text for the names of datarefs and commands can be a large memory hit for many arduino boards. Here are some ways to reduce the impact: + * + * This first one utilizes abbreviations. In the folder where the XPLDirect plugin is installed there is a file called abbreviations.txt. You can add abbreviations to this as you like. + * The plugin will search for the abbreviation string you use for dataref names and command names, then convert them to the full length specified. Example: + * + * LTland = sim/cockpit/electrical/landing_lights_on + * + * This comes preset in the distrubution version of the abbreviations.txt file so we will try it in the example: + */ + drefLdgLight = XP.registerDataRef(F("LTland") ); // "LTland" will be converted to "sim/cockpit/electrical/landing_lights_on" + drefTaxiLight = XP.registerDataRef(F("LTtaxi")); + + +/* + * more examples for the testing box + */ + drefGearDeployed = XP.registerDataRef(F("sim/flightmodel2/gear/deploy_ratio") ); // this will be updated from xplane to tell us what position the landing gear is in + XP.requestUpdates(drefGearDeployed, 100, 1, 0); // Tell xplane to send us updates when the status of the gear position changes. + XP.requestUpdates(drefGearDeployed, 100, 1, 1); // 100 means don't update more often than every 100ms and .1 is a resolution divider to reduce data flow. eg we probably arent interested in .001 of gear position. + XP.requestUpdates(drefGearDeployed, 100, 1, 2); // The additional parameter is the array element to reference, since this dataref is an array of values. 0=nose, 1=left, 2=right + + drefThrottle = XP.registerDataRef(F("sim/cockpit2/engine/actuators/throttle_ratio") ); // This is an array dataref. We will be sending this data from a potentiometer + XP.setScaling(drefThrottle, 0, 102, 0, 1); // this uses a map style function to convert values 0-102 to a float value of 0-1. Since analogRead returns 0-1024, we will divide it + // by 10 when we read it then convert 0-102 to a float value of 0-1. + + drefEngineRPM = XP.registerDataRef(F("sim/cockpit2/gauges/indicators/altitude_ft_pilot") ); // indicated altitude for display on the LCD screen. This is a float + XP.requestUpdates(drefEngineRPM, 100, 10); // divide by 10 to show increments of 10 feet + + +/* + * Now register commands. + * + */ + cmdPause = XP.registerCommand(F("sim/operation/pause_toggle") ); + cmdToga = XP.registerCommand(F("sim/autopilot/take_off_go_around") ); + cmdGearToggle = XP.registerCommand(F("sim/flight_controls/landing_gear_toggle") ); + + +} + +void xplShutdown() +{ + // if you need to do things when xplane shuts down or unloads an aircraft, do it here. + +} diff --git a/XPLPro_Arduino/XPLPro/examples/XPLProMultiplexerExample/Multiplexer Wiring Diagram.jpg b/XPLPro_Arduino/XPLPro/examples/XPLProMultiplexerExample/Multiplexer Wiring Diagram.jpg new file mode 100644 index 0000000..d48a3e4 Binary files /dev/null and b/XPLPro_Arduino/XPLPro/examples/XPLProMultiplexerExample/Multiplexer Wiring Diagram.jpg differ diff --git a/XPLPro_Arduino/XPLPro/examples/XPLProMultiplexerExample/XPLProMultiplexerExample.ino b/XPLPro_Arduino/XPLPro/examples/XPLProMultiplexerExample/XPLProMultiplexerExample.ino new file mode 100644 index 0000000..6ffa270 --- /dev/null +++ b/XPLPro_Arduino/XPLPro/examples/XPLProMultiplexerExample/XPLProMultiplexerExample.ino @@ -0,0 +1,101 @@ + +/* + * + * XPLProMultiplexerExample + * + * Created by Curiosity Workshop for XPL/Pro arduino->XPlane system. + * + * This sketch was developed and tested on an Arduino Mega. + * This sketch was originally accompanied with a sample wiring diagram within the folder. + * + To report problems, download updates and examples, suggest enhancements or get technical support: + + discord: https://discord.gg/RacvaRFsMW + patreon: www.patreon.com/curiosityworkshop + YouTube: https://youtube.com/channel/UCISdHdJIundC-OSVAEPzQIQ + * + * + */ + +#include + +#include +#include + + +#define MUX1PIN_BEACON 0 +#define MUX1PIN_NAV 1 +#define MUX1PIN_STROBE 2 +#define MUX1PIN_LEDSWITCH 3 +#define MUX1PIN_STARTER 5 + +XPLPro XP(&Serial); + +void muxHandler(int muxChannel, int muxValue); +XPLMux4067Switches mux1(7, 3, 4, 5, 6, &muxHandler); // multiplexer signal is on 7 and select pins are 3-6. muxHandler can be NULL if you don't intend to use it. + // eg: XPLMux4067Switches mux1(7, 3, 4, 5, 6, NULL); + + +void setup() +{ + Serial.begin(XPL_BAUDRATE); + XP.begin("XPLPro Multiplexer Example", &xplRegister, &xplShutdown, &xplInboundHandler); + + mux1.begin(&XP); + pinMode(LED_BUILTIN, OUTPUT); + +} + +void loop() +{ + XP.xloop(); + mux1.check(); +//if (millis() % 1000 > 900) digitalWrite(LED_BUILTIN, HIGH); else digitalWrite(LED_BUILTIN, LOW); // Heartbeat +} + +void xplInboundHandler(inStruct *inData) +{ +} + + +void xplShutdown() +{ + + +} + +void xplRegister() +{ + mux1.clear(); // Reset switches + + mux1.addPin(MUX1PIN_BEACON, XPLMUX4067_COMMANDTRIGGER, XP.registerCommand(F("sim/lights/beacon_lights_toggle")) ); + mux1.addPin(MUX1PIN_STARTER, XPLMUX4067_COMMANDSTARTEND, XP.registerCommand(F("sim/engines/engage_starters")) ); + mux1.addPin(MUX1PIN_NAV, XPLMUX4067_DATAREFWRITE, XP.registerDataRef(F("sim/cockpit2/switches/navigation_lights_on")) ); + mux1.addPin(MUX1PIN_STROBE, XPLMUX4067_DATAREFWRITE_INVERT, XP.registerDataRef(F("sim/cockpit2/switches/strobe_lights_on")) ); + mux1.addPin(MUX1PIN_LEDSWITCH, XPLMUX4067_SENDTOHANDLER, 0 ); // this only sends the mux event to the handler. +} + +void muxHandler(int inPin, int inValue) +{ + + +// Process inbound mux signal. Use this if you have other uses for the incoming mux pins. +// Every mux pin event will call this after it triggers the xplane commands/dataref changes. +// I could also specify XPLMUX4067_SENDTOHANDLER when adding the pin, if I dont want anything done automatically and it will only call here. + + switch (inPin) + { + case MUX1PIN_LEDSWITCH : // all that will happen is the builtin LED will track the position of the switch + digitalWrite(LED_BUILTIN, !inValue); + break; + + case MUX1PIN_STROBE : // the dataref was already updated, but we can add functionality. + if (inValue == 0) XP.sendSpeakMessage("Strobe ON"); + if (inValue == 1) XP.sendSpeakMessage("Strobe OFF"); + break; + } + +} + + + diff --git a/XPLPro_Arduino/XPLPro/examples/XPLProMultiplexerExample/multiplexer wiring diagram.fzz b/XPLPro_Arduino/XPLPro/examples/XPLProMultiplexerExample/multiplexer wiring diagram.fzz new file mode 100644 index 0000000..83bfa65 Binary files /dev/null and b/XPLPro_Arduino/XPLPro/examples/XPLProMultiplexerExample/multiplexer wiring diagram.fzz differ diff --git a/XPLPro_Arduino/XPLPro/examples/XPLProParkingBrakeDemo/XPLProParkingBrakeDemo.ino b/XPLPro_Arduino/XPLPro/examples/XPLProParkingBrakeDemo/XPLProParkingBrakeDemo.ino new file mode 100644 index 0000000..56d8e4b --- /dev/null +++ b/XPLPro_Arduino/XPLPro/examples/XPLProParkingBrakeDemo/XPLProParkingBrakeDemo.ino @@ -0,0 +1,117 @@ + + +/* + * + * XPLProParkingBrakeDemo + * This example will light up a properly installed LED on a specified arduino pin, or you could use the built-in LED + * usually on pin 13. + * + * Created by Curiosity Workshop for XPL/Pro arduino->XPlane system. + * + * This sketch was developed and tested on an Arduino Mega in response to a user request. + * + To report problems, download updates and examples, suggest enhancements or get technical support: + + discord: https://discord.gg/RacvaRFsMW + patreon: www.patreon.com/curiosityworkshop + YouTube: https://youtube.com/channel/UCISdHdJIundC-OSVAEPzQIQ + * + * + */ + +#include +#include // include file for the X-plane direct interface +XPLPro XP(&Serial); // create an instance of it + + +long int startTime; + +#define PINLED_PARKINGBRAKE 13 + +int drefParkingBrake; // this stores a handle to the parking brake dataref + +void setup() +{ + + pinMode(PINLED_PARKINGBRAKE, OUTPUT); // built in LED on arduino board will turn on and off with the status of the beacon light + + Serial.begin(XPL_BAUDRATE); // start serial interface. Baudrate is specified in the header, dont change + + /* + needed for initialization. Parameters are: + a texual identifier of your device + your function that will be called when xplane and the plugin are ready for dataref and command registrations + your function that will be called when xplane either shuts down or unloads an aircraft model + your function that will be called when we have requested sends of datarefs that have changed + */ + XP.begin("XPLPro Parking Brake Demo!", &xplRegister, &xplShutdown, &xplInboundHandler); + digitalWrite(PINLED_PARKINGBRAKE, LOW); + + +} + + +void loop() +{ + + XP.xloop(); // needs to run every cycle. + +/************************************************************************************************************************************ + * everything after the next line will only occur every 100ms. You can also utilize other time values. + * This helps maintain serial data flow and also helps with switch debounce. + * do NOT add delays anywhere in the loop cycle, it will interfere with the reception of serial data from xplane and the plugin. + ************************************************************************************************************************************ +*/ + + if (millis() - startTime > 100) startTime = millis(); else return; + +} + +/* + * This function is the callback function we specified that will be called any time our requested data is sent to us. + * handle is the handle to the dataref. The following variables within the plugin are how we receive the data: + * + * inStruct *inData is a pointer to a structure that contains information about the incoming dataref. + * + * int inData->handle The handle of the incoming dataref + * int inData->element If the dataref is an array style dataref, this is the element of the array + * long inData->inLong long value for datarefs that are long values + * float inData->inFloat float value for datarefs that are float values + */ + void xplInboundHandler(inStruct *inData) +{ + if (inData->handle == drefParkingBrake) + { if (inData->inFloat > .2) digitalWrite(PINLED_PARKINGBRAKE, HIGH); // if parking brake is set turn the LED on + else digitalWrite(PINLED_PARKINGBRAKE, LOW); + + + } + + +} + +/* + * this is the function we set as a callback for when the plugin is ready to receive dataref and command bindings requests + * It could be called multiple times if for instance xplane is restarted or loads a different aircraft + */ +void xplRegister() +{ +/* + * This example registers a dataref for the beacon light. + * In the inbound handler section of the code we will turn on/off the LED on the arduino board to represent the status of the beacon light within xplane. + * On non-AVR boards remove the F() macro. + * + */ + drefParkingBrake = XP.registerDataRef(F("sim/cockpit2/controls/parking_brake_ratio") ); + XP.requestUpdates(drefParkingBrake, 100, .1); // Tell xplane to send us updates when the status of the parking brake changes. + // 100 means don't update more often than every 100ms and .1 is a precision specifier for float variables which is explained in another example, use .1 for this example + + + +} + +void xplShutdown() +{ + // if you need to do things when xplane shuts down or unloads an aircraft, do it here. + +} diff --git a/XPLPro_Arduino/XPLPro/examples/XPLProPotentiometersExample/Circuit Layout.fzz b/XPLPro_Arduino/XPLPro/examples/XPLProPotentiometersExample/Circuit Layout.fzz new file mode 100644 index 0000000..75d7a92 Binary files /dev/null and b/XPLPro_Arduino/XPLPro/examples/XPLProPotentiometersExample/Circuit Layout.fzz differ diff --git a/XPLPro_Arduino/XPLPro/examples/XPLProPotentiometersExample/Circuit Layout.jpg b/XPLPro_Arduino/XPLPro/examples/XPLProPotentiometersExample/Circuit Layout.jpg new file mode 100644 index 0000000..9de2332 Binary files /dev/null and b/XPLPro_Arduino/XPLPro/examples/XPLProPotentiometersExample/Circuit Layout.jpg differ diff --git a/XPLPro_Arduino/XPLPro/examples/XPLProPotentiometersExample/XPLProPotentiometersExample.ino b/XPLPro_Arduino/XPLPro/examples/XPLProPotentiometersExample/XPLProPotentiometersExample.ino new file mode 100644 index 0000000..1678aa5 --- /dev/null +++ b/XPLPro_Arduino/XPLPro/examples/XPLProPotentiometersExample/XPLProPotentiometersExample.ino @@ -0,0 +1,92 @@ + +/* + * + * XPLProPotentiometersExample + * + * Created by Curiosity Workshop for XPL/Pro arduino->XPlane system. + * + * This sketch was developed and tested on an Arduino Mega. + * + To report problems, download updates and examples, suggest enhancements or get technical support: + + discord: https://discord.gg/RacvaRFsMW + patreon: www.patreon.com/curiosityworkshop + YouTube: https://youtube.com/channel/UCISdHdJIundC-OSVAEPzQIQ + * + * + */ + +#include + +#include + +#define XPLPOTS_MAXPOTS 3 // adjust this as required for your needs. Higher number of course costs memory. Default is 10 if not specified +#include + + +#define PIN_THROTTLE A0 +#define PIN_MIXTURE A1 + + +XPLPro XP(&Serial); + +void potHandler(int pin, float potValue); +XPLPotentiometers pots(&potHandler); // potHandler is a function that will be called if we want to provide additional functionality. It can also be NULL if not needed. + +void setup() +{ + Serial.begin(XPL_BAUDRATE); + XP.begin("XPLPro Potentiometer Example", &xplRegister, &xplShutdown, &xplInboundHandler); + + pinMode(LED_BUILTIN, OUTPUT); + digitalWrite(LED_BUILTIN, LOW); + + pots.begin(&XP); + +} + +void loop() +{ + XP.xloop(); + pots.check(); + //if (millis() % 1000 > 900) digitalWrite(LED_BUILTIN, HIGH); else digitalWrite(LED_BUILTIN, LOW); // Heartbeat +} + +void xplInboundHandler(inStruct *inData) +{ + +} + +void xplShutdown() +{ + + +} + + +void xplRegister() +{ + pots.clear(); // Reset pots + + pots.addPin(PIN_THROTTLE, XPLPOTS_DATAREFWRITE, XP.registerDataRef(F("sim/cockpit2/engine/actuators/throttle_ratio_all")), 10 ,0, 1024, 0, 1); + pots.addPin(PIN_MIXTURE, XPLPOTS_DATAREFWRITE, XP.registerDataRef(F("sim/cockpit2/engine/actuators/mixture_ratio_all")), 10, 0, 1024, 0, 1 ); + + +} + +void potHandler(int inPin, float inValue) +{ + +// Process inbound potentiometer events. Use this if you have other uses for the incoming data. +// Every registered event will call this after it sends the value to xplane. +// I could also specify XPLPOTS_SENDTOHANDLER when adding the pin, if I dont want anything done automatically and it will only call here. + + switch (inPin) + { + case PIN_THROTTLE : + // do something cool + break; + + } + +} diff --git a/XPLPro_Arduino/XPLPro/examples/XPLProPotentiometersExample/build1.jpg b/XPLPro_Arduino/XPLPro/examples/XPLProPotentiometersExample/build1.jpg new file mode 100644 index 0000000..df41723 Binary files /dev/null and b/XPLPro_Arduino/XPLPro/examples/XPLProPotentiometersExample/build1.jpg differ diff --git a/XPLPro_Arduino/XPLPro/examples/XPLProPotentiometersExample/build2.jpg b/XPLPro_Arduino/XPLPro/examples/XPLProPotentiometersExample/build2.jpg new file mode 100644 index 0000000..a0f907e Binary files /dev/null and b/XPLPro_Arduino/XPLPro/examples/XPLProPotentiometersExample/build2.jpg differ diff --git a/XPLPro_Arduino/XPLPro/examples/XPLProPotentiometersExample/build3.jpg b/XPLPro_Arduino/XPLPro/examples/XPLProPotentiometersExample/build3.jpg new file mode 100644 index 0000000..8c46d81 Binary files /dev/null and b/XPLPro_Arduino/XPLPro/examples/XPLProPotentiometersExample/build3.jpg differ diff --git a/XPLPro_Arduino/XPLPro/examples/XPLProRadioBox/Circuit Layout.fzz b/XPLPro_Arduino/XPLPro/examples/XPLProRadioBox/Circuit Layout.fzz new file mode 100644 index 0000000..fb080ee Binary files /dev/null and b/XPLPro_Arduino/XPLPro/examples/XPLProRadioBox/Circuit Layout.fzz differ diff --git a/XPLPro_Arduino/XPLPro/examples/XPLProRadioBox/Circuit Layout_bb.jpg b/XPLPro_Arduino/XPLPro/examples/XPLProRadioBox/Circuit Layout_bb.jpg new file mode 100644 index 0000000..953ef08 Binary files /dev/null and b/XPLPro_Arduino/XPLPro/examples/XPLProRadioBox/Circuit Layout_bb.jpg differ diff --git a/XPLPro_Arduino/XPLPro/examples/XPLProRadioBox/XPLProRadioBox.ino b/XPLPro_Arduino/XPLPro/examples/XPLProRadioBox/XPLProRadioBox.ino new file mode 100644 index 0000000..856fd3c --- /dev/null +++ b/XPLPro_Arduino/XPLPro/examples/XPLProRadioBox/XPLProRadioBox.ino @@ -0,0 +1,579 @@ +/* + * + * XPLProRadioBox + * + * Created by Curiosity Workshop for XPL/Pro arduino->XPlane system. + * + * This sketch was developed and tested on an Arduino Mega. + * + * Video of this sketch in action: https://youtu.be/T1LJyjB_sV8 + * + * To report problems, download updates and examples, suggest enhancements or get technical support: + * + * discord: https://discord.gg/RacvaRFsMW + * patreon: www.patreon.com/curiosityworkshop + * YouTube: https://youtube.com/channel/UCISdHdJIundC-OSVAEPzQIQ + * + * + */ + +#include +#include +#include +#include // include file for the X-plane direct interface + +XPLPro XP(&Serial); // create an instance of it + +using namespace ace_button; +void handleButton(AceButton* button, uint8_t eventType, uint8_t /*buttonState*/) ; // header for button callback + +/** + * Get the current radio mode according to the rotary switch + */ + + #define MODE_COM1 0 + #define MODE_COM2 1 + #define MODE_NAV1 2 + #define MODE_NAV2 3M + #define MODE_XPDR 4 + #define MODE_ADF1 5 + #define MODE_MAX 5 + +#define PIN_ENCODER1_A 18 +#define PIN_ENCODER1_B 19 +#define PIN_BUTTON_ENCODER1 16 + +#define PIN_BUTTON_MODE 7 +#define PIN_BUTTON_FLIP 9 + +LiquidCrystal_I2C lcd(0x26,16,2); // Adjust this to match your LCD +Encoder encoder1(PIN_ENCODER1_A, PIN_ENCODER1_B); + +AceButton encoder1Button(PIN_BUTTON_ENCODER1); +AceButton modeButton(PIN_BUTTON_MODE); +AceButton flopButton(PIN_BUTTON_FLIP); + +int cmdCom1CourseDown; +int cmdCom1CourseUp; +int cmdCom1FineDown; +int cmdCom1FineUp; + +int cmdCom2CourseDown; +int cmdCom2CourseUp; +int cmdCom2FineDown; +int cmdCom2FineUp; + +int cmdNav1CourseDown; +int cmdNav1CourseUp; +int cmdNav1FineDown; +int cmdNav1FineUp; + +int cmdNav2CourseDown; +int cmdNav2CourseUp; +int cmdNav2FineDown; +int cmdNav2FineUp; + +int cmdXpdr12Down; +int cmdXpdr12Up; +int cmdXpdr34Down; +int cmdXpdr34Up; + +int cmdAdf110Down; +int cmdAdf110Up; +int cmdAdfOTDown; +int cmdAdfOTUp; +int cmdCom1Flip; +int cmdCom2Flip; +int cmdNav1Flip; +int cmdNav2Flip; +int cmdAdf1Flip; + +int drefCom1Freq; +int drefCom1StbyFreq; +int drefCom2Freq; +int drefCom2StbyFreq; + +int drefNav1Freq; +int drefNav1StbyFreq; +int drefNav2Freq; +int drefNav2StbyFreq; + +int drefXpdrCode; +int drefXpdrMode; + +int drefADFFreq; +int drefADFstbyFreq; + + + + +long int Com1 = 0; +long int Com1st = 0; +long int Com2 = 0; +long int Com2st = 0; +long int Nav1 = 0; +long int Nav1st = 0; +long int Nav2 = 0; +long int Nav2st = 0; +long int Adf1 = 0; +long int Adf1st = 0; + +long int Xpdr = 0; +long int xpdrMode = 0; + +int mode = 0; +int encMode = 0; + +int encoderPos; + + +//------------------------------------------ +void setup() +{ + + lcd.init(); + lcd.backlight(); + + mode = MODE_COM1; + + pinMode(PIN_BUTTON_MODE, INPUT_PULLUP); + pinMode(PIN_BUTTON_FLIP, INPUT_PULLUP); + pinMode(PIN_BUTTON_ENCODER1, INPUT_PULLUP); + + + // Configure the ButtonConfig with the event handler. + ButtonConfig* buttonConfig = ButtonConfig::getSystemButtonConfig(); + buttonConfig->setEventHandler(handleButton); + buttonConfig->setFeature(ButtonConfig::kFeatureLongPress); + buttonConfig->setFeature(ButtonConfig::kFeatureRepeatPress); + buttonConfig->setFeature(ButtonConfig::kFeatureSuppressAfterLongPress); + + + Serial.begin(XPL_BAUDRATE); // start serial interface. Baudrate is specified in the header, dont change + XP.begin("XPLPro Radiobox Demo!", &xplRegister, &xplShutdown, &xplInboundHandler); + displayUpdate(); +} + +//------------------------------------------ +void loop() +{ + + XP.xloop(); // needs to run every cycle. + + encoder1Button.check(); + modeButton.check(); + flopButton.check(); + + + // Get encoder direction (-1, 0, +1) + int encVal = encoder1.read() / 4; + if (encVal < 0) + { switch(mode) + { + case MODE_COM1: + if (encoderPos == 0) XP.commandTrigger(cmdCom1FineDown); + if (encoderPos == 1) XP.commandTrigger(cmdCom1CourseDown); + break; + + case MODE_COM2: + if (encoderPos == 0) XP.commandTrigger(cmdCom2FineDown); + if (encoderPos == 1) XP.commandTrigger(cmdCom2CourseDown); + break; + + case MODE_NAV1: + if (encoderPos == 0) XP.commandTrigger(cmdNav1FineDown); + if (encoderPos == 1) XP.commandTrigger(cmdNav1CourseDown); + break; + + case MODE_NAV2: + if (encoderPos == 0) XP.commandTrigger(cmdNav2FineDown); + if (encoderPos == 1) XP.commandTrigger(cmdNav2CourseDown); + break; + + case MODE_XPDR: + if (encoderPos == 0) XP.commandTrigger(cmdXpdr34Down); + if (encoderPos == 1) XP.commandTrigger(cmdXpdr12Down); + break; + + case MODE_ADF1: + if (encoderPos == 0) XP.commandTrigger(cmdAdf110Down); + if (encoderPos == 1) XP.commandTrigger(cmdAdfOTDown); + break; + } + encoder1.write(0); + + + // #define MODE_COM1 0 + //#define MODE_COM2 1 + //#define MODE_NAV1 2 + //#define MODE_NAV2 3 + //#define MODE_XPDR 4 + //#define MODE_ADF1 5 + } + if (encVal > 0) + { switch(mode) + { + case MODE_COM1: + if (encoderPos == 0) XP.commandTrigger(cmdCom1FineUp); + if (encoderPos == 1) XP.commandTrigger(cmdCom1CourseUp); + break; + case MODE_COM2: + if (encoderPos == 0) XP.commandTrigger(cmdCom2FineUp); + if (encoderPos == 1) XP.commandTrigger(cmdCom2CourseUp); + break; + + case MODE_NAV1: + if (encoderPos == 0) XP.commandTrigger(cmdNav1FineUp); + if (encoderPos == 1) XP.commandTrigger(cmdNav1CourseUp); + break; + + case MODE_NAV2: + if (encoderPos == 0) XP.commandTrigger(cmdNav2FineUp); + if (encoderPos == 1) XP.commandTrigger(cmdNav2CourseUp); + break; + + case MODE_XPDR: + if (encoderPos == 0) XP.commandTrigger(cmdXpdr34Up); + if (encoderPos == 1) XP.commandTrigger(cmdXpdr12Up); + break; + + case MODE_ADF1: + if (encoderPos == 0) XP.commandTrigger(cmdAdf110Up); + if (encoderPos == 1) XP.commandTrigger(cmdAdfOTUp); + break; + + + } + encoder1.write(0); + + + + //#define MODE_ADF1 5 + } +} + +// The event handler for the buttons. +void handleButton(AceButton* button, uint8_t eventType, + uint8_t /*buttonState*/) +{ + uint8_t pin = button->getPin(); + + if (pin == PIN_BUTTON_ENCODER1) + { + switch (eventType) + { + // Interpret a Released event as a Pressed event, to distiguish it + // from a LongPressed event. + case AceButton::kEventReleased: + + encoderPos ++; + if (encoderPos >1) encoderPos = 0; + displayUpdate(); + + break; + + } + + } + + if (pin == PIN_BUTTON_MODE) + { + + switch (eventType) + { + // Interpret a Released event as a Pressed event, to distiguish it + // from a LongPressed event. + case AceButton::kEventReleased: + mode++; + if (mode > MODE_MAX) mode = 0; + encoderPos = 1; + displayUpdate(); + break; + + } + } + + if (pin == PIN_BUTTON_FLIP) + { + + switch (eventType) + { + // Interpret a Released event as a Pressed event, to distiguish it + // from a LongPressed event. + case AceButton::kEventReleased: + switch(mode) + { + case MODE_COM1: XP.commandTrigger(cmdCom1Flip); break; + case MODE_COM2: XP.commandTrigger(cmdCom2Flip); break; + case MODE_NAV1: XP.commandTrigger(cmdNav1Flip); break; + case MODE_NAV2: XP.commandTrigger(cmdNav2Flip); break; + case MODE_ADF1: XP.commandTrigger(cmdAdf1Flip); break; + case MODE_XPDR: + xpdrMode ++; + if (xpdrMode > 3) xpdrMode = 0; // 3 is the highest standard transponder mode. Increase if you want other available modes. + XP.datarefWrite(drefXpdrMode, xpdrMode); + displayUpdate(); + break; + + } + break; + + } + } +} + +/* + * This function is the callback function we specified that will be called any time our requested data is sent to us. + * handle is the handle to the dataref. The following values are transfered to the callback through inStruct: + * + * int inData->handle The handle of the incoming dataref + * int inData->element If the dataref is an array style dataref, this is the element of the array + * long inData->inLong long value for datarefs that are long values + * float inData->inFloat float value for datarefs that are float values + */ +void xplInboundHandler(inStruct *inData) +{ + + if (inData->handle == drefCom1Freq) { Com1 = inData->inLong; displayUpdate(); return; } + if (inData->handle == drefCom1StbyFreq) { Com1st = inData->inLong; displayUpdate(); return; } + if (inData->handle == drefCom2Freq) { Com2 = inData->inLong; displayUpdate(); return; } + if (inData->handle == drefCom2StbyFreq) { Com2st = inData->inLong; displayUpdate(); return; } + if (inData->handle == drefNav1Freq) { Nav1 = inData->inLong; displayUpdate(); return; } + if (inData->handle == drefNav1StbyFreq) { Nav1st = inData->inLong; displayUpdate(); return; } + if (inData->handle == drefNav2Freq) { Nav2 = inData->inLong; displayUpdate(); return; } + if (inData->handle == drefNav2StbyFreq) { Nav2st = inData->inLong; displayUpdate(); return; } + if (inData->handle == drefXpdrCode) { Xpdr = inData->inLong; displayUpdate(); return; } + if (inData->handle == drefXpdrMode) { xpdrMode = inData->inLong; displayUpdate(); return; } + if (inData->handle == drefADFFreq) { Adf1 = inData->inLong; displayUpdate(); return; } + if (inData->handle == drefADFstbyFreq) { Adf1st = inData->inLong; displayUpdate(); return; } + +} + +void xplRegister() // this is the function we set as a callback for when the plugin is ready to receive dataref and command bindings requests +{ + + drefCom1Freq = XP.registerDataRef(F("sim/cockpit2/radios/actuators/com1_frequency_hz")); + XP.requestUpdates(drefCom1Freq, 100, 0); + drefCom1StbyFreq = XP.registerDataRef(F("sim/cockpit2/radios/actuators/com1_standby_frequency_hz")); + XP.requestUpdates(drefCom1StbyFreq, 100, 0); + drefCom2Freq = XP.registerDataRef(F("sim/cockpit2/radios/actuators/com2_frequency_hz")); + XP.requestUpdates(drefCom2Freq, 100, 0); + drefCom2StbyFreq = XP.registerDataRef(F("sim/cockpit2/radios/actuators/com2_standby_frequency_hz")); + XP.requestUpdates(drefCom2StbyFreq, 100, 0); + + drefNav1Freq = XP.registerDataRef(F("sim/cockpit2/radios/actuators/nav1_frequency_hz")); + XP.requestUpdates(drefNav1Freq, 100, 0); + drefNav1StbyFreq = XP.registerDataRef(F("sim/cockpit2/radios/actuators/nav1_standby_frequency_hz")); + XP.requestUpdates(drefNav1StbyFreq, 100, 0); + drefNav2Freq = XP.registerDataRef(F("sim/cockpit2/radios/actuators/nav2_frequency_hz")); + XP.requestUpdates(drefNav2Freq, 100, 0); + drefNav2StbyFreq = XP.registerDataRef(F("sim/cockpit2/radios/actuators/nav2_standby_frequency_hz")); + XP.requestUpdates(drefNav2StbyFreq, 100, 0); + + drefXpdrCode = XP.registerDataRef(F("sim/cockpit/radios/transponder_code")); + XP.requestUpdates(drefXpdrCode, 100, 0); + drefXpdrMode = XP.registerDataRef(F("sim/cockpit2/radios/actuators/transponder_mode")); + XP.requestUpdates(drefXpdrMode, 100, 0); + + drefADFFreq = XP.registerDataRef(F("sim/cockpit2/radios/actuators/adf1_frequency_hz")); + XP.requestUpdates(drefADFFreq, 100, 0); + drefADFstbyFreq = XP.registerDataRef(F("sim/cockpit2/radios/actuators/adf1_standby_frequency_hz")); + XP.requestUpdates(drefADFstbyFreq, 10, 0); + +/* + * Now register commands. + * + */ + cmdCom1CourseDown = XP.registerCommand(F("sim/radios/stby_com1_coarse_down")); + cmdCom1CourseUp = XP.registerCommand(F("sim/radios/stby_com1_coarse_up")); + cmdCom1FineDown = XP.registerCommand(F("sim/radios/stby_com1_fine_down")); + cmdCom1FineUp = XP.registerCommand(F("sim/radios/stby_com1_fine_up")); + cmdCom2CourseDown = XP.registerCommand(F("sim/radios/stby_com2_coarse_down")); + cmdCom2CourseUp = XP.registerCommand(F("sim/radios/stby_com2_coarse_up")); + cmdCom2FineDown = XP.registerCommand(F("sim/radios/stby_com2_fine_down")); + cmdCom2FineUp = XP.registerCommand(F("sim/radios/stby_com2_fine_up")); + + cmdNav1CourseDown = XP.registerCommand(F("sim/radios/stby_nav1_coarse_down")); + cmdNav1CourseUp = XP.registerCommand(F("sim/radios/stby_nav1_coarse_up")); + cmdNav1FineDown = XP.registerCommand(F("sim/radios/stby_nav1_fine_down")); + cmdNav1FineUp = XP.registerCommand(F("sim/radios/stby_nav1_fine_up")); + cmdNav2CourseDown = XP.registerCommand(F("sim/radios/stby_nav2_coarse_down")); + cmdNav2CourseUp = XP.registerCommand(F("sim/radios/stby_nav2_coarse_up")); + cmdNav2FineDown = XP.registerCommand(F("sim/radios/stby_nav2_fine_down")); + cmdNav2FineUp = XP.registerCommand(F("sim/radios/stby_nav2_fine_up")); + + cmdXpdr12Down = XP.registerCommand(F("sim/transponder/transponder_12_down")); + cmdXpdr12Up = XP.registerCommand(F("sim/transponder/transponder_12_up")); + cmdXpdr34Down = XP.registerCommand(F("sim/transponder/transponder_34_down")); + cmdXpdr34Up = XP.registerCommand(F("sim/transponder/transponder_34_up")); + + cmdAdf110Down = XP.registerCommand(F("sim/radios/stby_adf1_ones_tens_down")); + cmdAdf110Up = XP.registerCommand(F("sim/radios/stby_adf1_ones_tens_up")); + cmdAdfOTDown = XP.registerCommand(F("sim/radios/stby_adf1_hundreds_thous_down")); + cmdAdfOTUp = XP.registerCommand(F("sim/radios/stby_adf1_hundreds_thous_up")); + + cmdCom1Flip = XP.registerCommand(F("sim/radios/com1_standy_flip")); + cmdCom2Flip = XP.registerCommand(F("sim/radios/com2_standy_flip")); + cmdNav1Flip = XP.registerCommand(F("sim/radios/nav1_standy_flip")); + cmdNav2Flip = XP.registerCommand(F("sim/radios/nav2_standy_flip")); + + cmdAdf1Flip = XP.registerCommand(F("sim/radios/adf1_standy_flip")); + +} + +void xplShutdown() +{ + lcd.clear(); + displayUpdate(); + // if you need to do things when xplane shuts down or unloads an aircraft, do it here. + +} + + +void printFixedWidth(int x, int y, float in, byte width, byte decimals); + +/** + * Show selected mode on screen + */ +void displayUpdate() +{ + //lcd.clear(); + lcd.setCursor(0, 0); + + if (!XP.connectionStatus()) + { lcd.clear(); + lcd.print("INOP.."); + return; + } + + switch(mode) + { + + + case MODE_COM1: + lcd.print("COM 1 "); + + printFixedWidth(0,1, (float)Com1/100, 5, 2); + printFixedWidth(10,1, (float)Com1st/100, 5, 2); + + lcd.setCursor(10,0); + if (encoderPos == 0) lcd.print(" __"); + if (encoderPos == 1) lcd.print("___ "); + + break; + + case MODE_COM2: + lcd.print("COM 2"); + printFixedWidth(0,1, (float)Com2/100, 5, 2); + printFixedWidth(10,1, (float)Com2st/100, 5, 2); + + lcd.setCursor(10,0); + if (encoderPos == 0) lcd.print(" __"); + if (encoderPos == 1) lcd.print("___ "); + break; + + case MODE_NAV1: + lcd.print("NAV 1"); + + printFixedWidth(0,1, (float)Nav1/100, 5, 2); + printFixedWidth(10,1, (float)Nav1st/100, 5, 2); + + lcd.setCursor(10,0); + if (encoderPos == 0) lcd.print(" __"); + if (encoderPos == 1) lcd.print("___ "); + break; + + case MODE_NAV2: + lcd.print("NAV 2"); + + printFixedWidth(0,1, (float)Nav2/100, 5, 2); + printFixedWidth(10,1, (float)Nav2st/100, 5, 2); + + lcd.setCursor(10,0); + if (encoderPos == 0) lcd.print(" __"); + if (encoderPos == 1) lcd.print("___ "); + break; + + case MODE_XPDR: + lcd.print("XPDR "); + printFixedWidth(10,1, (float)Xpdr, 4, 0); + + lcd.print(" "); + lcd.setCursor(0,1); + switch(xpdrMode) + { + case 0: lcd.print("OFF "); break; + case 1: lcd.print("STBY "); break; + case 2: lcd.print("ON "); break; + case 3: lcd.print("ALT "); break; + case 4: lcd.print("TEST "); break; + case 5: lcd.print("GND "); break; + case 6: lcd.print("TA "); break; + case 7: lcd.print("TA/RA "); break; + default: lcd.print("??? "); + } + lcd.setCursor(10,0); + if (encoderPos == 0) lcd.print(" __ "); + if (encoderPos == 1) lcd.print("__ "); + break; + + case MODE_ADF1: + lcd.print("ADF1 "); + printFixedWidth(0,1, (float)Adf1, 4, 0); + printFixedWidth(10,1, (float)Adf1st, 4, 0); + + lcd.setCursor(10,0); + + if (encoderPos == 0) lcd.print(" __ "); + if (encoderPos == 1) lcd.print("__ "); + + break; + + default: + lcd.print("-----=INOP=-----"); + } +} + +/** + * Print numbers on fixed width + * @param out reference to print interface + * @param in value to format + * @param width number of total digits + * @param decimal number of decimal digits + */ +void printFixedWidth(int inX, int inY, float in, byte width, byte decimals) +{ + + lcd.setCursor(inX, inY); + float temp = in; + + if (decimals == 0){ + temp += 0.5; + } + + if (in < 0){ + width--; + } + + width -= decimals + 1; + + if (width < 0){ + width = 0; + } + + while (temp > 10 && width){ + temp /= 10; + width--; + } + + if (in < 0){ + lcd.print('-'); + } + + while (width){ + lcd.print('0'); + width--; + } + + lcd.print(abs(in), decimals); +} diff --git a/XPLPro_Arduino/XPLPro/examples/XPLProRadioSwapDemo/XPLProRadioSwapDemo.ino b/XPLPro_Arduino/XPLPro/examples/XPLProRadioSwapDemo/XPLProRadioSwapDemo.ino new file mode 100644 index 0000000..8a472ac --- /dev/null +++ b/XPLPro_Arduino/XPLPro/examples/XPLProRadioSwapDemo/XPLProRadioSwapDemo.ino @@ -0,0 +1,146 @@ + + +/* + * + * XPLProRadioSwapDemo + * + * Created by Curiosity Workshop for XPL/Pro arduino->XPlane system. + * + * This registers a command to swap the standby frequency with the active frequency on com1 and displays it on an i2c 2x16 LCD display + * + * This sketch was developed and tested on an Arduino Mega. + * + To report problems, download updates and examples, suggest enhancements or get technical support: + + discord: https://discord.gg/RacvaRFsMW + patreon: www.patreon.com/curiosityworkshop + YouTube: https://youtube.com/channel/UCISdHdJIundC-OSVAEPzQIQ + * + * + */ + +#include +#include + +#include // include file for the X-plane direct interface +XPLPro XP(&Serial); // create an instance of it + +LiquidCrystal_I2C lcd(0x26,16,2); + + +long int startTime; + + +#define PIN_COMSWAP 22 // momentary switch for nav swap + + +int drefComActive; // handle to dataref containing active com frequency +int drefComStandby; // handle to dataref containing standby com frequency +int cmdComSwap; // a command handle for toggling standby/active com frequencyn + + +void setup() +{ + lcd.init(); + lcd.backlight(); + lcd.setCursor(0,0); + lcd.print("XPLDemo"); + + pinMode(PIN_COMSWAP, INPUT_PULLUP); // if you are doing pin handling yourself you will want a pullup resistor or use the built-in one + + Serial.begin(XPL_BAUDRATE); // start serial interface. Baudrate is specified in the header, dont change + + /* + needed for initialization. Parameters are: + a texual identifier of your device + your function that will be called when xplane and the plugin are ready for dataref and command registrations + your function that will be called when xplane either shuts down or unloads an aircraft model + your function that will be called when we have requested sends of datarefs that have changed + */ + XP.begin("XPLPro Radio Swap Demo!", &xplRegister, &xplShutdown, &xplInboundHandler); + digitalWrite(LED_BUILTIN, LOW); + + +} + + +void loop() +{ + + + + XP.xloop(); // needs to run every cycle. + +/************************************************************************************************************************************ + * everything after the next line will only occur every 100ms. You can also utilize other time values. + * This helps maintain serial data flow and also helps with switch debounce. + * do NOT add delays anywhere in the loop cycle, it will interfere with the reception of serial data from xplane and the plugin. + ************************************************************************************************************************************ +*/ + + if (millis() - startTime > 100) startTime = millis(); else return; + + +/* + * This reads the status of the assigned pins and triggers commands accordingly. It would be best to use a button library for this for debounce and one-shot purposes + * I am not using one for simplicity in the demo. + */ + if (!digitalRead(PIN_COMSWAP) ) XP.commandTrigger(cmdComSwap); + + +} + +/* + * This function is the callback function we specified that will be called any time our requested data is sent to us. + * handle is the handle to the dataref. The following values are transfered to the callback through inStruct: + * + * int inData->handle The handle of the incoming dataref + * int inData->element If the dataref is an array style dataref, this is the element of the array + * long inData->inLong long value for datarefs that are long values + * float inData->inFloat float value for datarefs that are float values + */ +void xplInboundHandler(inStruct *inData) +{ + if (inData->handle == drefComActive) + { + lcd.setCursor(0,0); + lcd.print("COM1: "); + lcd.print(inData->inLong); + + } + + if (inData->handle == drefComStandby) + { lcd.setCursor(0,1); + lcd.print("STBY: "); + lcd.print(inData->inLong); // casted to INT to remove decimals + } + + + +} + +void xplRegister() // this is the function we set as a callback for when the plugin is ready to receive dataref and command bindings requests +{ + + + +/* + * + * On non-AVR boards remove the F() macro. + * + */ + drefComActive = XP.registerDataRef(F("sim/cockpit/radios/com1_freq_hz") ); + XP.requestUpdates(drefComActive, 100, 0); // Tell xplane to send us updates when the value changes. + // 100 means don't update more often than every 100ms and 0 is a resolution divider which is explained in another dataref, use 0 if no divider required + drefComStandby = XP.registerDataRef(F("sim/cockpit/radios/com1_stdby_freq_hz") ); + XP.requestUpdates(drefComStandby, 100, 0); + + cmdComSwap = XP.registerCommand(F("sim/radios/com1_standy_flip") ); + +} + +void xplShutdown() +{ + // if you need to do things when xplane shuts down or unloads an aircraft, do it here. + +} diff --git a/XPLPro_Arduino/XPLPro/examples/XPLProSequenceExample/XPLProSequenceExample.ino b/XPLPro_Arduino/XPLPro/examples/XPLProSequenceExample/XPLProSequenceExample.ino new file mode 100644 index 0000000..173ff00 --- /dev/null +++ b/XPLPro_Arduino/XPLPro/examples/XPLProSequenceExample/XPLProSequenceExample.ino @@ -0,0 +1,149 @@ + + +/* + * + * XPLProSequenceExample + * + * This sketch runs a series of commands or dataref writes over time when triggered + * + * + * Created by Curiosity Workshop for XPL/Pro arduino->XPlane system. + * + * This sketch was developed and tested on an Arduino Mega. + * + To report problems, download updates and examples, suggest enhancements or get technical support: + + discord: https://discord.gg/RacvaRFsMW + patreon: www.patreon.com/curiosityworkshop + YouTube: https://youtube.com/channel/UCISdHdJIundC-OSVAEPzQIQ + Facebook: https://www.facebook.com/curiosity.workshop42/ + * + * + */ + +#include +#include // include file for the X-plane direct interface + +#define XPLSEQUENCER_MAXEVENTS 10 // Max amount of events to allow. Default to 10 if not defined +#include // for making timed sequences + +XPLPro XP(&Serial); // create an instance of it + + +void seqStartupHandler(int inItem); // This will be called at the requested times +XPLSequencer seqStartup(&seqStartupHandler); // this will be the sequence for startup. We can make additional ones as needed. + +int drefMasterBattery; +int drefBeacon; // this stores a handle to the beacon light dataref +int drefNavLight; // this stores a handle to the nav light dataref +int drefThrottle; // this stores a handle to the throttle position dataref + +int cmdLdgLightToggle; // this stores a handle to the landing light toggle command + + +void setup() +{ + + pinMode(LED_BUILTIN, OUTPUT); // built in LED on arduino board will turn on and off with the status of the beacon light + //pinMode(PIN_TRIGGER, INPUT_PULLUP); + + Serial.begin(XPL_BAUDRATE); // start serial interface. Baudrate is specified in the header, dont change + + /* + needed for initialization. Parameters are: + a texual identifier of your device + your function that will be called when xplane and the plugin are ready for dataref and command registrations + your function that will be called when xplane either shuts down or unloads an aircraft model + your function that will be called when we have requested sends of datarefs that have changed + */ + XP.begin("XPLPro Sequence Example!", &xplRegister, &xplShutdown, &xplInboundHandler); + digitalWrite(LED_BUILTIN, LOW); + + +} + + +void loop() +{ + + unsigned long timeNow; + unsigned long startTime; + timeNow = millis(); + + XP.xloop(); // needs to run every cycle. + seqStartup.check(timeNow); + + +} + +/* + * This function is the callback function we specified that will be called any time our requested data is sent to us. + * handle is the handle to the dataref. The following variables within the plugin are how we receive the data: + * + * inStruct *inData is a pointer to a structure that contains information about the incoming dataref. + * + * int inData->handle The handle of the incoming dataref + * int inData->element If the dataref is an array style dataref, this is the element of the array + * long inData->inLong long value for datarefs that are long values + * float inData->inFloat float value for datarefs that are float values + */ + void xplInboundHandler(inStruct *inData) +{ + + if (inData->handle == drefMasterBattery) + { + if (inData->inLong == 1) seqStartup.trigger(); // The plugin keeps track of the data and only updates it when it changes. + + + } + +} + +/* + * this is the function we set as a callback for when the plugin is ready to receive dataref and command bindings requests + * It could be called multiple times if for instance xplane is restarted or loads a different aircraft + */ +void xplRegister() +{ + + drefMasterBattery = XP.registerDataRef(F("sim/cockpit/electrical/battery_on") ); + XP.requestUpdates(drefMasterBattery, 100, 1); // We need to subscribe for updates to the dataref if wanting to read them. When they change the inbound handler will be called + + + drefBeacon = XP.registerDataRef(F("sim/cockpit2/switches/beacon_on") ); + drefNavLight = XP.registerDataRef(F("sim/cockpit/electrical/nav_lights_on") ); + drefThrottle = XP.registerDataRef(F("sim/cockpit2/engine/actuators/throttle_ratio") ); + cmdLdgLightToggle = XP.registerCommand(F("sim/lights/landing_lights_toggle") ); + + seqStartup.clear(); + seqStartup.addEvent(2000); // first event will occur 2000ms after trigger. + seqStartup.addEvent(2000); // second event will occur 2 seconds after first event + seqStartup.addEvent(1000); // third event will occur 1 second after the previous one + seqStartup.addEvent(2000); // ...and so on. + seqStartup.addEvent(1000); + + +} + +void xplShutdown() +{ + // if you need to do things when xplane shuts down or unloads an aircraft, do it here. + +} + + +// This will be called for each scheduled event. inItem is which event we are on in the sequence requested. +void seqStartupHandler(int inItem) +{ + + switch(inItem) + { + case 0 : XP.datarefWrite(drefBeacon, 1); break; // turn on the beacon light + case 1 : XP.datarefWrite(drefNavLight, 1); break; // turn on the nav light + case 2 : XP.commandTrigger(cmdLdgLightToggle); break; // toggle the landing light on/off + case 3 : XP.datarefWrite(drefThrottle, .2F); break; // had to specify the type of .2 with "F" so it knows it is a float. You could also do (float).2 + case 4 : XP.sendSpeakMessage("Sequence Complete"); break; + } + +} + diff --git a/XPLPro_Arduino/XPLPro/examples/XPLProShutdownExample/XPLProShutdownExample.ino b/XPLPro_Arduino/XPLPro/examples/XPLProShutdownExample/XPLProShutdownExample.ino new file mode 100644 index 0000000..4a9de57 --- /dev/null +++ b/XPLPro_Arduino/XPLPro/examples/XPLProShutdownExample/XPLProShutdownExample.ino @@ -0,0 +1,84 @@ + + +/* + * + * XPLProShutdownExample + * + * This examples turns on the built in LED while Xplane is active with a plane loaded and off when the plane is unloaded + * or if Xplane shuts down + * + * Created by Curiosity Workshop for XPL/Pro arduino->XPlane system. + * + * This sketch was developed and tested on an Arduino Mega. + * + To report problems, download updates and examples, suggest enhancements or get technical support: + + discord: https://discord.gg/RacvaRFsMW + patreon: www.patreon.com/curiosityworkshop + YouTube: https://youtube.com/channel/UCISdHdJIundC-OSVAEPzQIQ + * + * + */ + +#include + +#include // include file for the X-plane direct interface +XPLPro XP(&Serial); // create an instance of it + + +void setup() +{ + + pinMode(LED_BUILTIN, OUTPUT); + + Serial.begin(XPL_BAUDRATE); // start serial interface. Baudrate is specified in the header, dont change + + /* + needed for initialization. Parameters are: + a texual identifier of your device + your function that will be called when xplane and the plugin are ready for dataref and command registrations + your function that will be called when xplane either shuts down or unloads an aircraft model + your function that will be called when we have requested sends of datarefs that have changed + */ + XP.begin("XPLPro Shutdown Demo!", &xplRegister, &xplShutdown, &xplInboundHandler); + digitalWrite(LED_BUILTIN, LOW); + + } + + +void loop() +{ + + XP.xloop(); // needs to run every cycle. + +} + +/* + * This function is the callback function we specified that will be called any time our requested data is sent to us. + * handle is the handle to the dataref. The following values are transfered to the callback through inStruct: + * + * int inData->handle The handle of the incoming dataref + * int inData->element If the dataref is an array style dataref, this is the element of the array + * long inData->inLong long value for datarefs that are long values + * float inData->inFloat float value for datarefs that are float values + */ +void xplInboundHandler(inStruct *inData) +{ + + + +} + +void xplRegister() // this is the function we set as a callback for when the plugin is ready to receive dataref and command bindings requests +{ + + digitalWrite(LED_BUILTIN, HIGH); //turn on the built in LED while xplane is actively running a plane + + } + +void xplShutdown() +{ + + digitalWrite(LED_BUILTIN, LOW); // turn off the built in LED when xplane exits or unloads a plane. + +} diff --git a/XPLPro_Arduino/XPLPro/examples/XPLProSingleEncoder/XPLProSingleEncoder.ino b/XPLPro_Arduino/XPLPro/examples/XPLProSingleEncoder/XPLProSingleEncoder.ino new file mode 100644 index 0000000..2a62db6 --- /dev/null +++ b/XPLPro_Arduino/XPLPro/examples/XPLProSingleEncoder/XPLProSingleEncoder.ino @@ -0,0 +1,137 @@ + + +/* + * + * XPLProSingleEncoder + * + * This example shows how to connect a single rotary encoder and trigger xplane commands with it. + * + * Created by Curiosity Workshop for XPL/Pro arduino->XPlane system. + * + * This sketch was developed and tested on an Arduino Mega. + * + To report problems, download updates and examples, suggest enhancements or get technical support: + + discord: https://discord.gg/RacvaRFsMW + patreon: www.patreon.com/curiosityworkshop + YouTube: https://youtube.com/channel/UCISdHdJIundC-OSVAEPzQIQ + * + * + */ + +#include + +#include // Available in the library manager. For the rotary encoder + +#include // include file for the X-plane direct interface +XPLPro XP(&Serial); // create an instance of it + +// Encoder Pins + +#define PIN_ENCODER0A 8 // Pins for first encoder. +#define PIN_ENCODER0B 9 + +Encoder encoder1(PIN_ENCODER0A, PIN_ENCODER0B); // create an instance for the encoder +int enc0; // this will be used to store and accumulate the current value of the encoder +unsigned cmdEncoder0Up; // these hold the command handles after registering the xplane commands. +unsigned cmdEncoder0Dn; + +void setup() +{ + + pinMode(LED_BUILTIN, OUTPUT); // built in LED on arduino board will turn on and off with the status of the beacon light + + Serial.begin(XPL_BAUDRATE); // start serial interface. Baudrate is specified in the header, dont change + + /* + needed for initialization. Parameters are: + a texual identifier of your device + your function that will be called when xplane and the plugin are ready for dataref and command registrations + your function that will be called when xplane either shuts down or unloads an aircraft model + your function that will be called when we have requested sends of datarefs that have changed + */ + XP.begin("XPLPro Single Encoder Demo!", &xplRegister, &xplShutdown, &xplInboundHandler); + digitalWrite(LED_BUILTIN, LOW); + + +} + + +void loop() +{ + + XP.xloop(); // needs to run every cycle. + EncodersCheck(); // This needs to run as often as possible as well unless you are using interrupt pins + + +} + +/* + * This function is the callback function we specified that will be called any time our requested data is sent to us. + * handle is the handle to the dataref. The following variables within the plugin are how we receive the data: + * + * inStruct *inData is a pointer to a structure that contains information about the incoming dataref. + * + * int inData->handle The handle of the incoming dataref + * int inData->element If the dataref is an array style dataref, this is the element of the array + * long inData->inLong long value for datarefs that are long values + * float inData->inFloat float value for datarefs that are float values + */ + void xplInboundHandler(inStruct *inData) +{ + + +} + +/* + * this is the function we set as a callback for when the plugin is ready to receive dataref and command bindings requests + * It could be called multiple times if for instance xplane is restarted or loads a different aircraft + */ +void xplRegister() +{ +/* + * This example registers two commands. These can be anything that makes sense to control with a rotary encoder. + * As a universal example I am using the heading select which is available in most aircraft models. + */ + + cmdEncoder0Up = XP.registerCommand(F("sim/autopilot/heading_down")); + cmdEncoder0Dn = XP.registerCommand(F("sim/autopilot/heading_up")); + + +} + +void xplShutdown() +{ + // if you need to do things when xplane shuts down or unloads an aircraft, do it here. + +} + + +void EncodersCheck(void) +{ + enc0 += encoder1.readAndReset(); +// enc1 += encoder1.readAndReset(); // to add encoders follow this format +// enc2 += encoder2.readAndReset(); +// enc3 += encoder3.readAndReset(); +// enc4 += encoder4.readAndReset(); +// enc5 += encoder5.readAndReset(); + + if (enc0 < -3) { XP.commandTrigger(cmdEncoder0Up); enc0 = 0; } // The quadrature encoders I am using create 4 pulses per detent. This waits until 4 are received before triggering the command. + if (enc0 > 3) { XP.commandTrigger(cmdEncoder0Dn); enc0 = 0; } + +// if (enc1 < -3) { XP.commandTrigger(cmdAirspeedUp); enc1 = 0; } +// if (enc1 > 3) { XP.commandTrigger(cmdAirspeedDn); enc1 = 0; } + +// if (enc2 < -3) { XP.commandTrigger(cmdHeadingUp); enc2 = 0; } +// if (enc2 > 3) { XP.commandTrigger(cmdHeadingDn); enc2 = 0; } + +// if (enc3 < -3) { XP.commandTrigger(cmdAltitudeDn); enc3 = 0; } +// if (enc3 > 3) { XP.commandTrigger(cmdAltitudeUp); enc3 = 0; } + +// if (enc4 < -3) { XP.commandTrigger(cmdVerticalSpeedUp); enc4 = 0; } +// if (enc4 > 3) { XP.commandTrigger(cmdVerticalSpeedDn); enc4 = 0; } + +// if (enc5 < -3) { XP.commandTrigger(cmdCourseCopilotUp); enc5 = 0; } +// if (enc5 > 3) { XP.commandTrigger(cmdCourseCopilotDn); enc5 = 0; } + +} diff --git a/XPLPro_Arduino/XPLPro/examples/XPLProSingleLED/XPLProSingleLED.ino b/XPLPro_Arduino/XPLPro/examples/XPLProSingleLED/XPLProSingleLED.ino new file mode 100644 index 0000000..9bbcdf6 --- /dev/null +++ b/XPLPro_Arduino/XPLPro/examples/XPLProSingleLED/XPLProSingleLED.ino @@ -0,0 +1,105 @@ + + +/* + * + * XPLProSingleLED + * + * This example shows how to connect a single LED to an xplane dataref. + * + * Created by Curiosity Workshop for XPL/Pro arduino->XPlane system. + * + * This sketch was developed and tested on an Arduino Mega. + * + To report problems, download updates and examples, suggest enhancements or get technical support: + + discord: https://discord.gg/RacvaRFsMW + patreon: www.patreon.com/curiosityworkshop + YouTube: https://youtube.com/channel/UCISdHdJIundC-OSVAEPzQIQ + * + * + */ + +#include + +#include // include file for the X-plane direct interface +XPLPro XP(&Serial); // create an instance of it + +#define PIN_LED0 10 // Pin for LED Anode (positive). The Cathode (negative) will need to be connected + // to ground, and somewhere in the line should be a resistor ~220 ohms for the 5v signal + // coming from the Arduino Mega. + +unsigned datarefLED0; // This will store a handle to access information from the requested dataref. + +void setup() +{ + + pinMode(PIN_LED0, OUTPUT); // This tells the arduino board that we are using the pin for output + + Serial.begin(XPL_BAUDRATE); // start serial interface. Baudrate is specified in the header, dont change + + /* + needed for initialization. Parameters are: + a texual identifier of your device + your function that will be called when xplane and the plugin are ready for dataref and command registrations + your function that will be called when xplane either shuts down or unloads an aircraft model + your function that will be called when we have requested sends of datarefs that have changed + */ + XP.begin("XPLPro Single LED Demo!", &xplRegister, &xplShutdown, &xplInboundHandler); + digitalWrite(PIN_LED0, LOW); // turn off the LED for now + + +} + + +void loop() +{ + + XP.xloop(); // needs to run every cycle. + +} + +/* + * This function is the callback function we specified that will be called any time our requested data is sent to us. + * handle is the handle to the dataref. The following variables within the plugin are how we receive the data: + * + * inStruct *inData is a pointer to a structure that contains information about the incoming dataref. + * + * int inData->handle The handle of the incoming dataref + * int inData->element If the dataref is an array style dataref, this is the element of the array + * long inData->inLong long value for datarefs that are long values + * float inData->inFloat float value for datarefs that are float values + * int inData->strLength If the dataref is binary data/string, length of the data + * char inData->inStr if binary data/string, a pointer to it. + */ +void xplInboundHandler(inStruct *inData) +{ + + if (inData->handle == datarefLED0) // Which handle is supplying new data... maybe ours? + { + digitalWrite(PIN_LED0, inData->inLong); // Xplane talks in long integers + } + +} + +/* + * this is the function we set as a callback for when the plugin is ready to receive dataref and command bindings requests + * It could be called multiple times if for instance xplane is restarted or loads a different aircraft + */ +void xplRegister() +{ +/* + * This example registers one dataref. + * As a universal example I am using the nav light switch which is available in most aircraft models. + */ + + datarefLED0 = XP.registerDataRef(F("sim/cockpit2/switches/navigation_lights_on")); + XP.requestUpdates(datarefLED0, 100, 0); // request that new values get sent to us. + +} + +void xplShutdown() +{ + // if you need to do things when xplane shuts down or unloads an aircraft, do it here. + +} + diff --git a/XPLPro_Arduino/XPLPro/examples/XPLProStringDemo/XPLProStringDemo.ino b/XPLPro_Arduino/XPLPro/examples/XPLProStringDemo/XPLProStringDemo.ino new file mode 100644 index 0000000..07a6598 --- /dev/null +++ b/XPLPro_Arduino/XPLPro/examples/XPLProStringDemo/XPLProStringDemo.ino @@ -0,0 +1,126 @@ + + +/* + * + * XPLProStringDemo + * + * Created by Curiosity Workshop for XPL/Pro arduino->XPlane system. + * + * This sketch was developed and tested on an Arduino Mega. + * + To report problems, download updates and examples, suggest enhancements or get technical support: + + discord: https://discord.gg/RacvaRFsMW + patreon: www.patreon.com/curiosityworkshop + YouTube: https://youtube.com/channel/UCISdHdJIundC-OSVAEPzQIQ + * + * + */ + +#include +#include + +#include // include file for the X-plane direct interface +XPLPro XP(&Serial); // create an instance of it + +LiquidCrystal_I2C lcd(0x27,16,2); + + +long int startTime; + + +int drefTailNum; // this holds the handle to the dataref + +void setup() +{ + lcd.init(); + lcd.backlight(); + lcd.setCursor(0,0); + lcd.print("XPLPro String"); + + + Serial.begin(XPL_BAUDRATE); // start serial interface. Baudrate is specified in the header, dont change + + /* + needed for initialization. Parameters are: + a texual identifier of your device + your function that will be called when xplane and the plugin are ready for dataref and command registrations + your function that will be called when xplane either shuts down or unloads an aircraft model + your function that will be called when we have requested sends of datarefs that have changed + */ + XP.begin("XPLPro Multi Demo!", &xplRegister, &xplShutdown, &xplInboundHandler); + digitalWrite(LED_BUILTIN, LOW); + + +} + + +void loop() +{ + + + + XP.xloop(); // needs to run every cycle. + +/************************************************************************************************************************************ + * everything after the next line will only occur every 100ms. You can also utilize other time values. + * This helps maintain serial data flow and also helps with switch debounce. + * do NOT add delays anywhere in the loop cycle, it will interfere with the reception of serial data from xplane and the plugin. + ************************************************************************************************************************************ +*/ + + if (millis() - startTime > 100) startTime = millis(); else return; + + + + + + +} + +/* + * This function is the callback function we specified that will be called any time our requested data is sent to us. + * handle is the handle to the dataref. The following values are transfered to the callback through inStruct: + * + * int inData->handle The handle of the incoming dataref + * int inData->element If the dataref is an array style dataref, this is the element of the array + * long inData->inLong long value for datarefs that are long values + * float inData->inFloat float value for datarefs that are float values + */ +void xplInboundHandler(inStruct *inData) +{ + + if (inData->handle == drefTailNum) + { lcd.setCursor(0,1); + lcd.print(inData->inStr); + + } + + + +} + +void xplRegister() // this is the function we set as a callback for when the plugin is ready to receive dataref and command bindings requests +{ + + + +/* + * This example registers a dataref for the beacon light. + * In the loop section of the code we will turn on/off the LED on the arduino board to represent the status of the beacon light within xplane. + * On non-AVR boards remove the F() macro. + * + */ + drefTailNum = XP.registerDataRef(F("sim/aircraft/view/acf_tailnum") ); + XP.requestUpdates(drefTailNum, 100, 0); // Tell xplane to send us updates when the status of the tail number changes. + // 100 means don't update more often than every 100ms and 0 is a resolution divider which is explained in another dataref, use 0 if no divider required + + + +} + +void xplShutdown() +{ + // if you need to do things when xplane shuts down or unloads an aircraft, do it here. + +} diff --git a/XPLPro_Arduino/XPLPro/examples/XPLProSwitchesExample/Circuit Layout.fzz b/XPLPro_Arduino/XPLPro/examples/XPLProSwitchesExample/Circuit Layout.fzz new file mode 100644 index 0000000..fcef7a8 Binary files /dev/null and b/XPLPro_Arduino/XPLPro/examples/XPLProSwitchesExample/Circuit Layout.fzz differ diff --git a/XPLPro_Arduino/XPLPro/examples/XPLProSwitchesExample/Circuit Layout.jpg b/XPLPro_Arduino/XPLPro/examples/XPLProSwitchesExample/Circuit Layout.jpg new file mode 100644 index 0000000..9e02a8b Binary files /dev/null and b/XPLPro_Arduino/XPLPro/examples/XPLProSwitchesExample/Circuit Layout.jpg differ diff --git a/XPLPro_Arduino/XPLPro/examples/XPLProSwitchesExample/XPLProSwitchesExample.ino b/XPLPro_Arduino/XPLPro/examples/XPLProSwitchesExample/XPLProSwitchesExample.ino new file mode 100644 index 0000000..7c9ead0 --- /dev/null +++ b/XPLPro_Arduino/XPLPro/examples/XPLProSwitchesExample/XPLProSwitchesExample.ino @@ -0,0 +1,102 @@ + +/* + * + * XPLProSwitchesExample + * + * Created by Curiosity Workshop for XPL/Pro arduino->XPlane system. + * + * This sketch was developed and tested on an Arduino Mega. + * This example accompanies the video on YouTube: https://www.youtube.com/watch?v=SMJiGwNc7rY + * + To report problems, download updates and examples, suggest enhancements or get technical support: + + discord: https://discord.gg/RacvaRFsMW + patreon: www.patreon.com/curiosityworkshop + YouTube: https://youtube.com/channel/UCISdHdJIundC-OSVAEPzQIQ + * + * + */ + +#include + +#include + +#define XPLSWITCHES_MAXSWITCHES 10 // adjust this as required for your needs. Higher number of course costs memory ~10 bytes each. Default is 40 if not specified +#include + + +#define PIN_BEACON 45 // Connect to a momentary switch. It will toggle the beacon lights on and off with each press +#define PIN_STROBE 47 // Connect to a regular toggle switch. We will control the dataref directly +#define PIN_STARTER 49 // Connect to a momentary switch. It will activate the starter while the button is pressed. +#define PIN_LEDSWITCH 51 // Connect to a any type of switch. The only function will be to turn the builtin LED on and off as a demonstration. +#define PIN_NAV 53 // Connect to a regular toggle switch. We will control the dataref directly. + +XPLPro XP(&Serial); + +void switchHandler(int pin, int switchValue); +XPLSwitches switches(&switchHandler); // switchHandler is a function that will be called if we want to provide additional functionality. It can also be NULL if not needed. + + + +void setup() +{ + Serial.begin(XPL_BAUDRATE); + XP.begin("XPLPro Switches Example", &xplRegister, &xplShutdown, &xplInboundHandler); + + pinMode(LED_BUILTIN, OUTPUT); + digitalWrite(LED_BUILTIN, LOW); + + switches.begin(&XP); + +} + +void loop() +{ + XP.xloop(); + switches.check(); + //if (millis() % 1000 > 900) digitalWrite(LED_BUILTIN, HIGH); else digitalWrite(LED_BUILTIN, LOW); // Heartbeat +} + +void xplInboundHandler(inStruct *inData) +{ + +} + +void xplShutdown() +{ + + +} + + +void xplRegister() +{ + switches.clear(); // Reset switches + + switches.addPin(PIN_BEACON, XPLSWITCHES_COMMANDTRIGGER, XP.registerCommand(F("sim/lights/beacon_lights_toggle")) ); + switches.addPin(PIN_STARTER, XPLSWITCHES_COMMANDSTARTEND, XP.registerCommand(F("sim/engines/engage_starters")) ); + switches.addPin(PIN_STROBE, XPLSWITCHES_DATAREFWRITE_INVERT, XP.registerDataRef(F("sim/cockpit2/switches/strobe_lights_on")) ); + switches.addPin(PIN_LEDSWITCH,XPLSWITCHES_SENDTOHANDLER, 0); // this only sends the mux event to the handler. Parameter "0" will be ignored in this case. + switches.addPin(PIN_NAV, XPLSWITCHES_DATAREFWRITE, XP.registerDataRef(F("sim/cockpit2/switches/navigation_lights_on")) ); +} + +void switchHandler(int inPin, int inValue) +{ + +// Process inbound switch events. Use this if you have other uses for the incoming mux pins. +// Every registered switch event will call this after it triggers the xplane commands/dataref changes. +// I could also specify XPLSWITCHES_SENDTOHANDLER when adding the pin, if I dont want anything done automatically and it will only call here. + + switch (inPin) + { + case PIN_LEDSWITCH : + digitalWrite(LED_BUILTIN, !inValue); + break; + + case PIN_STROBE : + if (inValue == 0) XP.sendSpeakMessage("Strobe ON"); + if (inValue == 1) XP.sendSpeakMessage("Strobe OFF"); + break; + } + +} diff --git a/XPLPro_Arduino/XPLPro/examples/XPLProSwitchesExample/build1.jpg b/XPLPro_Arduino/XPLPro/examples/XPLProSwitchesExample/build1.jpg new file mode 100644 index 0000000..71922e6 Binary files /dev/null and b/XPLPro_Arduino/XPLPro/examples/XPLProSwitchesExample/build1.jpg differ diff --git a/XPLPro_Arduino/XPLPro/examples/XPLProSwitchesExample/build2.jpg b/XPLPro_Arduino/XPLPro/examples/XPLProSwitchesExample/build2.jpg new file mode 100644 index 0000000..4b059e4 Binary files /dev/null and b/XPLPro_Arduino/XPLPro/examples/XPLProSwitchesExample/build2.jpg differ diff --git a/XPLPro_Arduino/XPLPro/examples/XPLProSwitchesExample/build3.jpg b/XPLPro_Arduino/XPLPro/examples/XPLProSwitchesExample/build3.jpg new file mode 100644 index 0000000..a2bcb35 Binary files /dev/null and b/XPLPro_Arduino/XPLPro/examples/XPLProSwitchesExample/build3.jpg differ diff --git a/XPLPro_Arduino/XPLPro/examples/XPLProTutorialPart2/XPLProTutorialPart2.ino b/XPLPro_Arduino/XPLPro/examples/XPLProTutorialPart2/XPLProTutorialPart2.ino new file mode 100644 index 0000000..41e68fd --- /dev/null +++ b/XPLPro_Arduino/XPLPro/examples/XPLProTutorialPart2/XPLProTutorialPart2.ino @@ -0,0 +1,136 @@ + + +/* + * + * XPLProTutorialPart2 + * + * This sketch expands on the beacon demo to include a switch to control the nav lights within xplane. + * It is intended to accompany our YouTube video + * + * Created by Curiosity Workshop for XPL/Pro arduino->XPlane system. + * + * This sketch was developed and tested on an Arduino Mega. + * + To report problems, download updates and examples, suggest enhancements or get technical support: + + discord: https://discord.gg/RacvaRFsMW + patreon: www.patreon.com/curiosityworkshop + YouTube: https://youtube.com/channel/UCISdHdJIundC-OSVAEPzQIQ + * + * + */ + +#include +#include // include file for the X-plane direct interface +XPLPro XP(&Serial); // create an instance of it + + +long int startTime; + +#define PIN_NAVLIGHT 24 // pin for nav light switch + +int drefBeacon; // this stores a handle to the beacon light dataref, which we will read +int drefNavLight; // this stores a handle to the nav light dataref, which we will write to + +int navlightPrevious; // this tracks the value of the nav light switch so we don't constantly send updates. + +void setup() +{ + + pinMode(LED_BUILTIN, OUTPUT); // built in LED on arduino board will turn on and off with the status of the beacon light + pinMode(PIN_NAVLIGHT, INPUT_PULLUP); // otherwise the value will be erratic when the pin is open and nobody likes that. + + Serial.begin(XPL_BAUDRATE); // start serial interface. Baudrate is specified in the header, dont change + + /* + needed for initialization. Parameters are: + a texual identifier of your device + your function that will be called when xplane and the plugin are ready for dataref and command registrations + your function that will be called when xplane either shuts down or unloads an aircraft model + your function that will be called when we have requested sends of datarefs that have changed + */ + XP.begin("XPLPro Beacon Light Demo!", &xplRegister, &xplShutdown, &xplInboundHandler); + digitalWrite(LED_BUILTIN, LOW); + + +} + + +void loop() +{ + + XP.xloop(); // needs to run every cycle. + +/************************************************************************************************************************************ + * everything after the next line will only occur every 100ms. You can also utilize other time values. + * This helps maintain serial data flow and also helps with switch debounce. + * do NOT add delays anywhere in the loop cycle, it will interfere with the reception of serial data from xplane and the plugin. + ************************************************************************************************************************************ +*/ + + if (millis() - startTime > 100) startTime = millis(); else return; + + + if (digitalRead(PIN_NAVLIGHT) != navlightPrevious) // to conserve the flow of data we should keep track of the previously sent value so we don't send a new one every cycle + { + navlightPrevious = digitalRead(PIN_NAVLIGHT); + XP.datarefWrite(drefNavLight, navlightPrevious); + } + +} + +/* + * This function is the callback function we specified that will be called any time our requested data is sent to us. + * handle is the handle to the dataref. The following variables within the plugin are how we receive the data: + * + * inStruct *inData is a pointer to a structure that contains information about the incoming dataref. + * + * int inData->handle The handle of the incoming dataref + * int inData->element If the dataref is an array style dataref, this is the element of the array + * long inData->inLong long value for datarefs that are long values + * float inData->inFloat float value for datarefs that are float values + */ + void xplInboundHandler(inStruct *inData) +{ + if (inData->handle == drefBeacon) + { if (inData->inLong) digitalWrite(LED_BUILTIN, HIGH); // if beacon is on set the builtin led on + else digitalWrite(LED_BUILTIN, LOW); + } + + +} + +/* + * this is the function we set as a callback for when the plugin is ready to receive dataref and command bindings requests + * It could be called multiple times if for instance xplane is restarted or loads a different aircraft + */ +void xplRegister() +{ +/* + * This example registers a dataref for the beacon light. + * In the inbound handler section of the code we will turn on/off the LED on the arduino board to represent the status of the beacon light within xplane. + * On non-AVR boards remove the F() macro. + * + */ + drefBeacon = XP.registerDataRef(F("sim/cockpit2/switches/beacon_on") ); + XP.requestUpdates(drefBeacon, 100, 0); // Tell xplane to send us updates when the status of the beacon light changes. + // 100 means don't update more often than every 100ms and 0 is a precision specifier for float variables which is explained in another example, use 0 for now. + +/* + * This example registers a dataref for the nav light. This time we will control the status of the light with a switch. + * It is up to you to confirm that the datarefs you utilize are writable. A handy website allows you to search + * for them and understand their attributes: https://developer.x-plane.com/datarefs/ + * + * In the loop section of the code we will check the status of the switch send it to the navLight dataref within Xplane. + * To test this, connect one side of a normal toggle switch to ground and the other to the pin used in the #define for PIN_NAVLIGHT (9) + */ + drefNavLight = XP.registerDataRef(F("sim/cockpit/electrical/nav_lights_on") ); + + +} + +void xplShutdown() +{ + // if you need to do things when xplane shuts down or unloads an aircraft, do it here. + +} diff --git a/XPLPro_Arduino/XPLPro/readme.txt b/XPLPro_Arduino/XPLPro/readme.txt new file mode 100644 index 0000000..156986c --- /dev/null +++ b/XPLPro_Arduino/XPLPro/readme.txt @@ -0,0 +1,144 @@ +Curiosity Workshop XPLPro Arduino Library - Library for serial interface to Xplane SDK. + + Created by Michael Gerlicher, Curiosity Workshop, September 2020 - 2023. + + To report problems, download updates and examples, suggest enhancements or get technical support, please visit one of the following: + + discord: https://discord.gg/gzXetjEST4 + patreon: www.patreon.com/curiosityworkshop + youtube: https://www.youtube.com/channel/UCISdHdJIundC-OSVAEPzQIQ + facebook: https://www.facebook.com/curiosity.workshop42 + + Please support this project in one of the following ways: + + Free: like and subscribe to our youtube channel! + Support us at patreon.com/curiosityworkshop + +Known issues: + + Arduino Uno with I2c display seems to interfere with serial dialog between the arduino and Xplane. + Incompatibility with some bluetooth serial port installations, try disabling them if you have issues. + + Remember to close your serial monitor if it is open, it will tie up the serial port and your device won't be found. + +Wish List + + -- additional scaling points for data (some gauges are not linear) and individual scales for array element datarefs + -- exclusion of com ports, some com port devices cause issues when opened/closed/opened + + +Updates: + +-- XP.setDataFlowSpeed(1000); // max bytes per second plugin will send. + + + +-- Library now sends data type in the inStruct. It follows the native xplane format: + + #define xplmType_Unknown 0 // Data of a type the current XPLM doesn't do. + #define xplmType_Int 1 // A single 4 - byte integer, native endian. + #define xplmType_Float 2 // A single 4 - byte float, native endian. + #define xplmType_Double 4 // A single 8 - byte double, native endian. + #define xplmType_FloatArray 8 // An array of 4 - byte floats, native endian. + #define xplmType_IntArray 16 // An array of 4 - byte integers, native endian. + #define xplmType_Data 32 // A variable block of data. + +-- fixed plugin bug with data types for comparing +-- in Serial log unprintable characters now are represented by their hex value (0xXX) + void dataFlowPause(void); // Mostly for internal use but can be useful if your device is busy updating a display screen or whatever + void dataFlowResume(void); + int getBufferStatus(void); // returns number of bytes in receive buffer + void setDataFlowSpeed(unsigned long int); // Set max bytes to send per second. The plugin will always send a complete packet then wait until + ` // the time catches up (in terms of flight loops) so take that into consideration. + + -- when requesting updates to data datarefs, specify the maximum digits to return in the precision specifier. + + 16 May 2024 + + -- added datarefTouch(dataref) method to ask the plugin to update specified dataref. This is experimental, probably redundant and should be used sparingly lest + much dataflow be induced. Only use this if you know why you might want to use it. + + + 10 May 2024 + + -- Data scaling now enabled for dataref values sent from the plugin to the arduino. + + -- Improvement made to send only amount of digits requested with "precision" parameter on float datarefs, reducing dataflow from the plugin to the arduino. + + -- Improvements made within the library to reduce creation of buffers for data transfer. Thanks GioCC! + + -- Logic put in to force the transmission of a subscribed dataref after "requestUpdates" has been called. This improves synchronization issues. + + -- Some datarefs return that they support multiple data types and may not update them all consistently (looking at you Zibo...). We can now + specify the data type that we want when we request updates with the new functions: + + /// @brief Request DataRef updates from the plugin + /// @param handle Handle of the DataRef to subscribe to + /// @param type Specific type of data to request, see header file + /// @param rate Maximum rate for updates to reduce traffic + /// @param precision Floating point precision + void requestUpdatesType(int handle, int type, int rate, float precision); + + /// @brief Request DataRef updates from the plugin for an array DataRef + /// @param handle Handle of the DataRef to subscribe to + /// @param type Specific type of data to request, see header file + /// @param rate Maximum rate for updates to reduce traffic + /// @param precision Floating point precision + /// @param arrayElement Array element to subscribe to + void requestUpdatesType(int handle, int type, int rate, float precision, int arrayElement); + + type can be one of the following xplane data types, as defined in the Xplane SDK: + + #define xplmType_Int 1 // A single 4 - byte integer, native endian. + #define xplmType_Float 2 // A single 4 - //byte float, native endian. + #define xplmType_Double 4 // A single 8 - byte double, native endian. + #define xplmType_FloatArray 8 // An array of 4 - byte floats, native endian. + #define xplmType_IntArray 16 // An array of 4 - byte integers, native endian. + #define xplmType_Data 32 // A variable block of data. + + You can continue to use the original requestUpdates functions, it will default to whatever type the dataref reports when registered. + + -- Rewrite of the request updates functions to reduce iterations on each cycle, improving performance and simplicity of code + -- added debug messages (sent from XPLPro device) to the status window. They also appear in the XPLProError.log file. + + -- minor bug fixes in examples + -- added XPLSequencer for making timed macro style events. Airplane startup? + -- added XPLProArraysExample + -- added array capability to XPLPotentiometers.h and XPLSwitches.h. See the example for information + -- Added other examples + + + 06 Mar 2024: + + -- Examples are now contained within the xplpro library folder to ease distribution and so they will show up in the arduino IDE examples under xplpro. + + -- Added XPLProMax72XX example sketch for connecting 72xx series LED displays. + + -- Arduino library now sends build version, this is derived automatically from the date and time of compilation. It will be utilized in future updates. + + -- Added XPLSwitches.h to the library, as well as an example. This takes care of common uses of switches used to control xplane and extensively simplifies coding. + + -- Added XPLMuxIn4067.h to the library, as well as an example. This handles connection to a 4067 multiplexer, use 5 arduino pins to receive 16 inputs. + Use another arduino pin to add another 16 inputs. + + + 03 Mar 2024: + -- String functionality implemented + -- Several functionality bugs squashed + + 16 May 2023: + -- When sending data to the plugin long ints were converted to ints in some cases. This has been resolved. + + -- Additional examples added. + + + + + + ToDo: + + -- Add scaling to outbound (from the plugin) data. Inbound data currently supported. + -- minor floating point data transfer issues + -- Some serial devices that aren't programmed with XPLPro can cause crashes on subsequent loads. + -- Bug fix, datarefs are updated after subsequent device registrations (disengage/reengage) + \ No newline at end of file diff --git a/XPLPro_Arduino/XPLProManual.odt b/XPLPro_Arduino/XPLProManual.odt deleted file mode 100644 index 741961d..0000000 Binary files a/XPLPro_Arduino/XPLProManual.odt and /dev/null differ diff --git a/XPLPro_Arduino/readme.txt b/XPLPro_Arduino/readme.txt deleted file mode 100644 index f4e53b3..0000000 --- a/XPLPro_Arduino/readme.txt +++ /dev/null @@ -1,23 +0,0 @@ -Curiosity Workshop XPLPro Arduino Library - Library for serial interface to Xplane SDK. - - Created by Michael Gerlicher, Curiosity Workshop, September 2020 - 2023. - - To report problems, download updates and examples, suggest enhancements or get technical support, please visit one of the following: - - discord: https://discord.gg/gzXetjEST4 - www.patreon.com/curiosityworkshop - https://www.youtube.com/channel/UCISdHdJIundC-OSVAEPzQIQ - - - Please support this project in one of the following ways: - - Free: like and subscribe to our youtube channel! - Support us at patreon.com/curiosityworkshop - -Known issues: - - Arduino Uno with I2c display seems to interfere with serial dialog between the arduino and Xplane. - Incompatibility with some bluetooth serial port installations, try disabling them if you have issues. - - Remember to close your serial monitor if it is open, it will tie up the serial port and your device won't be found. - diff --git a/XPLPro_Plugin/64/libconfig.dll b/XPLPro_Plugin/64/libconfig.dll deleted file mode 100644 index 34f55bd..0000000 Binary files a/XPLPro_Plugin/64/libconfig.dll and /dev/null differ diff --git a/XPLPro_Plugin/64/win.xpl b/XPLPro_Plugin/64/win.xpl deleted file mode 100644 index 11b8afb..0000000 Binary files a/XPLPro_Plugin/64/win.xpl and /dev/null differ diff --git a/XPLPro_Plugin/XPLPro/64/win.xpl b/XPLPro_Plugin/XPLPro/64/win.xpl new file mode 100644 index 0000000..138a57f Binary files /dev/null and b/XPLPro_Plugin/XPLPro/64/win.xpl differ diff --git a/XPLPro_Plugin/XPLPro.cfg b/XPLPro_Plugin/XPLPro/XPLPro.cfg similarity index 100% rename from XPLPro_Plugin/XPLPro.cfg rename to XPLPro_Plugin/XPLPro/XPLPro.cfg diff --git a/XPLPro_Plugin/abbreviations.txt b/XPLPro_Plugin/XPLPro/abbreviations.txt similarity index 61% rename from XPLPro_Plugin/abbreviations.txt rename to XPLPro_Plugin/XPLPro/abbreviations.txt index eb611c2..c0a2682 100644 --- a/XPLPro_Plugin/abbreviations.txt +++ b/XPLPro_Plugin/XPLPro/abbreviations.txt @@ -10,4 +10,15 @@ LTnav = sim/cockpit/electrical/nav_lights_on LTland = sim/cockpit/electrical/landing_lights_on LTstrobe = sim/cockpit/electrical/strobe_lights_on LTtaxi = sim/cockpit/electrical/taxi_light_on +LTtax = sim/cockpit/electrical/taxi_light_on +LTlnd = sim/cockpit/electrical/landing_lights_on +LTnav = sim/cockpit/electrical/nav_lights_on +LTstr = sim/cockpit/electrical/strobe_lights_on + ANmc = sim/cockpit/warnings/annunciators/master_caution + +Commands can be abbreviated as well: + +CMDpause = sim/operation/pause_toggle +CMDtoga = sim/autopilot/take_off_go_around +CMDgearToggle = sim/flight_controls/landing_gear_toggle \ No newline at end of file diff --git a/XPLPro_Plugin_Source/Config.cpp b/XPLPro_Plugin_Source/Config.cpp new file mode 100644 index 0000000..7c2288b --- /dev/null +++ b/XPLPro_Plugin_Source/Config.cpp @@ -0,0 +1,113 @@ + +#include +//#include "XPLDirectCommon.h" + +#include "Config.h" + +Config::Config(char *inFileName) +{ + + strncpy(_cfgFileName, inFileName, 512); + _cfgFileName[511] = 0; + + FILE* cfgFile; + _validConfig = false; + + + if (cfgFile = fopen(_cfgFileName, "r")) + fclose(cfgFile); + else + { + fprintf(errlog, "***Configuration file %s doesn't exist, please replace...\n", _cfgFileName); + return; + // createNewConfigFile(); + } + + fprintf(errlog, "Opening configuration file %s... ", _cfgFileName); + + //config_setting_t* root, * setting, * group, * array; + config_init(&_cfg); + + if (!config_read_file(&_cfg, _cfgFileName)) + { + fprintf(errlog, "Error: %s Line:%i\r\n", config_error_text(&_cfg), config_error_line(&_cfg)); + config_destroy(&_cfg); + + } + else + fprintf(errlog, "Success.\n"); + + _validConfig = true; + +} + +Config::~Config() +{ + if (_validConfig) return; + + config_write_file(&_cfg, _cfgFileName); + + config_destroy(&_cfg); +} + + +// commit changes to the configuration file +void Config::saveFile(void) +{ + if (!config_write_file(&_cfg, _cfgFileName)) + { + fprintf(errlog, "Config::saveFile Error: %s Line:%i\r\n", config_error_text(&_cfg), config_error_line(&_cfg)); + return; + } + else + { + // fprintf(errlog, "Config::saveFile: Success updating configuration file.\n"); + + + } +} + + +// getSerialLogFlag +int Config::getSerialLogFlag(void) +{ + int flag = 0; + + if (!_validConfig) return 0; + + if (config_lookup_int(&_cfg, "XPLProPlugin.logSerialData", &flag) == CONFIG_TRUE) + fprintf(errlog, "Config module found XPLProPlugin.logSerialData value %i\r\n", flag); + else + fprintf(errlog, "*** Config module returned CONFIG_FALSE looking up value XPLProPlugin.logSerialData \r\n"); + + return flag; +} + +void Config::setSerialLogFlag(int flag) +{ + if (!_validConfig) return; + + config_setting_t* flagSetting = config_lookup(&_cfg, "XPLProPlugin.logSerialData"); + + if (flagSetting == NULL) + { + fprintf(errlog, "*** Config module unable to locate path XPLProPlugin.logSerialData during write\r\n"); + return; + } + + if (config_setting_set_int(flagSetting, flag) == CONFIG_TRUE) + fprintf(errlog, "Config module set XPLProPlugin.logSerialData to value %i\r\n", flag); + else + fprintf(errlog, "***Config module returned error setting XPLProPlugin.logSerialData to value %i\r\n", flag); +} + + + + + +/* + +Stuff related to components + +*/ + diff --git a/XPLPro_Plugin_Source/Config.h b/XPLPro_Plugin_Source/Config.h new file mode 100644 index 0000000..4574fea --- /dev/null +++ b/XPLPro_Plugin_Source/Config.h @@ -0,0 +1,46 @@ +#pragma once +#ifndef CONFIGCLASS_H_INCLUDED +#define CONFIGCLASS_H_INCLUDED + +#include "libconfig.h" + + + +extern FILE* errlog; + +class Config +{ +private: + + char _cfgFileName[512]; + + config_t _cfg; + + // void createNewConfigFile(void); + + + +public: + + Config(char *inFileName); + ~Config(); + void saveFile(void); + + int getSerialLogFlag(void); + void setSerialLogFlag(int); + + // stuff for components + int getComponentCount(void); + int Config::getComponentInfo(int element, int* type, const char** name, const char** board, int* pinCount, int* linkCount); + void setComponentInfo(int element, int* type, const char* name, const char* board, const char* dataref, int arrayElement); + int getComponentPinInfo(int componentElement, int pinElement, const char** pinName); + + int Config::getComponentLinkInfo(int componentIndex, int linkIndex, char* inName, const char** outData); + int Config::getComponentLinkInfo(int componentIndex, int linkIndex, char* inName, int* outData); + + // local globals + int _validConfig; +}; + +#endif + diff --git a/XPLPro_Plugin_Source/DataTransfer.cpp b/XPLPro_Plugin_Source/DataTransfer.cpp new file mode 100644 index 0000000..bd47a08 --- /dev/null +++ b/XPLPro_Plugin_Source/DataTransfer.cpp @@ -0,0 +1,467 @@ +#define XPLM200 + + + + +#include "XPLProCommon.h" + +#include "XPLMPlugin.h" +#include "XPLMDataAccess.h" +#include "XPLMDisplay.h" +#include "XPLMGraphics.h" +#include "XPLMMenus.h" + +#include "XPWidgets.h" +#include "XPStandardWidgets.h" + +#include "XPLMUtilities.h" +#include "XPLMProcessing.h" + +#include "XPLMCamera.h" +#include "XPUIGraphics.h" +#include "XPWidgetUtils.h" + + +#include "XPLProPlugin.h" +#include "XPLDevice.h" + +#include "DataTransfer.h" + +#include + + + +int refHandleCounter = 0; +int cmdHandleCounter = 0; + + +long int packetsSent; +long int packetsReceived; + +int validPorts = 0; + +extern FILE* errlog; +extern FILE* serialLogFile; +extern float elapsedTime; +extern int lastRefSent; +extern int lastRefElementSent; + + +CommandBinding myCommands[XPL_MAXCOMMANDS_PC]; +DataRefBinding myBindings[XPL_MAXDATAREFS_PC]; +XPLDevice* myXPLDevices[XPLDEVICES_MAXDEVICES]; + +/**************************************************************************************/ +/* disengage -- unregister all datarefs and close all com ports */ +/**************************************************************************************/ +void disengageDevices(void) +{ + sendExitMessage(); + + for (int i = 0; i < XPLDEVICES_MAXDEVICES; i++) + { + + if (myXPLDevices[i]) + { + myXPLDevices[i]->port->shutDown(); + delete myXPLDevices[i]->port; + delete myXPLDevices[i]; + myXPLDevices[i] = NULL; + } + } + + validPorts = 0; + + for (int i = 0; i < refHandleCounter; i++) + { + myBindings[i].deviceIndex = -1; + myBindings[i].bindingActive = 0; + myBindings[i].Handle = -1; + myBindings[i].scaleFlag = 0; + + for (int j = 0; j < XPLMAX_ELEMENTS; j++) + { + myBindings[i].readFlag[j] = 0; + } + + XPLMUnregisterDataAccessor(myBindings[i].xplaneDataRefHandle); // deregister with xplane + myBindings[i].xplaneDataRefTypeID = 0; + myBindings[i].xplaneDataRefName[0] = NULL; + if (myBindings[i].currentSents[0] != NULL) + { + free(myBindings[i].currentSents[0]); + myBindings[i].currentSents[0] = NULL; + } + + } + + refHandleCounter = 0; + + for (int i = 0; i < cmdHandleCounter; i++) + { + myCommands[i].deviceIndex = -1; + myCommands[i].bindingActive = 0; + myCommands[i].Handle = -1; + myCommands[i].xplaneCommandHandle = NULL; + myCommands[i].xplaneCommandName[0] = NULL; + + } + + cmdHandleCounter = 0; + + +} + +/* +* Searches com ports for devices, then queries for datarefs and commands. +*/ +void engageDevices(void) +{ + fprintf(errlog, "engageDevices: started...\n"); + findDevices(); + activateDevices(); + //_updateDataRefs(1); // 1 represents to force updates to the devices + //sendRefreshRequest(); + +} + +/**************************************************************************************/ +/* _updateDataRefs -- get current dataref values for all registered datarefs */ +/**************************************************************************************/ +void _updateDataRefs(int forceUpdate) +{ + + int newVall; + float newValf; + double newValD; + + char writeBuffer[XPLMAX_PACKETSIZE]; + char stringBuffer[XPLMAX_PACKETSIZE - 5]; + + + + for (int i = 0; i < refHandleCounter; i++) + { + if (myBindings[i].bindingActive && myBindings[i].readFlag[0]) // todo: this needs to check all possible readFlags + { + + // if (elapsedTime - myXPLDevices[myBindings[i].deviceIndex].lastSendTime < myXPLDevices[myBindings[i].deviceIndex].minTimeBetweenFrames/1000 && !forceUpdate) + // break; + if (myBindings[i].xplaneDataRefTypeID & xplmType_Int) // process for datarefs of type int + { + newVall = (long int)XPLMGetDatai(myBindings[i].xplaneDataRefHandle); + + if (newVall != myBindings[i].currentSentl[0] || forceUpdate) + { + lastRefSent = i; + myBindings[i].currentSentl[0] = newVall; + sprintf_s(writeBuffer, XPLMAX_PACKETSIZE, ",%i,%ld", i, newVall); + myXPLDevices[myBindings[i].deviceIndex]->_writePacket(XPLCMD_DATAREFUPDATEINT, writeBuffer); + myXPLDevices[myBindings[i].deviceIndex]->lastSendTime = elapsedTime; + + // fprintf(errlog, "using packet: %s\r\n", writeBuffer); + + } + + } + + if (myBindings[i].xplaneDataRefTypeID & xplmType_IntArray) // process for datarefs of type int Array + { + for (int j = 0; j < XPLMAX_ELEMENTS; j++) // todo, this method should be something better + { + XPLMGetDatavi(myBindings[i].xplaneDataRefHandle, &newVall, j, 1); + if (myBindings[i].precision) newVall = ((int)(newVall / myBindings[i].precision) * myBindings[i].precision); + if (newVall != myBindings[i].currentSentl[j] || forceUpdate) + { + lastRefSent = i; + lastRefElementSent = j; + myBindings[i].currentSentl[j] = newVall; + sprintf_s(writeBuffer, XPLMAX_PACKETSIZE, ",%i,%ld,%i", i, newVall,j); + myXPLDevices[myBindings[i].deviceIndex]->_writePacket(XPLCMD_DATAREFUPDATEINTARRAY, writeBuffer); + myXPLDevices[myBindings[i].deviceIndex]->lastSendTime = elapsedTime; + + // fprintf(errlog, "using packet: %s\r\n", writeBuffer); + } + } + } + + + if (myBindings[i].xplaneDataRefTypeID & xplmType_Float) // process for datarefs of type float + { + + newValf = (float)XPLMGetDataf(myBindings[i].xplaneDataRefHandle); + + // fprintf(errlog, "updating dataRef %s with value %f...\r\n ", myBindings[i].xplaneDataRefName, newValf); + if (myBindings[i].precision) newValf = ((int)(newValf / myBindings[i].precision) * myBindings[i].precision); + + if (newValf != myBindings[i].currentSentf[0] || forceUpdate) + { + lastRefSent = i; + myBindings[i].currentSentf[0] = newValf; + sprintf_s(writeBuffer, XPLMAX_PACKETSIZE, ",%i,%f", i, newValf); + myXPLDevices[myBindings[i].deviceIndex]->_writePacket(XPLCMD_DATAREFUPDATEFLOAT, writeBuffer); + myXPLDevices[myBindings[i].deviceIndex]->lastSendTime = elapsedTime; + + // fprintf(errlog, "using packet: %s\r\n", writeBuffer); + + } + + } + + + if (myBindings[i].xplaneDataRefTypeID & xplmType_FloatArray) // process for datarefs of type float (array) + { + + + for (int j = 0; j < XPLMAX_ELEMENTS; j++) + { + XPLMGetDatavf(myBindings[i].xplaneDataRefHandle, &newValf, j, 1); + if (myBindings[i].precision) newValf = ((int)(newValf / myBindings[i].precision) * myBindings[i].precision); + + if (newValf != myBindings[i].currentSentf[j] || forceUpdate) + { + lastRefSent = i; + lastRefElementSent = j; + myBindings[i].currentSentf[j] = newValf; + sprintf_s(writeBuffer, XPLMAX_PACKETSIZE, ",%i,%f,%i", i, newValf,j); + myXPLDevices[myBindings[i].deviceIndex]->_writePacket(XPLCMD_DATAREFUPDATEFLOATARRAY, writeBuffer); + myXPLDevices[myBindings[i].deviceIndex]->lastSendTime = elapsedTime; + + // fprintf(errlog, "using packet: %s\r\n", writeBuffer); + + } + } + + } + + if (myBindings[i].xplaneDataRefTypeID & xplmType_Double) // process for datarefs of type double + { + + newValD = (double)XPLMGetDatad(myBindings[i].xplaneDataRefHandle); + + // fprintf(errlog, "updating dataRef %s with value %f...\r\n ", myBindings[i].xplaneDataRefName, newValf); + if (myBindings[i].precision) newValD = ((int)(newValD / myBindings[i].precision) * myBindings[i].precision); + + if (newValD != myBindings[i].currentSentD[0] || forceUpdate) + { + lastRefSent = i; + myBindings[i].currentSentD[0] = newValD; + sprintf_s(writeBuffer, XPLMAX_PACKETSIZE, ",%i,%f", i, newValD); + myXPLDevices[myBindings[i].deviceIndex]->_writePacket(XPLCMD_DATAREFUPDATEFLOAT, writeBuffer); + myXPLDevices[myBindings[i].deviceIndex]->lastSendTime = elapsedTime; + + // fprintf(errlog, "using packet: %s\r\n", writeBuffer); + + } + + } + + if (myBindings[i].xplaneDataRefTypeID & xplmType_Data) // process for datarefs of type Data (strings) + { + + newVall = (long int)XPLMGetDatab(myBindings[i].xplaneDataRefHandle, stringBuffer, 0, XPLMAX_PACKETSIZE - 5); + //stringBuffer[newVall] = 0; // null terminate + // fprintf(errlog, "updating dataRef %s with value %i...\r\n ", myBindings[i].xplaneDataRefName, newVall); + + if (memcmp(myBindings[i].currentSents[0], stringBuffer, newVall) || forceUpdate) + { + lastRefSent = i; + memcpy(myBindings[i].currentSents[0], stringBuffer, newVall); + sprintf(writeBuffer, ",%i,", i); + + memcpy(&writeBuffer[3], stringBuffer, newVall); + myXPLDevices[myBindings[i].deviceIndex]->_writePacketN(XPLCMD_DATAREFUPDATESTRING, writeBuffer, newVall + 3); + myXPLDevices[myBindings[i].deviceIndex]->lastSendTime = elapsedTime; + + // fprintf(errlog, "Updating dataref %s with packet: %s length: %i\r\n", myBindings[i].xplaneDataRefName, writeBuffer, newVall); + + + } + + } + } + + } + + +} + +/* + _updateCommands -- make sure commands are all updated. + */ +void _updateCommands(void) +{ + + + for (int i = 0; i < cmdHandleCounter; i++) + { + if (myCommands[i].bindingActive && myCommands[i].accumulator > 0) + { + + XPLMCommandOnce(myCommands[i].xplaneCommandHandle); + myCommands[i].accumulator--; + if (myCommands[i].accumulator < 0) myCommands[i].accumulator = 0; + + + } + + } + + +} + +/**************************************************************************************/ +/* activateDevices -- request dataref bindings from all active devices */ +/**************************************************************************************/ +void activateDevices(void) +{ + + fprintf(errlog, "XPLPro: Activating Devices... \n"); + + for (int i = 0; i < XPLDEVICES_MAXDEVICES; i++) + { + if (!myXPLDevices[i]) break; + + fprintf(errlog, "Requesting dataRef or Command registrations from port %s on device [%i]: %s\n", myXPLDevices[i]->port->portName, i, myXPLDevices[i]->deviceName); + myXPLDevices[i]->_writePacket(XPLCMD_SENDREQUEST, ""); + + } + +} + +/* + findDevices -- Scan for XPLPro devices and fills array with active devices +*/ + +int findDevices(void) +{ + time_t startTime; + serialClass* port; + validPorts = 0; + + fprintf(errlog, "Searching Com Ports... "); + + for (UINT i = 1; i < 256; i++) + { + port = new serialClass; + + if (port->begin(i) == i) + { + + fprintf(errlog, "\nFound valid port %s. Attemping poll for XPLPro device... ", port->portName); + myXPLDevices[validPorts] = new XPLDevice(validPorts); + myXPLDevices[validPorts]->port = port; + + if (myXPLDevices[validPorts]->_writePacket(XPLCMD_SENDNAME, "")) + fprintf(errlog, "Valid write operation, seems OK\n"); + + + startTime = time(NULL); + + while (difftime(time(NULL), startTime) < XPL_TIMEOUT_SECONDS && !myXPLDevices[validPorts]->isActive()) _processSerial(); + + if (!myXPLDevices[validPorts]->isActive()) + { + fprintf(errlog, "No response after %i seconds\n", XPL_TIMEOUT_SECONDS); + XPLMDebugString("."); + port->shutDown(); + delete myXPLDevices[validPorts]; + delete port; + //myXPLDevices[validPorts]->comPortName[0] = 0; + } + + else + { + myXPLDevices[validPorts]->readBuffer[0] = '\0'; + fprintf(errlog, " Device [%i] on %s identifies as an XPLPro device named: %s\n", validPorts, port->portName, myXPLDevices[validPorts]->deviceName); + + validPorts++; + } + + } + else + { + port->shutDown(); + delete port; + } + + } + + + //delete myXPLDevices[validPorts]; + XPLMDebugString(" Done Searching Com Ports\n"); + fprintf(errlog, "Total of %i compatible devices were found. \n\n", validPorts); + return 0; +} + + +void _processSerial() +{ + int port = 0; + + while (myXPLDevices[port] && port < XPLDEVICES_MAXDEVICES) + { + //fprintf(errlog, "working on xpldevice %i ...", port); + + myXPLDevices[port]->processSerial(); + + port++; + } +} + +/* + sendRefreshRequest -- request writable datarefs be refreshed +*/ + +void sendRefreshRequest(void) +{ + for (int i = 0; i < XPLDEVICES_MAXDEVICES; i++) + { + if (myXPLDevices[i]) + if (myXPLDevices[i] && myXPLDevices[i]->RefsLoaded) myXPLDevices[i]->_writePacket(XPLREQUEST_REFRESH, ""); + } + +} + +void sendExitMessage(void) +{ + fprintf(errlog, "\n*Xplane indicates that it is closing or unloading the current aircraft. I am letting all the devices know.\n"); + + for (int i = 0; i < XPLDEVICES_MAXDEVICES; i++) + { + if (myXPLDevices[i]) + if (myXPLDevices[i] && myXPLDevices[i]->RefsLoaded) myXPLDevices[i]->_writePacket(XPL_EXITING, ""); + } + +} + + + +/* +* reloadDevices +*/ +void reloadDevices(void) +{ + fprintf(errlog, "XPLPro device requested to reset and reload devices. \n"); + + + disengageDevices(); // just to make sure we are cleared + engageDevices(); + + + +} + + +/* + * map functions + */ +float mapFloat(long x, long inMin, long inMax, long outMin, long outMax) +{ + return (float)(x - inMin) * (outMax - outMin) / (float)(inMax - inMin) + outMin; +} + +long mapInt(long x, long inMin, long inMax, long outMin, long outMax) +{ + return (x - inMin) * (outMax - outMin) / (inMax - inMin) + outMin; +} \ No newline at end of file diff --git a/XPLPro_Plugin_Source/DataTransfer.h b/XPLPro_Plugin_Source/DataTransfer.h new file mode 100644 index 0000000..48ba07b --- /dev/null +++ b/XPLPro_Plugin_Source/DataTransfer.h @@ -0,0 +1,69 @@ +#pragma once +//#include "Serial.h" +#include "XPLProCommon.h" + +void BindingsSetup(void); +void BindingsLoad(void); + +int findDevices(void); +void activateDevices(void); +void sendExitMessage(void); +void sendRefreshRequest(void); +void disengageDevices(void); +void engageDevices(void); +void _processPacket(int); +void _processSerial(void); +void _updateDataRefs(int forceUpdate); +void _updateCommands(void); +int _writePacket(int port, char, char*); +int _writePacketN(int port, char, char*, int); +void reloadDevices(void); + +float mapFloat(long x, long inMin, long inMax, long outMin, long outMax); +long mapInt(long x, long inMin, long inMax, long outMin, long outMax); + +struct DataRefBinding +{ + int deviceIndex; // which XPLDirectDevice is this attached to + int bindingActive; // Is this binding being used + int Handle; // Handle is arbitrary and incremental and assigned by this plugin to send to arduino board +// int RWMode; // XPL_READ 1 XPL_WRITE 2 XPL_READWRITE 3 + int readFlag[XPLMAX_ELEMENTS]; // true if device requests updates for this dataref value/element + float precision; // reduce resolution by dividing then remultiplying with this number, or 0 for no processing + int updateRate; // minimum time in ms between updates sent + time_t lastUpdate; // time of last update + XPLMDataRef xplaneDataRefHandle; // Dataref handle of xplane element associated with binding + XPLMDataTypeID xplaneDataRefTypeID; // dataRef type + char xplaneDataRefName[80]; // character name of xplane dataref + int scaleFlag; + int scaleFromLow; + int scaleFromHigh; + int scaleToLow; + int scaleToHigh; + int currentElementSent[XPLMAX_ELEMENTS]; + long currentSentl[XPLMAX_ELEMENTS]; // Current long value sent to device + long currentReceivedl[XPLMAX_ELEMENTS]; // Current long value sent to Xplane + float currentSentf[XPLMAX_ELEMENTS]; // Current float value sent to device + + float currentReceivedf[XPLMAX_ELEMENTS]; // Current float value sent to Xplane + double currentSentD[XPLMAX_ELEMENTS]; // current double value sent to device + double currentReceivedD[XPLMAX_ELEMENTS]; // current double value sent to Xplane + + char* currentSents[XPLMAX_ELEMENTS]; // dynamically allocated string buffer for string types. + + +}; + +struct CommandBinding +{ + int deviceIndex; // which XPL Device is this attached to + int bindingActive; // Is this binding being used + int Handle; // Handle is incremental and assigned by this plugin to send to arduino board + + XPLMCommandRef xplaneCommandHandle; // Dataref handle of xplane element associated with binding + + char xplaneCommandName[80]; // character name of xplane dataref + int accumulator; + //int xplaneCurrentReceived; // Current value sent to Xplane + +}; diff --git a/XPLPro_Plugin_Source/SDK/CHeaders/Widgets/XPStandardWidgets.h b/XPLPro_Plugin_Source/SDK/CHeaders/Widgets/XPStandardWidgets.h new file mode 100644 index 0000000..42d4987 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/CHeaders/Widgets/XPStandardWidgets.h @@ -0,0 +1,556 @@ +#ifndef _XPStandardWidgets_h_ +#define _XPStandardWidgets_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPStandardWidgets + ***************************************************************************/ +/* + * ## THEORY OF OPERATION + * + * The standard widgets are widgets built into the widgets library. While you + * can gain access to the widget function that drives them, you generally use + * them by calling XPCreateWidget and then listening for special messages, + * etc. + * + * The standard widgets often send mesages to themselves when the user + * performs an event; these messages are sent up the widget hierarchy until + * they are handled. So you can add a widget proc directly to a push button + * (for example) to intercept the message when it is clicked, or you can put + * one widget proc on a window for all of the push buttons in the window. Most + * of these messages contain the original widget ID as a parameter so you can + * know which widget is messaging no matter who it is sent to. + * + */ + +#include "XPWidgetDefs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*************************************************************************** + * MAIN WINDOW + ***************************************************************************/ +/* + * The main window widget class provides a "window" as the user knows it. + * These windows are dragable and can be selected. Use them to create floating + * windows and non-modal dialogs. + * + */ + + +#define xpWidgetClass_MainWindow 1 + +/* + * Main Window Type Values + * + * These type values are used to control the appearance of a main window. + * + */ +enum { + /* The standard main window; pin stripes on XP7, metal frame on XP 6. */ + xpMainWindowStyle_MainWindow = 0, + + /* A translucent dark gray window, like the one ATC messages appear in. */ + xpMainWindowStyle_Translucent = 1, + + +}; + +/* + * Main Window Properties + * + */ +enum { + /* This property specifies the type of window. Set to one of the main window * + * types above. */ + xpProperty_MainWindowType = 1100, + + /* This property specifies whether the main window has close boxes in its * + * corners. */ + xpProperty_MainWindowHasCloseBoxes = 1200, + + +}; + +/* + * MainWindow Messages + * + */ +enum { + /* This message is sent when the close buttons are pressed for your window. */ + xpMessage_CloseButtonPushed = 1200, + + +}; + +/*************************************************************************** + * SUB WINDOW + ***************************************************************************/ +/* + * X-Plane dialogs are divided into separate areas; the sub window widgets + * allow you to make these areas. Create one main window and place several + * subwindows inside it. Then place your controls inside the subwindows. + * + */ + + +#define xpWidgetClass_SubWindow 2 + +/* + * SubWindow Type Values + * + * These values control the appearance of the subwindow. + * + */ +enum { + /* A panel that sits inside a main window. */ + xpSubWindowStyle_SubWindow = 0, + + /* A screen that sits inside a panel for showing text information. */ + xpSubWindowStyle_Screen = 2, + + /* A list view for scrolling lists. */ + xpSubWindowStyle_ListView = 3, + + +}; + +/* + * SubWindow Properties + * + */ +enum { + /* This property specifies the type of window. Set to one of the subwindow * + * types above. */ + xpProperty_SubWindowType = 1200, + + +}; + +/*************************************************************************** + * BUTTON + ***************************************************************************/ +/* + * The button class provides a number of different button styles and + * behaviors, including push buttons, radio buttons, check boxes, etc. The + * button label appears on or next to the button depending on the button's + * appearance, or type. + * + * The button's behavior is a separate property that dictates who it hilights + * and what kinds of messages it sends. Since behavior and type are different, + * you can do strange things like make check boxes that act as push buttons or + * push buttons with radio button behavior. + * + * In X-Plane 6 there were no check box graphics. The result is the following + * behavior: in X-Plane + * 6 all check box and radio buttons are round (radio-button style) buttons; + * in X-Plane 7 they are all square (check-box style) buttons. In a future + * version of X-Plane, the xpButtonBehavior enums will provide the correct + * graphic (check box or radio button) giving the expected result. + * + */ + + +#define xpWidgetClass_Button 3 + +/* + * Button Types + * + * These define the visual appearance of buttons but not how they respond to + * the mouse. + * + */ +enum { + /* This is a standard push button, like an 'OK' or 'Cancel' button in a dialog* + * box. */ + xpPushButton = 0, + + /* A check box or radio button. Use this and the button behaviors below to * + * get the desired behavior. */ + xpRadioButton = 1, + + /* A window close box. */ + xpWindowCloseBox = 3, + + /* A small down arrow. */ + xpLittleDownArrow = 5, + + /* A small up arrow. */ + xpLittleUpArrow = 6, + + +}; + +/* + * Button Behavior Values + * + * These define how the button responds to mouse clicks. + * + */ +enum { + /* Standard push button behavior. The button hilites while the mouse is * + * clicked over it and unhilites when the mouse is moved outside of it or * + * released. If the mouse is released over the button, the * + * xpMsg_PushButtonPressed message is sent. */ + xpButtonBehaviorPushButton = 0, + + /* Check box behavior. The button immediately toggles its value when the mouse* + * is clicked and sends out a xpMsg_ButtonStateChanged message. */ + xpButtonBehaviorCheckBox = 1, + + /* Radio button behavior. The button immediately sets its state to one and * + * sends out a xpMsg_ButtonStateChanged message if it was not already set to * + * one. You must turn off other radio buttons in a group in your code. */ + xpButtonBehaviorRadioButton = 2, + + +}; + +/* + * Button Properties + * + */ +enum { + /* This property sets the visual type of button. Use one of the button types * + * above. */ + xpProperty_ButtonType = 1300, + + /* This property sets the button's behavior. Use one of the button behaviors * + * above. */ + xpProperty_ButtonBehavior = 1301, + + /* This property tells whether a check box or radio button is "checked" or * + * not. Not used for push buttons. */ + xpProperty_ButtonState = 1302, + + +}; + +/* + * Button Messages + * + * These messages are sent by the button to itself and then up the widget + * chain when the button is clicked. (You may intercept them by providing a + * widget handler for the button itself or by providing a handler in a parent + * widget.) + * + */ +enum { + /* This message is sent when the user completes a click and release in a * + * button with push button behavior. Parameter one of the message is the * + * widget ID of the button. This message is dispatched up the widget * + * hierarchy. */ + xpMsg_PushButtonPressed = 1300, + + /* This message is sent when a button is clicked that has radio button or * + * check box behavior and its value changes. (Note that if the value changes * + * by setting a property you do not receive this message!) Parameter one is * + * the widget ID of the button, parameter 2 is the new state value, either * + * zero or one. This message is dispatched up the widget hierarchy. */ + xpMsg_ButtonStateChanged = 1301, + + +}; + +/*************************************************************************** + * TEXT FIELD + ***************************************************************************/ +/* + * The text field widget provides an editable text field including mouse + * selection and keyboard navigation. The contents of the text field are its + * descriptor. (The descriptor changes as the user types.) + * + * The text field can have a number of types, that effect the visual layout of + * the text field. The text field sends messages to itself so you may control + * its behavior. + * + * If you need to filter keystrokes, add a new handler and intercept the key + * press message. Since key presses are passed by pointer, you can modify the + * keystroke and pass it through to the text field widget. + * + * WARNING: in X-Plane before 7.10 (including 6.70) null characters could + * crash X-Plane. To prevent this, wrap this object with a filter function + * (more instructions can be found on the SDK website). + * + */ + + +#define xpWidgetClass_TextField 4 + +/* + * Text Field Type Values + * + * These control the look of the text field. + * + */ +enum { + /* A field for text entry. */ + xpTextEntryField = 0, + + /* A transparent text field. The user can type and the text is drawn, but no * + * background is drawn. You can draw your own background by adding a widget * + * handler and prehandling the draw message. */ + xpTextTransparent = 3, + + /* A translucent edit field, dark gray. */ + xpTextTranslucent = 4, + + +}; + +/* + * Text Field Properties + * + */ +enum { + /* This is the character position the selection starts at, zero based. If it * + * is the same as the end insertion point, the insertion point is not a * + * selection. */ + xpProperty_EditFieldSelStart = 1400, + + /* This is the character position of the end of the selection. */ + xpProperty_EditFieldSelEnd = 1401, + + /* This is the character position a drag was started at if the user is * + * dragging to select text, or -1 if a drag is not in progress. */ + xpProperty_EditFieldSelDragStart = 1402, + + /* This is the type of text field to display, from the above list. */ + xpProperty_TextFieldType = 1403, + + /* Set this property to 1 to password protect the field. Characters will be * + * drawn as *s even though the descriptor will contain plain-text. */ + xpProperty_PasswordMode = 1404, + + /* The max number of characters you can enter, if limited. Zero means * + * unlimited. */ + xpProperty_MaxCharacters = 1405, + + /* The first visible character on the left. This effectively scrolls the text* + * field. */ + xpProperty_ScrollPosition = 1406, + + /* The font to draw the field's text with. (An XPLMFontID.) */ + xpProperty_Font = 1407, + + /* This is the active side of the insert selection. (Internal) */ + xpProperty_ActiveEditSide = 1408, + + +}; + +/* + * Text Field Messages + * + */ +enum { + /* The text field sends this message to itself when its text changes. It sends* + * the message up the call chain; param1 is the text field's widget ID. */ + xpMsg_TextFieldChanged = 1400, + + +}; + +/*************************************************************************** + * SCROLL BAR + ***************************************************************************/ +/* + * A standard scroll bar or slider control. The scroll bar has a minimum, + * maximum and current value that is updated when the user drags it. The + * scroll bar sends continuous messages as it is dragged. + * + */ + + +#define xpWidgetClass_ScrollBar 5 + +/* + * Scroll Bar Type Values + * + * This defines how the scroll bar looks. + * + */ +enum { + /* A standard X-Plane scroll bar (with arrows on the ends). */ + xpScrollBarTypeScrollBar = 0, + + /* A slider, no arrows. */ + xpScrollBarTypeSlider = 1, + + +}; + +/* + * Scroll Bar Properties + * + */ +enum { + /* The current position of the thumb (in between the min and max, inclusive) */ + xpProperty_ScrollBarSliderPosition = 1500, + + /* The value the scroll bar has when the thumb is in the lowest position. */ + xpProperty_ScrollBarMin = 1501, + + /* The value the scroll bar has when the thumb is in the highest position. */ + xpProperty_ScrollBarMax = 1502, + + /* How many units to move the scroll bar when clicking next to the thumb. The * + * scroll bar always moves one unit when the arrows are clicked. */ + xpProperty_ScrollBarPageAmount = 1503, + + /* The type of scrollbar from the enums above. */ + xpProperty_ScrollBarType = 1504, + + /* Used internally. */ + xpProperty_ScrollBarSlop = 1505, + + +}; + +/* + * Scroll Bar Messages + * + */ +enum { + /* The scroll bar sends this message when the slider position changes. It * + * sends the message up the call chain; param1 is the Scroll Bar widget ID. */ + xpMsg_ScrollBarSliderPositionChanged = 1500, + + +}; + +/*************************************************************************** + * CAPTION + ***************************************************************************/ +/* + * A caption is a simple widget that shows its descriptor as a string, useful + * for labeling parts of a window. It always shows its descriptor as its + * string and is otherwise transparent. + * + */ + + +#define xpWidgetClass_Caption 6 + +/* + * Caption Properties + * + */ +enum { + /* This property specifies whether the caption is lit; use lit captions * + * against screens. */ + xpProperty_CaptionLit = 1600, + + +}; + +/*************************************************************************** + * GENERAL GRAPHICS + ***************************************************************************/ +/* + * The general graphics widget can show one of many icons available from + * X-Plane. + * + */ + + +#define xpWidgetClass_GeneralGraphics 7 + +/* + * General Graphics Types Values + * + * These define the icon for the general graphics. + * + */ +enum { + xpShip = 4, + + xpILSGlideScope = 5, + + xpMarkerLeft = 6, + + xp_Airport = 7, + + xpNDB = 8, + + xpVOR = 9, + + xpRadioTower = 10, + + xpAircraftCarrier = 11, + + xpFire = 12, + + xpMarkerRight = 13, + + xpCustomObject = 14, + + xpCoolingTower = 15, + + xpSmokeStack = 16, + + xpBuilding = 17, + + xpPowerLine = 18, + + xpVORWithCompassRose = 19, + + xpOilPlatform = 21, + + xpOilPlatformSmall = 22, + + xpWayPoint = 23, + + +}; + +/* + * General Graphics Properties + * + */ +enum { + /* This property controls the type of icon that is drawn. */ + xpProperty_GeneralGraphicsType = 1700, + + +}; + +/*************************************************************************** + * PROGRESS INDICATOR + ***************************************************************************/ +/* + * This widget implements a progress indicator as seen when X-Plane starts up. + * + */ + +#define xpWidgetClass_Progress 8 + +/* + * Progress Indicator Properties + * + */ +enum { + /* This is the current value of the progress indicator. */ + xpProperty_ProgressPosition = 1800, + + /* This is the minimum value, equivalent to 0% filled. */ + xpProperty_ProgressMin = 1801, + + /* This is the maximum value, equivalent to 100% filled. */ + xpProperty_ProgressMax = 1802, + + +}; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/CHeaders/Widgets/XPUIGraphics.h b/XPLPro_Plugin_Source/SDK/CHeaders/Widgets/XPUIGraphics.h new file mode 100644 index 0000000..b70e0f6 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/CHeaders/Widgets/XPUIGraphics.h @@ -0,0 +1,354 @@ +#ifndef _XPUIGraphics_h_ +#define _XPUIGraphics_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPUIGraphics + ***************************************************************************/ + +#include "XPWidgetDefs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*************************************************************************** + * UI GRAPHICS + ***************************************************************************/ + +/* + * XPWindowStyle + * + * There are a few built-in window styles in X-Plane that you can use. + * + * Note that X-Plane 6 does not offer real shadow-compositing; you must make + * sure to put a window on top of another window of the right style to the + * shadows work, etc. This applies to elements with insets and shadows. The + * rules are: + * + * Sub windows must go on top of main windows, and screens and list views on + * top of subwindows. Only help and main windows can be over the main screen. + * + * With X-Plane 7 any window or element may be placed over any other element. + * + * Some windows are scaled by stretching, some by repeating. The drawing + * routines know which scaling method to use. The list view cannot be rescaled + * in X-Plane 6 because it has both a repeating pattern and a gradient in one + * element. All other elements can be rescaled. + * + */ +enum { + /* An LCD screen that shows help. */ + xpWindow_Help = 0, + + /* A dialog box window. */ + xpWindow_MainWindow = 1, + + /* A panel or frame within a dialog box window. */ + xpWindow_SubWindow = 2, + + /* An LCD screen within a panel to hold text displays. */ + xpWindow_Screen = 4, + + /* A list view within a panel for scrolling file names, etc. */ + xpWindow_ListView = 5, + + +}; +typedef int XPWindowStyle; + +/* + * XPDrawWindow + * + * This routine draws a window of the given dimensions at the given offset on + * the virtual screen in a given style. The window is automatically scaled as + * appropriate using a bitmap scaling technique (scaling or repeating) as + * appropriate to the style. + * + */ +WIDGET_API void XPDrawWindow( + int inX1, + int inY1, + int inX2, + int inY2, + XPWindowStyle inStyle); + +/* + * XPGetWindowDefaultDimensions + * + * This routine returns the default dimensions for a window. Output is either + * a minimum or fixed value depending on whether the window is scalable. + * + */ +WIDGET_API void XPGetWindowDefaultDimensions( + XPWindowStyle inStyle, + int * outWidth, /* Can be NULL */ + int * outHeight); /* Can be NULL */ + +/* + * XPElementStyle + * + * Elements are individually drawable UI things like push buttons, etc. The + * style defines what kind of element you are drawing. Elements can be + * stretched in one or two dimensions (depending on the element). Some + * elements can be lit. + * + * In X-Plane 6 some elements must be drawn over metal. Some are scalable and + * some are not. Any element can be drawn anywhere in X-Plane 7. + * + * Scalable Axis Required Background + * + */ +enum { + /* x metal */ + xpElement_TextField = 6, + + /* none metal */ + xpElement_CheckBox = 9, + + /* none metal */ + xpElement_CheckBoxLit = 10, + + /* none window header */ + xpElement_WindowCloseBox = 14, + + /* none window header */ + xpElement_WindowCloseBoxPressed = 15, + + /* x metal */ + xpElement_PushButton = 16, + + /* x metal */ + xpElement_PushButtonLit = 17, + + /* none any */ + xpElement_OilPlatform = 24, + + /* none any */ + xpElement_OilPlatformSmall = 25, + + /* none any */ + xpElement_Ship = 26, + + /* none any */ + xpElement_ILSGlideScope = 27, + + /* none any */ + xpElement_MarkerLeft = 28, + + /* none any */ + xpElement_Airport = 29, + + /* none any */ + xpElement_Waypoint = 30, + + /* none any */ + xpElement_NDB = 31, + + /* none any */ + xpElement_VOR = 32, + + /* none any */ + xpElement_RadioTower = 33, + + /* none any */ + xpElement_AircraftCarrier = 34, + + /* none any */ + xpElement_Fire = 35, + + /* none any */ + xpElement_MarkerRight = 36, + + /* none any */ + xpElement_CustomObject = 37, + + /* none any */ + xpElement_CoolingTower = 38, + + /* none any */ + xpElement_SmokeStack = 39, + + /* none any */ + xpElement_Building = 40, + + /* none any */ + xpElement_PowerLine = 41, + + /* none metal */ + xpElement_CopyButtons = 45, + + /* none metal */ + xpElement_CopyButtonsWithEditingGrid = 46, + + /* x, y metal */ + xpElement_EditingGrid = 47, + + /* THIS CAN PROBABLY BE REMOVED */ + xpElement_ScrollBar = 48, + + /* none any */ + xpElement_VORWithCompassRose = 49, + + /* none metal */ + xpElement_Zoomer = 51, + + /* x, y metal */ + xpElement_TextFieldMiddle = 52, + + /* none metal */ + xpElement_LittleDownArrow = 53, + + /* none metal */ + xpElement_LittleUpArrow = 54, + + /* none metal */ + xpElement_WindowDragBar = 61, + + /* none metal */ + xpElement_WindowDragBarSmooth = 62, + + +}; +typedef int XPElementStyle; + +/* + * XPDrawElement + * + * XPDrawElement draws a given element at an offset on the virtual screen in + * set dimensions. + * *Even* if the element is not scalable, it will be scaled if the width and + * height do not match the preferred dimensions; it'll just look ugly. Pass + * inLit to see the lit version of the element; if the element cannot be lit + * this is ignored. + * + */ +WIDGET_API void XPDrawElement( + int inX1, + int inY1, + int inX2, + int inY2, + XPElementStyle inStyle, + int inLit); + +/* + * XPGetElementDefaultDimensions + * + * This routine returns the recommended or minimum dimensions of a given UI + * element. outCanBeLit tells whether the element has both a lit and unlit + * state. Pass `NULL` to not receive any of these parameters. + * + */ +WIDGET_API void XPGetElementDefaultDimensions( + XPElementStyle inStyle, + int * outWidth, /* Can be NULL */ + int * outHeight, /* Can be NULL */ + int * outCanBeLit); /* Can be NULL */ + +/* + * XPTrackStyle + * + * A track is a UI element that displays a value vertically or horizontally. + * X-Plane has three kinds of tracks: scroll bars, sliders, and progress bars. + * Tracks can be displayed either horizontally or vertically; tracks will + * choose their own layout based on the larger dimension of their dimensions + * (e.g. they know if they are tall or wide). Sliders may be lit or unlit + * (showing the user manipulating them). + * + * - ScrollBar: this is a standard scroll bar with arrows and a thumb to drag. + * - Slider: this is a simple track with a ball in the middle that can be + * slid. + * - Progress: this is a progress indicator showing how a long task is going. + * + */ +enum { + /* not over metal can be lit can be rotated */ + xpTrack_ScrollBar = 0, + + /* over metal can be lit can be rotated */ + xpTrack_Slider = 1, + + /* over metal cannot be lit cannot be rotated */ + xpTrack_Progress = 2, + + +}; +typedef int XPTrackStyle; + +/* + * XPDrawTrack + * + * This routine draws a track. You pass in the track dimensions and size; the + * track picks the optimal orientation for these dimensions. Pass in the + * track's minimum current and maximum values; the indicator will be + * positioned appropriately. You can also specify whether the track is lit or + * not. + * + */ +WIDGET_API void XPDrawTrack( + int inX1, + int inY1, + int inX2, + int inY2, + int inMin, + int inMax, + int inValue, + XPTrackStyle inTrackStyle, + int inLit); + +/* + * XPGetTrackDefaultDimensions + * + * This routine returns a track's default smaller dimension; all tracks are + * scalable in the larger dimension. It also returns whether a track can be + * lit. + * + */ +WIDGET_API void XPGetTrackDefaultDimensions( + XPTrackStyle inStyle, + int * outWidth, + int * outCanBeLit); + +/* + * XPGetTrackMetrics + * + * This routine returns the metrics of a track. If you want to write UI code + * to manipulate a track, this routine helps you know where the mouse + * locations are. For most other elements, the rectangle the element is drawn + * in is enough information. However, the scrollbar drawing routine does some + * automatic placement; this routine lets you know where things ended up. You + * pass almost everything you would pass to the draw routine. You get out the + * orientation, and other useful stuff. + * + * Besides orientation, you get five dimensions for the five parts of a + * scrollbar, which are the down button, down area (area before the thumb), + * the thumb, and the up area and button. For horizontal scrollers, the left + * button decreases; for vertical scrollers, the top button decreases. + * + */ +WIDGET_API void XPGetTrackMetrics( + int inX1, + int inY1, + int inX2, + int inY2, + int inMin, + int inMax, + int inValue, + XPTrackStyle inTrackStyle, + int * outIsVertical, + int * outDownBtnSize, + int * outDownPageSize, + int * outThumbSize, + int * outUpPageSize, + int * outUpBtnSize); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/CHeaders/Widgets/XPWidgetDefs.h b/XPLPro_Plugin_Source/SDK/CHeaders/Widgets/XPWidgetDefs.h new file mode 100644 index 0000000..c1b2341 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/CHeaders/Widgets/XPWidgetDefs.h @@ -0,0 +1,472 @@ +#ifndef _XPWidgetDefs_h_ +#define _XPWidgetDefs_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPWidgetDefs + ***************************************************************************/ + +#include "XPLMDefs.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +#if APL + #if XPWIDGETS + #if __GNUC__ >= 4 + #define WIDGET_API __attribute__((visibility("default"))) + #elif __MACH__ + #define WIDGET_API + #else + #define WIDGET_API __declspec(dllexport) + #endif + #else + #define WIDGET_API + #endif +#elif IBM + #if XPWIDGETS + #define WIDGET_API __declspec(dllexport) + #else + #define WIDGET_API __declspec(dllimport) + #endif +#elif LIN + #if XPWIDGETS + #if __GNUC__ >= 4 + #define WIDGET_API __attribute__((visibility("default"))) + #else + #define WIDGET_API + #endif + #else + #define WIDGET_API + #endif +#else +#pragma error "Platform not defined!" +#endif + /*************************************************************************** + * WIDGET DEFINITIONS + ***************************************************************************/ +/* + * A widget is a call-back driven screen entity like a push-button, window, + * text entry field, etc. + * + * Use the widget API to create widgets of various classes. You can nest them + * into trees of widgets to create complex user interfaces. + * + */ + + +/* + * XPWidgetID + * + * A Widget ID is an opaque unique non-zero handle identifying your widget. + * Use 0 to specify "no widget". This type is defined as wide enough to hold a + * pointer. You receive a widget ID when you create a new widget and then use + * that widget ID to further refer to the widget. + * + */ +typedef void * XPWidgetID; + +/* + * XPWidgetPropertyID + * + * Properties are values attached to instances of your widgets. A property is + * identified by a 32-bit ID and its value is the width of a pointer. + * + * Each widget instance may have a property or not have it. When you set a + * property on a widget for the first time, the property is added to the + * widget; it then stays there for the life of the widget. + * + * Some property IDs are predefined by the widget package; you can make up + * your own property IDs as well. + * + */ +enum { + /* A window's refcon is an opaque value used by client code to find other data* + * based on it. */ + xpProperty_Refcon = 0, + + /* These properties are used by the utlities to implement dragging. */ + xpProperty_Dragging = 1, + + xpProperty_DragXOff = 2, + + xpProperty_DragYOff = 3, + + /* Is the widget hilited? (For widgets that support this kind of thing.) */ + xpProperty_Hilited = 4, + + /* Is there a C++ object attached to this widget? */ + xpProperty_Object = 5, + + /* If this property is 1, the widget package will use OpenGL to restrict * + * drawing to the Wiget's exposed rectangle. */ + xpProperty_Clip = 6, + + /* Is this widget enabled (for those that have a disabled state too)? */ + xpProperty_Enabled = 7, + + /* NOTE: Property IDs 1 - 999 are reserved for the widgets library. * + * * + * NOTE: Property IDs 1000 - 9999 are allocated to the standard widget classes* + * provided with the library. * + * * + * Properties 1000 - 1099 are for widget class 0, 1100 - 1199 for widget class* + * 1, etc. */ + xpProperty_UserStart = 10000, + + +}; +typedef int XPWidgetPropertyID; + +/* + * XPMouseState_t + * + * When the mouse is clicked or dragged, a pointer to this structure is passed + * to your widget function. + * + */ +typedef struct { + int x; + int y; + /* Mouse Button number, left = 0 (right button not yet supported. */ + int button; +#if defined(XPLM200) + /* Scroll wheel delta (button in this case would be the wheel axis number). */ + int delta; +#endif /* XPLM200 */ +} XPMouseState_t; + +/* + * XPKeyState_t + * + * When a key is pressed, a pointer to this struct is passed to your widget + * function. + * + */ +typedef struct { + /* The ASCII key that was pressed. WARNING: this may be 0 for some non-ASCII * + * key sequences. */ + char key; + /* The flags. Make sure to check this if you only want key-downs! */ + XPLMKeyFlags flags; + /* The virtual key code for the key */ + char vkey; +} XPKeyState_t; + +/* + * XPWidgetGeometryChange_t + * + * This structure contains the deltas for your widget's geometry when it + * changes. + * + */ +typedef struct { + int dx; + /* +Y = the widget moved up */ + int dy; + int dwidth; + int dheight; +} XPWidgetGeometryChange_t; + +/* + * XPDispatchMode + * + * The dispatching modes describe how the widgets library sends out messages. + * Currently there are three modes: + * + */ +enum { + /* The message will only be sent to the target widget. */ + xpMode_Direct = 0, + + /* The message is sent to the target widget, then up the chain of parents * + * until the message is handled or a parentless widget is reached. */ + xpMode_UpChain = 1, + + /* The message is sent to the target widget and then all of its children * + * recursively depth-first. */ + xpMode_Recursive = 2, + + /* The message is snet just to the target, but goes to every callback, even if* + * it is handled. */ + xpMode_DirectAllCallbacks = 3, + + /* The message is only sent to the very first handler even if it is not * + * accepted. (This is really only useful for some internal widget library * + * functions.) */ + xpMode_Once = 4, + + +}; +typedef int XPDispatchMode; + +/* + * XPWidgetClass + * + * Widget classes define predefined widget types. A widget class basically + * specifies from a library the widget function to be used for the widget. + * Most widgets can be made right from classes. + * + */ +typedef int XPWidgetClass; + +/* An unspecified widget class. Other widget classes are in * + * XPStandardWidgets.h */ +#define xpWidgetClass_None 0 + +/*************************************************************************** + * WIDGET MESSAGES + ***************************************************************************/ + +/* + * XPWidgetMessage + * + * Widgets receive 32-bit messages indicating what action is to be taken or + * notifications of events. The list of messages may be expanded. + * + */ +enum { + /* No message, should not be sent. */ + xpMsg_None = 0, + + /* The create message is sent once per widget that is created with your widget* + * function and once for any widget that has your widget function attached. * + * * + * Dispatching: Direct * + * * + * Param 1: 1 if you are being added as a subclass, 0 if the widget is first * + * being created. */ + xpMsg_Create = 1, + + /* The destroy message is sent once for each message that is destroyed that * + * has your widget function. * + * * + * Dispatching: Direct for all * + * * + * Param 1: 1 if being deleted by a recursive delete to the parent, 0 for * + * explicit deletion. */ + xpMsg_Destroy = 2, + + /* The paint message is sent to your widget to draw itself. The paint message * + * is the bare-bones message; in response you must draw yourself, draw your * + * children, set up clipping and culling, check for visibility, etc. If you * + * don't want to do all of this, ignore the paint message and a draw message * + * (see below) will be sent to you. * + * * + * Dispatching: Direct */ + xpMsg_Paint = 3, + + /* The draw message is sent to your widget when it is time to draw yourself. * + * OpenGL will be set up to draw in 2-d global screen coordinates, but you * + * should use the XPLM to set up OpenGL state. * + * * + * Dispatching: Direct */ + xpMsg_Draw = 4, + + /* The key press message is sent once per key that is pressed. The first * + * parameter is the type of key code (integer or char) and the second is the * + * code itself. By handling this event, you consume the key stroke. * + * * + * Handling this message 'consumes' the keystroke; not handling it passes it * + * to your parent widget. * + * * + * Dispatching: Up Chain * + * * + * Param 1: A pointer to an XPKeyState_t structure with the keystroke. */ + xpMsg_KeyPress = 5, + + /* Keyboard focus is being given to you. By handling this message you accept * + * keyboard focus. The first parameter will be one if a child of yours gave up* + * focus to you, 0 if someone set focus on you explicitly. * + * * + * Handling this message accepts focus; not handling refuses focus. * + * * + * Dispatching: direct * + * * + * Param 1: 1 if you are gaining focus because your child is giving it up, 0 * + * if someone is explicitly giving you focus. */ + xpMsg_KeyTakeFocus = 6, + + /* Keyboard focus is being taken away from you. The first parameter will be * + * one if you are losing focus because another widget is taking it, or 0 if * + * someone called the API to make you lose focus explicitly. * + * * + * Dispatching: Direct * + * * + * Param 1: 1 if focus is being taken by another widget, 0 if code requested * + * to remove focus. */ + xpMsg_KeyLoseFocus = 7, + + /* You receive one mousedown event per click with a mouse-state structure * + * pointed to by parameter 1, by accepting this you eat the click, otherwise * + * your parent gets it. You will not receive drag and mouse up messages if you* + * do not accept the down message. * + * * + * Handling this message consumes the mouse click, not handling it passes it * + * to the next widget. You can act 'transparent' as a window by never handling* + * moues clicks to certain areas. * + * * + * Dispatching: Up chain NOTE: Technically this is direct dispatched, but the * + * widgets library will shop it to each widget until one consumes the click, * + * making it effectively "up chain". * + * * + * Param 1: A pointer to an XPMouseState_t containing the mouse status. */ + xpMsg_MouseDown = 8, + + /* You receive a series of mouse drag messages (typically one per frame in the* + * sim) as the mouse is moved once you have accepted a mouse down message. * + * Parameter one points to a mouse-state structure describing the mouse * + * location. You will continue to receive these until the mouse button is * + * released. You may receive multiple mouse state messages with the same mouse* + * position. You will receive mouse drag events even if the mouse is dragged * + * out of your current or original bounds at the time of the mouse down. * + * * + * Dispatching: Direct * + * * + * Param 1: A pointer to an XPMouseState_t containing the mouse status. */ + xpMsg_MouseDrag = 9, + + /* The mouseup event is sent once when the mouse button is released after a * + * drag or click. You only receive this message if you accept the mouseDown * + * message. Parameter one points to a mouse state structure. * + * * + * Dispatching: Direct * + * * + * Param 1: A pointer to an XPMouseState_t containing the mouse status. */ + xpMsg_MouseUp = 10, + + /* Your geometry or a child's geometry is being changed. * + * * + * Dispatching: Up chain * + * * + * Param 1: The widget ID of the original reshaped target. * + * * + * Param 2: A pointer to a XPWidgetGeometryChange_t struct describing the * + * change. */ + xpMsg_Reshape = 11, + + /* Your exposed area has changed. * + * * + * Dispatching: Direct */ + xpMsg_ExposedChanged = 12, + + /* A child has been added to you. The child's ID is passed in parameter one. * + * * + * Dispatching: Direct * + * * + * Param 1: The Widget ID of the child being added. */ + xpMsg_AcceptChild = 13, + + /* A child has been removed from to you. The child's ID is passed in parameter* + * one. * + * * + * Dispatching: Direct * + * * + * Param 1: The Widget ID of the child being removed. */ + xpMsg_LoseChild = 14, + + /* You now have a new parent, or have no parent. The parent's ID is passed in,* + * or 0 for no parent. * + * * + * Dispatching: Direct * + * * + * Param 1: The Widget ID of your parent */ + xpMsg_AcceptParent = 15, + + /* You or a child has been shown. Note that this does not include you being * + * shown because your parent was shown, you were put in a new parent, your * + * root was shown, etc. * + * * + * Dispatching: Up chain * + * * + * Param 1: The widget ID of the shown widget. */ + xpMsg_Shown = 16, + + /* You have been hidden. See limitations above. * + * * + * Dispatching: Up chain * + * * + * Param 1: The widget ID of the hidden widget. */ + xpMsg_Hidden = 17, + + /* Your descriptor has changed. * + * * + * Dispatching: Direct */ + xpMsg_DescriptorChanged = 18, + + /* A property has changed. Param 1 contains the property ID. * + * * + * Dispatching: Direct * + * * + * Param 1: The Property ID being changed. * + * * + * Param 2: The new property value */ + xpMsg_PropertyChanged = 19, + +#if defined(XPLM200) + /* The mouse wheel has moved. * + * * + * Return 1 to consume the mouse wheel move, or 0 to pass the message to a * + * parent. Dispatching: Up chain * + * * + * Param 1: A pointer to an XPMouseState_t containing the mouse status. */ + xpMsg_MouseWheel = 20, + +#endif /* XPLM200 */ +#if defined(XPLM200) + /* The cursor is over your widget. If you consume this message, change the * + * XPLMCursorStatus value to indicate the desired result, with the same rules * + * as in XPLMDisplay.h. * + * * + * Return 1 to consume this message, 0 to pass it on. * + * * + * Dispatching: Up chain Param 1: A pointer to an XPMouseState_t struct * + * containing the mouse status. * + * * + * Param 2: A pointer to a XPLMCursorStatus - set this to the cursor result * + * you desire. */ + xpMsg_CursorAdjust = 21, + +#endif /* XPLM200 */ + /* NOTE: Message IDs 1000 - 9999 are allocated to the standard widget classes * + * provided with the library with 1000 - 1099 for widget class 0, 1100 - 1199 * + * for widget class 1, etc. Message IDs 10,000 and beyond are for plugin use. */ + xpMsg_UserStart = 10000, + + +}; +typedef int XPWidgetMessage; + +/*************************************************************************** + * WIDGET CALLBACK FUNCTION + ***************************************************************************/ + +/* + * XPWidgetFunc_t + * + * This function defines your custom widget's behavior. It will be called by + * the widgets library to send messages to your widget. The message and widget + * ID are passed in, as well as two ptr-width signed parameters whose meaning + * varies with the message. Return 1 to indicate that you have processed the + * message, 0 to indicate that you have not. For any message that is not + * understood, return 0. + * + */ +typedef int (* XPWidgetFunc_t)( + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/CHeaders/Widgets/XPWidgetUtils.h b/XPLPro_Plugin_Source/SDK/CHeaders/Widgets/XPWidgetUtils.h new file mode 100644 index 0000000..ff757f7 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/CHeaders/Widgets/XPWidgetUtils.h @@ -0,0 +1,232 @@ +#ifndef _XPWidgetUtils_h_ +#define _XPWidgetUtils_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPWidgetUtils + ***************************************************************************/ +/* + * ## USAGE NOTES + * + * The XPWidgetUtils library contains useful functions that make writing and + * using widgets less of a pain. + * + * One set of functions are the widget behavior functions. These functions + * each add specific useful behaviors to widgets. They can be used in two + * manners: + * + * 1. You can add a widget behavior function to a widget as a callback proc + * using the XPAddWidgetCallback function. The widget will gain that + * behavior. Remember that the last function you add has highest priority. + * You can use this to change or augment the behavior of an existing + * finished widget. + * 2. You can call a widget function from inside your own widget function. + * This allows you to include useful behaviors in custom-built widgets. A + * number of the standard widgets get their behavior from this library. To + * do this, call the behavior function from your function first. If it + * returns 1, that means it handled the event and you don't need to; simply + * return 1. + * + */ + +#include "XPWidgetDefs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*************************************************************************** + * GENERAL UTILITIES + ***************************************************************************/ + + + +/* + * Convenience accessors + * + * It can be clumsy accessing the variables passed in by pointer to a struct + * for mouse and reshape messages; these accessors let you simply pass in the param + * right from the arguments of your widget proc and get back the value you want. + * + */ +#define MOUSE_X(param) (((XPMouseState_t *) (param))->x) +#define MOUSE_Y(param) (((XPMouseState_t *) (param))->y) + +#define DELTA_X(param) (((XPWidgetGeometryChange_t *) (param))->dx) +#define DELTA_Y(param) (((XPWidgetGeometryChange_t *) (param))->dy) +#define DELTA_W(param) (((XPWidgetGeometryChange_t *) (param))->dwidth) +#define DELTA_H(param) (((XPWidgetGeometryChange_t *) (param))->dheight) + +#define KEY_CHAR(param) (((XPKeyState_t *) (param))->key) +#define KEY_FLAGS(param) (((XPKeyState_t *) (param))->flags) +#define KEY_VKEY(param) (((XPKeyState_t *) (param))->vkey) + +#define IN_RECT(x, y, l, t, r, b) \ + (((x) >= (l)) && ((x) <= (r)) && ((y) >= (b)) && ((y) <= (t))) + +/* + * XPWidgetCreate_t + * + * This structure contains all of the parameters needed to create a wiget. It + * is used with XPUCreateWidgets to create widgets in bulk from an array. All + * parameters correspond to those of XPCreateWidget except for the container + * index. + * + * If the container index is equal to the index of a widget in the array, the + * widget in the array passed to XPUCreateWidgets is used as the parent of + * this widget. Note that if you pass an index greater than your own position + * in the array, the parent you are requesting will not exist yet. + * + * If the container index is NO_PARENT, the parent widget is specified as + * NULL. If the container index is PARAM_PARENT, the widget passed into + * XPUCreateWidgets is used. + * + */ +typedef struct { + int left; + int top; + int right; + int bottom; + int visible; + const char * descriptor; + /* Whether ethis widget is a root wiget */ + int isRoot; + /* The index of the widget to contain within, or a constant */ + int containerIndex; + XPWidgetClass widgetClass; +} XPWidgetCreate_t; + +#define NO_PARENT -1 + +#define PARAM_PARENT -2 + +#define WIDGET_COUNT(x) ((sizeof(x) / sizeof(XPWidgetCreate_t))) + +/* + * XPUCreateWidgets + * + * This function creates a series of widgets from a table (see + * XPCreateWidget_t above). Pass in an array of widget creation structures and + * an array of widget IDs that will receive each widget. + * + * Widget parents are specified by index into the created widget table, + * allowing you to create nested widget structures. You can create multiple + * widget trees in one table. Generally you should create widget trees from + * the top down. + * + * You can also pass in a widget ID that will be used when the widget's parent + * is listed as PARAM_PARENT; this allows you to embed widgets created with + * XPUCreateWidgets in a widget created previously. + * + */ +WIDGET_API void XPUCreateWidgets( + const XPWidgetCreate_t * inWidgetDefs, + int inCount, + XPWidgetID inParamParent, + XPWidgetID * ioWidgets); + +/* + * XPUMoveWidgetBy + * + * Simply moves a widget by an amount, +x = right, +y=up, without resizing the + * widget. + * + */ +WIDGET_API void XPUMoveWidgetBy( + XPWidgetID inWidget, + int inDeltaX, + int inDeltaY); + +/*************************************************************************** + * LAYOUT MANAGERS + ***************************************************************************/ +/* + * The layout managers are widget behavior functions for handling where + * widgets move. Layout managers can be called from a widget function or + * attached to a widget later. + * + */ + + +/* + * XPUFixedLayout + * + * This function causes the widget to maintain its children in fixed position + * relative to itself as it is resized. Use this on the top level 'window' + * widget for your window. + * + */ +WIDGET_API int XPUFixedLayout( + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2); + +/*************************************************************************** + * WIDGET PROC BEHAVIORS + ***************************************************************************/ +/* + * These widget behavior functions add other useful behaviors to widgets. + * These functions cannot be attached to a widget; they must be called from + * your widget function. + * + */ + + +/* + * XPUSelectIfNeeded + * + * This causes the widget to bring its window to the foreground if it is not + * already. inEatClick specifies whether clicks in the background should be + * consumed by bringin the window to the foreground. + * + */ +WIDGET_API int XPUSelectIfNeeded( + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2, + int inEatClick); + +/* + * XPUDefocusKeyboard + * + * This causes a click in the widget to send keyboard focus back to X-Plane. + * This stops editing of any text fields, etc. + * + */ +WIDGET_API int XPUDefocusKeyboard( + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2, + int inEatClick); + +/* + * XPUDragWidget + * + * XPUDragWidget drags the widget in response to mouse clicks. Pass in not + * only the event, but the global coordinates of the drag region, which might + * be a sub-region of your widget (for example, a title bar). + * + */ +WIDGET_API int XPUDragWidget( + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2, + int inLeft, + int inTop, + int inRight, + int inBottom); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/CHeaders/Widgets/XPWidgets.h b/XPLPro_Plugin_Source/SDK/CHeaders/Widgets/XPWidgets.h new file mode 100644 index 0000000..f4423e2 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/CHeaders/Widgets/XPWidgets.h @@ -0,0 +1,538 @@ +#ifndef _XPWidgets_h_ +#define _XPWidgets_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPWidgets + ***************************************************************************/ +/* + * ## THEORY OF OPERATION AND NOTES + * + * Widgets are persistent view 'objects' for X-Plane. A widget is an object + * referenced by its opaque handle (widget ID) and the APIs in this file. You + * cannot access the widget's guts directly. Every Widget has the following + * intrinsic data: + * + * - A bounding box defined in global screen coordinates with 0,0 in the + * bottom left and +y = up, +x = right. + * - A visible box, which is the intersection of the bounding box with the + * widget's parents visible box. + * - Zero or one parent widgets. (Always zero if the widget is a root widget. + * - Zero or more child widgets. + * - Whether the widget is a root. Root widgets are the top level plugin + * windows. + * - Whether the widget is visible. + * - A text string descriptor, whose meaning varies from widget to widget. + * - An arbitrary set of 32 bit integral properties defined by 32-bit integral + * keys. This is how specific widgets store specific data. + * - A list of widget callbacks proc that implements the widgets behaviors. + * + * The Widgets library sends messages to widgets to request specific behaviors + * or notify the widget of things. + * + * Widgets may have more than one callback function, in which case messages + * are sent to the most recently added callback function until the message is + * handled. Messages may also be sent to parents or children; see the + * XPWidgetDefs.h header file for the different widget message dispatching + * functions. By adding a callback function to a window you can 'subclass' its + * behavior. + * + * A set of standard widgets are provided that serve common UI purposes. You + * can also customize or implement entirely custom widgets. + * + * Widgets are different than other view hierarchies (most notably Win32, + * which they bear a striking resemblance to) in the following ways: + * + * - Not all behavior can be patched. State that is managed by the XPWidgets + * DLL and not by individual widgets cannot be customized. + * - All coordinates are in global screen coordinates. Coordinates are not + * relative to an enclosing widget, nor are they relative to a display + * window. + * - Widget messages are always dispatched synchronously, and there is no + * concept of scheduling an update or a dirty region. Messages originate + * from X-Plane as the sim cycle goes by. Since X-Plane is constantly + * redrawing, so are widgets; there is no need to mark a part of a widget as + * 'needing redrawing' because redrawing happens frequently whether the + * widget needs it or not. + * - Any widget may be a 'root' widget, causing it to be drawn; there is no + * relationship between widget class and rootness. Root widgets are + * imlemented as XPLMDisply windows. + * + */ + +#include "XPWidgetDefs.h" +#include "XPLMDisplay.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*************************************************************************** + * WIDGET CREATION AND MANAGEMENT + ***************************************************************************/ + +/* + * XPCreateWidget + * + * This function creates a new widget and returns the new widget's ID to you. + * If the widget creation fails for some reason, it returns NULL. Widget + * creation will fail either if you pass a bad class ID or if there is not + * adequate memory. + * + * Input Parameters: + * + * - Top, left, bottom, and right in global screen coordinates defining the + * widget's location on the screen. + * - inVisible is 1 if the widget should be drawn, 0 to start the widget as + * hidden. + * - inDescriptor is a null terminated string that will become the widget's + * descriptor. + * - inIsRoot is 1 if this is going to be a root widget, 0 if it will not be. + * - inContainer is the ID of this widget's container. It must be 0 for a root + * widget. for a non-root widget, pass the widget ID of the widget to place + * this widget within. If this widget is not going to start inside another + * widget, pass 0; this new widget will then just be floating off in space + * (and will not be drawn until it is placed in a widget. + * - inClass is the class of the widget to draw. Use one of the predefined + * class-IDs to create a standard widget. + * + * A note on widget embedding: a widget is only called (and will be drawn, + * etc.) if it is placed within a widget that will be called. Root widgets are + * always called. So it is possible to have whole chains of widgets that are + * simply not called. You can preconstruct widget trees and then place them + * into root widgets later to activate them if you wish. + * + */ +WIDGET_API XPWidgetID XPCreateWidget( + int inLeft, + int inTop, + int inRight, + int inBottom, + int inVisible, + const char * inDescriptor, + int inIsRoot, + XPWidgetID inContainer, + XPWidgetClass inClass); + +/* + * XPCreateCustomWidget + * + * This function is the same as XPCreateWidget except that instead of passing + * a class ID, you pass your widget callback function pointer defining the + * widget. Use this function to define a custom widget. All parameters are the + * same as XPCreateWidget, except that the widget class has been replaced with + * the widget function. + * + */ +WIDGET_API XPWidgetID XPCreateCustomWidget( + int inLeft, + int inTop, + int inRight, + int inBottom, + int inVisible, + const char * inDescriptor, + int inIsRoot, + XPWidgetID inContainer, + XPWidgetFunc_t inCallback); + +/* + * XPDestroyWidget + * + * This class destroys a widget. Pass in the ID of the widget to kill. If you + * pass 1 for inDestroyChilren, the widget's children will be destroyed first, + * then this widget will be destroyed. (Furthermore, the widget's children + * will be destroyed with the inDestroyChildren flag set to 1, so the + * destruction will recurse down the widget tree.) If you pass 0 for this + * flag, the child widgets will simply end up with their parent set to 0. + * + */ +WIDGET_API void XPDestroyWidget( + XPWidgetID inWidget, + int inDestroyChildren); + +/* + * XPSendMessageToWidget + * + * This sends any message to a widget. You should probably not go around + * simulating the predefined messages that the widgets library defines for + * you. You may however define custom messages for your widgets and send them + * with this method. + * + * This method supports several dispatching patterns; see XPDispatchMode for + * more info. The function returns 1 if the message was handled, 0 if it was + * not. + * + * For each widget that receives the message (see the dispatching modes), each + * widget function from the most recently installed to the oldest one receives + * the message in order until it is handled. + * + */ +WIDGET_API int XPSendMessageToWidget( + XPWidgetID inWidget, + XPWidgetMessage inMessage, + XPDispatchMode inMode, + intptr_t inParam1, + intptr_t inParam2); + +/*************************************************************************** + * WIDGET POSITIONING AND VISIBILITY + ***************************************************************************/ + +/* + * XPPlaceWidgetWithin + * + * This function changes which container a widget resides in. You may NOT use + * this function on a root widget! inSubWidget is the widget that will be + * moved. Pass a widget ID in inContainer to make inSubWidget be a child of + * inContainer. It will become the last/closest widget in the container. Pass + * 0 to remove the widget from any container. Any call to this other than + * passing the widget ID of the old parent of the affected widget will cause + * the widget to be removed from its old parent. Placing a widget within its + * own parent simply makes it the last widget. + * + * NOTE: this routine does not reposition the sub widget in global + * coordinates. If the container has layout management code, it will + * reposition the subwidget for you, otherwise you must do it with + * SetWidgetGeometry. + * + */ +WIDGET_API void XPPlaceWidgetWithin( + XPWidgetID inSubWidget, + XPWidgetID inContainer); + +/* + * XPCountChildWidgets + * + * This routine returns the number of widgets another widget contains. + * + */ +WIDGET_API int XPCountChildWidgets( + XPWidgetID inWidget); + +/* + * XPGetNthChildWidget + * + * This routine returns the widget ID of a child widget by index. Indexes are + * 0 based, from 0 to one minus the number of widgets in the parent, + * inclusive. If the index is invalid, 0 is returned. + * + */ +WIDGET_API XPWidgetID XPGetNthChildWidget( + XPWidgetID inWidget, + int inIndex); + +/* + * XPGetParentWidget + * + * Returns the parent of a widget, or 0 if the widget has no parent. Root + * widgets never have parents and therefore always return 0. + * + */ +WIDGET_API XPWidgetID XPGetParentWidget( + XPWidgetID inWidget); + +/* + * XPShowWidget + * + * This routine makes a widget visible if it is not already. Note that if a + * widget is not in a rooted widget hierarchy or one of its parents is not + * visible, it will still not be visible to the user. + * + */ +WIDGET_API void XPShowWidget( + XPWidgetID inWidget); + +/* + * XPHideWidget + * + * Makes a widget invisible. See XPShowWidget for considerations of when a + * widget might not be visible despite its own visibility state. + * + */ +WIDGET_API void XPHideWidget( + XPWidgetID inWidget); + +/* + * XPIsWidgetVisible + * + * This returns 1 if a widget is visible, 0 if it is not. Note that this + * routine takes into consideration whether a parent is invisible. Use this + * routine to tell if the user can see the widget. + * + */ +WIDGET_API int XPIsWidgetVisible( + XPWidgetID inWidget); + +/* + * XPFindRootWidget + * + * Returns the Widget ID of the root widget that contains the passed in widget + * or NULL if the passed in widget is not in a rooted hierarchy. + * + */ +WIDGET_API XPWidgetID XPFindRootWidget( + XPWidgetID inWidget); + +/* + * XPBringRootWidgetToFront + * + * This routine makes the specified widget be in the front most widget + * hierarchy. If this widget is a root widget, its widget hierarchy comes to + * front, otherwise the widget's root is brought to the front. If this widget + * is not in an active widget hiearchy (e.g. there is no root widget at the + * top of the tree), this routine does nothing. + * + */ +WIDGET_API void XPBringRootWidgetToFront( + XPWidgetID inWidget); + +/* + * XPIsWidgetInFront + * + * This routine returns true if this widget's hierarchy is the front most + * hierarchy. It returns false if the widget's hierarchy is not in front, or + * if the widget is not in a rooted hierarchy. + * + */ +WIDGET_API int XPIsWidgetInFront( + XPWidgetID inWidget); + +/* + * XPGetWidgetGeometry + * + * This routine returns the bounding box of a widget in global coordinates. + * Pass NULL for any parameter you are not interested in. + * + */ +WIDGET_API void XPGetWidgetGeometry( + XPWidgetID inWidget, + int * outLeft, /* Can be NULL */ + int * outTop, /* Can be NULL */ + int * outRight, /* Can be NULL */ + int * outBottom); /* Can be NULL */ + +/* + * XPSetWidgetGeometry + * + * This function changes the bounding box of a widget. + * + */ +WIDGET_API void XPSetWidgetGeometry( + XPWidgetID inWidget, + int inLeft, + int inTop, + int inRight, + int inBottom); + +/* + * XPGetWidgetForLocation + * + * Given a widget and a location, this routine returns the widget ID of the + * child of that widget that owns that location. If inRecursive is true then + * this will return a child of a child of a widget as it tries to find the + * deepest widget at that location. If inVisibleOnly is true, then only + * visible widgets are considered, otherwise all widgets are considered. The + * widget ID passed for inContainer will be returned if the location is in + * that widget but not in a child widget. 0 is returned if the location is not + * in the container. + * + * NOTE: if a widget's geometry extends outside its parents geometry, it will + * not be returned by this call for mouse locations outside the parent + * geometry. The parent geometry limits the child's eligibility for mouse + * location. + * + */ +WIDGET_API XPWidgetID XPGetWidgetForLocation( + XPWidgetID inContainer, + int inXOffset, + int inYOffset, + int inRecursive, + int inVisibleOnly); + +/* + * XPGetWidgetExposedGeometry + * + * This routine returns the bounds of the area of a widget that is completely + * within its parent widgets. Since a widget's bounding box can be outside its + * parent, part of its area will not be elligible for mouse clicks and should + * not draw. Use XPGetWidgetGeometry to find out what area defines your + * widget's shape, but use this routine to find out what area to actually draw + * into. Note that the widget library does not use OpenGL clipping to keep + * frame rates up, although you could use it internally. + * + */ +WIDGET_API void XPGetWidgetExposedGeometry( + XPWidgetID inWidgetID, + int * outLeft, /* Can be NULL */ + int * outTop, /* Can be NULL */ + int * outRight, /* Can be NULL */ + int * outBottom); /* Can be NULL */ + +/*************************************************************************** + * ACCESSING WIDGET DATA + ***************************************************************************/ + +/* + * XPSetWidgetDescriptor + * + * Every widget has a descriptor, which is a text string. What the text string + * is used for varies from widget to widget; for example, a push button's text + * is its descriptor, a caption shows its descriptor, and a text field's + * descriptor is the text being edited. In other words, the usage for the text + * varies from widget to widget, but this API provides a universal and + * convenient way to get at it. While not all UI widgets need their + * descriptor, many do. + * + */ +WIDGET_API void XPSetWidgetDescriptor( + XPWidgetID inWidget, + const char * inDescriptor); + +/* + * XPGetWidgetDescriptor + * + * This routine returns the widget's descriptor. Pass in the length of the + * buffer you are going to receive the descriptor in. The descriptor will be + * null terminated for you. This routine returns the length of the actual + * descriptor; if you pass NULL for outDescriptor, you can get the + * descriptor's length without getting its text. If the length of the + * descriptor exceeds your buffer length, the buffer will not be null + * terminated (this routine has 'strncpy' semantics). + * + */ +WIDGET_API int XPGetWidgetDescriptor( + XPWidgetID inWidget, + char * outDescriptor, + int inMaxDescLength); + +/* + * XPGetWidgetUnderlyingWindow + * + * Returns the window (from the XPLMDisplay API) that backs your widget + * window. If you have opted in to modern windows, via a call to + * XPLMEnableFeature("XPLM_USE_NATIVE_WIDGET_WINDOWS", 1), you can use the + * returned window ID for display APIs like XPLMSetWindowPositioningMode(), + * allowing you to pop the widget window out into a real OS window, or move it + * into VR. + * + */ +WIDGET_API XPLMWindowID XPGetWidgetUnderlyingWindow( + XPWidgetID inWidget); + +/* + * XPSetWidgetProperty + * + * This function sets a widget's property. Properties are arbitrary values + * associated by a widget by ID. + * + */ +WIDGET_API void XPSetWidgetProperty( + XPWidgetID inWidget, + XPWidgetPropertyID inProperty, + intptr_t inValue); + +/* + * XPGetWidgetProperty + * + * This routine returns the value of a widget's property, or 0 if the property + * is not defined. If you need to know whether the property is defined, pass a + * pointer to an int for inExists; the existence of that property will be + * returned in the int. Pass NULL for inExists if you do not need this + * information. + * + */ +WIDGET_API intptr_t XPGetWidgetProperty( + XPWidgetID inWidget, + XPWidgetPropertyID inProperty, + int * inExists); /* Can be NULL */ + +/*************************************************************************** + * KEYBOARD MANAGEMENT + ***************************************************************************/ + +/* + * XPSetKeyboardFocus + * + * Controls which widget will receive keystrokes. Pass the widget ID of the + * widget to get the keys. Note that if the widget does not care about + * keystrokes, they will go to the parent widget, and if no widget cares about + * them, they go to X-Plane. + * + * If you set the keyboard focus to widget ID 0, X-Plane gets keyboard focus. + * + * This routine returns the widget ID that ended up with keyboard focus, or 0 + * for X-Plane. + * + * Keyboard focus is not changed if the new widget will not accept it. For + * setting to X-Plane, keyboard focus is always accepted. + * + */ +WIDGET_API XPWidgetID XPSetKeyboardFocus( + XPWidgetID inWidget); + +/* + * XPLoseKeyboardFocus + * + * This causes the specified widget to lose focus; focus is passed to its + * parent, or the next parent that will accept it. This routine does nothing + * if this widget does not have focus. + * + */ +WIDGET_API void XPLoseKeyboardFocus( + XPWidgetID inWidget); + +/* + * XPGetWidgetWithFocus + * + * This routine returns the widget that has keyboard focus, or 0 if X-Plane + * has keyboard focus or some other plugin window that does not have widgets + * has focus. + * + */ +WIDGET_API XPWidgetID XPGetWidgetWithFocus(void); + +/*************************************************************************** + * CREATING CUSTOM WIDGETS + ***************************************************************************/ + +/* + * XPAddWidgetCallback + * + * This function adds a new widget callback to a widget. This widget callback + * supercedes any existing ones and will receive messages first; if it does + * not handle messages they will go on to be handled by pre-existing widgets. + * + * The widget function will remain on the widget for the life of the widget. + * The creation message will be sent to the new callback immediately with the + * widget ID, and the destruction message will be sent before the other widget + * function receives a destruction message. + * + * This provides a way to 'subclass' an existing widget. By providing a second + * hook that only handles certain widget messages, you can customize or extend + * widget behavior. + * + */ +WIDGET_API void XPAddWidgetCallback( + XPWidgetID inWidget, + XPWidgetFunc_t inNewCallback); + +/* + * XPGetWidgetClassFunc + * + * Given a widget class, this function returns the callbacks that power that + * widget class. + * + */ +WIDGET_API XPWidgetFunc_t XPGetWidgetClassFunc( + XPWidgetClass inWidgetClass); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/CHeaders/Wrappers/XPCBroadcaster.cpp b/XPLPro_Plugin_Source/SDK/CHeaders/Wrappers/XPCBroadcaster.cpp new file mode 100644 index 0000000..5fe6218 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/CHeaders/Wrappers/XPCBroadcaster.cpp @@ -0,0 +1,56 @@ +#include "XPCBroadcaster.h" +#include "XPCListener.h" + +XPCBroadcaster::XPCBroadcaster() : + mIterator(NULL) +{ +} + +XPCBroadcaster::~XPCBroadcaster() +{ + ListenerVector::iterator iter; + mIterator = &iter; + for (iter = mListeners.begin(); iter != mListeners.end(); ++iter) + { + (*iter)->BroadcasterRemoved(this); + } +} + +void XPCBroadcaster::AddListener( + XPCListener * inListener) +{ + mListeners.push_back(inListener); + inListener->BroadcasterAdded(this); +} + +void XPCBroadcaster::RemoveListener( + XPCListener * inListener) +{ + ListenerVector::iterator iter = std::find + (mListeners.begin(), mListeners.end(), inListener); + if (iter == mListeners.end()) + return; + + if (mIterator != NULL) + { + if (*mIterator >= iter) + (*mIterator)--; + } + + mListeners.erase(iter); + inListener->BroadcasterRemoved(this); +} + +void XPCBroadcaster::BroadcastMessage( + int inMessage, + void * inParam) +{ + ListenerVector::iterator iter; + mIterator = &iter; + for (iter = mListeners.begin(); iter != mListeners.end(); ++iter) + { + (*iter)->ListenToMessage(inMessage, inParam); + } + mIterator = NULL; +} + diff --git a/XPLPro_Plugin_Source/SDK/CHeaders/Wrappers/XPCBroadcaster.h b/XPLPro_Plugin_Source/SDK/CHeaders/Wrappers/XPCBroadcaster.h new file mode 100644 index 0000000..8f34a05 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/CHeaders/Wrappers/XPCBroadcaster.h @@ -0,0 +1,38 @@ +#ifndef _XPCBroadcaster_h_ +#define _XPCBroadcaster_h_ + +#include +#include + +class XPCListener; + +class XPCBroadcaster { +public: + + XPCBroadcaster(); + virtual ~XPCBroadcaster(); + + void AddListener( + XPCListener * inListener); + void RemoveListener( + XPCListener * inListener); + +protected: + + void BroadcastMessage( + int inMessage, + void * inParam=0); + +private: + + typedef std::vector ListenerVector; + + ListenerVector mListeners; + + // Reentrancy support + + ListenerVector::iterator * mIterator; + +}; + +#endif \ No newline at end of file diff --git a/XPLPro_Plugin_Source/SDK/CHeaders/Wrappers/XPCDisplay.cpp b/XPLPro_Plugin_Source/SDK/CHeaders/Wrappers/XPCDisplay.cpp new file mode 100644 index 0000000..fc996ca --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/CHeaders/Wrappers/XPCDisplay.cpp @@ -0,0 +1,104 @@ +#include "XPCDisplay.h" + +XPCKeySniffer::XPCKeySniffer(int inBeforeWindows) : mBeforeWindows(inBeforeWindows) +{ + XPLMRegisterKeySniffer(KeySnifferCB, mBeforeWindows, reinterpret_cast(this)); +} + +XPCKeySniffer::~XPCKeySniffer() +{ + XPLMUnregisterKeySniffer(KeySnifferCB, mBeforeWindows, reinterpret_cast(this)); +} + + +int XPCKeySniffer::KeySnifferCB( + char inCharKey, + XPLMKeyFlags inFlags, + char inVirtualKey, + void * inRefCon) +{ + XPCKeySniffer * me = reinterpret_cast(inRefCon); + return me->HandleKeyStroke(inCharKey, inFlags, inVirtualKey); +} + +XPCWindow::XPCWindow( + int inLeft, + int inTop, + int inRight, + int inBottom, + int inIsVisible) +{ + mWindow = XPLMCreateWindow(inLeft, inTop, inRight, inBottom, inIsVisible, + DrawCB, HandleKeyCB, MouseClickCB, + reinterpret_cast(this)); +} + +XPCWindow::~XPCWindow() +{ + XPLMDestroyWindow(mWindow); +} + +void XPCWindow::GetWindowGeometry( + int * outLeft, + int * outTop, + int * outRight, + int * outBottom) +{ + XPLMGetWindowGeometry(mWindow, outLeft, outTop, outRight, outBottom); +} + +void XPCWindow::SetWindowGeometry( + int inLeft, + int inTop, + int inRight, + int inBottom) +{ + XPLMSetWindowGeometry(mWindow, inLeft, inTop, inRight, inBottom); +} + +int XPCWindow::GetWindowIsVisible(void) +{ + return XPLMGetWindowIsVisible(mWindow); +} + +void XPCWindow::SetWindowIsVisible( + int inIsVisible) +{ + XPLMSetWindowIsVisible(mWindow, inIsVisible); +} + +void XPCWindow::TakeKeyboardFocus(void) +{ + XPLMTakeKeyboardFocus(mWindow); +} + +void XPCWindow::BringWindowToFront(void) +{ + XPLMBringWindowToFront(mWindow); +} + +int XPCWindow::IsWindowInFront(void) +{ + return XPLMIsWindowInFront(mWindow); +} + +void XPCWindow::DrawCB(XPLMWindowID inWindowID, void * inRefcon) +{ + XPCWindow * me = reinterpret_cast(inRefcon); + me->DoDraw(); +} + +void XPCWindow::HandleKeyCB(XPLMWindowID inWindowID, char inKey, XPLMKeyFlags inFlags, char inVirtualKey, void * inRefcon, int losingFocus) +{ + XPCWindow * me = reinterpret_cast(inRefcon); + if (losingFocus) + me->LoseFocus(); + else + me->HandleKey(inKey, inFlags, inVirtualKey); +} + +int XPCWindow::MouseClickCB(XPLMWindowID inWindowID, int x, int y, XPLMMouseStatus inMouse, void * inRefcon) +{ + XPCWindow * me = reinterpret_cast(inRefcon); + return me->HandleClick(x, y, inMouse); +} diff --git a/XPLPro_Plugin_Source/SDK/CHeaders/Wrappers/XPCDisplay.h b/XPLPro_Plugin_Source/SDK/CHeaders/Wrappers/XPCDisplay.h new file mode 100644 index 0000000..2465928 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/CHeaders/Wrappers/XPCDisplay.h @@ -0,0 +1,73 @@ +#ifndef _XPCDisplay_h_ +#define _XPCDisplay_h_ + +#include "XPLMDisplay.h" + +class XPCKeySniffer { +public: + + XPCKeySniffer(int inBeforeWindows); + virtual ~XPCKeySniffer(); + + virtual int HandleKeyStroke( + char inCharKey, + XPLMKeyFlags inFlags, + char inVirtualKey)=0; + +private: + + int mBeforeWindows; + + static int KeySnifferCB( + char inCharKey, + XPLMKeyFlags inFlags, + char inVirtualKey, + void * inRefCon); +}; + + + +class XPCWindow { +public: + + XPCWindow( + int inLeft, + int inTop, + int inRight, + int inBottom, + int inIsVisible); + virtual ~XPCWindow(); + + virtual void DoDraw(void)=0; + virtual void HandleKey(char inKey, XPLMKeyFlags inFlags, char inVirtualKey)=0; + virtual void LoseFocus(void)=0; + virtual int HandleClick(int x, int y, XPLMMouseStatus inMouse)=0; + + void GetWindowGeometry( + int * outLeft, + int * outTop, + int * outRight, + int * outBottom); + void SetWindowGeometry( + int inLeft, + int inTop, + int inRight, + int inBottom); + int GetWindowIsVisible(void); + void SetWindowIsVisible( + int inIsVisible); + void TakeKeyboardFocus(void); + void BringWindowToFront(void); + int IsWindowInFront(void); + +private: + + XPLMWindowID mWindow; + + static void DrawCB(XPLMWindowID inWindowID, void * inRefcon); + static void HandleKeyCB(XPLMWindowID inWindowID, char inKey, XPLMKeyFlags inFlags, char inVirtualKey, void * inRefcon, int losingFocus); + static int MouseClickCB(XPLMWindowID inWindowID, int x, int y, XPLMMouseStatus inMouse, void * inRefcon); + +}; + +#endif \ No newline at end of file diff --git a/XPLPro_Plugin_Source/SDK/CHeaders/Wrappers/XPCListener.cpp b/XPLPro_Plugin_Source/SDK/CHeaders/Wrappers/XPCListener.cpp new file mode 100644 index 0000000..b4c77aa --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/CHeaders/Wrappers/XPCListener.cpp @@ -0,0 +1,27 @@ +#include "XPCListener.h" +#include "XPCBroadcaster.h" + +XPCListener::XPCListener() +{ +} + +XPCListener::~XPCListener() +{ + while (!mBroadcasters.empty()) + mBroadcasters.front()->RemoveListener(this); +} + +void XPCListener::BroadcasterAdded( + XPCBroadcaster * inBroadcaster) +{ + mBroadcasters.push_back(inBroadcaster); +} + +void XPCListener::BroadcasterRemoved( + XPCBroadcaster * inBroadcaster) +{ + BroadcastVector::iterator iter = std::find(mBroadcasters.begin(), + mBroadcasters.end(), inBroadcaster); + if (iter != mBroadcasters.end()) + mBroadcasters.erase(iter); +} diff --git a/XPLPro_Plugin_Source/SDK/CHeaders/Wrappers/XPCListener.h b/XPLPro_Plugin_Source/SDK/CHeaders/Wrappers/XPCListener.h new file mode 100644 index 0000000..dbdd2a0 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/CHeaders/Wrappers/XPCListener.h @@ -0,0 +1,36 @@ +#ifndef _XPCListener_h_ +#define _XPCListener_h_ + +#include +#include + +class XPCBroadcaster; + + +class XPCListener { +public: + + XPCListener(); + virtual ~XPCListener(); + + virtual void ListenToMessage( + int inMessage, + void * inParam)=0; + +private: + + typedef std::vector BroadcastVector; + + BroadcastVector mBroadcasters; + + friend class XPCBroadcaster; + + void BroadcasterAdded( + XPCBroadcaster * inBroadcaster); + + void BroadcasterRemoved( + XPCBroadcaster * inBroadcaster); + +}; + +#endif \ No newline at end of file diff --git a/XPLPro_Plugin_Source/SDK/CHeaders/Wrappers/XPCProcessing.cpp b/XPLPro_Plugin_Source/SDK/CHeaders/Wrappers/XPCProcessing.cpp new file mode 100644 index 0000000..352c05f --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/CHeaders/Wrappers/XPCProcessing.cpp @@ -0,0 +1,52 @@ +#include "XPCProcessing.h" +#include "XPLMUtilities.h" + +XPCProcess::XPCProcess() : + mInCallback(false), + mCallbackTime(0) +{ + XPLMRegisterFlightLoopCallback(FlightLoopCB, 0, reinterpret_cast(this)); +} + +XPCProcess::~XPCProcess() +{ + XPLMUnregisterFlightLoopCallback(FlightLoopCB, reinterpret_cast(this)); +} + +void XPCProcess::StartProcessTime(float inSeconds) +{ + mCallbackTime = inSeconds; + if (!mInCallback) + XPLMSetFlightLoopCallbackInterval( + FlightLoopCB, mCallbackTime, 1/*relative to now*/, reinterpret_cast(this)); +} + +void XPCProcess::StartProcessCycles(int inCycles) +{ + mCallbackTime = -inCycles; + if (!mInCallback) + XPLMSetFlightLoopCallbackInterval( + FlightLoopCB, mCallbackTime, 1/*relative to now*/, reinterpret_cast(this)); +} + +void XPCProcess::StopProcess(void) +{ + mCallbackTime = 0; + if (!mInCallback) + XPLMSetFlightLoopCallbackInterval( + FlightLoopCB, mCallbackTime, 1/*relative to now*/, reinterpret_cast(this)); +} + + +float XPCProcess::FlightLoopCB( + float inElapsedSinceLastCall, + float inElapsedTimeSinceLastFlightLoop, + int inCounter, + void * inRefcon) +{ + XPCProcess * me = reinterpret_cast(inRefcon); + me->mInCallback = true; + me->DoProcessing(inElapsedSinceLastCall, inElapsedTimeSinceLastFlightLoop, inCounter); + me->mInCallback = false; + return me->mCallbackTime; +} \ No newline at end of file diff --git a/XPLPro_Plugin_Source/SDK/CHeaders/Wrappers/XPCProcessing.h b/XPLPro_Plugin_Source/SDK/CHeaders/Wrappers/XPCProcessing.h new file mode 100644 index 0000000..cd735e5 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/CHeaders/Wrappers/XPCProcessing.h @@ -0,0 +1,37 @@ +#ifndef _XPCProcessing_h_ +#define _XPCProcessing_h_ + +#include "XPLMProcessing.h" + +class XPCProcess { +public: + + XPCProcess(); + virtual ~XPCProcess(); + + void StartProcessTime(float inSeconds); + void StartProcessCycles(int inCycles); + void StopProcess(void); + + virtual void DoProcessing( + float inElapsedSinceLastCall, + float inElapsedTimeSinceLastFlightLoop, + int inCounter)=0; + +private: + + static float FlightLoopCB( + float inElapsedSinceLastCall, + float inElapsedTimeSinceLastFlightLoop, + int inCounter, + void * inRefcon); + + bool mInCallback; + float mCallbackTime; + + XPCProcess(const XPCProcess&); + XPCProcess& operator=(const XPCProcess&); + +}; + +#endif diff --git a/XPLPro_Plugin_Source/SDK/CHeaders/Wrappers/XPCWidget.cpp b/XPLPro_Plugin_Source/SDK/CHeaders/Wrappers/XPCWidget.cpp new file mode 100644 index 0000000..8ef8aa3 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/CHeaders/Wrappers/XPCWidget.cpp @@ -0,0 +1,123 @@ +#include "XPCWidget.h" + +XPCWidget::XPCWidget( + int inLeft, + int inTop, + int inRight, + int inBottom, + bool inVisible, + const char * inDescriptor, + bool inIsRoot, + XPWidgetID inParent, + XPWidgetClass inClass) : + mWidget(NULL), + mOwnsChildren(false), + mOwnsWidget(true) +{ + mWidget = XPCreateWidget( + inLeft, inTop, inRight, inBottom, + inVisible ? 1 : 0, + inDescriptor, + inIsRoot ? 1 : 0, + inIsRoot ? NULL : inParent, + inClass); + + XPSetWidgetProperty(mWidget, xpProperty_Object, reinterpret_cast(this)); + XPAddWidgetCallback(mWidget, WidgetCallback); +} + +XPCWidget::XPCWidget( + XPWidgetID inWidget, + bool inOwnsWidget) : + mWidget(inWidget), + mOwnsChildren(false), + mOwnsWidget(inOwnsWidget) +{ + XPSetWidgetProperty(mWidget, xpProperty_Object, reinterpret_cast(this)); + XPAddWidgetCallback(mWidget, WidgetCallback); +} + +XPCWidget::~XPCWidget() +{ + if (mOwnsWidget) + XPDestroyWidget(mWidget, mOwnsChildren ? 1 : 0); +} + +void XPCWidget::SetOwnsWidget( + bool inOwnsWidget) +{ + mOwnsWidget = inOwnsWidget; +} + +void XPCWidget::SetOwnsChildren( + bool inOwnsChildren) +{ + mOwnsChildren = inOwnsChildren; +} + +XPCWidget::operator XPWidgetID () const +{ + return mWidget; +} + +XPWidgetID XPCWidget::Get(void) const +{ + return mWidget; +} + +void XPCWidget::AddAttachment( + XPCWidgetAttachment * inAttachment, + bool inOwnsAttachment, + bool inPrefilter) +{ + if (inPrefilter) + { + mAttachments.insert(mAttachments.begin(), AttachmentInfo(inAttachment, inOwnsAttachment)); + } else { + mAttachments.push_back(AttachmentInfo(inAttachment, inOwnsAttachment)); + } +} + +void XPCWidget::RemoveAttachment( + XPCWidgetAttachment * inAttachment) +{ + for (AttachmentVector::iterator iter = mAttachments.begin(); + iter != mAttachments.end(); ++iter) + { + if (iter->first == inAttachment) + { + mAttachments.erase(iter); + return; + } + } +} + +int XPCWidget::HandleWidgetMessage( + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2) +{ + return 0; +} + +int XPCWidget::WidgetCallback( + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2) +{ + XPCWidget * me = reinterpret_cast(XPGetWidgetProperty(inWidget, xpProperty_Object, NULL)); + if (me == NULL) + return 0; + + for (AttachmentVector::iterator iter = me->mAttachments.begin(); iter != + me->mAttachments.end(); ++iter) + { + int result = iter->first->HandleWidgetMessage(me, inMessage, inWidget, inParam1, inParam2); + if (result != 0) + return result; + } + + return me->HandleWidgetMessage(inMessage, inWidget, inParam1, inParam2); +} diff --git a/XPLPro_Plugin_Source/SDK/CHeaders/Wrappers/XPCWidget.h b/XPLPro_Plugin_Source/SDK/CHeaders/Wrappers/XPCWidget.h new file mode 100644 index 0000000..788b56a --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/CHeaders/Wrappers/XPCWidget.h @@ -0,0 +1,84 @@ +#ifndef _XPCWidget_h_ +#define _XPCWidget_h_ + +#include +#include +#include "XPWidgets.h" + +class XPCWidget; + +class XPCWidgetAttachment { +public: + + virtual int HandleWidgetMessage( + XPCWidget * inObject, + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2)=0; + +}; + +class XPCWidget { +public: + + XPCWidget( + int inLeft, + int inTop, + int inRight, + int inBottom, + bool inVisible, + const char * inDescriptor, + bool inIsRoot, + XPWidgetID inParent, + XPWidgetClass inClass); + XPCWidget( + XPWidgetID inWidget, + bool inOwnsWidget); + virtual ~XPCWidget(); + + void SetOwnsWidget( + bool inOwnsWidget); + void SetOwnsChildren( + bool inOwnsChildren); + + operator XPWidgetID () const; + + XPWidgetID Get(void) const; + + void AddAttachment( + XPCWidgetAttachment * inAttachment, + bool inOwnsAttachment, + bool inPrefilter); + void RemoveAttachment( + XPCWidgetAttachment * inAttachment); + + virtual int HandleWidgetMessage( + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2); + +private: + + static int WidgetCallback( + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2); + + typedef std::pair AttachmentInfo; + typedef std::vector AttachmentVector; + + AttachmentVector mAttachments; + XPWidgetID mWidget; + bool mOwnsChildren; + bool mOwnsWidget; + + XPCWidget(); + XPCWidget(const XPCWidget&); + XPCWidget& operator=(const XPCWidget&); + +}; + +#endif \ No newline at end of file diff --git a/XPLPro_Plugin_Source/SDK/CHeaders/Wrappers/XPCWidgetAttachments.cpp b/XPLPro_Plugin_Source/SDK/CHeaders/Wrappers/XPCWidgetAttachments.cpp new file mode 100644 index 0000000..d87f105 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/CHeaders/Wrappers/XPCWidgetAttachments.cpp @@ -0,0 +1,267 @@ +#include "XPCWidgetAttachments.h" +#include "XPStandardWidgets.h" +#include "XPWidgetUtils.h" + +static void XPCGetOrderedSubWidgets( + XPWidgetID inWidget, + std::vector& outChildren); + +XPCKeyFilterAttachment::XPCKeyFilterAttachment( + const char * inValidKeys, + const char * outValidKeys) : + mInput(inValidKeys), + mOutput(outValidKeys) +{ +} + +XPCKeyFilterAttachment::~XPCKeyFilterAttachment() +{ +} + +int XPCKeyFilterAttachment::HandleWidgetMessage( + XPCWidget * inObject, + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2) +{ + if (inMessage == xpMsg_KeyPress) + { + char& theKey = KEY_CHAR(inParam1); + std::string::size_type pos = mInput.find(theKey); + if (pos == std::string::npos) + return 1; // Not found; eat the key! + else { + theKey = mOutput[pos]; + return 0; + } // Let it live. + } + return 0; +} + + +XPCKeyMessageAttachment::XPCKeyMessageAttachment( + char inKey, + int inMessage, + void * inParam, + bool inConsume, + bool inVkey, + XPCListener * inListener) : + mKey(inKey), mMsg(inMessage), mParam(inParam), mConsume(inConsume), + mVkey(inVkey) +{ + if (inListener != NULL) + this->AddListener(inListener); +} + +XPCKeyMessageAttachment::~XPCKeyMessageAttachment() +{ +} + +int XPCKeyMessageAttachment::HandleWidgetMessage( + XPCWidget * inObject, + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2) +{ + if (inMessage == xpMsg_KeyPress) + { + char theKey = mVkey ? KEY_VKEY(inParam1) : KEY_CHAR(inParam1); + if (theKey != mKey) + return 0; + if (!(KEY_FLAGS(inParam1) & xplm_DownFlag)) + return 0; + + BroadcastMessage(mMsg, mParam); + return mConsume ? 1 : 0; + } + return 0; +} + +XPCPushButtonMessageAttachment::XPCPushButtonMessageAttachment( + XPWidgetID inWidget, + int inMessage, + void * inParam, + XPCListener * inListener) : + mMsg(inMessage), mParam(inParam), mWidget(inWidget) +{ + if (inListener != NULL) + this->AddListener(inListener); +} + +XPCPushButtonMessageAttachment::~XPCPushButtonMessageAttachment() +{ +} + +int XPCPushButtonMessageAttachment::HandleWidgetMessage( + XPCWidget * inObject, + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2) +{ + if ((inMessage == xpMsg_PushButtonPressed) && ((XPWidgetID) inParam1 == mWidget)) + { + BroadcastMessage(mMsg, mParam); + return 1; + } + + if ((inMessage == xpMsg_ButtonStateChanged) && ((XPWidgetID) inParam1 == mWidget)) + { + BroadcastMessage(mMsg, mParam); + return 1; + } + return 0; +} + +XPCSliderMessageAttachment::XPCSliderMessageAttachment( + XPWidgetID inWidget, + int inMessage, + void * inParam, + XPCListener * inListener) : + mMsg(inMessage), mParam(inParam), mWidget(inWidget) +{ + if (inListener != NULL) + this->AddListener(inListener); +} + +XPCSliderMessageAttachment::~XPCSliderMessageAttachment() +{ +} + +int XPCSliderMessageAttachment::HandleWidgetMessage( + XPCWidget * inObject, + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2) +{ + if ((inMessage == xpMsg_ScrollBarSliderPositionChanged) && ((XPWidgetID) inParam1 == mWidget)) + { + BroadcastMessage(mMsg, mParam); + return 1; + } + + return 0; +} + + +XPCCloseButtonMessageAttachment::XPCCloseButtonMessageAttachment( + XPWidgetID inWidget, + int inMessage, + void * inParam, + XPCListener * inListener) : + mMsg(inMessage), mParam(inParam), mWidget(inWidget) +{ + if (inListener != NULL) + this->AddListener(inListener); +} + +XPCCloseButtonMessageAttachment::~XPCCloseButtonMessageAttachment() +{ +} + +int XPCCloseButtonMessageAttachment::HandleWidgetMessage( + XPCWidget * inObject, + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2) +{ + if ((inMessage == xpMessage_CloseButtonPushed) && ((XPWidgetID) inParam1 == mWidget)) + { + BroadcastMessage(mMsg, mParam); + return 1; + } + + return 0; +} + +XPCTabGroupAttachment::XPCTabGroupAttachment() +{ +} + +XPCTabGroupAttachment::~XPCTabGroupAttachment() +{ +} + +int XPCTabGroupAttachment::HandleWidgetMessage( + XPCWidget * inObject, + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2) +{ + if ((inMessage == xpMsg_KeyPress) && (KEY_CHAR(inParam1) == XPLM_KEY_TAB) && + ((KEY_FLAGS(inParam1) & xplm_UpFlag) == 0)) + { + bool backwards = (KEY_FLAGS(inParam1) & xplm_ShiftFlag) != 0; + std::vector widgets; + XPCGetOrderedSubWidgets(inWidget, widgets); + int n, index = 0; + XPWidgetID focusWidget = XPGetWidgetWithFocus(); + std::vector::iterator iter = std::find(widgets.begin(), widgets.end(), focusWidget); + if (iter != widgets.end()) + { + index = std::distance(widgets.begin(), iter); + if (backwards) + index--; + else + index++; + if (index < 0) + index = widgets.size() - 1; + if (index >= widgets.size()) + index = 0; + } + + if (backwards) + { + for (n = index; n >= 0; --n) + { + if (XPGetWidgetProperty(widgets[n], xpProperty_Enabled, NULL)) + if (XPSetKeyboardFocus(widgets[n]) != NULL) + return 1; + } + for (n = widgets.size() - 1; n > index; --n) + { + if (XPGetWidgetProperty(widgets[n], xpProperty_Enabled, NULL)) + if (XPSetKeyboardFocus(widgets[n]) != NULL) + return 1; + } + } else { + for (n = index; n < widgets.size(); ++n) + { + if (XPGetWidgetProperty(widgets[n], xpProperty_Enabled, NULL)) + if (XPSetKeyboardFocus(widgets[n]) != NULL) + return 1; + } + for (n = 0; n < index; ++n) + { + if (XPGetWidgetProperty(widgets[n], xpProperty_Enabled, NULL)) + if (XPSetKeyboardFocus(widgets[n]) != NULL) + return 1; + } + } + } + return 0; +} + + + +static void XPCGetOrderedSubWidgets( + XPWidgetID inWidget, + std::vector& outChildren) +{ + outChildren.clear(); + int count = XPCountChildWidgets(inWidget); + for (int n = 0; n < count; ++n) + { + XPWidgetID child = XPGetNthChildWidget(inWidget, n); + outChildren.push_back(child); + std::vector grandChildren; + XPCGetOrderedSubWidgets(child, grandChildren); + + outChildren.insert(outChildren.end(), grandChildren.begin(), grandChildren.end()); + } +} diff --git a/XPLPro_Plugin_Source/SDK/CHeaders/Wrappers/XPCWidgetAttachments.h b/XPLPro_Plugin_Source/SDK/CHeaders/Wrappers/XPCWidgetAttachments.h new file mode 100644 index 0000000..91fb587 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/CHeaders/Wrappers/XPCWidgetAttachments.h @@ -0,0 +1,146 @@ +#ifndef _XPCWidgetAttachments_h_ +#define _XPCWidgetAttachments_h_ + +#include + +#include "XPCWidget.h" +#include "XPCBroadcaster.h" + +class XPCKeyFilterAttachment : public XPCWidgetAttachment { +public: + + XPCKeyFilterAttachment( + const char * inValidKeys, + const char * outValidKeys); + virtual ~XPCKeyFilterAttachment(); + + virtual int HandleWidgetMessage( + XPCWidget * inObject, + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2); + +private: + + std::string mInput; + std::string mOutput; + +}; + + +class XPCKeyMessageAttachment : public XPCWidgetAttachment, public XPCBroadcaster { +public: + + XPCKeyMessageAttachment( + char inKey, + int inMessage, + void * inParam, + bool inConsume, + bool inVkey, + XPCListener * inListener); + virtual ~XPCKeyMessageAttachment(); + + virtual int HandleWidgetMessage( + XPCWidget * inObject, + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2); + +private: + + char mKey; + bool mVkey; + int mMsg; + void * mParam; + bool mConsume; + +}; + +class XPCPushButtonMessageAttachment : public XPCWidgetAttachment, XPCBroadcaster { +public: + + XPCPushButtonMessageAttachment( + XPWidgetID inWidget, + int inMessage, + void * inParam, + XPCListener * inListener); + virtual ~XPCPushButtonMessageAttachment(); + + virtual int HandleWidgetMessage( + XPCWidget * inObject, + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2); + +private: + XPWidgetID mWidget; + int mMsg; + void * mParam; +}; + +class XPCSliderMessageAttachment : public XPCWidgetAttachment, XPCBroadcaster { +public: + + XPCSliderMessageAttachment( + XPWidgetID inWidget, + int inMessage, + void * inParam, + XPCListener * inListener); + virtual ~XPCSliderMessageAttachment(); + + virtual int HandleWidgetMessage( + XPCWidget * inObject, + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2); + +private: + XPWidgetID mWidget; + int mMsg; + void * mParam; +}; + + +class XPCCloseButtonMessageAttachment : public XPCWidgetAttachment, XPCBroadcaster { +public: + + XPCCloseButtonMessageAttachment( + XPWidgetID inWidget, + int inMessage, + void * inParam, + XPCListener * inListener); + virtual ~XPCCloseButtonMessageAttachment(); + + virtual int HandleWidgetMessage( + XPCWidget * inObject, + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2); + +private: + XPWidgetID mWidget; + int mMsg; + void * mParam; +}; + +class XPCTabGroupAttachment : public XPCWidgetAttachment { +public: + + XPCTabGroupAttachment(); + virtual ~XPCTabGroupAttachment(); + + virtual int HandleWidgetMessage( + XPCWidget * inObject, + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2); + +}; + +#endif \ No newline at end of file diff --git a/XPLPro_Plugin_Source/SDK/CHeaders/XPLM/XPLMCamera.h b/XPLPro_Plugin_Source/SDK/CHeaders/XPLM/XPLMCamera.h new file mode 100644 index 0000000..db930ef --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/CHeaders/XPLM/XPLMCamera.h @@ -0,0 +1,167 @@ +#ifndef _XPLMCamera_h_ +#define _XPLMCamera_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPLMCamera + ***************************************************************************/ +/* + * The XPLMCamera APIs allow plug-ins to control the camera angle in X-Plane. + * This has a number of applications, including but not limited to: + * + * - Creating new views (including dynamic/user-controllable views) for the + * user. + * - Creating applications that use X-Plane as a renderer of scenery, + * aircrafts, or both. + * + * The camera is controlled via six parameters: a location in OpenGL + * coordinates and pitch, roll and yaw, similar to an airplane's position. + * OpenGL coordinate info is described in detail in the XPLMGraphics + * documentation; generally you should use the XPLMGraphics routines to + * convert from world to local coordinates. The camera's orientation starts + * facing level with the ground directly up the negative-Z axis (approximately + * north) with the horizon horizontal. It is then rotated clockwise for yaw, + * pitched up for positive pitch, and rolled clockwise around the vector it is + * looking along for roll. + * + * You control the camera either either until the user selects a new view or + * permanently (the later being similar to how UDP camera control works). You + * control the camera by registering a callback per frame from which you + * calculate the new camera positions. This guarantees smooth camera motion. + * + * Use the XPLMDataAccess APIs to get information like the position of the + * aircraft, etc. for complex camera positioning. + * + * Note: if your goal is to move the virtual pilot in the cockpit, this API is + * not needed; simply update the datarefs for the pilot's head position. + * + * For custom exterior cameras, set the camera's mode to an external view + * first to get correct sound and 2-d panel behavior. + * + */ + +#include "XPLMDefs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*************************************************************************** + * CAMERA CONTROL + ***************************************************************************/ + +/* + * XPLMCameraControlDuration + * + * This enumeration states how long you want to retain control of the camera. + * You can retain it indefinitely or until the user selects a new view. + * + */ +enum { + /* Control the camera until the user picks a new view. */ + xplm_ControlCameraUntilViewChanges = 1, + + /* Control the camera until your plugin is disabled or another plugin forcably* + * takes control. */ + xplm_ControlCameraForever = 2, + + +}; +typedef int XPLMCameraControlDuration; + +/* + * XPLMCameraPosition_t + * + * This structure contains a full specification of the camera. X, Y, and Z are + * the camera's position in OpenGL coordiantes; pitch, roll, and yaw are + * rotations from a camera facing flat north in degrees. Positive pitch means + * nose up, positive roll means roll right, and positive yaw means yaw right, + * all in degrees. Zoom is a zoom factor, with 1.0 meaning normal zoom and 2.0 + * magnifying by 2x (objects appear larger). + * + */ +typedef struct { + float x; + float y; + float z; + float pitch; + float heading; + float roll; + float zoom; +} XPLMCameraPosition_t; + +/* + * XPLMCameraControl_f + * + * You use an XPLMCameraControl function to provide continuous control over + * the camera. You are passed in a structure in which to put the new camera + * position; modify it and return 1 to reposition the camera. Return 0 to + * surrender control of the camera; camera control will be handled by X-Plane + * on this draw loop. The contents of the structure as you are called are + * undefined. + * + * If X-Plane is taking camera control away from you, this function will be + * called with inIsLosingControl set to 1 and ioCameraPosition NULL. + * + */ +typedef int (* XPLMCameraControl_f)( + XPLMCameraPosition_t * outCameraPosition, /* Can be NULL */ + int inIsLosingControl, + void * inRefcon); + +/* + * XPLMControlCamera + * + * This function repositions the camera on the next drawing cycle. You must + * pass a non-null control function. Specify in inHowLong how long you'd like + * control (indefinitely or until a new view mode is set by the user). + * + */ +XPLM_API void XPLMControlCamera( + XPLMCameraControlDuration inHowLong, + XPLMCameraControl_f inControlFunc, + void * inRefcon); + +/* + * XPLMDontControlCamera + * + * This function stops you from controlling the camera. If you have a camera + * control function, it will not be called with an inIsLosingControl flag. + * X-Plane will control the camera on the next cycle. + * + * For maximum compatibility you should not use this routine unless you are in + * posession of the camera. + * + */ +XPLM_API void XPLMDontControlCamera(void); + +/* + * XPLMIsCameraBeingControlled + * + * This routine returns 1 if the camera is being controlled, zero if it is + * not. If it is and you pass in a pointer to a camera control duration, the + * current control duration will be returned. + * + */ +XPLM_API int XPLMIsCameraBeingControlled( + XPLMCameraControlDuration * outCameraControlDuration); /* Can be NULL */ + +/* + * XPLMReadCameraPosition + * + * This function reads the current camera position. + * + */ +XPLM_API void XPLMReadCameraPosition( + XPLMCameraPosition_t * outCameraPosition); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/CHeaders/XPLM/XPLMDataAccess.h b/XPLPro_Plugin_Source/SDK/CHeaders/XPLM/XPLMDataAccess.h new file mode 100644 index 0000000..d8d1418 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/CHeaders/XPLM/XPLMDataAccess.h @@ -0,0 +1,716 @@ +#ifndef _XPLMDataAccess_h_ +#define _XPLMDataAccess_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPLMDataAccess + ***************************************************************************/ +/* + * The data access API gives you a generic, flexible, high performance way to + * read and write data to and from X-Plane and other plug-ins. For example, + * this API allows you to read and set the nav radios, get the plane location, + * determine the current effective graphics frame rate, etc. + * + * The data access APIs are the way that you read and write data from the sim + * as well as other plugins. + * + * The API works using opaque data references. A data reference is a source of + * data; you do not know where it comes from, but once you have it you can + * read the data quickly and possibly write it. + * + * Dataref Lookup + * -------------- + * + * Data references are identified by verbose, permanent string names; by + * convention these names use path separates to form a hierarchy of datarefs, + * e.g. (sim/cockpit/radios/nav1_freq_hz). The actual opaque numeric value of + * the data reference, as returned by the XPLM API, is implementation defined + * and changes each time X-Plane is launched; therefore you need to look up + * the dataref by path every time your plugin runs. + * + * The task of looking up a data reference is relatively expensive; look up + * your data references once based on the verbose path strings, and save the + * opaque data reference value for the duration of your plugin's operation. + * Reading and writing data references is relatively fast (the cost is + * equivalent to two function calls through function pointers). + * + * X-Plane publishes over 4000 datarefs; a complete list may be found in the + * reference section of the SDK online documentation (from the SDK home page, + * choose Documentation). + * + * Dataref Types + * ------------- + * + * A note on typing: you must know the correct data type to read and write. + * APIs are provided for reading and writing data in a number of ways. You can + * also double check the data type for a data ref. Automatic type conversion + * is not done for you. + * + * Dataref types are a set, e.g. a dataref can be more than one type. When + * this happens, you can choose which API you want to use to read. For + * example, it is not uncommon for a dataref to be of type float and double. + * This means you can use either XPLMGetDatad or XPLMGetDataf to read it. + * + * Creating New Datarefs + * --------------------- + * + * X-Plane provides datarefs that come with the sim, but plugins can also + * create their own datarefs. A plugin creates a dataref by registering + * function callbacks to read and write the dataref. The XPLM will call your + * plugin each time some other plugin (or X-Plane) tries to read or write the + * dataref. You must provide a read (and optional write) callback for each + * data type you support. + * + * A note for plugins sharing data with other plugins: the load order of + * plugins is not guaranteed. To make sure that every plugin publishing data + * has published their data references before other plugins try to subscribe, + * publish your data references in your start routine but resolve them the + * first time your 'enable' routine is called, or the first time they are + * needed in code. + * + * When a plugin that created a dataref is unloaded, it becomes "orphaned". + * The dataref handle continues to be usable, but the dataref is not writable, + * and reading it will always return 0 (or 0 items for arrays). If the plugin + * is reloaded and re-registers the dataref, the handle becomes un-orphaned + * and works again. + * + */ + +#include "XPLMDefs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*************************************************************************** + * READING AND WRITING DATA + ***************************************************************************/ +/* + * These routines allow you to access data from within X-Plane and sometimes + * modify it. + * + */ + + +/* + * XPLMDataRef + * + * A data ref is an opaque handle to data provided by the simulator or another + * plugin. It uniquely identifies one variable (or array of variables) over + * the lifetime of your plugin. You never hard code these values; you always + * get them from XPLMFindDataRef. + * + */ +typedef void * XPLMDataRef; + +/* + * XPLMDataTypeID + * + * This is an enumeration that defines the type of the data behind a data + * reference. This allows you to sanity check that the data type matches what + * you expect. But for the most part, you will know the type of data you are + * expecting from the online documentation. + * + * Data types each take a bit field; it is legal to have a single dataref be + * more than one type of data. Whe this happens, you can pick any matching + * get/set API. + * + */ +enum { + /* Data of a type the current XPLM doesn't do. */ + xplmType_Unknown = 0, + + /* A single 4-byte integer, native endian. */ + xplmType_Int = 1, + + /* A single 4-byte float, native endian. */ + xplmType_Float = 2, + + /* A single 8-byte double, native endian. */ + xplmType_Double = 4, + + /* An array of 4-byte floats, native endian. */ + xplmType_FloatArray = 8, + + /* An array of 4-byte integers, native endian. */ + xplmType_IntArray = 16, + + /* A variable block of data. */ + xplmType_Data = 32, + + +}; +typedef int XPLMDataTypeID; + +/* + * XPLMFindDataRef + * + * Given a c-style string that names the data ref, this routine looks up the + * actual opaque XPLMDataRef that you use to read and write the data. The + * string names for datarefs are published on the X-Plane SDK web site. + * + * This function returns NULL if the data ref cannot be found. + * + * NOTE: this function is relatively expensive; save the XPLMDataRef this + * function returns for future use. Do not look up your data ref by string + * every time you need to read or write it. + * + */ +XPLM_API XPLMDataRef XPLMFindDataRef( + const char * inDataRefName); + +/* + * XPLMCanWriteDataRef + * + * Given a data ref, this routine returns true if you can successfully set the + * data, false otherwise. Some datarefs are read-only. + * + * NOTE: even if a dataref is marked writable, it may not act writable. This + * can happen for datarefs that X-Plane writes to on every frame of + * simulation. In some cases, the dataref is writable but you have to set a + * separate "override" dataref to 1 to stop X-Plane from writing it. + * + */ +XPLM_API int XPLMCanWriteDataRef( + XPLMDataRef inDataRef); + +/* + * XPLMIsDataRefGood + * + * This function returns true if the passed in handle is a valid dataref that + * is not orphaned. + * + * Note: there is normally no need to call this function; datarefs returned by + * XPLMFindDataRef remain valid (but possibly orphaned) unless there is a + * complete plugin reload (in which case your plugin is reloaded anyway). + * Orphaned datarefs can be safely read and return 0. Therefore you never need + * to call XPLMIsDataRefGood to 'check' the safety of a dataref. + * (XPLMIsDatarefGood performs some slow checking of the handle validity, so + * it has a perormance cost.) + * + */ +XPLM_API int XPLMIsDataRefGood( + XPLMDataRef inDataRef); + +/* + * XPLMGetDataRefTypes + * + * This routine returns the types of the data ref for accessor use. If a data + * ref is available in multiple data types, the bit-wise OR of these types + * will be returned. + * + */ +XPLM_API XPLMDataTypeID XPLMGetDataRefTypes( + XPLMDataRef inDataRef); + +/*************************************************************************** + * DATA ACCESSORS + ***************************************************************************/ +/* + * These routines read and write the data references. For each supported data + * type there is a reader and a writer. + * + * If the data ref is orphaned or the plugin that provides it is disabled or + * there is a type mismatch, the functions that read data will return 0 as a + * default value or not modify the passed in memory. The plugins that write + * data will not write under these circumstances or if the data ref is + * read-only. + * + * NOTE: to keep the overhead of reading datarefs low, these routines do not + * do full validation of a dataref; passing a junk value for a dataref can + * result in crashing the sim. The get/set APIs do check for NULL. + * + * For array-style datarefs, you specify the number of items to read/write and + * the offset into the array; the actual number of items read or written is + * returned. This may be less to prevent an array-out-of-bounds error. + * + */ + + +/* + * XPLMGetDatai + * + * Read an integer data ref and return its value. The return value is the + * dataref value or 0 if the dataref is NULL or the plugin is disabled. + * + */ +XPLM_API int XPLMGetDatai( + XPLMDataRef inDataRef); + +/* + * XPLMSetDatai + * + * Write a new value to an integer data ref. This routine is a no-op if the + * plugin publishing the dataref is disabled, the dataref is NULL, or the + * dataref is not writable. + * + */ +XPLM_API void XPLMSetDatai( + XPLMDataRef inDataRef, + int inValue); + +/* + * XPLMGetDataf + * + * Read a single precision floating point dataref and return its value. The + * return value is the dataref value or 0.0 if the dataref is NULL or the + * plugin is disabled. + * + */ +XPLM_API float XPLMGetDataf( + XPLMDataRef inDataRef); + +/* + * XPLMSetDataf + * + * Write a new value to a single precision floating point data ref. This + * routine is a no-op if the plugin publishing the dataref is disabled, the + * dataref is NULL, or the dataref is not writable. + * + */ +XPLM_API void XPLMSetDataf( + XPLMDataRef inDataRef, + float inValue); + +/* + * XPLMGetDatad + * + * Read a double precision floating point dataref and return its value. The + * return value is the dataref value or 0.0 if the dataref is NULL or the + * plugin is disabled. + * + */ +XPLM_API double XPLMGetDatad( + XPLMDataRef inDataRef); + +/* + * XPLMSetDatad + * + * Write a new value to a double precision floating point data ref. This + * routine is a no-op if the plugin publishing the dataref is disabled, the + * dataref is NULL, or the dataref is not writable. + * + */ +XPLM_API void XPLMSetDatad( + XPLMDataRef inDataRef, + double inValue); + +/* + * XPLMGetDatavi + * + * Read a part of an integer array dataref. If you pass NULL for outValues, + * the routine will return the size of the array, ignoring inOffset and inMax. + * + * If outValues is not NULL, then up to inMax values are copied from the + * dataref into outValues, starting at inOffset in the dataref. If inMax + + * inOffset is larger than the size of the dataref, less than inMax values + * will be copied. The number of values copied is returned. + * + * Note: the semantics of array datarefs are entirely implemented by the + * plugin (or X-Plane) that provides the dataref, not the SDK itself; the + * above description is how these datarefs are intended to work, but a rogue + * plugin may have different behavior. + * + */ +XPLM_API int XPLMGetDatavi( + XPLMDataRef inDataRef, + int * outValues, /* Can be NULL */ + int inOffset, + int inMax); + +/* + * XPLMSetDatavi + * + * Write part or all of an integer array dataref. The values passed by + * inValues are written into the dataref starting at inOffset. Up to inCount + * values are written; however if the values would write "off the end" of the + * dataref array, then fewer values are written. + * + * Note: the semantics of array datarefs are entirely implemented by the + * plugin (or X-Plane) that provides the dataref, not the SDK itself; the + * above description is how these datarefs are intended to work, but a rogue + * plugin may have different behavior. + * + */ +XPLM_API void XPLMSetDatavi( + XPLMDataRef inDataRef, + int * inValues, + int inoffset, + int inCount); + +/* + * XPLMGetDatavf + * + * Read a part of a single precision floating point array dataref. If you pass + * NULL for outVaules, the routine will return the size of the array, ignoring + * inOffset and inMax. + * + * If outValues is not NULL, then up to inMax values are copied from the + * dataref into outValues, starting at inOffset in the dataref. If inMax + + * inOffset is larger than the size of the dataref, less than inMax values + * will be copied. The number of values copied is returned. + * + * Note: the semantics of array datarefs are entirely implemented by the + * plugin (or X-Plane) that provides the dataref, not the SDK itself; the + * above description is how these datarefs are intended to work, but a rogue + * plugin may have different behavior. + * + */ +XPLM_API int XPLMGetDatavf( + XPLMDataRef inDataRef, + float * outValues, /* Can be NULL */ + int inOffset, + int inMax); + +/* + * XPLMSetDatavf + * + * Write part or all of a single precision floating point array dataref. The + * values passed by inValues are written into the dataref starting at + * inOffset. Up to inCount values are written; however if the values would + * write "off the end" of the dataref array, then fewer values are written. + * + * Note: the semantics of array datarefs are entirely implemented by the + * plugin (or X-Plane) that provides the dataref, not the SDK itself; the + * above description is how these datarefs are intended to work, but a rogue + * plugin may have different behavior. + * + */ +XPLM_API void XPLMSetDatavf( + XPLMDataRef inDataRef, + float * inValues, + int inoffset, + int inCount); + +/* + * XPLMGetDatab + * + * Read a part of a byte array dataref. If you pass NULL for outVaules, the + * routine will return the size of the array, ignoring inOffset and inMax. + * + * If outValues is not NULL, then up to inMax values are copied from the + * dataref into outValues, starting at inOffset in the dataref. If inMax + + * inOffset is larger than the size of the dataref, less than inMax values + * will be copied. The number of values copied is returned. + * + * Note: the semantics of array datarefs are entirely implemented by the + * plugin (or X-Plane) that provides the dataref, not the SDK itself; the + * above description is how these datarefs are intended to work, but a rogue + * plugin may have different behavior. + * + */ +XPLM_API int XPLMGetDatab( + XPLMDataRef inDataRef, + void * outValue, /* Can be NULL */ + int inOffset, + int inMaxBytes); + +/* + * XPLMSetDatab + * + * Write part or all of a byte array dataref. The values passed by inValues + * are written into the dataref starting at inOffset. Up to inCount values are + * written; however if the values would write "off the end" of the dataref + * array, then fewer values are written. + * + * Note: the semantics of array datarefs are entirely implemented by the + * plugin (or X-Plane) that provides the dataref, not the SDK itself; the + * above description is how these datarefs are intended to work, but a rogue + * plugin may have different behavior. + * + */ +XPLM_API void XPLMSetDatab( + XPLMDataRef inDataRef, + void * inValue, + int inOffset, + int inLength); + +/*************************************************************************** + * PUBLISHING YOUR PLUGIN'S DATA + ***************************************************************************/ +/* + * These functions allow you to create data references that other plug-ins and + * X-Plane can access via the above data access APIs. Data references + * published by other plugins operate the same as ones published by X-Plane in + * all manners except that your data reference will not be available to other + * plugins if/when your plugin is disabled. + * + * You share data by registering data provider callback functions. When a + * plug-in requests your data, these callbacks are then called. You provide + * one callback to return the value when a plugin 'reads' it and another to + * change the value when a plugin 'writes' it. + * + * Important: you must pick a prefix for your datarefs other than "sim/" - + * this prefix is reserved for X-Plane. The X-Plane SDK website contains a + * registry where authors can select a unique first word for dataref names, to + * prevent dataref collisions between plugins. + * + */ + + +/* + * XPLMGetDatai_f + * + * Data provider function pointers. + * + * These define the function pointers you provide to get or set data. Note + * that you are passed a generic pointer for each one. This is the same + * pointer you pass in your register routine; you can use it to locate plugin + * variables, etc. + * + * The semantics of your callbacks are the same as the dataref accessor above + * - basically routines like XPLMGetDatai are just pass-throughs from a caller + * to your plugin. Be particularly mindful in implementing array dataref + * read-write accessors; you are responsible for avoiding overruns, supporting + * offset read/writes, and handling a read with a NULL buffer. + * + */ +typedef int (* XPLMGetDatai_f)( + void * inRefcon); + +/* + * XPLMSetDatai_f + * + */ +typedef void (* XPLMSetDatai_f)( + void * inRefcon, + int inValue); + +/* + * XPLMGetDataf_f + * + */ +typedef float (* XPLMGetDataf_f)( + void * inRefcon); + +/* + * XPLMSetDataf_f + * + */ +typedef void (* XPLMSetDataf_f)( + void * inRefcon, + float inValue); + +/* + * XPLMGetDatad_f + * + */ +typedef double (* XPLMGetDatad_f)( + void * inRefcon); + +/* + * XPLMSetDatad_f + * + */ +typedef void (* XPLMSetDatad_f)( + void * inRefcon, + double inValue); + +/* + * XPLMGetDatavi_f + * + */ +typedef int (* XPLMGetDatavi_f)( + void * inRefcon, + int * outValues, /* Can be NULL */ + int inOffset, + int inMax); + +/* + * XPLMSetDatavi_f + * + */ +typedef void (* XPLMSetDatavi_f)( + void * inRefcon, + int * inValues, + int inOffset, + int inCount); + +/* + * XPLMGetDatavf_f + * + */ +typedef int (* XPLMGetDatavf_f)( + void * inRefcon, + float * outValues, /* Can be NULL */ + int inOffset, + int inMax); + +/* + * XPLMSetDatavf_f + * + */ +typedef void (* XPLMSetDatavf_f)( + void * inRefcon, + float * inValues, + int inOffset, + int inCount); + +/* + * XPLMGetDatab_f + * + */ +typedef int (* XPLMGetDatab_f)( + void * inRefcon, + void * outValue, /* Can be NULL */ + int inOffset, + int inMaxLength); + +/* + * XPLMSetDatab_f + * + */ +typedef void (* XPLMSetDatab_f)( + void * inRefcon, + void * inValue, + int inOffset, + int inLength); + +/* + * XPLMRegisterDataAccessor + * + * This routine creates a new item of data that can be read and written. Pass + * in the data's full name for searching, the type(s) of the data for + * accessing, and whether the data can be written to. For each data type you + * support, pass in a read accessor function and a write accessor function if + * necessary. Pass NULL for data types you do not support or write accessors + * if you are read-only. + * + * You are returned a data ref for the new item of data created. You can use + * this data ref to unregister your data later or read or write from it. + * + */ +XPLM_API XPLMDataRef XPLMRegisterDataAccessor( + const char * inDataName, + XPLMDataTypeID inDataType, + int inIsWritable, + XPLMGetDatai_f inReadInt, + XPLMSetDatai_f inWriteInt, + XPLMGetDataf_f inReadFloat, + XPLMSetDataf_f inWriteFloat, + XPLMGetDatad_f inReadDouble, + XPLMSetDatad_f inWriteDouble, + XPLMGetDatavi_f inReadIntArray, + XPLMSetDatavi_f inWriteIntArray, + XPLMGetDatavf_f inReadFloatArray, + XPLMSetDatavf_f inWriteFloatArray, + XPLMGetDatab_f inReadData, + XPLMSetDatab_f inWriteData, + void * inReadRefcon, + void * inWriteRefcon); + +/* + * XPLMUnregisterDataAccessor + * + * Use this routine to unregister any data accessors you may have registered. + * You unregister a data ref by the XPLMDataRef you get back from + * registration. Once you unregister a data ref, your function pointer will + * not be called anymore. + * + */ +XPLM_API void XPLMUnregisterDataAccessor( + XPLMDataRef inDataRef); + +/*************************************************************************** + * SHARING DATA BETWEEN MULTIPLE PLUGINS + ***************************************************************************/ +/* + * The data reference registration APIs from the previous section allow a + * plugin to publish data in a one-owner manner; the plugin that publishes the + * data reference owns the real memory that the data ref uses. This is + * satisfactory for most cases, but there are also cases where plugnis need to + * share actual data. + * + * With a shared data reference, no one plugin owns the actual memory for the + * data reference; the plugin SDK allocates that for you. When the first + * plugin asks to 'share' the data, the memory is allocated. When the data is + * changed, every plugin that is sharing the data is notified. + * + * Shared data references differ from the 'owned' data references from the + * previous section in a few ways: + * + * * With shared data references, any plugin can create the data reference; + * with owned plugins one plugin must create the data reference and others + * subscribe. (This can be a problem if you don't know which set of plugins + * will be present). + * + * * With shared data references, every plugin that is sharing the data is + * notified when the data is changed. With owned data references, only the + * one owner is notified when the data is changed. + * + * * With shared data references, you cannot access the physical memory of the + * data reference; you must use the XPLMGet... and XPLMSet... APIs. With an + * owned data reference, the one owning data reference can manipulate the + * data reference's memory in any way it sees fit. + * + * Shared data references solve two problems: if you need to have a data + * reference used by several plugins but do not know which plugins will be + * installed, or if all plugins sharing data need to be notified when that + * data is changed, use shared data references. + * + */ + + +/* + * XPLMDataChanged_f + * + * An XPLMDataChanged_f is a callback that the XPLM calls whenever any other + * plug-in modifies shared data. A refcon you provide is passed back to help + * identify which data is being changed. In response, you may want to call one + * of the XPLMGetDataxxx routines to find the new value of the data. + * + */ +typedef void (* XPLMDataChanged_f)( + void * inRefcon); + +/* + * XPLMShareData + * + * This routine connects a plug-in to shared data, creating the shared data if + * necessary. inDataName is a standard path for the data ref, and inDataType + * specifies the type. This function will create the data if it does not + * exist. If the data already exists but the type does not match, an error is + * returned, so it is important that plug-in authors collaborate to establish + * public standards for shared data. + * + * If a notificationFunc is passed in and is not NULL, that notification + * function will be called whenever the data is modified. The notification + * refcon will be passed to it. This allows your plug-in to know which shared + * data was changed if multiple shared data are handled by one callback, or if + * the plug-in does not use global variables. + * + * A one is returned for successfully creating or finding the shared data; a + * zero if the data already exists but is of the wrong type. + * + */ +XPLM_API int XPLMShareData( + const char * inDataName, + XPLMDataTypeID inDataType, + XPLMDataChanged_f inNotificationFunc, + void * inNotificationRefcon); + +/* + * XPLMUnshareData + * + * This routine removes your notification function for shared data. Call it + * when done with the data to stop receiving change notifications. Arguments + * must match XPLMShareData. The actual memory will not necessarily be freed, + * since other plug-ins could be using it. + * + */ +XPLM_API int XPLMUnshareData( + const char * inDataName, + XPLMDataTypeID inDataType, + XPLMDataChanged_f inNotificationFunc, + void * inNotificationRefcon); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/CHeaders/XPLM/XPLMDefs.h b/XPLPro_Plugin_Source/SDK/CHeaders/XPLM/XPLMDefs.h new file mode 100644 index 0000000..bb1fe2f --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/CHeaders/XPLM/XPLMDefs.h @@ -0,0 +1,514 @@ +#ifndef _XPLMDefs_h_ +#define _XPLMDefs_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPLMDefs + ***************************************************************************/ +/* + * This file is contains the cross-platform and basic definitions for the + * X-Plane SDK. + * + * The preprocessor macros APL and IBM must be defined to specify the + * compilation target; define APL to 1 and IBM 0 to compile on Macintosh and + * APL to 0 and IBM to 1 for Windows. You must specify these macro definitions + * before including XPLMDefs.h or any other XPLM headers. You can do this + * using the -D command line option or a preprocessor header. + * + */ + + +#ifdef __cplusplus +extern "C" { +#endif + +#if IBM +#include +#else +#include +#endif +/*************************************************************************** + * DLL Definitions + ***************************************************************************/ +/* + * These definitions control the importing and exporting of functions within + * the DLL. + * + * You can prefix your five required callbacks with the PLUGIN_API macro to + * declare them as exported C functions. The XPLM_API macro identifies + * functions that are provided to you via the plugin SDK. (Link against + * XPLM.lib to use these functions.) + * + */ + + +#ifdef __cplusplus + #if APL + #if __GNUC__ >= 4 + #define PLUGIN_API extern "C" __attribute__((visibility("default"))) + #elif __MACH__ + #define PLUGIN_API extern "C" + #else + #define PLUGIN_API extern "C" __declspec(dllexport) + #endif + #elif IBM + #define PLUGIN_API extern "C" __declspec(dllexport) + #elif LIN + #if __GNUC__ >= 4 + #define PLUGIN_API extern "C" __attribute__((visibility("default"))) + #else + #define PLUGIN_API extern "C" + #endif + #else + #error "Platform not defined!" + #endif +#else + #if APL + #if __GNUC__ >= 4 + #define PLUGIN_API __attribute__((visibility("default"))) + #elif __MACH__ + #define PLUGIN_API + #else + #define PLUGIN_API __declspec(dllexport) + #endif + #elif IBM + #define PLUGIN_API __declspec(dllexport) + #elif LIN + #if __GNUC__ >= 4 + #define PLUGIN_API __attribute__((visibility("default"))) + #else + #define PLUGIN_API + #endif + #else + #error "Platform not defined!" + #endif +#endif + +#if APL + #if XPLM + #if __GNUC__ >= 4 + #define XPLM_API __attribute__((visibility("default"))) + #elif __MACH__ + #define XPLM_API + #else + #define XPLM_API __declspec(dllexport) + #endif + #else + #define XPLM_API + #endif +#elif IBM + #if XPLM + #define XPLM_API __declspec(dllexport) + #else + #define XPLM_API __declspec(dllimport) + #endif +#elif LIN + #if XPLM + #if __GNUC__ >= 4 + #define XPLM_API __attribute__((visibility("default"))) + #else + #define XPLM_API + #endif + #else + #define XPLM_API + #endif +#else + #error "Platform not defined!" +#endif + +/*************************************************************************** + * GLOBAL DEFINITIONS + ***************************************************************************/ +/* + * These definitions are used in all parts of the SDK. + * + */ + + +/* + * XPLMPluginID + * + * Each plug-in is identified by a unique integer ID. This ID can be used to + * disable or enable a plug-in, or discover what plug-in is 'running' at the + * time. A plug-in ID is unique within the currently running instance of + * X-Plane unless plug-ins are reloaded. Plug-ins may receive a different + * unique ID each time they are loaded. This includes the unloading and + * reloading of plugins that are part of the user's aircraft. + * + * For persistent identification of plug-ins, use XPLMFindPluginBySignature in + * XPLMUtiltiies.h + * + * -1 indicates no plug-in. + * + */ +typedef int XPLMPluginID; + +/* No plugin. */ +#define XPLM_NO_PLUGIN_ID (-1) + +/* X-Plane itself */ +#define XPLM_PLUGIN_XPLANE (0) + +/* The current XPLM revision is 3.03 (303). */ +#define kXPLM_Version (303) + +/* + * XPLMKeyFlags + * + * These bitfields define modifier keys in a platform independent way. When a + * key is pressed, a series of messages are sent to your plugin. The down + * flag is set in the first of these messages, and the up flag in the last. + * While the key is held down, messages are sent with neither to indicate that + * the key is being held down as a repeated character. + * + * The control flag is mapped to the control flag on Macintosh and PC. + * Generally X-Plane uses the control key and not the command key on + * Macintosh, providing a consistent interface across platforms that does not + * necessarily match the Macintosh user interface guidelines. There is not + * yet a way for plugins to access the Macintosh control keys without using + * #ifdefed code. + * + */ +enum { + /* The shift key is down */ + xplm_ShiftFlag = 1, + + /* The option or alt key is down */ + xplm_OptionAltFlag = 2, + + /* The control key is down* */ + xplm_ControlFlag = 4, + + /* The key is being pressed down */ + xplm_DownFlag = 8, + + /* The key is being released */ + xplm_UpFlag = 16, + + +}; +typedef int XPLMKeyFlags; + +/*************************************************************************** + * ASCII CONTROL KEY CODES + ***************************************************************************/ +/* + * These definitions define how various control keys are mapped to ASCII key + * codes. Not all key presses generate an ASCII value, so plugin code should + * be prepared to see null characters come from the keyboard...this usually + * represents a key stroke that has no equivalent ASCII, like a page-down + * press. Use virtual key codes to find these key strokes. + * + * ASCII key codes take into account modifier keys; shift keys will affect + * capitals and punctuation; control key combinations may have no vaild ASCII + * and produce NULL. To detect control-key combinations, use virtual key + * codes, not ASCII keys. + * + */ + + +#define XPLM_KEY_RETURN 13 + +#define XPLM_KEY_ESCAPE 27 + +#define XPLM_KEY_TAB 9 + +#define XPLM_KEY_DELETE 8 + +#define XPLM_KEY_LEFT 28 + +#define XPLM_KEY_RIGHT 29 + +#define XPLM_KEY_UP 30 + +#define XPLM_KEY_DOWN 31 + +#define XPLM_KEY_0 48 + +#define XPLM_KEY_1 49 + +#define XPLM_KEY_2 50 + +#define XPLM_KEY_3 51 + +#define XPLM_KEY_4 52 + +#define XPLM_KEY_5 53 + +#define XPLM_KEY_6 54 + +#define XPLM_KEY_7 55 + +#define XPLM_KEY_8 56 + +#define XPLM_KEY_9 57 + +#define XPLM_KEY_DECIMAL 46 + +/*************************************************************************** + * VIRTUAL KEY CODES + ***************************************************************************/ +/* + * These are cross-platform defines for every distinct keyboard press on the + * computer. Every physical key on the keyboard has a virtual key code. So + * the "two" key on the top row of the main keyboard has a different code from + * the "two" key on the numeric key pad. But the 'w' and 'W' character are + * indistinguishable by virtual key code because they are the same physical + * key (one with and one without the shift key). + * + * Use virtual key codes to detect keystrokes that do not have ASCII + * equivalents, allow the user to map the numeric keypad separately from the + * main keyboard, and detect control key and other modifier-key combinations + * that generate ASCII control key sequences (many of which are not available + * directly via character keys in the SDK). + * + * To assign virtual key codes we started with the Microsoft set but made some + * additions and changes. A few differences: + * + * 1. Modifier keys are not available as virtual key codes. You cannot get + * distinct modifier press and release messages. Please do not try to use + * modifier keys as regular keys; doing so will almost certainly interfere + * with users' abilities to use the native X-Plane key bindings. + * 2. Some keys that do not exist on both Mac and PC keyboards are removed. + * 3. Do not assume that the values of these keystrokes are interchangeable + * with MS v-keys. + * + */ + + +#define XPLM_VK_BACK 0x08 + +#define XPLM_VK_TAB 0x09 + +#define XPLM_VK_CLEAR 0x0C + +#define XPLM_VK_RETURN 0x0D + +#define XPLM_VK_ESCAPE 0x1B + +#define XPLM_VK_SPACE 0x20 + +#define XPLM_VK_PRIOR 0x21 + +#define XPLM_VK_NEXT 0x22 + +#define XPLM_VK_END 0x23 + +#define XPLM_VK_HOME 0x24 + +#define XPLM_VK_LEFT 0x25 + +#define XPLM_VK_UP 0x26 + +#define XPLM_VK_RIGHT 0x27 + +#define XPLM_VK_DOWN 0x28 + +#define XPLM_VK_SELECT 0x29 + +#define XPLM_VK_PRINT 0x2A + +#define XPLM_VK_EXECUTE 0x2B + +#define XPLM_VK_SNAPSHOT 0x2C + +#define XPLM_VK_INSERT 0x2D + +#define XPLM_VK_DELETE 0x2E + +#define XPLM_VK_HELP 0x2F + +/* XPLM_VK_0 thru XPLM_VK_9 are the same as ASCII '0' thru '9' (0x30 - 0x39) */ +#define XPLM_VK_0 0x30 + +#define XPLM_VK_1 0x31 + +#define XPLM_VK_2 0x32 + +#define XPLM_VK_3 0x33 + +#define XPLM_VK_4 0x34 + +#define XPLM_VK_5 0x35 + +#define XPLM_VK_6 0x36 + +#define XPLM_VK_7 0x37 + +#define XPLM_VK_8 0x38 + +#define XPLM_VK_9 0x39 + +/* XPLM_VK_A thru XPLM_VK_Z are the same as ASCII 'A' thru 'Z' (0x41 - 0x5A) */ +#define XPLM_VK_A 0x41 + +#define XPLM_VK_B 0x42 + +#define XPLM_VK_C 0x43 + +#define XPLM_VK_D 0x44 + +#define XPLM_VK_E 0x45 + +#define XPLM_VK_F 0x46 + +#define XPLM_VK_G 0x47 + +#define XPLM_VK_H 0x48 + +#define XPLM_VK_I 0x49 + +#define XPLM_VK_J 0x4A + +#define XPLM_VK_K 0x4B + +#define XPLM_VK_L 0x4C + +#define XPLM_VK_M 0x4D + +#define XPLM_VK_N 0x4E + +#define XPLM_VK_O 0x4F + +#define XPLM_VK_P 0x50 + +#define XPLM_VK_Q 0x51 + +#define XPLM_VK_R 0x52 + +#define XPLM_VK_S 0x53 + +#define XPLM_VK_T 0x54 + +#define XPLM_VK_U 0x55 + +#define XPLM_VK_V 0x56 + +#define XPLM_VK_W 0x57 + +#define XPLM_VK_X 0x58 + +#define XPLM_VK_Y 0x59 + +#define XPLM_VK_Z 0x5A + +#define XPLM_VK_NUMPAD0 0x60 + +#define XPLM_VK_NUMPAD1 0x61 + +#define XPLM_VK_NUMPAD2 0x62 + +#define XPLM_VK_NUMPAD3 0x63 + +#define XPLM_VK_NUMPAD4 0x64 + +#define XPLM_VK_NUMPAD5 0x65 + +#define XPLM_VK_NUMPAD6 0x66 + +#define XPLM_VK_NUMPAD7 0x67 + +#define XPLM_VK_NUMPAD8 0x68 + +#define XPLM_VK_NUMPAD9 0x69 + +#define XPLM_VK_MULTIPLY 0x6A + +#define XPLM_VK_ADD 0x6B + +#define XPLM_VK_SEPARATOR 0x6C + +#define XPLM_VK_SUBTRACT 0x6D + +#define XPLM_VK_DECIMAL 0x6E + +#define XPLM_VK_DIVIDE 0x6F + +#define XPLM_VK_F1 0x70 + +#define XPLM_VK_F2 0x71 + +#define XPLM_VK_F3 0x72 + +#define XPLM_VK_F4 0x73 + +#define XPLM_VK_F5 0x74 + +#define XPLM_VK_F6 0x75 + +#define XPLM_VK_F7 0x76 + +#define XPLM_VK_F8 0x77 + +#define XPLM_VK_F9 0x78 + +#define XPLM_VK_F10 0x79 + +#define XPLM_VK_F11 0x7A + +#define XPLM_VK_F12 0x7B + +#define XPLM_VK_F13 0x7C + +#define XPLM_VK_F14 0x7D + +#define XPLM_VK_F15 0x7E + +#define XPLM_VK_F16 0x7F + +#define XPLM_VK_F17 0x80 + +#define XPLM_VK_F18 0x81 + +#define XPLM_VK_F19 0x82 + +#define XPLM_VK_F20 0x83 + +#define XPLM_VK_F21 0x84 + +#define XPLM_VK_F22 0x85 + +#define XPLM_VK_F23 0x86 + +#define XPLM_VK_F24 0x87 + +/* The following definitions are extended and are not based on the Microsoft * + * key set. */ +#define XPLM_VK_EQUAL 0xB0 + +#define XPLM_VK_MINUS 0xB1 + +#define XPLM_VK_RBRACE 0xB2 + +#define XPLM_VK_LBRACE 0xB3 + +#define XPLM_VK_QUOTE 0xB4 + +#define XPLM_VK_SEMICOLON 0xB5 + +#define XPLM_VK_BACKSLASH 0xB6 + +#define XPLM_VK_COMMA 0xB7 + +#define XPLM_VK_SLASH 0xB8 + +#define XPLM_VK_PERIOD 0xB9 + +#define XPLM_VK_BACKQUOTE 0xBA + +#define XPLM_VK_ENTER 0xBB + +#define XPLM_VK_NUMPAD_ENT 0xBC + +#define XPLM_VK_NUMPAD_EQ 0xBD + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/CHeaders/XPLM/XPLMDisplay.h b/XPLPro_Plugin_Source/SDK/CHeaders/XPLM/XPLMDisplay.h new file mode 100644 index 0000000..48c7a70 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/CHeaders/XPLM/XPLMDisplay.h @@ -0,0 +1,1477 @@ +#ifndef _XPLMDisplay_h_ +#define _XPLMDisplay_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPLMDisplay + ***************************************************************************/ +/* + * This API provides the basic hooks to draw in X-Plane and create user + * interface. All X-Plane drawing is done in OpenGL. The X-Plane plug-in + * manager takes care of properly setting up the OpenGL context and matrices. + * You do not decide when in your code's execution to draw; X-Plane tells you + * (via callbacks) when it is ready to have your plugin draw. + * + * X-Plane's drawing strategy is straightforward: every "frame" the screen is + * rendered by drawing the 3-D scene (dome, ground, objects, airplanes, etc.) + * and then drawing the cockpit on top of it. Alpha blending is used to + * overlay the cockpit over the world (and the gauges over the panel, etc.). + * X-Plane user interface elements (including windows like the map, the main + * menu, etc.) are then drawn on top of the cockpit. + * + * There are two ways you can draw: directly and in a window. + * + * Direct drawing (deprecated!---more on that below) involves drawing to the + * screen before or after X-Plane finishes a phase of drawing. When you draw + * directly, you can specify whether X-Plane is to complete this phase or not. + * This allows you to do three things: draw before X-Plane does (under it), + * draw after X-Plane does (over it), or draw instead of X-Plane. + * + * To draw directly, you register a callback and specify which phase you want + * to intercept. The plug-in manager will call you over and over to draw that + * phase. + * + * Direct drawing allows you to override scenery, panels, or anything. Note + * that you cannot assume that you are the only plug-in drawing at this phase. + * + * Direct drawing is deprecated; at some point in the X-Plane 11 run, it will + * likely become unsupported entirely as X-Plane transitions from OpenGL to + * modern graphics API backends (e.g., Vulkan, Metal, etc.). In the long term, + * plugins should use the XPLMInstance API for drawing 3-D objects---this will + * be much more efficient than general 3-D OpenGL drawing, and it will + * actually be supported by the new graphics backends. We do not yet know what + * the post-transition API for generic 3-D drawing will look like (if it + * exists at all). + * + * In contrast to direct drawing, window drawing provides a higher level + * functionality. With window drawing, you create a 2-D window that takes up a + * portion of the screen. Window drawing is always two dimensional. Window + * drawing is front-to-back controlled; you can specify that you want your + * window to be brought on top, and other plug-ins may put their window on top + * of you. Window drawing also allows you to sign up for key presses and + * receive mouse clicks. + * + * There are three ways to get keystrokes: + * + * 1. If you create a window, the window can take keyboard focus. It will + * then receive all keystrokes. If no window has focus, X-Plane receives + * keystrokes. Use this to implement typing in dialog boxes, etc. Only + * one window may have focus at a time; your window will be notified if it + * loses focus. + * 2. If you need low level access to the keystroke stream, install a key + * sniffer. Key sniffers can be installed above everything or right in + * front of the sim. + * 3. If you would like to associate key strokes with commands/functions in + * your plug-in, you should simply register a command (via + * XPLMCreateCommand()) and allow users to bind whatever key they choose to + * that command. Another (now deprecated) method of doing so is to use a + * hot key---a key-specific callback. Hotkeys are sent based on virtual + * key strokes, so any key may be distinctly mapped with any modifiers. + * Hot keys can be remapped by other plug-ins. As a plug-in, you don't + * have to worry about what your hot key ends up mapped to; other plug-ins + * may provide a UI for remapping keystrokes. So hotkeys allow a user to + * resolve conflicts and customize keystrokes. + * + */ + +#include "XPLMDefs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*************************************************************************** + * DRAWING CALLBACKS + ***************************************************************************/ +/* + * Basic drawing callbacks, for low level intercepting of X-Plane's render + * loop. The purpose of drawing callbacks is to provide targeted additions or + * replacements to X-Plane's graphics environment (for example, to add extra + * custom objects, or replace drawing of the AI aircraft). Do not assume that + * the drawing callbacks will be called in the order implied by the + * enumerations. Also do not assume that each drawing phase ends before + * another begins; they may be nested. + * + * Note that all APIs in this section are deprecated, and will likely be + * removed during the X-Plane 11 run as part of the transition to + * Vulkan/Metal/etc. See the XPLMInstance API for future-proof drawing of 3-D + * objects. + * + */ + + +/* + * XPLMDrawingPhase + * + * This constant indicates which part of drawing we are in. Drawing is done + * from the back to the front. We get a callback before or after each item. + * Metaphases provide access to the beginning and end of the 3d (scene) and + * 2d (cockpit) drawing in a manner that is independent of new phases added + * via X-Plane implementation. + * + * **NOTE**: As of XPLM302 the legacy 3D drawing phases (xplm_Phase_FirstScene + * to xplm_Phase_LastScene) are deprecated. When running under X-Plane 11.50 + * with the modern Vulkan or Metal backend, X-Plane will no longer call + * these drawing phases. There is a new drawing phase, xplm_Phase_Modern3D, + * which is supported under OpenGL and Vulkan which is called out roughly + * where the old before xplm_Phase_Airplanes phase was for blending. This + * phase is *NOT* supported under Metal and comes with potentially + * substantial performance overhead. Please do *NOT* opt into this phase if + * you don't do any actual drawing that requires the depth buffer in some + * way! + * + * **WARNING**: As X-Plane's scenery evolves, some drawing phases may cease to + * exist and new ones may be invented. If you need a particularly specific + * use of these codes, consult Austin and/or be prepared to revise your code + * as X-Plane evolves. + * + */ +enum { +#if defined(XPLM_DEPRECATED) + /* Deprecated as of XPLM302. This is the earliest point at which you can draw * + * in 3-d. */ + xplm_Phase_FirstScene = 0, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated as of XPLM302. Drawing of land and water. */ + xplm_Phase_Terrain = 5, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated as of XPLM302. Drawing runways and other airport detail. */ + xplm_Phase_Airports = 10, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated as of XPLM302. Drawing roads, trails, trains, etc. */ + xplm_Phase_Vectors = 15, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated as of XPLM302. 3-d objects (houses, smokestacks, etc. */ + xplm_Phase_Objects = 20, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated as of XPLM302. External views of airplanes, both yours and the * + * AI aircraft. */ + xplm_Phase_Airplanes = 25, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated as of XPLM302. This is the last point at which you can draw in * + * 3-d. */ + xplm_Phase_LastScene = 30, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM302) + /* A chance to do modern 3D drawing. */ + xplm_Phase_Modern3D = 31, + +#endif /* XPLM302 */ + /* This is the first phase where you can draw in 2-d. */ + xplm_Phase_FirstCockpit = 35, + + /* The non-moving parts of the aircraft panel. */ + xplm_Phase_Panel = 40, + + /* The moving parts of the aircraft panel. */ + xplm_Phase_Gauges = 45, + + /* Floating windows from plugins. */ + xplm_Phase_Window = 50, + + /* The last chance to draw in 2d. */ + xplm_Phase_LastCockpit = 55, + +#if defined(XPLM200) + /* Removed as of XPLM300; Use the full-blown XPLMMap API instead. */ + xplm_Phase_LocalMap3D = 100, + +#endif /* XPLM200 */ +#if defined(XPLM200) + /* Removed as of XPLM300; Use the full-blown XPLMMap API instead. */ + xplm_Phase_LocalMap2D = 101, + +#endif /* XPLM200 */ +#if defined(XPLM200) + /* Removed as of XPLM300; Use the full-blown XPLMMap API instead. */ + xplm_Phase_LocalMapProfile = 102, + +#endif /* XPLM200 */ + +}; +typedef int XPLMDrawingPhase; + +/* + * XPLMDrawCallback_f + * + * This is the prototype for a low level drawing callback. You are passed in + * the phase and whether it is before or after. If you are before the phase, + * return 1 to let X-Plane draw or 0 to suppress X-Plane drawing. If you are + * after the phase the return value is ignored. + * + * Refcon is a unique value that you specify when registering the callback, + * allowing you to slip a pointer to your own data to the callback. + * + * Upon entry the OpenGL context will be correctly set up for you and OpenGL + * will be in 'local' coordinates for 3d drawing and panel coordinates for 2d + * drawing. The OpenGL state (texturing, etc.) will be unknown. + * + */ +typedef int (* XPLMDrawCallback_f)( + XPLMDrawingPhase inPhase, + int inIsBefore, + void * inRefcon); + +/* + * XPLMRegisterDrawCallback + * + * This routine registers a low level drawing callback. Pass in the phase you + * want to be called for and whether you want to be called before or after. + * This routine returns 1 if the registration was successful, or 0 if the + * phase does not exist in this version of X-Plane. You may register a + * callback multiple times for the same or different phases as long as the + * refcon is unique each time. + * + * Note that this function will likely be removed during the X-Plane 11 run as + * part of the transition to Vulkan/Metal/etc. See the XPLMInstance API for + * future-proof drawing of 3-D objects. + * + */ +XPLM_API int XPLMRegisterDrawCallback( + XPLMDrawCallback_f inCallback, + XPLMDrawingPhase inPhase, + int inWantsBefore, + void * inRefcon); + +/* + * XPLMUnregisterDrawCallback + * + * This routine unregisters a draw callback. You must unregister a callback + * for each time you register a callback if you have registered it multiple + * times with different refcons. The routine returns 1 if it can find the + * callback to unregister, 0 otherwise. + * + * Note that this function will likely be removed during the X-Plane 11 run as + * part of the transition to Vulkan/Metal/etc. See the XPLMInstance API for + * future-proof drawing of 3-D objects. + * + */ +XPLM_API int XPLMUnregisterDrawCallback( + XPLMDrawCallback_f inCallback, + XPLMDrawingPhase inPhase, + int inWantsBefore, + void * inRefcon); + +/*************************************************************************** + * WINDOW API + ***************************************************************************/ +/* + * The window API provides a high-level abstraction for drawing with UI + * interaction. + * + * Windows may operate in one of two modes: legacy (for plugins compiled + * against old versions of the XPLM, as well as windows created via the + * deprecated XPLMCreateWindow() function, rather than XPLMCreateWindowEx()), + * or modern (for windows compiled against the XPLM300 or newer API, and + * created via XPLMCreateWindowEx()). + * + * Modern windows have access to new X-Plane 11 windowing features, like + * support for new positioning modes (including being "popped out" into their + * own first-class window in the operating system). They can also optionally + * be decorated in the style of X-Plane 11 windows (like the map). + * + * Modern windows operate in "boxel" units. A boxel ("box of pixels") is a + * unit of virtual pixels which, depending on X-Plane's scaling, may + * correspond to an arbitrary NxN "box" of real pixels on screen. Because + * X-Plane handles this scaling automatically, you can effectively treat the + * units as though you were simply drawing in pixels, and know that when + * X-Plane is running with 150% or 200% scaling, your drawing will be + * automatically scaled (and likewise all mouse coordinates, screen bounds, + * etc. will also be auto-scaled). + * + * In contrast, legacy windows draw in true screen pixels, and thus tend to + * look quite small when X-Plane is operating in a scaled mode. + * + * Legacy windows have their origin in the lower left of the main X-Plane + * window. In contrast, since modern windows are not constrained to the main + * window, they have their origin in the lower left of the entire global + * desktop space, and the lower left of the main X-Plane window is not + * guaranteed to be (0, 0). In both cases, x increases as you move left, and y + * increases as you move up. + * + */ + + +/* + * XPLMWindowID + * + * This is an opaque identifier for a window. You use it to control your + * window. When you create a window (via either XPLMCreateWindow() or + * XPLMCreateWindowEx()), you will specify callbacks to handle drawing, mouse + * interaction, etc. + * + */ +typedef void * XPLMWindowID; + +/* + * XPLMDrawWindow_f + * + * A callback to handle 2-D drawing of your window. You are passed in your + * window and its refcon. Draw the window. You can use other XPLM functions + * from this header to find the current dimensions of your window, etc. When + * this callback is called, the OpenGL context will be set properly for 2-D + * window drawing. + * + * **Note**: Because you are drawing your window over a background, you can + * make a translucent window easily by simply not filling in your entire + * window's bounds. + * + */ +typedef void (* XPLMDrawWindow_f)( + XPLMWindowID inWindowID, + void * inRefcon); + +/* + * XPLMHandleKey_f + * + * This function is called when a key is pressed or keyboard focus is taken + * away from your window. If losingFocus is 1, you are losing the keyboard + * focus, otherwise a key was pressed and inKey contains its character. You + * are also passed your window and a refcon. + * + * Warning: this API declares virtual keys as a signed character; however the + * VKEY #define macros in XPLMDefs.h define the vkeys using unsigned values + * (that is 0x80 instead of -0x80). So you may need to cast the incoming vkey + * to an unsigned char to get correct comparisons in C. + * + */ +typedef void (* XPLMHandleKey_f)( + XPLMWindowID inWindowID, + char inKey, + XPLMKeyFlags inFlags, + char inVirtualKey, + void * inRefcon, + int losingFocus); + +/* + * XPLMMouseStatus + * + * When the mouse is clicked, your mouse click routine is called repeatedly. + * It is first called with the mouse down message. It is then called zero or + * more times with the mouse-drag message, and finally it is called once with + * the mouse up message. All of these messages will be directed to the same + * window; you are guaranteed to not receive a drag or mouse-up event without + * first receiving the corresponding mouse-down. + * + */ +enum { + xplm_MouseDown = 1, + + xplm_MouseDrag = 2, + + xplm_MouseUp = 3, + + +}; +typedef int XPLMMouseStatus; + +/* + * XPLMHandleMouseClick_f + * + * You receive this call for one of three events: + * + * - when the user clicks the mouse button down + * - (optionally) when the user drags the mouse after a down-click, but before + * the up-click + * - when the user releases the down-clicked mouse button. + * + * You receive the x and y of the click, your window, and a refcon. Return 1 + * to consume the click, or 0 to pass it through. + * + * WARNING: passing clicks through windows (as of this writing) causes mouse + * tracking problems in X-Plane; do not use this feature! + * + * The units for x and y values match the units used in your window. Thus, for + * "modern" windows (those created via XPLMCreateWindowEx() and compiled + * against the XPLM300 library), the units are boxels, while legacy windows + * will get pixels. Legacy windows have their origin in the lower left of the + * main X-Plane window, while modern windows have their origin in the lower + * left of the global desktop space. In both cases, x increases as you move + * right, and y increases as you move up. + * + */ +typedef int (* XPLMHandleMouseClick_f)( + XPLMWindowID inWindowID, + int x, + int y, + XPLMMouseStatus inMouse, + void * inRefcon); + +#if defined(XPLM200) +/* + * XPLMCursorStatus + * + * XPLMCursorStatus describes how you would like X-Plane to manage the cursor. + * See XPLMHandleCursor_f for more info. + * + */ +enum { + /* X-Plane manages the cursor normally, plugin does not affect the cusrsor. */ + xplm_CursorDefault = 0, + + /* X-Plane hides the cursor. */ + xplm_CursorHidden = 1, + + /* X-Plane shows the cursor as the default arrow. */ + xplm_CursorArrow = 2, + + /* X-Plane shows the cursor but lets you select an OS cursor. */ + xplm_CursorCustom = 3, + + +}; +typedef int XPLMCursorStatus; +#endif /* XPLM200 */ + +#if defined(XPLM200) +/* + * XPLMHandleCursor_f + * + * The SDK calls your cursor status callback when the mouse is over your + * plugin window. Return a cursor status code to indicate how you would like + * X-Plane to manage the cursor. If you return xplm_CursorDefault, the SDK + * will try lower-Z-order plugin windows, then let the sim manage the cursor. + * + * Note: you should never show or hide the cursor yourself---these APIs are + * typically reference-counted and thus cannot safely and predictably be used + * by the SDK. Instead return one of xplm_CursorHidden to hide the cursor or + * xplm_CursorArrow/xplm_CursorCustom to show the cursor. + * + * If you want to implement a custom cursor by drawing a cursor in OpenGL, use + * xplm_CursorHidden to hide the OS cursor and draw the cursor using a 2-d + * drawing callback (after xplm_Phase_Window is probably a good choice, but + * see deprecation warnings on the drawing APIs!). If you want to use a + * custom OS-based cursor, use xplm_CursorCustom to ask X-Plane to show the + * cursor but not affect its image. You can then use an OS specific call like + * SetThemeCursor (Mac) or SetCursor/LoadCursor (Windows). + * + * The units for x and y values match the units used in your window. Thus, for + * "modern" windows (those created via XPLMCreateWindowEx() and compiled + * against the XPLM300 library), the units are boxels, while legacy windows + * will get pixels. Legacy windows have their origin in the lower left of the + * main X-Plane window, while modern windows have their origin in the lower + * left of the global desktop space. In both cases, x increases as you move + * right, and y increases as you move up. + * + */ +typedef XPLMCursorStatus (* XPLMHandleCursor_f)( + XPLMWindowID inWindowID, + int x, + int y, + void * inRefcon); +#endif /* XPLM200 */ + +#if defined(XPLM200) +/* + * XPLMHandleMouseWheel_f + * + * The SDK calls your mouse wheel callback when one of the mouse wheels is + * scrolled within your window. Return 1 to consume the mouse wheel movement + * or 0 to pass them on to a lower window. (If your window appears opaque to + * the user, you should consume mouse wheel scrolling even if it does + * nothing.) The number of "clicks" indicates how far the wheel was turned + * since the last callback. The wheel is 0 for the vertical axis or 1 for the + * horizontal axis (for OS/mouse combinations that support this). + * + * The units for x and y values match the units used in your window. Thus, for + * "modern" windows (those created via XPLMCreateWindowEx() and compiled + * against the XPLM300 library), the units are boxels, while legacy windows + * will get pixels. Legacy windows have their origin in the lower left of the + * main X-Plane window, while modern windows have their origin in the lower + * left of the global desktop space. In both cases, x increases as you move + * right, and y increases as you move up. + * + */ +typedef int (* XPLMHandleMouseWheel_f)( + XPLMWindowID inWindowID, + int x, + int y, + int wheel, + int clicks, + void * inRefcon); +#endif /* XPLM200 */ + +#if defined(XPLM300) +/* + * XPLMWindowLayer + * + * XPLMWindowLayer describes where in the ordering of windows X-Plane should + * place a particular window. Windows in higher layers cover windows in lower + * layers. So, a given window might be at the top of its particular layer, but + * it might still be obscured by a window in a higher layer. (This happens + * frequently when floating windows, like X-Plane's map, are covered by a + * modal alert.) + * + * Your window's layer can only be specified when you create the window (in + * the XPLMCreateWindow_t you pass to XPLMCreateWindowEx()). For this reason, + * layering only applies to windows created with new X-Plane 11 GUI features. + * (Windows created using the older XPLMCreateWindow(), or windows compiled + * against a pre-XPLM300 version of the SDK will simply be placed in the + * flight overlay window layer.) + * + */ +enum { + /* The lowest layer, used for HUD-like displays while flying. */ + xplm_WindowLayerFlightOverlay = 0, + + /* Windows that "float" over the sim, like the X-Plane 11 map does. If you are* + * not sure which layer to create your window in, choose floating. */ + xplm_WindowLayerFloatingWindows = 1, + + /* An interruptive modal that covers the sim with a transparent black overlay * + * to draw the user's focus to the alert */ + xplm_WindowLayerModal = 2, + + /* "Growl"-style notifications that are visible in a corner of the screen, * + * even over modals */ + xplm_WindowLayerGrowlNotifications = 3, + + +}; +typedef int XPLMWindowLayer; +#endif /* XPLM300 */ + +#if defined(XPLM301) +/* + * XPLMWindowDecoration + * + * XPLMWindowDecoration describes how "modern" windows will be displayed. This + * impacts both how X-Plane draws your window as well as certain mouse + * handlers. + * + * Your window's decoration can only be specified when you create the window + * (in the XPLMCreateWindow_t you pass to XPLMCreateWindowEx()). + * + */ +enum { + /* X-Plane will draw no decoration for your window, and apply no automatic * + * click handlers. The window will not stop click from passing through its * + * bounds. This is suitable for "windows" which request, say, the full screen * + * bounds, then only draw in a small portion of the available area. */ + xplm_WindowDecorationNone = 0, + + /* The default decoration for "native" windows, like the map. Provides a solid* + * background, as well as click handlers for resizing and dragging the window.*/ + xplm_WindowDecorationRoundRectangle = 1, + + /* X-Plane will draw no decoration for your window, nor will it provide resize* + * handlers for your window edges, but it will stop clicks from passing * + * through your windows bounds. */ + xplm_WindowDecorationSelfDecorated = 2, + + /* Like self-decorated, but with resizing; X-Plane will draw no decoration for* + * your window, but it will stop clicks from passing through your windows * + * bounds, and provide automatic mouse handlers for resizing. */ + xplm_WindowDecorationSelfDecoratedResizable = 3, + + +}; +typedef int XPLMWindowDecoration; +#endif /* XPLM301 */ + +#if defined(XPLM200) +/* + * XPLMCreateWindow_t + * + * The XPMCreateWindow_t structure defines all of the parameters used to + * create a modern window using XPLMCreateWindowEx(). The structure will be + * expanded in future SDK APIs to include more features. Always set the + * structSize member to the size of your struct in bytes! + * + * All windows created by this function in the XPLM300 version of the API are + * created with the new X-Plane 11 GUI features. This means your plugin will + * get to "know" about the existence of X-Plane windows other than the main + * window. All drawing and mouse callbacks for your window will occur in + * "boxels," giving your windows automatic support for high-DPI scaling in + * X-Plane. In addition, your windows can opt-in to decoration with the + * X-Plane 11 window styling, and you can use the + * XPLMSetWindowPositioningMode() API to make your window "popped out" into a + * first-class operating system window. + * + * Note that this requires dealing with your window's bounds in "global + * desktop" positioning units, rather than the traditional panel coordinate + * system. In global desktop coordinates, the main X-Plane window may not have + * its origin at coordinate (0, 0), and your own window may have negative + * coordinates. Assuming you don't implicitly assume (0, 0) as your origin, + * the only API change you should need is to start using + * XPLMGetMouseLocationGlobal() rather than XPLMGetMouseLocation(), and + * XPLMGetScreenBoundsGlobal() instead of XPLMGetScreenSize(). + * + * If you ask to be decorated as a floating window, you'll get the blue window + * control bar and blue backing that you see in X-Plane 11's normal "floating" + * windows (like the map). + * + */ +typedef struct { + /* Used to inform XPLMCreateWindowEx() of the SDK version you compiled * + * against; should always be set to sizeof(XPLMCreateWindow_t) */ + int structSize; + /* Left bound, in global desktop boxels */ + int left; + /* Top bound, in global desktop boxels */ + int top; + /* Right bound, in global desktop boxels */ + int right; + /* Bottom bound, in global desktop boxels */ + int bottom; + int visible; + XPLMDrawWindow_f drawWindowFunc; + /* A callback to handle the user left-clicking within your window (or NULL to * + * ignore left clicks) */ + XPLMHandleMouseClick_f handleMouseClickFunc; + XPLMHandleKey_f handleKeyFunc; + XPLMHandleCursor_f handleCursorFunc; + XPLMHandleMouseWheel_f handleMouseWheelFunc; + /* A reference which will be passed into each of your window callbacks. Use * + * this to pass information to yourself as needed. */ + void * refcon; +#if defined(XPLM301) + /* Specifies the type of X-Plane 11-style "wrapper" you want around your * + * window, if any */ + XPLMWindowDecoration decorateAsFloatingWindow; +#endif /* XPLM301 */ +#if defined(XPLM300) + XPLMWindowLayer layer; +#endif /* XPLM300 */ +#if defined(XPLM300) + /* A callback to handle the user right-clicking within your window (or NULL to* + * ignore right clicks) */ + XPLMHandleMouseClick_f handleRightClickFunc; +#endif /* XPLM300 */ +} XPLMCreateWindow_t; +#endif /* XPLM200 */ + +#if defined(XPLM200) +/* + * XPLMCreateWindowEx + * + * This routine creates a new "modern" window. You pass in an + * XPLMCreateWindow_t structure with all of the fields set in. You must set + * the structSize of the structure to the size of the actual structure you + * used. Also, you must provide functions for every callback---you may not + * leave them null! (If you do not support the cursor or mouse wheel, use + * functions that return the default values.) + * + */ +XPLM_API XPLMWindowID XPLMCreateWindowEx( + XPLMCreateWindow_t * inParams); +#endif /* XPLM200 */ + +/* + * XPLMCreateWindow + * + * Deprecated as of XPLM300. + * + * This routine creates a new legacy window. Unlike modern windows (created + * via XPLMCreateWindowEx()), legacy windows do not have access to X-Plane 11 + * features like automatic scaling for high-DPI screens, native window styles, + * or support for being "popped out" into first-class operating system + * windows. + * + * Pass in the dimensions and offsets to the window's bottom left corner from + * the bottom left of the screen. You can specify whether the window is + * initially visible or not. Also, you pass in three callbacks to run the + * window and a refcon. This function returns a window ID you can use to + * refer to the new window. + * + * NOTE: Legacy windows do not have "frames"; you are responsible for drawing + * the background and frame of the window. Higher level libraries have + * routines which make this easy. + * + */ +XPLM_API XPLMWindowID XPLMCreateWindow( + int inLeft, + int inTop, + int inRight, + int inBottom, + int inIsVisible, + XPLMDrawWindow_f inDrawCallback, + XPLMHandleKey_f inKeyCallback, + XPLMHandleMouseClick_f inMouseCallback, + void * inRefcon); + +/* + * XPLMDestroyWindow + * + * This routine destroys a window. The window's callbacks are not called + * after this call. Keyboard focus is removed from the window before + * destroying it. + * + */ +XPLM_API void XPLMDestroyWindow( + XPLMWindowID inWindowID); + +/* + * XPLMGetScreenSize + * + * This routine returns the size of the main X-Plane OpenGL window in pixels. + * This number can be used to get a rough idea of the amount of detail the + * user will be able to see when drawing in 3-d. + * + */ +XPLM_API void XPLMGetScreenSize( + int * outWidth, /* Can be NULL */ + int * outHeight); /* Can be NULL */ + +#if defined(XPLM300) +/* + * XPLMGetScreenBoundsGlobal + * + * This routine returns the bounds of the "global" X-Plane desktop, in boxels. + * Unlike the non-global version XPLMGetScreenSize(), this is multi-monitor + * aware. There are three primary consequences of multimonitor awareness. + * + * First, if the user is running X-Plane in full-screen on two or more + * monitors (typically configured using one full-screen window per monitor), + * the global desktop will be sized to include all X-Plane windows. + * + * Second, the origin of the screen coordinates is not guaranteed to be (0, + * 0). Suppose the user has two displays side-by-side, both running at 1080p. + * Suppose further that they've configured their OS to make the left display + * their "primary" monitor, and that X-Plane is running in full-screen on + * their right monitor only. In this case, the global desktop bounds would be + * the rectangle from (1920, 0) to (3840, 1080). If the user later asked + * X-Plane to draw on their primary monitor as well, the bounds would change + * to (0, 0) to (3840, 1080). + * + * Finally, if the usable area of the virtual desktop is not a perfect + * rectangle (for instance, because the monitors have different resolutions or + * because one monitor is configured in the operating system to be above and + * to the right of the other), the global desktop will include any wasted + * space. Thus, if you have two 1080p monitors, and monitor 2 is configured to + * have its bottom left touch monitor 1's upper right, your global desktop + * area would be the rectangle from (0, 0) to (3840, 2160). + * + * Note that popped-out windows (windows drawn in their own operating system + * windows, rather than "floating" within X-Plane) are not included in these + * bounds. + * + */ +XPLM_API void XPLMGetScreenBoundsGlobal( + int * outLeft, /* Can be NULL */ + int * outTop, /* Can be NULL */ + int * outRight, /* Can be NULL */ + int * outBottom); /* Can be NULL */ +#endif /* XPLM300 */ + +#if defined(XPLM300) +/* + * XPLMReceiveMonitorBoundsGlobal_f + * + * This function is informed of the global bounds (in boxels) of a particular + * monitor within the X-Plane global desktop space. Note that X-Plane must be + * running in full screen on a monitor in order for that monitor to be passed + * to you in this callback. + * + */ +typedef void (* XPLMReceiveMonitorBoundsGlobal_f)( + int inMonitorIndex, + int inLeftBx, + int inTopBx, + int inRightBx, + int inBottomBx, + void * inRefcon); +#endif /* XPLM300 */ + +#if defined(XPLM300) +/* + * XPLMGetAllMonitorBoundsGlobal + * + * This routine immediately calls you back with the bounds (in boxels) of each + * full-screen X-Plane window within the X-Plane global desktop space. Note + * that if a monitor is *not* covered by an X-Plane window, you cannot get its + * bounds this way. Likewise, monitors with only an X-Plane window (not in + * full-screen mode) will not be included. + * + * If X-Plane is running in full-screen and your monitors are of the same size + * and configured contiguously in the OS, then the combined global bounds of + * all full-screen monitors will match the total global desktop bounds, as + * returned by XPLMGetScreenBoundsGlobal(). (Of course, if X-Plane is running + * in windowed mode, this will not be the case. Likewise, if you have + * differently sized monitors, the global desktop space will include wasted + * space.) + * + * Note that this function's monitor indices match those provided by + * XPLMGetAllMonitorBoundsOS(), but the coordinates are different (since the + * X-Plane global desktop may not match the operating system's global desktop, + * and one X-Plane boxel may be larger than one pixel due to 150% or 200% + * scaling). + * + */ +XPLM_API void XPLMGetAllMonitorBoundsGlobal( + XPLMReceiveMonitorBoundsGlobal_f inMonitorBoundsCallback, + void * inRefcon); +#endif /* XPLM300 */ + +#if defined(XPLM300) +/* + * XPLMReceiveMonitorBoundsOS_f + * + * This function is informed of the global bounds (in pixels) of a particular + * monitor within the operating system's global desktop space. Note that a + * monitor index being passed to you here does not indicate that X-Plane is + * running in full screen on this monitor, or even that any X-Plane windows + * exist on this monitor. + * + */ +typedef void (* XPLMReceiveMonitorBoundsOS_f)( + int inMonitorIndex, + int inLeftPx, + int inTopPx, + int inRightPx, + int inBottomPx, + void * inRefcon); +#endif /* XPLM300 */ + +#if defined(XPLM300) +/* + * XPLMGetAllMonitorBoundsOS + * + * This routine immediately calls you back with the bounds (in pixels) of each + * monitor within the operating system's global desktop space. Note that + * unlike XPLMGetAllMonitorBoundsGlobal(), this may include monitors that have + * no X-Plane window on them. + * + * Note that this function's monitor indices match those provided by + * XPLMGetAllMonitorBoundsGlobal(), but the coordinates are different (since + * the X-Plane global desktop may not match the operating system's global + * desktop, and one X-Plane boxel may be larger than one pixel). + * + */ +XPLM_API void XPLMGetAllMonitorBoundsOS( + XPLMReceiveMonitorBoundsOS_f inMonitorBoundsCallback, + void * inRefcon); +#endif /* XPLM300 */ + +/* + * XPLMGetMouseLocation + * + * Deprecated in XPLM300. Modern windows should use + * XPLMGetMouseLocationGlobal() instead. + * + * This routine returns the current mouse location in pixels relative to the + * main X-Plane window. The bottom left corner of the main window is (0, 0). + * Pass NULL to not receive info about either parameter. + * + * Because this function gives the mouse position relative to the main X-Plane + * window (rather than in global bounds), this function should only be used by + * legacy windows. Modern windows should instead get the mouse position in + * global desktop coordinates using XPLMGetMouseLocationGlobal(). + * + * Note that unlike XPLMGetMouseLocationGlobal(), if the mouse goes outside + * the user's main monitor (for instance, to a pop out window or a secondary + * monitor), this function will not reflect it. + * + */ +XPLM_API void XPLMGetMouseLocation( + int * outX, /* Can be NULL */ + int * outY); /* Can be NULL */ + +#if defined(XPLM300) +/* + * XPLMGetMouseLocationGlobal + * + * Returns the current mouse location in global desktop boxels. Unlike + * XPLMGetMouseLocation(), the bottom left of the main X-Plane window is not + * guaranteed to be (0, 0)---instead, the origin is the lower left of the + * entire global desktop space. In addition, this routine gives the real mouse + * location when the mouse goes to X-Plane windows other than the primary + * display. Thus, it can be used with both pop-out windows and secondary + * monitors. + * + * This is the mouse location function to use with modern windows (i.e., those + * created by XPLMCreateWindowEx()). + * + * Pass NULL to not receive info about either parameter. + * + */ +XPLM_API void XPLMGetMouseLocationGlobal( + int * outX, /* Can be NULL */ + int * outY); /* Can be NULL */ +#endif /* XPLM300 */ + +/* + * XPLMGetWindowGeometry + * + * This routine returns the position and size of a window. The units and + * coordinate system vary depending on the type of window you have. + * + * If this is a legacy window (one compiled against a pre-XPLM300 version of + * the SDK, or an XPLM300 window that was not created using + * XPLMCreateWindowEx()), the units are pixels relative to the main X-Plane + * display. + * + * If, on the other hand, this is a new X-Plane 11-style window (compiled + * against the XPLM300 SDK and created using XPLMCreateWindowEx()), the units + * are global desktop boxels. + * + * Pass NULL to not receive any paramter. + * + */ +XPLM_API void XPLMGetWindowGeometry( + XPLMWindowID inWindowID, + int * outLeft, /* Can be NULL */ + int * outTop, /* Can be NULL */ + int * outRight, /* Can be NULL */ + int * outBottom); /* Can be NULL */ + +/* + * XPLMSetWindowGeometry + * + * This routine allows you to set the position and size of a window. + * + * The units and coordinate system match those of XPLMGetWindowGeometry(). + * That is, modern windows use global desktop boxel coordinates, while legacy + * windows use pixels relative to the main X-Plane display. + * + * Note that this only applies to "floating" windows (that is, windows that + * are drawn within the X-Plane simulation windows, rather than being "popped + * out" into their own first-class operating system windows). To set the + * position of windows whose positioning mode is xplm_WindowPopOut, you'll + * need to instead use XPLMSetWindowGeometryOS(). + * + */ +XPLM_API void XPLMSetWindowGeometry( + XPLMWindowID inWindowID, + int inLeft, + int inTop, + int inRight, + int inBottom); + +#if defined(XPLM300) +/* + * XPLMGetWindowGeometryOS + * + * This routine returns the position and size of a "popped out" window (i.e., + * a window whose positioning mode is xplm_WindowPopOut), in operating system + * pixels. Pass NULL to not receive any parameter. + * + */ +XPLM_API void XPLMGetWindowGeometryOS( + XPLMWindowID inWindowID, + int * outLeft, /* Can be NULL */ + int * outTop, /* Can be NULL */ + int * outRight, /* Can be NULL */ + int * outBottom); /* Can be NULL */ +#endif /* XPLM300 */ + +#if defined(XPLM300) +/* + * XPLMSetWindowGeometryOS + * + * This routine allows you to set the position and size, in operating system + * pixel coordinates, of a popped out window (that is, a window whose + * positioning mode is xplm_WindowPopOut, which exists outside the X-Plane + * simulation window, in its own first-class operating system window). + * + * Note that you are responsible for ensuring both that your window is popped + * out (using XPLMWindowIsPoppedOut()) and that a monitor really exists at the + * OS coordinates you provide (using XPLMGetAllMonitorBoundsOS()). + * + */ +XPLM_API void XPLMSetWindowGeometryOS( + XPLMWindowID inWindowID, + int inLeft, + int inTop, + int inRight, + int inBottom); +#endif /* XPLM300 */ + +#if defined(XPLM301) +/* + * XPLMGetWindowGeometryVR + * + * Returns the width and height, in boxels, of a window in VR. Note that you + * are responsible for ensuring your window is in VR (using + * XPLMWindowIsInVR()). + * + */ +XPLM_API void XPLMGetWindowGeometryVR( + XPLMWindowID inWindowID, + int * outWidthBoxels, /* Can be NULL */ + int * outHeightBoxels); /* Can be NULL */ +#endif /* XPLM301 */ + +#if defined(XPLM301) +/* + * XPLMSetWindowGeometryVR + * + * This routine allows you to set the size, in boxels, of a window in VR (that + * is, a window whose positioning mode is xplm_WindowVR). + * + * Note that you are responsible for ensuring your window is in VR (using + * XPLMWindowIsInVR()). + * + */ +XPLM_API void XPLMSetWindowGeometryVR( + XPLMWindowID inWindowID, + int widthBoxels, + int heightBoxels); +#endif /* XPLM301 */ + +/* + * XPLMGetWindowIsVisible + * + * Returns true (1) if the specified window is visible. + * + */ +XPLM_API int XPLMGetWindowIsVisible( + XPLMWindowID inWindowID); + +/* + * XPLMSetWindowIsVisible + * + * This routine shows or hides a window. + * + */ +XPLM_API void XPLMSetWindowIsVisible( + XPLMWindowID inWindowID, + int inIsVisible); + +#if defined(XPLM300) +/* + * XPLMWindowIsPoppedOut + * + * True if this window has been popped out (making it a first-class window in + * the operating system), which in turn is true if and only if you have set + * the window's positioning mode to xplm_WindowPopOut. + * + * Only applies to modern windows. (Windows created using the deprecated + * XPLMCreateWindow(), or windows compiled against a pre-XPLM300 version of + * the SDK cannot be popped out.) + * + */ +XPLM_API int XPLMWindowIsPoppedOut( + XPLMWindowID inWindowID); +#endif /* XPLM300 */ + +#if defined(XPLM301) +/* + * XPLMWindowIsInVR + * + * True if this window has been moved to the virtual reality (VR) headset, + * which in turn is true if and only if you have set the window's positioning + * mode to xplm_WindowVR. + * + * Only applies to modern windows. (Windows created using the deprecated + * XPLMCreateWindow(), or windows compiled against a pre-XPLM301 version of + * the SDK cannot be moved to VR.) + * + */ +XPLM_API int XPLMWindowIsInVR( + XPLMWindowID inWindowID); +#endif /* XPLM301 */ + +#if defined(XPLM300) +/* + * XPLMSetWindowGravity + * + * A window's "gravity" controls how the window shifts as the whole X-Plane + * window resizes. A gravity of 1 means the window maintains its positioning + * relative to the right or top edges, 0 the left/bottom, and 0.5 keeps it + * centered. + * + * Default gravity is (0, 1, 0, 1), meaning your window will maintain its + * position relative to the top left and will not change size as its + * containing window grows. + * + * If you wanted, say, a window that sticks to the top of the screen (with a + * constant height), but which grows to take the full width of the window, you + * would pass (0, 1, 1, 1). Because your left and right edges would maintain + * their positioning relative to their respective edges of the screen, the + * whole width of your window would change with the X-Plane window. + * + * Only applies to modern windows. (Windows created using the deprecated + * XPLMCreateWindow(), or windows compiled against a pre-XPLM300 version of + * the SDK will simply get the default gravity.) + * + */ +XPLM_API void XPLMSetWindowGravity( + XPLMWindowID inWindowID, + float inLeftGravity, + float inTopGravity, + float inRightGravity, + float inBottomGravity); +#endif /* XPLM300 */ + +#if defined(XPLM300) +/* + * XPLMSetWindowResizingLimits + * + * Sets the minimum and maximum size of the client rectangle of the given + * window. (That is, it does not include any window styling that you might + * have asked X-Plane to apply on your behalf.) All resizing operations are + * constrained to these sizes. + * + * Only applies to modern windows. (Windows created using the deprecated + * XPLMCreateWindow(), or windows compiled against a pre-XPLM300 version of + * the SDK will have no minimum or maximum size.) + * + */ +XPLM_API void XPLMSetWindowResizingLimits( + XPLMWindowID inWindowID, + int inMinWidthBoxels, + int inMinHeightBoxels, + int inMaxWidthBoxels, + int inMaxHeightBoxels); +#endif /* XPLM300 */ + +#if defined(XPLM300) +/* + * XPLMWindowPositioningMode + * + * XPLMWindowPositionMode describes how X-Plane will position your window on + * the user's screen. X-Plane will maintain this positioning mode even as the + * user resizes their window or adds/removes full-screen monitors. + * + * Positioning mode can only be set for "modern" windows (that is, windows + * created using XPLMCreateWindowEx() and compiled against the XPLM300 SDK). + * Windows created using the deprecated XPLMCreateWindow(), or windows + * compiled against a pre-XPLM300 version of the SDK will simply get the + * "free" positioning mode. + * + */ +enum { + /* The default positioning mode. Set the window geometry and its future * + * position will be determined by its window gravity, resizing limits, and * + * user interactions. */ + xplm_WindowPositionFree = 0, + + /* Keep the window centered on the monitor you specify */ + xplm_WindowCenterOnMonitor = 1, + + /* Keep the window full screen on the monitor you specify */ + xplm_WindowFullScreenOnMonitor = 2, + + /* Like gui_window_full_screen_on_monitor, but stretches over *all* monitors * + * and popout windows. This is an obscure one... unless you have a very good * + * reason to need it, you probably don't! */ + xplm_WindowFullScreenOnAllMonitors = 3, + + /* A first-class window in the operating system, completely separate from the * + * X-Plane window(s) */ + xplm_WindowPopOut = 4, + +#if defined(XPLM301) + /* A floating window visible on the VR headset */ + xplm_WindowVR = 5, + +#endif /* XPLM301 */ + +}; +typedef int XPLMWindowPositioningMode; +#endif /* XPLM300 */ + +#if defined(XPLM300) +/* + * XPLMSetWindowPositioningMode + * + * Sets the policy for how X-Plane will position your window. + * + * Some positioning modes apply to a particular monitor. For those modes, you + * can pass a negative monitor index to position the window on the main + * X-Plane monitor (the screen with the X-Plane menu bar at the top). Or, if + * you have a specific monitor you want to position your window on, you can + * pass a real monitor index as received from, e.g., + * XPLMGetAllMonitorBoundsOS(). + * + * Only applies to modern windows. (Windows created using the deprecated + * XPLMCreateWindow(), or windows compiled against a pre-XPLM300 version of + * the SDK will always use xplm_WindowPositionFree.) + * + */ +XPLM_API void XPLMSetWindowPositioningMode( + XPLMWindowID inWindowID, + XPLMWindowPositioningMode inPositioningMode, + int inMonitorIndex); +#endif /* XPLM300 */ + +#if defined(XPLM300) +/* + * XPLMSetWindowTitle + * + * Sets the name for a window. This only applies to windows that opted-in to + * styling as an X-Plane 11 floating window (i.e., with styling mode + * xplm_WindowDecorationRoundRectangle) when they were created using + * XPLMCreateWindowEx(). + * + */ +XPLM_API void XPLMSetWindowTitle( + XPLMWindowID inWindowID, + const char * inWindowTitle); +#endif /* XPLM300 */ + +/* + * XPLMGetWindowRefCon + * + * Returns a window's reference constant, the unique value you can use for + * your own purposes. + * + */ +XPLM_API void * XPLMGetWindowRefCon( + XPLMWindowID inWindowID); + +/* + * XPLMSetWindowRefCon + * + * Sets a window's reference constant. Use this to pass data to yourself in + * the callbacks. + * + */ +XPLM_API void XPLMSetWindowRefCon( + XPLMWindowID inWindowID, + void * inRefcon); + +/* + * XPLMTakeKeyboardFocus + * + * This routine gives a specific window keyboard focus. Keystrokes will be + * sent to that window. Pass a window ID of 0 to remove keyboard focus from + * any plugin-created windows and instead pass keyboard strokes directly to + * X-Plane. + * + */ +XPLM_API void XPLMTakeKeyboardFocus( + XPLMWindowID inWindow); + +/* + * XPLMHasKeyboardFocus + * + * Returns true (1) if the indicated window has keyboard focus. Pass a window + * ID of 0 to see if no plugin window has focus, and all keystrokes will go + * directly to X-Plane. + * + */ +XPLM_API int XPLMHasKeyboardFocus( + XPLMWindowID inWindow); + +/* + * XPLMBringWindowToFront + * + * This routine brings the window to the front of the Z-order for its layer. + * Windows are brought to the front automatically when they are created. + * Beyond that, you should make sure you are front before handling mouse + * clicks. + * + * Note that this only brings your window to the front of its layer + * (XPLMWindowLayer). Thus, if you have a window in the floating window layer + * (xplm_WindowLayerFloatingWindows), but there is a modal window (in layer + * xplm_WindowLayerModal) above you, you would still not be the true frontmost + * window after calling this. (After all, the window layers are strictly + * ordered, and no window in a lower layer can ever be above any window in a + * higher one.) + * + */ +XPLM_API void XPLMBringWindowToFront( + XPLMWindowID inWindow); + +/* + * XPLMIsWindowInFront + * + * This routine returns true if the window you passed in is the frontmost + * visible window in its layer (XPLMWindowLayer). + * + * Thus, if you have a window at the front of the floating window layer + * (xplm_WindowLayerFloatingWindows), this will return true even if there is a + * modal window (in layer xplm_WindowLayerModal) above you. (Not to worry, + * though: in such a case, X-Plane will not pass clicks or keyboard input down + * to your layer until the window above stops "eating" the input.) + * + * Note that legacy windows are always placed in layer + * xplm_WindowLayerFlightOverlay, while modern-style windows default to + * xplm_WindowLayerFloatingWindows. This means it's perfectly consistent to + * have two different plugin-created windows (one legacy, one modern) *both* + * be in the front (of their different layers!) at the same time. + * + */ +XPLM_API int XPLMIsWindowInFront( + XPLMWindowID inWindow); + +/*************************************************************************** + * KEY SNIFFERS + ***************************************************************************/ +/* + * Low-level keyboard handlers. Allows for intercepting keystrokes outside the + * normal rules of the user interface. + * + */ + + +/* + * XPLMKeySniffer_f + * + * This is the prototype for a low level key-sniffing function. Window-based + * UI _should not use this_! The windowing system provides high-level + * mediated keyboard access, via the callbacks you attach to your + * XPLMCreateWindow_t. By comparison, the key sniffer provides low level + * keyboard access. + * + * Key sniffers are provided to allow libraries to provide non-windowed user + * interaction. For example, the MUI library uses a key sniffer to do pop-up + * text entry. + * + * Return 1 to pass the key on to the next sniffer, the window manager, + * X-Plane, or whomever is down stream. Return 0 to consume the key. + * + * Warning: this API declares virtual keys as a signed character; however the + * VKEY #define macros in XPLMDefs.h define the vkeys using unsigned values + * (that is 0x80 instead of -0x80). So you may need to cast the incoming vkey + * to an unsigned char to get correct comparisons in C. + * + */ +typedef int (* XPLMKeySniffer_f)( + char inChar, + XPLMKeyFlags inFlags, + char inVirtualKey, + void * inRefcon); + +/* + * XPLMRegisterKeySniffer + * + * This routine registers a key sniffing callback. You specify whether you + * want to sniff before the window system, or only sniff keys the window + * system does not consume. You should ALMOST ALWAYS sniff non-control keys + * after the window system. When the window system consumes a key, it is + * because the user has "focused" a window. Consuming the key or taking + * action based on the key will produce very weird results. Returns + * 1 if successful. + * + */ +XPLM_API int XPLMRegisterKeySniffer( + XPLMKeySniffer_f inCallback, + int inBeforeWindows, + void * inRefcon); + +/* + * XPLMUnregisterKeySniffer + * + * This routine unregisters a key sniffer. You must unregister a key sniffer + * for every time you register one with the exact same signature. Returns 1 + * if successful. + * + */ +XPLM_API int XPLMUnregisterKeySniffer( + XPLMKeySniffer_f inCallback, + int inBeforeWindows, + void * inRefcon); + +/*************************************************************************** + * HOT KEYS + ***************************************************************************/ +/* + * Keystrokes that can be managed by others. These are lower-level than window + * keyboard handlers (i.e., callbacks you attach to your XPLMCreateWindow_t), + * but higher level than key sniffers. + * + */ + + +/* + * XPLMHotKey_f + * + * Your hot key callback simply takes a pointer of your choosing. + * + */ +typedef void (* XPLMHotKey_f)( + void * inRefcon); + +/* + * XPLMHotKeyID + * + * An opaque ID used to identify a hot key. + * + */ +typedef void * XPLMHotKeyID; + +/* + * XPLMRegisterHotKey + * + * This routine registers a hot key. You specify your preferred key stroke + * virtual key/flag combination, a description of what your callback does (so + * other plug-ins can describe the plug-in to the user for remapping) and a + * callback function and opaque pointer to pass in). A new hot key ID is + * returned. During execution, the actual key associated with your hot key + * may change, but you are insulated from this. + * + */ +XPLM_API XPLMHotKeyID XPLMRegisterHotKey( + char inVirtualKey, + XPLMKeyFlags inFlags, + const char * inDescription, + XPLMHotKey_f inCallback, + void * inRefcon); + +/* + * XPLMUnregisterHotKey + * + * Unregisters a hot key. You can only unregister your own hot keys. + * + */ +XPLM_API void XPLMUnregisterHotKey( + XPLMHotKeyID inHotKey); + +/* + * XPLMCountHotKeys + * + * Returns the number of current hot keys. + * + */ +XPLM_API int XPLMCountHotKeys(void); + +/* + * XPLMGetNthHotKey + * + * Returns a hot key by index, for iteration on all hot keys. + * + */ +XPLM_API XPLMHotKeyID XPLMGetNthHotKey( + int inIndex); + +/* + * XPLMGetHotKeyInfo + * + * Returns information about the hot key. Return NULL for any parameter you + * don't want info about. The description should be at least 512 chars long. + * + */ +XPLM_API void XPLMGetHotKeyInfo( + XPLMHotKeyID inHotKey, + char * outVirtualKey, /* Can be NULL */ + XPLMKeyFlags * outFlags, /* Can be NULL */ + char * outDescription, /* Can be NULL */ + XPLMPluginID * outPlugin); /* Can be NULL */ + +/* + * XPLMSetHotKeyCombination + * + * Remaps a hot key's keystrokes. You may remap another plugin's keystrokes. + * + */ +XPLM_API void XPLMSetHotKeyCombination( + XPLMHotKeyID inHotKey, + char inVirtualKey, + XPLMKeyFlags inFlags); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/CHeaders/XPLM/XPLMGraphics.h b/XPLPro_Plugin_Source/SDK/CHeaders/XPLM/XPLMGraphics.h new file mode 100644 index 0000000..d7aef52 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/CHeaders/XPLM/XPLMGraphics.h @@ -0,0 +1,437 @@ +#ifndef _XPLMGraphics_h_ +#define _XPLMGraphics_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPLMGraphics + ***************************************************************************/ +/* + * A few notes on coordinate systems: + * + * X-Plane uses three kinds of coordinates. Global coordinates are specified + * as latitude, longitude and elevation. This coordinate system never changes + * but is not very precise. + * + * OpenGL (or 'local') coordinates are cartesian and shift with the plane. + * They offer more precision and are used for 3-d OpenGL drawing. The X axis + * is aligned east-west with positive X meaning east. The Y axis is aligned + * straight up and down at the point 0,0,0 (but since the earth is round it is + * not truly straight up and down at other points). The Z axis is aligned + * north-south at 0, 0, 0 with positive Z pointing south (but since the earth + * is round it isn't exactly north-south as you move east or west of 0, 0, 0). + * One unit is one meter and the point 0,0,0 is on the surface of the earth at + * sea level for some latitude and longitude picked by the sim such that the + * user's aircraft is reasonably nearby. + * + * 2-d Panel coordinates are 2d, with the X axis horizontal and the Y axis + * vertical. The point 0,0 is the bottom left and 1024,768 is the upper + * right of the screen. This is true no matter what resolution the user's + * monitor is in; when running in higher resolution, graphics will be + * scaled. + * + * Use X-Plane's routines to convert between global and local coordinates. Do + * not attempt to do this conversion yourself; the precise 'roundness' of + * X-Plane's physics model may not match your own, and (to make things + * weirder) the user can potentially customize the physics of the current + * planet. + * + */ + +#include "XPLMDefs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*************************************************************************** + * X-PLANE GRAPHICS + ***************************************************************************/ +/* + * These routines allow you to use OpenGL with X-Plane. + * + */ + + +/* + * XPLMTextureID + * + * XPLM Texture IDs name well-known textures in the sim for you to use. This + * allows you to recycle textures from X-Plane, saving VRAM. + * + * *Warning*: do not use these enums. The only remaining use they have is to + * access the legacy compatibility v10 UI texture; if you need this, get it + * via the Widgets library. + * + */ +enum { + /* The bitmap that contains window outlines, button outlines, fonts, etc. */ + xplm_Tex_GeneralInterface = 0, + +#if defined(XPLM_DEPRECATED) + /* The exterior paint for the user's aircraft (daytime). */ + xplm_Tex_AircraftPaint = 1, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* The exterior light map for the user's aircraft. */ + xplm_Tex_AircraftLiteMap = 2, + +#endif /* XPLM_DEPRECATED */ + +}; +typedef int XPLMTextureID; + +/* + * XPLMSetGraphicsState + * + * XPLMSetGraphicsState changes OpenGL's fixed function pipeline state. You + * are not responsible for restoring any state that is accessed via + * XPLMSetGraphicsState, but you are responsible for not accessing this state + * directly. + * + * - inEnableFog - enables or disables fog, equivalent to: glEnable(GL_FOG); + * - inNumberTexUnits - enables or disables a number of multitexturing units. + * If the number is 0, 2d texturing is disabled entirely, as in + * glDisable(GL_TEXTURE_2D); Otherwise, 2d texturing is enabled, and a + * number of multitexturing units are enabled sequentially, starting with + * unit 0, e.g. glActiveTextureARB(GL_TEXTURE0_ARB); glEnable + * (GL_TEXTURE_2D); + * - inEnableLighting - enables or disables OpenGL lighting, e.g. + * glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); + * - inEnableAlphaTesting - enables or disables the alpha test per pixel, e.g. + * glEnable(GL_ALPHA_TEST); + * - inEnableAlphaBlending - enables or disables alpha blending per pixel, + * e.g. glEnable(GL_BLEND); + * - inEnableDepthTesting - enables per pixel depth testing, as in + * glEnable(GL_DEPTH_TEST); + * - inEnableDepthWriting - enables writing back of depth information to the + * depth bufffer, as in glDepthMask(GL_TRUE); + * + * The purpose of this function is to change OpenGL state while keeping + * X-Plane aware of the state changes; this keeps X-Plane from getting + * surprised by OGL state changes, and prevents X-Plane and plug-ins from + * having to set all state before all draws; XPLMSetGraphicsState internally + * skips calls to change state that is already properly enabled. + * + * X-Plane does not have a 'default' OGL state for plug-ins with respect to + * the above state vector; plug-ins should totally set OGL state using this + * API before drawing. Use XPLMSetGraphicsState instead of any of the above + * OpenGL calls. + * + * WARNING: Any routine that performs drawing (e.g. XPLMDrawString or widget + * code) may change X-Plane's state. Always set state before drawing after + * unknown code has executed. + * + * *Deprecation Warnings*: X-Plane's lighting and fog environemnt is + * significantly more complex than the fixed function pipeline can express; + * do not assume that lighting and fog state is a good approximation for 3-d + * drawing. Prefer to use XPLMInstancing to draw objects. All calls to + * XPLMSetGraphicsState should have no fog or lighting. + * + */ +XPLM_API void XPLMSetGraphicsState( + int inEnableFog, + int inNumberTexUnits, + int inEnableLighting, + int inEnableAlphaTesting, + int inEnableAlphaBlending, + int inEnableDepthTesting, + int inEnableDepthWriting); + +/* + * XPLMBindTexture2d + * + * XPLMBindTexture2d changes what texture is bound to the 2d texturing + * target. This routine caches the current 2d texture across all texturing + * units in the sim and plug-ins, preventing extraneous binding. For + * example, consider several plug-ins running in series; if they all use the + * 'general interface' bitmap to do UI, calling this function will skip the + * rebinding of the general interface texture on all but the first plug-in, + * which can provide better frame rate son some graphics cards. + * + * inTextureID is the ID of the texture object to bind; inTextureUnit is a + * zero-based texture unit (e.g. 0 for the first one), up to a maximum of 4 + * units. (This number may increase in future versions of X-Plane.) + * + * Use this routine instead of glBindTexture(GL_TEXTURE_2D, ....); + * + */ +XPLM_API void XPLMBindTexture2d( + int inTextureNum, + int inTextureUnit); + +/* + * XPLMGenerateTextureNumbers + * + * Use this routine instead of glGenTextures to generate new texture object + * IDs. This routine historically ensured that plugins don't use texure IDs + * that X-Plane is reserving for its own use. + * + */ +XPLM_API void XPLMGenerateTextureNumbers( + int * outTextureIDs, + int inCount); + +#if defined(XPLM_DEPRECATED) +/* + * XPLMGetTexture + * + * XPLMGetTexture returns the OpenGL texture ID of an X-Plane texture based on + * a generic identifying code. For example, you can get the texture for + * X-Plane's UI bitmaps. + * + */ +XPLM_API int XPLMGetTexture( + XPLMTextureID inTexture); +#endif /* XPLM_DEPRECATED */ + +/* + * XPLMWorldToLocal + * + * This routine translates coordinates from latitude, longitude, and altitude + * to local scene coordinates. Latitude and longitude are in decimal degrees, + * and altitude is in meters MSL (mean sea level). The XYZ coordinates are in + * meters in the local OpenGL coordinate system. + * + */ +XPLM_API void XPLMWorldToLocal( + double inLatitude, + double inLongitude, + double inAltitude, + double * outX, + double * outY, + double * outZ); + +/* + * XPLMLocalToWorld + * + * This routine translates a local coordinate triplet back into latitude, + * longitude, and altitude. Latitude and longitude are in decimal degrees, + * and altitude is in meters MSL (mean sea level). The XYZ coordinates are in + * meters in the local OpenGL coordinate system. + * + * NOTE: world coordinates are less precise than local coordinates; you should + * try to avoid round tripping from local to world and back. + * + */ +XPLM_API void XPLMLocalToWorld( + double inX, + double inY, + double inZ, + double * outLatitude, + double * outLongitude, + double * outAltitude); + +/* + * XPLMDrawTranslucentDarkBox + * + * This routine draws a translucent dark box, partially obscuring parts of the + * screen but making text easy to read. This is the same graphics primitive + * used by X-Plane to show text files and ATC info. + * + */ +XPLM_API void XPLMDrawTranslucentDarkBox( + int inLeft, + int inTop, + int inRight, + int inBottom); + +/*************************************************************************** + * X-PLANE TEXT + ***************************************************************************/ + +/* + * XPLMFontID + * + * X-Plane features some fixed-character fonts. Each font may have its own + * metrics. + * + * WARNING: Some of these fonts are no longer supported or may have changed + * geometries. For maximum copmatibility, see the comments below. + * + * Note: X-Plane 7 supports proportional-spaced fonts. Since no measuring + * routine is available yet, the SDK will normally draw using a fixed-width + * font. You can use a dataref to enable proportional font drawing on XP7 if + * you want to. + * + */ +enum { + /* Mono-spaced font for user interface. Available in all versions of the SDK.*/ + xplmFont_Basic = 0, + +#if defined(XPLM_DEPRECATED) + /* Deprecated, do not use. */ + xplmFont_Menus = 1, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated, do not use. */ + xplmFont_Metal = 2, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated, do not use. */ + xplmFont_Led = 3, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated, do not use. */ + xplmFont_LedWide = 4, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated, do not use. */ + xplmFont_PanelHUD = 5, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated, do not use. */ + xplmFont_PanelEFIS = 6, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated, do not use. */ + xplmFont_PanelGPS = 7, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated, do not use. */ + xplmFont_RadiosGA = 8, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated, do not use. */ + xplmFont_RadiosBC = 9, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated, do not use. */ + xplmFont_RadiosHM = 10, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated, do not use. */ + xplmFont_RadiosGANarrow = 11, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated, do not use. */ + xplmFont_RadiosBCNarrow = 12, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated, do not use. */ + xplmFont_RadiosHMNarrow = 13, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated, do not use. */ + xplmFont_Timer = 14, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated, do not use. */ + xplmFont_FullRound = 15, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated, do not use. */ + xplmFont_SmallRound = 16, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated, do not use. */ + xplmFont_Menus_Localized = 17, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM200) + /* Proportional UI font. */ + xplmFont_Proportional = 18, + +#endif /* XPLM200 */ + +}; +typedef int XPLMFontID; + +/* + * XPLMDrawString + * + * This routine draws a NULL termianted string in a given font. Pass in the + * lower left pixel that the character is to be drawn onto. Also pass the + * character and font ID. This function returns the x offset plus the width of + * all drawn characters. The color to draw in is specified as a pointer to an + * array of three floating point colors, representing RGB intensities from 0.0 + * to 1.0. + * + */ +XPLM_API void XPLMDrawString( + float * inColorRGB, + int inXOffset, + int inYOffset, + char * inChar, + int * inWordWrapWidth, /* Can be NULL */ + XPLMFontID inFontID); + +/* + * XPLMDrawNumber + * + * This routine draws a number similar to the digit editing fields in + * PlaneMaker and data output display in X-Plane. Pass in a color, a + * position, a floating point value, and formatting info. Specify how many + * integer and how many decimal digits to show and whether to show a sign, as + * well as a character set. This routine returns the xOffset plus width of the + * string drawn. + * + */ +XPLM_API void XPLMDrawNumber( + float * inColorRGB, + int inXOffset, + int inYOffset, + double inValue, + int inDigits, + int inDecimals, + int inShowSign, + XPLMFontID inFontID); + +/* + * XPLMGetFontDimensions + * + * This routine returns the width and height of a character in a given font. + * It also tells you if the font only supports numeric digits. Pass NULL if + * you don't need a given field. Note that for a proportional font the width + * will be an arbitrary, hopefully average width. + * + */ +XPLM_API void XPLMGetFontDimensions( + XPLMFontID inFontID, + int * outCharWidth, /* Can be NULL */ + int * outCharHeight, /* Can be NULL */ + int * outDigitsOnly); /* Can be NULL */ + +#if defined(XPLM200) +/* + * XPLMMeasureString + * + * This routine returns the width in pixels of a string using a given font. + * The string is passed as a pointer plus length (and does not need to be null + * terminated); this is used to allow for measuring substrings. The return + * value is floating point; it is possible that future font drawing may allow + * for fractional pixels. + * + */ +XPLM_API float XPLMMeasureString( + XPLMFontID inFontID, + const char * inChar, + int inNumChars); +#endif /* XPLM200 */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/CHeaders/XPLM/XPLMInstance.h b/XPLPro_Plugin_Source/SDK/CHeaders/XPLM/XPLMInstance.h new file mode 100644 index 0000000..d2a8f2c --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/CHeaders/XPLM/XPLMInstance.h @@ -0,0 +1,136 @@ +#ifndef _XPLMInstance_h_ +#define _XPLMInstance_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPLMInstance + ***************************************************************************/ +/* + * This API provides instanced drawing of X-Plane objects (.obj files). In + * contrast to old drawing APIs, which required you to draw your own objects + * per-frame, the instancing API allows you to simply register an OBJ for + * drawing, then move or manipulate it later (as needed). + * + * This provides one tremendous benefit: it keeps all dataref operations for + * your object in one place. Because datarefs are main thread only, allowing + * dataref access anywhere is a serious performance bottleneck for the + * simulator---the whole simulator has to pause and wait for each dataref + * access. This performance penalty will only grow worse as X-Plane moves + * toward an ever more heavily multithreaded engine. + * + * The instancing API allows X-Plane to isolate all dataref manipulations for + * all plugin object drawing to one place, potentially providing huge + * performance gains. + * + * Here's how it works: + * + * When an instance is created, it provides a list of all datarefs you want to + * manipulate in for the OBJ in the future. This list of datarefs replaces the + * ad-hoc collections of dataref objects previously used by art assets. Then, + * per-frame, you can manipulate the instance by passing in a "block" of + * packed floats representing the current values of the datarefs for your + * instance. (Note that the ordering of this set of packed floats must exactly + * match the ordering of the datarefs when you created your instance.) + * + */ + +#include "XPLMDefs.h" +#include "XPLMScenery.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*************************************************************************** + * Instance Creation and Destruction + ***************************************************************************/ +/* + * Registers and unregisters instances. + * + */ + + +/* + * XPLMInstanceRef + * + * An opaque handle to an instance. + * + */ +typedef void * XPLMInstanceRef; + +/* + * XPLMCreateInstance + * + * XPLMCreateInstance creates a new instance, managed by your plug-in, and + * returns a handle to the instance. A few important requirements: + * + * * The object passed in must be fully loaded and returned from the XPLM + * before you can create your instance; you cannot pass a null obj ref, nor + * can you change the ref later. + * + * * If you use any custom datarefs in your object, they must be registered + * before the object is loaded. This is true even if their data will be + * provided via the instance dataref list. + * + * * The instance dataref array must be a valid ptr to an array of at least + * one item that is null terminated. That is, if you do not want any + * datarefs, you must passa ptr to an array with a null item. You cannot + * pass null for this. + * + */ +XPLM_API XPLMInstanceRef XPLMCreateInstance( + XPLMObjectRef obj, + const char ** datarefs); + +/* + * XPLMDestroyInstance + * + * XPLMDestroyInstance destroys and deallocates your instance; once called, + * you are still responsible for releasing the OBJ ref. + * + * Tip: you can release your OBJ ref after you call XPLMCreateInstance as long + * as you never use it again; the instance will maintain its own reference to + * the OBJ and the object OBJ be deallocated when the instance is destroyed. + * + */ +XPLM_API void XPLMDestroyInstance( + XPLMInstanceRef instance); + +/*************************************************************************** + * Instance Manipulation + ***************************************************************************/ + +/* + * XPLMInstanceSetPosition + * + * Updates both the position of the instance and all datarefs you registered + * for it. Call this from a flight loop callback or UI callback. + * + * __DO NOT__ call XPLMInstanceSetPosition from a drawing callback; the whole + * point of instancing is that you do not need any drawing callbacks. Setting + * instance data from a drawing callback may have undefined consequences, and + * the drawing callback hurts FPS unnecessarily. + * + * The memory pointed to by the data pointer must be large enough to hold one + * float for every data ref you have registered, and must contain valid + * floating point data. + * + * BUG: before X-Plane 11.50, if you have no dataref registered, you must + * still pass a valid pointer for data and not null. + * + */ +XPLM_API void XPLMInstanceSetPosition( + XPLMInstanceRef instance, + const XPLMDrawInfo_t * new_position, + const float * data); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/CHeaders/XPLM/XPLMMap.h b/XPLPro_Plugin_Source/SDK/CHeaders/XPLM/XPLMMap.h new file mode 100644 index 0000000..18c055a --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/CHeaders/XPLM/XPLMMap.h @@ -0,0 +1,631 @@ +#ifndef _XPLMMap_h_ +#define _XPLMMap_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPLMMap + ***************************************************************************/ +/* + * This API allows you to create new layers within X-Plane maps. Your layers + * can draw arbitrary OpenGL, but they conveniently also have access to + * X-Plane's built-in icon and label drawing functions. + * + * As of X-Plane 11, map drawing happens in three stages: + * + * 1. backgrounds and "fill," + * 2. icons, and + * 3. labels. + * + * Thus, all background drawing gets layered beneath all icons, which likewise + * get layered beneath all labels. Within each stage, the map obeys a + * consistent layer ordering, such that "fill" layers (layers that cover a + * large amount of map area, like the terrain and clouds) appear beneath + * "markings" layers (like airport icons). This ensures that layers with fine + * details don't get obscured by layers with larger details. + * + * The XPLM map API reflects both aspects of this draw layering: you can + * register a layer as providing either markings or fill, and X-Plane will + * draw your fill layers beneath your markings layers (regardless of + * registration order). Likewise, you are guaranteed that your layer's icons + * (added from within an icon callback) will go above your layer's OpenGL + * drawing, and your labels will go above your icons. + * + * The XPLM guarantees that all plugin-created fill layers go on top of all + * native X-Plane fill layers, and all plugin-created markings layers go on + * top of all X-Plane markings layers (with the exception of the aircraft + * icons). It also guarantees that the draw order of your own plugin's layers + * will be consistent. But, for layers created by different plugins, the only + * guarantee is that we will draw all of one plugin's layers of each type + * (fill, then markings), then all of the others'; we don't guarantee which + * plugin's fill and markings layers go on top of the other's. + * + * As of X-Plane 11, maps use true cartographic projections for their drawing, + * and different maps may use different projections. For that reason, all + * drawing calls include an opaque handle for the projection you should use to + * do the drawing. Any time you would draw at a particular latitude/longitude, + * you'll need to ask the projection to translate that position into "map + * coordinates." (Note that the projection is guaranteed not to change between + * calls to your prepare-cache hook, so if you cache your map coordinates + * ahead of time, there's no need to re-project them when you actually draw.) + * + * In addition to mapping normal latitude/longitude locations into map + * coordinates, the projection APIs also let you know the current heading for + * north. (Since X-Plane 11 maps can rotate to match the heading of the user's + * aircraft, it's not safe to assume that north is at zero degrees rotation.) + * + */ + +#include "XPLMDefs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(XPLM300) +/*************************************************************************** + * DRAWING CALLBACKS + ***************************************************************************/ +/* + * When you create a new map layer (using XPLMCreateMapLayer), you can provide + * any or all of these callbacks. They allow you to insert your own OpenGL + * drawing, text labels, and icons into the X-Plane map at the appropriate + * places, allowing your layer to behave as similarly to X-Plane's built-in + * layers as possible. + * + */ + + +/* + * XPLMMapLayerID + * + * This is an opaque handle for a plugin-created map layer. Pass it to the map + * drawing APIs from an appropriate callback to draw in the layer you created. + * + */ +typedef void * XPLMMapLayerID; + +/* + * XPLMMapProjectionID + * + * This is an opaque handle for a map projection. Pass it to the projection + * APIs to translate between map coordinates and latitude/longitudes. + * + */ +typedef void * XPLMMapProjectionID; + +/* + * XPLMMapStyle + * + * Indicates the visual style being drawn by the map. In X-Plane, the user can + * choose between a number of map types, and different map types may have use + * a different visual representation for the same elements (for instance, the + * visual style of the terrain layer changes drastically between the VFR and + * IFR layers), or certain layers may be disabled entirely in some map types + * (e.g., localizers are only visible in the IFR low-enroute style). + * + */ +enum { + xplm_MapStyle_VFR_Sectional = 0, + + xplm_MapStyle_IFR_LowEnroute = 1, + + xplm_MapStyle_IFR_HighEnroute = 2, + + +}; +typedef int XPLMMapStyle; + +/* + * XPLMMapDrawingCallback_f + * + * This is the OpenGL map drawing callback for plugin-created map layers. You + * can perform arbitrary OpenGL drawing from this callback, with one + * exception: changes to the Z-buffer are not permitted, and will result in + * map drawing errors. + * + * All drawing done from within this callback appears beneath all built-in + * X-Plane icons and labels, but above the built-in "fill" layers (layers + * providing major details, like terrain and water). Note, however, that the + * relative ordering between the drawing callbacks of different plugins is not + * guaranteed. + * + */ +typedef void (* XPLMMapDrawingCallback_f)( + XPLMMapLayerID inLayer, + const float * inMapBoundsLeftTopRightBottom, + float zoomRatio, + float mapUnitsPerUserInterfaceUnit, + XPLMMapStyle mapStyle, + XPLMMapProjectionID projection, + void * inRefcon); + +/* + * XPLMMapIconDrawingCallback_f + * + * This is the icon drawing callback that enables plugin-created map layers to + * draw icons using X-Plane's built-in icon drawing functionality. You can + * request an arbitrary number of PNG icons to be drawn via + * XPLMDrawMapIconFromSheet() from within this callback, but you may not + * perform any OpenGL drawing here. + * + * Icons enqueued by this function will appear above all OpenGL drawing + * (performed by your optional XPLMMapDrawingCallback_f), and above all + * built-in X-Plane map icons of the same layer type ("fill" or "markings," as + * determined by the XPLMMapLayerType in your XPLMCreateMapLayer_t). Note, + * however, that the relative ordering between the drawing callbacks of + * different plugins is not guaranteed. + * + */ +typedef void (* XPLMMapIconDrawingCallback_f)( + XPLMMapLayerID inLayer, + const float * inMapBoundsLeftTopRightBottom, + float zoomRatio, + float mapUnitsPerUserInterfaceUnit, + XPLMMapStyle mapStyle, + XPLMMapProjectionID projection, + void * inRefcon); + +/* + * XPLMMapLabelDrawingCallback_f + * + * This is the label drawing callback that enables plugin-created map layers + * to draw text labels using X-Plane's built-in labeling functionality. You + * can request an arbitrary number of text labels to be drawn via + * XPLMDrawMapLabel() from within this callback, but you may not perform any + * OpenGL drawing here. + * + * Labels enqueued by this function will appear above all OpenGL drawing + * (performed by your optional XPLMMapDrawingCallback_f), and above all + * built-in map icons and labels of the same layer type ("fill" or "markings," + * as determined by the XPLMMapLayerType in your XPLMCreateMapLayer_t). Note, + * however, that the relative ordering between the drawing callbacks of + * different plugins is not guaranteed. + * + */ +typedef void (* XPLMMapLabelDrawingCallback_f)( + XPLMMapLayerID inLayer, + const float * inMapBoundsLeftTopRightBottom, + float zoomRatio, + float mapUnitsPerUserInterfaceUnit, + XPLMMapStyle mapStyle, + XPLMMapProjectionID projection, + void * inRefcon); + +#endif /* XPLM300 */ +#if defined(XPLM300) +/*************************************************************************** + * LAYER MANAGEMENT CALLBACKS + ***************************************************************************/ +/* + * These are various "bookkeeping" callbacks that your map layer can receive + * (if you provide the callback in your XPLMCreateMapLayer_t). They allow you + * to manage the lifecycle of your layer, as well as cache any + * computationally-intensive preparation you might need for drawing. + * + */ + + +/* + * XPLMMapPrepareCacheCallback_f + * + * A callback used to allow you to cache whatever information your layer needs + * to draw in the current map area. + * + * This is called each time the map's total bounds change. This is typically + * triggered by new DSFs being loaded, such that X-Plane discards old, + * now-distant DSFs and pulls in new ones. At that point, the available bounds + * of the map also change to match the new DSF area. + * + * By caching just the information you need to draw in this area, your future + * draw calls can be made faster, since you'll be able to simply "splat" your + * precomputed information each frame. + * + * We guarantee that the map projection will not change between successive + * prepare cache calls, nor will any draw call give you bounds outside these + * total map bounds. So, if you cache the projected map coordinates of all the + * items you might want to draw in the total map area, you can be guaranteed + * that no draw call will be asked to do any new work. + * + */ +typedef void (* XPLMMapPrepareCacheCallback_f)( + XPLMMapLayerID inLayer, + const float * inTotalMapBoundsLeftTopRightBottom, + XPLMMapProjectionID projection, + void * inRefcon); + +/* + * XPLMMapWillBeDeletedCallback_f + * + * Called just before your map layer gets deleted. Because SDK-created map + * layers have the same lifetime as the X-Plane map that contains them, if the + * map gets unloaded from memory, your layer will too. + * + */ +typedef void (* XPLMMapWillBeDeletedCallback_f)( + XPLMMapLayerID inLayer, + void * inRefcon); + +#endif /* XPLM300 */ +#if defined(XPLM300) +/*************************************************************************** + * MAP LAYER CREATION AND DESTRUCTION + ***************************************************************************/ +/* + * Enables the creation of new map layers. Layers are created for a particular + * instance of the X-Plane map. For instance, if you want your layer to appear + * in both the normal map interface and the Instructor Operator Station (IOS), + * you would need two separate calls to XPLMCreateMapLayer(), with two + * different values for your XPLMCreateMapLayer_t::layer_name. + * + * Your layer's lifetime will be determined by the lifetime of the map it is + * created in. If the map is destroyed (on the X-Plane side), your layer will + * be too, and you'll receive a callback to your + * XPLMMapWillBeDeletedCallback_f. + * + */ + + +/* + * XPLMMapLayerType + * + * Indicates the type of map layer you are creating. Fill layers will always + * be drawn beneath markings layers. + * + */ +enum { + /* A layer that draws "fill" graphics, like weather patterns, terrain, etc. * + * Fill layers frequently cover a large portion of the visible map area. */ + xplm_MapLayer_Fill = 0, + + /* A layer that provides markings for particular map features, like NAVAIDs, * + * airports, etc. Even dense markings layers cover a small portion of the * + * total map area. */ + xplm_MapLayer_Markings = 1, + + +}; +typedef int XPLMMapLayerType; + +/* Globally unique identifier for X-Plane's Map window, used as the * + * mapToCreateLayerIn parameter in XPLMCreateMapLayer_t */ +#define XPLM_MAP_USER_INTERFACE "XPLM_MAP_USER_INTERFACE" + +/* Globally unique identifier for X-Plane's Instructor Operator Station * + * window, used as the mapToCreateLayerIn parameter in XPLMCreateMapLayer_t */ +#define XPLM_MAP_IOS "XPLM_MAP_IOS" + +/* + * XPLMCreateMapLayer_t + * + * This structure defines all of the parameters used to create a map layer + * using XPLMCreateMapLayer. The structure will be expanded in future SDK APIs + * to include more features. Always set the structSize member to the size of + * your struct in bytes! + * + * Each layer must be associated with exactly one map instance in X-Plane. + * That map, and that map alone, will call your callbacks. Likewise, when that + * map is deleted, your layer will be as well. + * + */ +typedef struct { + /* Used to inform XPLMCreateMapLayer() of the SDK version you compiled * + * against; should always be set to sizeof(XPLMCreateMapLayer_t) */ + int structSize; + /* Globally unique string identifying the map you want this layer to appear * + * in. As of XPLM300, this is limited to one of XPLM_MAP_USER_INTERFACE or * + * XPLM_MAP_IOS */ + const char * mapToCreateLayerIn; + /* The type of layer you are creating, used to determine draw order (all * + * plugin-created markings layers are drawn above all plugin-created fill * + * layers) */ + XPLMMapLayerType layerType; + /* Optional callback to inform you this layer is being deleted (due to its * + * owning map being destroyed) */ + XPLMMapWillBeDeletedCallback_f willBeDeletedCallback; + /* Optional callback you want to use to prepare your draw cache when the map * + * bounds change (set to NULL if you don't want this callback) */ + XPLMMapPrepareCacheCallback_f prepCacheCallback; + /* Optional callback you want to use for arbitrary OpenGL drawing, which goes * + * beneath all icons in the map's layering system (set to NULL if you don't * + * want this callback) */ + XPLMMapDrawingCallback_f drawCallback; + /* Optional callback you want to use for drawing icons, which go above all * + * built-in X-Plane icons (except the aircraft) in the map's layering system * + * (set to NULL if you don't want this callback) */ + XPLMMapIconDrawingCallback_f iconCallback; + /* Optional callback you want to use for drawing map labels, which go above * + * all built-in X-Plane icons and labels (except those of aircraft) in the * + * map's layering system (set to NULL if you don't want this callback) */ + XPLMMapLabelDrawingCallback_f labelCallback; + /* True if you want a checkbox to be created in the map UI to toggle this * + * layer on and off; false if the layer should simply always be enabled */ + int showUiToggle; + /* Short label to use for this layer in the user interface */ + const char * layerName; + /* A reference to arbitrary data that will be passed to your callbacks */ + void * refcon; +} XPLMCreateMapLayer_t; + +/* + * XPLMCreateMapLayer + * + * This routine creates a new map layer. You pass in an XPLMCreateMapLayer_t + * structure with all of the fields set in. You must set the structSize of + * the structure to the size of the actual structure you used. + * + * Returns NULL if the layer creation failed. This happens most frequently + * because the map you specified in your + * XPLMCreateMapLayer_t::mapToCreateLayerIn field doesn't exist (that is, if + * XPLMMapExists() returns 0 for the specified map). You can use + * XPLMRegisterMapCreationHook() to get a notification each time a new map is + * opened in X-Plane, at which time you can create layers in it. + * + */ +XPLM_API XPLMMapLayerID XPLMCreateMapLayer( + XPLMCreateMapLayer_t * inParams); + +/* + * XPLMDestroyMapLayer + * + * Destroys a map layer you created (calling your + * XPLMMapWillBeDeletedCallback_f if applicable). Returns true if a deletion + * took place. + * + */ +XPLM_API int XPLMDestroyMapLayer( + XPLMMapLayerID inLayer); + +/* + * XPLMMapCreatedCallback_f + * + * A callback to notify your plugin that a new map has been created in + * X-Plane. This is the best time to add a custom map layer using + * XPLMCreateMapLayer(). + * + * No OpenGL drawing is permitted within this callback. + * + */ +typedef void (* XPLMMapCreatedCallback_f)( + const char * mapIdentifier, + void * refcon); + +/* + * XPLMRegisterMapCreationHook + * + * Registers your callback to receive a notification each time a new map is + * constructed in X-Plane. This callback is the best time to add your custom + * map layer using XPLMCreateMapLayer(). + * + * Note that you will not be notified about any maps that already exist---you + * can use XPLMMapExists() to check for maps that were created previously. + * + */ +XPLM_API void XPLMRegisterMapCreationHook( + XPLMMapCreatedCallback_f callback, + void * refcon); + +/* + * XPLMMapExists + * + * Returns 1 if the map with the specified identifier already exists in + * X-Plane. In that case, you can safely call XPLMCreateMapLayer() specifying + * that your layer should be added to that map. + * + */ +XPLM_API int XPLMMapExists( + const char * mapIdentifier); + +#endif /* XPLM300 */ +#if defined(XPLM300) +/*************************************************************************** + * MAP DRAWING + ***************************************************************************/ +/* + * These APIs are only valid from within a map drawing callback (one of + * XPLMIconDrawingCallback_t or XPLMMapLabelDrawingCallback_f). Your drawing + * callbacks are registered when you create a new map layer as part of your + * XPLMCreateMapLayer_t. The functions here hook into X-Plane's built-in map + * drawing functionality for icons and labels, so that you get a consistent + * style with the rest of the X-Plane map. + * + * Note that the X-Plane 11 map introduces a strict ordering: layers of type + * xplm_MapLayer_Fill get drawn beneath all xplm_MapLayer_Markings layers. + * Likewise, all OpenGL drawing (performed in your layer's + * XPLMMapDrawingCallback_f) will appear beneath any icons and labels you + * draw. + * + */ + + +/* + * XPLMMapOrientation + * + * Indicates whether a map element should be match its rotation to the map + * itself, or to the user interface. For instance, the map itself may be + * rotated such that "up" matches the user's aircraft, but you may want to + * draw a text label such that it is always rotated zero degrees relative to + * the user's perspective. In that case, you would have it draw with UI + * orientation. + * + */ +enum { + /* Orient such that a 0 degree rotation matches the map's north */ + xplm_MapOrientation_Map = 0, + + /* Orient such that a 0 degree rotation is "up" relative to the user interface*/ + xplm_MapOrientation_UI = 1, + + +}; +typedef int XPLMMapOrientation; + +/* + * XPLMDrawMapIconFromSheet + * + * Enables plugin-created map layers to draw PNG icons using X-Plane's + * built-in icon drawing functionality. Only valid from within an + * XPLMIconDrawingCallback_t (but you can request an arbitrary number of icons + * to be drawn from within your callback). + * + * X-Plane will automatically manage the memory for your texture so that it + * only has to be loaded from disk once as long as you continue drawing it + * per-frame. (When you stop drawing it, the memory may purged in a "garbage + * collection" pass, require a load from disk in the future.) + * + * Instead of having X-Plane draw a full PNG, this method allows you to use UV + * coordinates to request a portion of the image to be drawn. This allows you + * to use a single texture load (of an icon sheet, for example) to draw many + * icons. Doing so is much more efficient than drawing a dozen different small + * PNGs. + * + * The UV coordinates used here treat the texture you load as being comprised + * of a number of identically sized "cells." You specify the width and height + * in cells (ds and dt, respectively), as well as the coordinates within the + * cell grid for the sub-image you'd like to draw. + * + * Note that you can use different ds and dt values in subsequent calls with + * the same texture sheet. This enables you to use icons of different sizes in + * the same sheet if you arrange them properly in the PNG. + * + * This function is only valid from within an XPLMIconDrawingCallback_t (but + * you can request an arbitrary number of icons to be drawn from within your + * callback). + * + */ +XPLM_API void XPLMDrawMapIconFromSheet( + XPLMMapLayerID layer, + const char * inPngPath, + int s, + int t, + int ds, + int dt, + float mapX, + float mapY, + XPLMMapOrientation orientation, + float rotationDegrees, + float mapWidth); + +/* + * XPLMDrawMapLabel + * + * Enables plugin-created map layers to draw text labels using X-Plane's + * built-in labeling functionality. Only valid from within an + * XPLMMapLabelDrawingCallback_f (but you can request an arbitrary number of + * text labels to be drawn from within your callback). + * + */ +XPLM_API void XPLMDrawMapLabel( + XPLMMapLayerID layer, + const char * inText, + float mapX, + float mapY, + XPLMMapOrientation orientation, + float rotationDegrees); + +#endif /* XPLM300 */ +#if defined(XPLM300) +/*************************************************************************** + * MAP PROJECTIONS + ***************************************************************************/ +/* + * As of X-Plane 11, the map draws using true cartographic projections, and + * different maps may use different projections. Thus, to draw at a particular + * latitude and longitude, you must first transform your real-world + * coordinates into map coordinates. + * + * The map projection is also responsible for giving you the current scale of + * the map. That is, the projection can tell you how many map units correspond + * to 1 meter at a given point. + * + * Finally, the map projection can give you the current rotation of the map. + * Since X-Plane 11 maps can rotate to match the heading of the aircraft, the + * map's rotation can potentially change every frame. + * + */ + + +/* + * XPLMMapProject + * + * Projects a latitude/longitude into map coordinates. This is the inverse of + * XPLMMapUnproject(). + * + * Only valid from within a map layer callback (one of + * XPLMMapPrepareCacheCallback_f, XPLMMapDrawingCallback_f, + * XPLMMapIconDrawingCallback_f, or XPLMMapLabelDrawingCallback_f.) + * + */ +XPLM_API void XPLMMapProject( + XPLMMapProjectionID projection, + double latitude, + double longitude, + float * outX, + float * outY); + +/* + * XPLMMapUnproject + * + * Transforms map coordinates back into a latitude and longitude. This is the + * inverse of XPLMMapProject(). + * + * Only valid from within a map layer callback (one of + * XPLMMapPrepareCacheCallback_f, XPLMMapDrawingCallback_f, + * XPLMMapIconDrawingCallback_f, or XPLMMapLabelDrawingCallback_f.) + * + */ +XPLM_API void XPLMMapUnproject( + XPLMMapProjectionID projection, + float mapX, + float mapY, + double * outLatitude, + double * outLongitude); + +/* + * XPLMMapScaleMeter + * + * Returns the number of map units that correspond to a distance of one meter + * at a given set of map coordinates. + * + * Only valid from within a map layer callback (one of + * XPLMMapPrepareCacheCallback_f, XPLMMapDrawingCallback_f, + * XPLMMapIconDrawingCallback_f, or XPLMMapLabelDrawingCallback_f.) + * + */ +XPLM_API float XPLMMapScaleMeter( + XPLMMapProjectionID projection, + float mapX, + float mapY); + +/* + * XPLMMapGetNorthHeading + * + * Returns the heading (in degrees clockwise from "up") that corresponds to + * north at a given point on the map. In other words, if your runway has a + * true heading of 360, you would use "north" as the Cartesian angle at which + * to draw the runway on the map. (You would add the result of + * XPLMMapGetNorthHeading() to your true heading to get the map angle.) + * + * This is necessary becuase X-Plane's map can be rotated to match your + * aircraft's orientation; north is not always "up." + * + * Only valid from within a map layer callback (one of + * XPLMMapPrepareCacheCallback_f, XPLMMapDrawingCallback_f, + * XPLMMapIconDrawingCallback_f, or XPLMMapLabelDrawingCallback_f.) + * + */ +XPLM_API float XPLMMapGetNorthHeading( + XPLMMapProjectionID projection, + float mapX, + float mapY); + +#endif /* XPLM300 */ +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/CHeaders/XPLM/XPLMMenus.h b/XPLPro_Plugin_Source/SDK/CHeaders/XPLM/XPLMMenus.h new file mode 100644 index 0000000..f5802ab --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/CHeaders/XPLM/XPLMMenus.h @@ -0,0 +1,290 @@ +#ifndef _XPLMMenus_h_ +#define _XPLMMenus_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPLMMenus + ***************************************************************************/ +/* + * Plug-ins can create menus in the menu bar of X-Plane. This is done by + * creating a menu and then creating items. Menus are referred to by an + * opaque ID. Items are referred to by (zero-based) index number. + * + * Menus are "sandboxed" between plugins---no plugin can access the menus of + * any other plugin. Furthermore, all menu indices are relative to your + * plugin's menus only; if your plugin creates two sub-menus in the Plugins + * menu at different times, it doesn't matter how many other plugins also + * create sub-menus of Plugins in the intervening time: your sub-menus will be + * given menu indices 0 and 1. (The SDK does some work in the back-end to + * filter out menus that are irrelevant to your plugin in order to deliver + * this consistency for each plugin.) + * + * When you create a menu item, you specify how we should handle clicks on + * that menu item. You can either have the XPLM trigger a callback (the + * XPLMMenuHandler_f associated with the menu that contains the item), or you + * can simply have a command be triggered (with no associated call to your + * menu handler). The advantage of the latter method is that X-Plane will + * display any keyboard shortcuts associated with the command. (In contrast, + * there are no keyboard shortcuts associated with menu handler callbacks with + * specific parameters.) + * + * Menu text in X-Plane is UTF8; X-Plane's character set covers latin, greek + * and cyrillic characters, Katakana, as well as some Japanese symbols. Some + * APIs have a inDeprecatedAndIgnored parameter that used to select a + * character set; since X-Plane 9 all localization is done via UTF-8 only. + * + */ + +#include "XPLMDefs.h" +#include "XPLMUtilities.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*************************************************************************** + * XPLM MENUS + ***************************************************************************/ + +/* + * XPLMMenuCheck + * + * These enumerations define the various 'check' states for an X-Plane menu. + * 'checking' in X-Plane actually appears as a light which may or may not be + * lit. So there are three possible states. + * + */ +enum { + /* there is no symbol to the left of the menu item. */ + xplm_Menu_NoCheck = 0, + + /* the menu has a mark next to it that is unmarked (not lit). */ + xplm_Menu_Unchecked = 1, + + /* the menu has a mark next to it that is checked (lit). */ + xplm_Menu_Checked = 2, + + +}; +typedef int XPLMMenuCheck; + +/* + * XPLMMenuID + * + * This is a unique ID for each menu you create. + * + */ +typedef void * XPLMMenuID; + +/* + * XPLMMenuHandler_f + * + * A menu handler function takes two reference pointers, one for the menu + * (specified when the menu was created) and one for the item (specified when + * the item was created). + * + */ +typedef void (* XPLMMenuHandler_f)( + void * inMenuRef, + void * inItemRef); + +/* + * XPLMFindPluginsMenu + * + * This function returns the ID of the plug-ins menu, which is created for you + * at startup. + * + */ +XPLM_API XPLMMenuID XPLMFindPluginsMenu(void); + +#if defined(XPLM300) +/* + * XPLMFindAircraftMenu + * + * This function returns the ID of the menu for the currently-loaded aircraft, + * used for showing aircraft-specific commands. + * + * The aircraft menu is created by X-Plane at startup, but it remains hidden + * until it is populated via XPLMAppendMenuItem() or + * XPLMAppendMenuItemWithCommand(). + * + * Only plugins loaded with the user's current aircraft are allowed to access + * the aircraft menu. For all other plugins, this will return NULL, and any + * attempts to add menu items to it will fail. + * + */ +XPLM_API XPLMMenuID XPLMFindAircraftMenu(void); +#endif /* XPLM300 */ + +/* + * XPLMCreateMenu + * + * This function creates a new menu and returns its ID. It returns NULL if + * the menu cannot be created. Pass in a parent menu ID and an item index to + * create a submenu, or NULL for the parent menu to put the menu in the menu + * bar. The menu's name is only used if the menu is in the menubar. You also + * pass a handler function and a menu reference value. Pass NULL for the + * handler if you do not need callbacks from the menu (for example, if it only + * contains submenus). + * + * Important: you must pass a valid, non-empty menu title even if the menu is + * a submenu where the title is not visible. + * + */ +XPLM_API XPLMMenuID XPLMCreateMenu( + const char * inName, + XPLMMenuID inParentMenu, + int inParentItem, + XPLMMenuHandler_f inHandler, + void * inMenuRef); + +/* + * XPLMDestroyMenu + * + * This function destroys a menu that you have created. Use this to remove a + * submenu if necessary. (Normally this function will not be necessary.) + * + */ +XPLM_API void XPLMDestroyMenu( + XPLMMenuID inMenuID); + +/* + * XPLMClearAllMenuItems + * + * This function removes all menu items from a menu, allowing you to rebuild + * it. Use this function if you need to change the number of items on a menu. + * + */ +XPLM_API void XPLMClearAllMenuItems( + XPLMMenuID inMenuID); + +/* + * XPLMAppendMenuItem + * + * This routine appends a new menu item to the bottom of a menu and returns + * its index. Pass in the menu to add the item to, the items name, and a void + * * ref for this item. + * + * Returns a negative index if the append failed (due to an invalid parent + * menu argument). + * + * Note that all menu indices returned are relative to your plugin's menus + * only; if your plugin creates two sub-menus in the Plugins menu at different + * times, it doesn't matter how many other plugins also create sub-menus of + * Plugins in the intervening time: your sub-menus will be given menu indices + * 0 and 1. (The SDK does some work in the back-end to filter out menus that + * are irrelevant to your plugin in order to deliver this consistency for each + * plugin.) + * + */ +XPLM_API int XPLMAppendMenuItem( + XPLMMenuID inMenu, + const char * inItemName, + void * inItemRef, + int inDeprecatedAndIgnored); + +#if defined(XPLM300) +/* + * XPLMAppendMenuItemWithCommand + * + * Like XPLMAppendMenuItem(), but instead of the new menu item triggering the + * XPLMMenuHandler_f of the containiner menu, it will simply execute the + * command you pass in. Using a command for your menu item allows the user to + * bind a keyboard shortcut to the command and see that shortcut represented + * in the menu. + * + * Returns a negative index if the append failed (due to an invalid parent + * menu argument). + * + * Like XPLMAppendMenuItem(), all menu indices are relative to your plugin's + * menus only. + * + */ +XPLM_API int XPLMAppendMenuItemWithCommand( + XPLMMenuID inMenu, + const char * inItemName, + XPLMCommandRef inCommandToExecute); +#endif /* XPLM300 */ + +/* + * XPLMAppendMenuSeparator + * + * This routine adds a separator to the end of a menu. + * + * Returns a negative index if the append failed (due to an invalid parent + * menu argument). + * + */ +XPLM_API void XPLMAppendMenuSeparator( + XPLMMenuID inMenu); + +/* + * XPLMSetMenuItemName + * + * This routine changes the name of an existing menu item. Pass in the menu + * ID and the index of the menu item. + * + */ +XPLM_API void XPLMSetMenuItemName( + XPLMMenuID inMenu, + int inIndex, + const char * inItemName, + int inDeprecatedAndIgnored); + +/* + * XPLMCheckMenuItem + * + * Set whether a menu item is checked. Pass in the menu ID and item index. + * + */ +XPLM_API void XPLMCheckMenuItem( + XPLMMenuID inMenu, + int index, + XPLMMenuCheck inCheck); + +/* + * XPLMCheckMenuItemState + * + * This routine returns whether a menu item is checked or not. A menu item's + * check mark may be on or off, or a menu may not have an icon at all. + * + */ +XPLM_API void XPLMCheckMenuItemState( + XPLMMenuID inMenu, + int index, + XPLMMenuCheck * outCheck); + +/* + * XPLMEnableMenuItem + * + * Sets whether this menu item is enabled. Items start out enabled. + * + */ +XPLM_API void XPLMEnableMenuItem( + XPLMMenuID inMenu, + int index, + int enabled); + +#if defined(XPLM210) +/* + * XPLMRemoveMenuItem + * + * Removes one item from a menu. Note that all menu items below are moved up + * one; your plugin must track the change in index numbers. + * + */ +XPLM_API void XPLMRemoveMenuItem( + XPLMMenuID inMenu, + int inIndex); +#endif /* XPLM210 */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/CHeaders/XPLM/XPLMNavigation.h b/XPLPro_Plugin_Source/SDK/CHeaders/XPLM/XPLMNavigation.h new file mode 100644 index 0000000..716caf0 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/CHeaders/XPLM/XPLMNavigation.h @@ -0,0 +1,362 @@ +#ifndef _XPLMNavigation_h_ +#define _XPLMNavigation_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPLMNavigation + ***************************************************************************/ +/* + * The XPLM Navigation APIs give you some access to the navigation databases + * inside X-Plane. X-Plane stores all navigation information in RAM, so by + * using these APIs you can gain access to most information without having to + * go to disk or parse the files yourself. + * + * You can also use this API to program the FMS. You must use the navigation + * APIs to find the nav-aids you want to program into the FMS, since the FMS + * is powered internally by X-Plane's navigation database. + * + */ + +#include "XPLMDefs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*************************************************************************** + * NAVIGATION DATABASE ACCESS + ***************************************************************************/ + +/* + * XPLMNavType + * + * These enumerations define the different types of navaids. They are each + * defined with a separate bit so that they may be bit-wise added together to + * form sets of nav-aid types. + * + * NOTE: xplm_Nav_LatLon is a specific lat-lon coordinate entered into the + * FMS. It will not exist in the database, and cannot be programmed into the + * FMS. Querying the FMS for navaids will return it. Use + * XPLMSetFMSEntryLatLon to set a lat/lon waypoint. + * + */ +enum { + xplm_Nav_Unknown = 0, + + xplm_Nav_Airport = 1, + + xplm_Nav_NDB = 2, + + xplm_Nav_VOR = 4, + + xplm_Nav_ILS = 8, + + xplm_Nav_Localizer = 16, + + xplm_Nav_GlideSlope = 32, + + xplm_Nav_OuterMarker = 64, + + xplm_Nav_MiddleMarker = 128, + + xplm_Nav_InnerMarker = 256, + + xplm_Nav_Fix = 512, + + xplm_Nav_DME = 1024, + + xplm_Nav_LatLon = 2048, + + +}; +typedef int XPLMNavType; + +/* + * XPLMNavRef + * + * XPLMNavRef is an iterator into the navigation database. The navigation + * database is essentially an array, but it is not necessarily densely + * populated. The only assumption you can safely make is that like-typed + * nav-aids are grouped together. + * + * Use XPLMNavRef to refer to a nav-aid. + * + * XPLM_NAV_NOT_FOUND is returned by functions that return an XPLMNavRef when + * the iterator must be invalid. + * + */ +typedef int XPLMNavRef; + +#define XPLM_NAV_NOT_FOUND -1 + +/* + * XPLMGetFirstNavAid + * + * This returns the very first navaid in the database. Use this to traverse + * the entire database. Returns XPLM_NAV_NOT_FOUND if the nav database is + * empty. + * + */ +XPLM_API XPLMNavRef XPLMGetFirstNavAid(void); + +/* + * XPLMGetNextNavAid + * + * Given a valid nav aid ref, this routine returns the next navaid. It + * returns XPLM_NAV_NOT_FOUND if the nav aid passed in was invalid or if the + * navaid passed in was the last one in the database. Use this routine to + * iterate across all like-typed navaids or the entire database. + * + */ +XPLM_API XPLMNavRef XPLMGetNextNavAid( + XPLMNavRef inNavAidRef); + +/* + * XPLMFindFirstNavAidOfType + * + * This routine returns the ref of the first navaid of the given type in the + * database or XPLM_NAV_NOT_FOUND if there are no navaids of that type in the + * database. You must pass exactly one nav aid type to this routine. + * + */ +XPLM_API XPLMNavRef XPLMFindFirstNavAidOfType( + XPLMNavType inType); + +/* + * XPLMFindLastNavAidOfType + * + * This routine returns the ref of the last navaid of the given type in the + * database or XPLM_NAV_NOT_FOUND if there are no navaids of that type in the + * database. You must pass exactly one nav aid type to this routine. + * + */ +XPLM_API XPLMNavRef XPLMFindLastNavAidOfType( + XPLMNavType inType); + +/* + * XPLMFindNavAid + * + * This routine provides a number of searching capabilities for the nav + * database. XPLMFindNavAid will search through every nav aid whose type is + * within inType (multiple types may be added together) and return any + * nav-aids found based on the following rules: + * + * * If inLat and inLon are not NULL, the navaid nearest to that lat/lon will + * be returned, otherwise the last navaid found will be returned. + * + * * If inFrequency is not NULL, then any navaids considered must match this + * frequency. Note that this will screen out radio beacons that do not have + * frequency data published (like inner markers) but not fixes and airports. + * + * * If inNameFragment is not NULL, only navaids that contain the fragment in + * their name will be returned. + * + * * If inIDFragment is not NULL, only navaids that contain the fragment in + * their IDs will be returned. + * + * This routine provides a simple way to do a number of useful searches: + * * Find the nearest navaid on this frequency. + * * Find the nearest airport. + * * Find the VOR whose ID is "KBOS". + * * Find the nearest airport whose name contains "Chicago". + * + */ +XPLM_API XPLMNavRef XPLMFindNavAid( + const char * inNameFragment, /* Can be NULL */ + const char * inIDFragment, /* Can be NULL */ + float * inLat, /* Can be NULL */ + float * inLon, /* Can be NULL */ + int * inFrequency, /* Can be NULL */ + XPLMNavType inType); + +/* + * XPLMGetNavAidInfo + * + * This routine returns information about a navaid. Any non-null field is + * filled out with information if it is available. + * + * Frequencies are in the nav.dat convention as described in the X-Plane nav + * database FAQ: NDB frequencies are exact, all others are multiplied by 100. + * + * The buffer for IDs should be at least 6 chars and the buffer for names + * should be at least 41 chars, but since these values are likely to go up, I + * recommend passing at least 32 chars for IDs and 256 chars for names when + * possible. + * + * The outReg parameter tells if the navaid is within the local "region" of + * loaded DSFs. (This information may not be particularly useful to plugins.) + * The parameter is a single byte value 1 for true or 0 for false, not a C + * string. + * + */ +XPLM_API void XPLMGetNavAidInfo( + XPLMNavRef inRef, + XPLMNavType * outType, /* Can be NULL */ + float * outLatitude, /* Can be NULL */ + float * outLongitude, /* Can be NULL */ + float * outHeight, /* Can be NULL */ + int * outFrequency, /* Can be NULL */ + float * outHeading, /* Can be NULL */ + char * outID, /* Can be NULL */ + char * outName, /* Can be NULL */ + char * outReg); /* Can be NULL */ + +/*************************************************************************** + * FLIGHT MANAGEMENT COMPUTER + ***************************************************************************/ +/* + * Note: the FMS works based on an array of entries. Indices into the array + * are zero-based. Each entry is a nav-aid plus an altitude. The FMS tracks + * the currently displayed entry and the entry that it is flying to. + * + * The FMS must be programmed with contiguous entries, so clearing an entry at + * the end shortens the effective flight plan. There is a max of 100 + * waypoints in the flight plan. + * + */ + + +/* + * XPLMCountFMSEntries + * + * This routine returns the number of entries in the FMS. + * + */ +XPLM_API int XPLMCountFMSEntries(void); + +/* + * XPLMGetDisplayedFMSEntry + * + * This routine returns the index of the entry the pilot is viewing. + * + */ +XPLM_API int XPLMGetDisplayedFMSEntry(void); + +/* + * XPLMGetDestinationFMSEntry + * + * This routine returns the index of the entry the FMS is flying to. + * + */ +XPLM_API int XPLMGetDestinationFMSEntry(void); + +/* + * XPLMSetDisplayedFMSEntry + * + * This routine changes which entry the FMS is showing to the index specified. + * + */ +XPLM_API void XPLMSetDisplayedFMSEntry( + int inIndex); + +/* + * XPLMSetDestinationFMSEntry + * + * This routine changes which entry the FMS is flying the aircraft toward. + * + */ +XPLM_API void XPLMSetDestinationFMSEntry( + int inIndex); + +/* + * XPLMGetFMSEntryInfo + * + * This routine returns information about a given FMS entry. If the entry is + * an airport or navaid, a reference to a nav entry can be returned allowing + * you to find additional information (such as a frequency, ILS heading, name, + * etc.). Note that this reference can be XPLM_NAV_NOT_FOUND until the + * information has been looked up asynchronously, so after flightplan changes, + * it might take up to a second for this field to become populated. The other + * information is available immediately. For a lat/lon entry, the lat/lon is + * returned by this routine but the navaid cannot be looked up (and the + * reference will be XPLM_NAV_NOT_FOUND). FMS name entry buffers should be at + * least 256 chars in length. + * + * WARNING: Due to a bug in X-Plane prior to 11.31, the navaid reference will + * not be set to XPLM_NAV_NOT_FOUND while no data is available, and instead + * just remain the value of the variable that you passed the pointer to. + * Therefore, always initialize the variable to XPLM_NAV_NOT_FOUND before + * passing the pointer to this function. + * + */ +XPLM_API void XPLMGetFMSEntryInfo( + int inIndex, + XPLMNavType * outType, /* Can be NULL */ + char * outID, /* Can be NULL */ + XPLMNavRef * outRef, /* Can be NULL */ + int * outAltitude, /* Can be NULL */ + float * outLat, /* Can be NULL */ + float * outLon); /* Can be NULL */ + +/* + * XPLMSetFMSEntryInfo + * + * This routine changes an entry in the FMS to have the destination navaid + * passed in and the altitude specified. Use this only for airports, fixes, + * and radio-beacon navaids. Currently of radio beacons, the FMS can only + * support VORs and NDBs. Use the routines below to clear or fly to a lat/lon. + * + */ +XPLM_API void XPLMSetFMSEntryInfo( + int inIndex, + XPLMNavRef inRef, + int inAltitude); + +/* + * XPLMSetFMSEntryLatLon + * + * This routine changes the entry in the FMS to a lat/lon entry with the given + * coordinates. + * + */ +XPLM_API void XPLMSetFMSEntryLatLon( + int inIndex, + float inLat, + float inLon, + int inAltitude); + +/* + * XPLMClearFMSEntry + * + * This routine clears the given entry, potentially shortening the flight + * plan. + * + */ +XPLM_API void XPLMClearFMSEntry( + int inIndex); + +/*************************************************************************** + * GPS RECEIVER + ***************************************************************************/ +/* + * These APIs let you read data from the GPS unit. + * + */ + +/* + * XPLMGetGPSDestinationType + * + * This routine returns the type of the currently selected GPS destination, + * one of fix, airport, VOR or NDB. + * + */ +XPLM_API XPLMNavType XPLMGetGPSDestinationType(void); + +/* + * XPLMGetGPSDestination + * + * This routine returns the current GPS destination. + * + */ +XPLM_API XPLMNavRef XPLMGetGPSDestination(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/CHeaders/XPLM/XPLMPlanes.h b/XPLPro_Plugin_Source/SDK/CHeaders/XPLM/XPLMPlanes.h new file mode 100644 index 0000000..486302d --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/CHeaders/XPLM/XPLMPlanes.h @@ -0,0 +1,287 @@ +#ifndef _XPLMPlanes_h_ +#define _XPLMPlanes_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPLMPlanes + ***************************************************************************/ +/* + * The XPLMPlanes APIs allow you to control the various aircraft in X-Plane, + * both the user's and the sim's. + * + * *Note*: unlike almost all other APIs in the SDK, aircraft paths are _full_ + * file system paths for historical reasons. You'll need to prefix all + * relative paths with the X-Plane path as accessed via XPLMGetSystemPath. + * + */ + +#include "XPLMDefs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*************************************************************************** + * USER AIRCRAFT ACCESS + ***************************************************************************/ + +/* + * XPLMSetUsersAircraft + * + * This routine changes the user's aircraft. Note that this will reinitialize + * the user to be on the nearest airport's first runway. Pass in a full path + * (hard drive and everything including the .acf extension) to the .acf file. + * + */ +XPLM_API void XPLMSetUsersAircraft( + const char * inAircraftPath); +/* + * XPLMPlaceUserAtAirport + * + * This routine places the user at a given airport. Specify the airport by + * its X-Plane airport ID (e.g. 'KBOS'). + * + */ +XPLM_API void XPLMPlaceUserAtAirport( + const char * inAirportCode); +#if defined(XPLM300) +/* + * XPLMPlaceUserAtLocation + * + * Places the user at a specific location after performing any necessary + * scenery loads. + * + * As with in-air starts initiated from the X-Plane user interface, the + * aircraft will always start with its engines running, regardless of the + * user's preferences (i.e., regardless of what the dataref + * `sim/operation/prefs/startup_running` says). + * + */ +XPLM_API void XPLMPlaceUserAtLocation( + double latitudeDegrees, + double longitudeDegrees, + float elevationMetersMSL, + float headingDegreesTrue, + float speedMetersPerSecond); +#endif /* XPLM300 */ +/*************************************************************************** + * GLOBAL AIRCRAFT ACCESS + ***************************************************************************/ + +/* The user's aircraft is always index 0. */ +#define XPLM_USER_AIRCRAFT 0 +#if defined(XPLM_DEPRECATED) +/* + * XPLMPlaneDrawState_t + * + * This structure contains additional plane parameter info to be passed to + * draw plane. Make sure to fill in the size of the structure field with + * sizeof(XPLMDrawPlaneState_t) so that the XPLM can tell how many fields you + * knew about when compiling your plugin (since more fields may be added + * later). + * + * Most of these fields are ratios from 0 to 1 for control input. X-Plane + * calculates what the actual controls look like based on the .acf file for + * that airplane. Note for the yoke inputs, this is what the pilot of the + * plane has commanded (post artificial stability system if there were one) + * and affects aelerons, rudder, etc. It is not necessarily related to the + * actual position of the plane! + * + */ +typedef struct { + /* The size of the draw state struct. */ + int structSize; + /* A ratio from [0..1] describing how far the landing gear is extended. */ + float gearPosition; + /* Ratio of flap deployment, 0 = up, 1 = full deploy. */ + float flapRatio; + /* Ratio of spoiler deployment, 0 = none, 1 = full deploy. */ + float spoilerRatio; + /* Ratio of speed brake deployment, 0 = none, 1 = full deploy. */ + float speedBrakeRatio; + /* Ratio of slat deployment, 0 = none, 1 = full deploy. */ + float slatRatio; + /* Wing sweep ratio, 0 = forward, 1 = swept. */ + float wingSweep; + /* Thrust power, 0 = none, 1 = full fwd, -1 = full reverse. */ + float thrust; + /* Total pitch input for this plane. */ + float yokePitch; + /* Total Heading input for this plane. */ + float yokeHeading; + /* Total Roll input for this plane. */ + float yokeRoll; +} XPLMPlaneDrawState_t; +#endif /* XPLM_DEPRECATED */ +/* + * XPLMCountAircraft + * + * This function returns the number of aircraft X-Plane is capable of having, + * as well as the number of aircraft that are currently active. These numbers + * count the user's aircraft. It can also return the plugin that is currently + * controlling aircraft. In X-Plane 7, this routine reflects the number of + * aircraft the user has enabled in the rendering options window. + * + */ +XPLM_API void XPLMCountAircraft( + int * outTotalAircraft, + int * outActiveAircraft, + XPLMPluginID * outController); +/* + * XPLMGetNthAircraftModel + * + * This function returns the aircraft model for the Nth aircraft. Indices are + * zero based, with zero being the user's aircraft. The file name should be + * at least 256 chars in length; the path should be at least 512 chars in + * length. + * + */ +XPLM_API void XPLMGetNthAircraftModel( + int inIndex, + char * outFileName, + char * outPath); +/*************************************************************************** + * EXCLUSIVE AIRCRAFT ACCESS + ***************************************************************************/ +/* + * The following routines require exclusive access to the airplane APIs. Only + * one plugin may have this access at a time. + * + */ + + +/* + * XPLMPlanesAvailable_f + * + * Your airplanes available callback is called when another plugin gives up + * access to the multiplayer planes. Use this to wait for access to + * multiplayer. + * + */ +typedef void (* XPLMPlanesAvailable_f)( + void * inRefcon); + +/* + * XPLMAcquirePlanes + * + * XPLMAcquirePlanes grants your plugin exclusive access to the aircraft. It + * returns 1 if you gain access, 0 if you do not. + * + * inAircraft - pass in an array of pointers to strings specifying the planes + * you want loaded. For any plane index you do not want loaded, pass a + * 0-length string. Other strings should be full paths with the .acf + * extension. NULL terminates this array, or pass NULL if there are no planes + * you want loaded. + * + * If you pass in a callback and do not receive access to the planes your + * callback will be called when the airplanes are available. If you do receive + * airplane access, your callback will not be called. + * + */ +XPLM_API int XPLMAcquirePlanes( + char ** inAircraft, /* Can be NULL */ + XPLMPlanesAvailable_f inCallback, + void * inRefcon); + +/* + * XPLMReleasePlanes + * + * Call this function to release access to the planes. Note that if you are + * disabled, access to planes is released for you and you must reacquire it. + * + */ +XPLM_API void XPLMReleasePlanes(void); + +/* + * XPLMSetActiveAircraftCount + * + * This routine sets the number of active planes. If you pass in a number + * higher than the total number of planes availables, only the total number of + * planes available is actually used. + * + */ +XPLM_API void XPLMSetActiveAircraftCount( + int inCount); + +/* + * XPLMSetAircraftModel + * + * This routine loads an aircraft model. It may only be called if you have + * exclusive access to the airplane APIs. Pass in the path of the model with + * the .acf extension. The index is zero based, but you may not pass in 0 + * (use XPLMSetUsersAircraft to load the user's aircracft). + * + */ +XPLM_API void XPLMSetAircraftModel( + int inIndex, + const char * inAircraftPath); + +/* + * XPLMDisableAIForPlane + * + * This routine turns off X-Plane's AI for a given plane. The plane will + * continue to draw and be a real plane in X-Plane, but will not move itself. + * + */ +XPLM_API void XPLMDisableAIForPlane( + int inPlaneIndex); + +#if defined(XPLM_DEPRECATED) +/* + * XPLMDrawAircraft + * + * WARNING: Aircraft drawing via this API is deprecated and will not work in + * future versions of X-Plane. Use XPLMInstance for 3-d drawing of custom + * aircraft models. + * + * This routine draws an aircraft. It can only be called from a 3-d drawing + * callback. Pass in the position of the plane in OpenGL local coordinates + * and the orientation of the plane. A 1 for full drawing indicates that the + * whole plane must be drawn; a 0 indicates you only need the nav lights + * drawn. (This saves rendering time when planes are far away.) + * + */ +XPLM_API void XPLMDrawAircraft( + int inPlaneIndex, + float inX, + float inY, + float inZ, + float inPitch, + float inRoll, + float inYaw, + int inFullDraw, + XPLMPlaneDrawState_t * inDrawStateInfo); +#endif /* XPLM_DEPRECATED */ + +#if defined(XPLM_DEPRECATED) +/* + * XPLMReinitUsersPlane + * + * WARNING: DO NOT USE. Use XPLMPlaceUserAtAirport or + * XPLMPlaceUserAtLocation. + * + * This function recomputes the derived flight model data from the aircraft + * structure in memory. If you have used the data access layer to modify the + * aircraft structure, use this routine to resynchronize X-Plane; since + * X-Plane works at least partly from derived values, the sim will not behave + * properly until this is called. + * + * WARNING: this routine does not necessarily place the airplane at the + * airport; use XPLMSetUsersAircraft to be compatible. This routine is + * provided to do special experimentation with flight models without resetting + * flight. + * + */ +XPLM_API void XPLMReinitUsersPlane(void); +#endif /* XPLM_DEPRECATED */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/CHeaders/XPLM/XPLMPlugin.h b/XPLPro_Plugin_Source/SDK/CHeaders/XPLM/XPLMPlugin.h new file mode 100644 index 0000000..be5d06c --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/CHeaders/XPLM/XPLMPlugin.h @@ -0,0 +1,422 @@ +#ifndef _XPLMPlugin_h_ +#define _XPLMPlugin_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPLMPlugin + ***************************************************************************/ +/* + * These APIs provide facilities to find and work with other plugins and + * manage other plugins. + * + */ + +#include "XPLMDefs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*************************************************************************** + * FINDING PLUGINS + ***************************************************************************/ +/* + * These APIs allow you to find another plugin or yourself, or iterate across + * all plugins. For example, if you wrote an FMS plugin that needed to talk + * to an autopilot plugin, you could use these APIs to locate the autopilot + * plugin. + * + */ + + +/* + * XPLMGetMyID + * + * This routine returns the plugin ID of the calling plug-in. Call this to + * get your own ID. + * + */ +XPLM_API XPLMPluginID XPLMGetMyID(void); + +/* + * XPLMCountPlugins + * + * This routine returns the total number of plug-ins that are loaded, both + * disabled and enabled. + * + */ +XPLM_API int XPLMCountPlugins(void); + +/* + * XPLMGetNthPlugin + * + * This routine returns the ID of a plug-in by index. Index is 0 based from 0 + * to XPLMCountPlugins-1, inclusive. Plugins may be returned in any arbitrary + * order. + * + */ +XPLM_API XPLMPluginID XPLMGetNthPlugin( + int inIndex); + +/* + * XPLMFindPluginByPath + * + * This routine returns the plug-in ID of the plug-in whose file exists at the + * passed in absolute file system path. XPLM_NO_PLUGIN_ID is returned if the + * path does not point to a currently loaded plug-in. + * + */ +XPLM_API XPLMPluginID XPLMFindPluginByPath( + const char * inPath); + +/* + * XPLMFindPluginBySignature + * + * This routine returns the plug-in ID of the plug-in whose signature matches + * what is passed in or XPLM_NO_PLUGIN_ID if no running plug-in has this + * signature. Signatures are the best way to identify another plug-in as they + * are independent of the file system path of a plug-in or the human-readable + * plug-in name, and should be unique for all plug-ins. Use this routine to + * locate another plugin that your plugin interoperates with + * + */ +XPLM_API XPLMPluginID XPLMFindPluginBySignature( + const char * inSignature); + +/* + * XPLMGetPluginInfo + * + * This routine returns information about a plug-in. Each parameter should be + * a pointer to a buffer of at least + * 256 characters, or NULL to not receive the information. + * + * outName - the human-readable name of the plug-in. outFilePath - the + * absolute file path to the file that contains this plug-in. outSignature - a + * unique string that identifies this plug-in. outDescription - a + * human-readable description of this plug-in. + * + */ +XPLM_API void XPLMGetPluginInfo( + XPLMPluginID inPlugin, + char * outName, /* Can be NULL */ + char * outFilePath, /* Can be NULL */ + char * outSignature, /* Can be NULL */ + char * outDescription); /* Can be NULL */ + +/*************************************************************************** + * ENABLING/DISABLING PLUG-INS + ***************************************************************************/ +/* + * These routines are used to work with plug-ins and manage them. Most + * plugins will not need to use these APIs. + * + */ + + +/* + * XPLMIsPluginEnabled + * + * Returns whether the specified plug-in is enabled for running. + * + */ +XPLM_API int XPLMIsPluginEnabled( + XPLMPluginID inPluginID); + +/* + * XPLMEnablePlugin + * + * This routine enables a plug-in if it is not already enabled. It returns 1 + * if the plugin was enabled or successfully enables itself, 0 if it does not. + * Plugins may fail to enable (for example, if resources cannot be acquired) + * by returning 0 from their XPluginEnable callback. + * + */ +XPLM_API int XPLMEnablePlugin( + XPLMPluginID inPluginID); + +/* + * XPLMDisablePlugin + * + * This routine disableds an enabled plug-in. + * + */ +XPLM_API void XPLMDisablePlugin( + XPLMPluginID inPluginID); + +/* + * XPLMReloadPlugins + * + * This routine reloads all plug-ins. Once this routine is called and you + * return from the callback you were within (e.g. a menu select callback) you + * will receive your XPluginDisable and XPluginStop callbacks and your DLL + * will be unloaded, then the start process happens as if the sim was starting + * up. + * + */ +XPLM_API void XPLMReloadPlugins(void); + +/*************************************************************************** + * INTERPLUGIN MESSAGING + ***************************************************************************/ +/* + * Plugin messages are defined as 32-bit integers. Messages below 0x00FFFFFF + * are reserved for X-Plane and the plugin SDK. + * + * Messages come with a pointer parameter; the meaning of this pointer depends + * on the message itself. In some messages, the pointer parameter contains an + * actual typed pointer to data that can be inspected in the plugin; in these + * cases the documentation will state that the parameter "points to" + * information. + * + * in other cases, the value of the pointer is actually an integral number + * stuffed into the pointer's storage. In these second cases, the pointer + * parameter needs to be cast, not dereferenced. In these caess, the + * documentation will state that the parameter "contains" a value, which will + * always be an integral type. + * + * Some messages don't use the pointer parameter - in this case your plugin + * should ignore it. + * + * Messages have two conceptual uses: notifications and commands. Commands + * are sent from one plugin to another to induce behavior; notifications are + * sent from one plugin to all others for informational purposes. It is + * important that commands and notifications not have the same values because + * this could cause a notification sent by one plugin to accidentally induce a + * command in another. + * + * By convention, plugin-defined notifications should have the high bit set + * (e.g. be greater or equal to unsigned 0x8000000) while commands should have + * this bit be cleared. + * + * The following messages are sent to your plugin by X-Plane. + * + */ + + +/* This message is sent to your plugin whenever the user's plane crashes. The * + * parameter is ignored. */ +#define XPLM_MSG_PLANE_CRASHED 101 + +/* This message is sent to your plugin whenever a new plane is loaded. The * + * parameter contains the index number of the plane being loaded; 0 indicates * + * the user's plane. */ +#define XPLM_MSG_PLANE_LOADED 102 + +/* This messages is sent whenever the user's plane is positioned at a new * + * airport. The parameter is ignored. */ +#define XPLM_MSG_AIRPORT_LOADED 103 + +/* This message is sent whenever new scenery is loaded. Use datarefs to * + * determine the new scenery files that were loaded. The parameter is ignored.*/ +#define XPLM_MSG_SCENERY_LOADED 104 + +/* This message is sent whenever the user adjusts the number of X-Plane * + * aircraft models. You must use XPLMCountPlanes to find out how many planes * + * are now available. This message will only be sent in XP7 and higher * + * because in XP6 the number of aircraft is not user-adjustable. The parameter* + * is ignored. */ +#define XPLM_MSG_AIRPLANE_COUNT_CHANGED 105 + +#if defined(XPLM200) +/* This message is sent to your plugin whenever a plane is unloaded. The * + * parameter contains the index number of the plane being unloaded; 0 * + * indicates the user's plane. The parameter is of type int, passed as the * + * value of the pointer. (That is: the parameter is an int, not a pointer to * + * an int.) */ +#define XPLM_MSG_PLANE_UNLOADED 106 +#endif /* XPLM200 */ + +#if defined(XPLM210) +/* This message is sent to your plugin right before X-Plane writes its * + * preferences file. You can use this for two purposes: to write your own * + * preferences, and to modify any datarefs to influence preferences output. * + * For example, if your plugin temporarily modifies saved preferences, you can* + * put them back to their default values here to avoid having the tweaks be * + * persisted if your plugin is not loaded on the next invocation of X-Plane. * + * The parameter is ignored. */ +#define XPLM_MSG_WILL_WRITE_PREFS 107 +#endif /* XPLM210 */ + +#if defined(XPLM210) +/* This message is sent to your plugin right after a livery is loaded for an * + * airplane. You can use this to check the new livery (via datarefs) and * + * react accordingly. The parameter contains the index number of the aircraft* + * whose livery is changing. */ +#define XPLM_MSG_LIVERY_LOADED 108 +#endif /* XPLM210 */ + +#if defined(XPLM301) +/* Sent to your plugin right before X-Plane enters virtual reality mode (at * + * which time any windows that are not positioned in VR mode will no longer be* + * visible to the user). The parameter is unused and should be ignored. */ +#define XPLM_MSG_ENTERED_VR 109 +#endif /* XPLM301 */ + +#if defined(XPLM301) +/* Sent to your plugin right before X-Plane leaves virtual reality mode (at * + * which time you may want to clean up windows that are positioned in VR * + * mode). The parameter is unused and should be ignored. */ +#define XPLM_MSG_EXITING_VR 110 +#endif /* XPLM301 */ + +#if defined(XPLM303) +/* Sent to your plugin if another plugin wants to take over AI planes. If you * + * are a synthetic traffic provider, that probably means a plugin for an * + * online network has connected and wants to supply aircraft flown by real * + * humans and you should cease to provide synthetic traffic. If however you * + * are providing online traffic from real humans, you probably don't want to * + * disconnect, in which case you just ignore this message. The sender is the * + * plugin ID of the plugin asking for control of the planes now. You can use * + * it to find out who is requesting and whether you should yield to them. * + * Synthetic traffic providers should always yield to online networks. The * + * parameter is unused and should be ignored. */ +#define XPLM_MSG_RELEASE_PLANES 111 +#endif /* XPLM303 */ + +/* + * XPLMSendMessageToPlugin + * + * This function sends a message to another plug-in or X-Plane. Pass + * XPLM_NO_PLUGIN_ID to broadcast to all plug-ins. Only enabled plug-ins with + * a message receive function receive the message. + * + */ +XPLM_API void XPLMSendMessageToPlugin( + XPLMPluginID inPlugin, + int inMessage, + void * inParam); + +#if defined(XPLM200) +/*************************************************************************** + * Plugin Features API + ***************************************************************************/ +/* + * The plugin features API allows your plugin to "sign up" for additional + * capabilities and plugin system features that are normally disabled for + * backward compatibility. This allows advanced plugins to "opt-in" to new + * behavior. + * + * Each feature is defined by a permanent string name. The feature string + * names will vary with the particular installation of X-Plane, so plugins + * should not expect a feature to be guaranteed present. + * + * XPLM_WANTS_REFLECTIONS + * ---------------------- + * + * Available in the SDK 2.0 and later for X-Plane 9, enabling this capability + * causes your plugin to receive drawing hook callbacks when X-Plane builds + * its off-screen reflection and shadow rendering passes. Plugins should + * enable this and examine the dataref sim/graphics/view/plane_render_type to + * determine whether the drawing callback is for a reflection, shadow + * calculation, or the main screen. Rendering can be simlified or omitted for + * reflections, and non-solid drawing should be skipped for shadow + * calculations. + * + * **Note**: direct drawing via draw callbacks is not recommended; use the + * XPLMInstance API to create object models instead. + * + * XPLM_USE_NATIVE_PATHS + * --------------------- + * + * available in the SDK 2.1 and later for X-Plane 10, this modifies the plugin + * system to use Unix-style paths on all operating systems. With this enabled: + * + * * OS X paths will match the native OS X Unix. + * * Windows will use forward slashes but preserve C:\ or another drive letter + * when using complete file paths. + * * Linux uses its native file system path scheme. + * + * Without this enabled: + * + * * OS X will use CFM file paths separated by a colon. + * * Windows will use back-slashes and conventional DOS paths. + * * Linux uses its native file system path scheme. + * + * All plugins should enable this feature on OS X to access the native file + * system. + * + * XPLM_USE_NATIVE_WIDGET_WINDOWS + * ------------------------------ + * + * Available in the SDK 3.0.2 SDK, this capability tells the widgets library + * to use new, modern X-Plane backed XPLMDisplay windows to anchor all widget + * trees. Without it, widgets will always use legacy windows. + * + * Plugins should enable this to allow their widget hierarchies to respond to + * the user's UI size settings and to map widget-based windwos to a VR HMD. + * + * Before enabling this, make sure any custom widget code in your plugin is + * prepared to cope with the UI coordinate system not being th same as the + * OpenGL window coordinate system. + * + */ + + +/* + * XPLMFeatureEnumerator_f + * + * You pass an XPLMFeatureEnumerator_f to get a list of all features supported + * by a given version running version of X-Plane. This routine is called once + * for each feature. + * + */ +typedef void (* XPLMFeatureEnumerator_f)( + const char * inFeature, + void * inRef); + +/* + * XPLMHasFeature + * + * This returns 1 if the given installation of X-Plane supports a feature, or + * 0 if it does not. + * + */ +XPLM_API int XPLMHasFeature( + const char * inFeature); + +/* + * XPLMIsFeatureEnabled + * + * This returns 1 if a feature is currently enabled for your plugin, or 0 if + * it is not enabled. It is an error to call this routine with an unsupported + * feature. + * + */ +XPLM_API int XPLMIsFeatureEnabled( + const char * inFeature); + +/* + * XPLMEnableFeature + * + * This routine enables or disables a feature for your plugin. This will + * change the running behavior of X-Plane and your plugin in some way, + * depending on the feature. + * + */ +XPLM_API void XPLMEnableFeature( + const char * inFeature, + int inEnable); + +/* + * XPLMEnumerateFeatures + * + * This routine calls your enumerator callback once for each feature that this + * running version of X-Plane supports. Use this routine to determine all of + * the features that X-Plane can support. + * + */ +XPLM_API void XPLMEnumerateFeatures( + XPLMFeatureEnumerator_f inEnumerator, + void * inRef); + +#endif /* XPLM200 */ +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/CHeaders/XPLM/XPLMProcessing.h b/XPLPro_Plugin_Source/SDK/CHeaders/XPLM/XPLMProcessing.h new file mode 100644 index 0000000..94ef0c4 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/CHeaders/XPLM/XPLMProcessing.h @@ -0,0 +1,264 @@ +#ifndef _XPLMProcessing_h_ +#define _XPLMProcessing_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPLMProcessing + ***************************************************************************/ +/* + * This API allows you to get regular callbacks during the flight loop, the + * part of X-Plane where the plane's position calculates the physics of + * flight, etc. Use these APIs to accomplish periodic tasks like logging data + * and performing I/O. + * + * You can receive a callback either just before or just after the per-frame + * physics calculations happen - you can use post-FM callbacks to "patch" the + * flight model after it has run. + * + * If the user has set the number of flight model iterations per frame greater + * than one your plugin will _not_ see this; these integrations run on the + * sub-section of the flight model where iterations improve responsiveness + * (e.g. physical integration, not simple systems tracking) and are thus + * opaque to plugins. + * + * Flight loop scheduling, when scheduled by time, is scheduled by a "first + * callback after the deadline" schedule, e.g. your callbacks will always be + * slightly late to ensure that we don't run faster than your deadline. + * + * WARNING: Do NOT use these callbacks to draw! You cannot draw during flight + * loop callbacks. Use the drawing callbacks (see XPLMDisplay for more info) + * for graphics. (One exception: you can use a post-flight loop callback to + * update your own off-screen FBOs.) + * + */ + +#include "XPLMDefs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*************************************************************************** + * FLIGHT LOOP CALLBACKS + ***************************************************************************/ + +#if defined(XPLM210) +/* + * XPLMFlightLoopPhaseType + * + * You can register a flight loop callback to run either before or after the + * flight model is integrated by X-Plane. + * + */ +enum { + /* Your callback runs before X-Plane integrates the flight model. */ + xplm_FlightLoop_Phase_BeforeFlightModel = 0, + + /* Your callback runs after X-Plane integrates the flight model. */ + xplm_FlightLoop_Phase_AfterFlightModel = 1, + + +}; +typedef int XPLMFlightLoopPhaseType; +#endif /* XPLM210 */ + +#if defined(XPLM210) +/* + * XPLMFlightLoopID + * + * This is an opaque identifier for a flight loop callback. You can use this + * identifier to easily track and remove your callbacks, or to use the new + * flight loop APIs. + * + */ +typedef void * XPLMFlightLoopID; +#endif /* XPLM210 */ + +/* + * XPLMFlightLoop_f + * + * This is your flight loop callback. Each time the flight loop is iterated + * through, you receive this call at the end. + * + * Flight loop callbacks receive a number of input timing parameters. These + * input timing parameters are not particularly useful; you may need to track + * your own timing data (e.g. by reading datarefs). The input parameters are: + * + * - inElapsedSinceLastCall: the wall time since your last callback. + * - inElapsedTimeSinceLastFlightLoop: the wall time since any flight loop was + * dispatched. + * - inCounter: a monotonically increasing counter, bumped once per flight + * loop dispatch from the sim. + * - inRefcon: your own ptr constant from when you regitered yor callback. + * + * Your return value controls when you will next be called. + * + * - Return 0 to stop receiving callbacks. + * - Pass a positive number to specify how many seconds until the next + * callback. (You will be called at or after this time, not before.) + * - Pass a negative number to specify how many loops must go by until you + * are called. For example, -1.0 means call me the very next loop. + * + * Try to run your flight loop as infrequently as is practical, and suspend it + * (using return value 0) when you do not need it; lots of flight loop + * callbacks that do nothing lowers X-Plane's frame rate. + * + * Your callback will NOT be unregistered if you return 0; it will merely be + * inactive. + * + */ +typedef float (* XPLMFlightLoop_f)( + float inElapsedSinceLastCall, + float inElapsedTimeSinceLastFlightLoop, + int inCounter, + void * inRefcon); + +#if defined(XPLM210) +/* + * XPLMCreateFlightLoop_t + * + * XPLMCreateFlightLoop_t contains the parameters to create a new flight loop + * callback. The strsucture can be expanded in future SDKs - always set + * structSize to the size of your structure in bytes. + * + */ +typedef struct { + int structSize; + XPLMFlightLoopPhaseType phase; + XPLMFlightLoop_f callbackFunc; + void * refcon; +} XPLMCreateFlightLoop_t; +#endif /* XPLM210 */ + +/* + * XPLMGetElapsedTime + * + * This routine returns the elapsed time since the sim started up in decimal + * seconds. This is a wall timer; it keeps counting upward even if the sim is + * pasued. + * + * __WARNING__: XPLMGetElapsedTime is not a very good timer! It lacks + * precision in both its data type and its source. Do not attempt to use it + * for timing critical applications like network multiplayer. + * + */ +XPLM_API float XPLMGetElapsedTime(void); + +/* + * XPLMGetCycleNumber + * + * This routine returns a counter starting at zero for each sim cycle + * computed/video frame rendered. + * + */ +XPLM_API int XPLMGetCycleNumber(void); + +/* + * XPLMRegisterFlightLoopCallback + * + * This routine registers your flight loop callback. Pass in a pointer to a + * flight loop function and a refcon. inInterval defines when you will be + * called. Pass in a positive number to specify seconds from registration time + * to the next callback. Pass in a negative number to indicate when you will + * be called (e.g. pass -1 to be called at the next cylcle). Pass 0 to not be + * called; your callback will be inactive. + * + * (This legacy function only installs pre-flight-loop callbacks; use + * XPLMCreateFlightLoop for more control.) + * + */ +XPLM_API void XPLMRegisterFlightLoopCallback( + XPLMFlightLoop_f inFlightLoop, + float inInterval, + void * inRefcon); + +/* + * XPLMUnregisterFlightLoopCallback + * + * This routine unregisters your flight loop callback. Do NOT call it from + * your flight loop callback. Once your flight loop callback is unregistered, + * it will not be called again. + * + * Only use this on flight loops registered via + * XPLMRegisterFlightLoopCallback. + * + */ +XPLM_API void XPLMUnregisterFlightLoopCallback( + XPLMFlightLoop_f inFlightLoop, + void * inRefcon); + +/* + * XPLMSetFlightLoopCallbackInterval + * + * This routine sets when a callback will be called. Do NOT call it from your + * callback; use the return value of the callback to change your callback + * interval from inside your callback. + * + * inInterval is formatted the same way as in XPLMRegisterFlightLoopCallback; + * positive for seconds, negative for cycles, and 0 for deactivating the + * callback. If inRelativeToNow is 1, times are from the time of this call; + * otherwise they are from the time the callback was last called (or the time + * it was registered if it has never been called. + * + */ +XPLM_API void XPLMSetFlightLoopCallbackInterval( + XPLMFlightLoop_f inFlightLoop, + float inInterval, + int inRelativeToNow, + void * inRefcon); + +#if defined(XPLM210) +/* + * XPLMCreateFlightLoop + * + * This routine creates a flight loop callback and returns its ID. The flight + * loop callback is created using the input param struct, and is inited to be + * unscheduled. + * + */ +XPLM_API XPLMFlightLoopID XPLMCreateFlightLoop( + XPLMCreateFlightLoop_t * inParams); +#endif /* XPLM210 */ + +#if defined(XPLM210) +/* + * XPLMDestroyFlightLoop + * + * This routine destroys a flight loop callback by ID. Only call it on flight + * loops created with the newer XPLMCreateFlightLoop API. + * + */ +XPLM_API void XPLMDestroyFlightLoop( + XPLMFlightLoopID inFlightLoopID); +#endif /* XPLM210 */ + +#if defined(XPLM210) +/* + * XPLMScheduleFlightLoop + * + * This routine schedules a flight loop callback for future execution. If + * inInterval is negative, it is run in a certain number of frames based on + * the absolute value of the input. If the interval is positive, it is a + * duration in seconds. + * + * If inRelativeToNow is true, ties are interpretted relative to the time this + * routine is called; otherwise they are relative to the last call time or the + * time the flight loop was registered (if never called). + * + */ +XPLM_API void XPLMScheduleFlightLoop( + XPLMFlightLoopID inFlightLoopID, + float inInterval, + int inRelativeToNow); +#endif /* XPLM210 */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/CHeaders/XPLM/XPLMScenery.h b/XPLPro_Plugin_Source/SDK/CHeaders/XPLM/XPLMScenery.h new file mode 100644 index 0000000..452bac9 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/CHeaders/XPLM/XPLMScenery.h @@ -0,0 +1,450 @@ +#ifndef _XPLMScenery_h_ +#define _XPLMScenery_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPLMScenery + ***************************************************************************/ +/* + * This package contains APIs to interact with X-Plane's scenery system. + * + */ + +#include "XPLMDefs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(XPLM200) +/*************************************************************************** + * Terrain Y-Testing + ***************************************************************************/ +/* + * The Y-testing API allows you to locate the physical scenery mesh. This + * would be used to place dynamic graphics on top of the ground in a plausible + * way or do physics interactions. + * + * The Y-test API works via probe objects, which are allocated by your plugin + * and used to query terrain. Probe objects exist both to capture which + * algorithm you have requested (see probe types) and also to cache query + * information. + * + * Performance Guidelines + * ---------------------- + * + * It is generally faster to use the same probe for nearby points and + * different probes for different points. Try not to allocate more than + * "hundreds" of probes at most. Share probes if you need more. Generally, + * probing operations are expensive, and should be avoided via caching when + * possible. + * + * Y testing returns a location on the terrain, a normal vectory, and a + * velocity vector. The normal vector tells you the slope of the terrain at + * that point. The velocity vector tells you if that terrain is moving (and is + * in meters/second). For example, if your Y test hits the aircraft carrier + * deck, this tells you the velocity of that point on the deck. + * + * Note: the Y-testing API is limited to probing the loaded scenery area, + * which is approximately 300x300 km in X-Plane 9. Probes outside this area + * will return the height of a 0 MSL sphere. + * + */ + + +/* + * XPLMProbeType + * + * XPLMProbeType defines the type of terrain probe - each probe has a + * different algorithm. (Only one type of probe is provided right now, but + * future APIs will expose more flexible or poewrful or useful probes. + * + */ +enum { + /* The Y probe gives you the location of the tallest physical scenery along * + * the Y axis going through the queried point. */ + xplm_ProbeY = 0, + + +}; +typedef int XPLMProbeType; + +/* + * XPLMProbeResult + * + * Probe results - possible results from a probe query. + * + */ +enum { + /* The probe hit terrain and returned valid values. */ + xplm_ProbeHitTerrain = 0, + + /* An error in the API call. Either the probe struct size is bad, or the * + * probe is invalid or the type is mismatched for the specific query call. */ + xplm_ProbeError = 1, + + /* The probe call succeeded but there is no terrain under this point (perhaps * + * it is off the side of the planet?) */ + xplm_ProbeMissed = 2, + + +}; +typedef int XPLMProbeResult; + +/* + * XPLMProbeRef + * + * An XPLMProbeRef is an opaque handle to a probe, used for querying the + * terrain. + * + */ +typedef void * XPLMProbeRef; + +/* + * XPLMProbeInfo_t + * + * XPLMProbeInfo_t contains the results of a probe call. Make sure to set + * structSize to the size of the struct before using it. + * + */ +typedef struct { + /* Size of structure in bytes - always set this before calling the XPLM. */ + int structSize; + /* Resulting X location of the terrain point we hit, in local OpenGL * + * coordinates. */ + float locationX; + /* Resulting Y location of the terrain point we hit, in local OpenGL * + * coordinates. */ + float locationY; + /* Resulting Z location of the terrain point we hit, in local OpenGL * + * coordinates. */ + float locationZ; + /* X component of the normal vector to the terrain we found. */ + float normalX; + /* Y component of the normal vector to the terrain we found. */ + float normalY; + /* Z component of the normal vector to the terrain we found. */ + float normalZ; + /* X component of the velocity vector of the terrain we found. */ + float velocityX; + /* Y component of the velocity vector of the terrain we found. */ + float velocityY; + /* Z component of the velocity vector of the terrain we found. */ + float velocityZ; + /* Tells if the surface we hit is water (otherwise it is land). */ + int is_wet; +} XPLMProbeInfo_t; + +/* + * XPLMCreateProbe + * + * Creates a new probe object of a given type and returns. + * + */ +XPLM_API XPLMProbeRef XPLMCreateProbe( + XPLMProbeType inProbeType); + +/* + * XPLMDestroyProbe + * + * Deallocates an existing probe object. + * + */ +XPLM_API void XPLMDestroyProbe( + XPLMProbeRef inProbe); + +/* + * XPLMProbeTerrainXYZ + * + * Probes the terrain. Pass in the XYZ coordinate of the probe point, a probe + * object, and an XPLMProbeInfo_t struct that has its structSize member set + * properly. Other fields are filled in if we hit terrain, and a probe result + * is returned. + * + */ +XPLM_API XPLMProbeResult XPLMProbeTerrainXYZ( + XPLMProbeRef inProbe, + float inX, + float inY, + float inZ, + XPLMProbeInfo_t * outInfo); + +#endif /* XPLM200 */ +#if defined(XPLM300) +/*************************************************************************** + * Magnetic Variation + ***************************************************************************/ +/* + * Use the magnetic variation (more properly, the "magnetic declination") API + * to find the offset of magnetic north from true north at a given latitude + * and longitude within the simulator. + * + * In the real world, the Earth's magnetic field is irregular, such that true + * north (the direction along a meridian toward the north pole) does not + * necessarily match what a magnetic compass shows as north. + * + * Using this API ensures that you present the same offsets to users as + * X-Plane's built-in instruments. + * + */ + + +/* + * XPLMGetMagneticVariation + * + * Returns X-Plane's simulated magnetic variation (declination) at the + * indication latitude and longitude. + * + */ +XPLM_API float XPLMGetMagneticVariation( + double latitude, + double longitude); + +/* + * XPLMDegTrueToDegMagnetic + * + * Converts a heading in degrees relative to true north into a value relative + * to magnetic north at the user's current location. + * + */ +XPLM_API float XPLMDegTrueToDegMagnetic( + float headingDegreesTrue); + +/* + * XPLMDegMagneticToDegTrue + * + * Converts a heading in degrees relative to magnetic north at the user's + * current location into a value relative to true north. + * + */ +XPLM_API float XPLMDegMagneticToDegTrue( + float headingDegreesMagnetic); + +#endif /* XPLM300 */ +/*************************************************************************** + * Object Drawing + ***************************************************************************/ +/* + * The object drawing routines let you load and draw X-Plane OBJ files. + * Objects are loaded by file path and managed via an opaque handle. X-Plane + * naturally reference counts objects, so it is important that you balance + * every successful call to XPLMLoadObject with a call to XPLMUnloadObject! + * + */ + + +#if defined(XPLM200) +/* + * XPLMObjectRef + * + * An XPLMObjectRef is a opaque handle to an .obj file that has been loaded + * into memory. + * + */ +typedef void * XPLMObjectRef; +#endif /* XPLM200 */ + +#if defined(XPLM200) +/* + * XPLMDrawInfo_t + * + * The XPLMDrawInfo_t structure contains positioning info for one object that + * is to be drawn. Be sure to set structSize to the size of the structure for + * future expansion. + * + */ +typedef struct { + /* Set this to the size of this structure! */ + int structSize; + /* X location of the object in local coordinates. */ + float x; + /* Y location of the object in local coordinates. */ + float y; + /* Z location of the object in local coordinates. */ + float z; + /* Pitch in degres to rotate the object, positive is up. */ + float pitch; + /* Heading in local coordinates to rotate the object, clockwise. */ + float heading; + /* Roll to rotate the object. */ + float roll; +} XPLMDrawInfo_t; +#endif /* XPLM200 */ + +#if defined(XPLM210) +/* + * XPLMObjectLoaded_f + * + * You provide this callback when loading an object asynchronously; it will be + * called once the object is loaded. Your refcon is passed back. The object + * ref passed in is the newly loaded object (ready for use) or NULL if an + * error occured. + * + * If your plugin is disabled, this callback will be delivered as soon as the + * plugin is re-enabled. If your plugin is unloaded before this callback is + * ever called, the SDK will release the object handle for you. + * + */ +typedef void (* XPLMObjectLoaded_f)( + XPLMObjectRef inObject, + void * inRefcon); +#endif /* XPLM210 */ + +#if defined(XPLM200) +/* + * XPLMLoadObject + * + * This routine loads an OBJ file and returns a handle to it. If X-Plane has + * already loaded the object, the handle to the existing object is returned. + * Do not assume you will get the same handle back twice, but do make sure to + * call unload once for every load to avoid "leaking" objects. The object will + * be purged from memory when no plugins and no scenery are using it. + * + * The path for the object must be relative to the X-System base folder. If + * the path is in the root of the X-System folder you may need to prepend ./ + * to it; loading objects in the root of the X-System folder is STRONGLY + * discouraged - your plugin should not dump art resources in the root folder! + * + * XPLMLoadObject will return NULL if the object cannot be loaded (either + * because it is not found or the file is misformatted). This routine will + * load any object that can be used in the X-Plane scenery system. + * + * It is important that the datarefs an object uses for animation already be + * loaded before you load the object. For this reason it may be necessary to + * defer object loading until the sim has fully started. + * + */ +XPLM_API XPLMObjectRef XPLMLoadObject( + const char * inPath); +#endif /* XPLM200 */ + +#if defined(XPLM210) +/* + * XPLMLoadObjectAsync + * + * This routine loads an object asynchronously; control is returned to you + * immediately while X-Plane loads the object. The sim will not stop flying + * while the object loads. For large objects, it may be several seconds before + * the load finishes. + * + * You provide a callback function that is called once the load has completed. + * Note that if the object cannot be loaded, you will not find out until the + * callback function is called with a NULL object handle. + * + * There is no way to cancel an asynchronous object load; you must wait for + * the load to complete and then release the object if it is no longer + * desired. + * + */ +XPLM_API void XPLMLoadObjectAsync( + const char * inPath, + XPLMObjectLoaded_f inCallback, + void * inRefcon); +#endif /* XPLM210 */ + +#if defined(XPLM_DEPRECATED) +/* + * XPLMDrawObjects + * + * __Deprecation Warning__: use XPLMInstancing to draw 3-d objects by creating + * instances, rather than these APIs from draw callbacks. + * + * XPLMDrawObjects draws an object from an OBJ file one or more times. You + * pass in the object and an array of XPLMDrawInfo_t structs, one for each + * place you would like the object to be drawn. + * + * X-Plane will attempt to cull the objects based on LOD and visibility, and + * will pick the appropriate LOD. + * + * Lighting is a boolean; pass 1 to show the night version of object with + * night-only lights lit up. Pass 0 to show the daytime version of the object. + * + * earth_relative controls the coordinate system. If this is 1, the rotations + * you specify are applied to the object after its coordinate system is + * transformed from local to earth-relative coordinates -- that is, an object + * with no rotations will point toward true north and the Y axis will be up + * against gravity. If this is 0, the object is drawn with your rotations from + * local coordanates -- that is, an object with no rotations is drawn pointing + * down the -Z axis and the Y axis of the object matches the local coordinate + * Y axis. + * + */ +XPLM_API void XPLMDrawObjects( + XPLMObjectRef inObject, + int inCount, + XPLMDrawInfo_t * inLocations, + int lighting, + int earth_relative); +#endif /* XPLM_DEPRECATED */ + +#if defined(XPLM200) +/* + * XPLMUnloadObject + * + * This routine marks an object as no longer being used by your plugin. + * Objects are reference counted: once no plugins are using an object, it is + * purged from memory. Make sure to call XPLMUnloadObject once for each + * successful call to XPLMLoadObject. + * + */ +XPLM_API void XPLMUnloadObject( + XPLMObjectRef inObject); +#endif /* XPLM200 */ + +#if defined(XPLM200) +/*************************************************************************** + * Library Access + ***************************************************************************/ +/* + * The library access routines allow you to locate scenery objects via the + * X-Plane library system. Right now library access is only provided for + * objects, allowing plugin-drawn objects to be extended using the library + * system. + * + */ + + +/* + * XPLMLibraryEnumerator_f + * + * An XPLMLibraryEnumerator_f is a callback you provide that is called once + * for each library element that is located. The returned paths will be + * relative to the X-System folder. + * + */ +typedef void (* XPLMLibraryEnumerator_f)( + const char * inFilePath, + void * inRef); + +/* + * XPLMLookupObjects + * + * This routine looks up a virtual path in the library system and returns all + * matching elements. You provide a callback - one virtual path may match many + * objects in the library. XPLMLookupObjects returns the number of objects + * found. + * + * The latitude and longitude parameters specify the location the object will + * be used. The library system allows for scenery packages to only provide + * objects to certain local locations. Only objects that are allowed at the + * latitude/longitude you provide will be returned. + * + */ +XPLM_API int XPLMLookupObjects( + const char * inPath, + float inLatitude, + float inLongitude, + XPLMLibraryEnumerator_f enumerator, + void * ref); + +#endif /* XPLM200 */ +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/CHeaders/XPLM/XPLMUtilities.h b/XPLPro_Plugin_Source/SDK/CHeaders/XPLM/XPLMUtilities.h new file mode 100644 index 0000000..bec319e --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/CHeaders/XPLM/XPLMUtilities.h @@ -0,0 +1,970 @@ +#ifndef _XPLMUtilities_h_ +#define _XPLMUtilities_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPLMUtilities + ***************************************************************************/ + +#include "XPLMDefs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*************************************************************************** + * FILE UTILITIES + ***************************************************************************/ +/* + * The XPLMUtilities file APIs provide some basic file and path functions for + * use with X-Plane. + * + * Directory Separators + * -------------------- + * + * The XPLM has two modes it can work in: + * + * * X-Plane native paths: all paths are UTF8 strings, using the unix forward + * slash (/) as the directory separating character. In native path mode, + * you use the same path format for all three operating systems. + * + * * Legacy OS paths: the directroy separator is \ for Windows, : for OS X, + * and / for Linux; OS paths are encoded in MacRoman for OS X using legacy + * HFS conventions, use the application code page for multi-byte encoding + * on Unix using DOS path conventions, and use UTF-8 for Linux. + * + * While legacy OS paths are the default, we strongly encourage you to opt in + * to native paths using the XPLMEnableFeature API. + * + * * All OS X plugins should enable native paths all of the time; if you do + * not do this, you will have to convert all paths back from HFS to Unix + * (and deal with MacRoman) - code written using native paths and the C + * file APIs "just works" on OS X. + * + * * For Linux plugins, there is no difference between the two encodings. + * + * * Windows plugins will need to convert the UTF8 file paths to UTF16 for + * use with the "wide" APIs. While it might seem tempting to stick with + * legacy OS paths (and just use the "ANSI" Windows APIs), X-Plane is fully + * unicode-capable, and will often be installed in paths where the user's + * directories have no ACP encoding. + * + * Full and Relative Paths + * ----------------------- + * + * Some of these APIs use full paths, but others use paths relative to the + * user's X-Plane installation. This is documented on a per-API basis. + * + */ + + +#if defined(XPLM200) +/* + * XPLMDataFileType + * + * These enums define types of data files you can load or unload using the + * SDK. + * + */ +enum { + /* A situation (.sit) file, which starts off a flight in a given * + * configuration. */ + xplm_DataFile_Situation = 1, + + /* A situation movie (.smo) file, which replays a past flight. */ + xplm_DataFile_ReplayMovie = 2, + + +}; +typedef int XPLMDataFileType; +#endif /* XPLM200 */ + +/* + * XPLMGetSystemPath + * + * This function returns the full path to the X-System folder. Note that this + * is a directory path, so it ends in a trailing : or /. + * + * The buffer you pass should be at least 512 characters long. The path is + * returned using the current native or OS path conventions. + * + */ +XPLM_API void XPLMGetSystemPath( + char * outSystemPath); + +/* + * XPLMGetPrefsPath + * + * This routine returns a full path to a file that is within X-Plane's + * preferences directory. (You should remove the file name back to the last + * directory separator to get the preferences directory using + * XPLMExtractFileAndPath.) + * + * The buffer you pass should be at least 512 characters long. The path is + * returned using the current native or OS path conventions. + * + */ +XPLM_API void XPLMGetPrefsPath( + char * outPrefsPath); + +/* + * XPLMGetDirectorySeparator + * + * This routine returns a string with one char and a null terminator that is + * the directory separator for the current platform. This allows you to write + * code that concatinates directory paths without having to #ifdef for + * platform. The character returned will reflect the current file path mode. + * + */ +XPLM_API const char * XPLMGetDirectorySeparator(void); + +/* + * XPLMExtractFileAndPath + * + * Given a full path to a file, this routine separates the path from the file. + * If the path is a partial directory (e.g. ends in : or \) the trailing + * directory separator is removed. This routine works in-place; a pointer to + * the file part of the buffer is returned; the original buffer still starts + * with the path and is null terminated with no trailing separator. + * + */ +XPLM_API char * XPLMExtractFileAndPath( + char * inFullPath); + +/* + * XPLMGetDirectoryContents + * + * This routine returns a list of files in a directory (specified by a full + * path, no trailing : or \). The output is returned as a list of NULL + * terminated strings. An index array (if specified) is filled with pointers + * into the strings. The last file is indicated by a zero-length string (and + * NULL in the indices). This routine will return 1 if you had capacity for + * all files or 0 if you did not. You can also skip a given number of files. + * + * * inDirectoryPath - a null terminated C string containing the full path to + * the directory with no trailing directory char. + * + * * inFirstReturn - the zero-based index of the first file in the directory + * to return. (Usually zero to fetch all in one pass.) + * + * * outFileNames - a buffer to receive a series of sequential null + * terminated C-string file names. A zero-length C string will be appended + * to the very end. + * + * * inFileNameBufSize - the size of the file name buffer in bytes. + * + * * outIndices - a pointer to an array of character pointers that will + * become an index into the directory. The last file will be followed by a + * NULL value. Pass NULL if you do not want indexing information. + * + * * inIndexCount - the max size of the index in entries. + * + * * outTotalFiles - if not NULL, this is filled in with the number of files + * in the directory. + * + * * outReturnedFiles - if not NULL, the number of files returned by this + * iteration. + * + * Return value: 1 if all info could be returned, 0 if there was a buffer + * overrun. + * + * WARNING: Before X-Plane 7 this routine did not properly iterate through + * directories. If X-Plane + * 6 compatibility is needed, use your own code to iterate directories. + * + */ +XPLM_API int XPLMGetDirectoryContents( + const char * inDirectoryPath, + int inFirstReturn, + char * outFileNames, + int inFileNameBufSize, + char ** outIndices, /* Can be NULL */ + int inIndexCount, + int * outTotalFiles, /* Can be NULL */ + int * outReturnedFiles); /* Can be NULL */ + +#if defined(XPLM200) +/* + * XPLMLoadDataFile + * + * Loads a data file of a given type. Paths must be relative to the X-System + * folder. To clear the replay, pass a NULL file name (this is only valid with + * replay movies, not sit files). + * + */ +XPLM_API int XPLMLoadDataFile( + XPLMDataFileType inFileType, + const char * inFilePath); /* Can be NULL */ +#endif /* XPLM200 */ + +#if defined(XPLM200) +/* + * XPLMSaveDataFile + * + * Saves the current situation or replay; paths are relative to the X-System + * folder. + * + */ +XPLM_API int XPLMSaveDataFile( + XPLMDataFileType inFileType, + const char * inFilePath); +#endif /* XPLM200 */ + +/*************************************************************************** + * X-PLANE MISC + ***************************************************************************/ + +/* + * XPLMHostApplicationID + * + * While the plug-in SDK is only accessible to plugins running inside X-Plane, + * the original authors considered extending the API to other applications + * that shared basic infrastructure with X-Plane. These enumerations are + * hold-overs from that original roadmap; all values other than X-Plane are + * deprecated. Your plugin should never need this enumeration. + * + */ +enum { + xplm_Host_Unknown = 0, + + xplm_Host_XPlane = 1, + +#if defined(XPLM_DEPRECATED) + xplm_Host_PlaneMaker = 2, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + xplm_Host_WorldMaker = 3, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + xplm_Host_Briefer = 4, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + xplm_Host_PartMaker = 5, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + xplm_Host_YoungsMod = 6, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + xplm_Host_XAuto = 7, + +#endif /* XPLM_DEPRECATED */ + +}; +typedef int XPLMHostApplicationID; + +/* + * XPLMLanguageCode + * + * These enums define what language the sim is running in. These enumerations + * do not imply that the sim can or does run in all of these languages; they + * simply provide a known encoding in the event that a given sim version is + * localized to a certain language. + * + */ +enum { + xplm_Language_Unknown = 0, + + xplm_Language_English = 1, + + xplm_Language_French = 2, + + xplm_Language_German = 3, + + xplm_Language_Italian = 4, + + xplm_Language_Spanish = 5, + + xplm_Language_Korean = 6, + +#if defined(XPLM200) + xplm_Language_Russian = 7, + +#endif /* XPLM200 */ +#if defined(XPLM200) + xplm_Language_Greek = 8, + +#endif /* XPLM200 */ +#if defined(XPLM200) + xplm_Language_Japanese = 9, + +#endif /* XPLM200 */ +#if defined(XPLM300) + xplm_Language_Chinese = 10, + +#endif /* XPLM300 */ + +}; +typedef int XPLMLanguageCode; + +#if defined(XPLM200) +/* + * XPLMError_f + * + * An XPLM error callback is a function that you provide to receive debugging + * information from the plugin SDK. See XPLMSetErrorCallback for more + * information. NOTE: for the sake of debugging, your error callback will be + * called even if your plugin is not enabled, allowing you to receive debug + * info in your XPluginStart and XPluginStop callbacks. To avoid causing logic + * errors in the management code, do not call any other plugin routines from + * your error callback - it is only meant for catching errors in the + * debugging. + * + */ +typedef void (* XPLMError_f)( + const char * inMessage); +#endif /* XPLM200 */ + +#if defined(XPLM_DEPRECATED) +/* + * XPLMInitialized + * + * Deprecated: This function returns 1 if X-Plane has properly initialized the + * plug-in system. If this routine returns 0, many XPLM functions will not + * work. + * + * NOTE: because plugins are always called from within the XPLM, there is no + * need to check for initialization; it will always return 1. This routine is + * deprecated - you do not need to check it before continuing within your + * plugin. + * + */ +XPLM_API int XPLMInitialized(void); +#endif /* XPLM_DEPRECATED */ + +/* + * XPLMGetVersions + * + * This routine returns the revision of both X-Plane and the XPLM DLL. All + * versions are three-digit decimal numbers (e.g. 606 for version 6.06 of + * X-Plane); the current revision of the XPLM is 200 (2.00). This routine also + * returns the host ID of the app running us. + * + * The most common use of this routine is to special-case around X-Plane + * version-specific behavior. + * + */ +XPLM_API void XPLMGetVersions( + int * outXPlaneVersion, + int * outXPLMVersion, + XPLMHostApplicationID * outHostID); + +/* + * XPLMGetLanguage + * + * This routine returns the langauge the sim is running in. + * + */ +XPLM_API XPLMLanguageCode XPLMGetLanguage(void); + +#if defined(XPLM200) +/* + * XPLMFindSymbol + * + * This routine will attempt to find the symbol passed in the inString + * parameter. If the symbol is found a pointer the function is returned, + * othewise the function will return NULL. + * + * You can use XPLMFindSymbol to utilize newer SDK API features without + * requiring newer versions of the SDK (and X-Plane) as your minimum X-Plane + * version as follows: + * + * * Define the XPLMnnn macro to the minimum required XPLM version you will + * ship with (e.g. XPLM210 for X-Plane 10 compatibility). + * + * * Use XPLMGetVersions and XPLMFindSymbol to detect that the host sim is + * new enough to use new functions and resolve function pointers. + * + * * Conditionally use the new functions if and only if XPLMFindSymbol only + * returns a non- NULL pointer. + * + * Warning: you should always check the XPLM API version as well as the + * results of XPLMFindSymbol to determine if funtionality is safe to use. + * + * To use functionality via XPLMFindSymbol you will need to copy your own + * definitions of the X-Plane API prototypes and cast the returned pointer to + * the correct type. + * + */ +XPLM_API void * XPLMFindSymbol( + const char * inString); +#endif /* XPLM200 */ + +#if defined(XPLM200) +/* + * XPLMSetErrorCallback + * + * XPLMSetErrorCallback installs an error-reporting callback for your plugin. + * Normally the plugin system performs minimum diagnostics to maximize + * performance. When you install an error callback, you will receive calls due + * to certain plugin errors, such as passing bad parameters or incorrect data. + * + * Important: the error callback determines *programming* errors, e.g. bad API + * parameters. Every error that is returned by the error callback represents a + * mistake in your plugin that you should fix. Error callbacks are not used to + * report expected run-time problems (e.g. disk I/O errors). + * + * The intention is for you to install the error callback during debug + * sections and put a break-point inside your callback. This will cause you to + * break into the debugger from within the SDK at the point in your plugin + * where you made an illegal call. + * + * Installing an error callback may activate error checking code that would + * not normally run, and this may adversely affect performance, so do not + * leave error callbacks installed in shipping plugins. Since the only useful + * response to an error is to change code, error callbacks are not useful "in + * the field". + * + */ +XPLM_API void XPLMSetErrorCallback( + XPLMError_f inCallback); +#endif /* XPLM200 */ + +/* + * XPLMDebugString + * + * This routine outputs a C-style string to the Log.txt file. The file is + * immediately flushed so you will not lose data. (This does cause a + * performance penalty.) + * + * Please do *not* leave routine diagnostic logging enabled in your shipping + * plugin. The X-Plane Log file is shared by X-Plane and every plugin in the + * system, and plugins that (when functioning normally) print verbose log + * output make it difficult for developers to find error conditions from other + * parts of the system. + * + */ +XPLM_API void XPLMDebugString( + const char * inString); + +/* + * XPLMSpeakString + * + * This function displays the string in a translucent overlay over the current + * display and also speaks the string if text-to-speech is enabled. The string + * is spoken asynchronously, this function returns immediately. This function + * may not speak or print depending on user preferences. + * + */ +XPLM_API void XPLMSpeakString( + const char * inString); + +/* + * XPLMGetVirtualKeyDescription + * + * Given a virtual key code (as defined in XPLMDefs.h) this routine returns a + * human-readable string describing the character. This routine is provided + * for showing users what keyboard mappings they have set up. The string may + * read 'unknown' or be a blank or NULL string if the virtual key is unknown. + * + */ +XPLM_API const char * XPLMGetVirtualKeyDescription( + char inVirtualKey); + +/* + * XPLMReloadScenery + * + * XPLMReloadScenery reloads the current set of scenery. You can use this + * function in two typical ways: simply call it to reload the scenery, picking + * up any new installed scenery, .env files, etc. from disk. Or, change the + * lat/ref and lon/ref data refs and then call this function to shift the + * scenery environment. This routine is equivalent to picking "reload + * scenery" from the developer menu. + * + */ +XPLM_API void XPLMReloadScenery(void); + +#if defined(XPLM200) +/*************************************************************************** + * X-PLANE COMMAND MANAGEMENT + ***************************************************************************/ +/* + * The command management APIs let plugins interact with the command-system in + * X-Plane, the abstraction behind keyboard presses and joystick buttons. This + * API lets you create new commands and modify the behavior (or get + * notification) of existing ones. + * + * X-Plane Command Phases + * ---------------------- + * + * X-Plane commands are not instantaneous; they operate over a duration. + * (Think of a joystick button press - you can press, hold down, and then + * release the joystick button; X-Plane commands model this entire process.) + * + * An X-Plane command consists of three phases: a beginning, continuous + * repetition, and an ending. The command may be repeated zero times in its + * duration, followed by one command ending. Command begin and end messges are + * balanced, but a command may be bound to more than one event source (e.g. a + * keyboard key and a joystick button), in which case you may receive a second + * begin during before any end). + * + * When you issue commands in the plugin system, you *must* balance every call + * to XPLMCommandBegin with a call to XPLMCommandEnd with the same command + * reference. + * + * Command Behavior Modification + * ----------------------------- + * + * You can register a callback to handle a command either before or after + * X-Plane does; if you receive the command before X-Plane you have the option + * to either let X-Plane handle the command or hide the command from X-Plane. + * This lets plugins both augment commands and replace them. + * + * If you register for an existing command, be sure that you are *consistent* + * in letting X-Plane handle or not handle the command; you are responsible + * for passing a *balanced* number of begin and end messages to X-Plane. (E.g. + * it is not legal to pass all the begin messages to X-Plane but hide all the + * end messages). + * + */ + + +/* + * XPLMCommandPhase + * + * The phases of a command. + * + */ +enum { + /* The command is being started. */ + xplm_CommandBegin = 0, + + /* The command is continuing to execute. */ + xplm_CommandContinue = 1, + + /* The command has ended. */ + xplm_CommandEnd = 2, + + +}; +typedef int XPLMCommandPhase; + +/* + * XPLMCommandRef + * + * A command ref is an opaque identifier for an X-Plane command. Command + * references stay the same for the life of your plugin but not between + * executions of X-Plane. Command refs are used to execute commands, create + * commands, and create callbacks for particular commands. + * + * Note that a command is not "owned" by a particular plugin. Since many + * plugins may participate in a command's execution, the command does not go + * away if the plugin that created it is unloaded. + * + */ +typedef void * XPLMCommandRef; + +/* + * XPLMCommandCallback_f + * + * A command callback is a function in your plugin that is called when a + * command is pressed. Your callback receives the command reference for the + * particular command, the phase of the command that is executing, and a + * reference pointer that you specify when registering the callback. + * + * Your command handler should return 1 to let processing of the command + * continue to other plugins and X-Plane, or 0 to halt processing, potentially + * bypassing X-Plane code. + * + */ +typedef int (* XPLMCommandCallback_f)( + XPLMCommandRef inCommand, + XPLMCommandPhase inPhase, + void * inRefcon); + +/* + * XPLMFindCommand + * + * XPLMFindCommand looks up a command by name, and returns its command + * reference or NULL if the command does not exist. + * + */ +XPLM_API XPLMCommandRef XPLMFindCommand( + const char * inName); + +/* + * XPLMCommandBegin + * + * XPLMCommandBegin starts the execution of a command, specified by its + * command reference. The command is "held down" until XPLMCommandEnd is + * called. You must balance each XPLMCommandBegin call with an XPLMCommandEnd + * call. + * + */ +XPLM_API void XPLMCommandBegin( + XPLMCommandRef inCommand); + +/* + * XPLMCommandEnd + * + * XPLMCommandEnd ends the execution of a given command that was started with + * XPLMCommandBegin. You must not issue XPLMCommandEnd for a command you did + * not begin. + * + */ +XPLM_API void XPLMCommandEnd( + XPLMCommandRef inCommand); + +/* + * XPLMCommandOnce + * + * This executes a given command momentarily, that is, the command begins and + * ends immediately. This is the equivalent of calling XPLMCommandBegin() and + * XPLMCommandEnd() back ot back. + * + */ +XPLM_API void XPLMCommandOnce( + XPLMCommandRef inCommand); + +/* + * XPLMCreateCommand + * + * XPLMCreateCommand creates a new command for a given string. If the command + * already exists, the existing command reference is returned. The description + * may appear in user interface contexts, such as the joystick configuration + * screen. + * + */ +XPLM_API XPLMCommandRef XPLMCreateCommand( + const char * inName, + const char * inDescription); + +/* + * XPLMRegisterCommandHandler + * + * XPLMRegisterCommandHandler registers a callback to be called when a command + * is executed. You provide a callback with a reference pointer. + * + * If inBefore is true, your command handler callback will be executed before + * X-Plane executes the command, and returning 0 from your callback will + * disable X-Plane's processing of the command. If inBefore is false, your + * callback will run after X-Plane. (You can register a single callback both + * before and after a command.) + * + */ +XPLM_API void XPLMRegisterCommandHandler( + XPLMCommandRef inComand, + XPLMCommandCallback_f inHandler, + int inBefore, + void * inRefcon); + +/* + * XPLMUnregisterCommandHandler + * + * XPLMUnregisterCommandHandler removes a command callback registered with + * XPLMRegisterCommandHandler. + * + */ +XPLM_API void XPLMUnregisterCommandHandler( + XPLMCommandRef inComand, + XPLMCommandCallback_f inHandler, + int inBefore, + void * inRefcon); + +#endif /* XPLM200 */ +#if defined(XPLM_DEPRECATED) +/*************************************************************************** + * X-PLANE USER INTERACTION + ***************************************************************************/ +/* + * WARNING: The legacy user interaction API is deprecated; while it was the + * only way to run commands in X-Plane 6,7 and 8, it is obsolete, and was + * replaced by the command system API in X-Plane 9. You should not use this + * API; replace any of the calls below with XPLMCommand invocations based on + * persistent command strings. The documentation that follows is for historic + * reference only. + * + * The legacy user interaction APIs let you simulate commands the user can do + * with a joystick, keyboard etc. Note that it is generally safer for future + * compatibility to use one of these commands than to manipulate the + * underlying sim data. + * + */ + + +/* + * XPLMCommandKeyID + * + * These enums represent all the keystrokes available within X-Plane. They can + * be sent to X-Plane directly. For example, you can reverse thrust using + * these enumerations. + * + */ +enum { + xplm_key_pause=0, + xplm_key_revthrust, + xplm_key_jettison, + xplm_key_brakesreg, + xplm_key_brakesmax, + xplm_key_gear, + xplm_key_timedn, + xplm_key_timeup, + xplm_key_fadec, + xplm_key_otto_dis, + xplm_key_otto_atr, + xplm_key_otto_asi, + xplm_key_otto_hdg, + xplm_key_otto_gps, + xplm_key_otto_lev, + xplm_key_otto_hnav, + xplm_key_otto_alt, + xplm_key_otto_vvi, + xplm_key_otto_vnav, + xplm_key_otto_nav1, + xplm_key_otto_nav2, + xplm_key_targ_dn, + xplm_key_targ_up, + xplm_key_hdgdn, + xplm_key_hdgup, + xplm_key_barodn, + xplm_key_baroup, + xplm_key_obs1dn, + xplm_key_obs1up, + xplm_key_obs2dn, + xplm_key_obs2up, + xplm_key_com1_1, + xplm_key_com1_2, + xplm_key_com1_3, + xplm_key_com1_4, + xplm_key_nav1_1, + xplm_key_nav1_2, + xplm_key_nav1_3, + xplm_key_nav1_4, + xplm_key_com2_1, + xplm_key_com2_2, + xplm_key_com2_3, + xplm_key_com2_4, + xplm_key_nav2_1, + xplm_key_nav2_2, + xplm_key_nav2_3, + xplm_key_nav2_4, + xplm_key_adf_1, + xplm_key_adf_2, + xplm_key_adf_3, + xplm_key_adf_4, + xplm_key_adf_5, + xplm_key_adf_6, + xplm_key_transpon_1, + xplm_key_transpon_2, + xplm_key_transpon_3, + xplm_key_transpon_4, + xplm_key_transpon_5, + xplm_key_transpon_6, + xplm_key_transpon_7, + xplm_key_transpon_8, + xplm_key_flapsup, + xplm_key_flapsdn, + xplm_key_cheatoff, + xplm_key_cheaton, + xplm_key_sbrkoff, + xplm_key_sbrkon, + xplm_key_ailtrimL, + xplm_key_ailtrimR, + xplm_key_rudtrimL, + xplm_key_rudtrimR, + xplm_key_elvtrimD, + xplm_key_elvtrimU, + xplm_key_forward, + xplm_key_down, + xplm_key_left, + xplm_key_right, + xplm_key_back, + xplm_key_tower, + xplm_key_runway, + xplm_key_chase, + xplm_key_free1, + xplm_key_free2, + xplm_key_spot, + xplm_key_fullscrn1, + xplm_key_fullscrn2, + xplm_key_tanspan, + xplm_key_smoke, + xplm_key_map, + xplm_key_zoomin, + xplm_key_zoomout, + xplm_key_cycledump, + xplm_key_replay, + xplm_key_tranID, + xplm_key_max +}; +typedef int XPLMCommandKeyID; + +/* + * XPLMCommandButtonID + * + * These are enumerations for all of the things you can do with a joystick + * button in X-Plane. They currently match the buttons menu in the equipment + * setup dialog, but these enums will be stable even if they change in + * X-Plane. + * + */ +enum { + xplm_joy_nothing=0, + xplm_joy_start_all, + xplm_joy_start_0, + xplm_joy_start_1, + xplm_joy_start_2, + xplm_joy_start_3, + xplm_joy_start_4, + xplm_joy_start_5, + xplm_joy_start_6, + xplm_joy_start_7, + xplm_joy_throt_up, + xplm_joy_throt_dn, + xplm_joy_prop_up, + xplm_joy_prop_dn, + xplm_joy_mixt_up, + xplm_joy_mixt_dn, + xplm_joy_carb_tog, + xplm_joy_carb_on, + xplm_joy_carb_off, + xplm_joy_trev, + xplm_joy_trm_up, + xplm_joy_trm_dn, + xplm_joy_rot_trm_up, + xplm_joy_rot_trm_dn, + xplm_joy_rud_lft, + xplm_joy_rud_cntr, + xplm_joy_rud_rgt, + xplm_joy_ail_lft, + xplm_joy_ail_cntr, + xplm_joy_ail_rgt, + xplm_joy_B_rud_lft, + xplm_joy_B_rud_rgt, + xplm_joy_look_up, + xplm_joy_look_dn, + xplm_joy_look_lft, + xplm_joy_look_rgt, + xplm_joy_glance_l, + xplm_joy_glance_r, + xplm_joy_v_fnh, + xplm_joy_v_fwh, + xplm_joy_v_tra, + xplm_joy_v_twr, + xplm_joy_v_run, + xplm_joy_v_cha, + xplm_joy_v_fr1, + xplm_joy_v_fr2, + xplm_joy_v_spo, + xplm_joy_flapsup, + xplm_joy_flapsdn, + xplm_joy_vctswpfwd, + xplm_joy_vctswpaft, + xplm_joy_gear_tog, + xplm_joy_gear_up, + xplm_joy_gear_down, + xplm_joy_lft_brake, + xplm_joy_rgt_brake, + xplm_joy_brakesREG, + xplm_joy_brakesMAX, + xplm_joy_speedbrake, + xplm_joy_ott_dis, + xplm_joy_ott_atr, + xplm_joy_ott_asi, + xplm_joy_ott_hdg, + xplm_joy_ott_alt, + xplm_joy_ott_vvi, + xplm_joy_tim_start, + xplm_joy_tim_reset, + xplm_joy_ecam_up, + xplm_joy_ecam_dn, + xplm_joy_fadec, + xplm_joy_yaw_damp, + xplm_joy_art_stab, + xplm_joy_chute, + xplm_joy_JATO, + xplm_joy_arrest, + xplm_joy_jettison, + xplm_joy_fuel_dump, + xplm_joy_puffsmoke, + xplm_joy_prerotate, + xplm_joy_UL_prerot, + xplm_joy_UL_collec, + xplm_joy_TOGA, + xplm_joy_shutdown, + xplm_joy_con_atc, + xplm_joy_fail_now, + xplm_joy_pause, + xplm_joy_rock_up, + xplm_joy_rock_dn, + xplm_joy_rock_lft, + xplm_joy_rock_rgt, + xplm_joy_rock_for, + xplm_joy_rock_aft, + xplm_joy_idle_hilo, + xplm_joy_lanlights, + xplm_joy_max +}; +typedef int XPLMCommandButtonID; + +/* + * XPLMSimulateKeyPress + * + * This function simulates a key being pressed for X-Plane. The keystroke goes + * directly to X-Plane; it is never sent to any plug-ins. However, since this + * is a raw key stroke it may be mapped by the keys file or enter text into a + * field. + * + * Deprecated: use XPLMCommandOnce + * + */ +XPLM_API void XPLMSimulateKeyPress( + int inKeyType, + int inKey); + +/* + * XPLMCommandKeyStroke + * + * This routine simulates a command-key stroke. However, the keys are done by + * function, not by actual letter, so this function works even if the user has + * remapped their keyboard. Examples of things you might do with this include + * pausing the simulator. + * + * Deprecated: use XPLMCommandOnce + * + */ +XPLM_API void XPLMCommandKeyStroke( + XPLMCommandKeyID inKey); + +/* + * XPLMCommandButtonPress + * + * This function simulates any of the actions that might be taken by pressing + * a joystick button. However, this lets you call the command directly rather + * than have to know which button is mapped where. Important: you must release + * each button you press. The APIs are separate so that you can 'hold down' a + * button for a fixed amount of time. + * + * Deprecated: use XPLMCommandBegin. + * + */ +XPLM_API void XPLMCommandButtonPress( + XPLMCommandButtonID inButton); + +/* + * XPLMCommandButtonRelease + * + * This function simulates any of the actions that might be taken by pressing + * a joystick button. See XPLMCommandButtonPress. + * + * Deprecated: use XPLMCommandEnd. + * + */ +XPLM_API void XPLMCommandButtonRelease( + XPLMCommandButtonID inButton); + +#endif /* XPLM_DEPRECATED */ +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/Delphi/Widgets/XPStandardWidgets.pas b/XPLPro_Plugin_Source/SDK/Delphi/Widgets/XPStandardWidgets.pas new file mode 100644 index 0000000..d77f383 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/Delphi/Widgets/XPStandardWidgets.pas @@ -0,0 +1,470 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPStandardWidgets; +INTERFACE +{ + ## THEORY OF OPERATION + + The standard widgets are widgets built into the widgets library. While you + can gain access to the widget function that drives them, you generally use + them by calling XPCreateWidget and then listening for special messages, + etc. + + The standard widgets often send mesages to themselves when the user + performs an event; these messages are sent up the widget hierarchy until + they are handled. So you can add a widget proc directly to a push button + (for example) to intercept the message when it is clicked, or you can put + one widget proc on a window for all of the push buttons in the window. Most + of these messages contain the original widget ID as a parameter so you can + know which widget is messaging no matter who it is sent to. +} + +USES + XPWidgetDefs; + {$A4} +{___________________________________________________________________________ + * MAIN WINDOW + ___________________________________________________________________________} +{ + The main window widget class provides a "window" as the user knows it. + These windows are dragable and can be selected. Use them to create floating + windows and non-modal dialogs. +} + + +CONST + xpWidgetClass_MainWindow = 1; + + { + Main Window Type Values + + These type values are used to control the appearance of a main window. + } + { The standard main window; pin stripes on XP7, metal frame on XP 6. } + xpMainWindowStyle_MainWindow = 0 +; + { A translucent dark gray window, like the one ATC messages appear in. } + xpMainWindowStyle_Translucent = 1 +; + + { + Main Window Properties + } + { This property specifies the type of window. Set to one of the main window } + { types above. } + xpProperty_MainWindowType = 1100 +; + { This property specifies whether the main window has close boxes in its } + { corners. } + xpProperty_MainWindowHasCloseBoxes = 1200 +; + + { + MainWindow Messages + } + { This message is sent when the close buttons are pressed for your window. } + xpMessage_CloseButtonPushed = 1200 +; + +{___________________________________________________________________________ + * SUB WINDOW + ___________________________________________________________________________} +{ + X-Plane dialogs are divided into separate areas; the sub window widgets + allow you to make these areas. Create one main window and place several + subwindows inside it. Then place your controls inside the subwindows. +} + + +CONST + xpWidgetClass_SubWindow = 2; + + { + SubWindow Type Values + + These values control the appearance of the subwindow. + } + { A panel that sits inside a main window. } + xpSubWindowStyle_SubWindow = 0 +; + { A screen that sits inside a panel for showing text information. } + xpSubWindowStyle_Screen = 2 +; + { A list view for scrolling lists. } + xpSubWindowStyle_ListView = 3 +; + + { + SubWindow Properties + } + { This property specifies the type of window. Set to one of the subwindow } + { types above. } + xpProperty_SubWindowType = 1200 +; + +{___________________________________________________________________________ + * BUTTON + ___________________________________________________________________________} +{ + The button class provides a number of different button styles and + behaviors, including push buttons, radio buttons, check boxes, etc. The + button label appears on or next to the button depending on the button's + appearance, or type. + + The button's behavior is a separate property that dictates who it hilights + and what kinds of messages it sends. Since behavior and type are different, + you can do strange things like make check boxes that act as push buttons or + push buttons with radio button behavior. + + In X-Plane 6 there were no check box graphics. The result is the following + behavior: in X-Plane + 6 all check box and radio buttons are round (radio-button style) buttons; + in X-Plane 7 they are all square (check-box style) buttons. In a future + version of X-Plane, the xpButtonBehavior enums will provide the correct + graphic (check box or radio button) giving the expected result. +} + + +CONST + xpWidgetClass_Button = 3; + + { + Button Types + + These define the visual appearance of buttons but not how they respond to + the mouse. + } + { This is a standard push button, like an 'OK' or 'Cancel' button in a dialog} + { box. } + xpPushButton = 0 +; + { A check box or radio button. Use this and the button behaviors below to } + { get the desired behavior. } + xpRadioButton = 1 +; + { A window close box. } + xpWindowCloseBox = 3 +; + { A small down arrow. } + xpLittleDownArrow = 5 +; + { A small up arrow. } + xpLittleUpArrow = 6 +; + + { + Button Behavior Values + + These define how the button responds to mouse clicks. + } + { Standard push button behavior. The button hilites while the mouse is } + { clicked over it and unhilites when the mouse is moved outside of it or } + { released. If the mouse is released over the button, the } + { xpMsg_PushButtonPressed message is sent. } + xpButtonBehaviorPushButton = 0 +; + { Check box behavior. The button immediately toggles its value when the mouse} + { is clicked and sends out a xpMsg_ButtonStateChanged message. } + xpButtonBehaviorCheckBox = 1 +; + { Radio button behavior. The button immediately sets its state to one and } + { sends out a xpMsg_ButtonStateChanged message if it was not already set to } + { one. You must turn off other radio buttons in a group in your code. } + xpButtonBehaviorRadioButton = 2 +; + + { + Button Properties + } + { This property sets the visual type of button. Use one of the button types } + { above. } + xpProperty_ButtonType = 1300 +; + { This property sets the button's behavior. Use one of the button behaviors } + { above. } + xpProperty_ButtonBehavior = 1301 +; + { This property tells whether a check box or radio button is "checked" or } + { not. Not used for push buttons. } + xpProperty_ButtonState = 1302 +; + + { + Button Messages + + These messages are sent by the button to itself and then up the widget + chain when the button is clicked. (You may intercept them by providing a + widget handler for the button itself or by providing a handler in a parent + widget.) + } + { This message is sent when the user completes a click and release in a } + { button with push button behavior. Parameter one of the message is the } + { widget ID of the button. This message is dispatched up the widget } + { hierarchy. } + xpMsg_PushButtonPressed = 1300 +; + { This message is sent when a button is clicked that has radio button or } + { check box behavior and its value changes. (Note that if the value changes } + { by setting a property you do not receive this message!) Parameter one is } + { the widget ID of the button, parameter 2 is the new state value, either } + { zero or one. This message is dispatched up the widget hierarchy. } + xpMsg_ButtonStateChanged = 1301 +; + +{___________________________________________________________________________ + * TEXT FIELD + ___________________________________________________________________________} +{ + The text field widget provides an editable text field including mouse + selection and keyboard navigation. The contents of the text field are its + descriptor. (The descriptor changes as the user types.) + + The text field can have a number of types, that effect the visual layout of + the text field. The text field sends messages to itself so you may control + its behavior. + + If you need to filter keystrokes, add a new handler and intercept the key + press message. Since key presses are passed by pointer, you can modify the + keystroke and pass it through to the text field widget. + + WARNING: in X-Plane before 7.10 (including 6.70) null characters could + crash X-Plane. To prevent this, wrap this object with a filter function + (more instructions can be found on the SDK website). +} + + +CONST + xpWidgetClass_TextField = 4; + + { + Text Field Type Values + + These control the look of the text field. + } + { A field for text entry. } + xpTextEntryField = 0 +; + { A transparent text field. The user can type and the text is drawn, but no } + { background is drawn. You can draw your own background by adding a widget } + { handler and prehandling the draw message. } + xpTextTransparent = 3 +; + { A translucent edit field, dark gray. } + xpTextTranslucent = 4 +; + + { + Text Field Properties + } + { This is the character position the selection starts at, zero based. If it } + { is the same as the end insertion point, the insertion point is not a } + { selection. } + xpProperty_EditFieldSelStart = 1400 +; + { This is the character position of the end of the selection. } + xpProperty_EditFieldSelEnd = 1401 +; + { This is the character position a drag was started at if the user is } + { dragging to select text, or -1 if a drag is not in progress. } + xpProperty_EditFieldSelDragStart = 1402 +; + { This is the type of text field to display, from the above list. } + xpProperty_TextFieldType = 1403 +; + { Set this property to 1 to password protect the field. Characters will be } + { drawn as *s even though the descriptor will contain plain-text. } + xpProperty_PasswordMode = 1404 +; + { The max number of characters you can enter, if limited. Zero means } + { unlimited. } + xpProperty_MaxCharacters = 1405 +; + { The first visible character on the left. This effectively scrolls the text} + { field. } + xpProperty_ScrollPosition = 1406 +; + { The font to draw the field's text with. (An XPLMFontID.) } + xpProperty_Font = 1407 +; + { This is the active side of the insert selection. (Internal) } + xpProperty_ActiveEditSide = 1408 +; + + { + Text Field Messages + } + { The text field sends this message to itself when its text changes. It sends} + { the message up the call chain; param1 is the text field's widget ID. } + xpMsg_TextFieldChanged = 1400 +; + +{___________________________________________________________________________ + * SCROLL BAR + ___________________________________________________________________________} +{ + A standard scroll bar or slider control. The scroll bar has a minimum, + maximum and current value that is updated when the user drags it. The + scroll bar sends continuous messages as it is dragged. +} + + +CONST + xpWidgetClass_ScrollBar = 5; + + { + Scroll Bar Type Values + + This defines how the scroll bar looks. + } + { A standard X-Plane scroll bar (with arrows on the ends). } + xpScrollBarTypeScrollBar = 0 +; + { A slider, no arrows. } + xpScrollBarTypeSlider = 1 +; + + { + Scroll Bar Properties + } + { The current position of the thumb (in between the min and max, inclusive) } + xpProperty_ScrollBarSliderPosition = 1500 +; + { The value the scroll bar has when the thumb is in the lowest position. } + xpProperty_ScrollBarMin = 1501 +; + { The value the scroll bar has when the thumb is in the highest position. } + xpProperty_ScrollBarMax = 1502 +; + { How many units to move the scroll bar when clicking next to the thumb. The } + { scroll bar always moves one unit when the arrows are clicked. } + xpProperty_ScrollBarPageAmount = 1503 +; + { The type of scrollbar from the enums above. } + xpProperty_ScrollBarType = 1504 +; + { Used internally. } + xpProperty_ScrollBarSlop = 1505 +; + + { + Scroll Bar Messages + } + { The scroll bar sends this message when the slider position changes. It } + { sends the message up the call chain; param1 is the Scroll Bar widget ID. } + xpMsg_ScrollBarSliderPositionChanged = 1500 +; + +{___________________________________________________________________________ + * CAPTION + ___________________________________________________________________________} +{ + A caption is a simple widget that shows its descriptor as a string, useful + for labeling parts of a window. It always shows its descriptor as its + string and is otherwise transparent. +} + + +CONST + xpWidgetClass_Caption = 6; + + { + Caption Properties + } + { This property specifies whether the caption is lit; use lit captions } + { against screens. } + xpProperty_CaptionLit = 1600 +; + +{___________________________________________________________________________ + * GENERAL GRAPHICS + ___________________________________________________________________________} +{ + The general graphics widget can show one of many icons available from + X-Plane. +} + + +CONST + xpWidgetClass_GeneralGraphics = 7; + + { + General Graphics Types Values + + These define the icon for the general graphics. + } + xpShip = 4 +; + xpILSGlideScope = 5 +; + xpMarkerLeft = 6 +; + xp_Airport = 7 +; + xpNDB = 8 +; + xpVOR = 9 +; + xpRadioTower = 10 +; + xpAircraftCarrier = 11 +; + xpFire = 12 +; + xpMarkerRight = 13 +; + xpCustomObject = 14 +; + xpCoolingTower = 15 +; + xpSmokeStack = 16 +; + xpBuilding = 17 +; + xpPowerLine = 18 +; + xpVORWithCompassRose = 19 +; + xpOilPlatform = 21 +; + xpOilPlatformSmall = 22 +; + xpWayPoint = 23 +; + + { + General Graphics Properties + } + { This property controls the type of icon that is drawn. } + xpProperty_GeneralGraphicsType = 1700 +; + +{___________________________________________________________________________ + * PROGRESS INDICATOR + ___________________________________________________________________________} +{ + This widget implements a progress indicator as seen when X-Plane starts up. +} + +CONST + xpWidgetClass_Progress = 8; + + { + Progress Indicator Properties + } + { This is the current value of the progress indicator. } + xpProperty_ProgressPosition = 1800 +; + { This is the minimum value, equivalent to 0% filled. } + xpProperty_ProgressMin = 1801 +; + { This is the maximum value, equivalent to 100% filled. } + xpProperty_ProgressMax = 1802 +; + + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/Delphi/Widgets/XPUIGraphics.pas b/XPLPro_Plugin_Source/SDK/Delphi/Widgets/XPUIGraphics.pas new file mode 100644 index 0000000..65e0636 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/Delphi/Widgets/XPUIGraphics.pas @@ -0,0 +1,342 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPUIGraphics; +INTERFACE + +USES + XPWidgetDefs; + {$A4} +{___________________________________________________________________________ + * UI GRAPHICS + ___________________________________________________________________________} + + { + XPWindowStyle + + There are a few built-in window styles in X-Plane that you can use. + + Note that X-Plane 6 does not offer real shadow-compositing; you must make + sure to put a window on top of another window of the right style to the + shadows work, etc. This applies to elements with insets and shadows. The + rules are: + + Sub windows must go on top of main windows, and screens and list views on + top of subwindows. Only help and main windows can be over the main screen. + + With X-Plane 7 any window or element may be placed over any other element. + + Some windows are scaled by stretching, some by repeating. The drawing + routines know which scaling method to use. The list view cannot be rescaled + in X-Plane 6 because it has both a repeating pattern and a gradient in one + element. All other elements can be rescaled. + } +TYPE + XPWindowStyle = ( + { An LCD screen that shows help. } + xpWindow_Help = 0 + + { A dialog box window. } + ,xpWindow_MainWindow = 1 + + { A panel or frame within a dialog box window. } + ,xpWindow_SubWindow = 2 + + { An LCD screen within a panel to hold text displays. } + ,xpWindow_Screen = 4 + + { A list view within a panel for scrolling file names, etc. } + ,xpWindow_ListView = 5 + + ); + PXPWindowStyle = ^XPWindowStyle; + + { + XPDrawWindow + + This routine draws a window of the given dimensions at the given offset on + the virtual screen in a given style. The window is automatically scaled as + appropriate using a bitmap scaling technique (scaling or repeating) as + appropriate to the style. + } + PROCEDURE XPDrawWindow( + inX1 : Integer; + inY1 : Integer; + inX2 : Integer; + inY2 : Integer; + inStyle : XPWindowStyle); + cdecl; external XPWIDGETS.DLL; + + { + XPGetWindowDefaultDimensions + + This routine returns the default dimensions for a window. Output is either + a minimum or fixed value depending on whether the window is scalable. + } + PROCEDURE XPGetWindowDefaultDimensions( + inStyle : XPWindowStyle; + outWidth : PInteger; { Can be nil } + outHeight : PInteger); { Can be nil } + cdecl; external XPWIDGETS.DLL; + + { + XPElementStyle + + Elements are individually drawable UI things like push buttons, etc. The + style defines what kind of element you are drawing. Elements can be + stretched in one or two dimensions (depending on the element). Some + elements can be lit. + + In X-Plane 6 some elements must be drawn over metal. Some are scalable and + some are not. Any element can be drawn anywhere in X-Plane 7. + + Scalable Axis Required Background + } +TYPE + XPElementStyle = ( + { x metal } + xpElement_TextField = 6 + + { none metal } + ,xpElement_CheckBox = 9 + + { none metal } + ,xpElement_CheckBoxLit = 10 + + { none window header } + ,xpElement_WindowCloseBox = 14 + + { none window header } + ,xpElement_WindowCloseBoxPressed = 15 + + { x metal } + ,xpElement_PushButton = 16 + + { x metal } + ,xpElement_PushButtonLit = 17 + + { none any } + ,xpElement_OilPlatform = 24 + + { none any } + ,xpElement_OilPlatformSmall = 25 + + { none any } + ,xpElement_Ship = 26 + + { none any } + ,xpElement_ILSGlideScope = 27 + + { none any } + ,xpElement_MarkerLeft = 28 + + { none any } + ,xpElement_Airport = 29 + + { none any } + ,xpElement_Waypoint = 30 + + { none any } + ,xpElement_NDB = 31 + + { none any } + ,xpElement_VOR = 32 + + { none any } + ,xpElement_RadioTower = 33 + + { none any } + ,xpElement_AircraftCarrier = 34 + + { none any } + ,xpElement_Fire = 35 + + { none any } + ,xpElement_MarkerRight = 36 + + { none any } + ,xpElement_CustomObject = 37 + + { none any } + ,xpElement_CoolingTower = 38 + + { none any } + ,xpElement_SmokeStack = 39 + + { none any } + ,xpElement_Building = 40 + + { none any } + ,xpElement_PowerLine = 41 + + { none metal } + ,xpElement_CopyButtons = 45 + + { none metal } + ,xpElement_CopyButtonsWithEditingGrid = 46 + + { x, y metal } + ,xpElement_EditingGrid = 47 + + { THIS CAN PROBABLY BE REMOVED } + ,xpElement_ScrollBar = 48 + + { none any } + ,xpElement_VORWithCompassRose = 49 + + { none metal } + ,xpElement_Zoomer = 51 + + { x, y metal } + ,xpElement_TextFieldMiddle = 52 + + { none metal } + ,xpElement_LittleDownArrow = 53 + + { none metal } + ,xpElement_LittleUpArrow = 54 + + { none metal } + ,xpElement_WindowDragBar = 61 + + { none metal } + ,xpElement_WindowDragBarSmooth = 62 + + ); + PXPElementStyle = ^XPElementStyle; + + { + XPDrawElement + + XPDrawElement draws a given element at an offset on the virtual screen in + set dimensions. + *Even* if the element is not scalable, it will be scaled if the width and + height do not match the preferred dimensions; it'll just look ugly. Pass + inLit to see the lit version of the element; if the element cannot be lit + this is ignored. + } + PROCEDURE XPDrawElement( + inX1 : Integer; + inY1 : Integer; + inX2 : Integer; + inY2 : Integer; + inStyle : XPElementStyle; + inLit : Integer); + cdecl; external XPWIDGETS.DLL; + + { + XPGetElementDefaultDimensions + + This routine returns the recommended or minimum dimensions of a given UI + element. outCanBeLit tells whether the element has both a lit and unlit + state. Pass `NULL` to not receive any of these parameters. + } + PROCEDURE XPGetElementDefaultDimensions( + inStyle : XPElementStyle; + outWidth : PInteger; { Can be nil } + outHeight : PInteger; { Can be nil } + outCanBeLit : PInteger); { Can be nil } + cdecl; external XPWIDGETS.DLL; + + { + XPTrackStyle + + A track is a UI element that displays a value vertically or horizontally. + X-Plane has three kinds of tracks: scroll bars, sliders, and progress bars. + Tracks can be displayed either horizontally or vertically; tracks will + choose their own layout based on the larger dimension of their dimensions + (e.g. they know if they are tall or wide). Sliders may be lit or unlit + (showing the user manipulating them). + + - ScrollBar: this is a standard scroll bar with arrows and a thumb to drag. + - Slider: this is a simple track with a ball in the middle that can be + slid. + - Progress: this is a progress indicator showing how a long task is going. + } +TYPE + XPTrackStyle = ( + { not over metal can be lit can be rotated } + xpTrack_ScrollBar = 0 + + { over metal can be lit can be rotated } + ,xpTrack_Slider = 1 + + { over metal cannot be lit cannot be rotated } + ,xpTrack_Progress = 2 + + ); + PXPTrackStyle = ^XPTrackStyle; + + { + XPDrawTrack + + This routine draws a track. You pass in the track dimensions and size; the + track picks the optimal orientation for these dimensions. Pass in the + track's minimum current and maximum values; the indicator will be + positioned appropriately. You can also specify whether the track is lit or + not. + } + PROCEDURE XPDrawTrack( + inX1 : Integer; + inY1 : Integer; + inX2 : Integer; + inY2 : Integer; + inMin : Integer; + inMax : Integer; + inValue : Integer; + inTrackStyle : XPTrackStyle; + inLit : Integer); + cdecl; external XPWIDGETS.DLL; + + { + XPGetTrackDefaultDimensions + + This routine returns a track's default smaller dimension; all tracks are + scalable in the larger dimension. It also returns whether a track can be + lit. + } + PROCEDURE XPGetTrackDefaultDimensions( + inStyle : XPTrackStyle; + outWidth : PInteger; + outCanBeLit : PInteger); + cdecl; external XPWIDGETS.DLL; + + { + XPGetTrackMetrics + + This routine returns the metrics of a track. If you want to write UI code + to manipulate a track, this routine helps you know where the mouse + locations are. For most other elements, the rectangle the element is drawn + in is enough information. However, the scrollbar drawing routine does some + automatic placement; this routine lets you know where things ended up. You + pass almost everything you would pass to the draw routine. You get out the + orientation, and other useful stuff. + + Besides orientation, you get five dimensions for the five parts of a + scrollbar, which are the down button, down area (area before the thumb), + the thumb, and the up area and button. For horizontal scrollers, the left + button decreases; for vertical scrollers, the top button decreases. + } + PROCEDURE XPGetTrackMetrics( + inX1 : Integer; + inY1 : Integer; + inX2 : Integer; + inY2 : Integer; + inMin : Integer; + inMax : Integer; + inValue : Integer; + inTrackStyle : XPTrackStyle; + outIsVertical : PInteger; + outDownBtnSize : PInteger; + outDownPageSize : PInteger; + outThumbSize : PInteger; + outUpPageSize : PInteger; + outUpBtnSize : PInteger); + cdecl; external XPWIDGETS.DLL; + + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/Delphi/Widgets/XPWidgetDefs.pas b/XPLPro_Plugin_Source/SDK/Delphi/Widgets/XPWidgetDefs.pas new file mode 100644 index 0000000..1cc342f --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/Delphi/Widgets/XPWidgetDefs.pas @@ -0,0 +1,427 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPWidgetDefs; +INTERFACE + +USES + XPLMDefs; + {$A4} +{___________________________________________________________________________ + * WIDGET DEFINITIONS + ___________________________________________________________________________} +{ + A widget is a call-back driven screen entity like a push-button, window, + text entry field, etc. + + Use the widget API to create widgets of various classes. You can nest them + into trees of widgets to create complex user interfaces. +} + + +TYPE + { + XPWidgetID + + A Widget ID is an opaque unique non-zero handle identifying your widget. + Use 0 to specify "no widget". This type is defined as wide enough to hold a + pointer. You receive a widget ID when you create a new widget and then use + that widget ID to further refer to the widget. + } + XPWidgetID = pointer; + PXPWidgetID = ^XPWidgetID; + + { + XPWidgetPropertyID + + Properties are values attached to instances of your widgets. A property is + identified by a 32-bit ID and its value is the width of a pointer. + + Each widget instance may have a property or not have it. When you set a + property on a widget for the first time, the property is added to the + widget; it then stays there for the life of the widget. + + Some property IDs are predefined by the widget package; you can make up + your own property IDs as well. + } + XPWidgetPropertyID = ( + { A window's refcon is an opaque value used by client code to find other data} + { based on it. } + xpProperty_Refcon = 0 + + { These properties are used by the utlities to implement dragging. } + ,xpProperty_Dragging = 1 + + ,xpProperty_DragXOff = 2 + + ,xpProperty_DragYOff = 3 + + { Is the widget hilited? (For widgets that support this kind of thing.) } + ,xpProperty_Hilited = 4 + + { Is there a C++ object attached to this widget? } + ,xpProperty_Object = 5 + + { If this property is 1, the widget package will use OpenGL to restrict } + { drawing to the Wiget's exposed rectangle. } + ,xpProperty_Clip = 6 + + { Is this widget enabled (for those that have a disabled state too)? } + ,xpProperty_Enabled = 7 + + { NOTE: Property IDs 1 - 999 are reserved for the widgets library. } + { } + { NOTE: Property IDs 1000 - 9999 are allocated to the standard widget classes} + { provided with the library. } + { } + { Properties 1000 - 1099 are for widget class 0, 1100 - 1199 for widget class} + { 1, etc. } + ,xpProperty_UserStart = 10000 + + ); + PXPWidgetPropertyID = ^XPWidgetPropertyID; + + { + XPMouseState_t + + When the mouse is clicked or dragged, a pointer to this structure is passed + to your widget function. + } + XPMouseState_t = RECORD + x : Integer; + y : Integer; + { Mouse Button number, left = 0 (right button not yet supported. } + button : Integer; +{$IFDEF XPLM200} + { Scroll wheel delta (button in this case would be the wheel axis number). } + delta : Integer; +{$ENDIF XPLM200} + END; + PXPMouseState_t = ^XPMouseState_t; + + { + XPKeyState_t + + When a key is pressed, a pointer to this struct is passed to your widget + function. + } + XPKeyState_t = RECORD + { The ASCII key that was pressed. WARNING: this may be 0 for some non-ASCII } + { key sequences. } + key : XPLMChar; + { The flags. Make sure to check this if you only want key-downs! } + flags : XPLMKeyFlags; + { The virtual key code for the key } + vkey : XPLMChar; + END; + PXPKeyState_t = ^XPKeyState_t; + + { + XPWidgetGeometryChange_t + + This structure contains the deltas for your widget's geometry when it + changes. + } + XPWidgetGeometryChange_t = RECORD + dx : Integer; + { +Y = the widget moved up } + dy : Integer; + dwidth : Integer; + dheight : Integer; + END; + PXPWidgetGeometryChange_t = ^XPWidgetGeometryChange_t; + + { + XPDispatchMode + + The dispatching modes describe how the widgets library sends out messages. + Currently there are three modes: + } + XPDispatchMode = ( + { The message will only be sent to the target widget. } + xpMode_Direct = 0 + + { The message is sent to the target widget, then up the chain of parents } + { until the message is handled or a parentless widget is reached. } + ,xpMode_UpChain = 1 + + { The message is sent to the target widget and then all of its children } + { recursively depth-first. } + ,xpMode_Recursive = 2 + + { The message is snet just to the target, but goes to every callback, even if} + { it is handled. } + ,xpMode_DirectAllCallbacks = 3 + + { The message is only sent to the very first handler even if it is not } + { accepted. (This is really only useful for some internal widget library } + { functions.) } + ,xpMode_Once = 4 + + ); + PXPDispatchMode = ^XPDispatchMode; + + { + XPWidgetClass + + Widget classes define predefined widget types. A widget class basically + specifies from a library the widget function to be used for the widget. + Most widgets can be made right from classes. + } + XPWidgetClass = Integer; + PXPWidgetClass = ^XPWidgetClass; + +CONST + { An unspecified widget class. Other widget classes are in } + { XPStandardWidgets.h } + xpWidgetClass_None = 0; + +{___________________________________________________________________________ + * WIDGET MESSAGES + ___________________________________________________________________________} + + { + XPWidgetMessage + + Widgets receive 32-bit messages indicating what action is to be taken or + notifications of events. The list of messages may be expanded. + } +TYPE + XPWidgetMessage = ( + { No message, should not be sent. } + xpMsg_None = 0 + + { The create message is sent once per widget that is created with your widget} + { function and once for any widget that has your widget function attached. } + { } + { Dispatching: Direct } + { } + { Param 1: 1 if you are being added as a subclass, 0 if the widget is first } + { being created. } + ,xpMsg_Create = 1 + + { The destroy message is sent once for each message that is destroyed that } + { has your widget function. } + { } + { Dispatching: Direct for all } + { } + { Param 1: 1 if being deleted by a recursive delete to the parent, 0 for } + { explicit deletion. } + ,xpMsg_Destroy = 2 + + { The paint message is sent to your widget to draw itself. The paint message } + { is the bare-bones message; in response you must draw yourself, draw your } + { children, set up clipping and culling, check for visibility, etc. If you } + { don't want to do all of this, ignore the paint message and a draw message } + { (see below) will be sent to you. } + { } + { Dispatching: Direct } + ,xpMsg_Paint = 3 + + { The draw message is sent to your widget when it is time to draw yourself. } + { OpenGL will be set up to draw in 2-d global screen coordinates, but you } + { should use the XPLM to set up OpenGL state. } + { } + { Dispatching: Direct } + ,xpMsg_Draw = 4 + + { The key press message is sent once per key that is pressed. The first } + { parameter is the type of key code (integer or char) and the second is the } + { code itself. By handling this event, you consume the key stroke. } + { } + { Handling this message 'consumes' the keystroke; not handling it passes it } + { to your parent widget. } + { } + { Dispatching: Up Chain } + { } + { Param 1: A pointer to an XPKeyState_t structure with the keystroke. } + ,xpMsg_KeyPress = 5 + + { Keyboard focus is being given to you. By handling this message you accept } + { keyboard focus. The first parameter will be one if a child of yours gave up} + { focus to you, 0 if someone set focus on you explicitly. } + { } + { Handling this message accepts focus; not handling refuses focus. } + { } + { Dispatching: direct } + { } + { Param 1: 1 if you are gaining focus because your child is giving it up, 0 } + { if someone is explicitly giving you focus. } + ,xpMsg_KeyTakeFocus = 6 + + { Keyboard focus is being taken away from you. The first parameter will be } + { one if you are losing focus because another widget is taking it, or 0 if } + { someone called the API to make you lose focus explicitly. } + { } + { Dispatching: Direct } + { } + { Param 1: 1 if focus is being taken by another widget, 0 if code requested } + { to remove focus. } + ,xpMsg_KeyLoseFocus = 7 + + { You receive one mousedown event per click with a mouse-state structure } + { pointed to by parameter 1, by accepting this you eat the click, otherwise } + { your parent gets it. You will not receive drag and mouse up messages if you} + { do not accept the down message. } + { } + { Handling this message consumes the mouse click, not handling it passes it } + { to the next widget. You can act 'transparent' as a window by never handling} + { moues clicks to certain areas. } + { } + { Dispatching: Up chain NOTE: Technically this is direct dispatched, but the } + { widgets library will shop it to each widget until one consumes the click, } + { making it effectively "up chain". } + { } + { Param 1: A pointer to an XPMouseState_t containing the mouse status. } + ,xpMsg_MouseDown = 8 + + { You receive a series of mouse drag messages (typically one per frame in the} + { sim) as the mouse is moved once you have accepted a mouse down message. } + { Parameter one points to a mouse-state structure describing the mouse } + { location. You will continue to receive these until the mouse button is } + { released. You may receive multiple mouse state messages with the same mouse} + { position. You will receive mouse drag events even if the mouse is dragged } + { out of your current or original bounds at the time of the mouse down. } + { } + { Dispatching: Direct } + { } + { Param 1: A pointer to an XPMouseState_t containing the mouse status. } + ,xpMsg_MouseDrag = 9 + + { The mouseup event is sent once when the mouse button is released after a } + { drag or click. You only receive this message if you accept the mouseDown } + { message. Parameter one points to a mouse state structure. } + { } + { Dispatching: Direct } + { } + { Param 1: A pointer to an XPMouseState_t containing the mouse status. } + ,xpMsg_MouseUp = 10 + + { Your geometry or a child's geometry is being changed. } + { } + { Dispatching: Up chain } + { } + { Param 1: The widget ID of the original reshaped target. } + { } + { Param 2: A pointer to a XPWidgetGeometryChange_t struct describing the } + { change. } + ,xpMsg_Reshape = 11 + + { Your exposed area has changed. } + { } + { Dispatching: Direct } + ,xpMsg_ExposedChanged = 12 + + { A child has been added to you. The child's ID is passed in parameter one. } + { } + { Dispatching: Direct } + { } + { Param 1: The Widget ID of the child being added. } + ,xpMsg_AcceptChild = 13 + + { A child has been removed from to you. The child's ID is passed in parameter} + { one. } + { } + { Dispatching: Direct } + { } + { Param 1: The Widget ID of the child being removed. } + ,xpMsg_LoseChild = 14 + + { You now have a new parent, or have no parent. The parent's ID is passed in,} + { or 0 for no parent. } + { } + { Dispatching: Direct } + { } + { Param 1: The Widget ID of your parent } + ,xpMsg_AcceptParent = 15 + + { You or a child has been shown. Note that this does not include you being } + { shown because your parent was shown, you were put in a new parent, your } + { root was shown, etc. } + { } + { Dispatching: Up chain } + { } + { Param 1: The widget ID of the shown widget. } + ,xpMsg_Shown = 16 + + { You have been hidden. See limitations above. } + { } + { Dispatching: Up chain } + { } + { Param 1: The widget ID of the hidden widget. } + ,xpMsg_Hidden = 17 + + { Your descriptor has changed. } + { } + { Dispatching: Direct } + ,xpMsg_DescriptorChanged = 18 + + { A property has changed. Param 1 contains the property ID. } + { } + { Dispatching: Direct } + { } + { Param 1: The Property ID being changed. } + { } + { Param 2: The new property value } + ,xpMsg_PropertyChanged = 19 + +{$IFDEF XPLM200} + { The mouse wheel has moved. } + { } + { Return 1 to consume the mouse wheel move, or 0 to pass the message to a } + { parent. Dispatching: Up chain } + { } + { Param 1: A pointer to an XPMouseState_t containing the mouse status. } + ,xpMsg_MouseWheel = 20 +{$ENDIF XPLM200} + +{$IFDEF XPLM200} + { The cursor is over your widget. If you consume this message, change the } + { XPLMCursorStatus value to indicate the desired result, with the same rules } + { as in XPLMDisplay.h. } + { } + { Return 1 to consume this message, 0 to pass it on. } + { } + { Dispatching: Up chain Param 1: A pointer to an XPMouseState_t struct } + { containing the mouse status. } + { } + { Param 2: A pointer to a XPLMCursorStatus - set this to the cursor result } + { you desire. } + ,xpMsg_CursorAdjust = 21 +{$ENDIF XPLM200} + + { NOTE: Message IDs 1000 - 9999 are allocated to the standard widget classes } + { provided with the library with 1000 - 1099 for widget class 0, 1100 - 1199 } + { for widget class 1, etc. Message IDs 10,000 and beyond are for plugin use. } + ,xpMsg_UserStart = 10000 + + ); + PXPWidgetMessage = ^XPWidgetMessage; + +{___________________________________________________________________________ + * WIDGET CALLBACK FUNCTION + ___________________________________________________________________________} + + { + XPWidgetFunc_t + + This function defines your custom widget's behavior. It will be called by + the widgets library to send messages to your widget. The message and widget + ID are passed in, as well as two ptr-width signed parameters whose meaning + varies with the message. Return 1 to indicate that you have processed the + message, 0 to indicate that you have not. For any message that is not + understood, return 0. + } +TYPE + XPWidgetFunc_t = FUNCTION( + inMessage : XPWidgetMessage; + inWidget : XPWidgetID; + inParam1 : intptr_t; + inParam2 : intptr_t) : Integer; cdecl; + + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/Delphi/Widgets/XPWidgetUtils.pas b/XPLPro_Plugin_Source/SDK/Delphi/Widgets/XPWidgetUtils.pas new file mode 100644 index 0000000..9621126 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/Delphi/Widgets/XPWidgetUtils.pas @@ -0,0 +1,197 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPWidgetUtils; +INTERFACE +{ + ## USAGE NOTES + + The XPWidgetUtils library contains useful functions that make writing and + using widgets less of a pain. + + One set of functions are the widget behavior functions. These functions + each add specific useful behaviors to widgets. They can be used in two + manners: + + 1. You can add a widget behavior function to a widget as a callback proc + using the XPAddWidgetCallback function. The widget will gain that + behavior. Remember that the last function you add has highest priority. + You can use this to change or augment the behavior of an existing + finished widget. + 2. You can call a widget function from inside your own widget function. + This allows you to include useful behaviors in custom-built widgets. A + number of the standard widgets get their behavior from this library. To + do this, call the behavior function from your function first. If it + returns 1, that means it handled the event and you don't need to; simply + return 1. +} + +USES + XPWidgetDefs; + {$A4} +{___________________________________________________________________________ + * GENERAL UTILITIES + ___________________________________________________________________________} + + + { + XPWidgetCreate_t + + This structure contains all of the parameters needed to create a wiget. It + is used with XPUCreateWidgets to create widgets in bulk from an array. All + parameters correspond to those of XPCreateWidget except for the container + index. + + If the container index is equal to the index of a widget in the array, the + widget in the array passed to XPUCreateWidgets is used as the parent of + this widget. Note that if you pass an index greater than your own position + in the array, the parent you are requesting will not exist yet. + + If the container index is NO_PARENT, the parent widget is specified as + NULL. If the container index is PARAM_PARENT, the widget passed into + XPUCreateWidgets is used. + } +TYPE + XPWidgetCreate_t = RECORD + left : Integer; + top : Integer; + right : Integer; + bottom : Integer; + visible : Integer; + descriptor : XPLMString; + { Whether ethis widget is a root wiget } + isRoot : Integer; + { The index of the widget to contain within, or a constant } + containerIndex : Integer; + widgetClass : XPWidgetClass; + END; + PXPWidgetCreate_t = ^XPWidgetCreate_t; + +CONST + NO_PARENT = -1; + + PARAM_PARENT = -2; + + + { + XPUCreateWidgets + + This function creates a series of widgets from a table (see + XPCreateWidget_t above). Pass in an array of widget creation structures and + an array of widget IDs that will receive each widget. + + Widget parents are specified by index into the created widget table, + allowing you to create nested widget structures. You can create multiple + widget trees in one table. Generally you should create widget trees from + the top down. + + You can also pass in a widget ID that will be used when the widget's parent + is listed as PARAM_PARENT; this allows you to embed widgets created with + XPUCreateWidgets in a widget created previously. + } + PROCEDURE XPUCreateWidgets( + inWidgetDefs : PXPWidgetCreate_t; + inCount : Integer; + inParamParent : XPWidgetID; + ioWidgets : PXPWidgetID); + cdecl; external XPWIDGETS.DLL; + + { + XPUMoveWidgetBy + + Simply moves a widget by an amount, +x = right, +y=up, without resizing the + widget. + } + PROCEDURE XPUMoveWidgetBy( + inWidget : XPWidgetID; + inDeltaX : Integer; + inDeltaY : Integer); + cdecl; external XPWIDGETS.DLL; + +{___________________________________________________________________________ + * LAYOUT MANAGERS + ___________________________________________________________________________} +{ + The layout managers are widget behavior functions for handling where + widgets move. Layout managers can be called from a widget function or + attached to a widget later. +} + + + { + XPUFixedLayout + + This function causes the widget to maintain its children in fixed position + relative to itself as it is resized. Use this on the top level 'window' + widget for your window. + } + FUNCTION XPUFixedLayout( + inMessage : XPWidgetMessage; + inWidget : XPWidgetID; + inParam1 : intptr_t; + inParam2 : intptr_t) : Integer; + cdecl; external XPWIDGETS.DLL; + +{___________________________________________________________________________ + * WIDGET PROC BEHAVIORS + ___________________________________________________________________________} +{ + These widget behavior functions add other useful behaviors to widgets. + These functions cannot be attached to a widget; they must be called from + your widget function. +} + + + { + XPUSelectIfNeeded + + This causes the widget to bring its window to the foreground if it is not + already. inEatClick specifies whether clicks in the background should be + consumed by bringin the window to the foreground. + } + FUNCTION XPUSelectIfNeeded( + inMessage : XPWidgetMessage; + inWidget : XPWidgetID; + inParam1 : intptr_t; + inParam2 : intptr_t; + inEatClick : Integer) : Integer; + cdecl; external XPWIDGETS.DLL; + + { + XPUDefocusKeyboard + + This causes a click in the widget to send keyboard focus back to X-Plane. + This stops editing of any text fields, etc. + } + FUNCTION XPUDefocusKeyboard( + inMessage : XPWidgetMessage; + inWidget : XPWidgetID; + inParam1 : intptr_t; + inParam2 : intptr_t; + inEatClick : Integer) : Integer; + cdecl; external XPWIDGETS.DLL; + + { + XPUDragWidget + + XPUDragWidget drags the widget in response to mouse clicks. Pass in not + only the event, but the global coordinates of the drag region, which might + be a sub-region of your widget (for example, a title bar). + } + FUNCTION XPUDragWidget( + inMessage : XPWidgetMessage; + inWidget : XPWidgetID; + inParam1 : intptr_t; + inParam2 : intptr_t; + inLeft : Integer; + inTop : Integer; + inRight : Integer; + inBottom : Integer) : Integer; + cdecl; external XPWIDGETS.DLL; + + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/Delphi/Widgets/XPWidgets.pas b/XPLPro_Plugin_Source/SDK/Delphi/Widgets/XPWidgets.pas new file mode 100644 index 0000000..46ae542 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/Delphi/Widgets/XPWidgets.pas @@ -0,0 +1,527 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPWidgets; +INTERFACE +{ + ## THEORY OF OPERATION AND NOTES + + Widgets are persistent view 'objects' for X-Plane. A widget is an object + referenced by its opaque handle (widget ID) and the APIs in this file. You + cannot access the widget's guts directly. Every Widget has the following + intrinsic data: + + - A bounding box defined in global screen coordinates with 0,0 in the + bottom left and +y = up, +x = right. + - A visible box, which is the intersection of the bounding box with the + widget's parents visible box. + - Zero or one parent widgets. (Always zero if the widget is a root widget. + - Zero or more child widgets. + - Whether the widget is a root. Root widgets are the top level plugin + windows. + - Whether the widget is visible. + - A text string descriptor, whose meaning varies from widget to widget. + - An arbitrary set of 32 bit integral properties defined by 32-bit integral + keys. This is how specific widgets store specific data. + - A list of widget callbacks proc that implements the widgets behaviors. + + The Widgets library sends messages to widgets to request specific behaviors + or notify the widget of things. + + Widgets may have more than one callback function, in which case messages + are sent to the most recently added callback function until the message is + handled. Messages may also be sent to parents or children; see the + XPWidgetDefs.h header file for the different widget message dispatching + functions. By adding a callback function to a window you can 'subclass' its + behavior. + + A set of standard widgets are provided that serve common UI purposes. You + can also customize or implement entirely custom widgets. + + Widgets are different than other view hierarchies (most notably Win32, + which they bear a striking resemblance to) in the following ways: + + - Not all behavior can be patched. State that is managed by the XPWidgets + DLL and not by individual widgets cannot be customized. + - All coordinates are in global screen coordinates. Coordinates are not + relative to an enclosing widget, nor are they relative to a display + window. + - Widget messages are always dispatched synchronously, and there is no + concept of scheduling an update or a dirty region. Messages originate + from X-Plane as the sim cycle goes by. Since X-Plane is constantly + redrawing, so are widgets; there is no need to mark a part of a widget as + 'needing redrawing' because redrawing happens frequently whether the + widget needs it or not. + - Any widget may be a 'root' widget, causing it to be drawn; there is no + relationship between widget class and rootness. Root widgets are + imlemented as XPLMDisply windows. +} + +USES + XPWidgetDefs, XPLMDisplay; + {$A4} +{___________________________________________________________________________ + * WIDGET CREATION AND MANAGEMENT + ___________________________________________________________________________} + + { + XPCreateWidget + + This function creates a new widget and returns the new widget's ID to you. + If the widget creation fails for some reason, it returns NULL. Widget + creation will fail either if you pass a bad class ID or if there is not + adequate memory. + + Input Parameters: + + - Top, left, bottom, and right in global screen coordinates defining the + widget's location on the screen. + - inVisible is 1 if the widget should be drawn, 0 to start the widget as + hidden. + - inDescriptor is a null terminated string that will become the widget's + descriptor. + - inIsRoot is 1 if this is going to be a root widget, 0 if it will not be. + - inContainer is the ID of this widget's container. It must be 0 for a root + widget. for a non-root widget, pass the widget ID of the widget to place + this widget within. If this widget is not going to start inside another + widget, pass 0; this new widget will then just be floating off in space + (and will not be drawn until it is placed in a widget. + - inClass is the class of the widget to draw. Use one of the predefined + class-IDs to create a standard widget. + + A note on widget embedding: a widget is only called (and will be drawn, + etc.) if it is placed within a widget that will be called. Root widgets are + always called. So it is possible to have whole chains of widgets that are + simply not called. You can preconstruct widget trees and then place them + into root widgets later to activate them if you wish. + } + FUNCTION XPCreateWidget( + inLeft : Integer; + inTop : Integer; + inRight : Integer; + inBottom : Integer; + inVisible : Integer; + inDescriptor : XPLMString; + inIsRoot : Integer; + inContainer : XPWidgetID; + inClass : XPWidgetClass) : XPWidgetID; + cdecl; external XPWIDGETS.DLL; + + { + XPCreateCustomWidget + + This function is the same as XPCreateWidget except that instead of passing + a class ID, you pass your widget callback function pointer defining the + widget. Use this function to define a custom widget. All parameters are the + same as XPCreateWidget, except that the widget class has been replaced with + the widget function. + } + FUNCTION XPCreateCustomWidget( + inLeft : Integer; + inTop : Integer; + inRight : Integer; + inBottom : Integer; + inVisible : Integer; + inDescriptor : XPLMString; + inIsRoot : Integer; + inContainer : XPWidgetID; + inCallback : XPWidgetFunc_t) : XPWidgetID; + cdecl; external XPWIDGETS.DLL; + + { + XPDestroyWidget + + This class destroys a widget. Pass in the ID of the widget to kill. If you + pass 1 for inDestroyChilren, the widget's children will be destroyed first, + then this widget will be destroyed. (Furthermore, the widget's children + will be destroyed with the inDestroyChildren flag set to 1, so the + destruction will recurse down the widget tree.) If you pass 0 for this + flag, the child widgets will simply end up with their parent set to 0. + } + PROCEDURE XPDestroyWidget( + inWidget : XPWidgetID; + inDestroyChildren : Integer); + cdecl; external XPWIDGETS.DLL; + + { + XPSendMessageToWidget + + This sends any message to a widget. You should probably not go around + simulating the predefined messages that the widgets library defines for + you. You may however define custom messages for your widgets and send them + with this method. + + This method supports several dispatching patterns; see XPDispatchMode for + more info. The function returns 1 if the message was handled, 0 if it was + not. + + For each widget that receives the message (see the dispatching modes), each + widget function from the most recently installed to the oldest one receives + the message in order until it is handled. + } + FUNCTION XPSendMessageToWidget( + inWidget : XPWidgetID; + inMessage : XPWidgetMessage; + inMode : XPDispatchMode; + inParam1 : intptr_t; + inParam2 : intptr_t) : Integer; + cdecl; external XPWIDGETS.DLL; + +{___________________________________________________________________________ + * WIDGET POSITIONING AND VISIBILITY + ___________________________________________________________________________} + + { + XPPlaceWidgetWithin + + This function changes which container a widget resides in. You may NOT use + this function on a root widget! inSubWidget is the widget that will be + moved. Pass a widget ID in inContainer to make inSubWidget be a child of + inContainer. It will become the last/closest widget in the container. Pass + 0 to remove the widget from any container. Any call to this other than + passing the widget ID of the old parent of the affected widget will cause + the widget to be removed from its old parent. Placing a widget within its + own parent simply makes it the last widget. + + NOTE: this routine does not reposition the sub widget in global + coordinates. If the container has layout management code, it will + reposition the subwidget for you, otherwise you must do it with + SetWidgetGeometry. + } + PROCEDURE XPPlaceWidgetWithin( + inSubWidget : XPWidgetID; + inContainer : XPWidgetID); + cdecl; external XPWIDGETS.DLL; + + { + XPCountChildWidgets + + This routine returns the number of widgets another widget contains. + } + FUNCTION XPCountChildWidgets( + inWidget : XPWidgetID) : Integer; + cdecl; external XPWIDGETS.DLL; + + { + XPGetNthChildWidget + + This routine returns the widget ID of a child widget by index. Indexes are + 0 based, from 0 to one minus the number of widgets in the parent, + inclusive. If the index is invalid, 0 is returned. + } + FUNCTION XPGetNthChildWidget( + inWidget : XPWidgetID; + inIndex : Integer) : XPWidgetID; + cdecl; external XPWIDGETS.DLL; + + { + XPGetParentWidget + + Returns the parent of a widget, or 0 if the widget has no parent. Root + widgets never have parents and therefore always return 0. + } + FUNCTION XPGetParentWidget( + inWidget : XPWidgetID) : XPWidgetID; + cdecl; external XPWIDGETS.DLL; + + { + XPShowWidget + + This routine makes a widget visible if it is not already. Note that if a + widget is not in a rooted widget hierarchy or one of its parents is not + visible, it will still not be visible to the user. + } + PROCEDURE XPShowWidget( + inWidget : XPWidgetID); + cdecl; external XPWIDGETS.DLL; + + { + XPHideWidget + + Makes a widget invisible. See XPShowWidget for considerations of when a + widget might not be visible despite its own visibility state. + } + PROCEDURE XPHideWidget( + inWidget : XPWidgetID); + cdecl; external XPWIDGETS.DLL; + + { + XPIsWidgetVisible + + This returns 1 if a widget is visible, 0 if it is not. Note that this + routine takes into consideration whether a parent is invisible. Use this + routine to tell if the user can see the widget. + } + FUNCTION XPIsWidgetVisible( + inWidget : XPWidgetID) : Integer; + cdecl; external XPWIDGETS.DLL; + + { + XPFindRootWidget + + Returns the Widget ID of the root widget that contains the passed in widget + or NULL if the passed in widget is not in a rooted hierarchy. + } + FUNCTION XPFindRootWidget( + inWidget : XPWidgetID) : XPWidgetID; + cdecl; external XPWIDGETS.DLL; + + { + XPBringRootWidgetToFront + + This routine makes the specified widget be in the front most widget + hierarchy. If this widget is a root widget, its widget hierarchy comes to + front, otherwise the widget's root is brought to the front. If this widget + is not in an active widget hiearchy (e.g. there is no root widget at the + top of the tree), this routine does nothing. + } + PROCEDURE XPBringRootWidgetToFront( + inWidget : XPWidgetID); + cdecl; external XPWIDGETS.DLL; + + { + XPIsWidgetInFront + + This routine returns true if this widget's hierarchy is the front most + hierarchy. It returns false if the widget's hierarchy is not in front, or + if the widget is not in a rooted hierarchy. + } + FUNCTION XPIsWidgetInFront( + inWidget : XPWidgetID) : Integer; + cdecl; external XPWIDGETS.DLL; + + { + XPGetWidgetGeometry + + This routine returns the bounding box of a widget in global coordinates. + Pass NULL for any parameter you are not interested in. + } + PROCEDURE XPGetWidgetGeometry( + inWidget : XPWidgetID; + outLeft : PInteger; { Can be nil } + outTop : PInteger; { Can be nil } + outRight : PInteger; { Can be nil } + outBottom : PInteger); { Can be nil } + cdecl; external XPWIDGETS.DLL; + + { + XPSetWidgetGeometry + + This function changes the bounding box of a widget. + } + PROCEDURE XPSetWidgetGeometry( + inWidget : XPWidgetID; + inLeft : Integer; + inTop : Integer; + inRight : Integer; + inBottom : Integer); + cdecl; external XPWIDGETS.DLL; + + { + XPGetWidgetForLocation + + Given a widget and a location, this routine returns the widget ID of the + child of that widget that owns that location. If inRecursive is true then + this will return a child of a child of a widget as it tries to find the + deepest widget at that location. If inVisibleOnly is true, then only + visible widgets are considered, otherwise all widgets are considered. The + widget ID passed for inContainer will be returned if the location is in + that widget but not in a child widget. 0 is returned if the location is not + in the container. + + NOTE: if a widget's geometry extends outside its parents geometry, it will + not be returned by this call for mouse locations outside the parent + geometry. The parent geometry limits the child's eligibility for mouse + location. + } + FUNCTION XPGetWidgetForLocation( + inContainer : XPWidgetID; + inXOffset : Integer; + inYOffset : Integer; + inRecursive : Integer; + inVisibleOnly : Integer) : XPWidgetID; + cdecl; external XPWIDGETS.DLL; + + { + XPGetWidgetExposedGeometry + + This routine returns the bounds of the area of a widget that is completely + within its parent widgets. Since a widget's bounding box can be outside its + parent, part of its area will not be elligible for mouse clicks and should + not draw. Use XPGetWidgetGeometry to find out what area defines your + widget's shape, but use this routine to find out what area to actually draw + into. Note that the widget library does not use OpenGL clipping to keep + frame rates up, although you could use it internally. + } + PROCEDURE XPGetWidgetExposedGeometry( + inWidgetID : XPWidgetID; + outLeft : PInteger; { Can be nil } + outTop : PInteger; { Can be nil } + outRight : PInteger; { Can be nil } + outBottom : PInteger); { Can be nil } + cdecl; external XPWIDGETS.DLL; + +{___________________________________________________________________________ + * ACCESSING WIDGET DATA + ___________________________________________________________________________} + + { + XPSetWidgetDescriptor + + Every widget has a descriptor, which is a text string. What the text string + is used for varies from widget to widget; for example, a push button's text + is its descriptor, a caption shows its descriptor, and a text field's + descriptor is the text being edited. In other words, the usage for the text + varies from widget to widget, but this API provides a universal and + convenient way to get at it. While not all UI widgets need their + descriptor, many do. + } + PROCEDURE XPSetWidgetDescriptor( + inWidget : XPWidgetID; + inDescriptor : XPLMString); + cdecl; external XPWIDGETS.DLL; + + { + XPGetWidgetDescriptor + + This routine returns the widget's descriptor. Pass in the length of the + buffer you are going to receive the descriptor in. The descriptor will be + null terminated for you. This routine returns the length of the actual + descriptor; if you pass NULL for outDescriptor, you can get the + descriptor's length without getting its text. If the length of the + descriptor exceeds your buffer length, the buffer will not be null + terminated (this routine has 'strncpy' semantics). + } + FUNCTION XPGetWidgetDescriptor( + inWidget : XPWidgetID; + outDescriptor : XPLMString; + inMaxDescLength : Integer) : Integer; + cdecl; external XPWIDGETS.DLL; + + { + XPGetWidgetUnderlyingWindow + + Returns the window (from the XPLMDisplay API) that backs your widget + window. If you have opted in to modern windows, via a call to + XPLMEnableFeature("XPLM_USE_NATIVE_WIDGET_WINDOWS", 1), you can use the + returned window ID for display APIs like XPLMSetWindowPositioningMode(), + allowing you to pop the widget window out into a real OS window, or move it + into VR. + } + FUNCTION XPGetWidgetUnderlyingWindow( + inWidget : XPWidgetID) : XPLMWindowID; + cdecl; external XPWIDGETS.DLL; + + { + XPSetWidgetProperty + + This function sets a widget's property. Properties are arbitrary values + associated by a widget by ID. + } + PROCEDURE XPSetWidgetProperty( + inWidget : XPWidgetID; + inProperty : XPWidgetPropertyID; + inValue : intptr_t); + cdecl; external XPWIDGETS.DLL; + + { + XPGetWidgetProperty + + This routine returns the value of a widget's property, or 0 if the property + is not defined. If you need to know whether the property is defined, pass a + pointer to an int for inExists; the existence of that property will be + returned in the int. Pass NULL for inExists if you do not need this + information. + } + FUNCTION XPGetWidgetProperty( + inWidget : XPWidgetID; + inProperty : XPWidgetPropertyID; + inExists : PInteger) : intptr_t; { Can be nil } + cdecl; external XPWIDGETS.DLL; + +{___________________________________________________________________________ + * KEYBOARD MANAGEMENT + ___________________________________________________________________________} + + { + XPSetKeyboardFocus + + Controls which widget will receive keystrokes. Pass the widget ID of the + widget to get the keys. Note that if the widget does not care about + keystrokes, they will go to the parent widget, and if no widget cares about + them, they go to X-Plane. + + If you set the keyboard focus to widget ID 0, X-Plane gets keyboard focus. + + This routine returns the widget ID that ended up with keyboard focus, or 0 + for X-Plane. + + Keyboard focus is not changed if the new widget will not accept it. For + setting to X-Plane, keyboard focus is always accepted. + } + FUNCTION XPSetKeyboardFocus( + inWidget : XPWidgetID) : XPWidgetID; + cdecl; external XPWIDGETS.DLL; + + { + XPLoseKeyboardFocus + + This causes the specified widget to lose focus; focus is passed to its + parent, or the next parent that will accept it. This routine does nothing + if this widget does not have focus. + } + PROCEDURE XPLoseKeyboardFocus( + inWidget : XPWidgetID); + cdecl; external XPWIDGETS.DLL; + + { + XPGetWidgetWithFocus + + This routine returns the widget that has keyboard focus, or 0 if X-Plane + has keyboard focus or some other plugin window that does not have widgets + has focus. + } + FUNCTION XPGetWidgetWithFocus: XPWidgetID; + cdecl; external XPWIDGETS.DLL; + +{___________________________________________________________________________ + * CREATING CUSTOM WIDGETS + ___________________________________________________________________________} + + { + XPAddWidgetCallback + + This function adds a new widget callback to a widget. This widget callback + supercedes any existing ones and will receive messages first; if it does + not handle messages they will go on to be handled by pre-existing widgets. + + The widget function will remain on the widget for the life of the widget. + The creation message will be sent to the new callback immediately with the + widget ID, and the destruction message will be sent before the other widget + function receives a destruction message. + + This provides a way to 'subclass' an existing widget. By providing a second + hook that only handles certain widget messages, you can customize or extend + widget behavior. + } + PROCEDURE XPAddWidgetCallback( + inWidget : XPWidgetID; + inNewCallback : XPWidgetFunc_t); + cdecl; external XPWIDGETS.DLL; + + { + XPGetWidgetClassFunc + + Given a widget class, this function returns the callbacks that power that + widget class. + } + FUNCTION XPGetWidgetClassFunc( + inWidgetClass : XPWidgetClass) : XPWidgetFunc_t; + cdecl; external XPWIDGETS.DLL; + + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/Delphi/XPLM/XPLMCamera.pas b/XPLPro_Plugin_Source/SDK/Delphi/XPLM/XPLMCamera.pas new file mode 100644 index 0000000..ad76fa4 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/Delphi/XPLM/XPLMCamera.pas @@ -0,0 +1,155 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPLMCamera; +INTERFACE +{ + The XPLMCamera APIs allow plug-ins to control the camera angle in X-Plane. + This has a number of applications, including but not limited to: + + - Creating new views (including dynamic/user-controllable views) for the + user. + - Creating applications that use X-Plane as a renderer of scenery, + aircrafts, or both. + + The camera is controlled via six parameters: a location in OpenGL + coordinates and pitch, roll and yaw, similar to an airplane's position. + OpenGL coordinate info is described in detail in the XPLMGraphics + documentation; generally you should use the XPLMGraphics routines to + convert from world to local coordinates. The camera's orientation starts + facing level with the ground directly up the negative-Z axis (approximately + north) with the horizon horizontal. It is then rotated clockwise for yaw, + pitched up for positive pitch, and rolled clockwise around the vector it is + looking along for roll. + + You control the camera either either until the user selects a new view or + permanently (the later being similar to how UDP camera control works). You + control the camera by registering a callback per frame from which you + calculate the new camera positions. This guarantees smooth camera motion. + + Use the XPLMDataAccess APIs to get information like the position of the + aircraft, etc. for complex camera positioning. + + Note: if your goal is to move the virtual pilot in the cockpit, this API is + not needed; simply update the datarefs for the pilot's head position. + + For custom exterior cameras, set the camera's mode to an external view + first to get correct sound and 2-d panel behavior. +} + +USES + XPLMDefs; + {$A4} +{___________________________________________________________________________ + * CAMERA CONTROL + ___________________________________________________________________________} + + { + XPLMCameraControlDuration + + This enumeration states how long you want to retain control of the camera. + You can retain it indefinitely or until the user selects a new view. + } +TYPE + XPLMCameraControlDuration = ( + { Control the camera until the user picks a new view. } + xplm_ControlCameraUntilViewChanges = 1 + + { Control the camera until your plugin is disabled or another plugin forcably} + { takes control. } + ,xplm_ControlCameraForever = 2 + + ); + PXPLMCameraControlDuration = ^XPLMCameraControlDuration; + + { + XPLMCameraPosition_t + + This structure contains a full specification of the camera. X, Y, and Z are + the camera's position in OpenGL coordiantes; pitch, roll, and yaw are + rotations from a camera facing flat north in degrees. Positive pitch means + nose up, positive roll means roll right, and positive yaw means yaw right, + all in degrees. Zoom is a zoom factor, with 1.0 meaning normal zoom and 2.0 + magnifying by 2x (objects appear larger). + } + XPLMCameraPosition_t = RECORD + x : Single; + y : Single; + z : Single; + pitch : Single; + heading : Single; + roll : Single; + zoom : Single; + END; + PXPLMCameraPosition_t = ^XPLMCameraPosition_t; + + { + XPLMCameraControl_f + + You use an XPLMCameraControl function to provide continuous control over + the camera. You are passed in a structure in which to put the new camera + position; modify it and return 1 to reposition the camera. Return 0 to + surrender control of the camera; camera control will be handled by X-Plane + on this draw loop. The contents of the structure as you are called are + undefined. + + If X-Plane is taking camera control away from you, this function will be + called with inIsLosingControl set to 1 and ioCameraPosition NULL. + } + XPLMCameraControl_f = FUNCTION( + outCameraPosition : PXPLMCameraPosition_t; { Can be nil } + inIsLosingControl : Integer; + inRefcon : pointer) : Integer; cdecl; + + { + XPLMControlCamera + + This function repositions the camera on the next drawing cycle. You must + pass a non-null control function. Specify in inHowLong how long you'd like + control (indefinitely or until a new view mode is set by the user). + } + PROCEDURE XPLMControlCamera( + inHowLong : XPLMCameraControlDuration; + inControlFunc : XPLMCameraControl_f; + inRefcon : pointer); + cdecl; external XPLM_DLL; + + { + XPLMDontControlCamera + + This function stops you from controlling the camera. If you have a camera + control function, it will not be called with an inIsLosingControl flag. + X-Plane will control the camera on the next cycle. + + For maximum compatibility you should not use this routine unless you are in + posession of the camera. + } + PROCEDURE XPLMDontControlCamera; + cdecl; external XPLM_DLL; + + { + XPLMIsCameraBeingControlled + + This routine returns 1 if the camera is being controlled, zero if it is + not. If it is and you pass in a pointer to a camera control duration, the + current control duration will be returned. + } + FUNCTION XPLMIsCameraBeingControlled( + outCameraControlDuration: PXPLMCameraControlDuration) : Integer; { Can be nil } + cdecl; external XPLM_DLL; + + { + XPLMReadCameraPosition + + This function reads the current camera position. + } + PROCEDURE XPLMReadCameraPosition( + outCameraPosition : PXPLMCameraPosition_t); + cdecl; external XPLM_DLL; + + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/Delphi/XPLM/XPLMDataAccess.pas b/XPLPro_Plugin_Source/SDK/Delphi/XPLM/XPLMDataAccess.pas new file mode 100644 index 0000000..1ad210e --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/Delphi/XPLM/XPLMDataAccess.pas @@ -0,0 +1,690 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPLMDataAccess; +INTERFACE +{ + The data access API gives you a generic, flexible, high performance way to + read and write data to and from X-Plane and other plug-ins. For example, + this API allows you to read and set the nav radios, get the plane location, + determine the current effective graphics frame rate, etc. + + The data access APIs are the way that you read and write data from the sim + as well as other plugins. + + The API works using opaque data references. A data reference is a source of + data; you do not know where it comes from, but once you have it you can + read the data quickly and possibly write it. + + Dataref Lookup + -------------- + + Data references are identified by verbose, permanent string names; by + convention these names use path separates to form a hierarchy of datarefs, + e.g. (sim/cockpit/radios/nav1_freq_hz). The actual opaque numeric value of + the data reference, as returned by the XPLM API, is implementation defined + and changes each time X-Plane is launched; therefore you need to look up + the dataref by path every time your plugin runs. + + The task of looking up a data reference is relatively expensive; look up + your data references once based on the verbose path strings, and save the + opaque data reference value for the duration of your plugin's operation. + Reading and writing data references is relatively fast (the cost is + equivalent to two function calls through function pointers). + + X-Plane publishes over 4000 datarefs; a complete list may be found in the + reference section of the SDK online documentation (from the SDK home page, + choose Documentation). + + Dataref Types + ------------- + + A note on typing: you must know the correct data type to read and write. + APIs are provided for reading and writing data in a number of ways. You can + also double check the data type for a data ref. Automatic type conversion + is not done for you. + + Dataref types are a set, e.g. a dataref can be more than one type. When + this happens, you can choose which API you want to use to read. For + example, it is not uncommon for a dataref to be of type float and double. + This means you can use either XPLMGetDatad or XPLMGetDataf to read it. + + Creating New Datarefs + --------------------- + + X-Plane provides datarefs that come with the sim, but plugins can also + create their own datarefs. A plugin creates a dataref by registering + function callbacks to read and write the dataref. The XPLM will call your + plugin each time some other plugin (or X-Plane) tries to read or write the + dataref. You must provide a read (and optional write) callback for each + data type you support. + + A note for plugins sharing data with other plugins: the load order of + plugins is not guaranteed. To make sure that every plugin publishing data + has published their data references before other plugins try to subscribe, + publish your data references in your start routine but resolve them the + first time your 'enable' routine is called, or the first time they are + needed in code. + + When a plugin that created a dataref is unloaded, it becomes "orphaned". + The dataref handle continues to be usable, but the dataref is not writable, + and reading it will always return 0 (or 0 items for arrays). If the plugin + is reloaded and re-registers the dataref, the handle becomes un-orphaned + and works again. +} + +USES + XPLMDefs; + {$A4} +{___________________________________________________________________________ + * READING AND WRITING DATA + ___________________________________________________________________________} +{ + These routines allow you to access data from within X-Plane and sometimes + modify it. +} + + +TYPE + { + XPLMDataRef + + A data ref is an opaque handle to data provided by the simulator or another + plugin. It uniquely identifies one variable (or array of variables) over + the lifetime of your plugin. You never hard code these values; you always + get them from XPLMFindDataRef. + } + XPLMDataRef = pointer; + PXPLMDataRef = ^XPLMDataRef; + + { + XPLMDataTypeID + + This is an enumeration that defines the type of the data behind a data + reference. This allows you to sanity check that the data type matches what + you expect. But for the most part, you will know the type of data you are + expecting from the online documentation. + + Data types each take a bit field; it is legal to have a single dataref be + more than one type of data. Whe this happens, you can pick any matching + get/set API. + } + XPLMDataTypeID = ( + { Data of a type the current XPLM doesn't do. } + xplmType_Unknown = 0 + + { A single 4-byte integer, native endian. } + ,xplmType_Int = 1 + + { A single 4-byte float, native endian. } + ,xplmType_Float = 2 + + { A single 8-byte double, native endian. } + ,xplmType_Double = 4 + + { An array of 4-byte floats, native endian. } + ,xplmType_FloatArray = 8 + + { An array of 4-byte integers, native endian. } + ,xplmType_IntArray = 16 + + { A variable block of data. } + ,xplmType_Data = 32 + + ); + PXPLMDataTypeID = ^XPLMDataTypeID; + + { + XPLMFindDataRef + + Given a c-style string that names the data ref, this routine looks up the + actual opaque XPLMDataRef that you use to read and write the data. The + string names for datarefs are published on the X-Plane SDK web site. + + This function returns NULL if the data ref cannot be found. + + NOTE: this function is relatively expensive; save the XPLMDataRef this + function returns for future use. Do not look up your data ref by string + every time you need to read or write it. + } + FUNCTION XPLMFindDataRef( + inDataRefName : XPLMString) : XPLMDataRef; + cdecl; external XPLM_DLL; + + { + XPLMCanWriteDataRef + + Given a data ref, this routine returns true if you can successfully set the + data, false otherwise. Some datarefs are read-only. + + NOTE: even if a dataref is marked writable, it may not act writable. This + can happen for datarefs that X-Plane writes to on every frame of + simulation. In some cases, the dataref is writable but you have to set a + separate "override" dataref to 1 to stop X-Plane from writing it. + } + FUNCTION XPLMCanWriteDataRef( + inDataRef : XPLMDataRef) : Integer; + cdecl; external XPLM_DLL; + + { + XPLMIsDataRefGood + + This function returns true if the passed in handle is a valid dataref that + is not orphaned. + + Note: there is normally no need to call this function; datarefs returned by + XPLMFindDataRef remain valid (but possibly orphaned) unless there is a + complete plugin reload (in which case your plugin is reloaded anyway). + Orphaned datarefs can be safely read and return 0. Therefore you never need + to call XPLMIsDataRefGood to 'check' the safety of a dataref. + (XPLMIsDatarefGood performs some slow checking of the handle validity, so + it has a perormance cost.) + } + FUNCTION XPLMIsDataRefGood( + inDataRef : XPLMDataRef) : Integer; + cdecl; external XPLM_DLL; + + { + XPLMGetDataRefTypes + + This routine returns the types of the data ref for accessor use. If a data + ref is available in multiple data types, the bit-wise OR of these types + will be returned. + } + FUNCTION XPLMGetDataRefTypes( + inDataRef : XPLMDataRef) : XPLMDataTypeID; + cdecl; external XPLM_DLL; + +{___________________________________________________________________________ + * DATA ACCESSORS + ___________________________________________________________________________} +{ + These routines read and write the data references. For each supported data + type there is a reader and a writer. + + If the data ref is orphaned or the plugin that provides it is disabled or + there is a type mismatch, the functions that read data will return 0 as a + default value or not modify the passed in memory. The plugins that write + data will not write under these circumstances or if the data ref is + read-only. + + NOTE: to keep the overhead of reading datarefs low, these routines do not + do full validation of a dataref; passing a junk value for a dataref can + result in crashing the sim. The get/set APIs do check for NULL. + + For array-style datarefs, you specify the number of items to read/write and + the offset into the array; the actual number of items read or written is + returned. This may be less to prevent an array-out-of-bounds error. +} + + + { + XPLMGetDatai + + Read an integer data ref and return its value. The return value is the + dataref value or 0 if the dataref is NULL or the plugin is disabled. + } + FUNCTION XPLMGetDatai( + inDataRef : XPLMDataRef) : Integer; + cdecl; external XPLM_DLL; + + { + XPLMSetDatai + + Write a new value to an integer data ref. This routine is a no-op if the + plugin publishing the dataref is disabled, the dataref is NULL, or the + dataref is not writable. + } + PROCEDURE XPLMSetDatai( + inDataRef : XPLMDataRef; + inValue : Integer); + cdecl; external XPLM_DLL; + + { + XPLMGetDataf + + Read a single precision floating point dataref and return its value. The + return value is the dataref value or 0.0 if the dataref is NULL or the + plugin is disabled. + } + FUNCTION XPLMGetDataf( + inDataRef : XPLMDataRef) : Single; + cdecl; external XPLM_DLL; + + { + XPLMSetDataf + + Write a new value to a single precision floating point data ref. This + routine is a no-op if the plugin publishing the dataref is disabled, the + dataref is NULL, or the dataref is not writable. + } + PROCEDURE XPLMSetDataf( + inDataRef : XPLMDataRef; + inValue : Single); + cdecl; external XPLM_DLL; + + { + XPLMGetDatad + + Read a double precision floating point dataref and return its value. The + return value is the dataref value or 0.0 if the dataref is NULL or the + plugin is disabled. + } + FUNCTION XPLMGetDatad( + inDataRef : XPLMDataRef) : Real; + cdecl; external XPLM_DLL; + + { + XPLMSetDatad + + Write a new value to a double precision floating point data ref. This + routine is a no-op if the plugin publishing the dataref is disabled, the + dataref is NULL, or the dataref is not writable. + } + PROCEDURE XPLMSetDatad( + inDataRef : XPLMDataRef; + inValue : Real); + cdecl; external XPLM_DLL; + + { + XPLMGetDatavi + + Read a part of an integer array dataref. If you pass NULL for outValues, + the routine will return the size of the array, ignoring inOffset and inMax. + + If outValues is not NULL, then up to inMax values are copied from the + dataref into outValues, starting at inOffset in the dataref. If inMax + + inOffset is larger than the size of the dataref, less than inMax values + will be copied. The number of values copied is returned. + + Note: the semantics of array datarefs are entirely implemented by the + plugin (or X-Plane) that provides the dataref, not the SDK itself; the + above description is how these datarefs are intended to work, but a rogue + plugin may have different behavior. + } + FUNCTION XPLMGetDatavi( + inDataRef : XPLMDataRef; + outValues : PInteger; { Can be nil } + inOffset : Integer; + inMax : Integer) : Integer; + cdecl; external XPLM_DLL; + + { + XPLMSetDatavi + + Write part or all of an integer array dataref. The values passed by + inValues are written into the dataref starting at inOffset. Up to inCount + values are written; however if the values would write "off the end" of the + dataref array, then fewer values are written. + + Note: the semantics of array datarefs are entirely implemented by the + plugin (or X-Plane) that provides the dataref, not the SDK itself; the + above description is how these datarefs are intended to work, but a rogue + plugin may have different behavior. + } + PROCEDURE XPLMSetDatavi( + inDataRef : XPLMDataRef; + inValues : PInteger; + inoffset : Integer; + inCount : Integer); + cdecl; external XPLM_DLL; + + { + XPLMGetDatavf + + Read a part of a single precision floating point array dataref. If you pass + NULL for outVaules, the routine will return the size of the array, ignoring + inOffset and inMax. + + If outValues is not NULL, then up to inMax values are copied from the + dataref into outValues, starting at inOffset in the dataref. If inMax + + inOffset is larger than the size of the dataref, less than inMax values + will be copied. The number of values copied is returned. + + Note: the semantics of array datarefs are entirely implemented by the + plugin (or X-Plane) that provides the dataref, not the SDK itself; the + above description is how these datarefs are intended to work, but a rogue + plugin may have different behavior. + } + FUNCTION XPLMGetDatavf( + inDataRef : XPLMDataRef; + outValues : PSingle; { Can be nil } + inOffset : Integer; + inMax : Integer) : Integer; + cdecl; external XPLM_DLL; + + { + XPLMSetDatavf + + Write part or all of a single precision floating point array dataref. The + values passed by inValues are written into the dataref starting at + inOffset. Up to inCount values are written; however if the values would + write "off the end" of the dataref array, then fewer values are written. + + Note: the semantics of array datarefs are entirely implemented by the + plugin (or X-Plane) that provides the dataref, not the SDK itself; the + above description is how these datarefs are intended to work, but a rogue + plugin may have different behavior. + } + PROCEDURE XPLMSetDatavf( + inDataRef : XPLMDataRef; + inValues : PSingle; + inoffset : Integer; + inCount : Integer); + cdecl; external XPLM_DLL; + + { + XPLMGetDatab + + Read a part of a byte array dataref. If you pass NULL for outVaules, the + routine will return the size of the array, ignoring inOffset and inMax. + + If outValues is not NULL, then up to inMax values are copied from the + dataref into outValues, starting at inOffset in the dataref. If inMax + + inOffset is larger than the size of the dataref, less than inMax values + will be copied. The number of values copied is returned. + + Note: the semantics of array datarefs are entirely implemented by the + plugin (or X-Plane) that provides the dataref, not the SDK itself; the + above description is how these datarefs are intended to work, but a rogue + plugin may have different behavior. + } + FUNCTION XPLMGetDatab( + inDataRef : XPLMDataRef; + outValue : pointer; { Can be nil } + inOffset : Integer; + inMaxBytes : Integer) : Integer; + cdecl; external XPLM_DLL; + + { + XPLMSetDatab + + Write part or all of a byte array dataref. The values passed by inValues + are written into the dataref starting at inOffset. Up to inCount values are + written; however if the values would write "off the end" of the dataref + array, then fewer values are written. + + Note: the semantics of array datarefs are entirely implemented by the + plugin (or X-Plane) that provides the dataref, not the SDK itself; the + above description is how these datarefs are intended to work, but a rogue + plugin may have different behavior. + } + PROCEDURE XPLMSetDatab( + inDataRef : XPLMDataRef; + inValue : pointer; + inOffset : Integer; + inLength : Integer); + cdecl; external XPLM_DLL; + +{___________________________________________________________________________ + * PUBLISHING YOUR PLUGIN'S DATA + ___________________________________________________________________________} +{ + These functions allow you to create data references that other plug-ins and + X-Plane can access via the above data access APIs. Data references + published by other plugins operate the same as ones published by X-Plane in + all manners except that your data reference will not be available to other + plugins if/when your plugin is disabled. + + You share data by registering data provider callback functions. When a + plug-in requests your data, these callbacks are then called. You provide + one callback to return the value when a plugin 'reads' it and another to + change the value when a plugin 'writes' it. + + Important: you must pick a prefix for your datarefs other than "sim/" - + this prefix is reserved for X-Plane. The X-Plane SDK website contains a + registry where authors can select a unique first word for dataref names, to + prevent dataref collisions between plugins. +} + + + { + XPLMGetDatai_f + + Data provider function pointers. + + These define the function pointers you provide to get or set data. Note + that you are passed a generic pointer for each one. This is the same + pointer you pass in your register routine; you can use it to locate plugin + variables, etc. + + The semantics of your callbacks are the same as the dataref accessor above + - basically routines like XPLMGetDatai are just pass-throughs from a caller + to your plugin. Be particularly mindful in implementing array dataref + read-write accessors; you are responsible for avoiding overruns, supporting + offset read/writes, and handling a read with a NULL buffer. + } +TYPE + XPLMGetDatai_f = FUNCTION( + inRefcon : pointer) : Integer; cdecl; + + { + XPLMSetDatai_f + } + XPLMSetDatai_f = PROCEDURE( + inRefcon : pointer; + inValue : Integer); cdecl; + + { + XPLMGetDataf_f + } + XPLMGetDataf_f = FUNCTION( + inRefcon : pointer) : Single; cdecl; + + { + XPLMSetDataf_f + } + XPLMSetDataf_f = PROCEDURE( + inRefcon : pointer; + inValue : Single); cdecl; + + { + XPLMGetDatad_f + } + XPLMGetDatad_f = FUNCTION( + inRefcon : pointer) : Real; cdecl; + + { + XPLMSetDatad_f + } + XPLMSetDatad_f = PROCEDURE( + inRefcon : pointer; + inValue : Real); cdecl; + + { + XPLMGetDatavi_f + } + XPLMGetDatavi_f = FUNCTION( + inRefcon : pointer; + outValues : PInteger; { Can be nil } + inOffset : Integer; + inMax : Integer) : Integer; cdecl; + + { + XPLMSetDatavi_f + } + XPLMSetDatavi_f = PROCEDURE( + inRefcon : pointer; + inValues : PInteger; + inOffset : Integer; + inCount : Integer); cdecl; + + { + XPLMGetDatavf_f + } + XPLMGetDatavf_f = FUNCTION( + inRefcon : pointer; + outValues : PSingle; { Can be nil } + inOffset : Integer; + inMax : Integer) : Integer; cdecl; + + { + XPLMSetDatavf_f + } + XPLMSetDatavf_f = PROCEDURE( + inRefcon : pointer; + inValues : PSingle; + inOffset : Integer; + inCount : Integer); cdecl; + + { + XPLMGetDatab_f + } + XPLMGetDatab_f = FUNCTION( + inRefcon : pointer; + outValue : pointer; { Can be nil } + inOffset : Integer; + inMaxLength : Integer) : Integer; cdecl; + + { + XPLMSetDatab_f + } + XPLMSetDatab_f = PROCEDURE( + inRefcon : pointer; + inValue : pointer; + inOffset : Integer; + inLength : Integer); cdecl; + + { + XPLMRegisterDataAccessor + + This routine creates a new item of data that can be read and written. Pass + in the data's full name for searching, the type(s) of the data for + accessing, and whether the data can be written to. For each data type you + support, pass in a read accessor function and a write accessor function if + necessary. Pass NULL for data types you do not support or write accessors + if you are read-only. + + You are returned a data ref for the new item of data created. You can use + this data ref to unregister your data later or read or write from it. + } + FUNCTION XPLMRegisterDataAccessor( + inDataName : XPLMString; + inDataType : XPLMDataTypeID; + inIsWritable : Integer; + inReadInt : XPLMGetDatai_f; + inWriteInt : XPLMSetDatai_f; + inReadFloat : XPLMGetDataf_f; + inWriteFloat : XPLMSetDataf_f; + inReadDouble : XPLMGetDatad_f; + inWriteDouble : XPLMSetDatad_f; + inReadIntArray : XPLMGetDatavi_f; + inWriteIntArray : XPLMSetDatavi_f; + inReadFloatArray : XPLMGetDatavf_f; + inWriteFloatArray : XPLMSetDatavf_f; + inReadData : XPLMGetDatab_f; + inWriteData : XPLMSetDatab_f; + inReadRefcon : pointer; + inWriteRefcon : pointer) : XPLMDataRef; + cdecl; external XPLM_DLL; + + { + XPLMUnregisterDataAccessor + + Use this routine to unregister any data accessors you may have registered. + You unregister a data ref by the XPLMDataRef you get back from + registration. Once you unregister a data ref, your function pointer will + not be called anymore. + } + PROCEDURE XPLMUnregisterDataAccessor( + inDataRef : XPLMDataRef); + cdecl; external XPLM_DLL; + +{___________________________________________________________________________ + * SHARING DATA BETWEEN MULTIPLE PLUGINS + ___________________________________________________________________________} +{ + The data reference registration APIs from the previous section allow a + plugin to publish data in a one-owner manner; the plugin that publishes the + data reference owns the real memory that the data ref uses. This is + satisfactory for most cases, but there are also cases where plugnis need to + share actual data. + + With a shared data reference, no one plugin owns the actual memory for the + data reference; the plugin SDK allocates that for you. When the first + plugin asks to 'share' the data, the memory is allocated. When the data is + changed, every plugin that is sharing the data is notified. + + Shared data references differ from the 'owned' data references from the + previous section in a few ways: + + * With shared data references, any plugin can create the data reference; + with owned plugins one plugin must create the data reference and others + subscribe. (This can be a problem if you don't know which set of plugins + will be present). + + * With shared data references, every plugin that is sharing the data is + notified when the data is changed. With owned data references, only the + one owner is notified when the data is changed. + + * With shared data references, you cannot access the physical memory of the + data reference; you must use the XPLMGet... and XPLMSet... APIs. With an + owned data reference, the one owning data reference can manipulate the + data reference's memory in any way it sees fit. + + Shared data references solve two problems: if you need to have a data + reference used by several plugins but do not know which plugins will be + installed, or if all plugins sharing data need to be notified when that + data is changed, use shared data references. +} + + + { + XPLMDataChanged_f + + An XPLMDataChanged_f is a callback that the XPLM calls whenever any other + plug-in modifies shared data. A refcon you provide is passed back to help + identify which data is being changed. In response, you may want to call one + of the XPLMGetDataxxx routines to find the new value of the data. + } +TYPE + XPLMDataChanged_f = PROCEDURE( + inRefcon : pointer); cdecl; + + { + XPLMShareData + + This routine connects a plug-in to shared data, creating the shared data if + necessary. inDataName is a standard path for the data ref, and inDataType + specifies the type. This function will create the data if it does not + exist. If the data already exists but the type does not match, an error is + returned, so it is important that plug-in authors collaborate to establish + public standards for shared data. + + If a notificationFunc is passed in and is not NULL, that notification + function will be called whenever the data is modified. The notification + refcon will be passed to it. This allows your plug-in to know which shared + data was changed if multiple shared data are handled by one callback, or if + the plug-in does not use global variables. + + A one is returned for successfully creating or finding the shared data; a + zero if the data already exists but is of the wrong type. + } + FUNCTION XPLMShareData( + inDataName : XPLMString; + inDataType : XPLMDataTypeID; + inNotificationFunc : XPLMDataChanged_f; + inNotificationRefcon: pointer) : Integer; + cdecl; external XPLM_DLL; + + { + XPLMUnshareData + + This routine removes your notification function for shared data. Call it + when done with the data to stop receiving change notifications. Arguments + must match XPLMShareData. The actual memory will not necessarily be freed, + since other plug-ins could be using it. + } + FUNCTION XPLMUnshareData( + inDataName : XPLMString; + inDataType : XPLMDataTypeID; + inNotificationFunc : XPLMDataChanged_f; + inNotificationRefcon: pointer) : Integer; + cdecl; external XPLM_DLL; + + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/Delphi/XPLM/XPLMDefs.pas b/XPLPro_Plugin_Source/SDK/Delphi/XPLM/XPLMDefs.pas new file mode 100644 index 0000000..91bd774 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/Delphi/XPLM/XPLMDefs.pas @@ -0,0 +1,438 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPLMDefs; +INTERFACE +{ + This file is contains the cross-platform and basic definitions for the + X-Plane SDK. + + The preprocessor macros APL and IBM must be defined to specify the + compilation target; define APL to 1 and IBM 0 to compile on Macintosh and + APL to 0 and IBM to 1 for Windows. You must specify these macro definitions + before including XPLMDefs.h or any other XPLM headers. You can do this + using the -D command line option or a preprocessor header. +} + + {$A4} +{$IFDEF LINUX} + {$DEFINE KYLIX} +{$ENDIF} +TYPE +{$IFNDEF DELPHI} +{$IFNDEF KYLIX} + Pchar = ^char; + Ppchar = ^Pchar; + Psingle = ^single; + Pinteger = ^integer; +{$ENDIF} +{$ENDIF} + Preal = ^real; + Plongint = ^longint; +{___________________________________________________________________________ + * DLL Definitions + ___________________________________________________________________________} +{ + These definitions control the importing and exporting of functions within + the DLL. + + You can prefix your five required callbacks with the PLUGIN_API macro to + declare them as exported C functions. The XPLM_API macro identifies + functions that are provided to you via the plugin SDK. (Link against + XPLM.lib to use these functions.) +} + + + +{___________________________________________________________________________ + * GLOBAL DEFINITIONS + ___________________________________________________________________________} +{ + These definitions are used in all parts of the SDK. +} + + +TYPE + { + XPLMPluginID + + Each plug-in is identified by a unique integer ID. This ID can be used to + disable or enable a plug-in, or discover what plug-in is 'running' at the + time. A plug-in ID is unique within the currently running instance of + X-Plane unless plug-ins are reloaded. Plug-ins may receive a different + unique ID each time they are loaded. This includes the unloading and + reloading of plugins that are part of the user's aircraft. + + For persistent identification of plug-ins, use XPLMFindPluginBySignature in + XPLMUtiltiies.h + + -1 indicates no plug-in. + } + XPLMPluginID = Integer; + PXPLMPluginID = ^XPLMPluginID; + +CONST + { No plugin. } + XPLM_NO_PLUGIN_ID = (-1); + + { X-Plane itself } + XPLM_PLUGIN_XPLANE = (0); + + { The current XPLM revision is 3.03 (303). } + kXPLM_Version = (303); + + { + XPLMKeyFlags + + These bitfields define modifier keys in a platform independent way. When a + key is pressed, a series of messages are sent to your plugin. The down + flag is set in the first of these messages, and the up flag in the last. + While the key is held down, messages are sent with neither to indicate that + the key is being held down as a repeated character. + + The control flag is mapped to the control flag on Macintosh and PC. + Generally X-Plane uses the control key and not the command key on + Macintosh, providing a consistent interface across platforms that does not + necessarily match the Macintosh user interface guidelines. There is not + yet a way for plugins to access the Macintosh control keys without using + #ifdefed code. + } +TYPE + XPLMKeyFlags = ( + { The shift key is down } + xplm_ShiftFlag = 1 + + { The option or alt key is down } + ,xplm_OptionAltFlag = 2 + + { The control key is down* } + ,xplm_ControlFlag = 4 + + { The key is being pressed down } + ,xplm_DownFlag = 8 + + { The key is being released } + ,xplm_UpFlag = 16 + + ); + PXPLMKeyFlags = ^XPLMKeyFlags; + +{___________________________________________________________________________ + * ASCII CONTROL KEY CODES + ___________________________________________________________________________} +{ + These definitions define how various control keys are mapped to ASCII key + codes. Not all key presses generate an ASCII value, so plugin code should + be prepared to see null characters come from the keyboard...this usually + represents a key stroke that has no equivalent ASCII, like a page-down + press. Use virtual key codes to find these key strokes. + + ASCII key codes take into account modifier keys; shift keys will affect + capitals and punctuation; control key combinations may have no vaild ASCII + and produce NULL. To detect control-key combinations, use virtual key + codes, not ASCII keys. +} + + +CONST + XPLM_KEY_RETURN = 13; + + XPLM_KEY_ESCAPE = 27; + + XPLM_KEY_TAB = 9; + + XPLM_KEY_DELETE = 8; + + XPLM_KEY_LEFT = 28; + + XPLM_KEY_RIGHT = 29; + + XPLM_KEY_UP = 30; + + XPLM_KEY_DOWN = 31; + + XPLM_KEY_0 = 48; + + XPLM_KEY_1 = 49; + + XPLM_KEY_2 = 50; + + XPLM_KEY_3 = 51; + + XPLM_KEY_4 = 52; + + XPLM_KEY_5 = 53; + + XPLM_KEY_6 = 54; + + XPLM_KEY_7 = 55; + + XPLM_KEY_8 = 56; + + XPLM_KEY_9 = 57; + + XPLM_KEY_DECIMAL = 46; + +{___________________________________________________________________________ + * VIRTUAL KEY CODES + ___________________________________________________________________________} +{ + These are cross-platform defines for every distinct keyboard press on the + computer. Every physical key on the keyboard has a virtual key code. So + the "two" key on the top row of the main keyboard has a different code from + the "two" key on the numeric key pad. But the 'w' and 'W' character are + indistinguishable by virtual key code because they are the same physical + key (one with and one without the shift key). + + Use virtual key codes to detect keystrokes that do not have ASCII + equivalents, allow the user to map the numeric keypad separately from the + main keyboard, and detect control key and other modifier-key combinations + that generate ASCII control key sequences (many of which are not available + directly via character keys in the SDK). + + To assign virtual key codes we started with the Microsoft set but made some + additions and changes. A few differences: + + 1. Modifier keys are not available as virtual key codes. You cannot get + distinct modifier press and release messages. Please do not try to use + modifier keys as regular keys; doing so will almost certainly interfere + with users' abilities to use the native X-Plane key bindings. + 2. Some keys that do not exist on both Mac and PC keyboards are removed. + 3. Do not assume that the values of these keystrokes are interchangeable + with MS v-keys. +} + + +CONST + XPLM_VK_BACK = $08; + + XPLM_VK_TAB = $09; + + XPLM_VK_CLEAR = $0C; + + XPLM_VK_RETURN = $0D; + + XPLM_VK_ESCAPE = $1B; + + XPLM_VK_SPACE = $20; + + XPLM_VK_PRIOR = $21; + + XPLM_VK_NEXT = $22; + + XPLM_VK_END = $23; + + XPLM_VK_HOME = $24; + + XPLM_VK_LEFT = $25; + + XPLM_VK_UP = $26; + + XPLM_VK_RIGHT = $27; + + XPLM_VK_DOWN = $28; + + XPLM_VK_SELECT = $29; + + XPLM_VK_PRINT = $2A; + + XPLM_VK_EXECUTE = $2B; + + XPLM_VK_SNAPSHOT = $2C; + + XPLM_VK_INSERT = $2D; + + XPLM_VK_DELETE = $2E; + + XPLM_VK_HELP = $2F; + + { XPLM_VK_0 thru XPLM_VK_9 are the same as ASCII '0' thru '9' (0x30 - 0x39) } + XPLM_VK_0 = $30; + + XPLM_VK_1 = $31; + + XPLM_VK_2 = $32; + + XPLM_VK_3 = $33; + + XPLM_VK_4 = $34; + + XPLM_VK_5 = $35; + + XPLM_VK_6 = $36; + + XPLM_VK_7 = $37; + + XPLM_VK_8 = $38; + + XPLM_VK_9 = $39; + + { XPLM_VK_A thru XPLM_VK_Z are the same as ASCII 'A' thru 'Z' (0x41 - 0x5A) } + XPLM_VK_A = $41; + + XPLM_VK_B = $42; + + XPLM_VK_C = $43; + + XPLM_VK_D = $44; + + XPLM_VK_E = $45; + + XPLM_VK_F = $46; + + XPLM_VK_G = $47; + + XPLM_VK_H = $48; + + XPLM_VK_I = $49; + + XPLM_VK_J = $4A; + + XPLM_VK_K = $4B; + + XPLM_VK_L = $4C; + + XPLM_VK_M = $4D; + + XPLM_VK_N = $4E; + + XPLM_VK_O = $4F; + + XPLM_VK_P = $50; + + XPLM_VK_Q = $51; + + XPLM_VK_R = $52; + + XPLM_VK_S = $53; + + XPLM_VK_T = $54; + + XPLM_VK_U = $55; + + XPLM_VK_V = $56; + + XPLM_VK_W = $57; + + XPLM_VK_X = $58; + + XPLM_VK_Y = $59; + + XPLM_VK_Z = $5A; + + XPLM_VK_NUMPAD0 = $60; + + XPLM_VK_NUMPAD1 = $61; + + XPLM_VK_NUMPAD2 = $62; + + XPLM_VK_NUMPAD3 = $63; + + XPLM_VK_NUMPAD4 = $64; + + XPLM_VK_NUMPAD5 = $65; + + XPLM_VK_NUMPAD6 = $66; + + XPLM_VK_NUMPAD7 = $67; + + XPLM_VK_NUMPAD8 = $68; + + XPLM_VK_NUMPAD9 = $69; + + XPLM_VK_MULTIPLY = $6A; + + XPLM_VK_ADD = $6B; + + XPLM_VK_SEPARATOR = $6C; + + XPLM_VK_SUBTRACT = $6D; + + XPLM_VK_DECIMAL = $6E; + + XPLM_VK_DIVIDE = $6F; + + XPLM_VK_F1 = $70; + + XPLM_VK_F2 = $71; + + XPLM_VK_F3 = $72; + + XPLM_VK_F4 = $73; + + XPLM_VK_F5 = $74; + + XPLM_VK_F6 = $75; + + XPLM_VK_F7 = $76; + + XPLM_VK_F8 = $77; + + XPLM_VK_F9 = $78; + + XPLM_VK_F10 = $79; + + XPLM_VK_F11 = $7A; + + XPLM_VK_F12 = $7B; + + XPLM_VK_F13 = $7C; + + XPLM_VK_F14 = $7D; + + XPLM_VK_F15 = $7E; + + XPLM_VK_F16 = $7F; + + XPLM_VK_F17 = $80; + + XPLM_VK_F18 = $81; + + XPLM_VK_F19 = $82; + + XPLM_VK_F20 = $83; + + XPLM_VK_F21 = $84; + + XPLM_VK_F22 = $85; + + XPLM_VK_F23 = $86; + + XPLM_VK_F24 = $87; + + { The following definitions are extended and are not based on the Microsoft } + { key set. } + XPLM_VK_EQUAL = $B0; + + XPLM_VK_MINUS = $B1; + + XPLM_VK_RBRACE = $B2; + + XPLM_VK_LBRACE = $B3; + + XPLM_VK_QUOTE = $B4; + + XPLM_VK_SEMICOLON = $B5; + + XPLM_VK_BACKSLASH = $B6; + + XPLM_VK_COMMA = $B7; + + XPLM_VK_SLASH = $B8; + + XPLM_VK_PERIOD = $B9; + + XPLM_VK_BACKQUOTE = $BA; + + XPLM_VK_ENTER = $BB; + + XPLM_VK_NUMPAD_ENT = $BC; + + XPLM_VK_NUMPAD_EQ = $BD; + + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/Delphi/XPLM/XPLMDisplay.pas b/XPLPro_Plugin_Source/SDK/Delphi/XPLM/XPLMDisplay.pas new file mode 100644 index 0000000..a100fd0 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/Delphi/XPLM/XPLMDisplay.pas @@ -0,0 +1,1452 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPLMDisplay; +INTERFACE +{ + This API provides the basic hooks to draw in X-Plane and create user + interface. All X-Plane drawing is done in OpenGL. The X-Plane plug-in + manager takes care of properly setting up the OpenGL context and matrices. + You do not decide when in your code's execution to draw; X-Plane tells you + (via callbacks) when it is ready to have your plugin draw. + + X-Plane's drawing strategy is straightforward: every "frame" the screen is + rendered by drawing the 3-D scene (dome, ground, objects, airplanes, etc.) + and then drawing the cockpit on top of it. Alpha blending is used to + overlay the cockpit over the world (and the gauges over the panel, etc.). + X-Plane user interface elements (including windows like the map, the main + menu, etc.) are then drawn on top of the cockpit. + + There are two ways you can draw: directly and in a window. + + Direct drawing (deprecated!---more on that below) involves drawing to the + screen before or after X-Plane finishes a phase of drawing. When you draw + directly, you can specify whether X-Plane is to complete this phase or not. + This allows you to do three things: draw before X-Plane does (under it), + draw after X-Plane does (over it), or draw instead of X-Plane. + + To draw directly, you register a callback and specify which phase you want + to intercept. The plug-in manager will call you over and over to draw that + phase. + + Direct drawing allows you to override scenery, panels, or anything. Note + that you cannot assume that you are the only plug-in drawing at this phase. + + Direct drawing is deprecated; at some point in the X-Plane 11 run, it will + likely become unsupported entirely as X-Plane transitions from OpenGL to + modern graphics API backends (e.g., Vulkan, Metal, etc.). In the long term, + plugins should use the XPLMInstance API for drawing 3-D objects---this will + be much more efficient than general 3-D OpenGL drawing, and it will + actually be supported by the new graphics backends. We do not yet know what + the post-transition API for generic 3-D drawing will look like (if it + exists at all). + + In contrast to direct drawing, window drawing provides a higher level + functionality. With window drawing, you create a 2-D window that takes up a + portion of the screen. Window drawing is always two dimensional. Window + drawing is front-to-back controlled; you can specify that you want your + window to be brought on top, and other plug-ins may put their window on top + of you. Window drawing also allows you to sign up for key presses and + receive mouse clicks. + + There are three ways to get keystrokes: + + 1. If you create a window, the window can take keyboard focus. It will + then receive all keystrokes. If no window has focus, X-Plane receives + keystrokes. Use this to implement typing in dialog boxes, etc. Only + one window may have focus at a time; your window will be notified if it + loses focus. + 2. If you need low level access to the keystroke stream, install a key + sniffer. Key sniffers can be installed above everything or right in + front of the sim. + 3. If you would like to associate key strokes with commands/functions in + your plug-in, you should simply register a command (via + XPLMCreateCommand()) and allow users to bind whatever key they choose to + that command. Another (now deprecated) method of doing so is to use a + hot key---a key-specific callback. Hotkeys are sent based on virtual + key strokes, so any key may be distinctly mapped with any modifiers. + Hot keys can be remapped by other plug-ins. As a plug-in, you don't + have to worry about what your hot key ends up mapped to; other plug-ins + may provide a UI for remapping keystrokes. So hotkeys allow a user to + resolve conflicts and customize keystrokes. +} + +USES + XPLMDefs; + {$A4} +{___________________________________________________________________________ + * DRAWING CALLBACKS + ___________________________________________________________________________} +{ + Basic drawing callbacks, for low level intercepting of X-Plane's render + loop. The purpose of drawing callbacks is to provide targeted additions or + replacements to X-Plane's graphics environment (for example, to add extra + custom objects, or replace drawing of the AI aircraft). Do not assume that + the drawing callbacks will be called in the order implied by the + enumerations. Also do not assume that each drawing phase ends before + another begins; they may be nested. + + Note that all APIs in this section are deprecated, and will likely be + removed during the X-Plane 11 run as part of the transition to + Vulkan/Metal/etc. See the XPLMInstance API for future-proof drawing of 3-D + objects. +} + + + { + XPLMDrawingPhase + + This constant indicates which part of drawing we are in. Drawing is done + from the back to the front. We get a callback before or after each item. + Metaphases provide access to the beginning and end of the 3d (scene) and + 2d (cockpit) drawing in a manner that is independent of new phases added + via X-Plane implementation. + + **NOTE**: As of XPLM302 the legacy 3D drawing phases (xplm_Phase_FirstScene + to xplm_Phase_LastScene) are deprecated. When running under X-Plane 11.50 + with the modern Vulkan or Metal backend, X-Plane will no longer call + these drawing phases. There is a new drawing phase, xplm_Phase_Modern3D, + which is supported under OpenGL and Vulkan which is called out roughly + where the old before xplm_Phase_Airplanes phase was for blending. This + phase is *NOT* supported under Metal and comes with potentially + substantial performance overhead. Please do *NOT* opt into this phase if + you don't do any actual drawing that requires the depth buffer in some + way! + + **WARNING**: As X-Plane's scenery evolves, some drawing phases may cease to + exist and new ones may be invented. If you need a particularly specific + use of these codes, consult Austin and/or be prepared to revise your code + as X-Plane evolves. + } +TYPE + XPLMDrawingPhase = ( +{$IFDEF XPLM_DEPRECATED} + { Deprecated as of XPLM302. This is the earliest point at which you can draw } + { in 3-d. } + xplm_Phase_FirstScene = 0 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated as of XPLM302. Drawing of land and water. } + ,xplm_Phase_Terrain = 5 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated as of XPLM302. Drawing runways and other airport detail. } + ,xplm_Phase_Airports = 10 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated as of XPLM302. Drawing roads, trails, trains, etc. } + ,xplm_Phase_Vectors = 15 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated as of XPLM302. 3-d objects (houses, smokestacks, etc. } + ,xplm_Phase_Objects = 20 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated as of XPLM302. External views of airplanes, both yours and the } + { AI aircraft. } + ,xplm_Phase_Airplanes = 25 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated as of XPLM302. This is the last point at which you can draw in } + { 3-d. } + ,xplm_Phase_LastScene = 30 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM302} + { A chance to do modern 3D drawing. } + ,xplm_Phase_Modern3D = 31 +{$ENDIF XPLM302} + + { This is the first phase where you can draw in 2-d. } + ,xplm_Phase_FirstCockpit = 35 + + { The non-moving parts of the aircraft panel. } + ,xplm_Phase_Panel = 40 + + { The moving parts of the aircraft panel. } + ,xplm_Phase_Gauges = 45 + + { Floating windows from plugins. } + ,xplm_Phase_Window = 50 + + { The last chance to draw in 2d. } + ,xplm_Phase_LastCockpit = 55 + +{$IFDEF XPLM200} + { Removed as of XPLM300; Use the full-blown XPLMMap API instead. } + ,xplm_Phase_LocalMap3D = 100 +{$ENDIF XPLM200} + +{$IFDEF XPLM200} + { Removed as of XPLM300; Use the full-blown XPLMMap API instead. } + ,xplm_Phase_LocalMap2D = 101 +{$ENDIF XPLM200} + +{$IFDEF XPLM200} + { Removed as of XPLM300; Use the full-blown XPLMMap API instead. } + ,xplm_Phase_LocalMapProfile = 102 +{$ENDIF XPLM200} + + ); + PXPLMDrawingPhase = ^XPLMDrawingPhase; + + { + XPLMDrawCallback_f + + This is the prototype for a low level drawing callback. You are passed in + the phase and whether it is before or after. If you are before the phase, + return 1 to let X-Plane draw or 0 to suppress X-Plane drawing. If you are + after the phase the return value is ignored. + + Refcon is a unique value that you specify when registering the callback, + allowing you to slip a pointer to your own data to the callback. + + Upon entry the OpenGL context will be correctly set up for you and OpenGL + will be in 'local' coordinates for 3d drawing and panel coordinates for 2d + drawing. The OpenGL state (texturing, etc.) will be unknown. + } + XPLMDrawCallback_f = FUNCTION( + inPhase : XPLMDrawingPhase; + inIsBefore : Integer; + inRefcon : pointer) : Integer; cdecl; + + { + XPLMRegisterDrawCallback + + This routine registers a low level drawing callback. Pass in the phase you + want to be called for and whether you want to be called before or after. + This routine returns 1 if the registration was successful, or 0 if the + phase does not exist in this version of X-Plane. You may register a + callback multiple times for the same or different phases as long as the + refcon is unique each time. + + Note that this function will likely be removed during the X-Plane 11 run as + part of the transition to Vulkan/Metal/etc. See the XPLMInstance API for + future-proof drawing of 3-D objects. + } + FUNCTION XPLMRegisterDrawCallback( + inCallback : XPLMDrawCallback_f; + inPhase : XPLMDrawingPhase; + inWantsBefore : Integer; + inRefcon : pointer) : Integer; + cdecl; external XPLM_DLL; + + { + XPLMUnregisterDrawCallback + + This routine unregisters a draw callback. You must unregister a callback + for each time you register a callback if you have registered it multiple + times with different refcons. The routine returns 1 if it can find the + callback to unregister, 0 otherwise. + + Note that this function will likely be removed during the X-Plane 11 run as + part of the transition to Vulkan/Metal/etc. See the XPLMInstance API for + future-proof drawing of 3-D objects. + } + FUNCTION XPLMUnregisterDrawCallback( + inCallback : XPLMDrawCallback_f; + inPhase : XPLMDrawingPhase; + inWantsBefore : Integer; + inRefcon : pointer) : Integer; + cdecl; external XPLM_DLL; + +{___________________________________________________________________________ + * WINDOW API + ___________________________________________________________________________} +{ + The window API provides a high-level abstraction for drawing with UI + interaction. + + Windows may operate in one of two modes: legacy (for plugins compiled + against old versions of the XPLM, as well as windows created via the + deprecated XPLMCreateWindow() function, rather than XPLMCreateWindowEx()), + or modern (for windows compiled against the XPLM300 or newer API, and + created via XPLMCreateWindowEx()). + + Modern windows have access to new X-Plane 11 windowing features, like + support for new positioning modes (including being "popped out" into their + own first-class window in the operating system). They can also optionally + be decorated in the style of X-Plane 11 windows (like the map). + + Modern windows operate in "boxel" units. A boxel ("box of pixels") is a + unit of virtual pixels which, depending on X-Plane's scaling, may + correspond to an arbitrary NxN "box" of real pixels on screen. Because + X-Plane handles this scaling automatically, you can effectively treat the + units as though you were simply drawing in pixels, and know that when + X-Plane is running with 150% or 200% scaling, your drawing will be + automatically scaled (and likewise all mouse coordinates, screen bounds, + etc. will also be auto-scaled). + + In contrast, legacy windows draw in true screen pixels, and thus tend to + look quite small when X-Plane is operating in a scaled mode. + + Legacy windows have their origin in the lower left of the main X-Plane + window. In contrast, since modern windows are not constrained to the main + window, they have their origin in the lower left of the entire global + desktop space, and the lower left of the main X-Plane window is not + guaranteed to be (0, 0). In both cases, x increases as you move left, and y + increases as you move up. +} + + +TYPE + { + XPLMWindowID + + This is an opaque identifier for a window. You use it to control your + window. When you create a window (via either XPLMCreateWindow() or + XPLMCreateWindowEx()), you will specify callbacks to handle drawing, mouse + interaction, etc. + } + XPLMWindowID = pointer; + PXPLMWindowID = ^XPLMWindowID; + + { + XPLMDrawWindow_f + + A callback to handle 2-D drawing of your window. You are passed in your + window and its refcon. Draw the window. You can use other XPLM functions + from this header to find the current dimensions of your window, etc. When + this callback is called, the OpenGL context will be set properly for 2-D + window drawing. + + **Note**: Because you are drawing your window over a background, you can + make a translucent window easily by simply not filling in your entire + window's bounds. + } + XPLMDrawWindow_f = PROCEDURE( + inWindowID : XPLMWindowID; + inRefcon : pointer); cdecl; + + { + XPLMHandleKey_f + + This function is called when a key is pressed or keyboard focus is taken + away from your window. If losingFocus is 1, you are losing the keyboard + focus, otherwise a key was pressed and inKey contains its character. You + are also passed your window and a refcon. + + Warning: this API declares virtual keys as a signed character; however the + VKEY #define macros in XPLMDefs.h define the vkeys using unsigned values + (that is 0x80 instead of -0x80). So you may need to cast the incoming vkey + to an unsigned char to get correct comparisons in C. + } + XPLMHandleKey_f = PROCEDURE( + inWindowID : XPLMWindowID; + inKey : XPLMChar; + inFlags : XPLMKeyFlags; + inVirtualKey : XPLMChar; + inRefcon : pointer; + losingFocus : Integer); cdecl; + + { + XPLMMouseStatus + + When the mouse is clicked, your mouse click routine is called repeatedly. + It is first called with the mouse down message. It is then called zero or + more times with the mouse-drag message, and finally it is called once with + the mouse up message. All of these messages will be directed to the same + window; you are guaranteed to not receive a drag or mouse-up event without + first receiving the corresponding mouse-down. + } + XPLMMouseStatus = ( + xplm_MouseDown = 1 + + ,xplm_MouseDrag = 2 + + ,xplm_MouseUp = 3 + + ); + PXPLMMouseStatus = ^XPLMMouseStatus; + + { + XPLMHandleMouseClick_f + + You receive this call for one of three events: + + - when the user clicks the mouse button down + - (optionally) when the user drags the mouse after a down-click, but before + the up-click + - when the user releases the down-clicked mouse button. + + You receive the x and y of the click, your window, and a refcon. Return 1 + to consume the click, or 0 to pass it through. + + WARNING: passing clicks through windows (as of this writing) causes mouse + tracking problems in X-Plane; do not use this feature! + + The units for x and y values match the units used in your window. Thus, for + "modern" windows (those created via XPLMCreateWindowEx() and compiled + against the XPLM300 library), the units are boxels, while legacy windows + will get pixels. Legacy windows have their origin in the lower left of the + main X-Plane window, while modern windows have their origin in the lower + left of the global desktop space. In both cases, x increases as you move + right, and y increases as you move up. + } + XPLMHandleMouseClick_f = FUNCTION( + inWindowID : XPLMWindowID; + x : Integer; + y : Integer; + inMouse : XPLMMouseStatus; + inRefcon : pointer) : Integer; cdecl; + +{$IFDEF XPLM200} + { + XPLMCursorStatus + + XPLMCursorStatus describes how you would like X-Plane to manage the cursor. + See XPLMHandleCursor_f for more info. + } +TYPE + XPLMCursorStatus = ( + { X-Plane manages the cursor normally, plugin does not affect the cusrsor. } + xplm_CursorDefault = 0 + + { X-Plane hides the cursor. } + ,xplm_CursorHidden = 1 + + { X-Plane shows the cursor as the default arrow. } + ,xplm_CursorArrow = 2 + + { X-Plane shows the cursor but lets you select an OS cursor. } + ,xplm_CursorCustom = 3 + + ); + PXPLMCursorStatus = ^XPLMCursorStatus; +{$ENDIF XPLM200} + +{$IFDEF XPLM200} + { + XPLMHandleCursor_f + + The SDK calls your cursor status callback when the mouse is over your + plugin window. Return a cursor status code to indicate how you would like + X-Plane to manage the cursor. If you return xplm_CursorDefault, the SDK + will try lower-Z-order plugin windows, then let the sim manage the cursor. + + Note: you should never show or hide the cursor yourself---these APIs are + typically reference-counted and thus cannot safely and predictably be used + by the SDK. Instead return one of xplm_CursorHidden to hide the cursor or + xplm_CursorArrow/xplm_CursorCustom to show the cursor. + + If you want to implement a custom cursor by drawing a cursor in OpenGL, use + xplm_CursorHidden to hide the OS cursor and draw the cursor using a 2-d + drawing callback (after xplm_Phase_Window is probably a good choice, but + see deprecation warnings on the drawing APIs!). If you want to use a + custom OS-based cursor, use xplm_CursorCustom to ask X-Plane to show the + cursor but not affect its image. You can then use an OS specific call like + SetThemeCursor (Mac) or SetCursor/LoadCursor (Windows). + + The units for x and y values match the units used in your window. Thus, for + "modern" windows (those created via XPLMCreateWindowEx() and compiled + against the XPLM300 library), the units are boxels, while legacy windows + will get pixels. Legacy windows have their origin in the lower left of the + main X-Plane window, while modern windows have their origin in the lower + left of the global desktop space. In both cases, x increases as you move + right, and y increases as you move up. + } + XPLMHandleCursor_f = FUNCTION( + inWindowID : XPLMWindowID; + x : Integer; + y : Integer; + inRefcon : pointer) : XPLMCursorStatus; cdecl; +{$ENDIF XPLM200} + +{$IFDEF XPLM200} + { + XPLMHandleMouseWheel_f + + The SDK calls your mouse wheel callback when one of the mouse wheels is + scrolled within your window. Return 1 to consume the mouse wheel movement + or 0 to pass them on to a lower window. (If your window appears opaque to + the user, you should consume mouse wheel scrolling even if it does + nothing.) The number of "clicks" indicates how far the wheel was turned + since the last callback. The wheel is 0 for the vertical axis or 1 for the + horizontal axis (for OS/mouse combinations that support this). + + The units for x and y values match the units used in your window. Thus, for + "modern" windows (those created via XPLMCreateWindowEx() and compiled + against the XPLM300 library), the units are boxels, while legacy windows + will get pixels. Legacy windows have their origin in the lower left of the + main X-Plane window, while modern windows have their origin in the lower + left of the global desktop space. In both cases, x increases as you move + right, and y increases as you move up. + } + XPLMHandleMouseWheel_f = FUNCTION( + inWindowID : XPLMWindowID; + x : Integer; + y : Integer; + wheel : Integer; + clicks : Integer; + inRefcon : pointer) : Integer; cdecl; +{$ENDIF XPLM200} + +{$IFDEF XPLM300} + { + XPLMWindowLayer + + XPLMWindowLayer describes where in the ordering of windows X-Plane should + place a particular window. Windows in higher layers cover windows in lower + layers. So, a given window might be at the top of its particular layer, but + it might still be obscured by a window in a higher layer. (This happens + frequently when floating windows, like X-Plane's map, are covered by a + modal alert.) + + Your window's layer can only be specified when you create the window (in + the XPLMCreateWindow_t you pass to XPLMCreateWindowEx()). For this reason, + layering only applies to windows created with new X-Plane 11 GUI features. + (Windows created using the older XPLMCreateWindow(), or windows compiled + against a pre-XPLM300 version of the SDK will simply be placed in the + flight overlay window layer.) + } +TYPE + XPLMWindowLayer = ( + { The lowest layer, used for HUD-like displays while flying. } + xplm_WindowLayerFlightOverlay = 0 + + { Windows that "float" over the sim, like the X-Plane 11 map does. If you are} + { not sure which layer to create your window in, choose floating. } + ,xplm_WindowLayerFloatingWindows = 1 + + { An interruptive modal that covers the sim with a transparent black overlay } + { to draw the user's focus to the alert } + ,xplm_WindowLayerModal = 2 + + { "Growl"-style notifications that are visible in a corner of the screen, } + { even over modals } + ,xplm_WindowLayerGrowlNotifications = 3 + + ); + PXPLMWindowLayer = ^XPLMWindowLayer; +{$ENDIF XPLM300} + +{$IFDEF XPLM301} + { + XPLMWindowDecoration + + XPLMWindowDecoration describes how "modern" windows will be displayed. This + impacts both how X-Plane draws your window as well as certain mouse + handlers. + + Your window's decoration can only be specified when you create the window + (in the XPLMCreateWindow_t you pass to XPLMCreateWindowEx()). + } +TYPE + XPLMWindowDecoration = ( + { X-Plane will draw no decoration for your window, and apply no automatic } + { click handlers. The window will not stop click from passing through its } + { bounds. This is suitable for "windows" which request, say, the full screen } + { bounds, then only draw in a small portion of the available area. } + xplm_WindowDecorationNone = 0 + + { The default decoration for "native" windows, like the map. Provides a solid} + { background, as well as click handlers for resizing and dragging the window.} + ,xplm_WindowDecorationRoundRectangle = 1 + + { X-Plane will draw no decoration for your window, nor will it provide resize} + { handlers for your window edges, but it will stop clicks from passing } + { through your windows bounds. } + ,xplm_WindowDecorationSelfDecorated = 2 + + { Like self-decorated, but with resizing; X-Plane will draw no decoration for} + { your window, but it will stop clicks from passing through your windows } + { bounds, and provide automatic mouse handlers for resizing. } + ,xplm_WindowDecorationSelfDecoratedResizable = 3 + + ); + PXPLMWindowDecoration = ^XPLMWindowDecoration; +{$ENDIF XPLM301} + +{$IFDEF XPLM200} + { + XPLMCreateWindow_t + + The XPMCreateWindow_t structure defines all of the parameters used to + create a modern window using XPLMCreateWindowEx(). The structure will be + expanded in future SDK APIs to include more features. Always set the + structSize member to the size of your struct in bytes! + + All windows created by this function in the XPLM300 version of the API are + created with the new X-Plane 11 GUI features. This means your plugin will + get to "know" about the existence of X-Plane windows other than the main + window. All drawing and mouse callbacks for your window will occur in + "boxels," giving your windows automatic support for high-DPI scaling in + X-Plane. In addition, your windows can opt-in to decoration with the + X-Plane 11 window styling, and you can use the + XPLMSetWindowPositioningMode() API to make your window "popped out" into a + first-class operating system window. + + Note that this requires dealing with your window's bounds in "global + desktop" positioning units, rather than the traditional panel coordinate + system. In global desktop coordinates, the main X-Plane window may not have + its origin at coordinate (0, 0), and your own window may have negative + coordinates. Assuming you don't implicitly assume (0, 0) as your origin, + the only API change you should need is to start using + XPLMGetMouseLocationGlobal() rather than XPLMGetMouseLocation(), and + XPLMGetScreenBoundsGlobal() instead of XPLMGetScreenSize(). + + If you ask to be decorated as a floating window, you'll get the blue window + control bar and blue backing that you see in X-Plane 11's normal "floating" + windows (like the map). + } +TYPE + XPLMCreateWindow_t = RECORD + { Used to inform XPLMCreateWindowEx() of the SDK version you compiled } + { against; should always be set to sizeof(XPLMCreateWindow_t) } + structSize : Integer; + { Left bound, in global desktop boxels } + left : Integer; + { Top bound, in global desktop boxels } + top : Integer; + { Right bound, in global desktop boxels } + right : Integer; + { Bottom bound, in global desktop boxels } + bottom : Integer; + visible : Integer; + drawWindowFunc : XPLMDrawWindow_f; + { A callback to handle the user left-clicking within your window (or NULL to } + { ignore left clicks) } + handleMouseClickFunc : XPLMHandleMouseClick_f; + handleKeyFunc : XPLMHandleKey_f; + handleCursorFunc : XPLMHandleCursor_f; + handleMouseWheelFunc : XPLMHandleMouseWheel_f; + { A reference which will be passed into each of your window callbacks. Use } + { this to pass information to yourself as needed. } + refcon : pointer; +{$IFDEF XPLM301} + { Specifies the type of X-Plane 11-style "wrapper" you want around your } + { window, if any } + decorateAsFloatingWindow : XPLMWindowDecoration; +{$ENDIF XPLM301} +{$IFDEF XPLM300} + layer : XPLMWindowLayer; +{$ENDIF XPLM300} +{$IFDEF XPLM300} + { A callback to handle the user right-clicking within your window (or NULL to} + { ignore right clicks) } + handleRightClickFunc : XPLMHandleMouseClick_f; +{$ENDIF XPLM300} + END; + PXPLMCreateWindow_t = ^XPLMCreateWindow_t; +{$ENDIF XPLM200} + +{$IFDEF XPLM200} + { + XPLMCreateWindowEx + + This routine creates a new "modern" window. You pass in an + XPLMCreateWindow_t structure with all of the fields set in. You must set + the structSize of the structure to the size of the actual structure you + used. Also, you must provide functions for every callback---you may not + leave them null! (If you do not support the cursor or mouse wheel, use + functions that return the default values.) + } + FUNCTION XPLMCreateWindowEx( + inParams : PXPLMCreateWindow_t) : XPLMWindowID; + cdecl; external XPLM_DLL; +{$ENDIF XPLM200} + + { + XPLMCreateWindow + + Deprecated as of XPLM300. + + This routine creates a new legacy window. Unlike modern windows (created + via XPLMCreateWindowEx()), legacy windows do not have access to X-Plane 11 + features like automatic scaling for high-DPI screens, native window styles, + or support for being "popped out" into first-class operating system + windows. + + Pass in the dimensions and offsets to the window's bottom left corner from + the bottom left of the screen. You can specify whether the window is + initially visible or not. Also, you pass in three callbacks to run the + window and a refcon. This function returns a window ID you can use to + refer to the new window. + + NOTE: Legacy windows do not have "frames"; you are responsible for drawing + the background and frame of the window. Higher level libraries have + routines which make this easy. + } + FUNCTION XPLMCreateWindow( + inLeft : Integer; + inTop : Integer; + inRight : Integer; + inBottom : Integer; + inIsVisible : Integer; + inDrawCallback : XPLMDrawWindow_f; + inKeyCallback : XPLMHandleKey_f; + inMouseCallback : XPLMHandleMouseClick_f; + inRefcon : pointer) : XPLMWindowID; + cdecl; external XPLM_DLL; + + { + XPLMDestroyWindow + + This routine destroys a window. The window's callbacks are not called + after this call. Keyboard focus is removed from the window before + destroying it. + } + PROCEDURE XPLMDestroyWindow( + inWindowID : XPLMWindowID); + cdecl; external XPLM_DLL; + + { + XPLMGetScreenSize + + This routine returns the size of the main X-Plane OpenGL window in pixels. + This number can be used to get a rough idea of the amount of detail the + user will be able to see when drawing in 3-d. + } + PROCEDURE XPLMGetScreenSize( + outWidth : PInteger; { Can be nil } + outHeight : PInteger); { Can be nil } + cdecl; external XPLM_DLL; + +{$IFDEF XPLM300} + { + XPLMGetScreenBoundsGlobal + + This routine returns the bounds of the "global" X-Plane desktop, in boxels. + Unlike the non-global version XPLMGetScreenSize(), this is multi-monitor + aware. There are three primary consequences of multimonitor awareness. + + First, if the user is running X-Plane in full-screen on two or more + monitors (typically configured using one full-screen window per monitor), + the global desktop will be sized to include all X-Plane windows. + + Second, the origin of the screen coordinates is not guaranteed to be (0, + 0). Suppose the user has two displays side-by-side, both running at 1080p. + Suppose further that they've configured their OS to make the left display + their "primary" monitor, and that X-Plane is running in full-screen on + their right monitor only. In this case, the global desktop bounds would be + the rectangle from (1920, 0) to (3840, 1080). If the user later asked + X-Plane to draw on their primary monitor as well, the bounds would change + to (0, 0) to (3840, 1080). + + Finally, if the usable area of the virtual desktop is not a perfect + rectangle (for instance, because the monitors have different resolutions or + because one monitor is configured in the operating system to be above and + to the right of the other), the global desktop will include any wasted + space. Thus, if you have two 1080p monitors, and monitor 2 is configured to + have its bottom left touch monitor 1's upper right, your global desktop + area would be the rectangle from (0, 0) to (3840, 2160). + + Note that popped-out windows (windows drawn in their own operating system + windows, rather than "floating" within X-Plane) are not included in these + bounds. + } + PROCEDURE XPLMGetScreenBoundsGlobal( + outLeft : PInteger; { Can be nil } + outTop : PInteger; { Can be nil } + outRight : PInteger; { Can be nil } + outBottom : PInteger); { Can be nil } + cdecl; external XPLM_DLL; +{$ENDIF XPLM300} + +{$IFDEF XPLM300} + { + XPLMReceiveMonitorBoundsGlobal_f + + This function is informed of the global bounds (in boxels) of a particular + monitor within the X-Plane global desktop space. Note that X-Plane must be + running in full screen on a monitor in order for that monitor to be passed + to you in this callback. + } +TYPE + XPLMReceiveMonitorBoundsGlobal_f = PROCEDURE( + inMonitorIndex : Integer; + inLeftBx : Integer; + inTopBx : Integer; + inRightBx : Integer; + inBottomBx : Integer; + inRefcon : pointer); cdecl; +{$ENDIF XPLM300} + +{$IFDEF XPLM300} + { + XPLMGetAllMonitorBoundsGlobal + + This routine immediately calls you back with the bounds (in boxels) of each + full-screen X-Plane window within the X-Plane global desktop space. Note + that if a monitor is *not* covered by an X-Plane window, you cannot get its + bounds this way. Likewise, monitors with only an X-Plane window (not in + full-screen mode) will not be included. + + If X-Plane is running in full-screen and your monitors are of the same size + and configured contiguously in the OS, then the combined global bounds of + all full-screen monitors will match the total global desktop bounds, as + returned by XPLMGetScreenBoundsGlobal(). (Of course, if X-Plane is running + in windowed mode, this will not be the case. Likewise, if you have + differently sized monitors, the global desktop space will include wasted + space.) + + Note that this function's monitor indices match those provided by + XPLMGetAllMonitorBoundsOS(), but the coordinates are different (since the + X-Plane global desktop may not match the operating system's global desktop, + and one X-Plane boxel may be larger than one pixel due to 150% or 200% + scaling). + } + PROCEDURE XPLMGetAllMonitorBoundsGlobal( + inMonitorBoundsCallback: XPLMReceiveMonitorBoundsGlobal_f; + inRefcon : pointer); + cdecl; external XPLM_DLL; +{$ENDIF XPLM300} + +{$IFDEF XPLM300} + { + XPLMReceiveMonitorBoundsOS_f + + This function is informed of the global bounds (in pixels) of a particular + monitor within the operating system's global desktop space. Note that a + monitor index being passed to you here does not indicate that X-Plane is + running in full screen on this monitor, or even that any X-Plane windows + exist on this monitor. + } +TYPE + XPLMReceiveMonitorBoundsOS_f = PROCEDURE( + inMonitorIndex : Integer; + inLeftPx : Integer; + inTopPx : Integer; + inRightPx : Integer; + inBottomPx : Integer; + inRefcon : pointer); cdecl; +{$ENDIF XPLM300} + +{$IFDEF XPLM300} + { + XPLMGetAllMonitorBoundsOS + + This routine immediately calls you back with the bounds (in pixels) of each + monitor within the operating system's global desktop space. Note that + unlike XPLMGetAllMonitorBoundsGlobal(), this may include monitors that have + no X-Plane window on them. + + Note that this function's monitor indices match those provided by + XPLMGetAllMonitorBoundsGlobal(), but the coordinates are different (since + the X-Plane global desktop may not match the operating system's global + desktop, and one X-Plane boxel may be larger than one pixel). + } + PROCEDURE XPLMGetAllMonitorBoundsOS( + inMonitorBoundsCallback: XPLMReceiveMonitorBoundsOS_f; + inRefcon : pointer); + cdecl; external XPLM_DLL; +{$ENDIF XPLM300} + + { + XPLMGetMouseLocation + + Deprecated in XPLM300. Modern windows should use + XPLMGetMouseLocationGlobal() instead. + + This routine returns the current mouse location in pixels relative to the + main X-Plane window. The bottom left corner of the main window is (0, 0). + Pass NULL to not receive info about either parameter. + + Because this function gives the mouse position relative to the main X-Plane + window (rather than in global bounds), this function should only be used by + legacy windows. Modern windows should instead get the mouse position in + global desktop coordinates using XPLMGetMouseLocationGlobal(). + + Note that unlike XPLMGetMouseLocationGlobal(), if the mouse goes outside + the user's main monitor (for instance, to a pop out window or a secondary + monitor), this function will not reflect it. + } + PROCEDURE XPLMGetMouseLocation( + outX : PInteger; { Can be nil } + outY : PInteger); { Can be nil } + cdecl; external XPLM_DLL; + +{$IFDEF XPLM300} + { + XPLMGetMouseLocationGlobal + + Returns the current mouse location in global desktop boxels. Unlike + XPLMGetMouseLocation(), the bottom left of the main X-Plane window is not + guaranteed to be (0, 0)---instead, the origin is the lower left of the + entire global desktop space. In addition, this routine gives the real mouse + location when the mouse goes to X-Plane windows other than the primary + display. Thus, it can be used with both pop-out windows and secondary + monitors. + + This is the mouse location function to use with modern windows (i.e., those + created by XPLMCreateWindowEx()). + + Pass NULL to not receive info about either parameter. + } + PROCEDURE XPLMGetMouseLocationGlobal( + outX : PInteger; { Can be nil } + outY : PInteger); { Can be nil } + cdecl; external XPLM_DLL; +{$ENDIF XPLM300} + + { + XPLMGetWindowGeometry + + This routine returns the position and size of a window. The units and + coordinate system vary depending on the type of window you have. + + If this is a legacy window (one compiled against a pre-XPLM300 version of + the SDK, or an XPLM300 window that was not created using + XPLMCreateWindowEx()), the units are pixels relative to the main X-Plane + display. + + If, on the other hand, this is a new X-Plane 11-style window (compiled + against the XPLM300 SDK and created using XPLMCreateWindowEx()), the units + are global desktop boxels. + + Pass NULL to not receive any paramter. + } + PROCEDURE XPLMGetWindowGeometry( + inWindowID : XPLMWindowID; + outLeft : PInteger; { Can be nil } + outTop : PInteger; { Can be nil } + outRight : PInteger; { Can be nil } + outBottom : PInteger); { Can be nil } + cdecl; external XPLM_DLL; + + { + XPLMSetWindowGeometry + + This routine allows you to set the position and size of a window. + + The units and coordinate system match those of XPLMGetWindowGeometry(). + That is, modern windows use global desktop boxel coordinates, while legacy + windows use pixels relative to the main X-Plane display. + + Note that this only applies to "floating" windows (that is, windows that + are drawn within the X-Plane simulation windows, rather than being "popped + out" into their own first-class operating system windows). To set the + position of windows whose positioning mode is xplm_WindowPopOut, you'll + need to instead use XPLMSetWindowGeometryOS(). + } + PROCEDURE XPLMSetWindowGeometry( + inWindowID : XPLMWindowID; + inLeft : Integer; + inTop : Integer; + inRight : Integer; + inBottom : Integer); + cdecl; external XPLM_DLL; + +{$IFDEF XPLM300} + { + XPLMGetWindowGeometryOS + + This routine returns the position and size of a "popped out" window (i.e., + a window whose positioning mode is xplm_WindowPopOut), in operating system + pixels. Pass NULL to not receive any parameter. + } + PROCEDURE XPLMGetWindowGeometryOS( + inWindowID : XPLMWindowID; + outLeft : PInteger; { Can be nil } + outTop : PInteger; { Can be nil } + outRight : PInteger; { Can be nil } + outBottom : PInteger); { Can be nil } + cdecl; external XPLM_DLL; +{$ENDIF XPLM300} + +{$IFDEF XPLM300} + { + XPLMSetWindowGeometryOS + + This routine allows you to set the position and size, in operating system + pixel coordinates, of a popped out window (that is, a window whose + positioning mode is xplm_WindowPopOut, which exists outside the X-Plane + simulation window, in its own first-class operating system window). + + Note that you are responsible for ensuring both that your window is popped + out (using XPLMWindowIsPoppedOut()) and that a monitor really exists at the + OS coordinates you provide (using XPLMGetAllMonitorBoundsOS()). + } + PROCEDURE XPLMSetWindowGeometryOS( + inWindowID : XPLMWindowID; + inLeft : Integer; + inTop : Integer; + inRight : Integer; + inBottom : Integer); + cdecl; external XPLM_DLL; +{$ENDIF XPLM300} + +{$IFDEF XPLM301} + { + XPLMGetWindowGeometryVR + + Returns the width and height, in boxels, of a window in VR. Note that you + are responsible for ensuring your window is in VR (using + XPLMWindowIsInVR()). + } + PROCEDURE XPLMGetWindowGeometryVR( + inWindowID : XPLMWindowID; + outWidthBoxels : PInteger; { Can be nil } + outHeightBoxels : PInteger); { Can be nil } + cdecl; external XPLM_DLL; +{$ENDIF XPLM301} + +{$IFDEF XPLM301} + { + XPLMSetWindowGeometryVR + + This routine allows you to set the size, in boxels, of a window in VR (that + is, a window whose positioning mode is xplm_WindowVR). + + Note that you are responsible for ensuring your window is in VR (using + XPLMWindowIsInVR()). + } + PROCEDURE XPLMSetWindowGeometryVR( + inWindowID : XPLMWindowID; + widthBoxels : Integer; + heightBoxels : Integer); + cdecl; external XPLM_DLL; +{$ENDIF XPLM301} + + { + XPLMGetWindowIsVisible + + Returns true (1) if the specified window is visible. + } + FUNCTION XPLMGetWindowIsVisible( + inWindowID : XPLMWindowID) : Integer; + cdecl; external XPLM_DLL; + + { + XPLMSetWindowIsVisible + + This routine shows or hides a window. + } + PROCEDURE XPLMSetWindowIsVisible( + inWindowID : XPLMWindowID; + inIsVisible : Integer); + cdecl; external XPLM_DLL; + +{$IFDEF XPLM300} + { + XPLMWindowIsPoppedOut + + True if this window has been popped out (making it a first-class window in + the operating system), which in turn is true if and only if you have set + the window's positioning mode to xplm_WindowPopOut. + + Only applies to modern windows. (Windows created using the deprecated + XPLMCreateWindow(), or windows compiled against a pre-XPLM300 version of + the SDK cannot be popped out.) + } + FUNCTION XPLMWindowIsPoppedOut( + inWindowID : XPLMWindowID) : Integer; + cdecl; external XPLM_DLL; +{$ENDIF XPLM300} + +{$IFDEF XPLM301} + { + XPLMWindowIsInVR + + True if this window has been moved to the virtual reality (VR) headset, + which in turn is true if and only if you have set the window's positioning + mode to xplm_WindowVR. + + Only applies to modern windows. (Windows created using the deprecated + XPLMCreateWindow(), or windows compiled against a pre-XPLM301 version of + the SDK cannot be moved to VR.) + } + FUNCTION XPLMWindowIsInVR( + inWindowID : XPLMWindowID) : Integer; + cdecl; external XPLM_DLL; +{$ENDIF XPLM301} + +{$IFDEF XPLM300} + { + XPLMSetWindowGravity + + A window's "gravity" controls how the window shifts as the whole X-Plane + window resizes. A gravity of 1 means the window maintains its positioning + relative to the right or top edges, 0 the left/bottom, and 0.5 keeps it + centered. + + Default gravity is (0, 1, 0, 1), meaning your window will maintain its + position relative to the top left and will not change size as its + containing window grows. + + If you wanted, say, a window that sticks to the top of the screen (with a + constant height), but which grows to take the full width of the window, you + would pass (0, 1, 1, 1). Because your left and right edges would maintain + their positioning relative to their respective edges of the screen, the + whole width of your window would change with the X-Plane window. + + Only applies to modern windows. (Windows created using the deprecated + XPLMCreateWindow(), or windows compiled against a pre-XPLM300 version of + the SDK will simply get the default gravity.) + } + PROCEDURE XPLMSetWindowGravity( + inWindowID : XPLMWindowID; + inLeftGravity : Single; + inTopGravity : Single; + inRightGravity : Single; + inBottomGravity : Single); + cdecl; external XPLM_DLL; +{$ENDIF XPLM300} + +{$IFDEF XPLM300} + { + XPLMSetWindowResizingLimits + + Sets the minimum and maximum size of the client rectangle of the given + window. (That is, it does not include any window styling that you might + have asked X-Plane to apply on your behalf.) All resizing operations are + constrained to these sizes. + + Only applies to modern windows. (Windows created using the deprecated + XPLMCreateWindow(), or windows compiled against a pre-XPLM300 version of + the SDK will have no minimum or maximum size.) + } + PROCEDURE XPLMSetWindowResizingLimits( + inWindowID : XPLMWindowID; + inMinWidthBoxels : Integer; + inMinHeightBoxels : Integer; + inMaxWidthBoxels : Integer; + inMaxHeightBoxels : Integer); + cdecl; external XPLM_DLL; +{$ENDIF XPLM300} + +{$IFDEF XPLM300} + { + XPLMWindowPositioningMode + + XPLMWindowPositionMode describes how X-Plane will position your window on + the user's screen. X-Plane will maintain this positioning mode even as the + user resizes their window or adds/removes full-screen monitors. + + Positioning mode can only be set for "modern" windows (that is, windows + created using XPLMCreateWindowEx() and compiled against the XPLM300 SDK). + Windows created using the deprecated XPLMCreateWindow(), or windows + compiled against a pre-XPLM300 version of the SDK will simply get the + "free" positioning mode. + } +TYPE + XPLMWindowPositioningMode = ( + { The default positioning mode. Set the window geometry and its future } + { position will be determined by its window gravity, resizing limits, and } + { user interactions. } + xplm_WindowPositionFree = 0 + + { Keep the window centered on the monitor you specify } + ,xplm_WindowCenterOnMonitor = 1 + + { Keep the window full screen on the monitor you specify } + ,xplm_WindowFullScreenOnMonitor = 2 + + { Like gui_window_full_screen_on_monitor, but stretches over *all* monitors } + { and popout windows. This is an obscure one... unless you have a very good } + { reason to need it, you probably don't! } + ,xplm_WindowFullScreenOnAllMonitors = 3 + + { A first-class window in the operating system, completely separate from the } + { X-Plane window(s) } + ,xplm_WindowPopOut = 4 + +{$IFDEF XPLM301} + { A floating window visible on the VR headset } + ,xplm_WindowVR = 5 +{$ENDIF XPLM301} + + ); + PXPLMWindowPositioningMode = ^XPLMWindowPositioningMode; +{$ENDIF XPLM300} + +{$IFDEF XPLM300} + { + XPLMSetWindowPositioningMode + + Sets the policy for how X-Plane will position your window. + + Some positioning modes apply to a particular monitor. For those modes, you + can pass a negative monitor index to position the window on the main + X-Plane monitor (the screen with the X-Plane menu bar at the top). Or, if + you have a specific monitor you want to position your window on, you can + pass a real monitor index as received from, e.g., + XPLMGetAllMonitorBoundsOS(). + + Only applies to modern windows. (Windows created using the deprecated + XPLMCreateWindow(), or windows compiled against a pre-XPLM300 version of + the SDK will always use xplm_WindowPositionFree.) + } + PROCEDURE XPLMSetWindowPositioningMode( + inWindowID : XPLMWindowID; + inPositioningMode : XPLMWindowPositioningMode; + inMonitorIndex : Integer); + cdecl; external XPLM_DLL; +{$ENDIF XPLM300} + +{$IFDEF XPLM300} + { + XPLMSetWindowTitle + + Sets the name for a window. This only applies to windows that opted-in to + styling as an X-Plane 11 floating window (i.e., with styling mode + xplm_WindowDecorationRoundRectangle) when they were created using + XPLMCreateWindowEx(). + } + PROCEDURE XPLMSetWindowTitle( + inWindowID : XPLMWindowID; + inWindowTitle : XPLMString); + cdecl; external XPLM_DLL; +{$ENDIF XPLM300} + + { + XPLMGetWindowRefCon + + Returns a window's reference constant, the unique value you can use for + your own purposes. + } + FUNCTION XPLMGetWindowRefCon( + inWindowID : XPLMWindowID) : pointer; + cdecl; external XPLM_DLL; + + { + XPLMSetWindowRefCon + + Sets a window's reference constant. Use this to pass data to yourself in + the callbacks. + } + PROCEDURE XPLMSetWindowRefCon( + inWindowID : XPLMWindowID; + inRefcon : pointer); + cdecl; external XPLM_DLL; + + { + XPLMTakeKeyboardFocus + + This routine gives a specific window keyboard focus. Keystrokes will be + sent to that window. Pass a window ID of 0 to remove keyboard focus from + any plugin-created windows and instead pass keyboard strokes directly to + X-Plane. + } + PROCEDURE XPLMTakeKeyboardFocus( + inWindow : XPLMWindowID); + cdecl; external XPLM_DLL; + + { + XPLMHasKeyboardFocus + + Returns true (1) if the indicated window has keyboard focus. Pass a window + ID of 0 to see if no plugin window has focus, and all keystrokes will go + directly to X-Plane. + } + FUNCTION XPLMHasKeyboardFocus( + inWindow : XPLMWindowID) : Integer; + cdecl; external XPLM_DLL; + + { + XPLMBringWindowToFront + + This routine brings the window to the front of the Z-order for its layer. + Windows are brought to the front automatically when they are created. + Beyond that, you should make sure you are front before handling mouse + clicks. + + Note that this only brings your window to the front of its layer + (XPLMWindowLayer). Thus, if you have a window in the floating window layer + (xplm_WindowLayerFloatingWindows), but there is a modal window (in layer + xplm_WindowLayerModal) above you, you would still not be the true frontmost + window after calling this. (After all, the window layers are strictly + ordered, and no window in a lower layer can ever be above any window in a + higher one.) + } + PROCEDURE XPLMBringWindowToFront( + inWindow : XPLMWindowID); + cdecl; external XPLM_DLL; + + { + XPLMIsWindowInFront + + This routine returns true if the window you passed in is the frontmost + visible window in its layer (XPLMWindowLayer). + + Thus, if you have a window at the front of the floating window layer + (xplm_WindowLayerFloatingWindows), this will return true even if there is a + modal window (in layer xplm_WindowLayerModal) above you. (Not to worry, + though: in such a case, X-Plane will not pass clicks or keyboard input down + to your layer until the window above stops "eating" the input.) + + Note that legacy windows are always placed in layer + xplm_WindowLayerFlightOverlay, while modern-style windows default to + xplm_WindowLayerFloatingWindows. This means it's perfectly consistent to + have two different plugin-created windows (one legacy, one modern) *both* + be in the front (of their different layers!) at the same time. + } + FUNCTION XPLMIsWindowInFront( + inWindow : XPLMWindowID) : Integer; + cdecl; external XPLM_DLL; + +{___________________________________________________________________________ + * KEY SNIFFERS + ___________________________________________________________________________} +{ + Low-level keyboard handlers. Allows for intercepting keystrokes outside the + normal rules of the user interface. +} + + + { + XPLMKeySniffer_f + + This is the prototype for a low level key-sniffing function. Window-based + UI _should not use this_! The windowing system provides high-level + mediated keyboard access, via the callbacks you attach to your + XPLMCreateWindow_t. By comparison, the key sniffer provides low level + keyboard access. + + Key sniffers are provided to allow libraries to provide non-windowed user + interaction. For example, the MUI library uses a key sniffer to do pop-up + text entry. + + Return 1 to pass the key on to the next sniffer, the window manager, + X-Plane, or whomever is down stream. Return 0 to consume the key. + + Warning: this API declares virtual keys as a signed character; however the + VKEY #define macros in XPLMDefs.h define the vkeys using unsigned values + (that is 0x80 instead of -0x80). So you may need to cast the incoming vkey + to an unsigned char to get correct comparisons in C. + } +TYPE + XPLMKeySniffer_f = FUNCTION( + inChar : XPLMChar; + inFlags : XPLMKeyFlags; + inVirtualKey : XPLMChar; + inRefcon : pointer) : Integer; cdecl; + + { + XPLMRegisterKeySniffer + + This routine registers a key sniffing callback. You specify whether you + want to sniff before the window system, or only sniff keys the window + system does not consume. You should ALMOST ALWAYS sniff non-control keys + after the window system. When the window system consumes a key, it is + because the user has "focused" a window. Consuming the key or taking + action based on the key will produce very weird results. Returns + 1 if successful. + } + FUNCTION XPLMRegisterKeySniffer( + inCallback : XPLMKeySniffer_f; + inBeforeWindows : Integer; + inRefcon : pointer) : Integer; + cdecl; external XPLM_DLL; + + { + XPLMUnregisterKeySniffer + + This routine unregisters a key sniffer. You must unregister a key sniffer + for every time you register one with the exact same signature. Returns 1 + if successful. + } + FUNCTION XPLMUnregisterKeySniffer( + inCallback : XPLMKeySniffer_f; + inBeforeWindows : Integer; + inRefcon : pointer) : Integer; + cdecl; external XPLM_DLL; + +{___________________________________________________________________________ + * HOT KEYS + ___________________________________________________________________________} +{ + Keystrokes that can be managed by others. These are lower-level than window + keyboard handlers (i.e., callbacks you attach to your XPLMCreateWindow_t), + but higher level than key sniffers. +} + + + { + XPLMHotKey_f + + Your hot key callback simply takes a pointer of your choosing. + } +TYPE + XPLMHotKey_f = PROCEDURE( + inRefcon : pointer); cdecl; + + { + XPLMHotKeyID + + An opaque ID used to identify a hot key. + } + XPLMHotKeyID = pointer; + PXPLMHotKeyID = ^XPLMHotKeyID; + + { + XPLMRegisterHotKey + + This routine registers a hot key. You specify your preferred key stroke + virtual key/flag combination, a description of what your callback does (so + other plug-ins can describe the plug-in to the user for remapping) and a + callback function and opaque pointer to pass in). A new hot key ID is + returned. During execution, the actual key associated with your hot key + may change, but you are insulated from this. + } + FUNCTION XPLMRegisterHotKey( + inVirtualKey : XPLMChar; + inFlags : XPLMKeyFlags; + inDescription : XPLMString; + inCallback : XPLMHotKey_f; + inRefcon : pointer) : XPLMHotKeyID; + cdecl; external XPLM_DLL; + + { + XPLMUnregisterHotKey + + Unregisters a hot key. You can only unregister your own hot keys. + } + PROCEDURE XPLMUnregisterHotKey( + inHotKey : XPLMHotKeyID); + cdecl; external XPLM_DLL; + + { + XPLMCountHotKeys + + Returns the number of current hot keys. + } + FUNCTION XPLMCountHotKeys: Integer; + cdecl; external XPLM_DLL; + + { + XPLMGetNthHotKey + + Returns a hot key by index, for iteration on all hot keys. + } + FUNCTION XPLMGetNthHotKey( + inIndex : Integer) : XPLMHotKeyID; + cdecl; external XPLM_DLL; + + { + XPLMGetHotKeyInfo + + Returns information about the hot key. Return NULL for any parameter you + don't want info about. The description should be at least 512 chars long. + } + PROCEDURE XPLMGetHotKeyInfo( + inHotKey : XPLMHotKeyID; + outVirtualKey : XPLMString; { Can be nil } + outFlags : PXPLMKeyFlags; { Can be nil } + outDescription : XPLMString; { Can be nil } + outPlugin : PXPLMPluginID); { Can be nil } + cdecl; external XPLM_DLL; + + { + XPLMSetHotKeyCombination + + Remaps a hot key's keystrokes. You may remap another plugin's keystrokes. + } + PROCEDURE XPLMSetHotKeyCombination( + inHotKey : XPLMHotKeyID; + inVirtualKey : XPLMChar; + inFlags : XPLMKeyFlags); + cdecl; external XPLM_DLL; + + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/Delphi/XPLM/XPLMGraphics.pas b/XPLPro_Plugin_Source/SDK/Delphi/XPLM/XPLMGraphics.pas new file mode 100644 index 0000000..20ff61a --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/Delphi/XPLM/XPLMGraphics.pas @@ -0,0 +1,424 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPLMGraphics; +INTERFACE +{ + A few notes on coordinate systems: + + X-Plane uses three kinds of coordinates. Global coordinates are specified + as latitude, longitude and elevation. This coordinate system never changes + but is not very precise. + + OpenGL (or 'local') coordinates are cartesian and shift with the plane. + They offer more precision and are used for 3-d OpenGL drawing. The X axis + is aligned east-west with positive X meaning east. The Y axis is aligned + straight up and down at the point 0,0,0 (but since the earth is round it is + not truly straight up and down at other points). The Z axis is aligned + north-south at 0, 0, 0 with positive Z pointing south (but since the earth + is round it isn't exactly north-south as you move east or west of 0, 0, 0). + One unit is one meter and the point 0,0,0 is on the surface of the earth at + sea level for some latitude and longitude picked by the sim such that the + user's aircraft is reasonably nearby. + + 2-d Panel coordinates are 2d, with the X axis horizontal and the Y axis + vertical. The point 0,0 is the bottom left and 1024,768 is the upper + right of the screen. This is true no matter what resolution the user's + monitor is in; when running in higher resolution, graphics will be + scaled. + + Use X-Plane's routines to convert between global and local coordinates. Do + not attempt to do this conversion yourself; the precise 'roundness' of + X-Plane's physics model may not match your own, and (to make things + weirder) the user can potentially customize the physics of the current + planet. +} + +USES + XPLMDefs; + {$A4} +{___________________________________________________________________________ + * X-PLANE GRAPHICS + ___________________________________________________________________________} +{ + These routines allow you to use OpenGL with X-Plane. +} + + + { + XPLMTextureID + + XPLM Texture IDs name well-known textures in the sim for you to use. This + allows you to recycle textures from X-Plane, saving VRAM. + + *Warning*: do not use these enums. The only remaining use they have is to + access the legacy compatibility v10 UI texture; if you need this, get it + via the Widgets library. + } +TYPE + XPLMTextureID = ( + { The bitmap that contains window outlines, button outlines, fonts, etc. } + xplm_Tex_GeneralInterface = 0 + +{$IFDEF XPLM_DEPRECATED} + { The exterior paint for the user's aircraft (daytime). } + ,xplm_Tex_AircraftPaint = 1 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { The exterior light map for the user's aircraft. } + ,xplm_Tex_AircraftLiteMap = 2 +{$ENDIF XPLM_DEPRECATED} + + ); + PXPLMTextureID = ^XPLMTextureID; + + { + XPLMSetGraphicsState + + XPLMSetGraphicsState changes OpenGL's fixed function pipeline state. You + are not responsible for restoring any state that is accessed via + XPLMSetGraphicsState, but you are responsible for not accessing this state + directly. + + - inEnableFog - enables or disables fog, equivalent to: glEnable(GL_FOG); + - inNumberTexUnits - enables or disables a number of multitexturing units. + If the number is 0, 2d texturing is disabled entirely, as in + glDisable(GL_TEXTURE_2D); Otherwise, 2d texturing is enabled, and a + number of multitexturing units are enabled sequentially, starting with + unit 0, e.g. glActiveTextureARB(GL_TEXTURE0_ARB); glEnable + (GL_TEXTURE_2D); + - inEnableLighting - enables or disables OpenGL lighting, e.g. + glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); + - inEnableAlphaTesting - enables or disables the alpha test per pixel, e.g. + glEnable(GL_ALPHA_TEST); + - inEnableAlphaBlending - enables or disables alpha blending per pixel, + e.g. glEnable(GL_BLEND); + - inEnableDepthTesting - enables per pixel depth testing, as in + glEnable(GL_DEPTH_TEST); + - inEnableDepthWriting - enables writing back of depth information to the + depth bufffer, as in glDepthMask(GL_TRUE); + + The purpose of this function is to change OpenGL state while keeping + X-Plane aware of the state changes; this keeps X-Plane from getting + surprised by OGL state changes, and prevents X-Plane and plug-ins from + having to set all state before all draws; XPLMSetGraphicsState internally + skips calls to change state that is already properly enabled. + + X-Plane does not have a 'default' OGL state for plug-ins with respect to + the above state vector; plug-ins should totally set OGL state using this + API before drawing. Use XPLMSetGraphicsState instead of any of the above + OpenGL calls. + + WARNING: Any routine that performs drawing (e.g. XPLMDrawString or widget + code) may change X-Plane's state. Always set state before drawing after + unknown code has executed. + + *Deprecation Warnings*: X-Plane's lighting and fog environemnt is + significantly more complex than the fixed function pipeline can express; + do not assume that lighting and fog state is a good approximation for 3-d + drawing. Prefer to use XPLMInstancing to draw objects. All calls to + XPLMSetGraphicsState should have no fog or lighting. + } + PROCEDURE XPLMSetGraphicsState( + inEnableFog : Integer; + inNumberTexUnits : Integer; + inEnableLighting : Integer; + inEnableAlphaTesting: Integer; + inEnableAlphaBlending: Integer; + inEnableDepthTesting: Integer; + inEnableDepthWriting: Integer); + cdecl; external XPLM_DLL; + + { + XPLMBindTexture2d + + XPLMBindTexture2d changes what texture is bound to the 2d texturing + target. This routine caches the current 2d texture across all texturing + units in the sim and plug-ins, preventing extraneous binding. For + example, consider several plug-ins running in series; if they all use the + 'general interface' bitmap to do UI, calling this function will skip the + rebinding of the general interface texture on all but the first plug-in, + which can provide better frame rate son some graphics cards. + + inTextureID is the ID of the texture object to bind; inTextureUnit is a + zero-based texture unit (e.g. 0 for the first one), up to a maximum of 4 + units. (This number may increase in future versions of X-Plane.) + + Use this routine instead of glBindTexture(GL_TEXTURE_2D, ....); + } + PROCEDURE XPLMBindTexture2d( + inTextureNum : Integer; + inTextureUnit : Integer); + cdecl; external XPLM_DLL; + + { + XPLMGenerateTextureNumbers + + Use this routine instead of glGenTextures to generate new texture object + IDs. This routine historically ensured that plugins don't use texure IDs + that X-Plane is reserving for its own use. + } + PROCEDURE XPLMGenerateTextureNumbers( + outTextureIDs : PInteger; + inCount : Integer); + cdecl; external XPLM_DLL; + +{$IFDEF XPLM_DEPRECATED} + { + XPLMGetTexture + + XPLMGetTexture returns the OpenGL texture ID of an X-Plane texture based on + a generic identifying code. For example, you can get the texture for + X-Plane's UI bitmaps. + } + FUNCTION XPLMGetTexture( + inTexture : XPLMTextureID) : Integer; + cdecl; external XPLM_DLL; +{$ENDIF XPLM_DEPRECATED} + + { + XPLMWorldToLocal + + This routine translates coordinates from latitude, longitude, and altitude + to local scene coordinates. Latitude and longitude are in decimal degrees, + and altitude is in meters MSL (mean sea level). The XYZ coordinates are in + meters in the local OpenGL coordinate system. + } + PROCEDURE XPLMWorldToLocal( + inLatitude : Real; + inLongitude : Real; + inAltitude : Real; + outX : PReal; + outY : PReal; + outZ : PReal); + cdecl; external XPLM_DLL; + + { + XPLMLocalToWorld + + This routine translates a local coordinate triplet back into latitude, + longitude, and altitude. Latitude and longitude are in decimal degrees, + and altitude is in meters MSL (mean sea level). The XYZ coordinates are in + meters in the local OpenGL coordinate system. + + NOTE: world coordinates are less precise than local coordinates; you should + try to avoid round tripping from local to world and back. + } + PROCEDURE XPLMLocalToWorld( + inX : Real; + inY : Real; + inZ : Real; + outLatitude : PReal; + outLongitude : PReal; + outAltitude : PReal); + cdecl; external XPLM_DLL; + + { + XPLMDrawTranslucentDarkBox + + This routine draws a translucent dark box, partially obscuring parts of the + screen but making text easy to read. This is the same graphics primitive + used by X-Plane to show text files and ATC info. + } + PROCEDURE XPLMDrawTranslucentDarkBox( + inLeft : Integer; + inTop : Integer; + inRight : Integer; + inBottom : Integer); + cdecl; external XPLM_DLL; + +{___________________________________________________________________________ + * X-PLANE TEXT + ___________________________________________________________________________} + + { + XPLMFontID + + X-Plane features some fixed-character fonts. Each font may have its own + metrics. + + WARNING: Some of these fonts are no longer supported or may have changed + geometries. For maximum copmatibility, see the comments below. + + Note: X-Plane 7 supports proportional-spaced fonts. Since no measuring + routine is available yet, the SDK will normally draw using a fixed-width + font. You can use a dataref to enable proportional font drawing on XP7 if + you want to. + } +TYPE + XPLMFontID = ( + { Mono-spaced font for user interface. Available in all versions of the SDK.} + xplmFont_Basic = 0 + +{$IFDEF XPLM_DEPRECATED} + { Deprecated, do not use. } + ,xplmFont_Menus = 1 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated, do not use. } + ,xplmFont_Metal = 2 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated, do not use. } + ,xplmFont_Led = 3 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated, do not use. } + ,xplmFont_LedWide = 4 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated, do not use. } + ,xplmFont_PanelHUD = 5 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated, do not use. } + ,xplmFont_PanelEFIS = 6 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated, do not use. } + ,xplmFont_PanelGPS = 7 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated, do not use. } + ,xplmFont_RadiosGA = 8 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated, do not use. } + ,xplmFont_RadiosBC = 9 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated, do not use. } + ,xplmFont_RadiosHM = 10 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated, do not use. } + ,xplmFont_RadiosGANarrow = 11 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated, do not use. } + ,xplmFont_RadiosBCNarrow = 12 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated, do not use. } + ,xplmFont_RadiosHMNarrow = 13 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated, do not use. } + ,xplmFont_Timer = 14 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated, do not use. } + ,xplmFont_FullRound = 15 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated, do not use. } + ,xplmFont_SmallRound = 16 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated, do not use. } + ,xplmFont_Menus_Localized = 17 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM200} + { Proportional UI font. } + ,xplmFont_Proportional = 18 +{$ENDIF XPLM200} + + ); + PXPLMFontID = ^XPLMFontID; + + { + XPLMDrawString + + This routine draws a NULL termianted string in a given font. Pass in the + lower left pixel that the character is to be drawn onto. Also pass the + character and font ID. This function returns the x offset plus the width of + all drawn characters. The color to draw in is specified as a pointer to an + array of three floating point colors, representing RGB intensities from 0.0 + to 1.0. + } + PROCEDURE XPLMDrawString( + inColorRGB : PSingle; + inXOffset : Integer; + inYOffset : Integer; + inChar : XPLMString; + inWordWrapWidth : PInteger; { Can be nil } + inFontID : XPLMFontID); + cdecl; external XPLM_DLL; + + { + XPLMDrawNumber + + This routine draws a number similar to the digit editing fields in + PlaneMaker and data output display in X-Plane. Pass in a color, a + position, a floating point value, and formatting info. Specify how many + integer and how many decimal digits to show and whether to show a sign, as + well as a character set. This routine returns the xOffset plus width of the + string drawn. + } + PROCEDURE XPLMDrawNumber( + inColorRGB : PSingle; + inXOffset : Integer; + inYOffset : Integer; + inValue : Real; + inDigits : Integer; + inDecimals : Integer; + inShowSign : Integer; + inFontID : XPLMFontID); + cdecl; external XPLM_DLL; + + { + XPLMGetFontDimensions + + This routine returns the width and height of a character in a given font. + It also tells you if the font only supports numeric digits. Pass NULL if + you don't need a given field. Note that for a proportional font the width + will be an arbitrary, hopefully average width. + } + PROCEDURE XPLMGetFontDimensions( + inFontID : XPLMFontID; + outCharWidth : PInteger; { Can be nil } + outCharHeight : PInteger; { Can be nil } + outDigitsOnly : PInteger); { Can be nil } + cdecl; external XPLM_DLL; + +{$IFDEF XPLM200} + { + XPLMMeasureString + + This routine returns the width in pixels of a string using a given font. + The string is passed as a pointer plus length (and does not need to be null + terminated); this is used to allow for measuring substrings. The return + value is floating point; it is possible that future font drawing may allow + for fractional pixels. + } + FUNCTION XPLMMeasureString( + inFontID : XPLMFontID; + inChar : XPLMString; + inNumChars : Integer) : Single; + cdecl; external XPLM_DLL; +{$ENDIF XPLM200} + + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/Delphi/XPLM/XPLMInstance.pas b/XPLPro_Plugin_Source/SDK/Delphi/XPLM/XPLMInstance.pas new file mode 100644 index 0000000..a38d2bb --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/Delphi/XPLM/XPLMInstance.pas @@ -0,0 +1,125 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPLMInstance; +INTERFACE +{ + This API provides instanced drawing of X-Plane objects (.obj files). In + contrast to old drawing APIs, which required you to draw your own objects + per-frame, the instancing API allows you to simply register an OBJ for + drawing, then move or manipulate it later (as needed). + + This provides one tremendous benefit: it keeps all dataref operations for + your object in one place. Because datarefs are main thread only, allowing + dataref access anywhere is a serious performance bottleneck for the + simulator---the whole simulator has to pause and wait for each dataref + access. This performance penalty will only grow worse as X-Plane moves + toward an ever more heavily multithreaded engine. + + The instancing API allows X-Plane to isolate all dataref manipulations for + all plugin object drawing to one place, potentially providing huge + performance gains. + + Here's how it works: + + When an instance is created, it provides a list of all datarefs you want to + manipulate in for the OBJ in the future. This list of datarefs replaces the + ad-hoc collections of dataref objects previously used by art assets. Then, + per-frame, you can manipulate the instance by passing in a "block" of + packed floats representing the current values of the datarefs for your + instance. (Note that the ordering of this set of packed floats must exactly + match the ordering of the datarefs when you created your instance.) +} + +USES + XPLMDefs, XPLMScenery; + {$A4} +{___________________________________________________________________________ + * Instance Creation and Destruction + ___________________________________________________________________________} +{ + Registers and unregisters instances. +} + + +TYPE + { + XPLMInstanceRef + + An opaque handle to an instance. + } + XPLMInstanceRef = pointer; + PXPLMInstanceRef = ^XPLMInstanceRef; + + { + XPLMCreateInstance + + XPLMCreateInstance creates a new instance, managed by your plug-in, and + returns a handle to the instance. A few important requirements: + + * The object passed in must be fully loaded and returned from the XPLM + before you can create your instance; you cannot pass a null obj ref, nor + can you change the ref later. + + * If you use any custom datarefs in your object, they must be registered + before the object is loaded. This is true even if their data will be + provided via the instance dataref list. + + * The instance dataref array must be a valid ptr to an array of at least + one item that is null terminated. That is, if you do not want any + datarefs, you must passa ptr to an array with a null item. You cannot + pass null for this. + } + FUNCTION XPLMCreateInstance( + obj : XPLMObjectRef; + datarefs : PXPLMString) : XPLMInstanceRef; + cdecl; external XPLM_DLL; + + { + XPLMDestroyInstance + + XPLMDestroyInstance destroys and deallocates your instance; once called, + you are still responsible for releasing the OBJ ref. + + Tip: you can release your OBJ ref after you call XPLMCreateInstance as long + as you never use it again; the instance will maintain its own reference to + the OBJ and the object OBJ be deallocated when the instance is destroyed. + } + PROCEDURE XPLMDestroyInstance( + instance : XPLMInstanceRef); + cdecl; external XPLM_DLL; + +{___________________________________________________________________________ + * Instance Manipulation + ___________________________________________________________________________} + + { + XPLMInstanceSetPosition + + Updates both the position of the instance and all datarefs you registered + for it. Call this from a flight loop callback or UI callback. + + __DO NOT__ call XPLMInstanceSetPosition from a drawing callback; the whole + point of instancing is that you do not need any drawing callbacks. Setting + instance data from a drawing callback may have undefined consequences, and + the drawing callback hurts FPS unnecessarily. + + The memory pointed to by the data pointer must be large enough to hold one + float for every data ref you have registered, and must contain valid + floating point data. + + BUG: before X-Plane 11.50, if you have no dataref registered, you must + still pass a valid pointer for data and not null. + } + PROCEDURE XPLMInstanceSetPosition( + instance : XPLMInstanceRef; + new_position : PXPLMDrawInfo_t; + data : PSingle); + cdecl; external XPLM_DLL; + + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/Delphi/XPLM/XPLMMap.pas b/XPLPro_Plugin_Source/SDK/Delphi/XPLM/XPLMMap.pas new file mode 100644 index 0000000..61c82dc --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/Delphi/XPLM/XPLMMap.pas @@ -0,0 +1,611 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPLMMap; +INTERFACE +{ + This API allows you to create new layers within X-Plane maps. Your layers + can draw arbitrary OpenGL, but they conveniently also have access to + X-Plane's built-in icon and label drawing functions. + + As of X-Plane 11, map drawing happens in three stages: + + 1. backgrounds and "fill," + 2. icons, and + 3. labels. + + Thus, all background drawing gets layered beneath all icons, which likewise + get layered beneath all labels. Within each stage, the map obeys a + consistent layer ordering, such that "fill" layers (layers that cover a + large amount of map area, like the terrain and clouds) appear beneath + "markings" layers (like airport icons). This ensures that layers with fine + details don't get obscured by layers with larger details. + + The XPLM map API reflects both aspects of this draw layering: you can + register a layer as providing either markings or fill, and X-Plane will + draw your fill layers beneath your markings layers (regardless of + registration order). Likewise, you are guaranteed that your layer's icons + (added from within an icon callback) will go above your layer's OpenGL + drawing, and your labels will go above your icons. + + The XPLM guarantees that all plugin-created fill layers go on top of all + native X-Plane fill layers, and all plugin-created markings layers go on + top of all X-Plane markings layers (with the exception of the aircraft + icons). It also guarantees that the draw order of your own plugin's layers + will be consistent. But, for layers created by different plugins, the only + guarantee is that we will draw all of one plugin's layers of each type + (fill, then markings), then all of the others'; we don't guarantee which + plugin's fill and markings layers go on top of the other's. + + As of X-Plane 11, maps use true cartographic projections for their drawing, + and different maps may use different projections. For that reason, all + drawing calls include an opaque handle for the projection you should use to + do the drawing. Any time you would draw at a particular latitude/longitude, + you'll need to ask the projection to translate that position into "map + coordinates." (Note that the projection is guaranteed not to change between + calls to your prepare-cache hook, so if you cache your map coordinates + ahead of time, there's no need to re-project them when you actually draw.) + + In addition to mapping normal latitude/longitude locations into map + coordinates, the projection APIs also let you know the current heading for + north. (Since X-Plane 11 maps can rotate to match the heading of the user's + aircraft, it's not safe to assume that north is at zero degrees rotation.) +} + +USES + XPLMDefs; + {$A4} +{$IFDEF XPLM300} +{___________________________________________________________________________ + * DRAWING CALLBACKS + ___________________________________________________________________________} +{ + When you create a new map layer (using XPLMCreateMapLayer), you can provide + any or all of these callbacks. They allow you to insert your own OpenGL + drawing, text labels, and icons into the X-Plane map at the appropriate + places, allowing your layer to behave as similarly to X-Plane's built-in + layers as possible. +} + + +TYPE + { + XPLMMapLayerID + + This is an opaque handle for a plugin-created map layer. Pass it to the map + drawing APIs from an appropriate callback to draw in the layer you created. + } + XPLMMapLayerID = pointer; + PXPLMMapLayerID = ^XPLMMapLayerID; + + { + XPLMMapProjectionID + + This is an opaque handle for a map projection. Pass it to the projection + APIs to translate between map coordinates and latitude/longitudes. + } + XPLMMapProjectionID = pointer; + PXPLMMapProjectionID = ^XPLMMapProjectionID; + + { + XPLMMapStyle + + Indicates the visual style being drawn by the map. In X-Plane, the user can + choose between a number of map types, and different map types may have use + a different visual representation for the same elements (for instance, the + visual style of the terrain layer changes drastically between the VFR and + IFR layers), or certain layers may be disabled entirely in some map types + (e.g., localizers are only visible in the IFR low-enroute style). + } + XPLMMapStyle = ( + xplm_MapStyle_VFR_Sectional = 0 + + ,xplm_MapStyle_IFR_LowEnroute = 1 + + ,xplm_MapStyle_IFR_HighEnroute = 2 + + ); + PXPLMMapStyle = ^XPLMMapStyle; + + { + XPLMMapDrawingCallback_f + + This is the OpenGL map drawing callback for plugin-created map layers. You + can perform arbitrary OpenGL drawing from this callback, with one + exception: changes to the Z-buffer are not permitted, and will result in + map drawing errors. + + All drawing done from within this callback appears beneath all built-in + X-Plane icons and labels, but above the built-in "fill" layers (layers + providing major details, like terrain and water). Note, however, that the + relative ordering between the drawing callbacks of different plugins is not + guaranteed. + } + XPLMMapDrawingCallback_f = PROCEDURE( + inLayer : XPLMMapLayerID; + inMapBoundsLeftTopRightBottom: PSingle; + zoomRatio : Single; + mapUnitsPerUserInterfaceUnit: Single; + mapStyle : XPLMMapStyle; + projection : XPLMMapProjectionID; + inRefcon : pointer); cdecl; + + { + XPLMMapIconDrawingCallback_f + + This is the icon drawing callback that enables plugin-created map layers to + draw icons using X-Plane's built-in icon drawing functionality. You can + request an arbitrary number of PNG icons to be drawn via + XPLMDrawMapIconFromSheet() from within this callback, but you may not + perform any OpenGL drawing here. + + Icons enqueued by this function will appear above all OpenGL drawing + (performed by your optional XPLMMapDrawingCallback_f), and above all + built-in X-Plane map icons of the same layer type ("fill" or "markings," as + determined by the XPLMMapLayerType in your XPLMCreateMapLayer_t). Note, + however, that the relative ordering between the drawing callbacks of + different plugins is not guaranteed. + } + XPLMMapIconDrawingCallback_f = PROCEDURE( + inLayer : XPLMMapLayerID; + inMapBoundsLeftTopRightBottom: PSingle; + zoomRatio : Single; + mapUnitsPerUserInterfaceUnit: Single; + mapStyle : XPLMMapStyle; + projection : XPLMMapProjectionID; + inRefcon : pointer); cdecl; + + { + XPLMMapLabelDrawingCallback_f + + This is the label drawing callback that enables plugin-created map layers + to draw text labels using X-Plane's built-in labeling functionality. You + can request an arbitrary number of text labels to be drawn via + XPLMDrawMapLabel() from within this callback, but you may not perform any + OpenGL drawing here. + + Labels enqueued by this function will appear above all OpenGL drawing + (performed by your optional XPLMMapDrawingCallback_f), and above all + built-in map icons and labels of the same layer type ("fill" or "markings," + as determined by the XPLMMapLayerType in your XPLMCreateMapLayer_t). Note, + however, that the relative ordering between the drawing callbacks of + different plugins is not guaranteed. + } + XPLMMapLabelDrawingCallback_f = PROCEDURE( + inLayer : XPLMMapLayerID; + inMapBoundsLeftTopRightBottom: PSingle; + zoomRatio : Single; + mapUnitsPerUserInterfaceUnit: Single; + mapStyle : XPLMMapStyle; + projection : XPLMMapProjectionID; + inRefcon : pointer); cdecl; + +{$ENDIF XPLM300} +{$IFDEF XPLM300} +{___________________________________________________________________________ + * LAYER MANAGEMENT CALLBACKS + ___________________________________________________________________________} +{ + These are various "bookkeeping" callbacks that your map layer can receive + (if you provide the callback in your XPLMCreateMapLayer_t). They allow you + to manage the lifecycle of your layer, as well as cache any + computationally-intensive preparation you might need for drawing. +} + + + { + XPLMMapPrepareCacheCallback_f + + A callback used to allow you to cache whatever information your layer needs + to draw in the current map area. + + This is called each time the map's total bounds change. This is typically + triggered by new DSFs being loaded, such that X-Plane discards old, + now-distant DSFs and pulls in new ones. At that point, the available bounds + of the map also change to match the new DSF area. + + By caching just the information you need to draw in this area, your future + draw calls can be made faster, since you'll be able to simply "splat" your + precomputed information each frame. + + We guarantee that the map projection will not change between successive + prepare cache calls, nor will any draw call give you bounds outside these + total map bounds. So, if you cache the projected map coordinates of all the + items you might want to draw in the total map area, you can be guaranteed + that no draw call will be asked to do any new work. + } +TYPE + XPLMMapPrepareCacheCallback_f = PROCEDURE( + inLayer : XPLMMapLayerID; + inTotalMapBoundsLeftTopRightBottom: PSingle; + projection : XPLMMapProjectionID; + inRefcon : pointer); cdecl; + + { + XPLMMapWillBeDeletedCallback_f + + Called just before your map layer gets deleted. Because SDK-created map + layers have the same lifetime as the X-Plane map that contains them, if the + map gets unloaded from memory, your layer will too. + } + XPLMMapWillBeDeletedCallback_f = PROCEDURE( + inLayer : XPLMMapLayerID; + inRefcon : pointer); cdecl; + +{$ENDIF XPLM300} +{$IFDEF XPLM300} +{___________________________________________________________________________ + * MAP LAYER CREATION AND DESTRUCTION + ___________________________________________________________________________} +{ + Enables the creation of new map layers. Layers are created for a particular + instance of the X-Plane map. For instance, if you want your layer to appear + in both the normal map interface and the Instructor Operator Station (IOS), + you would need two separate calls to XPLMCreateMapLayer(), with two + different values for your XPLMCreateMapLayer_t::layer_name. + + Your layer's lifetime will be determined by the lifetime of the map it is + created in. If the map is destroyed (on the X-Plane side), your layer will + be too, and you'll receive a callback to your + XPLMMapWillBeDeletedCallback_f. +} + + + { + XPLMMapLayerType + + Indicates the type of map layer you are creating. Fill layers will always + be drawn beneath markings layers. + } +TYPE + XPLMMapLayerType = ( + { A layer that draws "fill" graphics, like weather patterns, terrain, etc. } + { Fill layers frequently cover a large portion of the visible map area. } + xplm_MapLayer_Fill = 0 + + { A layer that provides markings for particular map features, like NAVAIDs, } + { airports, etc. Even dense markings layers cover a small portion of the } + { total map area. } + ,xplm_MapLayer_Markings = 1 + + ); + PXPLMMapLayerType = ^XPLMMapLayerType; + +CONST + { Globally unique identifier for X-Plane's Map window, used as the } + { mapToCreateLayerIn parameter in XPLMCreateMapLayer_t } + XPLM_MAP_USER_INTERFACE = "XPLM_MAP_USER_INTERFACE"; + + { Globally unique identifier for X-Plane's Instructor Operator Station } + { window, used as the mapToCreateLayerIn parameter in XPLMCreateMapLayer_t } + XPLM_MAP_IOS = "XPLM_MAP_IOS"; + + { + XPLMCreateMapLayer_t + + This structure defines all of the parameters used to create a map layer + using XPLMCreateMapLayer. The structure will be expanded in future SDK APIs + to include more features. Always set the structSize member to the size of + your struct in bytes! + + Each layer must be associated with exactly one map instance in X-Plane. + That map, and that map alone, will call your callbacks. Likewise, when that + map is deleted, your layer will be as well. + } +TYPE + XPLMCreateMapLayer_t = RECORD + { Used to inform XPLMCreateMapLayer() of the SDK version you compiled } + { against; should always be set to sizeof(XPLMCreateMapLayer_t) } + structSize : Integer; + { Globally unique string identifying the map you want this layer to appear } + { in. As of XPLM300, this is limited to one of XPLM_MAP_USER_INTERFACE or } + { XPLM_MAP_IOS } + mapToCreateLayerIn : XPLMString; + { The type of layer you are creating, used to determine draw order (all } + { plugin-created markings layers are drawn above all plugin-created fill } + { layers) } + layerType : XPLMMapLayerType; + { Optional callback to inform you this layer is being deleted (due to its } + { owning map being destroyed) } + willBeDeletedCallback : XPLMMapWillBeDeletedCallback_f; + { Optional callback you want to use to prepare your draw cache when the map } + { bounds change (set to NULL if you don't want this callback) } + prepCacheCallback : XPLMMapPrepareCacheCallback_f; + { Optional callback you want to use for arbitrary OpenGL drawing, which goes } + { beneath all icons in the map's layering system (set to NULL if you don't } + { want this callback) } + drawCallback : XPLMMapDrawingCallback_f; + { Optional callback you want to use for drawing icons, which go above all } + { built-in X-Plane icons (except the aircraft) in the map's layering system } + { (set to NULL if you don't want this callback) } + iconCallback : XPLMMapIconDrawingCallback_f; + { Optional callback you want to use for drawing map labels, which go above } + { all built-in X-Plane icons and labels (except those of aircraft) in the } + { map's layering system (set to NULL if you don't want this callback) } + labelCallback : XPLMMapLabelDrawingCallback_f; + { True if you want a checkbox to be created in the map UI to toggle this } + { layer on and off; false if the layer should simply always be enabled } + showUiToggle : Integer; + { Short label to use for this layer in the user interface } + layerName : XPLMString; + { A reference to arbitrary data that will be passed to your callbacks } + refcon : pointer; + END; + PXPLMCreateMapLayer_t = ^XPLMCreateMapLayer_t; + + { + XPLMCreateMapLayer + + This routine creates a new map layer. You pass in an XPLMCreateMapLayer_t + structure with all of the fields set in. You must set the structSize of + the structure to the size of the actual structure you used. + + Returns NULL if the layer creation failed. This happens most frequently + because the map you specified in your + XPLMCreateMapLayer_t::mapToCreateLayerIn field doesn't exist (that is, if + XPLMMapExists() returns 0 for the specified map). You can use + XPLMRegisterMapCreationHook() to get a notification each time a new map is + opened in X-Plane, at which time you can create layers in it. + } + FUNCTION XPLMCreateMapLayer( + inParams : PXPLMCreateMapLayer_t) : XPLMMapLayerID; + cdecl; external XPLM_DLL; + + { + XPLMDestroyMapLayer + + Destroys a map layer you created (calling your + XPLMMapWillBeDeletedCallback_f if applicable). Returns true if a deletion + took place. + } + FUNCTION XPLMDestroyMapLayer( + inLayer : XPLMMapLayerID) : Integer; + cdecl; external XPLM_DLL; + + { + XPLMMapCreatedCallback_f + + A callback to notify your plugin that a new map has been created in + X-Plane. This is the best time to add a custom map layer using + XPLMCreateMapLayer(). + + No OpenGL drawing is permitted within this callback. + } +TYPE + XPLMMapCreatedCallback_f = PROCEDURE( + mapIdentifier : XPLMString; + refcon : pointer); cdecl; + + { + XPLMRegisterMapCreationHook + + Registers your callback to receive a notification each time a new map is + constructed in X-Plane. This callback is the best time to add your custom + map layer using XPLMCreateMapLayer(). + + Note that you will not be notified about any maps that already exist---you + can use XPLMMapExists() to check for maps that were created previously. + } + PROCEDURE XPLMRegisterMapCreationHook( + callback : XPLMMapCreatedCallback_f; + refcon : pointer); + cdecl; external XPLM_DLL; + + { + XPLMMapExists + + Returns 1 if the map with the specified identifier already exists in + X-Plane. In that case, you can safely call XPLMCreateMapLayer() specifying + that your layer should be added to that map. + } + FUNCTION XPLMMapExists( + mapIdentifier : XPLMString) : Integer; + cdecl; external XPLM_DLL; + +{$ENDIF XPLM300} +{$IFDEF XPLM300} +{___________________________________________________________________________ + * MAP DRAWING + ___________________________________________________________________________} +{ + These APIs are only valid from within a map drawing callback (one of + XPLMIconDrawingCallback_t or XPLMMapLabelDrawingCallback_f). Your drawing + callbacks are registered when you create a new map layer as part of your + XPLMCreateMapLayer_t. The functions here hook into X-Plane's built-in map + drawing functionality for icons and labels, so that you get a consistent + style with the rest of the X-Plane map. + + Note that the X-Plane 11 map introduces a strict ordering: layers of type + xplm_MapLayer_Fill get drawn beneath all xplm_MapLayer_Markings layers. + Likewise, all OpenGL drawing (performed in your layer's + XPLMMapDrawingCallback_f) will appear beneath any icons and labels you + draw. +} + + + { + XPLMMapOrientation + + Indicates whether a map element should be match its rotation to the map + itself, or to the user interface. For instance, the map itself may be + rotated such that "up" matches the user's aircraft, but you may want to + draw a text label such that it is always rotated zero degrees relative to + the user's perspective. In that case, you would have it draw with UI + orientation. + } +TYPE + XPLMMapOrientation = ( + { Orient such that a 0 degree rotation matches the map's north } + xplm_MapOrientation_Map = 0 + + { Orient such that a 0 degree rotation is "up" relative to the user interface} + ,xplm_MapOrientation_UI = 1 + + ); + PXPLMMapOrientation = ^XPLMMapOrientation; + + { + XPLMDrawMapIconFromSheet + + Enables plugin-created map layers to draw PNG icons using X-Plane's + built-in icon drawing functionality. Only valid from within an + XPLMIconDrawingCallback_t (but you can request an arbitrary number of icons + to be drawn from within your callback). + + X-Plane will automatically manage the memory for your texture so that it + only has to be loaded from disk once as long as you continue drawing it + per-frame. (When you stop drawing it, the memory may purged in a "garbage + collection" pass, require a load from disk in the future.) + + Instead of having X-Plane draw a full PNG, this method allows you to use UV + coordinates to request a portion of the image to be drawn. This allows you + to use a single texture load (of an icon sheet, for example) to draw many + icons. Doing so is much more efficient than drawing a dozen different small + PNGs. + + The UV coordinates used here treat the texture you load as being comprised + of a number of identically sized "cells." You specify the width and height + in cells (ds and dt, respectively), as well as the coordinates within the + cell grid for the sub-image you'd like to draw. + + Note that you can use different ds and dt values in subsequent calls with + the same texture sheet. This enables you to use icons of different sizes in + the same sheet if you arrange them properly in the PNG. + + This function is only valid from within an XPLMIconDrawingCallback_t (but + you can request an arbitrary number of icons to be drawn from within your + callback). + } + PROCEDURE XPLMDrawMapIconFromSheet( + layer : XPLMMapLayerID; + inPngPath : XPLMString; + s : Integer; + t : Integer; + ds : Integer; + dt : Integer; + mapX : Single; + mapY : Single; + orientation : XPLMMapOrientation; + rotationDegrees : Single; + mapWidth : Single); + cdecl; external XPLM_DLL; + + { + XPLMDrawMapLabel + + Enables plugin-created map layers to draw text labels using X-Plane's + built-in labeling functionality. Only valid from within an + XPLMMapLabelDrawingCallback_f (but you can request an arbitrary number of + text labels to be drawn from within your callback). + } + PROCEDURE XPLMDrawMapLabel( + layer : XPLMMapLayerID; + inText : XPLMString; + mapX : Single; + mapY : Single; + orientation : XPLMMapOrientation; + rotationDegrees : Single); + cdecl; external XPLM_DLL; + +{$ENDIF XPLM300} +{$IFDEF XPLM300} +{___________________________________________________________________________ + * MAP PROJECTIONS + ___________________________________________________________________________} +{ + As of X-Plane 11, the map draws using true cartographic projections, and + different maps may use different projections. Thus, to draw at a particular + latitude and longitude, you must first transform your real-world + coordinates into map coordinates. + + The map projection is also responsible for giving you the current scale of + the map. That is, the projection can tell you how many map units correspond + to 1 meter at a given point. + + Finally, the map projection can give you the current rotation of the map. + Since X-Plane 11 maps can rotate to match the heading of the aircraft, the + map's rotation can potentially change every frame. +} + + + { + XPLMMapProject + + Projects a latitude/longitude into map coordinates. This is the inverse of + XPLMMapUnproject(). + + Only valid from within a map layer callback (one of + XPLMMapPrepareCacheCallback_f, XPLMMapDrawingCallback_f, + XPLMMapIconDrawingCallback_f, or XPLMMapLabelDrawingCallback_f.) + } + PROCEDURE XPLMMapProject( + projection : XPLMMapProjectionID; + latitude : Real; + longitude : Real; + outX : PSingle; + outY : PSingle); + cdecl; external XPLM_DLL; + + { + XPLMMapUnproject + + Transforms map coordinates back into a latitude and longitude. This is the + inverse of XPLMMapProject(). + + Only valid from within a map layer callback (one of + XPLMMapPrepareCacheCallback_f, XPLMMapDrawingCallback_f, + XPLMMapIconDrawingCallback_f, or XPLMMapLabelDrawingCallback_f.) + } + PROCEDURE XPLMMapUnproject( + projection : XPLMMapProjectionID; + mapX : Single; + mapY : Single; + outLatitude : PReal; + outLongitude : PReal); + cdecl; external XPLM_DLL; + + { + XPLMMapScaleMeter + + Returns the number of map units that correspond to a distance of one meter + at a given set of map coordinates. + + Only valid from within a map layer callback (one of + XPLMMapPrepareCacheCallback_f, XPLMMapDrawingCallback_f, + XPLMMapIconDrawingCallback_f, or XPLMMapLabelDrawingCallback_f.) + } + FUNCTION XPLMMapScaleMeter( + projection : XPLMMapProjectionID; + mapX : Single; + mapY : Single) : Single; + cdecl; external XPLM_DLL; + + { + XPLMMapGetNorthHeading + + Returns the heading (in degrees clockwise from "up") that corresponds to + north at a given point on the map. In other words, if your runway has a + true heading of 360, you would use "north" as the Cartesian angle at which + to draw the runway on the map. (You would add the result of + XPLMMapGetNorthHeading() to your true heading to get the map angle.) + + This is necessary becuase X-Plane's map can be rotated to match your + aircraft's orientation; north is not always "up." + + Only valid from within a map layer callback (one of + XPLMMapPrepareCacheCallback_f, XPLMMapDrawingCallback_f, + XPLMMapIconDrawingCallback_f, or XPLMMapLabelDrawingCallback_f.) + } + FUNCTION XPLMMapGetNorthHeading( + projection : XPLMMapProjectionID; + mapX : Single; + mapY : Single) : Single; + cdecl; external XPLM_DLL; + +{$ENDIF XPLM300} + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/Delphi/XPLM/XPLMMenus.pas b/XPLPro_Plugin_Source/SDK/Delphi/XPLM/XPLMMenus.pas new file mode 100644 index 0000000..754a434 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/Delphi/XPLM/XPLMMenus.pas @@ -0,0 +1,277 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPLMMenus; +INTERFACE +{ + Plug-ins can create menus in the menu bar of X-Plane. This is done by + creating a menu and then creating items. Menus are referred to by an + opaque ID. Items are referred to by (zero-based) index number. + + Menus are "sandboxed" between plugins---no plugin can access the menus of + any other plugin. Furthermore, all menu indices are relative to your + plugin's menus only; if your plugin creates two sub-menus in the Plugins + menu at different times, it doesn't matter how many other plugins also + create sub-menus of Plugins in the intervening time: your sub-menus will be + given menu indices 0 and 1. (The SDK does some work in the back-end to + filter out menus that are irrelevant to your plugin in order to deliver + this consistency for each plugin.) + + When you create a menu item, you specify how we should handle clicks on + that menu item. You can either have the XPLM trigger a callback (the + XPLMMenuHandler_f associated with the menu that contains the item), or you + can simply have a command be triggered (with no associated call to your + menu handler). The advantage of the latter method is that X-Plane will + display any keyboard shortcuts associated with the command. (In contrast, + there are no keyboard shortcuts associated with menu handler callbacks with + specific parameters.) + + Menu text in X-Plane is UTF8; X-Plane's character set covers latin, greek + and cyrillic characters, Katakana, as well as some Japanese symbols. Some + APIs have a inDeprecatedAndIgnored parameter that used to select a + character set; since X-Plane 9 all localization is done via UTF-8 only. +} + +USES + XPLMDefs, XPLMUtilities; + {$A4} +{___________________________________________________________________________ + * XPLM MENUS + ___________________________________________________________________________} + + { + XPLMMenuCheck + + These enumerations define the various 'check' states for an X-Plane menu. + 'checking' in X-Plane actually appears as a light which may or may not be + lit. So there are three possible states. + } +TYPE + XPLMMenuCheck = ( + { there is no symbol to the left of the menu item. } + xplm_Menu_NoCheck = 0 + + { the menu has a mark next to it that is unmarked (not lit). } + ,xplm_Menu_Unchecked = 1 + + { the menu has a mark next to it that is checked (lit). } + ,xplm_Menu_Checked = 2 + + ); + PXPLMMenuCheck = ^XPLMMenuCheck; + + { + XPLMMenuID + + This is a unique ID for each menu you create. + } + XPLMMenuID = pointer; + PXPLMMenuID = ^XPLMMenuID; + + { + XPLMMenuHandler_f + + A menu handler function takes two reference pointers, one for the menu + (specified when the menu was created) and one for the item (specified when + the item was created). + } + XPLMMenuHandler_f = PROCEDURE( + inMenuRef : pointer; + inItemRef : pointer); cdecl; + + { + XPLMFindPluginsMenu + + This function returns the ID of the plug-ins menu, which is created for you + at startup. + } + FUNCTION XPLMFindPluginsMenu: XPLMMenuID; + cdecl; external XPLM_DLL; + +{$IFDEF XPLM300} + { + XPLMFindAircraftMenu + + This function returns the ID of the menu for the currently-loaded aircraft, + used for showing aircraft-specific commands. + + The aircraft menu is created by X-Plane at startup, but it remains hidden + until it is populated via XPLMAppendMenuItem() or + XPLMAppendMenuItemWithCommand(). + + Only plugins loaded with the user's current aircraft are allowed to access + the aircraft menu. For all other plugins, this will return NULL, and any + attempts to add menu items to it will fail. + } + FUNCTION XPLMFindAircraftMenu: XPLMMenuID; + cdecl; external XPLM_DLL; +{$ENDIF XPLM300} + + { + XPLMCreateMenu + + This function creates a new menu and returns its ID. It returns NULL if + the menu cannot be created. Pass in a parent menu ID and an item index to + create a submenu, or NULL for the parent menu to put the menu in the menu + bar. The menu's name is only used if the menu is in the menubar. You also + pass a handler function and a menu reference value. Pass NULL for the + handler if you do not need callbacks from the menu (for example, if it only + contains submenus). + + Important: you must pass a valid, non-empty menu title even if the menu is + a submenu where the title is not visible. + } + FUNCTION XPLMCreateMenu( + inName : XPLMString; + inParentMenu : XPLMMenuID; + inParentItem : Integer; + inHandler : XPLMMenuHandler_f; + inMenuRef : pointer) : XPLMMenuID; + cdecl; external XPLM_DLL; + + { + XPLMDestroyMenu + + This function destroys a menu that you have created. Use this to remove a + submenu if necessary. (Normally this function will not be necessary.) + } + PROCEDURE XPLMDestroyMenu( + inMenuID : XPLMMenuID); + cdecl; external XPLM_DLL; + + { + XPLMClearAllMenuItems + + This function removes all menu items from a menu, allowing you to rebuild + it. Use this function if you need to change the number of items on a menu. + } + PROCEDURE XPLMClearAllMenuItems( + inMenuID : XPLMMenuID); + cdecl; external XPLM_DLL; + + { + XPLMAppendMenuItem + + This routine appends a new menu item to the bottom of a menu and returns + its index. Pass in the menu to add the item to, the items name, and a void + * ref for this item. + + Returns a negative index if the append failed (due to an invalid parent + menu argument). + + Note that all menu indices returned are relative to your plugin's menus + only; if your plugin creates two sub-menus in the Plugins menu at different + times, it doesn't matter how many other plugins also create sub-menus of + Plugins in the intervening time: your sub-menus will be given menu indices + 0 and 1. (The SDK does some work in the back-end to filter out menus that + are irrelevant to your plugin in order to deliver this consistency for each + plugin.) + } + FUNCTION XPLMAppendMenuItem( + inMenu : XPLMMenuID; + inItemName : XPLMString; + inItemRef : pointer; + inDeprecatedAndIgnored: Integer) : Integer; + cdecl; external XPLM_DLL; + +{$IFDEF XPLM300} + { + XPLMAppendMenuItemWithCommand + + Like XPLMAppendMenuItem(), but instead of the new menu item triggering the + XPLMMenuHandler_f of the containiner menu, it will simply execute the + command you pass in. Using a command for your menu item allows the user to + bind a keyboard shortcut to the command and see that shortcut represented + in the menu. + + Returns a negative index if the append failed (due to an invalid parent + menu argument). + + Like XPLMAppendMenuItem(), all menu indices are relative to your plugin's + menus only. + } + FUNCTION XPLMAppendMenuItemWithCommand( + inMenu : XPLMMenuID; + inItemName : XPLMString; + inCommandToExecute : XPLMCommandRef) : Integer; + cdecl; external XPLM_DLL; +{$ENDIF XPLM300} + + { + XPLMAppendMenuSeparator + + This routine adds a separator to the end of a menu. + + Returns a negative index if the append failed (due to an invalid parent + menu argument). + } + PROCEDURE XPLMAppendMenuSeparator( + inMenu : XPLMMenuID); + cdecl; external XPLM_DLL; + + { + XPLMSetMenuItemName + + This routine changes the name of an existing menu item. Pass in the menu + ID and the index of the menu item. + } + PROCEDURE XPLMSetMenuItemName( + inMenu : XPLMMenuID; + inIndex : Integer; + inItemName : XPLMString; + inDeprecatedAndIgnored: Integer); + cdecl; external XPLM_DLL; + + { + XPLMCheckMenuItem + + Set whether a menu item is checked. Pass in the menu ID and item index. + } + PROCEDURE XPLMCheckMenuItem( + inMenu : XPLMMenuID; + index : Integer; + inCheck : XPLMMenuCheck); + cdecl; external XPLM_DLL; + + { + XPLMCheckMenuItemState + + This routine returns whether a menu item is checked or not. A menu item's + check mark may be on or off, or a menu may not have an icon at all. + } + PROCEDURE XPLMCheckMenuItemState( + inMenu : XPLMMenuID; + index : Integer; + outCheck : PXPLMMenuCheck); + cdecl; external XPLM_DLL; + + { + XPLMEnableMenuItem + + Sets whether this menu item is enabled. Items start out enabled. + } + PROCEDURE XPLMEnableMenuItem( + inMenu : XPLMMenuID; + index : Integer; + enabled : Integer); + cdecl; external XPLM_DLL; + +{$IFDEF XPLM210} + { + XPLMRemoveMenuItem + + Removes one item from a menu. Note that all menu items below are moved up + one; your plugin must track the change in index numbers. + } + PROCEDURE XPLMRemoveMenuItem( + inMenu : XPLMMenuID; + inIndex : Integer); + cdecl; external XPLM_DLL; +{$ENDIF XPLM210} + + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/Delphi/XPLM/XPLMNavigation.pas b/XPLPro_Plugin_Source/SDK/Delphi/XPLM/XPLMNavigation.pas new file mode 100644 index 0000000..044b99b --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/Delphi/XPLM/XPLMNavigation.pas @@ -0,0 +1,350 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPLMNavigation; +INTERFACE +{ + The XPLM Navigation APIs give you some access to the navigation databases + inside X-Plane. X-Plane stores all navigation information in RAM, so by + using these APIs you can gain access to most information without having to + go to disk or parse the files yourself. + + You can also use this API to program the FMS. You must use the navigation + APIs to find the nav-aids you want to program into the FMS, since the FMS + is powered internally by X-Plane's navigation database. +} + +USES + XPLMDefs; + {$A4} +{___________________________________________________________________________ + * NAVIGATION DATABASE ACCESS + ___________________________________________________________________________} + + { + XPLMNavType + + These enumerations define the different types of navaids. They are each + defined with a separate bit so that they may be bit-wise added together to + form sets of nav-aid types. + + NOTE: xplm_Nav_LatLon is a specific lat-lon coordinate entered into the + FMS. It will not exist in the database, and cannot be programmed into the + FMS. Querying the FMS for navaids will return it. Use + XPLMSetFMSEntryLatLon to set a lat/lon waypoint. + } +TYPE + XPLMNavType = ( + xplm_Nav_Unknown = 0 + + ,xplm_Nav_Airport = 1 + + ,xplm_Nav_NDB = 2 + + ,xplm_Nav_VOR = 4 + + ,xplm_Nav_ILS = 8 + + ,xplm_Nav_Localizer = 16 + + ,xplm_Nav_GlideSlope = 32 + + ,xplm_Nav_OuterMarker = 64 + + ,xplm_Nav_MiddleMarker = 128 + + ,xplm_Nav_InnerMarker = 256 + + ,xplm_Nav_Fix = 512 + + ,xplm_Nav_DME = 1024 + + ,xplm_Nav_LatLon = 2048 + + ); + PXPLMNavType = ^XPLMNavType; + + { + XPLMNavRef + + XPLMNavRef is an iterator into the navigation database. The navigation + database is essentially an array, but it is not necessarily densely + populated. The only assumption you can safely make is that like-typed + nav-aids are grouped together. + + Use XPLMNavRef to refer to a nav-aid. + + XPLM_NAV_NOT_FOUND is returned by functions that return an XPLMNavRef when + the iterator must be invalid. + } + XPLMNavRef = Integer; + PXPLMNavRef = ^XPLMNavRef; + +CONST + XPLM_NAV_NOT_FOUND = -1; + + { + XPLMGetFirstNavAid + + This returns the very first navaid in the database. Use this to traverse + the entire database. Returns XPLM_NAV_NOT_FOUND if the nav database is + empty. + } + FUNCTION XPLMGetFirstNavAid: XPLMNavRef; + cdecl; external XPLM_DLL; + + { + XPLMGetNextNavAid + + Given a valid nav aid ref, this routine returns the next navaid. It + returns XPLM_NAV_NOT_FOUND if the nav aid passed in was invalid or if the + navaid passed in was the last one in the database. Use this routine to + iterate across all like-typed navaids or the entire database. + } + FUNCTION XPLMGetNextNavAid( + inNavAidRef : XPLMNavRef) : XPLMNavRef; + cdecl; external XPLM_DLL; + + { + XPLMFindFirstNavAidOfType + + This routine returns the ref of the first navaid of the given type in the + database or XPLM_NAV_NOT_FOUND if there are no navaids of that type in the + database. You must pass exactly one nav aid type to this routine. + } + FUNCTION XPLMFindFirstNavAidOfType( + inType : XPLMNavType) : XPLMNavRef; + cdecl; external XPLM_DLL; + + { + XPLMFindLastNavAidOfType + + This routine returns the ref of the last navaid of the given type in the + database or XPLM_NAV_NOT_FOUND if there are no navaids of that type in the + database. You must pass exactly one nav aid type to this routine. + } + FUNCTION XPLMFindLastNavAidOfType( + inType : XPLMNavType) : XPLMNavRef; + cdecl; external XPLM_DLL; + + { + XPLMFindNavAid + + This routine provides a number of searching capabilities for the nav + database. XPLMFindNavAid will search through every nav aid whose type is + within inType (multiple types may be added together) and return any + nav-aids found based on the following rules: + + * If inLat and inLon are not NULL, the navaid nearest to that lat/lon will + be returned, otherwise the last navaid found will be returned. + + * If inFrequency is not NULL, then any navaids considered must match this + frequency. Note that this will screen out radio beacons that do not have + frequency data published (like inner markers) but not fixes and airports. + + * If inNameFragment is not NULL, only navaids that contain the fragment in + their name will be returned. + + * If inIDFragment is not NULL, only navaids that contain the fragment in + their IDs will be returned. + + This routine provides a simple way to do a number of useful searches: + * Find the nearest navaid on this frequency. + * Find the nearest airport. + * Find the VOR whose ID is "KBOS". + * Find the nearest airport whose name contains "Chicago". + } + FUNCTION XPLMFindNavAid( + inNameFragment : XPLMString; { Can be nil } + inIDFragment : XPLMString; { Can be nil } + inLat : PSingle; { Can be nil } + inLon : PSingle; { Can be nil } + inFrequency : PInteger; { Can be nil } + inType : XPLMNavType) : XPLMNavRef; + cdecl; external XPLM_DLL; + + { + XPLMGetNavAidInfo + + This routine returns information about a navaid. Any non-null field is + filled out with information if it is available. + + Frequencies are in the nav.dat convention as described in the X-Plane nav + database FAQ: NDB frequencies are exact, all others are multiplied by 100. + + The buffer for IDs should be at least 6 chars and the buffer for names + should be at least 41 chars, but since these values are likely to go up, I + recommend passing at least 32 chars for IDs and 256 chars for names when + possible. + + The outReg parameter tells if the navaid is within the local "region" of + loaded DSFs. (This information may not be particularly useful to plugins.) + The parameter is a single byte value 1 for true or 0 for false, not a C + string. + } + PROCEDURE XPLMGetNavAidInfo( + inRef : XPLMNavRef; + outType : PXPLMNavType; { Can be nil } + outLatitude : PSingle; { Can be nil } + outLongitude : PSingle; { Can be nil } + outHeight : PSingle; { Can be nil } + outFrequency : PInteger; { Can be nil } + outHeading : PSingle; { Can be nil } + outID : XPLMString; { Can be nil } + outName : XPLMString; { Can be nil } + outReg : XPLMString); { Can be nil } + cdecl; external XPLM_DLL; + +{___________________________________________________________________________ + * FLIGHT MANAGEMENT COMPUTER + ___________________________________________________________________________} +{ + Note: the FMS works based on an array of entries. Indices into the array + are zero-based. Each entry is a nav-aid plus an altitude. The FMS tracks + the currently displayed entry and the entry that it is flying to. + + The FMS must be programmed with contiguous entries, so clearing an entry at + the end shortens the effective flight plan. There is a max of 100 + waypoints in the flight plan. +} + + + { + XPLMCountFMSEntries + + This routine returns the number of entries in the FMS. + } + FUNCTION XPLMCountFMSEntries: Integer; + cdecl; external XPLM_DLL; + + { + XPLMGetDisplayedFMSEntry + + This routine returns the index of the entry the pilot is viewing. + } + FUNCTION XPLMGetDisplayedFMSEntry: Integer; + cdecl; external XPLM_DLL; + + { + XPLMGetDestinationFMSEntry + + This routine returns the index of the entry the FMS is flying to. + } + FUNCTION XPLMGetDestinationFMSEntry: Integer; + cdecl; external XPLM_DLL; + + { + XPLMSetDisplayedFMSEntry + + This routine changes which entry the FMS is showing to the index specified. + } + PROCEDURE XPLMSetDisplayedFMSEntry( + inIndex : Integer); + cdecl; external XPLM_DLL; + + { + XPLMSetDestinationFMSEntry + + This routine changes which entry the FMS is flying the aircraft toward. + } + PROCEDURE XPLMSetDestinationFMSEntry( + inIndex : Integer); + cdecl; external XPLM_DLL; + + { + XPLMGetFMSEntryInfo + + This routine returns information about a given FMS entry. If the entry is + an airport or navaid, a reference to a nav entry can be returned allowing + you to find additional information (such as a frequency, ILS heading, name, + etc.). Note that this reference can be XPLM_NAV_NOT_FOUND until the + information has been looked up asynchronously, so after flightplan changes, + it might take up to a second for this field to become populated. The other + information is available immediately. For a lat/lon entry, the lat/lon is + returned by this routine but the navaid cannot be looked up (and the + reference will be XPLM_NAV_NOT_FOUND). FMS name entry buffers should be at + least 256 chars in length. + + WARNING: Due to a bug in X-Plane prior to 11.31, the navaid reference will + not be set to XPLM_NAV_NOT_FOUND while no data is available, and instead + just remain the value of the variable that you passed the pointer to. + Therefore, always initialize the variable to XPLM_NAV_NOT_FOUND before + passing the pointer to this function. + } + PROCEDURE XPLMGetFMSEntryInfo( + inIndex : Integer; + outType : PXPLMNavType; { Can be nil } + outID : XPLMString; { Can be nil } + outRef : PXPLMNavRef; { Can be nil } + outAltitude : PInteger; { Can be nil } + outLat : PSingle; { Can be nil } + outLon : PSingle); { Can be nil } + cdecl; external XPLM_DLL; + + { + XPLMSetFMSEntryInfo + + This routine changes an entry in the FMS to have the destination navaid + passed in and the altitude specified. Use this only for airports, fixes, + and radio-beacon navaids. Currently of radio beacons, the FMS can only + support VORs and NDBs. Use the routines below to clear or fly to a lat/lon. + } + PROCEDURE XPLMSetFMSEntryInfo( + inIndex : Integer; + inRef : XPLMNavRef; + inAltitude : Integer); + cdecl; external XPLM_DLL; + + { + XPLMSetFMSEntryLatLon + + This routine changes the entry in the FMS to a lat/lon entry with the given + coordinates. + } + PROCEDURE XPLMSetFMSEntryLatLon( + inIndex : Integer; + inLat : Single; + inLon : Single; + inAltitude : Integer); + cdecl; external XPLM_DLL; + + { + XPLMClearFMSEntry + + This routine clears the given entry, potentially shortening the flight + plan. + } + PROCEDURE XPLMClearFMSEntry( + inIndex : Integer); + cdecl; external XPLM_DLL; + +{___________________________________________________________________________ + * GPS RECEIVER + ___________________________________________________________________________} +{ + These APIs let you read data from the GPS unit. +} + + { + XPLMGetGPSDestinationType + + This routine returns the type of the currently selected GPS destination, + one of fix, airport, VOR or NDB. + } + FUNCTION XPLMGetGPSDestinationType: XPLMNavType; + cdecl; external XPLM_DLL; + + { + XPLMGetGPSDestination + + This routine returns the current GPS destination. + } + FUNCTION XPLMGetGPSDestination: XPLMNavRef; + cdecl; external XPLM_DLL; + + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/Delphi/XPLM/XPLMPlanes.pas b/XPLPro_Plugin_Source/SDK/Delphi/XPLM/XPLMPlanes.pas new file mode 100644 index 0000000..3801f0a --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/Delphi/XPLM/XPLMPlanes.pas @@ -0,0 +1,278 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPLMPlanes; +INTERFACE +{ + The XPLMPlanes APIs allow you to control the various aircraft in X-Plane, + both the user's and the sim's. + + *Note*: unlike almost all other APIs in the SDK, aircraft paths are _full_ + file system paths for historical reasons. You'll need to prefix all + relative paths with the X-Plane path as accessed via XPLMGetSystemPath. +} + +USES + XPLMDefs; + {$A4} +{___________________________________________________________________________ + * USER AIRCRAFT ACCESS + ___________________________________________________________________________} + + { + XPLMSetUsersAircraft + + This routine changes the user's aircraft. Note that this will reinitialize + the user to be on the nearest airport's first runway. Pass in a full path + (hard drive and everything including the .acf extension) to the .acf file. + } + PROCEDURE XPLMSetUsersAircraft( + inAircraftPath : XPLMString); + cdecl; external XPLM_DLL; + { + XPLMPlaceUserAtAirport + + This routine places the user at a given airport. Specify the airport by + its X-Plane airport ID (e.g. 'KBOS'). + } + PROCEDURE XPLMPlaceUserAtAirport( + inAirportCode : XPLMString); + cdecl; external XPLM_DLL; +{$IFDEF XPLM300} + { + XPLMPlaceUserAtLocation + + Places the user at a specific location after performing any necessary + scenery loads. + + As with in-air starts initiated from the X-Plane user interface, the + aircraft will always start with its engines running, regardless of the + user's preferences (i.e., regardless of what the dataref + `sim/operation/prefs/startup_running` says). + } + PROCEDURE XPLMPlaceUserAtLocation( + latitudeDegrees : Real; + longitudeDegrees : Real; + elevationMetersMSL : Single; + headingDegreesTrue : Single; + speedMetersPerSecond: Single); + cdecl; external XPLM_DLL; +{$ENDIF XPLM300} +{___________________________________________________________________________ + * GLOBAL AIRCRAFT ACCESS + ___________________________________________________________________________} + +CONST + { The user's aircraft is always index 0. } + XPLM_USER_AIRCRAFT = 0; +{$IFDEF XPLM_DEPRECATED} + { + XPLMPlaneDrawState_t + + This structure contains additional plane parameter info to be passed to + draw plane. Make sure to fill in the size of the structure field with + sizeof(XPLMDrawPlaneState_t) so that the XPLM can tell how many fields you + knew about when compiling your plugin (since more fields may be added + later). + + Most of these fields are ratios from 0 to 1 for control input. X-Plane + calculates what the actual controls look like based on the .acf file for + that airplane. Note for the yoke inputs, this is what the pilot of the + plane has commanded (post artificial stability system if there were one) + and affects aelerons, rudder, etc. It is not necessarily related to the + actual position of the plane! + } +TYPE + XPLMPlaneDrawState_t = RECORD + { The size of the draw state struct. } + structSize : Integer; + { A ratio from [0..1] describing how far the landing gear is extended. } + gearPosition : Single; + { Ratio of flap deployment, 0 = up, 1 = full deploy. } + flapRatio : Single; + { Ratio of spoiler deployment, 0 = none, 1 = full deploy. } + spoilerRatio : Single; + { Ratio of speed brake deployment, 0 = none, 1 = full deploy. } + speedBrakeRatio : Single; + { Ratio of slat deployment, 0 = none, 1 = full deploy. } + slatRatio : Single; + { Wing sweep ratio, 0 = forward, 1 = swept. } + wingSweep : Single; + { Thrust power, 0 = none, 1 = full fwd, -1 = full reverse. } + thrust : Single; + { Total pitch input for this plane. } + yokePitch : Single; + { Total Heading input for this plane. } + yokeHeading : Single; + { Total Roll input for this plane. } + yokeRoll : Single; + END; + PXPLMPlaneDrawState_t = ^XPLMPlaneDrawState_t; +{$ENDIF XPLM_DEPRECATED} + { + XPLMCountAircraft + + This function returns the number of aircraft X-Plane is capable of having, + as well as the number of aircraft that are currently active. These numbers + count the user's aircraft. It can also return the plugin that is currently + controlling aircraft. In X-Plane 7, this routine reflects the number of + aircraft the user has enabled in the rendering options window. + } + PROCEDURE XPLMCountAircraft( + outTotalAircraft : PInteger; + outActiveAircraft : PInteger; + outController : PXPLMPluginID); + cdecl; external XPLM_DLL; + { + XPLMGetNthAircraftModel + + This function returns the aircraft model for the Nth aircraft. Indices are + zero based, with zero being the user's aircraft. The file name should be + at least 256 chars in length; the path should be at least 512 chars in + length. + } + PROCEDURE XPLMGetNthAircraftModel( + inIndex : Integer; + outFileName : XPLMString; + outPath : XPLMString); + cdecl; external XPLM_DLL; +{___________________________________________________________________________ + * EXCLUSIVE AIRCRAFT ACCESS + ___________________________________________________________________________} +{ + The following routines require exclusive access to the airplane APIs. Only + one plugin may have this access at a time. +} + + + { + XPLMPlanesAvailable_f + + Your airplanes available callback is called when another plugin gives up + access to the multiplayer planes. Use this to wait for access to + multiplayer. + } +TYPE + XPLMPlanesAvailable_f = PROCEDURE( + inRefcon : pointer); cdecl; + + { + XPLMAcquirePlanes + + XPLMAcquirePlanes grants your plugin exclusive access to the aircraft. It + returns 1 if you gain access, 0 if you do not. + + inAircraft - pass in an array of pointers to strings specifying the planes + you want loaded. For any plane index you do not want loaded, pass a + 0-length string. Other strings should be full paths with the .acf + extension. NULL terminates this array, or pass NULL if there are no planes + you want loaded. + + If you pass in a callback and do not receive access to the planes your + callback will be called when the airplanes are available. If you do receive + airplane access, your callback will not be called. + } + FUNCTION XPLMAcquirePlanes( + inAircraft : PXPLMString; { Can be nil } + inCallback : XPLMPlanesAvailable_f; + inRefcon : pointer) : Integer; + cdecl; external XPLM_DLL; + + { + XPLMReleasePlanes + + Call this function to release access to the planes. Note that if you are + disabled, access to planes is released for you and you must reacquire it. + } + PROCEDURE XPLMReleasePlanes; + cdecl; external XPLM_DLL; + + { + XPLMSetActiveAircraftCount + + This routine sets the number of active planes. If you pass in a number + higher than the total number of planes availables, only the total number of + planes available is actually used. + } + PROCEDURE XPLMSetActiveAircraftCount( + inCount : Integer); + cdecl; external XPLM_DLL; + + { + XPLMSetAircraftModel + + This routine loads an aircraft model. It may only be called if you have + exclusive access to the airplane APIs. Pass in the path of the model with + the .acf extension. The index is zero based, but you may not pass in 0 + (use XPLMSetUsersAircraft to load the user's aircracft). + } + PROCEDURE XPLMSetAircraftModel( + inIndex : Integer; + inAircraftPath : XPLMString); + cdecl; external XPLM_DLL; + + { + XPLMDisableAIForPlane + + This routine turns off X-Plane's AI for a given plane. The plane will + continue to draw and be a real plane in X-Plane, but will not move itself. + } + PROCEDURE XPLMDisableAIForPlane( + inPlaneIndex : Integer); + cdecl; external XPLM_DLL; + +{$IFDEF XPLM_DEPRECATED} + { + XPLMDrawAircraft + + WARNING: Aircraft drawing via this API is deprecated and will not work in + future versions of X-Plane. Use XPLMInstance for 3-d drawing of custom + aircraft models. + + This routine draws an aircraft. It can only be called from a 3-d drawing + callback. Pass in the position of the plane in OpenGL local coordinates + and the orientation of the plane. A 1 for full drawing indicates that the + whole plane must be drawn; a 0 indicates you only need the nav lights + drawn. (This saves rendering time when planes are far away.) + } + PROCEDURE XPLMDrawAircraft( + inPlaneIndex : Integer; + inX : Single; + inY : Single; + inZ : Single; + inPitch : Single; + inRoll : Single; + inYaw : Single; + inFullDraw : Integer; + inDrawStateInfo : PXPLMPlaneDrawState_t); + cdecl; external XPLM_DLL; +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { + XPLMReinitUsersPlane + + WARNING: DO NOT USE. Use XPLMPlaceUserAtAirport or + XPLMPlaceUserAtLocation. + + This function recomputes the derived flight model data from the aircraft + structure in memory. If you have used the data access layer to modify the + aircraft structure, use this routine to resynchronize X-Plane; since + X-Plane works at least partly from derived values, the sim will not behave + properly until this is called. + + WARNING: this routine does not necessarily place the airplane at the + airport; use XPLMSetUsersAircraft to be compatible. This routine is + provided to do special experimentation with flight models without resetting + flight. + } + PROCEDURE XPLMReinitUsersPlane; + cdecl; external XPLM_DLL; +{$ENDIF XPLM_DEPRECATED} + + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/Delphi/XPLM/XPLMPlugin.pas b/XPLPro_Plugin_Source/SDK/Delphi/XPLM/XPLMPlugin.pas new file mode 100644 index 0000000..83fbb73 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/Delphi/XPLM/XPLMPlugin.pas @@ -0,0 +1,413 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPLMPlugin; +INTERFACE +{ + These APIs provide facilities to find and work with other plugins and + manage other plugins. +} + +USES + XPLMDefs; + {$A4} +{___________________________________________________________________________ + * FINDING PLUGINS + ___________________________________________________________________________} +{ + These APIs allow you to find another plugin or yourself, or iterate across + all plugins. For example, if you wrote an FMS plugin that needed to talk + to an autopilot plugin, you could use these APIs to locate the autopilot + plugin. +} + + + { + XPLMGetMyID + + This routine returns the plugin ID of the calling plug-in. Call this to + get your own ID. + } + FUNCTION XPLMGetMyID: XPLMPluginID; + cdecl; external XPLM_DLL; + + { + XPLMCountPlugins + + This routine returns the total number of plug-ins that are loaded, both + disabled and enabled. + } + FUNCTION XPLMCountPlugins: Integer; + cdecl; external XPLM_DLL; + + { + XPLMGetNthPlugin + + This routine returns the ID of a plug-in by index. Index is 0 based from 0 + to XPLMCountPlugins-1, inclusive. Plugins may be returned in any arbitrary + order. + } + FUNCTION XPLMGetNthPlugin( + inIndex : Integer) : XPLMPluginID; + cdecl; external XPLM_DLL; + + { + XPLMFindPluginByPath + + This routine returns the plug-in ID of the plug-in whose file exists at the + passed in absolute file system path. XPLM_NO_PLUGIN_ID is returned if the + path does not point to a currently loaded plug-in. + } + FUNCTION XPLMFindPluginByPath( + inPath : XPLMString) : XPLMPluginID; + cdecl; external XPLM_DLL; + + { + XPLMFindPluginBySignature + + This routine returns the plug-in ID of the plug-in whose signature matches + what is passed in or XPLM_NO_PLUGIN_ID if no running plug-in has this + signature. Signatures are the best way to identify another plug-in as they + are independent of the file system path of a plug-in or the human-readable + plug-in name, and should be unique for all plug-ins. Use this routine to + locate another plugin that your plugin interoperates with + } + FUNCTION XPLMFindPluginBySignature( + inSignature : XPLMString) : XPLMPluginID; + cdecl; external XPLM_DLL; + + { + XPLMGetPluginInfo + + This routine returns information about a plug-in. Each parameter should be + a pointer to a buffer of at least + 256 characters, or NULL to not receive the information. + + outName - the human-readable name of the plug-in. outFilePath - the + absolute file path to the file that contains this plug-in. outSignature - a + unique string that identifies this plug-in. outDescription - a + human-readable description of this plug-in. + } + PROCEDURE XPLMGetPluginInfo( + inPlugin : XPLMPluginID; + outName : XPLMString; { Can be nil } + outFilePath : XPLMString; { Can be nil } + outSignature : XPLMString; { Can be nil } + outDescription : XPLMString); { Can be nil } + cdecl; external XPLM_DLL; + +{___________________________________________________________________________ + * ENABLING/DISABLING PLUG-INS + ___________________________________________________________________________} +{ + These routines are used to work with plug-ins and manage them. Most + plugins will not need to use these APIs. +} + + + { + XPLMIsPluginEnabled + + Returns whether the specified plug-in is enabled for running. + } + FUNCTION XPLMIsPluginEnabled( + inPluginID : XPLMPluginID) : Integer; + cdecl; external XPLM_DLL; + + { + XPLMEnablePlugin + + This routine enables a plug-in if it is not already enabled. It returns 1 + if the plugin was enabled or successfully enables itself, 0 if it does not. + Plugins may fail to enable (for example, if resources cannot be acquired) + by returning 0 from their XPluginEnable callback. + } + FUNCTION XPLMEnablePlugin( + inPluginID : XPLMPluginID) : Integer; + cdecl; external XPLM_DLL; + + { + XPLMDisablePlugin + + This routine disableds an enabled plug-in. + } + PROCEDURE XPLMDisablePlugin( + inPluginID : XPLMPluginID); + cdecl; external XPLM_DLL; + + { + XPLMReloadPlugins + + This routine reloads all plug-ins. Once this routine is called and you + return from the callback you were within (e.g. a menu select callback) you + will receive your XPluginDisable and XPluginStop callbacks and your DLL + will be unloaded, then the start process happens as if the sim was starting + up. + } + PROCEDURE XPLMReloadPlugins; + cdecl; external XPLM_DLL; + +{___________________________________________________________________________ + * INTERPLUGIN MESSAGING + ___________________________________________________________________________} +{ + Plugin messages are defined as 32-bit integers. Messages below 0x00FFFFFF + are reserved for X-Plane and the plugin SDK. + + Messages come with a pointer parameter; the meaning of this pointer depends + on the message itself. In some messages, the pointer parameter contains an + actual typed pointer to data that can be inspected in the plugin; in these + cases the documentation will state that the parameter "points to" + information. + + in other cases, the value of the pointer is actually an integral number + stuffed into the pointer's storage. In these second cases, the pointer + parameter needs to be cast, not dereferenced. In these caess, the + documentation will state that the parameter "contains" a value, which will + always be an integral type. + + Some messages don't use the pointer parameter - in this case your plugin + should ignore it. + + Messages have two conceptual uses: notifications and commands. Commands + are sent from one plugin to another to induce behavior; notifications are + sent from one plugin to all others for informational purposes. It is + important that commands and notifications not have the same values because + this could cause a notification sent by one plugin to accidentally induce a + command in another. + + By convention, plugin-defined notifications should have the high bit set + (e.g. be greater or equal to unsigned 0x8000000) while commands should have + this bit be cleared. + + The following messages are sent to your plugin by X-Plane. +} + + +CONST + { This message is sent to your plugin whenever the user's plane crashes. The } + { parameter is ignored. } + XPLM_MSG_PLANE_CRASHED = 101; + + { This message is sent to your plugin whenever a new plane is loaded. The } + { parameter contains the index number of the plane being loaded; 0 indicates } + { the user's plane. } + XPLM_MSG_PLANE_LOADED = 102; + + { This messages is sent whenever the user's plane is positioned at a new } + { airport. The parameter is ignored. } + XPLM_MSG_AIRPORT_LOADED = 103; + + { This message is sent whenever new scenery is loaded. Use datarefs to } + { determine the new scenery files that were loaded. The parameter is ignored.} + XPLM_MSG_SCENERY_LOADED = 104; + + { This message is sent whenever the user adjusts the number of X-Plane } + { aircraft models. You must use XPLMCountPlanes to find out how many planes } + { are now available. This message will only be sent in XP7 and higher } + { because in XP6 the number of aircraft is not user-adjustable. The parameter} + { is ignored. } + XPLM_MSG_AIRPLANE_COUNT_CHANGED = 105; + +{$IFDEF XPLM200} +CONST + { This message is sent to your plugin whenever a plane is unloaded. The } + { parameter contains the index number of the plane being unloaded; 0 } + { indicates the user's plane. The parameter is of type int, passed as the } + { value of the pointer. (That is: the parameter is an int, not a pointer to } + { an int.) } + XPLM_MSG_PLANE_UNLOADED = 106; +{$ENDIF XPLM200} + +{$IFDEF XPLM210} +CONST + { This message is sent to your plugin right before X-Plane writes its } + { preferences file. You can use this for two purposes: to write your own } + { preferences, and to modify any datarefs to influence preferences output. } + { For example, if your plugin temporarily modifies saved preferences, you can} + { put them back to their default values here to avoid having the tweaks be } + { persisted if your plugin is not loaded on the next invocation of X-Plane. } + { The parameter is ignored. } + XPLM_MSG_WILL_WRITE_PREFS = 107; +{$ENDIF XPLM210} + +{$IFDEF XPLM210} + { This message is sent to your plugin right after a livery is loaded for an } + { airplane. You can use this to check the new livery (via datarefs) and } + { react accordingly. The parameter contains the index number of the aircraft} + { whose livery is changing. } + XPLM_MSG_LIVERY_LOADED = 108; +{$ENDIF XPLM210} + +{$IFDEF XPLM301} +CONST + { Sent to your plugin right before X-Plane enters virtual reality mode (at } + { which time any windows that are not positioned in VR mode will no longer be} + { visible to the user). The parameter is unused and should be ignored. } + XPLM_MSG_ENTERED_VR = 109; +{$ENDIF XPLM301} + +{$IFDEF XPLM301} + { Sent to your plugin right before X-Plane leaves virtual reality mode (at } + { which time you may want to clean up windows that are positioned in VR } + { mode). The parameter is unused and should be ignored. } + XPLM_MSG_EXITING_VR = 110; +{$ENDIF XPLM301} + +{$IFDEF XPLM303} +CONST + { Sent to your plugin if another plugin wants to take over AI planes. If you } + { are a synthetic traffic provider, that probably means a plugin for an } + { online network has connected and wants to supply aircraft flown by real } + { humans and you should cease to provide synthetic traffic. If however you } + { are providing online traffic from real humans, you probably don't want to } + { disconnect, in which case you just ignore this message. The sender is the } + { plugin ID of the plugin asking for control of the planes now. You can use } + { it to find out who is requesting and whether you should yield to them. } + { Synthetic traffic providers should always yield to online networks. The } + { parameter is unused and should be ignored. } + XPLM_MSG_RELEASE_PLANES = 111; +{$ENDIF XPLM303} + + { + XPLMSendMessageToPlugin + + This function sends a message to another plug-in or X-Plane. Pass + XPLM_NO_PLUGIN_ID to broadcast to all plug-ins. Only enabled plug-ins with + a message receive function receive the message. + } + PROCEDURE XPLMSendMessageToPlugin( + inPlugin : XPLMPluginID; + inMessage : Integer; + inParam : pointer); + cdecl; external XPLM_DLL; + +{$IFDEF XPLM200} +{___________________________________________________________________________ + * Plugin Features API + ___________________________________________________________________________} +{ + The plugin features API allows your plugin to "sign up" for additional + capabilities and plugin system features that are normally disabled for + backward compatibility. This allows advanced plugins to "opt-in" to new + behavior. + + Each feature is defined by a permanent string name. The feature string + names will vary with the particular installation of X-Plane, so plugins + should not expect a feature to be guaranteed present. + + XPLM_WANTS_REFLECTIONS + ---------------------- + + Available in the SDK 2.0 and later for X-Plane 9, enabling this capability + causes your plugin to receive drawing hook callbacks when X-Plane builds + its off-screen reflection and shadow rendering passes. Plugins should + enable this and examine the dataref sim/graphics/view/plane_render_type to + determine whether the drawing callback is for a reflection, shadow + calculation, or the main screen. Rendering can be simlified or omitted for + reflections, and non-solid drawing should be skipped for shadow + calculations. + + **Note**: direct drawing via draw callbacks is not recommended; use the + XPLMInstance API to create object models instead. + + XPLM_USE_NATIVE_PATHS + --------------------- + + available in the SDK 2.1 and later for X-Plane 10, this modifies the plugin + system to use Unix-style paths on all operating systems. With this enabled: + + * OS X paths will match the native OS X Unix. + * Windows will use forward slashes but preserve C:\ or another drive letter + when using complete file paths. + * Linux uses its native file system path scheme. + + Without this enabled: + + * OS X will use CFM file paths separated by a colon. + * Windows will use back-slashes and conventional DOS paths. + * Linux uses its native file system path scheme. + + All plugins should enable this feature on OS X to access the native file + system. + + XPLM_USE_NATIVE_WIDGET_WINDOWS + ------------------------------ + + Available in the SDK 3.0.2 SDK, this capability tells the widgets library + to use new, modern X-Plane backed XPLMDisplay windows to anchor all widget + trees. Without it, widgets will always use legacy windows. + + Plugins should enable this to allow their widget hierarchies to respond to + the user's UI size settings and to map widget-based windwos to a VR HMD. + + Before enabling this, make sure any custom widget code in your plugin is + prepared to cope with the UI coordinate system not being th same as the + OpenGL window coordinate system. +} + + + { + XPLMFeatureEnumerator_f + + You pass an XPLMFeatureEnumerator_f to get a list of all features supported + by a given version running version of X-Plane. This routine is called once + for each feature. + } +TYPE + XPLMFeatureEnumerator_f = PROCEDURE( + inFeature : XPLMString; + inRef : pointer); cdecl; + + { + XPLMHasFeature + + This returns 1 if the given installation of X-Plane supports a feature, or + 0 if it does not. + } + FUNCTION XPLMHasFeature( + inFeature : XPLMString) : Integer; + cdecl; external XPLM_DLL; + + { + XPLMIsFeatureEnabled + + This returns 1 if a feature is currently enabled for your plugin, or 0 if + it is not enabled. It is an error to call this routine with an unsupported + feature. + } + FUNCTION XPLMIsFeatureEnabled( + inFeature : XPLMString) : Integer; + cdecl; external XPLM_DLL; + + { + XPLMEnableFeature + + This routine enables or disables a feature for your plugin. This will + change the running behavior of X-Plane and your plugin in some way, + depending on the feature. + } + PROCEDURE XPLMEnableFeature( + inFeature : XPLMString; + inEnable : Integer); + cdecl; external XPLM_DLL; + + { + XPLMEnumerateFeatures + + This routine calls your enumerator callback once for each feature that this + running version of X-Plane supports. Use this routine to determine all of + the features that X-Plane can support. + } + PROCEDURE XPLMEnumerateFeatures( + inEnumerator : XPLMFeatureEnumerator_f; + inRef : pointer); + cdecl; external XPLM_DLL; + +{$ENDIF XPLM200} + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/Delphi/XPLM/XPLMProcessing.pas b/XPLPro_Plugin_Source/SDK/Delphi/XPLM/XPLMProcessing.pas new file mode 100644 index 0000000..e09b6e5 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/Delphi/XPLM/XPLMProcessing.pas @@ -0,0 +1,254 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPLMProcessing; +INTERFACE +{ + This API allows you to get regular callbacks during the flight loop, the + part of X-Plane where the plane's position calculates the physics of + flight, etc. Use these APIs to accomplish periodic tasks like logging data + and performing I/O. + + You can receive a callback either just before or just after the per-frame + physics calculations happen - you can use post-FM callbacks to "patch" the + flight model after it has run. + + If the user has set the number of flight model iterations per frame greater + than one your plugin will _not_ see this; these integrations run on the + sub-section of the flight model where iterations improve responsiveness + (e.g. physical integration, not simple systems tracking) and are thus + opaque to plugins. + + Flight loop scheduling, when scheduled by time, is scheduled by a "first + callback after the deadline" schedule, e.g. your callbacks will always be + slightly late to ensure that we don't run faster than your deadline. + + WARNING: Do NOT use these callbacks to draw! You cannot draw during flight + loop callbacks. Use the drawing callbacks (see XPLMDisplay for more info) + for graphics. (One exception: you can use a post-flight loop callback to + update your own off-screen FBOs.) +} + +USES + XPLMDefs; + {$A4} +{___________________________________________________________________________ + * FLIGHT LOOP CALLBACKS + ___________________________________________________________________________} + +{$IFDEF XPLM210} + { + XPLMFlightLoopPhaseType + + You can register a flight loop callback to run either before or after the + flight model is integrated by X-Plane. + } +TYPE + XPLMFlightLoopPhaseType = ( + { Your callback runs before X-Plane integrates the flight model. } + xplm_FlightLoop_Phase_BeforeFlightModel = 0 + + { Your callback runs after X-Plane integrates the flight model. } + ,xplm_FlightLoop_Phase_AfterFlightModel = 1 + + ); + PXPLMFlightLoopPhaseType = ^XPLMFlightLoopPhaseType; +{$ENDIF XPLM210} + +{$IFDEF XPLM210} + { + XPLMFlightLoopID + + This is an opaque identifier for a flight loop callback. You can use this + identifier to easily track and remove your callbacks, or to use the new + flight loop APIs. + } + XPLMFlightLoopID = pointer; + PXPLMFlightLoopID = ^XPLMFlightLoopID; +{$ENDIF XPLM210} + + { + XPLMFlightLoop_f + + This is your flight loop callback. Each time the flight loop is iterated + through, you receive this call at the end. + + Flight loop callbacks receive a number of input timing parameters. These + input timing parameters are not particularly useful; you may need to track + your own timing data (e.g. by reading datarefs). The input parameters are: + + - inElapsedSinceLastCall: the wall time since your last callback. + - inElapsedTimeSinceLastFlightLoop: the wall time since any flight loop was + dispatched. + - inCounter: a monotonically increasing counter, bumped once per flight + loop dispatch from the sim. + - inRefcon: your own ptr constant from when you regitered yor callback. + + Your return value controls when you will next be called. + + - Return 0 to stop receiving callbacks. + - Pass a positive number to specify how many seconds until the next + callback. (You will be called at or after this time, not before.) + - Pass a negative number to specify how many loops must go by until you + are called. For example, -1.0 means call me the very next loop. + + Try to run your flight loop as infrequently as is practical, and suspend it + (using return value 0) when you do not need it; lots of flight loop + callbacks that do nothing lowers X-Plane's frame rate. + + Your callback will NOT be unregistered if you return 0; it will merely be + inactive. + } +TYPE + XPLMFlightLoop_f = FUNCTION( + inElapsedSinceLastCall: Single; + inElapsedTimeSinceLastFlightLoop: Single; + inCounter : Integer; + inRefcon : pointer) : Single; cdecl; + +{$IFDEF XPLM210} + { + XPLMCreateFlightLoop_t + + XPLMCreateFlightLoop_t contains the parameters to create a new flight loop + callback. The strsucture can be expanded in future SDKs - always set + structSize to the size of your structure in bytes. + } +TYPE + XPLMCreateFlightLoop_t = RECORD + structSize : Integer; + phase : XPLMFlightLoopPhaseType; + callbackFunc : XPLMFlightLoop_f; + refcon : pointer; + END; + PXPLMCreateFlightLoop_t = ^XPLMCreateFlightLoop_t; +{$ENDIF XPLM210} + + { + XPLMGetElapsedTime + + This routine returns the elapsed time since the sim started up in decimal + seconds. This is a wall timer; it keeps counting upward even if the sim is + pasued. + + __WARNING__: XPLMGetElapsedTime is not a very good timer! It lacks + precision in both its data type and its source. Do not attempt to use it + for timing critical applications like network multiplayer. + } + FUNCTION XPLMGetElapsedTime: Single; + cdecl; external XPLM_DLL; + + { + XPLMGetCycleNumber + + This routine returns a counter starting at zero for each sim cycle + computed/video frame rendered. + } + FUNCTION XPLMGetCycleNumber: Integer; + cdecl; external XPLM_DLL; + + { + XPLMRegisterFlightLoopCallback + + This routine registers your flight loop callback. Pass in a pointer to a + flight loop function and a refcon. inInterval defines when you will be + called. Pass in a positive number to specify seconds from registration time + to the next callback. Pass in a negative number to indicate when you will + be called (e.g. pass -1 to be called at the next cylcle). Pass 0 to not be + called; your callback will be inactive. + + (This legacy function only installs pre-flight-loop callbacks; use + XPLMCreateFlightLoop for more control.) + } + PROCEDURE XPLMRegisterFlightLoopCallback( + inFlightLoop : XPLMFlightLoop_f; + inInterval : Single; + inRefcon : pointer); + cdecl; external XPLM_DLL; + + { + XPLMUnregisterFlightLoopCallback + + This routine unregisters your flight loop callback. Do NOT call it from + your flight loop callback. Once your flight loop callback is unregistered, + it will not be called again. + + Only use this on flight loops registered via + XPLMRegisterFlightLoopCallback. + } + PROCEDURE XPLMUnregisterFlightLoopCallback( + inFlightLoop : XPLMFlightLoop_f; + inRefcon : pointer); + cdecl; external XPLM_DLL; + + { + XPLMSetFlightLoopCallbackInterval + + This routine sets when a callback will be called. Do NOT call it from your + callback; use the return value of the callback to change your callback + interval from inside your callback. + + inInterval is formatted the same way as in XPLMRegisterFlightLoopCallback; + positive for seconds, negative for cycles, and 0 for deactivating the + callback. If inRelativeToNow is 1, times are from the time of this call; + otherwise they are from the time the callback was last called (or the time + it was registered if it has never been called. + } + PROCEDURE XPLMSetFlightLoopCallbackInterval( + inFlightLoop : XPLMFlightLoop_f; + inInterval : Single; + inRelativeToNow : Integer; + inRefcon : pointer); + cdecl; external XPLM_DLL; + +{$IFDEF XPLM210} + { + XPLMCreateFlightLoop + + This routine creates a flight loop callback and returns its ID. The flight + loop callback is created using the input param struct, and is inited to be + unscheduled. + } + FUNCTION XPLMCreateFlightLoop( + inParams : PXPLMCreateFlightLoop_t) : XPLMFlightLoopID; + cdecl; external XPLM_DLL; +{$ENDIF XPLM210} + +{$IFDEF XPLM210} + { + XPLMDestroyFlightLoop + + This routine destroys a flight loop callback by ID. Only call it on flight + loops created with the newer XPLMCreateFlightLoop API. + } + PROCEDURE XPLMDestroyFlightLoop( + inFlightLoopID : XPLMFlightLoopID); + cdecl; external XPLM_DLL; +{$ENDIF XPLM210} + +{$IFDEF XPLM210} + { + XPLMScheduleFlightLoop + + This routine schedules a flight loop callback for future execution. If + inInterval is negative, it is run in a certain number of frames based on + the absolute value of the input. If the interval is positive, it is a + duration in seconds. + + If inRelativeToNow is true, ties are interpretted relative to the time this + routine is called; otherwise they are relative to the last call time or the + time the flight loop was registered (if never called). + } + PROCEDURE XPLMScheduleFlightLoop( + inFlightLoopID : XPLMFlightLoopID; + inInterval : Single; + inRelativeToNow : Integer); + cdecl; external XPLM_DLL; +{$ENDIF XPLM210} + + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/Delphi/XPLM/XPLMScenery.pas b/XPLPro_Plugin_Source/SDK/Delphi/XPLM/XPLMScenery.pas new file mode 100644 index 0000000..a585830 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/Delphi/XPLM/XPLMScenery.pas @@ -0,0 +1,434 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPLMScenery; +INTERFACE +{ + This package contains APIs to interact with X-Plane's scenery system. +} + +USES + XPLMDefs; + {$A4} +{$IFDEF XPLM200} +{___________________________________________________________________________ + * Terrain Y-Testing + ___________________________________________________________________________} +{ + The Y-testing API allows you to locate the physical scenery mesh. This + would be used to place dynamic graphics on top of the ground in a plausible + way or do physics interactions. + + The Y-test API works via probe objects, which are allocated by your plugin + and used to query terrain. Probe objects exist both to capture which + algorithm you have requested (see probe types) and also to cache query + information. + + Performance Guidelines + ---------------------- + + It is generally faster to use the same probe for nearby points and + different probes for different points. Try not to allocate more than + "hundreds" of probes at most. Share probes if you need more. Generally, + probing operations are expensive, and should be avoided via caching when + possible. + + Y testing returns a location on the terrain, a normal vectory, and a + velocity vector. The normal vector tells you the slope of the terrain at + that point. The velocity vector tells you if that terrain is moving (and is + in meters/second). For example, if your Y test hits the aircraft carrier + deck, this tells you the velocity of that point on the deck. + + Note: the Y-testing API is limited to probing the loaded scenery area, + which is approximately 300x300 km in X-Plane 9. Probes outside this area + will return the height of a 0 MSL sphere. +} + + + { + XPLMProbeType + + XPLMProbeType defines the type of terrain probe - each probe has a + different algorithm. (Only one type of probe is provided right now, but + future APIs will expose more flexible or poewrful or useful probes. + } +TYPE + XPLMProbeType = ( + { The Y probe gives you the location of the tallest physical scenery along } + { the Y axis going through the queried point. } + xplm_ProbeY = 0 + + ); + PXPLMProbeType = ^XPLMProbeType; + + { + XPLMProbeResult + + Probe results - possible results from a probe query. + } + XPLMProbeResult = ( + { The probe hit terrain and returned valid values. } + xplm_ProbeHitTerrain = 0 + + { An error in the API call. Either the probe struct size is bad, or the } + { probe is invalid or the type is mismatched for the specific query call. } + ,xplm_ProbeError = 1 + + { The probe call succeeded but there is no terrain under this point (perhaps } + { it is off the side of the planet?) } + ,xplm_ProbeMissed = 2 + + ); + PXPLMProbeResult = ^XPLMProbeResult; + + { + XPLMProbeRef + + An XPLMProbeRef is an opaque handle to a probe, used for querying the + terrain. + } + XPLMProbeRef = pointer; + PXPLMProbeRef = ^XPLMProbeRef; + + { + XPLMProbeInfo_t + + XPLMProbeInfo_t contains the results of a probe call. Make sure to set + structSize to the size of the struct before using it. + } + XPLMProbeInfo_t = RECORD + { Size of structure in bytes - always set this before calling the XPLM. } + structSize : Integer; + { Resulting X location of the terrain point we hit, in local OpenGL } + { coordinates. } + locationX : Single; + { Resulting Y location of the terrain point we hit, in local OpenGL } + { coordinates. } + locationY : Single; + { Resulting Z location of the terrain point we hit, in local OpenGL } + { coordinates. } + locationZ : Single; + { X component of the normal vector to the terrain we found. } + normalX : Single; + { Y component of the normal vector to the terrain we found. } + normalY : Single; + { Z component of the normal vector to the terrain we found. } + normalZ : Single; + { X component of the velocity vector of the terrain we found. } + velocityX : Single; + { Y component of the velocity vector of the terrain we found. } + velocityY : Single; + { Z component of the velocity vector of the terrain we found. } + velocityZ : Single; + { Tells if the surface we hit is water (otherwise it is land). } + is_wet : Integer; + END; + PXPLMProbeInfo_t = ^XPLMProbeInfo_t; + + { + XPLMCreateProbe + + Creates a new probe object of a given type and returns. + } + FUNCTION XPLMCreateProbe( + inProbeType : XPLMProbeType) : XPLMProbeRef; + cdecl; external XPLM_DLL; + + { + XPLMDestroyProbe + + Deallocates an existing probe object. + } + PROCEDURE XPLMDestroyProbe( + inProbe : XPLMProbeRef); + cdecl; external XPLM_DLL; + + { + XPLMProbeTerrainXYZ + + Probes the terrain. Pass in the XYZ coordinate of the probe point, a probe + object, and an XPLMProbeInfo_t struct that has its structSize member set + properly. Other fields are filled in if we hit terrain, and a probe result + is returned. + } + FUNCTION XPLMProbeTerrainXYZ( + inProbe : XPLMProbeRef; + inX : Single; + inY : Single; + inZ : Single; + outInfo : PXPLMProbeInfo_t) : XPLMProbeResult; + cdecl; external XPLM_DLL; + +{$ENDIF XPLM200} +{$IFDEF XPLM300} +{___________________________________________________________________________ + * Magnetic Variation + ___________________________________________________________________________} +{ + Use the magnetic variation (more properly, the "magnetic declination") API + to find the offset of magnetic north from true north at a given latitude + and longitude within the simulator. + + In the real world, the Earth's magnetic field is irregular, such that true + north (the direction along a meridian toward the north pole) does not + necessarily match what a magnetic compass shows as north. + + Using this API ensures that you present the same offsets to users as + X-Plane's built-in instruments. +} + + + { + XPLMGetMagneticVariation + + Returns X-Plane's simulated magnetic variation (declination) at the + indication latitude and longitude. + } + FUNCTION XPLMGetMagneticVariation( + latitude : Real; + longitude : Real) : Single; + cdecl; external XPLM_DLL; + + { + XPLMDegTrueToDegMagnetic + + Converts a heading in degrees relative to true north into a value relative + to magnetic north at the user's current location. + } + FUNCTION XPLMDegTrueToDegMagnetic( + headingDegreesTrue : Single) : Single; + cdecl; external XPLM_DLL; + + { + XPLMDegMagneticToDegTrue + + Converts a heading in degrees relative to magnetic north at the user's + current location into a value relative to true north. + } + FUNCTION XPLMDegMagneticToDegTrue( + headingDegreesMagnetic: Single) : Single; + cdecl; external XPLM_DLL; + +{$ENDIF XPLM300} +{___________________________________________________________________________ + * Object Drawing + ___________________________________________________________________________} +{ + The object drawing routines let you load and draw X-Plane OBJ files. + Objects are loaded by file path and managed via an opaque handle. X-Plane + naturally reference counts objects, so it is important that you balance + every successful call to XPLMLoadObject with a call to XPLMUnloadObject! +} + + +{$IFDEF XPLM200} +TYPE + { + XPLMObjectRef + + An XPLMObjectRef is a opaque handle to an .obj file that has been loaded + into memory. + } + XPLMObjectRef = pointer; + PXPLMObjectRef = ^XPLMObjectRef; +{$ENDIF XPLM200} + +{$IFDEF XPLM200} + { + XPLMDrawInfo_t + + The XPLMDrawInfo_t structure contains positioning info for one object that + is to be drawn. Be sure to set structSize to the size of the structure for + future expansion. + } + XPLMDrawInfo_t = RECORD + { Set this to the size of this structure! } + structSize : Integer; + { X location of the object in local coordinates. } + x : Single; + { Y location of the object in local coordinates. } + y : Single; + { Z location of the object in local coordinates. } + z : Single; + { Pitch in degres to rotate the object, positive is up. } + pitch : Single; + { Heading in local coordinates to rotate the object, clockwise. } + heading : Single; + { Roll to rotate the object. } + roll : Single; + END; + PXPLMDrawInfo_t = ^XPLMDrawInfo_t; +{$ENDIF XPLM200} + +{$IFDEF XPLM210} + { + XPLMObjectLoaded_f + + You provide this callback when loading an object asynchronously; it will be + called once the object is loaded. Your refcon is passed back. The object + ref passed in is the newly loaded object (ready for use) or NULL if an + error occured. + + If your plugin is disabled, this callback will be delivered as soon as the + plugin is re-enabled. If your plugin is unloaded before this callback is + ever called, the SDK will release the object handle for you. + } +TYPE + XPLMObjectLoaded_f = PROCEDURE( + inObject : XPLMObjectRef; + inRefcon : pointer); cdecl; +{$ENDIF XPLM210} + +{$IFDEF XPLM200} + { + XPLMLoadObject + + This routine loads an OBJ file and returns a handle to it. If X-Plane has + already loaded the object, the handle to the existing object is returned. + Do not assume you will get the same handle back twice, but do make sure to + call unload once for every load to avoid "leaking" objects. The object will + be purged from memory when no plugins and no scenery are using it. + + The path for the object must be relative to the X-System base folder. If + the path is in the root of the X-System folder you may need to prepend ./ + to it; loading objects in the root of the X-System folder is STRONGLY + discouraged - your plugin should not dump art resources in the root folder! + + XPLMLoadObject will return NULL if the object cannot be loaded (either + because it is not found or the file is misformatted). This routine will + load any object that can be used in the X-Plane scenery system. + + It is important that the datarefs an object uses for animation already be + loaded before you load the object. For this reason it may be necessary to + defer object loading until the sim has fully started. + } + FUNCTION XPLMLoadObject( + inPath : XPLMString) : XPLMObjectRef; + cdecl; external XPLM_DLL; +{$ENDIF XPLM200} + +{$IFDEF XPLM210} + { + XPLMLoadObjectAsync + + This routine loads an object asynchronously; control is returned to you + immediately while X-Plane loads the object. The sim will not stop flying + while the object loads. For large objects, it may be several seconds before + the load finishes. + + You provide a callback function that is called once the load has completed. + Note that if the object cannot be loaded, you will not find out until the + callback function is called with a NULL object handle. + + There is no way to cancel an asynchronous object load; you must wait for + the load to complete and then release the object if it is no longer + desired. + } + PROCEDURE XPLMLoadObjectAsync( + inPath : XPLMString; + inCallback : XPLMObjectLoaded_f; + inRefcon : pointer); + cdecl; external XPLM_DLL; +{$ENDIF XPLM210} + +{$IFDEF XPLM_DEPRECATED} + { + XPLMDrawObjects + + __Deprecation Warning__: use XPLMInstancing to draw 3-d objects by creating + instances, rather than these APIs from draw callbacks. + + XPLMDrawObjects draws an object from an OBJ file one or more times. You + pass in the object and an array of XPLMDrawInfo_t structs, one for each + place you would like the object to be drawn. + + X-Plane will attempt to cull the objects based on LOD and visibility, and + will pick the appropriate LOD. + + Lighting is a boolean; pass 1 to show the night version of object with + night-only lights lit up. Pass 0 to show the daytime version of the object. + + earth_relative controls the coordinate system. If this is 1, the rotations + you specify are applied to the object after its coordinate system is + transformed from local to earth-relative coordinates -- that is, an object + with no rotations will point toward true north and the Y axis will be up + against gravity. If this is 0, the object is drawn with your rotations from + local coordanates -- that is, an object with no rotations is drawn pointing + down the -Z axis and the Y axis of the object matches the local coordinate + Y axis. + } + PROCEDURE XPLMDrawObjects( + inObject : XPLMObjectRef; + inCount : Integer; + inLocations : PXPLMDrawInfo_t; + lighting : Integer; + earth_relative : Integer); + cdecl; external XPLM_DLL; +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM200} + { + XPLMUnloadObject + + This routine marks an object as no longer being used by your plugin. + Objects are reference counted: once no plugins are using an object, it is + purged from memory. Make sure to call XPLMUnloadObject once for each + successful call to XPLMLoadObject. + } + PROCEDURE XPLMUnloadObject( + inObject : XPLMObjectRef); + cdecl; external XPLM_DLL; +{$ENDIF XPLM200} + +{$IFDEF XPLM200} +{___________________________________________________________________________ + * Library Access + ___________________________________________________________________________} +{ + The library access routines allow you to locate scenery objects via the + X-Plane library system. Right now library access is only provided for + objects, allowing plugin-drawn objects to be extended using the library + system. +} + + + { + XPLMLibraryEnumerator_f + + An XPLMLibraryEnumerator_f is a callback you provide that is called once + for each library element that is located. The returned paths will be + relative to the X-System folder. + } +TYPE + XPLMLibraryEnumerator_f = PROCEDURE( + inFilePath : XPLMString; + inRef : pointer); cdecl; + + { + XPLMLookupObjects + + This routine looks up a virtual path in the library system and returns all + matching elements. You provide a callback - one virtual path may match many + objects in the library. XPLMLookupObjects returns the number of objects + found. + + The latitude and longitude parameters specify the location the object will + be used. The library system allows for scenery packages to only provide + objects to certain local locations. Only objects that are allowed at the + latitude/longitude you provide will be returned. + } + FUNCTION XPLMLookupObjects( + inPath : XPLMString; + inLatitude : Single; + inLongitude : Single; + enumerator : XPLMLibraryEnumerator_f; + ref : pointer) : Integer; + cdecl; external XPLM_DLL; + +{$ENDIF XPLM200} + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/Delphi/XPLM/XPLMUtilities.pas b/XPLPro_Plugin_Source/SDK/Delphi/XPLM/XPLMUtilities.pas new file mode 100644 index 0000000..121e28b --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/Delphi/XPLM/XPLMUtilities.pas @@ -0,0 +1,951 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPLMUtilities; +INTERFACE + +USES + XPLMDefs; + {$A4} +{___________________________________________________________________________ + * FILE UTILITIES + ___________________________________________________________________________} +{ + The XPLMUtilities file APIs provide some basic file and path functions for + use with X-Plane. + + Directory Separators + -------------------- + + The XPLM has two modes it can work in: + + * X-Plane native paths: all paths are UTF8 strings, using the unix forward + slash (/) as the directory separating character. In native path mode, + you use the same path format for all three operating systems. + + * Legacy OS paths: the directroy separator is \ for Windows, : for OS X, + and / for Linux; OS paths are encoded in MacRoman for OS X using legacy + HFS conventions, use the application code page for multi-byte encoding + on Unix using DOS path conventions, and use UTF-8 for Linux. + + While legacy OS paths are the default, we strongly encourage you to opt in + to native paths using the XPLMEnableFeature API. + + * All OS X plugins should enable native paths all of the time; if you do + not do this, you will have to convert all paths back from HFS to Unix + (and deal with MacRoman) - code written using native paths and the C + file APIs "just works" on OS X. + + * For Linux plugins, there is no difference between the two encodings. + + * Windows plugins will need to convert the UTF8 file paths to UTF16 for + use with the "wide" APIs. While it might seem tempting to stick with + legacy OS paths (and just use the "ANSI" Windows APIs), X-Plane is fully + unicode-capable, and will often be installed in paths where the user's + directories have no ACP encoding. + + Full and Relative Paths + ----------------------- + + Some of these APIs use full paths, but others use paths relative to the + user's X-Plane installation. This is documented on a per-API basis. +} + + +{$IFDEF XPLM200} + { + XPLMDataFileType + + These enums define types of data files you can load or unload using the + SDK. + } +TYPE + XPLMDataFileType = ( + { A situation (.sit) file, which starts off a flight in a given } + { configuration. } + xplm_DataFile_Situation = 1 + + { A situation movie (.smo) file, which replays a past flight. } + ,xplm_DataFile_ReplayMovie = 2 + + ); + PXPLMDataFileType = ^XPLMDataFileType; +{$ENDIF XPLM200} + + { + XPLMGetSystemPath + + This function returns the full path to the X-System folder. Note that this + is a directory path, so it ends in a trailing : or /. + + The buffer you pass should be at least 512 characters long. The path is + returned using the current native or OS path conventions. + } + PROCEDURE XPLMGetSystemPath( + outSystemPath : XPLMString); + cdecl; external XPLM_DLL; + + { + XPLMGetPrefsPath + + This routine returns a full path to a file that is within X-Plane's + preferences directory. (You should remove the file name back to the last + directory separator to get the preferences directory using + XPLMExtractFileAndPath.) + + The buffer you pass should be at least 512 characters long. The path is + returned using the current native or OS path conventions. + } + PROCEDURE XPLMGetPrefsPath( + outPrefsPath : XPLMString); + cdecl; external XPLM_DLL; + + { + XPLMGetDirectorySeparator + + This routine returns a string with one char and a null terminator that is + the directory separator for the current platform. This allows you to write + code that concatinates directory paths without having to #ifdef for + platform. The character returned will reflect the current file path mode. + } + FUNCTION XPLMGetDirectorySeparator: XPLMString; + cdecl; external XPLM_DLL; + + { + XPLMExtractFileAndPath + + Given a full path to a file, this routine separates the path from the file. + If the path is a partial directory (e.g. ends in : or \) the trailing + directory separator is removed. This routine works in-place; a pointer to + the file part of the buffer is returned; the original buffer still starts + with the path and is null terminated with no trailing separator. + } + FUNCTION XPLMExtractFileAndPath( + inFullPath : XPLMString) : XPLMString; + cdecl; external XPLM_DLL; + + { + XPLMGetDirectoryContents + + This routine returns a list of files in a directory (specified by a full + path, no trailing : or \). The output is returned as a list of NULL + terminated strings. An index array (if specified) is filled with pointers + into the strings. The last file is indicated by a zero-length string (and + NULL in the indices). This routine will return 1 if you had capacity for + all files or 0 if you did not. You can also skip a given number of files. + + * inDirectoryPath - a null terminated C string containing the full path to + the directory with no trailing directory char. + + * inFirstReturn - the zero-based index of the first file in the directory + to return. (Usually zero to fetch all in one pass.) + + * outFileNames - a buffer to receive a series of sequential null + terminated C-string file names. A zero-length C string will be appended + to the very end. + + * inFileNameBufSize - the size of the file name buffer in bytes. + + * outIndices - a pointer to an array of character pointers that will + become an index into the directory. The last file will be followed by a + NULL value. Pass NULL if you do not want indexing information. + + * inIndexCount - the max size of the index in entries. + + * outTotalFiles - if not NULL, this is filled in with the number of files + in the directory. + + * outReturnedFiles - if not NULL, the number of files returned by this + iteration. + + Return value: 1 if all info could be returned, 0 if there was a buffer + overrun. + + WARNING: Before X-Plane 7 this routine did not properly iterate through + directories. If X-Plane + 6 compatibility is needed, use your own code to iterate directories. + } + FUNCTION XPLMGetDirectoryContents( + inDirectoryPath : XPLMString; + inFirstReturn : Integer; + outFileNames : XPLMString; + inFileNameBufSize : Integer; + outIndices : PXPLMString; { Can be nil } + inIndexCount : Integer; + outTotalFiles : PInteger; { Can be nil } + outReturnedFiles : PInteger) : Integer; { Can be nil } + cdecl; external XPLM_DLL; + +{$IFDEF XPLM200} + { + XPLMLoadDataFile + + Loads a data file of a given type. Paths must be relative to the X-System + folder. To clear the replay, pass a NULL file name (this is only valid with + replay movies, not sit files). + } + FUNCTION XPLMLoadDataFile( + inFileType : XPLMDataFileType; + inFilePath : XPLMString) : Integer; { Can be nil } + cdecl; external XPLM_DLL; +{$ENDIF XPLM200} + +{$IFDEF XPLM200} + { + XPLMSaveDataFile + + Saves the current situation or replay; paths are relative to the X-System + folder. + } + FUNCTION XPLMSaveDataFile( + inFileType : XPLMDataFileType; + inFilePath : XPLMString) : Integer; + cdecl; external XPLM_DLL; +{$ENDIF XPLM200} + +{___________________________________________________________________________ + * X-PLANE MISC + ___________________________________________________________________________} + + { + XPLMHostApplicationID + + While the plug-in SDK is only accessible to plugins running inside X-Plane, + the original authors considered extending the API to other applications + that shared basic infrastructure with X-Plane. These enumerations are + hold-overs from that original roadmap; all values other than X-Plane are + deprecated. Your plugin should never need this enumeration. + } +TYPE + XPLMHostApplicationID = ( + xplm_Host_Unknown = 0 + + ,xplm_Host_XPlane = 1 + +{$IFDEF XPLM_DEPRECATED} + ,xplm_Host_PlaneMaker = 2 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + ,xplm_Host_WorldMaker = 3 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + ,xplm_Host_Briefer = 4 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + ,xplm_Host_PartMaker = 5 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + ,xplm_Host_YoungsMod = 6 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + ,xplm_Host_XAuto = 7 +{$ENDIF XPLM_DEPRECATED} + + ); + PXPLMHostApplicationID = ^XPLMHostApplicationID; + + { + XPLMLanguageCode + + These enums define what language the sim is running in. These enumerations + do not imply that the sim can or does run in all of these languages; they + simply provide a known encoding in the event that a given sim version is + localized to a certain language. + } + XPLMLanguageCode = ( + xplm_Language_Unknown = 0 + + ,xplm_Language_English = 1 + + ,xplm_Language_French = 2 + + ,xplm_Language_German = 3 + + ,xplm_Language_Italian = 4 + + ,xplm_Language_Spanish = 5 + + ,xplm_Language_Korean = 6 + +{$IFDEF XPLM200} + ,xplm_Language_Russian = 7 +{$ENDIF XPLM200} + +{$IFDEF XPLM200} + ,xplm_Language_Greek = 8 +{$ENDIF XPLM200} + +{$IFDEF XPLM200} + ,xplm_Language_Japanese = 9 +{$ENDIF XPLM200} + +{$IFDEF XPLM300} + ,xplm_Language_Chinese = 10 +{$ENDIF XPLM300} + + ); + PXPLMLanguageCode = ^XPLMLanguageCode; + +{$IFDEF XPLM200} + { + XPLMError_f + + An XPLM error callback is a function that you provide to receive debugging + information from the plugin SDK. See XPLMSetErrorCallback for more + information. NOTE: for the sake of debugging, your error callback will be + called even if your plugin is not enabled, allowing you to receive debug + info in your XPluginStart and XPluginStop callbacks. To avoid causing logic + errors in the management code, do not call any other plugin routines from + your error callback - it is only meant for catching errors in the + debugging. + } +TYPE + XPLMError_f = PROCEDURE( + inMessage : XPLMString); cdecl; +{$ENDIF XPLM200} + +{$IFDEF XPLM_DEPRECATED} + { + XPLMInitialized + + Deprecated: This function returns 1 if X-Plane has properly initialized the + plug-in system. If this routine returns 0, many XPLM functions will not + work. + + NOTE: because plugins are always called from within the XPLM, there is no + need to check for initialization; it will always return 1. This routine is + deprecated - you do not need to check it before continuing within your + plugin. + } + FUNCTION XPLMInitialized: Integer; + cdecl; external XPLM_DLL; +{$ENDIF XPLM_DEPRECATED} + + { + XPLMGetVersions + + This routine returns the revision of both X-Plane and the XPLM DLL. All + versions are three-digit decimal numbers (e.g. 606 for version 6.06 of + X-Plane); the current revision of the XPLM is 200 (2.00). This routine also + returns the host ID of the app running us. + + The most common use of this routine is to special-case around X-Plane + version-specific behavior. + } + PROCEDURE XPLMGetVersions( + outXPlaneVersion : PInteger; + outXPLMVersion : PInteger; + outHostID : PXPLMHostApplicationID); + cdecl; external XPLM_DLL; + + { + XPLMGetLanguage + + This routine returns the langauge the sim is running in. + } + FUNCTION XPLMGetLanguage: XPLMLanguageCode; + cdecl; external XPLM_DLL; + +{$IFDEF XPLM200} + { + XPLMFindSymbol + + This routine will attempt to find the symbol passed in the inString + parameter. If the symbol is found a pointer the function is returned, + othewise the function will return NULL. + + You can use XPLMFindSymbol to utilize newer SDK API features without + requiring newer versions of the SDK (and X-Plane) as your minimum X-Plane + version as follows: + + * Define the XPLMnnn macro to the minimum required XPLM version you will + ship with (e.g. XPLM210 for X-Plane 10 compatibility). + + * Use XPLMGetVersions and XPLMFindSymbol to detect that the host sim is + new enough to use new functions and resolve function pointers. + + * Conditionally use the new functions if and only if XPLMFindSymbol only + returns a non- NULL pointer. + + Warning: you should always check the XPLM API version as well as the + results of XPLMFindSymbol to determine if funtionality is safe to use. + + To use functionality via XPLMFindSymbol you will need to copy your own + definitions of the X-Plane API prototypes and cast the returned pointer to + the correct type. + } + FUNCTION XPLMFindSymbol( + inString : XPLMString) : pointer; + cdecl; external XPLM_DLL; +{$ENDIF XPLM200} + +{$IFDEF XPLM200} + { + XPLMSetErrorCallback + + XPLMSetErrorCallback installs an error-reporting callback for your plugin. + Normally the plugin system performs minimum diagnostics to maximize + performance. When you install an error callback, you will receive calls due + to certain plugin errors, such as passing bad parameters or incorrect data. + + Important: the error callback determines *programming* errors, e.g. bad API + parameters. Every error that is returned by the error callback represents a + mistake in your plugin that you should fix. Error callbacks are not used to + report expected run-time problems (e.g. disk I/O errors). + + The intention is for you to install the error callback during debug + sections and put a break-point inside your callback. This will cause you to + break into the debugger from within the SDK at the point in your plugin + where you made an illegal call. + + Installing an error callback may activate error checking code that would + not normally run, and this may adversely affect performance, so do not + leave error callbacks installed in shipping plugins. Since the only useful + response to an error is to change code, error callbacks are not useful "in + the field". + } + PROCEDURE XPLMSetErrorCallback( + inCallback : XPLMError_f); + cdecl; external XPLM_DLL; +{$ENDIF XPLM200} + + { + XPLMDebugString + + This routine outputs a C-style string to the Log.txt file. The file is + immediately flushed so you will not lose data. (This does cause a + performance penalty.) + + Please do *not* leave routine diagnostic logging enabled in your shipping + plugin. The X-Plane Log file is shared by X-Plane and every plugin in the + system, and plugins that (when functioning normally) print verbose log + output make it difficult for developers to find error conditions from other + parts of the system. + } + PROCEDURE XPLMDebugString( + inString : XPLMString); + cdecl; external XPLM_DLL; + + { + XPLMSpeakString + + This function displays the string in a translucent overlay over the current + display and also speaks the string if text-to-speech is enabled. The string + is spoken asynchronously, this function returns immediately. This function + may not speak or print depending on user preferences. + } + PROCEDURE XPLMSpeakString( + inString : XPLMString); + cdecl; external XPLM_DLL; + + { + XPLMGetVirtualKeyDescription + + Given a virtual key code (as defined in XPLMDefs.h) this routine returns a + human-readable string describing the character. This routine is provided + for showing users what keyboard mappings they have set up. The string may + read 'unknown' or be a blank or NULL string if the virtual key is unknown. + } + FUNCTION XPLMGetVirtualKeyDescription( + inVirtualKey : XPLMChar) : XPLMString; + cdecl; external XPLM_DLL; + + { + XPLMReloadScenery + + XPLMReloadScenery reloads the current set of scenery. You can use this + function in two typical ways: simply call it to reload the scenery, picking + up any new installed scenery, .env files, etc. from disk. Or, change the + lat/ref and lon/ref data refs and then call this function to shift the + scenery environment. This routine is equivalent to picking "reload + scenery" from the developer menu. + } + PROCEDURE XPLMReloadScenery; + cdecl; external XPLM_DLL; + +{$IFDEF XPLM200} +{___________________________________________________________________________ + * X-PLANE COMMAND MANAGEMENT + ___________________________________________________________________________} +{ + The command management APIs let plugins interact with the command-system in + X-Plane, the abstraction behind keyboard presses and joystick buttons. This + API lets you create new commands and modify the behavior (or get + notification) of existing ones. + + X-Plane Command Phases + ---------------------- + + X-Plane commands are not instantaneous; they operate over a duration. + (Think of a joystick button press - you can press, hold down, and then + release the joystick button; X-Plane commands model this entire process.) + + An X-Plane command consists of three phases: a beginning, continuous + repetition, and an ending. The command may be repeated zero times in its + duration, followed by one command ending. Command begin and end messges are + balanced, but a command may be bound to more than one event source (e.g. a + keyboard key and a joystick button), in which case you may receive a second + begin during before any end). + + When you issue commands in the plugin system, you *must* balance every call + to XPLMCommandBegin with a call to XPLMCommandEnd with the same command + reference. + + Command Behavior Modification + ----------------------------- + + You can register a callback to handle a command either before or after + X-Plane does; if you receive the command before X-Plane you have the option + to either let X-Plane handle the command or hide the command from X-Plane. + This lets plugins both augment commands and replace them. + + If you register for an existing command, be sure that you are *consistent* + in letting X-Plane handle or not handle the command; you are responsible + for passing a *balanced* number of begin and end messages to X-Plane. (E.g. + it is not legal to pass all the begin messages to X-Plane but hide all the + end messages). +} + + + { + XPLMCommandPhase + + The phases of a command. + } +TYPE + XPLMCommandPhase = ( + { The command is being started. } + xplm_CommandBegin = 0 + + { The command is continuing to execute. } + ,xplm_CommandContinue = 1 + + { The command has ended. } + ,xplm_CommandEnd = 2 + + ); + PXPLMCommandPhase = ^XPLMCommandPhase; + + { + XPLMCommandRef + + A command ref is an opaque identifier for an X-Plane command. Command + references stay the same for the life of your plugin but not between + executions of X-Plane. Command refs are used to execute commands, create + commands, and create callbacks for particular commands. + + Note that a command is not "owned" by a particular plugin. Since many + plugins may participate in a command's execution, the command does not go + away if the plugin that created it is unloaded. + } + XPLMCommandRef = pointer; + PXPLMCommandRef = ^XPLMCommandRef; + + { + XPLMCommandCallback_f + + A command callback is a function in your plugin that is called when a + command is pressed. Your callback receives the command reference for the + particular command, the phase of the command that is executing, and a + reference pointer that you specify when registering the callback. + + Your command handler should return 1 to let processing of the command + continue to other plugins and X-Plane, or 0 to halt processing, potentially + bypassing X-Plane code. + } + XPLMCommandCallback_f = FUNCTION( + inCommand : XPLMCommandRef; + inPhase : XPLMCommandPhase; + inRefcon : pointer) : Integer; cdecl; + + { + XPLMFindCommand + + XPLMFindCommand looks up a command by name, and returns its command + reference or NULL if the command does not exist. + } + FUNCTION XPLMFindCommand( + inName : XPLMString) : XPLMCommandRef; + cdecl; external XPLM_DLL; + + { + XPLMCommandBegin + + XPLMCommandBegin starts the execution of a command, specified by its + command reference. The command is "held down" until XPLMCommandEnd is + called. You must balance each XPLMCommandBegin call with an XPLMCommandEnd + call. + } + PROCEDURE XPLMCommandBegin( + inCommand : XPLMCommandRef); + cdecl; external XPLM_DLL; + + { + XPLMCommandEnd + + XPLMCommandEnd ends the execution of a given command that was started with + XPLMCommandBegin. You must not issue XPLMCommandEnd for a command you did + not begin. + } + PROCEDURE XPLMCommandEnd( + inCommand : XPLMCommandRef); + cdecl; external XPLM_DLL; + + { + XPLMCommandOnce + + This executes a given command momentarily, that is, the command begins and + ends immediately. This is the equivalent of calling XPLMCommandBegin() and + XPLMCommandEnd() back ot back. + } + PROCEDURE XPLMCommandOnce( + inCommand : XPLMCommandRef); + cdecl; external XPLM_DLL; + + { + XPLMCreateCommand + + XPLMCreateCommand creates a new command for a given string. If the command + already exists, the existing command reference is returned. The description + may appear in user interface contexts, such as the joystick configuration + screen. + } + FUNCTION XPLMCreateCommand( + inName : XPLMString; + inDescription : XPLMString) : XPLMCommandRef; + cdecl; external XPLM_DLL; + + { + XPLMRegisterCommandHandler + + XPLMRegisterCommandHandler registers a callback to be called when a command + is executed. You provide a callback with a reference pointer. + + If inBefore is true, your command handler callback will be executed before + X-Plane executes the command, and returning 0 from your callback will + disable X-Plane's processing of the command. If inBefore is false, your + callback will run after X-Plane. (You can register a single callback both + before and after a command.) + } + PROCEDURE XPLMRegisterCommandHandler( + inComand : XPLMCommandRef; + inHandler : XPLMCommandCallback_f; + inBefore : Integer; + inRefcon : pointer); + cdecl; external XPLM_DLL; + + { + XPLMUnregisterCommandHandler + + XPLMUnregisterCommandHandler removes a command callback registered with + XPLMRegisterCommandHandler. + } + PROCEDURE XPLMUnregisterCommandHandler( + inComand : XPLMCommandRef; + inHandler : XPLMCommandCallback_f; + inBefore : Integer; + inRefcon : pointer); + cdecl; external XPLM_DLL; + +{$ENDIF XPLM200} +{$IFDEF XPLM_DEPRECATED} +{___________________________________________________________________________ + * X-PLANE USER INTERACTION + ___________________________________________________________________________} +{ + WARNING: The legacy user interaction API is deprecated; while it was the + only way to run commands in X-Plane 6,7 and 8, it is obsolete, and was + replaced by the command system API in X-Plane 9. You should not use this + API; replace any of the calls below with XPLMCommand invocations based on + persistent command strings. The documentation that follows is for historic + reference only. + + The legacy user interaction APIs let you simulate commands the user can do + with a joystick, keyboard etc. Note that it is generally safer for future + compatibility to use one of these commands than to manipulate the + underlying sim data. +} + + + { + XPLMCommandKeyID + + These enums represent all the keystrokes available within X-Plane. They can + be sent to X-Plane directly. For example, you can reverse thrust using + these enumerations. + } +TYPE + XPLMCommandKeyID = ( + xplm_key_pause=0, + xplm_key_revthrust, + xplm_key_jettison, + xplm_key_brakesreg, + xplm_key_brakesmax, + xplm_key_gear, + xplm_key_timedn, + xplm_key_timeup, + xplm_key_fadec, + xplm_key_otto_dis, + xplm_key_otto_atr, + xplm_key_otto_asi, + xplm_key_otto_hdg, + xplm_key_otto_gps, + xplm_key_otto_lev, + xplm_key_otto_hnav, + xplm_key_otto_alt, + xplm_key_otto_vvi, + xplm_key_otto_vnav, + xplm_key_otto_nav1, + xplm_key_otto_nav2, + xplm_key_targ_dn, + xplm_key_targ_up, + xplm_key_hdgdn, + xplm_key_hdgup, + xplm_key_barodn, + xplm_key_baroup, + xplm_key_obs1dn, + xplm_key_obs1up, + xplm_key_obs2dn, + xplm_key_obs2up, + xplm_key_com1_1, + xplm_key_com1_2, + xplm_key_com1_3, + xplm_key_com1_4, + xplm_key_nav1_1, + xplm_key_nav1_2, + xplm_key_nav1_3, + xplm_key_nav1_4, + xplm_key_com2_1, + xplm_key_com2_2, + xplm_key_com2_3, + xplm_key_com2_4, + xplm_key_nav2_1, + xplm_key_nav2_2, + xplm_key_nav2_3, + xplm_key_nav2_4, + xplm_key_adf_1, + xplm_key_adf_2, + xplm_key_adf_3, + xplm_key_adf_4, + xplm_key_adf_5, + xplm_key_adf_6, + xplm_key_transpon_1, + xplm_key_transpon_2, + xplm_key_transpon_3, + xplm_key_transpon_4, + xplm_key_transpon_5, + xplm_key_transpon_6, + xplm_key_transpon_7, + xplm_key_transpon_8, + xplm_key_flapsup, + xplm_key_flapsdn, + xplm_key_cheatoff, + xplm_key_cheaton, + xplm_key_sbrkoff, + xplm_key_sbrkon, + xplm_key_ailtrimL, + xplm_key_ailtrimR, + xplm_key_rudtrimL, + xplm_key_rudtrimR, + xplm_key_elvtrimD, + xplm_key_elvtrimU, + xplm_key_forward, + xplm_key_down, + xplm_key_left, + xplm_key_right, + xplm_key_back, + xplm_key_tower, + xplm_key_runway, + xplm_key_chase, + xplm_key_free1, + xplm_key_free2, + xplm_key_spot, + xplm_key_fullscrn1, + xplm_key_fullscrn2, + xplm_key_tanspan, + xplm_key_smoke, + xplm_key_map, + xplm_key_zoomin, + xplm_key_zoomout, + xplm_key_cycledump, + xplm_key_replay, + xplm_key_tranID, + xplm_key_max + ); + PXPLMCommandKeyID = ^XPLMCommandKeyID; + + { + XPLMCommandButtonID + + These are enumerations for all of the things you can do with a joystick + button in X-Plane. They currently match the buttons menu in the equipment + setup dialog, but these enums will be stable even if they change in + X-Plane. + } + XPLMCommandButtonID = ( + xplm_joy_nothing=0, + xplm_joy_start_all, + xplm_joy_start_0, + xplm_joy_start_1, + xplm_joy_start_2, + xplm_joy_start_3, + xplm_joy_start_4, + xplm_joy_start_5, + xplm_joy_start_6, + xplm_joy_start_7, + xplm_joy_throt_up, + xplm_joy_throt_dn, + xplm_joy_prop_up, + xplm_joy_prop_dn, + xplm_joy_mixt_up, + xplm_joy_mixt_dn, + xplm_joy_carb_tog, + xplm_joy_carb_on, + xplm_joy_carb_off, + xplm_joy_trev, + xplm_joy_trm_up, + xplm_joy_trm_dn, + xplm_joy_rot_trm_up, + xplm_joy_rot_trm_dn, + xplm_joy_rud_lft, + xplm_joy_rud_cntr, + xplm_joy_rud_rgt, + xplm_joy_ail_lft, + xplm_joy_ail_cntr, + xplm_joy_ail_rgt, + xplm_joy_B_rud_lft, + xplm_joy_B_rud_rgt, + xplm_joy_look_up, + xplm_joy_look_dn, + xplm_joy_look_lft, + xplm_joy_look_rgt, + xplm_joy_glance_l, + xplm_joy_glance_r, + xplm_joy_v_fnh, + xplm_joy_v_fwh, + xplm_joy_v_tra, + xplm_joy_v_twr, + xplm_joy_v_run, + xplm_joy_v_cha, + xplm_joy_v_fr1, + xplm_joy_v_fr2, + xplm_joy_v_spo, + xplm_joy_flapsup, + xplm_joy_flapsdn, + xplm_joy_vctswpfwd, + xplm_joy_vctswpaft, + xplm_joy_gear_tog, + xplm_joy_gear_up, + xplm_joy_gear_down, + xplm_joy_lft_brake, + xplm_joy_rgt_brake, + xplm_joy_brakesREG, + xplm_joy_brakesMAX, + xplm_joy_speedbrake, + xplm_joy_ott_dis, + xplm_joy_ott_atr, + xplm_joy_ott_asi, + xplm_joy_ott_hdg, + xplm_joy_ott_alt, + xplm_joy_ott_vvi, + xplm_joy_tim_start, + xplm_joy_tim_reset, + xplm_joy_ecam_up, + xplm_joy_ecam_dn, + xplm_joy_fadec, + xplm_joy_yaw_damp, + xplm_joy_art_stab, + xplm_joy_chute, + xplm_joy_JATO, + xplm_joy_arrest, + xplm_joy_jettison, + xplm_joy_fuel_dump, + xplm_joy_puffsmoke, + xplm_joy_prerotate, + xplm_joy_UL_prerot, + xplm_joy_UL_collec, + xplm_joy_TOGA, + xplm_joy_shutdown, + xplm_joy_con_atc, + xplm_joy_fail_now, + xplm_joy_pause, + xplm_joy_rock_up, + xplm_joy_rock_dn, + xplm_joy_rock_lft, + xplm_joy_rock_rgt, + xplm_joy_rock_for, + xplm_joy_rock_aft, + xplm_joy_idle_hilo, + xplm_joy_lanlights, + xplm_joy_max + ); + PXPLMCommandButtonID = ^XPLMCommandButtonID; + + { + XPLMSimulateKeyPress + + This function simulates a key being pressed for X-Plane. The keystroke goes + directly to X-Plane; it is never sent to any plug-ins. However, since this + is a raw key stroke it may be mapped by the keys file or enter text into a + field. + + Deprecated: use XPLMCommandOnce + } + PROCEDURE XPLMSimulateKeyPress( + inKeyType : Integer; + inKey : Integer); + cdecl; external XPLM_DLL; + + { + XPLMCommandKeyStroke + + This routine simulates a command-key stroke. However, the keys are done by + function, not by actual letter, so this function works even if the user has + remapped their keyboard. Examples of things you might do with this include + pausing the simulator. + + Deprecated: use XPLMCommandOnce + } + PROCEDURE XPLMCommandKeyStroke( + inKey : XPLMCommandKeyID); + cdecl; external XPLM_DLL; + + { + XPLMCommandButtonPress + + This function simulates any of the actions that might be taken by pressing + a joystick button. However, this lets you call the command directly rather + than have to know which button is mapped where. Important: you must release + each button you press. The APIs are separate so that you can 'hold down' a + button for a fixed amount of time. + + Deprecated: use XPLMCommandBegin. + } + PROCEDURE XPLMCommandButtonPress( + inButton : XPLMCommandButtonID); + cdecl; external XPLM_DLL; + + { + XPLMCommandButtonRelease + + This function simulates any of the actions that might be taken by pressing + a joystick button. See XPLMCommandButtonPress. + + Deprecated: use XPLMCommandEnd. + } + PROCEDURE XPLMCommandButtonRelease( + inButton : XPLMCommandButtonID); + cdecl; external XPLM_DLL; + +{$ENDIF XPLM_DEPRECATED} + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/Libraries/Mac/XPLM.framework/XPLM b/XPLPro_Plugin_Source/SDK/Libraries/Mac/XPLM.framework/XPLM new file mode 100644 index 0000000..3340711 Binary files /dev/null and b/XPLPro_Plugin_Source/SDK/Libraries/Mac/XPLM.framework/XPLM differ diff --git a/XPLPro_Plugin_Source/SDK/Libraries/Mac/XPWidgets.framework/XPWidgets b/XPLPro_Plugin_Source/SDK/Libraries/Mac/XPWidgets.framework/XPWidgets new file mode 100644 index 0000000..20e521a Binary files /dev/null and b/XPLPro_Plugin_Source/SDK/Libraries/Mac/XPWidgets.framework/XPWidgets differ diff --git a/XPLPro_Plugin_Source/SDK/README.txt b/XPLPro_Plugin_Source/SDK/README.txt new file mode 100644 index 0000000..2316eb5 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/README.txt @@ -0,0 +1,197 @@ +------------------------------------------------------------------------------- + THE X-PLANE PLUGIN SDK +------------------------------------------------------------------------------- + +This download contains the files necessary to build plugins for X-Plane. The +X-Plane plugin website is: + +http://www.xsquawkbox.net/xpsdk/ + +The website contains full documentation on the SDK including tech notes, sample +plugins, sample code, contact information, and links to the latest versions of +this SDK. + +The X-Plane SDK authors can be reached at: + +xplanesdk@xsquawkbox.net + +Please do not email Austin or Laminar Research for SDK questions or support; +the SDK is a third party effort. + +the X-Plane developer mailing list is an unlisted yahoo group frequented by +many X-Plane developers. + +x-plane-dev@yahoogroups.com + +------------------------------------------------------------------------------- + SDK FILES +------------------------------------------------------------------------------- + +license.txt Copyright information for this download. +README.txt This document +CHeaders Header files for compiling C/C++ plugins +Delphi Interfaces for compiling Pascal plugins +Libraries Import libraries for linking on Windows + and frameworks for linking on Mac. + +Note: there are no import/link-time libraries for Linux; on Linux, plugins +simply leave SDK symbols undefined and they are discovered at runtime. The +SDK website explains this process in more detail. + +Mac CFM plugins are not supported by the SDK versions 2.0 and higher; the +2.0 SDK requires X-Plane 9.0 or newer, and X-Plane 9 will not run on +Mac OS 9. Therefore CFM plugins are not useful (and are probably +counterproductive since they cannot support x86 code). If you have a CFM +plugin, continue to use the 1.0 SDK to build it. You will have to port to +Mach-O if you want to use 2.0 features. + +------------------------------------------------------------------------------- + RELEASE NOTES +------------------------------------------------------------------------------- + +This section contains per-release notes for the history of the X-Plane SDK. + +X-Plane SDK Release 2.1.3 11/14/13 + +Fixed XPC Wrappers to use int and intptr_t instead of long. This fixes +crashes for plugins on 64-bit Windows. + +X-Plane SDK Release 2.1.2 RC2 1/15/13 + +Removed headers from frameworks, as they don't work; updated README. + +X-Plane SDK Release 2.1.2 RC1 1/12/13 + +The 2.1.2 SDK adds frameworks for the XPLM and XPWidgets; Mac developers +can link directly against these frameworks and avoid unresolved symbols +and flat namespace problems. The frameworks produce plugins that will +work on X-Plane 8, 9, and 10 depending on the plugin CPU architecture, +minimum system SDK, and XPLM API revision number. + +X-Plane SDK Release 2.1.1 RC1 10/29/12 + +The 2.1.1 update to the SDK provides 64-bit build materials. + +X-Plane SDK Release 2.1.0 RC1 3/31/12 + +This is the first release of the version 2.1 X-Plane SDK. This version of the +SDK exposes new APIs. + +This API also replaces all references to "long" with int or intptr_t, +depending on whether the integer needs to be wide enough to hold coerced +pointers. Most of the time, int is used; the notable exception is the widgets +library where params and properties can contain pointers to user data. + +This change is not an ABI change - compiled plugins will work unmodified. +However for some compilers, you may need to replace long with int or intptr_t +in your code. + +X-Plane SDK Release 2.0.1 RC1 7/21/10 + +This release adds symbol visibility macros for GCC 4 on Linux and corrects a few +function documentation comments. + +X-Plane SDK Release 2.0 RC1 7/11/08 + +This release includes a corrected XPLM.lib for windows with exports for some of +the new 2.0 APIs. + +X-Plane SDK Release 2.0 Beta 2 4/23/08 + +This release includes new APIs for reading and writing data files and drawing +hooks for the local map screen, as well as some minor tweaks: + +- Sim version is 2.0 in the headers. +- unload plane msg marked as 2.0 only. +- New enumerations for additional languages. +- Function level docs improved. + +X-Plane SDK Release 2.0 Beta 1 1/19/08 + +This is the first release of the version 2.0 X-Plane SDK. CFM support has +been removed, and the license has been simplified, reflecting that it only has +to cover the SDK include/import lib files and not the sample code or examples. + +X-Plane SDK Release 1.0.2 1/5/05 + +The headers of the SDK are modified to support Kylix. No changes for Mac, +Windows, or C users. Headers now have SDK version numbers. + +X-Plane SDK Release 1.0.1 12/29/04 + +The headers of this SDK are modified to support Linux complication. No changes +for Mac and Windows users. + +X-Plane SDK Release Candidate 1 + +Only one slight change in the enums: the enum xpProperty_SubWindowHasCloseBoxes +in XPStandardWidgets.h has been changed to xpProperty_MainWindowHasCloseBoxes. +Its value has not been changed, so you will need to search-and-replace your code +when using this version of the SDK, but already-compiled plugins will experience +no different operation. + +The documentation has been revised for all headers to revise changes made to the +SDK over the course of beta. + +X-Plane SDK Beta 5 + +This version of the SDK features a number of enumeration changes to reflect the +X-Plane interface more correctly. This became crucial when X-Plane 7's new user +interface was released. With X-Plane in release candidates hopefully beta 5 of +the SDK could be the last one. Please see: + +www.xsquawkbox.net/xpsdk/newui.html + +For a comprehensive description of all the enumeration changes. For most +plugins (no developers reported using the deprecated enumerations), a simple +search and replace should suffice. Plugins compiled against the beta 4 SDK that +do not use now-unsupported graphics will continue to work correctly. + +X-Plane SDK Beta 4 + +This release corrects two problems with the Pascal headers: function pointer +types are now declared cdecl (since this is how the SDK calls them), and the +import library for the widget callbacks is now XPWIDGETS.DLL as it should be. + +X-Plane SDK Beta 3 + +This release finally features full documentation and a stable widgets API, as +well as a few other minor bug fixes. + +Starting with beta 3, the DLLs necessary to run plugins ship with X-Plane 660. +The SDK will work with X-Plane 660 RC3 and later. The XPWidgets DLL now lives +in the Resources/plugins folder. + +Starting with beta 3, extra plugins, documentation, sample code, and sample +projects are now featured directly on the web in the new X-Plane SDK library. +They are not included in the SDK zip file; the zip file only contains headers +and lib files for the SDK. + +X-Plane SDK Beta 2 + +You must recompile your plugin for the beta 2 plugin SDK! Plugins compiled +against the beta 1 SDK will not work with X-Plane 660 or the new XPLM.DLL. + +A huge number of data refs have been added. Unfortunately the documentation +is thin. Use the data ref tester plugin to view the data refs in real time +and find what you need. + +The data ref APIs have also changed to allow for arrays of integers as well +as floats. Some sim variables are now arrays that were previously many +individual items. + +A new drawing phase is available for replacing aircraft graphics. The +texturing APIs in XPLMGraphics have been revised. The most notable change is +that you cannot use the SDK to load your textures. (This functionality was +broken and never worked in beta 1.) See the x-plane-dev list for sample code +on how to load your own bitmaps. + +X-Plane can reload plugins on the fly. Use the Plugin Enabler plugin to reload +your plugin. On the Mac you can throw the old DLL in the trash and put a new +one in its place to reload a new version of the plugin. On the PC, an alert +comes up; while this alert is up you can swap your plugins' DLL. This allows +you to recompile your plugin without rebooting the sim. + +Delphi Pascal interfaces and sample code are in the SDK. Thanks to Billy +Verreynne for his hard work on this. + diff --git a/XPLPro_Plugin_Source/SDK/SDK/CHeaders/Widgets/XPStandardWidgets.h b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/Widgets/XPStandardWidgets.h new file mode 100644 index 0000000..42d4987 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/Widgets/XPStandardWidgets.h @@ -0,0 +1,556 @@ +#ifndef _XPStandardWidgets_h_ +#define _XPStandardWidgets_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPStandardWidgets + ***************************************************************************/ +/* + * ## THEORY OF OPERATION + * + * The standard widgets are widgets built into the widgets library. While you + * can gain access to the widget function that drives them, you generally use + * them by calling XPCreateWidget and then listening for special messages, + * etc. + * + * The standard widgets often send mesages to themselves when the user + * performs an event; these messages are sent up the widget hierarchy until + * they are handled. So you can add a widget proc directly to a push button + * (for example) to intercept the message when it is clicked, or you can put + * one widget proc on a window for all of the push buttons in the window. Most + * of these messages contain the original widget ID as a parameter so you can + * know which widget is messaging no matter who it is sent to. + * + */ + +#include "XPWidgetDefs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*************************************************************************** + * MAIN WINDOW + ***************************************************************************/ +/* + * The main window widget class provides a "window" as the user knows it. + * These windows are dragable and can be selected. Use them to create floating + * windows and non-modal dialogs. + * + */ + + +#define xpWidgetClass_MainWindow 1 + +/* + * Main Window Type Values + * + * These type values are used to control the appearance of a main window. + * + */ +enum { + /* The standard main window; pin stripes on XP7, metal frame on XP 6. */ + xpMainWindowStyle_MainWindow = 0, + + /* A translucent dark gray window, like the one ATC messages appear in. */ + xpMainWindowStyle_Translucent = 1, + + +}; + +/* + * Main Window Properties + * + */ +enum { + /* This property specifies the type of window. Set to one of the main window * + * types above. */ + xpProperty_MainWindowType = 1100, + + /* This property specifies whether the main window has close boxes in its * + * corners. */ + xpProperty_MainWindowHasCloseBoxes = 1200, + + +}; + +/* + * MainWindow Messages + * + */ +enum { + /* This message is sent when the close buttons are pressed for your window. */ + xpMessage_CloseButtonPushed = 1200, + + +}; + +/*************************************************************************** + * SUB WINDOW + ***************************************************************************/ +/* + * X-Plane dialogs are divided into separate areas; the sub window widgets + * allow you to make these areas. Create one main window and place several + * subwindows inside it. Then place your controls inside the subwindows. + * + */ + + +#define xpWidgetClass_SubWindow 2 + +/* + * SubWindow Type Values + * + * These values control the appearance of the subwindow. + * + */ +enum { + /* A panel that sits inside a main window. */ + xpSubWindowStyle_SubWindow = 0, + + /* A screen that sits inside a panel for showing text information. */ + xpSubWindowStyle_Screen = 2, + + /* A list view for scrolling lists. */ + xpSubWindowStyle_ListView = 3, + + +}; + +/* + * SubWindow Properties + * + */ +enum { + /* This property specifies the type of window. Set to one of the subwindow * + * types above. */ + xpProperty_SubWindowType = 1200, + + +}; + +/*************************************************************************** + * BUTTON + ***************************************************************************/ +/* + * The button class provides a number of different button styles and + * behaviors, including push buttons, radio buttons, check boxes, etc. The + * button label appears on or next to the button depending on the button's + * appearance, or type. + * + * The button's behavior is a separate property that dictates who it hilights + * and what kinds of messages it sends. Since behavior and type are different, + * you can do strange things like make check boxes that act as push buttons or + * push buttons with radio button behavior. + * + * In X-Plane 6 there were no check box graphics. The result is the following + * behavior: in X-Plane + * 6 all check box and radio buttons are round (radio-button style) buttons; + * in X-Plane 7 they are all square (check-box style) buttons. In a future + * version of X-Plane, the xpButtonBehavior enums will provide the correct + * graphic (check box or radio button) giving the expected result. + * + */ + + +#define xpWidgetClass_Button 3 + +/* + * Button Types + * + * These define the visual appearance of buttons but not how they respond to + * the mouse. + * + */ +enum { + /* This is a standard push button, like an 'OK' or 'Cancel' button in a dialog* + * box. */ + xpPushButton = 0, + + /* A check box or radio button. Use this and the button behaviors below to * + * get the desired behavior. */ + xpRadioButton = 1, + + /* A window close box. */ + xpWindowCloseBox = 3, + + /* A small down arrow. */ + xpLittleDownArrow = 5, + + /* A small up arrow. */ + xpLittleUpArrow = 6, + + +}; + +/* + * Button Behavior Values + * + * These define how the button responds to mouse clicks. + * + */ +enum { + /* Standard push button behavior. The button hilites while the mouse is * + * clicked over it and unhilites when the mouse is moved outside of it or * + * released. If the mouse is released over the button, the * + * xpMsg_PushButtonPressed message is sent. */ + xpButtonBehaviorPushButton = 0, + + /* Check box behavior. The button immediately toggles its value when the mouse* + * is clicked and sends out a xpMsg_ButtonStateChanged message. */ + xpButtonBehaviorCheckBox = 1, + + /* Radio button behavior. The button immediately sets its state to one and * + * sends out a xpMsg_ButtonStateChanged message if it was not already set to * + * one. You must turn off other radio buttons in a group in your code. */ + xpButtonBehaviorRadioButton = 2, + + +}; + +/* + * Button Properties + * + */ +enum { + /* This property sets the visual type of button. Use one of the button types * + * above. */ + xpProperty_ButtonType = 1300, + + /* This property sets the button's behavior. Use one of the button behaviors * + * above. */ + xpProperty_ButtonBehavior = 1301, + + /* This property tells whether a check box or radio button is "checked" or * + * not. Not used for push buttons. */ + xpProperty_ButtonState = 1302, + + +}; + +/* + * Button Messages + * + * These messages are sent by the button to itself and then up the widget + * chain when the button is clicked. (You may intercept them by providing a + * widget handler for the button itself or by providing a handler in a parent + * widget.) + * + */ +enum { + /* This message is sent when the user completes a click and release in a * + * button with push button behavior. Parameter one of the message is the * + * widget ID of the button. This message is dispatched up the widget * + * hierarchy. */ + xpMsg_PushButtonPressed = 1300, + + /* This message is sent when a button is clicked that has radio button or * + * check box behavior and its value changes. (Note that if the value changes * + * by setting a property you do not receive this message!) Parameter one is * + * the widget ID of the button, parameter 2 is the new state value, either * + * zero or one. This message is dispatched up the widget hierarchy. */ + xpMsg_ButtonStateChanged = 1301, + + +}; + +/*************************************************************************** + * TEXT FIELD + ***************************************************************************/ +/* + * The text field widget provides an editable text field including mouse + * selection and keyboard navigation. The contents of the text field are its + * descriptor. (The descriptor changes as the user types.) + * + * The text field can have a number of types, that effect the visual layout of + * the text field. The text field sends messages to itself so you may control + * its behavior. + * + * If you need to filter keystrokes, add a new handler and intercept the key + * press message. Since key presses are passed by pointer, you can modify the + * keystroke and pass it through to the text field widget. + * + * WARNING: in X-Plane before 7.10 (including 6.70) null characters could + * crash X-Plane. To prevent this, wrap this object with a filter function + * (more instructions can be found on the SDK website). + * + */ + + +#define xpWidgetClass_TextField 4 + +/* + * Text Field Type Values + * + * These control the look of the text field. + * + */ +enum { + /* A field for text entry. */ + xpTextEntryField = 0, + + /* A transparent text field. The user can type and the text is drawn, but no * + * background is drawn. You can draw your own background by adding a widget * + * handler and prehandling the draw message. */ + xpTextTransparent = 3, + + /* A translucent edit field, dark gray. */ + xpTextTranslucent = 4, + + +}; + +/* + * Text Field Properties + * + */ +enum { + /* This is the character position the selection starts at, zero based. If it * + * is the same as the end insertion point, the insertion point is not a * + * selection. */ + xpProperty_EditFieldSelStart = 1400, + + /* This is the character position of the end of the selection. */ + xpProperty_EditFieldSelEnd = 1401, + + /* This is the character position a drag was started at if the user is * + * dragging to select text, or -1 if a drag is not in progress. */ + xpProperty_EditFieldSelDragStart = 1402, + + /* This is the type of text field to display, from the above list. */ + xpProperty_TextFieldType = 1403, + + /* Set this property to 1 to password protect the field. Characters will be * + * drawn as *s even though the descriptor will contain plain-text. */ + xpProperty_PasswordMode = 1404, + + /* The max number of characters you can enter, if limited. Zero means * + * unlimited. */ + xpProperty_MaxCharacters = 1405, + + /* The first visible character on the left. This effectively scrolls the text* + * field. */ + xpProperty_ScrollPosition = 1406, + + /* The font to draw the field's text with. (An XPLMFontID.) */ + xpProperty_Font = 1407, + + /* This is the active side of the insert selection. (Internal) */ + xpProperty_ActiveEditSide = 1408, + + +}; + +/* + * Text Field Messages + * + */ +enum { + /* The text field sends this message to itself when its text changes. It sends* + * the message up the call chain; param1 is the text field's widget ID. */ + xpMsg_TextFieldChanged = 1400, + + +}; + +/*************************************************************************** + * SCROLL BAR + ***************************************************************************/ +/* + * A standard scroll bar or slider control. The scroll bar has a minimum, + * maximum and current value that is updated when the user drags it. The + * scroll bar sends continuous messages as it is dragged. + * + */ + + +#define xpWidgetClass_ScrollBar 5 + +/* + * Scroll Bar Type Values + * + * This defines how the scroll bar looks. + * + */ +enum { + /* A standard X-Plane scroll bar (with arrows on the ends). */ + xpScrollBarTypeScrollBar = 0, + + /* A slider, no arrows. */ + xpScrollBarTypeSlider = 1, + + +}; + +/* + * Scroll Bar Properties + * + */ +enum { + /* The current position of the thumb (in between the min and max, inclusive) */ + xpProperty_ScrollBarSliderPosition = 1500, + + /* The value the scroll bar has when the thumb is in the lowest position. */ + xpProperty_ScrollBarMin = 1501, + + /* The value the scroll bar has when the thumb is in the highest position. */ + xpProperty_ScrollBarMax = 1502, + + /* How many units to move the scroll bar when clicking next to the thumb. The * + * scroll bar always moves one unit when the arrows are clicked. */ + xpProperty_ScrollBarPageAmount = 1503, + + /* The type of scrollbar from the enums above. */ + xpProperty_ScrollBarType = 1504, + + /* Used internally. */ + xpProperty_ScrollBarSlop = 1505, + + +}; + +/* + * Scroll Bar Messages + * + */ +enum { + /* The scroll bar sends this message when the slider position changes. It * + * sends the message up the call chain; param1 is the Scroll Bar widget ID. */ + xpMsg_ScrollBarSliderPositionChanged = 1500, + + +}; + +/*************************************************************************** + * CAPTION + ***************************************************************************/ +/* + * A caption is a simple widget that shows its descriptor as a string, useful + * for labeling parts of a window. It always shows its descriptor as its + * string and is otherwise transparent. + * + */ + + +#define xpWidgetClass_Caption 6 + +/* + * Caption Properties + * + */ +enum { + /* This property specifies whether the caption is lit; use lit captions * + * against screens. */ + xpProperty_CaptionLit = 1600, + + +}; + +/*************************************************************************** + * GENERAL GRAPHICS + ***************************************************************************/ +/* + * The general graphics widget can show one of many icons available from + * X-Plane. + * + */ + + +#define xpWidgetClass_GeneralGraphics 7 + +/* + * General Graphics Types Values + * + * These define the icon for the general graphics. + * + */ +enum { + xpShip = 4, + + xpILSGlideScope = 5, + + xpMarkerLeft = 6, + + xp_Airport = 7, + + xpNDB = 8, + + xpVOR = 9, + + xpRadioTower = 10, + + xpAircraftCarrier = 11, + + xpFire = 12, + + xpMarkerRight = 13, + + xpCustomObject = 14, + + xpCoolingTower = 15, + + xpSmokeStack = 16, + + xpBuilding = 17, + + xpPowerLine = 18, + + xpVORWithCompassRose = 19, + + xpOilPlatform = 21, + + xpOilPlatformSmall = 22, + + xpWayPoint = 23, + + +}; + +/* + * General Graphics Properties + * + */ +enum { + /* This property controls the type of icon that is drawn. */ + xpProperty_GeneralGraphicsType = 1700, + + +}; + +/*************************************************************************** + * PROGRESS INDICATOR + ***************************************************************************/ +/* + * This widget implements a progress indicator as seen when X-Plane starts up. + * + */ + +#define xpWidgetClass_Progress 8 + +/* + * Progress Indicator Properties + * + */ +enum { + /* This is the current value of the progress indicator. */ + xpProperty_ProgressPosition = 1800, + + /* This is the minimum value, equivalent to 0% filled. */ + xpProperty_ProgressMin = 1801, + + /* This is the maximum value, equivalent to 100% filled. */ + xpProperty_ProgressMax = 1802, + + +}; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/SDK/CHeaders/Widgets/XPUIGraphics.h b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/Widgets/XPUIGraphics.h new file mode 100644 index 0000000..b70e0f6 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/Widgets/XPUIGraphics.h @@ -0,0 +1,354 @@ +#ifndef _XPUIGraphics_h_ +#define _XPUIGraphics_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPUIGraphics + ***************************************************************************/ + +#include "XPWidgetDefs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*************************************************************************** + * UI GRAPHICS + ***************************************************************************/ + +/* + * XPWindowStyle + * + * There are a few built-in window styles in X-Plane that you can use. + * + * Note that X-Plane 6 does not offer real shadow-compositing; you must make + * sure to put a window on top of another window of the right style to the + * shadows work, etc. This applies to elements with insets and shadows. The + * rules are: + * + * Sub windows must go on top of main windows, and screens and list views on + * top of subwindows. Only help and main windows can be over the main screen. + * + * With X-Plane 7 any window or element may be placed over any other element. + * + * Some windows are scaled by stretching, some by repeating. The drawing + * routines know which scaling method to use. The list view cannot be rescaled + * in X-Plane 6 because it has both a repeating pattern and a gradient in one + * element. All other elements can be rescaled. + * + */ +enum { + /* An LCD screen that shows help. */ + xpWindow_Help = 0, + + /* A dialog box window. */ + xpWindow_MainWindow = 1, + + /* A panel or frame within a dialog box window. */ + xpWindow_SubWindow = 2, + + /* An LCD screen within a panel to hold text displays. */ + xpWindow_Screen = 4, + + /* A list view within a panel for scrolling file names, etc. */ + xpWindow_ListView = 5, + + +}; +typedef int XPWindowStyle; + +/* + * XPDrawWindow + * + * This routine draws a window of the given dimensions at the given offset on + * the virtual screen in a given style. The window is automatically scaled as + * appropriate using a bitmap scaling technique (scaling or repeating) as + * appropriate to the style. + * + */ +WIDGET_API void XPDrawWindow( + int inX1, + int inY1, + int inX2, + int inY2, + XPWindowStyle inStyle); + +/* + * XPGetWindowDefaultDimensions + * + * This routine returns the default dimensions for a window. Output is either + * a minimum or fixed value depending on whether the window is scalable. + * + */ +WIDGET_API void XPGetWindowDefaultDimensions( + XPWindowStyle inStyle, + int * outWidth, /* Can be NULL */ + int * outHeight); /* Can be NULL */ + +/* + * XPElementStyle + * + * Elements are individually drawable UI things like push buttons, etc. The + * style defines what kind of element you are drawing. Elements can be + * stretched in one or two dimensions (depending on the element). Some + * elements can be lit. + * + * In X-Plane 6 some elements must be drawn over metal. Some are scalable and + * some are not. Any element can be drawn anywhere in X-Plane 7. + * + * Scalable Axis Required Background + * + */ +enum { + /* x metal */ + xpElement_TextField = 6, + + /* none metal */ + xpElement_CheckBox = 9, + + /* none metal */ + xpElement_CheckBoxLit = 10, + + /* none window header */ + xpElement_WindowCloseBox = 14, + + /* none window header */ + xpElement_WindowCloseBoxPressed = 15, + + /* x metal */ + xpElement_PushButton = 16, + + /* x metal */ + xpElement_PushButtonLit = 17, + + /* none any */ + xpElement_OilPlatform = 24, + + /* none any */ + xpElement_OilPlatformSmall = 25, + + /* none any */ + xpElement_Ship = 26, + + /* none any */ + xpElement_ILSGlideScope = 27, + + /* none any */ + xpElement_MarkerLeft = 28, + + /* none any */ + xpElement_Airport = 29, + + /* none any */ + xpElement_Waypoint = 30, + + /* none any */ + xpElement_NDB = 31, + + /* none any */ + xpElement_VOR = 32, + + /* none any */ + xpElement_RadioTower = 33, + + /* none any */ + xpElement_AircraftCarrier = 34, + + /* none any */ + xpElement_Fire = 35, + + /* none any */ + xpElement_MarkerRight = 36, + + /* none any */ + xpElement_CustomObject = 37, + + /* none any */ + xpElement_CoolingTower = 38, + + /* none any */ + xpElement_SmokeStack = 39, + + /* none any */ + xpElement_Building = 40, + + /* none any */ + xpElement_PowerLine = 41, + + /* none metal */ + xpElement_CopyButtons = 45, + + /* none metal */ + xpElement_CopyButtonsWithEditingGrid = 46, + + /* x, y metal */ + xpElement_EditingGrid = 47, + + /* THIS CAN PROBABLY BE REMOVED */ + xpElement_ScrollBar = 48, + + /* none any */ + xpElement_VORWithCompassRose = 49, + + /* none metal */ + xpElement_Zoomer = 51, + + /* x, y metal */ + xpElement_TextFieldMiddle = 52, + + /* none metal */ + xpElement_LittleDownArrow = 53, + + /* none metal */ + xpElement_LittleUpArrow = 54, + + /* none metal */ + xpElement_WindowDragBar = 61, + + /* none metal */ + xpElement_WindowDragBarSmooth = 62, + + +}; +typedef int XPElementStyle; + +/* + * XPDrawElement + * + * XPDrawElement draws a given element at an offset on the virtual screen in + * set dimensions. + * *Even* if the element is not scalable, it will be scaled if the width and + * height do not match the preferred dimensions; it'll just look ugly. Pass + * inLit to see the lit version of the element; if the element cannot be lit + * this is ignored. + * + */ +WIDGET_API void XPDrawElement( + int inX1, + int inY1, + int inX2, + int inY2, + XPElementStyle inStyle, + int inLit); + +/* + * XPGetElementDefaultDimensions + * + * This routine returns the recommended or minimum dimensions of a given UI + * element. outCanBeLit tells whether the element has both a lit and unlit + * state. Pass `NULL` to not receive any of these parameters. + * + */ +WIDGET_API void XPGetElementDefaultDimensions( + XPElementStyle inStyle, + int * outWidth, /* Can be NULL */ + int * outHeight, /* Can be NULL */ + int * outCanBeLit); /* Can be NULL */ + +/* + * XPTrackStyle + * + * A track is a UI element that displays a value vertically or horizontally. + * X-Plane has three kinds of tracks: scroll bars, sliders, and progress bars. + * Tracks can be displayed either horizontally or vertically; tracks will + * choose their own layout based on the larger dimension of their dimensions + * (e.g. they know if they are tall or wide). Sliders may be lit or unlit + * (showing the user manipulating them). + * + * - ScrollBar: this is a standard scroll bar with arrows and a thumb to drag. + * - Slider: this is a simple track with a ball in the middle that can be + * slid. + * - Progress: this is a progress indicator showing how a long task is going. + * + */ +enum { + /* not over metal can be lit can be rotated */ + xpTrack_ScrollBar = 0, + + /* over metal can be lit can be rotated */ + xpTrack_Slider = 1, + + /* over metal cannot be lit cannot be rotated */ + xpTrack_Progress = 2, + + +}; +typedef int XPTrackStyle; + +/* + * XPDrawTrack + * + * This routine draws a track. You pass in the track dimensions and size; the + * track picks the optimal orientation for these dimensions. Pass in the + * track's minimum current and maximum values; the indicator will be + * positioned appropriately. You can also specify whether the track is lit or + * not. + * + */ +WIDGET_API void XPDrawTrack( + int inX1, + int inY1, + int inX2, + int inY2, + int inMin, + int inMax, + int inValue, + XPTrackStyle inTrackStyle, + int inLit); + +/* + * XPGetTrackDefaultDimensions + * + * This routine returns a track's default smaller dimension; all tracks are + * scalable in the larger dimension. It also returns whether a track can be + * lit. + * + */ +WIDGET_API void XPGetTrackDefaultDimensions( + XPTrackStyle inStyle, + int * outWidth, + int * outCanBeLit); + +/* + * XPGetTrackMetrics + * + * This routine returns the metrics of a track. If you want to write UI code + * to manipulate a track, this routine helps you know where the mouse + * locations are. For most other elements, the rectangle the element is drawn + * in is enough information. However, the scrollbar drawing routine does some + * automatic placement; this routine lets you know where things ended up. You + * pass almost everything you would pass to the draw routine. You get out the + * orientation, and other useful stuff. + * + * Besides orientation, you get five dimensions for the five parts of a + * scrollbar, which are the down button, down area (area before the thumb), + * the thumb, and the up area and button. For horizontal scrollers, the left + * button decreases; for vertical scrollers, the top button decreases. + * + */ +WIDGET_API void XPGetTrackMetrics( + int inX1, + int inY1, + int inX2, + int inY2, + int inMin, + int inMax, + int inValue, + XPTrackStyle inTrackStyle, + int * outIsVertical, + int * outDownBtnSize, + int * outDownPageSize, + int * outThumbSize, + int * outUpPageSize, + int * outUpBtnSize); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/SDK/CHeaders/Widgets/XPWidgetDefs.h b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/Widgets/XPWidgetDefs.h new file mode 100644 index 0000000..c1b2341 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/Widgets/XPWidgetDefs.h @@ -0,0 +1,472 @@ +#ifndef _XPWidgetDefs_h_ +#define _XPWidgetDefs_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPWidgetDefs + ***************************************************************************/ + +#include "XPLMDefs.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +#if APL + #if XPWIDGETS + #if __GNUC__ >= 4 + #define WIDGET_API __attribute__((visibility("default"))) + #elif __MACH__ + #define WIDGET_API + #else + #define WIDGET_API __declspec(dllexport) + #endif + #else + #define WIDGET_API + #endif +#elif IBM + #if XPWIDGETS + #define WIDGET_API __declspec(dllexport) + #else + #define WIDGET_API __declspec(dllimport) + #endif +#elif LIN + #if XPWIDGETS + #if __GNUC__ >= 4 + #define WIDGET_API __attribute__((visibility("default"))) + #else + #define WIDGET_API + #endif + #else + #define WIDGET_API + #endif +#else +#pragma error "Platform not defined!" +#endif + /*************************************************************************** + * WIDGET DEFINITIONS + ***************************************************************************/ +/* + * A widget is a call-back driven screen entity like a push-button, window, + * text entry field, etc. + * + * Use the widget API to create widgets of various classes. You can nest them + * into trees of widgets to create complex user interfaces. + * + */ + + +/* + * XPWidgetID + * + * A Widget ID is an opaque unique non-zero handle identifying your widget. + * Use 0 to specify "no widget". This type is defined as wide enough to hold a + * pointer. You receive a widget ID when you create a new widget and then use + * that widget ID to further refer to the widget. + * + */ +typedef void * XPWidgetID; + +/* + * XPWidgetPropertyID + * + * Properties are values attached to instances of your widgets. A property is + * identified by a 32-bit ID and its value is the width of a pointer. + * + * Each widget instance may have a property or not have it. When you set a + * property on a widget for the first time, the property is added to the + * widget; it then stays there for the life of the widget. + * + * Some property IDs are predefined by the widget package; you can make up + * your own property IDs as well. + * + */ +enum { + /* A window's refcon is an opaque value used by client code to find other data* + * based on it. */ + xpProperty_Refcon = 0, + + /* These properties are used by the utlities to implement dragging. */ + xpProperty_Dragging = 1, + + xpProperty_DragXOff = 2, + + xpProperty_DragYOff = 3, + + /* Is the widget hilited? (For widgets that support this kind of thing.) */ + xpProperty_Hilited = 4, + + /* Is there a C++ object attached to this widget? */ + xpProperty_Object = 5, + + /* If this property is 1, the widget package will use OpenGL to restrict * + * drawing to the Wiget's exposed rectangle. */ + xpProperty_Clip = 6, + + /* Is this widget enabled (for those that have a disabled state too)? */ + xpProperty_Enabled = 7, + + /* NOTE: Property IDs 1 - 999 are reserved for the widgets library. * + * * + * NOTE: Property IDs 1000 - 9999 are allocated to the standard widget classes* + * provided with the library. * + * * + * Properties 1000 - 1099 are for widget class 0, 1100 - 1199 for widget class* + * 1, etc. */ + xpProperty_UserStart = 10000, + + +}; +typedef int XPWidgetPropertyID; + +/* + * XPMouseState_t + * + * When the mouse is clicked or dragged, a pointer to this structure is passed + * to your widget function. + * + */ +typedef struct { + int x; + int y; + /* Mouse Button number, left = 0 (right button not yet supported. */ + int button; +#if defined(XPLM200) + /* Scroll wheel delta (button in this case would be the wheel axis number). */ + int delta; +#endif /* XPLM200 */ +} XPMouseState_t; + +/* + * XPKeyState_t + * + * When a key is pressed, a pointer to this struct is passed to your widget + * function. + * + */ +typedef struct { + /* The ASCII key that was pressed. WARNING: this may be 0 for some non-ASCII * + * key sequences. */ + char key; + /* The flags. Make sure to check this if you only want key-downs! */ + XPLMKeyFlags flags; + /* The virtual key code for the key */ + char vkey; +} XPKeyState_t; + +/* + * XPWidgetGeometryChange_t + * + * This structure contains the deltas for your widget's geometry when it + * changes. + * + */ +typedef struct { + int dx; + /* +Y = the widget moved up */ + int dy; + int dwidth; + int dheight; +} XPWidgetGeometryChange_t; + +/* + * XPDispatchMode + * + * The dispatching modes describe how the widgets library sends out messages. + * Currently there are three modes: + * + */ +enum { + /* The message will only be sent to the target widget. */ + xpMode_Direct = 0, + + /* The message is sent to the target widget, then up the chain of parents * + * until the message is handled or a parentless widget is reached. */ + xpMode_UpChain = 1, + + /* The message is sent to the target widget and then all of its children * + * recursively depth-first. */ + xpMode_Recursive = 2, + + /* The message is snet just to the target, but goes to every callback, even if* + * it is handled. */ + xpMode_DirectAllCallbacks = 3, + + /* The message is only sent to the very first handler even if it is not * + * accepted. (This is really only useful for some internal widget library * + * functions.) */ + xpMode_Once = 4, + + +}; +typedef int XPDispatchMode; + +/* + * XPWidgetClass + * + * Widget classes define predefined widget types. A widget class basically + * specifies from a library the widget function to be used for the widget. + * Most widgets can be made right from classes. + * + */ +typedef int XPWidgetClass; + +/* An unspecified widget class. Other widget classes are in * + * XPStandardWidgets.h */ +#define xpWidgetClass_None 0 + +/*************************************************************************** + * WIDGET MESSAGES + ***************************************************************************/ + +/* + * XPWidgetMessage + * + * Widgets receive 32-bit messages indicating what action is to be taken or + * notifications of events. The list of messages may be expanded. + * + */ +enum { + /* No message, should not be sent. */ + xpMsg_None = 0, + + /* The create message is sent once per widget that is created with your widget* + * function and once for any widget that has your widget function attached. * + * * + * Dispatching: Direct * + * * + * Param 1: 1 if you are being added as a subclass, 0 if the widget is first * + * being created. */ + xpMsg_Create = 1, + + /* The destroy message is sent once for each message that is destroyed that * + * has your widget function. * + * * + * Dispatching: Direct for all * + * * + * Param 1: 1 if being deleted by a recursive delete to the parent, 0 for * + * explicit deletion. */ + xpMsg_Destroy = 2, + + /* The paint message is sent to your widget to draw itself. The paint message * + * is the bare-bones message; in response you must draw yourself, draw your * + * children, set up clipping and culling, check for visibility, etc. If you * + * don't want to do all of this, ignore the paint message and a draw message * + * (see below) will be sent to you. * + * * + * Dispatching: Direct */ + xpMsg_Paint = 3, + + /* The draw message is sent to your widget when it is time to draw yourself. * + * OpenGL will be set up to draw in 2-d global screen coordinates, but you * + * should use the XPLM to set up OpenGL state. * + * * + * Dispatching: Direct */ + xpMsg_Draw = 4, + + /* The key press message is sent once per key that is pressed. The first * + * parameter is the type of key code (integer or char) and the second is the * + * code itself. By handling this event, you consume the key stroke. * + * * + * Handling this message 'consumes' the keystroke; not handling it passes it * + * to your parent widget. * + * * + * Dispatching: Up Chain * + * * + * Param 1: A pointer to an XPKeyState_t structure with the keystroke. */ + xpMsg_KeyPress = 5, + + /* Keyboard focus is being given to you. By handling this message you accept * + * keyboard focus. The first parameter will be one if a child of yours gave up* + * focus to you, 0 if someone set focus on you explicitly. * + * * + * Handling this message accepts focus; not handling refuses focus. * + * * + * Dispatching: direct * + * * + * Param 1: 1 if you are gaining focus because your child is giving it up, 0 * + * if someone is explicitly giving you focus. */ + xpMsg_KeyTakeFocus = 6, + + /* Keyboard focus is being taken away from you. The first parameter will be * + * one if you are losing focus because another widget is taking it, or 0 if * + * someone called the API to make you lose focus explicitly. * + * * + * Dispatching: Direct * + * * + * Param 1: 1 if focus is being taken by another widget, 0 if code requested * + * to remove focus. */ + xpMsg_KeyLoseFocus = 7, + + /* You receive one mousedown event per click with a mouse-state structure * + * pointed to by parameter 1, by accepting this you eat the click, otherwise * + * your parent gets it. You will not receive drag and mouse up messages if you* + * do not accept the down message. * + * * + * Handling this message consumes the mouse click, not handling it passes it * + * to the next widget. You can act 'transparent' as a window by never handling* + * moues clicks to certain areas. * + * * + * Dispatching: Up chain NOTE: Technically this is direct dispatched, but the * + * widgets library will shop it to each widget until one consumes the click, * + * making it effectively "up chain". * + * * + * Param 1: A pointer to an XPMouseState_t containing the mouse status. */ + xpMsg_MouseDown = 8, + + /* You receive a series of mouse drag messages (typically one per frame in the* + * sim) as the mouse is moved once you have accepted a mouse down message. * + * Parameter one points to a mouse-state structure describing the mouse * + * location. You will continue to receive these until the mouse button is * + * released. You may receive multiple mouse state messages with the same mouse* + * position. You will receive mouse drag events even if the mouse is dragged * + * out of your current or original bounds at the time of the mouse down. * + * * + * Dispatching: Direct * + * * + * Param 1: A pointer to an XPMouseState_t containing the mouse status. */ + xpMsg_MouseDrag = 9, + + /* The mouseup event is sent once when the mouse button is released after a * + * drag or click. You only receive this message if you accept the mouseDown * + * message. Parameter one points to a mouse state structure. * + * * + * Dispatching: Direct * + * * + * Param 1: A pointer to an XPMouseState_t containing the mouse status. */ + xpMsg_MouseUp = 10, + + /* Your geometry or a child's geometry is being changed. * + * * + * Dispatching: Up chain * + * * + * Param 1: The widget ID of the original reshaped target. * + * * + * Param 2: A pointer to a XPWidgetGeometryChange_t struct describing the * + * change. */ + xpMsg_Reshape = 11, + + /* Your exposed area has changed. * + * * + * Dispatching: Direct */ + xpMsg_ExposedChanged = 12, + + /* A child has been added to you. The child's ID is passed in parameter one. * + * * + * Dispatching: Direct * + * * + * Param 1: The Widget ID of the child being added. */ + xpMsg_AcceptChild = 13, + + /* A child has been removed from to you. The child's ID is passed in parameter* + * one. * + * * + * Dispatching: Direct * + * * + * Param 1: The Widget ID of the child being removed. */ + xpMsg_LoseChild = 14, + + /* You now have a new parent, or have no parent. The parent's ID is passed in,* + * or 0 for no parent. * + * * + * Dispatching: Direct * + * * + * Param 1: The Widget ID of your parent */ + xpMsg_AcceptParent = 15, + + /* You or a child has been shown. Note that this does not include you being * + * shown because your parent was shown, you were put in a new parent, your * + * root was shown, etc. * + * * + * Dispatching: Up chain * + * * + * Param 1: The widget ID of the shown widget. */ + xpMsg_Shown = 16, + + /* You have been hidden. See limitations above. * + * * + * Dispatching: Up chain * + * * + * Param 1: The widget ID of the hidden widget. */ + xpMsg_Hidden = 17, + + /* Your descriptor has changed. * + * * + * Dispatching: Direct */ + xpMsg_DescriptorChanged = 18, + + /* A property has changed. Param 1 contains the property ID. * + * * + * Dispatching: Direct * + * * + * Param 1: The Property ID being changed. * + * * + * Param 2: The new property value */ + xpMsg_PropertyChanged = 19, + +#if defined(XPLM200) + /* The mouse wheel has moved. * + * * + * Return 1 to consume the mouse wheel move, or 0 to pass the message to a * + * parent. Dispatching: Up chain * + * * + * Param 1: A pointer to an XPMouseState_t containing the mouse status. */ + xpMsg_MouseWheel = 20, + +#endif /* XPLM200 */ +#if defined(XPLM200) + /* The cursor is over your widget. If you consume this message, change the * + * XPLMCursorStatus value to indicate the desired result, with the same rules * + * as in XPLMDisplay.h. * + * * + * Return 1 to consume this message, 0 to pass it on. * + * * + * Dispatching: Up chain Param 1: A pointer to an XPMouseState_t struct * + * containing the mouse status. * + * * + * Param 2: A pointer to a XPLMCursorStatus - set this to the cursor result * + * you desire. */ + xpMsg_CursorAdjust = 21, + +#endif /* XPLM200 */ + /* NOTE: Message IDs 1000 - 9999 are allocated to the standard widget classes * + * provided with the library with 1000 - 1099 for widget class 0, 1100 - 1199 * + * for widget class 1, etc. Message IDs 10,000 and beyond are for plugin use. */ + xpMsg_UserStart = 10000, + + +}; +typedef int XPWidgetMessage; + +/*************************************************************************** + * WIDGET CALLBACK FUNCTION + ***************************************************************************/ + +/* + * XPWidgetFunc_t + * + * This function defines your custom widget's behavior. It will be called by + * the widgets library to send messages to your widget. The message and widget + * ID are passed in, as well as two ptr-width signed parameters whose meaning + * varies with the message. Return 1 to indicate that you have processed the + * message, 0 to indicate that you have not. For any message that is not + * understood, return 0. + * + */ +typedef int (* XPWidgetFunc_t)( + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/SDK/CHeaders/Widgets/XPWidgetUtils.h b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/Widgets/XPWidgetUtils.h new file mode 100644 index 0000000..ff757f7 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/Widgets/XPWidgetUtils.h @@ -0,0 +1,232 @@ +#ifndef _XPWidgetUtils_h_ +#define _XPWidgetUtils_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPWidgetUtils + ***************************************************************************/ +/* + * ## USAGE NOTES + * + * The XPWidgetUtils library contains useful functions that make writing and + * using widgets less of a pain. + * + * One set of functions are the widget behavior functions. These functions + * each add specific useful behaviors to widgets. They can be used in two + * manners: + * + * 1. You can add a widget behavior function to a widget as a callback proc + * using the XPAddWidgetCallback function. The widget will gain that + * behavior. Remember that the last function you add has highest priority. + * You can use this to change or augment the behavior of an existing + * finished widget. + * 2. You can call a widget function from inside your own widget function. + * This allows you to include useful behaviors in custom-built widgets. A + * number of the standard widgets get their behavior from this library. To + * do this, call the behavior function from your function first. If it + * returns 1, that means it handled the event and you don't need to; simply + * return 1. + * + */ + +#include "XPWidgetDefs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*************************************************************************** + * GENERAL UTILITIES + ***************************************************************************/ + + + +/* + * Convenience accessors + * + * It can be clumsy accessing the variables passed in by pointer to a struct + * for mouse and reshape messages; these accessors let you simply pass in the param + * right from the arguments of your widget proc and get back the value you want. + * + */ +#define MOUSE_X(param) (((XPMouseState_t *) (param))->x) +#define MOUSE_Y(param) (((XPMouseState_t *) (param))->y) + +#define DELTA_X(param) (((XPWidgetGeometryChange_t *) (param))->dx) +#define DELTA_Y(param) (((XPWidgetGeometryChange_t *) (param))->dy) +#define DELTA_W(param) (((XPWidgetGeometryChange_t *) (param))->dwidth) +#define DELTA_H(param) (((XPWidgetGeometryChange_t *) (param))->dheight) + +#define KEY_CHAR(param) (((XPKeyState_t *) (param))->key) +#define KEY_FLAGS(param) (((XPKeyState_t *) (param))->flags) +#define KEY_VKEY(param) (((XPKeyState_t *) (param))->vkey) + +#define IN_RECT(x, y, l, t, r, b) \ + (((x) >= (l)) && ((x) <= (r)) && ((y) >= (b)) && ((y) <= (t))) + +/* + * XPWidgetCreate_t + * + * This structure contains all of the parameters needed to create a wiget. It + * is used with XPUCreateWidgets to create widgets in bulk from an array. All + * parameters correspond to those of XPCreateWidget except for the container + * index. + * + * If the container index is equal to the index of a widget in the array, the + * widget in the array passed to XPUCreateWidgets is used as the parent of + * this widget. Note that if you pass an index greater than your own position + * in the array, the parent you are requesting will not exist yet. + * + * If the container index is NO_PARENT, the parent widget is specified as + * NULL. If the container index is PARAM_PARENT, the widget passed into + * XPUCreateWidgets is used. + * + */ +typedef struct { + int left; + int top; + int right; + int bottom; + int visible; + const char * descriptor; + /* Whether ethis widget is a root wiget */ + int isRoot; + /* The index of the widget to contain within, or a constant */ + int containerIndex; + XPWidgetClass widgetClass; +} XPWidgetCreate_t; + +#define NO_PARENT -1 + +#define PARAM_PARENT -2 + +#define WIDGET_COUNT(x) ((sizeof(x) / sizeof(XPWidgetCreate_t))) + +/* + * XPUCreateWidgets + * + * This function creates a series of widgets from a table (see + * XPCreateWidget_t above). Pass in an array of widget creation structures and + * an array of widget IDs that will receive each widget. + * + * Widget parents are specified by index into the created widget table, + * allowing you to create nested widget structures. You can create multiple + * widget trees in one table. Generally you should create widget trees from + * the top down. + * + * You can also pass in a widget ID that will be used when the widget's parent + * is listed as PARAM_PARENT; this allows you to embed widgets created with + * XPUCreateWidgets in a widget created previously. + * + */ +WIDGET_API void XPUCreateWidgets( + const XPWidgetCreate_t * inWidgetDefs, + int inCount, + XPWidgetID inParamParent, + XPWidgetID * ioWidgets); + +/* + * XPUMoveWidgetBy + * + * Simply moves a widget by an amount, +x = right, +y=up, without resizing the + * widget. + * + */ +WIDGET_API void XPUMoveWidgetBy( + XPWidgetID inWidget, + int inDeltaX, + int inDeltaY); + +/*************************************************************************** + * LAYOUT MANAGERS + ***************************************************************************/ +/* + * The layout managers are widget behavior functions for handling where + * widgets move. Layout managers can be called from a widget function or + * attached to a widget later. + * + */ + + +/* + * XPUFixedLayout + * + * This function causes the widget to maintain its children in fixed position + * relative to itself as it is resized. Use this on the top level 'window' + * widget for your window. + * + */ +WIDGET_API int XPUFixedLayout( + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2); + +/*************************************************************************** + * WIDGET PROC BEHAVIORS + ***************************************************************************/ +/* + * These widget behavior functions add other useful behaviors to widgets. + * These functions cannot be attached to a widget; they must be called from + * your widget function. + * + */ + + +/* + * XPUSelectIfNeeded + * + * This causes the widget to bring its window to the foreground if it is not + * already. inEatClick specifies whether clicks in the background should be + * consumed by bringin the window to the foreground. + * + */ +WIDGET_API int XPUSelectIfNeeded( + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2, + int inEatClick); + +/* + * XPUDefocusKeyboard + * + * This causes a click in the widget to send keyboard focus back to X-Plane. + * This stops editing of any text fields, etc. + * + */ +WIDGET_API int XPUDefocusKeyboard( + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2, + int inEatClick); + +/* + * XPUDragWidget + * + * XPUDragWidget drags the widget in response to mouse clicks. Pass in not + * only the event, but the global coordinates of the drag region, which might + * be a sub-region of your widget (for example, a title bar). + * + */ +WIDGET_API int XPUDragWidget( + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2, + int inLeft, + int inTop, + int inRight, + int inBottom); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/SDK/CHeaders/Widgets/XPWidgets.h b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/Widgets/XPWidgets.h new file mode 100644 index 0000000..f4423e2 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/Widgets/XPWidgets.h @@ -0,0 +1,538 @@ +#ifndef _XPWidgets_h_ +#define _XPWidgets_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPWidgets + ***************************************************************************/ +/* + * ## THEORY OF OPERATION AND NOTES + * + * Widgets are persistent view 'objects' for X-Plane. A widget is an object + * referenced by its opaque handle (widget ID) and the APIs in this file. You + * cannot access the widget's guts directly. Every Widget has the following + * intrinsic data: + * + * - A bounding box defined in global screen coordinates with 0,0 in the + * bottom left and +y = up, +x = right. + * - A visible box, which is the intersection of the bounding box with the + * widget's parents visible box. + * - Zero or one parent widgets. (Always zero if the widget is a root widget. + * - Zero or more child widgets. + * - Whether the widget is a root. Root widgets are the top level plugin + * windows. + * - Whether the widget is visible. + * - A text string descriptor, whose meaning varies from widget to widget. + * - An arbitrary set of 32 bit integral properties defined by 32-bit integral + * keys. This is how specific widgets store specific data. + * - A list of widget callbacks proc that implements the widgets behaviors. + * + * The Widgets library sends messages to widgets to request specific behaviors + * or notify the widget of things. + * + * Widgets may have more than one callback function, in which case messages + * are sent to the most recently added callback function until the message is + * handled. Messages may also be sent to parents or children; see the + * XPWidgetDefs.h header file for the different widget message dispatching + * functions. By adding a callback function to a window you can 'subclass' its + * behavior. + * + * A set of standard widgets are provided that serve common UI purposes. You + * can also customize or implement entirely custom widgets. + * + * Widgets are different than other view hierarchies (most notably Win32, + * which they bear a striking resemblance to) in the following ways: + * + * - Not all behavior can be patched. State that is managed by the XPWidgets + * DLL and not by individual widgets cannot be customized. + * - All coordinates are in global screen coordinates. Coordinates are not + * relative to an enclosing widget, nor are they relative to a display + * window. + * - Widget messages are always dispatched synchronously, and there is no + * concept of scheduling an update or a dirty region. Messages originate + * from X-Plane as the sim cycle goes by. Since X-Plane is constantly + * redrawing, so are widgets; there is no need to mark a part of a widget as + * 'needing redrawing' because redrawing happens frequently whether the + * widget needs it or not. + * - Any widget may be a 'root' widget, causing it to be drawn; there is no + * relationship between widget class and rootness. Root widgets are + * imlemented as XPLMDisply windows. + * + */ + +#include "XPWidgetDefs.h" +#include "XPLMDisplay.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*************************************************************************** + * WIDGET CREATION AND MANAGEMENT + ***************************************************************************/ + +/* + * XPCreateWidget + * + * This function creates a new widget and returns the new widget's ID to you. + * If the widget creation fails for some reason, it returns NULL. Widget + * creation will fail either if you pass a bad class ID or if there is not + * adequate memory. + * + * Input Parameters: + * + * - Top, left, bottom, and right in global screen coordinates defining the + * widget's location on the screen. + * - inVisible is 1 if the widget should be drawn, 0 to start the widget as + * hidden. + * - inDescriptor is a null terminated string that will become the widget's + * descriptor. + * - inIsRoot is 1 if this is going to be a root widget, 0 if it will not be. + * - inContainer is the ID of this widget's container. It must be 0 for a root + * widget. for a non-root widget, pass the widget ID of the widget to place + * this widget within. If this widget is not going to start inside another + * widget, pass 0; this new widget will then just be floating off in space + * (and will not be drawn until it is placed in a widget. + * - inClass is the class of the widget to draw. Use one of the predefined + * class-IDs to create a standard widget. + * + * A note on widget embedding: a widget is only called (and will be drawn, + * etc.) if it is placed within a widget that will be called. Root widgets are + * always called. So it is possible to have whole chains of widgets that are + * simply not called. You can preconstruct widget trees and then place them + * into root widgets later to activate them if you wish. + * + */ +WIDGET_API XPWidgetID XPCreateWidget( + int inLeft, + int inTop, + int inRight, + int inBottom, + int inVisible, + const char * inDescriptor, + int inIsRoot, + XPWidgetID inContainer, + XPWidgetClass inClass); + +/* + * XPCreateCustomWidget + * + * This function is the same as XPCreateWidget except that instead of passing + * a class ID, you pass your widget callback function pointer defining the + * widget. Use this function to define a custom widget. All parameters are the + * same as XPCreateWidget, except that the widget class has been replaced with + * the widget function. + * + */ +WIDGET_API XPWidgetID XPCreateCustomWidget( + int inLeft, + int inTop, + int inRight, + int inBottom, + int inVisible, + const char * inDescriptor, + int inIsRoot, + XPWidgetID inContainer, + XPWidgetFunc_t inCallback); + +/* + * XPDestroyWidget + * + * This class destroys a widget. Pass in the ID of the widget to kill. If you + * pass 1 for inDestroyChilren, the widget's children will be destroyed first, + * then this widget will be destroyed. (Furthermore, the widget's children + * will be destroyed with the inDestroyChildren flag set to 1, so the + * destruction will recurse down the widget tree.) If you pass 0 for this + * flag, the child widgets will simply end up with their parent set to 0. + * + */ +WIDGET_API void XPDestroyWidget( + XPWidgetID inWidget, + int inDestroyChildren); + +/* + * XPSendMessageToWidget + * + * This sends any message to a widget. You should probably not go around + * simulating the predefined messages that the widgets library defines for + * you. You may however define custom messages for your widgets and send them + * with this method. + * + * This method supports several dispatching patterns; see XPDispatchMode for + * more info. The function returns 1 if the message was handled, 0 if it was + * not. + * + * For each widget that receives the message (see the dispatching modes), each + * widget function from the most recently installed to the oldest one receives + * the message in order until it is handled. + * + */ +WIDGET_API int XPSendMessageToWidget( + XPWidgetID inWidget, + XPWidgetMessage inMessage, + XPDispatchMode inMode, + intptr_t inParam1, + intptr_t inParam2); + +/*************************************************************************** + * WIDGET POSITIONING AND VISIBILITY + ***************************************************************************/ + +/* + * XPPlaceWidgetWithin + * + * This function changes which container a widget resides in. You may NOT use + * this function on a root widget! inSubWidget is the widget that will be + * moved. Pass a widget ID in inContainer to make inSubWidget be a child of + * inContainer. It will become the last/closest widget in the container. Pass + * 0 to remove the widget from any container. Any call to this other than + * passing the widget ID of the old parent of the affected widget will cause + * the widget to be removed from its old parent. Placing a widget within its + * own parent simply makes it the last widget. + * + * NOTE: this routine does not reposition the sub widget in global + * coordinates. If the container has layout management code, it will + * reposition the subwidget for you, otherwise you must do it with + * SetWidgetGeometry. + * + */ +WIDGET_API void XPPlaceWidgetWithin( + XPWidgetID inSubWidget, + XPWidgetID inContainer); + +/* + * XPCountChildWidgets + * + * This routine returns the number of widgets another widget contains. + * + */ +WIDGET_API int XPCountChildWidgets( + XPWidgetID inWidget); + +/* + * XPGetNthChildWidget + * + * This routine returns the widget ID of a child widget by index. Indexes are + * 0 based, from 0 to one minus the number of widgets in the parent, + * inclusive. If the index is invalid, 0 is returned. + * + */ +WIDGET_API XPWidgetID XPGetNthChildWidget( + XPWidgetID inWidget, + int inIndex); + +/* + * XPGetParentWidget + * + * Returns the parent of a widget, or 0 if the widget has no parent. Root + * widgets never have parents and therefore always return 0. + * + */ +WIDGET_API XPWidgetID XPGetParentWidget( + XPWidgetID inWidget); + +/* + * XPShowWidget + * + * This routine makes a widget visible if it is not already. Note that if a + * widget is not in a rooted widget hierarchy or one of its parents is not + * visible, it will still not be visible to the user. + * + */ +WIDGET_API void XPShowWidget( + XPWidgetID inWidget); + +/* + * XPHideWidget + * + * Makes a widget invisible. See XPShowWidget for considerations of when a + * widget might not be visible despite its own visibility state. + * + */ +WIDGET_API void XPHideWidget( + XPWidgetID inWidget); + +/* + * XPIsWidgetVisible + * + * This returns 1 if a widget is visible, 0 if it is not. Note that this + * routine takes into consideration whether a parent is invisible. Use this + * routine to tell if the user can see the widget. + * + */ +WIDGET_API int XPIsWidgetVisible( + XPWidgetID inWidget); + +/* + * XPFindRootWidget + * + * Returns the Widget ID of the root widget that contains the passed in widget + * or NULL if the passed in widget is not in a rooted hierarchy. + * + */ +WIDGET_API XPWidgetID XPFindRootWidget( + XPWidgetID inWidget); + +/* + * XPBringRootWidgetToFront + * + * This routine makes the specified widget be in the front most widget + * hierarchy. If this widget is a root widget, its widget hierarchy comes to + * front, otherwise the widget's root is brought to the front. If this widget + * is not in an active widget hiearchy (e.g. there is no root widget at the + * top of the tree), this routine does nothing. + * + */ +WIDGET_API void XPBringRootWidgetToFront( + XPWidgetID inWidget); + +/* + * XPIsWidgetInFront + * + * This routine returns true if this widget's hierarchy is the front most + * hierarchy. It returns false if the widget's hierarchy is not in front, or + * if the widget is not in a rooted hierarchy. + * + */ +WIDGET_API int XPIsWidgetInFront( + XPWidgetID inWidget); + +/* + * XPGetWidgetGeometry + * + * This routine returns the bounding box of a widget in global coordinates. + * Pass NULL for any parameter you are not interested in. + * + */ +WIDGET_API void XPGetWidgetGeometry( + XPWidgetID inWidget, + int * outLeft, /* Can be NULL */ + int * outTop, /* Can be NULL */ + int * outRight, /* Can be NULL */ + int * outBottom); /* Can be NULL */ + +/* + * XPSetWidgetGeometry + * + * This function changes the bounding box of a widget. + * + */ +WIDGET_API void XPSetWidgetGeometry( + XPWidgetID inWidget, + int inLeft, + int inTop, + int inRight, + int inBottom); + +/* + * XPGetWidgetForLocation + * + * Given a widget and a location, this routine returns the widget ID of the + * child of that widget that owns that location. If inRecursive is true then + * this will return a child of a child of a widget as it tries to find the + * deepest widget at that location. If inVisibleOnly is true, then only + * visible widgets are considered, otherwise all widgets are considered. The + * widget ID passed for inContainer will be returned if the location is in + * that widget but not in a child widget. 0 is returned if the location is not + * in the container. + * + * NOTE: if a widget's geometry extends outside its parents geometry, it will + * not be returned by this call for mouse locations outside the parent + * geometry. The parent geometry limits the child's eligibility for mouse + * location. + * + */ +WIDGET_API XPWidgetID XPGetWidgetForLocation( + XPWidgetID inContainer, + int inXOffset, + int inYOffset, + int inRecursive, + int inVisibleOnly); + +/* + * XPGetWidgetExposedGeometry + * + * This routine returns the bounds of the area of a widget that is completely + * within its parent widgets. Since a widget's bounding box can be outside its + * parent, part of its area will not be elligible for mouse clicks and should + * not draw. Use XPGetWidgetGeometry to find out what area defines your + * widget's shape, but use this routine to find out what area to actually draw + * into. Note that the widget library does not use OpenGL clipping to keep + * frame rates up, although you could use it internally. + * + */ +WIDGET_API void XPGetWidgetExposedGeometry( + XPWidgetID inWidgetID, + int * outLeft, /* Can be NULL */ + int * outTop, /* Can be NULL */ + int * outRight, /* Can be NULL */ + int * outBottom); /* Can be NULL */ + +/*************************************************************************** + * ACCESSING WIDGET DATA + ***************************************************************************/ + +/* + * XPSetWidgetDescriptor + * + * Every widget has a descriptor, which is a text string. What the text string + * is used for varies from widget to widget; for example, a push button's text + * is its descriptor, a caption shows its descriptor, and a text field's + * descriptor is the text being edited. In other words, the usage for the text + * varies from widget to widget, but this API provides a universal and + * convenient way to get at it. While not all UI widgets need their + * descriptor, many do. + * + */ +WIDGET_API void XPSetWidgetDescriptor( + XPWidgetID inWidget, + const char * inDescriptor); + +/* + * XPGetWidgetDescriptor + * + * This routine returns the widget's descriptor. Pass in the length of the + * buffer you are going to receive the descriptor in. The descriptor will be + * null terminated for you. This routine returns the length of the actual + * descriptor; if you pass NULL for outDescriptor, you can get the + * descriptor's length without getting its text. If the length of the + * descriptor exceeds your buffer length, the buffer will not be null + * terminated (this routine has 'strncpy' semantics). + * + */ +WIDGET_API int XPGetWidgetDescriptor( + XPWidgetID inWidget, + char * outDescriptor, + int inMaxDescLength); + +/* + * XPGetWidgetUnderlyingWindow + * + * Returns the window (from the XPLMDisplay API) that backs your widget + * window. If you have opted in to modern windows, via a call to + * XPLMEnableFeature("XPLM_USE_NATIVE_WIDGET_WINDOWS", 1), you can use the + * returned window ID for display APIs like XPLMSetWindowPositioningMode(), + * allowing you to pop the widget window out into a real OS window, or move it + * into VR. + * + */ +WIDGET_API XPLMWindowID XPGetWidgetUnderlyingWindow( + XPWidgetID inWidget); + +/* + * XPSetWidgetProperty + * + * This function sets a widget's property. Properties are arbitrary values + * associated by a widget by ID. + * + */ +WIDGET_API void XPSetWidgetProperty( + XPWidgetID inWidget, + XPWidgetPropertyID inProperty, + intptr_t inValue); + +/* + * XPGetWidgetProperty + * + * This routine returns the value of a widget's property, or 0 if the property + * is not defined. If you need to know whether the property is defined, pass a + * pointer to an int for inExists; the existence of that property will be + * returned in the int. Pass NULL for inExists if you do not need this + * information. + * + */ +WIDGET_API intptr_t XPGetWidgetProperty( + XPWidgetID inWidget, + XPWidgetPropertyID inProperty, + int * inExists); /* Can be NULL */ + +/*************************************************************************** + * KEYBOARD MANAGEMENT + ***************************************************************************/ + +/* + * XPSetKeyboardFocus + * + * Controls which widget will receive keystrokes. Pass the widget ID of the + * widget to get the keys. Note that if the widget does not care about + * keystrokes, they will go to the parent widget, and if no widget cares about + * them, they go to X-Plane. + * + * If you set the keyboard focus to widget ID 0, X-Plane gets keyboard focus. + * + * This routine returns the widget ID that ended up with keyboard focus, or 0 + * for X-Plane. + * + * Keyboard focus is not changed if the new widget will not accept it. For + * setting to X-Plane, keyboard focus is always accepted. + * + */ +WIDGET_API XPWidgetID XPSetKeyboardFocus( + XPWidgetID inWidget); + +/* + * XPLoseKeyboardFocus + * + * This causes the specified widget to lose focus; focus is passed to its + * parent, or the next parent that will accept it. This routine does nothing + * if this widget does not have focus. + * + */ +WIDGET_API void XPLoseKeyboardFocus( + XPWidgetID inWidget); + +/* + * XPGetWidgetWithFocus + * + * This routine returns the widget that has keyboard focus, or 0 if X-Plane + * has keyboard focus or some other plugin window that does not have widgets + * has focus. + * + */ +WIDGET_API XPWidgetID XPGetWidgetWithFocus(void); + +/*************************************************************************** + * CREATING CUSTOM WIDGETS + ***************************************************************************/ + +/* + * XPAddWidgetCallback + * + * This function adds a new widget callback to a widget. This widget callback + * supercedes any existing ones and will receive messages first; if it does + * not handle messages they will go on to be handled by pre-existing widgets. + * + * The widget function will remain on the widget for the life of the widget. + * The creation message will be sent to the new callback immediately with the + * widget ID, and the destruction message will be sent before the other widget + * function receives a destruction message. + * + * This provides a way to 'subclass' an existing widget. By providing a second + * hook that only handles certain widget messages, you can customize or extend + * widget behavior. + * + */ +WIDGET_API void XPAddWidgetCallback( + XPWidgetID inWidget, + XPWidgetFunc_t inNewCallback); + +/* + * XPGetWidgetClassFunc + * + * Given a widget class, this function returns the callbacks that power that + * widget class. + * + */ +WIDGET_API XPWidgetFunc_t XPGetWidgetClassFunc( + XPWidgetClass inWidgetClass); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/SDK/CHeaders/Wrappers/XPCBroadcaster.cpp b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/Wrappers/XPCBroadcaster.cpp new file mode 100644 index 0000000..5fe6218 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/Wrappers/XPCBroadcaster.cpp @@ -0,0 +1,56 @@ +#include "XPCBroadcaster.h" +#include "XPCListener.h" + +XPCBroadcaster::XPCBroadcaster() : + mIterator(NULL) +{ +} + +XPCBroadcaster::~XPCBroadcaster() +{ + ListenerVector::iterator iter; + mIterator = &iter; + for (iter = mListeners.begin(); iter != mListeners.end(); ++iter) + { + (*iter)->BroadcasterRemoved(this); + } +} + +void XPCBroadcaster::AddListener( + XPCListener * inListener) +{ + mListeners.push_back(inListener); + inListener->BroadcasterAdded(this); +} + +void XPCBroadcaster::RemoveListener( + XPCListener * inListener) +{ + ListenerVector::iterator iter = std::find + (mListeners.begin(), mListeners.end(), inListener); + if (iter == mListeners.end()) + return; + + if (mIterator != NULL) + { + if (*mIterator >= iter) + (*mIterator)--; + } + + mListeners.erase(iter); + inListener->BroadcasterRemoved(this); +} + +void XPCBroadcaster::BroadcastMessage( + int inMessage, + void * inParam) +{ + ListenerVector::iterator iter; + mIterator = &iter; + for (iter = mListeners.begin(); iter != mListeners.end(); ++iter) + { + (*iter)->ListenToMessage(inMessage, inParam); + } + mIterator = NULL; +} + diff --git a/XPLPro_Plugin_Source/SDK/SDK/CHeaders/Wrappers/XPCBroadcaster.h b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/Wrappers/XPCBroadcaster.h new file mode 100644 index 0000000..8f34a05 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/Wrappers/XPCBroadcaster.h @@ -0,0 +1,38 @@ +#ifndef _XPCBroadcaster_h_ +#define _XPCBroadcaster_h_ + +#include +#include + +class XPCListener; + +class XPCBroadcaster { +public: + + XPCBroadcaster(); + virtual ~XPCBroadcaster(); + + void AddListener( + XPCListener * inListener); + void RemoveListener( + XPCListener * inListener); + +protected: + + void BroadcastMessage( + int inMessage, + void * inParam=0); + +private: + + typedef std::vector ListenerVector; + + ListenerVector mListeners; + + // Reentrancy support + + ListenerVector::iterator * mIterator; + +}; + +#endif \ No newline at end of file diff --git a/XPLPro_Plugin_Source/SDK/SDK/CHeaders/Wrappers/XPCDisplay.cpp b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/Wrappers/XPCDisplay.cpp new file mode 100644 index 0000000..fc996ca --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/Wrappers/XPCDisplay.cpp @@ -0,0 +1,104 @@ +#include "XPCDisplay.h" + +XPCKeySniffer::XPCKeySniffer(int inBeforeWindows) : mBeforeWindows(inBeforeWindows) +{ + XPLMRegisterKeySniffer(KeySnifferCB, mBeforeWindows, reinterpret_cast(this)); +} + +XPCKeySniffer::~XPCKeySniffer() +{ + XPLMUnregisterKeySniffer(KeySnifferCB, mBeforeWindows, reinterpret_cast(this)); +} + + +int XPCKeySniffer::KeySnifferCB( + char inCharKey, + XPLMKeyFlags inFlags, + char inVirtualKey, + void * inRefCon) +{ + XPCKeySniffer * me = reinterpret_cast(inRefCon); + return me->HandleKeyStroke(inCharKey, inFlags, inVirtualKey); +} + +XPCWindow::XPCWindow( + int inLeft, + int inTop, + int inRight, + int inBottom, + int inIsVisible) +{ + mWindow = XPLMCreateWindow(inLeft, inTop, inRight, inBottom, inIsVisible, + DrawCB, HandleKeyCB, MouseClickCB, + reinterpret_cast(this)); +} + +XPCWindow::~XPCWindow() +{ + XPLMDestroyWindow(mWindow); +} + +void XPCWindow::GetWindowGeometry( + int * outLeft, + int * outTop, + int * outRight, + int * outBottom) +{ + XPLMGetWindowGeometry(mWindow, outLeft, outTop, outRight, outBottom); +} + +void XPCWindow::SetWindowGeometry( + int inLeft, + int inTop, + int inRight, + int inBottom) +{ + XPLMSetWindowGeometry(mWindow, inLeft, inTop, inRight, inBottom); +} + +int XPCWindow::GetWindowIsVisible(void) +{ + return XPLMGetWindowIsVisible(mWindow); +} + +void XPCWindow::SetWindowIsVisible( + int inIsVisible) +{ + XPLMSetWindowIsVisible(mWindow, inIsVisible); +} + +void XPCWindow::TakeKeyboardFocus(void) +{ + XPLMTakeKeyboardFocus(mWindow); +} + +void XPCWindow::BringWindowToFront(void) +{ + XPLMBringWindowToFront(mWindow); +} + +int XPCWindow::IsWindowInFront(void) +{ + return XPLMIsWindowInFront(mWindow); +} + +void XPCWindow::DrawCB(XPLMWindowID inWindowID, void * inRefcon) +{ + XPCWindow * me = reinterpret_cast(inRefcon); + me->DoDraw(); +} + +void XPCWindow::HandleKeyCB(XPLMWindowID inWindowID, char inKey, XPLMKeyFlags inFlags, char inVirtualKey, void * inRefcon, int losingFocus) +{ + XPCWindow * me = reinterpret_cast(inRefcon); + if (losingFocus) + me->LoseFocus(); + else + me->HandleKey(inKey, inFlags, inVirtualKey); +} + +int XPCWindow::MouseClickCB(XPLMWindowID inWindowID, int x, int y, XPLMMouseStatus inMouse, void * inRefcon) +{ + XPCWindow * me = reinterpret_cast(inRefcon); + return me->HandleClick(x, y, inMouse); +} diff --git a/XPLPro_Plugin_Source/SDK/SDK/CHeaders/Wrappers/XPCDisplay.h b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/Wrappers/XPCDisplay.h new file mode 100644 index 0000000..2465928 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/Wrappers/XPCDisplay.h @@ -0,0 +1,73 @@ +#ifndef _XPCDisplay_h_ +#define _XPCDisplay_h_ + +#include "XPLMDisplay.h" + +class XPCKeySniffer { +public: + + XPCKeySniffer(int inBeforeWindows); + virtual ~XPCKeySniffer(); + + virtual int HandleKeyStroke( + char inCharKey, + XPLMKeyFlags inFlags, + char inVirtualKey)=0; + +private: + + int mBeforeWindows; + + static int KeySnifferCB( + char inCharKey, + XPLMKeyFlags inFlags, + char inVirtualKey, + void * inRefCon); +}; + + + +class XPCWindow { +public: + + XPCWindow( + int inLeft, + int inTop, + int inRight, + int inBottom, + int inIsVisible); + virtual ~XPCWindow(); + + virtual void DoDraw(void)=0; + virtual void HandleKey(char inKey, XPLMKeyFlags inFlags, char inVirtualKey)=0; + virtual void LoseFocus(void)=0; + virtual int HandleClick(int x, int y, XPLMMouseStatus inMouse)=0; + + void GetWindowGeometry( + int * outLeft, + int * outTop, + int * outRight, + int * outBottom); + void SetWindowGeometry( + int inLeft, + int inTop, + int inRight, + int inBottom); + int GetWindowIsVisible(void); + void SetWindowIsVisible( + int inIsVisible); + void TakeKeyboardFocus(void); + void BringWindowToFront(void); + int IsWindowInFront(void); + +private: + + XPLMWindowID mWindow; + + static void DrawCB(XPLMWindowID inWindowID, void * inRefcon); + static void HandleKeyCB(XPLMWindowID inWindowID, char inKey, XPLMKeyFlags inFlags, char inVirtualKey, void * inRefcon, int losingFocus); + static int MouseClickCB(XPLMWindowID inWindowID, int x, int y, XPLMMouseStatus inMouse, void * inRefcon); + +}; + +#endif \ No newline at end of file diff --git a/XPLPro_Plugin_Source/SDK/SDK/CHeaders/Wrappers/XPCListener.cpp b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/Wrappers/XPCListener.cpp new file mode 100644 index 0000000..b4c77aa --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/Wrappers/XPCListener.cpp @@ -0,0 +1,27 @@ +#include "XPCListener.h" +#include "XPCBroadcaster.h" + +XPCListener::XPCListener() +{ +} + +XPCListener::~XPCListener() +{ + while (!mBroadcasters.empty()) + mBroadcasters.front()->RemoveListener(this); +} + +void XPCListener::BroadcasterAdded( + XPCBroadcaster * inBroadcaster) +{ + mBroadcasters.push_back(inBroadcaster); +} + +void XPCListener::BroadcasterRemoved( + XPCBroadcaster * inBroadcaster) +{ + BroadcastVector::iterator iter = std::find(mBroadcasters.begin(), + mBroadcasters.end(), inBroadcaster); + if (iter != mBroadcasters.end()) + mBroadcasters.erase(iter); +} diff --git a/XPLPro_Plugin_Source/SDK/SDK/CHeaders/Wrappers/XPCListener.h b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/Wrappers/XPCListener.h new file mode 100644 index 0000000..dbdd2a0 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/Wrappers/XPCListener.h @@ -0,0 +1,36 @@ +#ifndef _XPCListener_h_ +#define _XPCListener_h_ + +#include +#include + +class XPCBroadcaster; + + +class XPCListener { +public: + + XPCListener(); + virtual ~XPCListener(); + + virtual void ListenToMessage( + int inMessage, + void * inParam)=0; + +private: + + typedef std::vector BroadcastVector; + + BroadcastVector mBroadcasters; + + friend class XPCBroadcaster; + + void BroadcasterAdded( + XPCBroadcaster * inBroadcaster); + + void BroadcasterRemoved( + XPCBroadcaster * inBroadcaster); + +}; + +#endif \ No newline at end of file diff --git a/XPLPro_Plugin_Source/SDK/SDK/CHeaders/Wrappers/XPCProcessing.cpp b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/Wrappers/XPCProcessing.cpp new file mode 100644 index 0000000..352c05f --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/Wrappers/XPCProcessing.cpp @@ -0,0 +1,52 @@ +#include "XPCProcessing.h" +#include "XPLMUtilities.h" + +XPCProcess::XPCProcess() : + mInCallback(false), + mCallbackTime(0) +{ + XPLMRegisterFlightLoopCallback(FlightLoopCB, 0, reinterpret_cast(this)); +} + +XPCProcess::~XPCProcess() +{ + XPLMUnregisterFlightLoopCallback(FlightLoopCB, reinterpret_cast(this)); +} + +void XPCProcess::StartProcessTime(float inSeconds) +{ + mCallbackTime = inSeconds; + if (!mInCallback) + XPLMSetFlightLoopCallbackInterval( + FlightLoopCB, mCallbackTime, 1/*relative to now*/, reinterpret_cast(this)); +} + +void XPCProcess::StartProcessCycles(int inCycles) +{ + mCallbackTime = -inCycles; + if (!mInCallback) + XPLMSetFlightLoopCallbackInterval( + FlightLoopCB, mCallbackTime, 1/*relative to now*/, reinterpret_cast(this)); +} + +void XPCProcess::StopProcess(void) +{ + mCallbackTime = 0; + if (!mInCallback) + XPLMSetFlightLoopCallbackInterval( + FlightLoopCB, mCallbackTime, 1/*relative to now*/, reinterpret_cast(this)); +} + + +float XPCProcess::FlightLoopCB( + float inElapsedSinceLastCall, + float inElapsedTimeSinceLastFlightLoop, + int inCounter, + void * inRefcon) +{ + XPCProcess * me = reinterpret_cast(inRefcon); + me->mInCallback = true; + me->DoProcessing(inElapsedSinceLastCall, inElapsedTimeSinceLastFlightLoop, inCounter); + me->mInCallback = false; + return me->mCallbackTime; +} \ No newline at end of file diff --git a/XPLPro_Plugin_Source/SDK/SDK/CHeaders/Wrappers/XPCProcessing.h b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/Wrappers/XPCProcessing.h new file mode 100644 index 0000000..cd735e5 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/Wrappers/XPCProcessing.h @@ -0,0 +1,37 @@ +#ifndef _XPCProcessing_h_ +#define _XPCProcessing_h_ + +#include "XPLMProcessing.h" + +class XPCProcess { +public: + + XPCProcess(); + virtual ~XPCProcess(); + + void StartProcessTime(float inSeconds); + void StartProcessCycles(int inCycles); + void StopProcess(void); + + virtual void DoProcessing( + float inElapsedSinceLastCall, + float inElapsedTimeSinceLastFlightLoop, + int inCounter)=0; + +private: + + static float FlightLoopCB( + float inElapsedSinceLastCall, + float inElapsedTimeSinceLastFlightLoop, + int inCounter, + void * inRefcon); + + bool mInCallback; + float mCallbackTime; + + XPCProcess(const XPCProcess&); + XPCProcess& operator=(const XPCProcess&); + +}; + +#endif diff --git a/XPLPro_Plugin_Source/SDK/SDK/CHeaders/Wrappers/XPCWidget.cpp b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/Wrappers/XPCWidget.cpp new file mode 100644 index 0000000..8ef8aa3 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/Wrappers/XPCWidget.cpp @@ -0,0 +1,123 @@ +#include "XPCWidget.h" + +XPCWidget::XPCWidget( + int inLeft, + int inTop, + int inRight, + int inBottom, + bool inVisible, + const char * inDescriptor, + bool inIsRoot, + XPWidgetID inParent, + XPWidgetClass inClass) : + mWidget(NULL), + mOwnsChildren(false), + mOwnsWidget(true) +{ + mWidget = XPCreateWidget( + inLeft, inTop, inRight, inBottom, + inVisible ? 1 : 0, + inDescriptor, + inIsRoot ? 1 : 0, + inIsRoot ? NULL : inParent, + inClass); + + XPSetWidgetProperty(mWidget, xpProperty_Object, reinterpret_cast(this)); + XPAddWidgetCallback(mWidget, WidgetCallback); +} + +XPCWidget::XPCWidget( + XPWidgetID inWidget, + bool inOwnsWidget) : + mWidget(inWidget), + mOwnsChildren(false), + mOwnsWidget(inOwnsWidget) +{ + XPSetWidgetProperty(mWidget, xpProperty_Object, reinterpret_cast(this)); + XPAddWidgetCallback(mWidget, WidgetCallback); +} + +XPCWidget::~XPCWidget() +{ + if (mOwnsWidget) + XPDestroyWidget(mWidget, mOwnsChildren ? 1 : 0); +} + +void XPCWidget::SetOwnsWidget( + bool inOwnsWidget) +{ + mOwnsWidget = inOwnsWidget; +} + +void XPCWidget::SetOwnsChildren( + bool inOwnsChildren) +{ + mOwnsChildren = inOwnsChildren; +} + +XPCWidget::operator XPWidgetID () const +{ + return mWidget; +} + +XPWidgetID XPCWidget::Get(void) const +{ + return mWidget; +} + +void XPCWidget::AddAttachment( + XPCWidgetAttachment * inAttachment, + bool inOwnsAttachment, + bool inPrefilter) +{ + if (inPrefilter) + { + mAttachments.insert(mAttachments.begin(), AttachmentInfo(inAttachment, inOwnsAttachment)); + } else { + mAttachments.push_back(AttachmentInfo(inAttachment, inOwnsAttachment)); + } +} + +void XPCWidget::RemoveAttachment( + XPCWidgetAttachment * inAttachment) +{ + for (AttachmentVector::iterator iter = mAttachments.begin(); + iter != mAttachments.end(); ++iter) + { + if (iter->first == inAttachment) + { + mAttachments.erase(iter); + return; + } + } +} + +int XPCWidget::HandleWidgetMessage( + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2) +{ + return 0; +} + +int XPCWidget::WidgetCallback( + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2) +{ + XPCWidget * me = reinterpret_cast(XPGetWidgetProperty(inWidget, xpProperty_Object, NULL)); + if (me == NULL) + return 0; + + for (AttachmentVector::iterator iter = me->mAttachments.begin(); iter != + me->mAttachments.end(); ++iter) + { + int result = iter->first->HandleWidgetMessage(me, inMessage, inWidget, inParam1, inParam2); + if (result != 0) + return result; + } + + return me->HandleWidgetMessage(inMessage, inWidget, inParam1, inParam2); +} diff --git a/XPLPro_Plugin_Source/SDK/SDK/CHeaders/Wrappers/XPCWidget.h b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/Wrappers/XPCWidget.h new file mode 100644 index 0000000..788b56a --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/Wrappers/XPCWidget.h @@ -0,0 +1,84 @@ +#ifndef _XPCWidget_h_ +#define _XPCWidget_h_ + +#include +#include +#include "XPWidgets.h" + +class XPCWidget; + +class XPCWidgetAttachment { +public: + + virtual int HandleWidgetMessage( + XPCWidget * inObject, + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2)=0; + +}; + +class XPCWidget { +public: + + XPCWidget( + int inLeft, + int inTop, + int inRight, + int inBottom, + bool inVisible, + const char * inDescriptor, + bool inIsRoot, + XPWidgetID inParent, + XPWidgetClass inClass); + XPCWidget( + XPWidgetID inWidget, + bool inOwnsWidget); + virtual ~XPCWidget(); + + void SetOwnsWidget( + bool inOwnsWidget); + void SetOwnsChildren( + bool inOwnsChildren); + + operator XPWidgetID () const; + + XPWidgetID Get(void) const; + + void AddAttachment( + XPCWidgetAttachment * inAttachment, + bool inOwnsAttachment, + bool inPrefilter); + void RemoveAttachment( + XPCWidgetAttachment * inAttachment); + + virtual int HandleWidgetMessage( + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2); + +private: + + static int WidgetCallback( + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2); + + typedef std::pair AttachmentInfo; + typedef std::vector AttachmentVector; + + AttachmentVector mAttachments; + XPWidgetID mWidget; + bool mOwnsChildren; + bool mOwnsWidget; + + XPCWidget(); + XPCWidget(const XPCWidget&); + XPCWidget& operator=(const XPCWidget&); + +}; + +#endif \ No newline at end of file diff --git a/XPLPro_Plugin_Source/SDK/SDK/CHeaders/Wrappers/XPCWidgetAttachments.cpp b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/Wrappers/XPCWidgetAttachments.cpp new file mode 100644 index 0000000..d87f105 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/Wrappers/XPCWidgetAttachments.cpp @@ -0,0 +1,267 @@ +#include "XPCWidgetAttachments.h" +#include "XPStandardWidgets.h" +#include "XPWidgetUtils.h" + +static void XPCGetOrderedSubWidgets( + XPWidgetID inWidget, + std::vector& outChildren); + +XPCKeyFilterAttachment::XPCKeyFilterAttachment( + const char * inValidKeys, + const char * outValidKeys) : + mInput(inValidKeys), + mOutput(outValidKeys) +{ +} + +XPCKeyFilterAttachment::~XPCKeyFilterAttachment() +{ +} + +int XPCKeyFilterAttachment::HandleWidgetMessage( + XPCWidget * inObject, + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2) +{ + if (inMessage == xpMsg_KeyPress) + { + char& theKey = KEY_CHAR(inParam1); + std::string::size_type pos = mInput.find(theKey); + if (pos == std::string::npos) + return 1; // Not found; eat the key! + else { + theKey = mOutput[pos]; + return 0; + } // Let it live. + } + return 0; +} + + +XPCKeyMessageAttachment::XPCKeyMessageAttachment( + char inKey, + int inMessage, + void * inParam, + bool inConsume, + bool inVkey, + XPCListener * inListener) : + mKey(inKey), mMsg(inMessage), mParam(inParam), mConsume(inConsume), + mVkey(inVkey) +{ + if (inListener != NULL) + this->AddListener(inListener); +} + +XPCKeyMessageAttachment::~XPCKeyMessageAttachment() +{ +} + +int XPCKeyMessageAttachment::HandleWidgetMessage( + XPCWidget * inObject, + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2) +{ + if (inMessage == xpMsg_KeyPress) + { + char theKey = mVkey ? KEY_VKEY(inParam1) : KEY_CHAR(inParam1); + if (theKey != mKey) + return 0; + if (!(KEY_FLAGS(inParam1) & xplm_DownFlag)) + return 0; + + BroadcastMessage(mMsg, mParam); + return mConsume ? 1 : 0; + } + return 0; +} + +XPCPushButtonMessageAttachment::XPCPushButtonMessageAttachment( + XPWidgetID inWidget, + int inMessage, + void * inParam, + XPCListener * inListener) : + mMsg(inMessage), mParam(inParam), mWidget(inWidget) +{ + if (inListener != NULL) + this->AddListener(inListener); +} + +XPCPushButtonMessageAttachment::~XPCPushButtonMessageAttachment() +{ +} + +int XPCPushButtonMessageAttachment::HandleWidgetMessage( + XPCWidget * inObject, + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2) +{ + if ((inMessage == xpMsg_PushButtonPressed) && ((XPWidgetID) inParam1 == mWidget)) + { + BroadcastMessage(mMsg, mParam); + return 1; + } + + if ((inMessage == xpMsg_ButtonStateChanged) && ((XPWidgetID) inParam1 == mWidget)) + { + BroadcastMessage(mMsg, mParam); + return 1; + } + return 0; +} + +XPCSliderMessageAttachment::XPCSliderMessageAttachment( + XPWidgetID inWidget, + int inMessage, + void * inParam, + XPCListener * inListener) : + mMsg(inMessage), mParam(inParam), mWidget(inWidget) +{ + if (inListener != NULL) + this->AddListener(inListener); +} + +XPCSliderMessageAttachment::~XPCSliderMessageAttachment() +{ +} + +int XPCSliderMessageAttachment::HandleWidgetMessage( + XPCWidget * inObject, + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2) +{ + if ((inMessage == xpMsg_ScrollBarSliderPositionChanged) && ((XPWidgetID) inParam1 == mWidget)) + { + BroadcastMessage(mMsg, mParam); + return 1; + } + + return 0; +} + + +XPCCloseButtonMessageAttachment::XPCCloseButtonMessageAttachment( + XPWidgetID inWidget, + int inMessage, + void * inParam, + XPCListener * inListener) : + mMsg(inMessage), mParam(inParam), mWidget(inWidget) +{ + if (inListener != NULL) + this->AddListener(inListener); +} + +XPCCloseButtonMessageAttachment::~XPCCloseButtonMessageAttachment() +{ +} + +int XPCCloseButtonMessageAttachment::HandleWidgetMessage( + XPCWidget * inObject, + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2) +{ + if ((inMessage == xpMessage_CloseButtonPushed) && ((XPWidgetID) inParam1 == mWidget)) + { + BroadcastMessage(mMsg, mParam); + return 1; + } + + return 0; +} + +XPCTabGroupAttachment::XPCTabGroupAttachment() +{ +} + +XPCTabGroupAttachment::~XPCTabGroupAttachment() +{ +} + +int XPCTabGroupAttachment::HandleWidgetMessage( + XPCWidget * inObject, + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2) +{ + if ((inMessage == xpMsg_KeyPress) && (KEY_CHAR(inParam1) == XPLM_KEY_TAB) && + ((KEY_FLAGS(inParam1) & xplm_UpFlag) == 0)) + { + bool backwards = (KEY_FLAGS(inParam1) & xplm_ShiftFlag) != 0; + std::vector widgets; + XPCGetOrderedSubWidgets(inWidget, widgets); + int n, index = 0; + XPWidgetID focusWidget = XPGetWidgetWithFocus(); + std::vector::iterator iter = std::find(widgets.begin(), widgets.end(), focusWidget); + if (iter != widgets.end()) + { + index = std::distance(widgets.begin(), iter); + if (backwards) + index--; + else + index++; + if (index < 0) + index = widgets.size() - 1; + if (index >= widgets.size()) + index = 0; + } + + if (backwards) + { + for (n = index; n >= 0; --n) + { + if (XPGetWidgetProperty(widgets[n], xpProperty_Enabled, NULL)) + if (XPSetKeyboardFocus(widgets[n]) != NULL) + return 1; + } + for (n = widgets.size() - 1; n > index; --n) + { + if (XPGetWidgetProperty(widgets[n], xpProperty_Enabled, NULL)) + if (XPSetKeyboardFocus(widgets[n]) != NULL) + return 1; + } + } else { + for (n = index; n < widgets.size(); ++n) + { + if (XPGetWidgetProperty(widgets[n], xpProperty_Enabled, NULL)) + if (XPSetKeyboardFocus(widgets[n]) != NULL) + return 1; + } + for (n = 0; n < index; ++n) + { + if (XPGetWidgetProperty(widgets[n], xpProperty_Enabled, NULL)) + if (XPSetKeyboardFocus(widgets[n]) != NULL) + return 1; + } + } + } + return 0; +} + + + +static void XPCGetOrderedSubWidgets( + XPWidgetID inWidget, + std::vector& outChildren) +{ + outChildren.clear(); + int count = XPCountChildWidgets(inWidget); + for (int n = 0; n < count; ++n) + { + XPWidgetID child = XPGetNthChildWidget(inWidget, n); + outChildren.push_back(child); + std::vector grandChildren; + XPCGetOrderedSubWidgets(child, grandChildren); + + outChildren.insert(outChildren.end(), grandChildren.begin(), grandChildren.end()); + } +} diff --git a/XPLPro_Plugin_Source/SDK/SDK/CHeaders/Wrappers/XPCWidgetAttachments.h b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/Wrappers/XPCWidgetAttachments.h new file mode 100644 index 0000000..91fb587 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/Wrappers/XPCWidgetAttachments.h @@ -0,0 +1,146 @@ +#ifndef _XPCWidgetAttachments_h_ +#define _XPCWidgetAttachments_h_ + +#include + +#include "XPCWidget.h" +#include "XPCBroadcaster.h" + +class XPCKeyFilterAttachment : public XPCWidgetAttachment { +public: + + XPCKeyFilterAttachment( + const char * inValidKeys, + const char * outValidKeys); + virtual ~XPCKeyFilterAttachment(); + + virtual int HandleWidgetMessage( + XPCWidget * inObject, + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2); + +private: + + std::string mInput; + std::string mOutput; + +}; + + +class XPCKeyMessageAttachment : public XPCWidgetAttachment, public XPCBroadcaster { +public: + + XPCKeyMessageAttachment( + char inKey, + int inMessage, + void * inParam, + bool inConsume, + bool inVkey, + XPCListener * inListener); + virtual ~XPCKeyMessageAttachment(); + + virtual int HandleWidgetMessage( + XPCWidget * inObject, + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2); + +private: + + char mKey; + bool mVkey; + int mMsg; + void * mParam; + bool mConsume; + +}; + +class XPCPushButtonMessageAttachment : public XPCWidgetAttachment, XPCBroadcaster { +public: + + XPCPushButtonMessageAttachment( + XPWidgetID inWidget, + int inMessage, + void * inParam, + XPCListener * inListener); + virtual ~XPCPushButtonMessageAttachment(); + + virtual int HandleWidgetMessage( + XPCWidget * inObject, + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2); + +private: + XPWidgetID mWidget; + int mMsg; + void * mParam; +}; + +class XPCSliderMessageAttachment : public XPCWidgetAttachment, XPCBroadcaster { +public: + + XPCSliderMessageAttachment( + XPWidgetID inWidget, + int inMessage, + void * inParam, + XPCListener * inListener); + virtual ~XPCSliderMessageAttachment(); + + virtual int HandleWidgetMessage( + XPCWidget * inObject, + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2); + +private: + XPWidgetID mWidget; + int mMsg; + void * mParam; +}; + + +class XPCCloseButtonMessageAttachment : public XPCWidgetAttachment, XPCBroadcaster { +public: + + XPCCloseButtonMessageAttachment( + XPWidgetID inWidget, + int inMessage, + void * inParam, + XPCListener * inListener); + virtual ~XPCCloseButtonMessageAttachment(); + + virtual int HandleWidgetMessage( + XPCWidget * inObject, + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2); + +private: + XPWidgetID mWidget; + int mMsg; + void * mParam; +}; + +class XPCTabGroupAttachment : public XPCWidgetAttachment { +public: + + XPCTabGroupAttachment(); + virtual ~XPCTabGroupAttachment(); + + virtual int HandleWidgetMessage( + XPCWidget * inObject, + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2); + +}; + +#endif \ No newline at end of file diff --git a/XPLPro_Plugin_Source/SDK/SDK/CHeaders/XPLM/XPLMCamera.h b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/XPLM/XPLMCamera.h new file mode 100644 index 0000000..db930ef --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/XPLM/XPLMCamera.h @@ -0,0 +1,167 @@ +#ifndef _XPLMCamera_h_ +#define _XPLMCamera_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPLMCamera + ***************************************************************************/ +/* + * The XPLMCamera APIs allow plug-ins to control the camera angle in X-Plane. + * This has a number of applications, including but not limited to: + * + * - Creating new views (including dynamic/user-controllable views) for the + * user. + * - Creating applications that use X-Plane as a renderer of scenery, + * aircrafts, or both. + * + * The camera is controlled via six parameters: a location in OpenGL + * coordinates and pitch, roll and yaw, similar to an airplane's position. + * OpenGL coordinate info is described in detail in the XPLMGraphics + * documentation; generally you should use the XPLMGraphics routines to + * convert from world to local coordinates. The camera's orientation starts + * facing level with the ground directly up the negative-Z axis (approximately + * north) with the horizon horizontal. It is then rotated clockwise for yaw, + * pitched up for positive pitch, and rolled clockwise around the vector it is + * looking along for roll. + * + * You control the camera either either until the user selects a new view or + * permanently (the later being similar to how UDP camera control works). You + * control the camera by registering a callback per frame from which you + * calculate the new camera positions. This guarantees smooth camera motion. + * + * Use the XPLMDataAccess APIs to get information like the position of the + * aircraft, etc. for complex camera positioning. + * + * Note: if your goal is to move the virtual pilot in the cockpit, this API is + * not needed; simply update the datarefs for the pilot's head position. + * + * For custom exterior cameras, set the camera's mode to an external view + * first to get correct sound and 2-d panel behavior. + * + */ + +#include "XPLMDefs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*************************************************************************** + * CAMERA CONTROL + ***************************************************************************/ + +/* + * XPLMCameraControlDuration + * + * This enumeration states how long you want to retain control of the camera. + * You can retain it indefinitely or until the user selects a new view. + * + */ +enum { + /* Control the camera until the user picks a new view. */ + xplm_ControlCameraUntilViewChanges = 1, + + /* Control the camera until your plugin is disabled or another plugin forcably* + * takes control. */ + xplm_ControlCameraForever = 2, + + +}; +typedef int XPLMCameraControlDuration; + +/* + * XPLMCameraPosition_t + * + * This structure contains a full specification of the camera. X, Y, and Z are + * the camera's position in OpenGL coordiantes; pitch, roll, and yaw are + * rotations from a camera facing flat north in degrees. Positive pitch means + * nose up, positive roll means roll right, and positive yaw means yaw right, + * all in degrees. Zoom is a zoom factor, with 1.0 meaning normal zoom and 2.0 + * magnifying by 2x (objects appear larger). + * + */ +typedef struct { + float x; + float y; + float z; + float pitch; + float heading; + float roll; + float zoom; +} XPLMCameraPosition_t; + +/* + * XPLMCameraControl_f + * + * You use an XPLMCameraControl function to provide continuous control over + * the camera. You are passed in a structure in which to put the new camera + * position; modify it and return 1 to reposition the camera. Return 0 to + * surrender control of the camera; camera control will be handled by X-Plane + * on this draw loop. The contents of the structure as you are called are + * undefined. + * + * If X-Plane is taking camera control away from you, this function will be + * called with inIsLosingControl set to 1 and ioCameraPosition NULL. + * + */ +typedef int (* XPLMCameraControl_f)( + XPLMCameraPosition_t * outCameraPosition, /* Can be NULL */ + int inIsLosingControl, + void * inRefcon); + +/* + * XPLMControlCamera + * + * This function repositions the camera on the next drawing cycle. You must + * pass a non-null control function. Specify in inHowLong how long you'd like + * control (indefinitely or until a new view mode is set by the user). + * + */ +XPLM_API void XPLMControlCamera( + XPLMCameraControlDuration inHowLong, + XPLMCameraControl_f inControlFunc, + void * inRefcon); + +/* + * XPLMDontControlCamera + * + * This function stops you from controlling the camera. If you have a camera + * control function, it will not be called with an inIsLosingControl flag. + * X-Plane will control the camera on the next cycle. + * + * For maximum compatibility you should not use this routine unless you are in + * posession of the camera. + * + */ +XPLM_API void XPLMDontControlCamera(void); + +/* + * XPLMIsCameraBeingControlled + * + * This routine returns 1 if the camera is being controlled, zero if it is + * not. If it is and you pass in a pointer to a camera control duration, the + * current control duration will be returned. + * + */ +XPLM_API int XPLMIsCameraBeingControlled( + XPLMCameraControlDuration * outCameraControlDuration); /* Can be NULL */ + +/* + * XPLMReadCameraPosition + * + * This function reads the current camera position. + * + */ +XPLM_API void XPLMReadCameraPosition( + XPLMCameraPosition_t * outCameraPosition); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/SDK/CHeaders/XPLM/XPLMDataAccess.h b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/XPLM/XPLMDataAccess.h new file mode 100644 index 0000000..d8d1418 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/XPLM/XPLMDataAccess.h @@ -0,0 +1,716 @@ +#ifndef _XPLMDataAccess_h_ +#define _XPLMDataAccess_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPLMDataAccess + ***************************************************************************/ +/* + * The data access API gives you a generic, flexible, high performance way to + * read and write data to and from X-Plane and other plug-ins. For example, + * this API allows you to read and set the nav radios, get the plane location, + * determine the current effective graphics frame rate, etc. + * + * The data access APIs are the way that you read and write data from the sim + * as well as other plugins. + * + * The API works using opaque data references. A data reference is a source of + * data; you do not know where it comes from, but once you have it you can + * read the data quickly and possibly write it. + * + * Dataref Lookup + * -------------- + * + * Data references are identified by verbose, permanent string names; by + * convention these names use path separates to form a hierarchy of datarefs, + * e.g. (sim/cockpit/radios/nav1_freq_hz). The actual opaque numeric value of + * the data reference, as returned by the XPLM API, is implementation defined + * and changes each time X-Plane is launched; therefore you need to look up + * the dataref by path every time your plugin runs. + * + * The task of looking up a data reference is relatively expensive; look up + * your data references once based on the verbose path strings, and save the + * opaque data reference value for the duration of your plugin's operation. + * Reading and writing data references is relatively fast (the cost is + * equivalent to two function calls through function pointers). + * + * X-Plane publishes over 4000 datarefs; a complete list may be found in the + * reference section of the SDK online documentation (from the SDK home page, + * choose Documentation). + * + * Dataref Types + * ------------- + * + * A note on typing: you must know the correct data type to read and write. + * APIs are provided for reading and writing data in a number of ways. You can + * also double check the data type for a data ref. Automatic type conversion + * is not done for you. + * + * Dataref types are a set, e.g. a dataref can be more than one type. When + * this happens, you can choose which API you want to use to read. For + * example, it is not uncommon for a dataref to be of type float and double. + * This means you can use either XPLMGetDatad or XPLMGetDataf to read it. + * + * Creating New Datarefs + * --------------------- + * + * X-Plane provides datarefs that come with the sim, but plugins can also + * create their own datarefs. A plugin creates a dataref by registering + * function callbacks to read and write the dataref. The XPLM will call your + * plugin each time some other plugin (or X-Plane) tries to read or write the + * dataref. You must provide a read (and optional write) callback for each + * data type you support. + * + * A note for plugins sharing data with other plugins: the load order of + * plugins is not guaranteed. To make sure that every plugin publishing data + * has published their data references before other plugins try to subscribe, + * publish your data references in your start routine but resolve them the + * first time your 'enable' routine is called, or the first time they are + * needed in code. + * + * When a plugin that created a dataref is unloaded, it becomes "orphaned". + * The dataref handle continues to be usable, but the dataref is not writable, + * and reading it will always return 0 (or 0 items for arrays). If the plugin + * is reloaded and re-registers the dataref, the handle becomes un-orphaned + * and works again. + * + */ + +#include "XPLMDefs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*************************************************************************** + * READING AND WRITING DATA + ***************************************************************************/ +/* + * These routines allow you to access data from within X-Plane and sometimes + * modify it. + * + */ + + +/* + * XPLMDataRef + * + * A data ref is an opaque handle to data provided by the simulator or another + * plugin. It uniquely identifies one variable (or array of variables) over + * the lifetime of your plugin. You never hard code these values; you always + * get them from XPLMFindDataRef. + * + */ +typedef void * XPLMDataRef; + +/* + * XPLMDataTypeID + * + * This is an enumeration that defines the type of the data behind a data + * reference. This allows you to sanity check that the data type matches what + * you expect. But for the most part, you will know the type of data you are + * expecting from the online documentation. + * + * Data types each take a bit field; it is legal to have a single dataref be + * more than one type of data. Whe this happens, you can pick any matching + * get/set API. + * + */ +enum { + /* Data of a type the current XPLM doesn't do. */ + xplmType_Unknown = 0, + + /* A single 4-byte integer, native endian. */ + xplmType_Int = 1, + + /* A single 4-byte float, native endian. */ + xplmType_Float = 2, + + /* A single 8-byte double, native endian. */ + xplmType_Double = 4, + + /* An array of 4-byte floats, native endian. */ + xplmType_FloatArray = 8, + + /* An array of 4-byte integers, native endian. */ + xplmType_IntArray = 16, + + /* A variable block of data. */ + xplmType_Data = 32, + + +}; +typedef int XPLMDataTypeID; + +/* + * XPLMFindDataRef + * + * Given a c-style string that names the data ref, this routine looks up the + * actual opaque XPLMDataRef that you use to read and write the data. The + * string names for datarefs are published on the X-Plane SDK web site. + * + * This function returns NULL if the data ref cannot be found. + * + * NOTE: this function is relatively expensive; save the XPLMDataRef this + * function returns for future use. Do not look up your data ref by string + * every time you need to read or write it. + * + */ +XPLM_API XPLMDataRef XPLMFindDataRef( + const char * inDataRefName); + +/* + * XPLMCanWriteDataRef + * + * Given a data ref, this routine returns true if you can successfully set the + * data, false otherwise. Some datarefs are read-only. + * + * NOTE: even if a dataref is marked writable, it may not act writable. This + * can happen for datarefs that X-Plane writes to on every frame of + * simulation. In some cases, the dataref is writable but you have to set a + * separate "override" dataref to 1 to stop X-Plane from writing it. + * + */ +XPLM_API int XPLMCanWriteDataRef( + XPLMDataRef inDataRef); + +/* + * XPLMIsDataRefGood + * + * This function returns true if the passed in handle is a valid dataref that + * is not orphaned. + * + * Note: there is normally no need to call this function; datarefs returned by + * XPLMFindDataRef remain valid (but possibly orphaned) unless there is a + * complete plugin reload (in which case your plugin is reloaded anyway). + * Orphaned datarefs can be safely read and return 0. Therefore you never need + * to call XPLMIsDataRefGood to 'check' the safety of a dataref. + * (XPLMIsDatarefGood performs some slow checking of the handle validity, so + * it has a perormance cost.) + * + */ +XPLM_API int XPLMIsDataRefGood( + XPLMDataRef inDataRef); + +/* + * XPLMGetDataRefTypes + * + * This routine returns the types of the data ref for accessor use. If a data + * ref is available in multiple data types, the bit-wise OR of these types + * will be returned. + * + */ +XPLM_API XPLMDataTypeID XPLMGetDataRefTypes( + XPLMDataRef inDataRef); + +/*************************************************************************** + * DATA ACCESSORS + ***************************************************************************/ +/* + * These routines read and write the data references. For each supported data + * type there is a reader and a writer. + * + * If the data ref is orphaned or the plugin that provides it is disabled or + * there is a type mismatch, the functions that read data will return 0 as a + * default value or not modify the passed in memory. The plugins that write + * data will not write under these circumstances or if the data ref is + * read-only. + * + * NOTE: to keep the overhead of reading datarefs low, these routines do not + * do full validation of a dataref; passing a junk value for a dataref can + * result in crashing the sim. The get/set APIs do check for NULL. + * + * For array-style datarefs, you specify the number of items to read/write and + * the offset into the array; the actual number of items read or written is + * returned. This may be less to prevent an array-out-of-bounds error. + * + */ + + +/* + * XPLMGetDatai + * + * Read an integer data ref and return its value. The return value is the + * dataref value or 0 if the dataref is NULL or the plugin is disabled. + * + */ +XPLM_API int XPLMGetDatai( + XPLMDataRef inDataRef); + +/* + * XPLMSetDatai + * + * Write a new value to an integer data ref. This routine is a no-op if the + * plugin publishing the dataref is disabled, the dataref is NULL, or the + * dataref is not writable. + * + */ +XPLM_API void XPLMSetDatai( + XPLMDataRef inDataRef, + int inValue); + +/* + * XPLMGetDataf + * + * Read a single precision floating point dataref and return its value. The + * return value is the dataref value or 0.0 if the dataref is NULL or the + * plugin is disabled. + * + */ +XPLM_API float XPLMGetDataf( + XPLMDataRef inDataRef); + +/* + * XPLMSetDataf + * + * Write a new value to a single precision floating point data ref. This + * routine is a no-op if the plugin publishing the dataref is disabled, the + * dataref is NULL, or the dataref is not writable. + * + */ +XPLM_API void XPLMSetDataf( + XPLMDataRef inDataRef, + float inValue); + +/* + * XPLMGetDatad + * + * Read a double precision floating point dataref and return its value. The + * return value is the dataref value or 0.0 if the dataref is NULL or the + * plugin is disabled. + * + */ +XPLM_API double XPLMGetDatad( + XPLMDataRef inDataRef); + +/* + * XPLMSetDatad + * + * Write a new value to a double precision floating point data ref. This + * routine is a no-op if the plugin publishing the dataref is disabled, the + * dataref is NULL, or the dataref is not writable. + * + */ +XPLM_API void XPLMSetDatad( + XPLMDataRef inDataRef, + double inValue); + +/* + * XPLMGetDatavi + * + * Read a part of an integer array dataref. If you pass NULL for outValues, + * the routine will return the size of the array, ignoring inOffset and inMax. + * + * If outValues is not NULL, then up to inMax values are copied from the + * dataref into outValues, starting at inOffset in the dataref. If inMax + + * inOffset is larger than the size of the dataref, less than inMax values + * will be copied. The number of values copied is returned. + * + * Note: the semantics of array datarefs are entirely implemented by the + * plugin (or X-Plane) that provides the dataref, not the SDK itself; the + * above description is how these datarefs are intended to work, but a rogue + * plugin may have different behavior. + * + */ +XPLM_API int XPLMGetDatavi( + XPLMDataRef inDataRef, + int * outValues, /* Can be NULL */ + int inOffset, + int inMax); + +/* + * XPLMSetDatavi + * + * Write part or all of an integer array dataref. The values passed by + * inValues are written into the dataref starting at inOffset. Up to inCount + * values are written; however if the values would write "off the end" of the + * dataref array, then fewer values are written. + * + * Note: the semantics of array datarefs are entirely implemented by the + * plugin (or X-Plane) that provides the dataref, not the SDK itself; the + * above description is how these datarefs are intended to work, but a rogue + * plugin may have different behavior. + * + */ +XPLM_API void XPLMSetDatavi( + XPLMDataRef inDataRef, + int * inValues, + int inoffset, + int inCount); + +/* + * XPLMGetDatavf + * + * Read a part of a single precision floating point array dataref. If you pass + * NULL for outVaules, the routine will return the size of the array, ignoring + * inOffset and inMax. + * + * If outValues is not NULL, then up to inMax values are copied from the + * dataref into outValues, starting at inOffset in the dataref. If inMax + + * inOffset is larger than the size of the dataref, less than inMax values + * will be copied. The number of values copied is returned. + * + * Note: the semantics of array datarefs are entirely implemented by the + * plugin (or X-Plane) that provides the dataref, not the SDK itself; the + * above description is how these datarefs are intended to work, but a rogue + * plugin may have different behavior. + * + */ +XPLM_API int XPLMGetDatavf( + XPLMDataRef inDataRef, + float * outValues, /* Can be NULL */ + int inOffset, + int inMax); + +/* + * XPLMSetDatavf + * + * Write part or all of a single precision floating point array dataref. The + * values passed by inValues are written into the dataref starting at + * inOffset. Up to inCount values are written; however if the values would + * write "off the end" of the dataref array, then fewer values are written. + * + * Note: the semantics of array datarefs are entirely implemented by the + * plugin (or X-Plane) that provides the dataref, not the SDK itself; the + * above description is how these datarefs are intended to work, but a rogue + * plugin may have different behavior. + * + */ +XPLM_API void XPLMSetDatavf( + XPLMDataRef inDataRef, + float * inValues, + int inoffset, + int inCount); + +/* + * XPLMGetDatab + * + * Read a part of a byte array dataref. If you pass NULL for outVaules, the + * routine will return the size of the array, ignoring inOffset and inMax. + * + * If outValues is not NULL, then up to inMax values are copied from the + * dataref into outValues, starting at inOffset in the dataref. If inMax + + * inOffset is larger than the size of the dataref, less than inMax values + * will be copied. The number of values copied is returned. + * + * Note: the semantics of array datarefs are entirely implemented by the + * plugin (or X-Plane) that provides the dataref, not the SDK itself; the + * above description is how these datarefs are intended to work, but a rogue + * plugin may have different behavior. + * + */ +XPLM_API int XPLMGetDatab( + XPLMDataRef inDataRef, + void * outValue, /* Can be NULL */ + int inOffset, + int inMaxBytes); + +/* + * XPLMSetDatab + * + * Write part or all of a byte array dataref. The values passed by inValues + * are written into the dataref starting at inOffset. Up to inCount values are + * written; however if the values would write "off the end" of the dataref + * array, then fewer values are written. + * + * Note: the semantics of array datarefs are entirely implemented by the + * plugin (or X-Plane) that provides the dataref, not the SDK itself; the + * above description is how these datarefs are intended to work, but a rogue + * plugin may have different behavior. + * + */ +XPLM_API void XPLMSetDatab( + XPLMDataRef inDataRef, + void * inValue, + int inOffset, + int inLength); + +/*************************************************************************** + * PUBLISHING YOUR PLUGIN'S DATA + ***************************************************************************/ +/* + * These functions allow you to create data references that other plug-ins and + * X-Plane can access via the above data access APIs. Data references + * published by other plugins operate the same as ones published by X-Plane in + * all manners except that your data reference will not be available to other + * plugins if/when your plugin is disabled. + * + * You share data by registering data provider callback functions. When a + * plug-in requests your data, these callbacks are then called. You provide + * one callback to return the value when a plugin 'reads' it and another to + * change the value when a plugin 'writes' it. + * + * Important: you must pick a prefix for your datarefs other than "sim/" - + * this prefix is reserved for X-Plane. The X-Plane SDK website contains a + * registry where authors can select a unique first word for dataref names, to + * prevent dataref collisions between plugins. + * + */ + + +/* + * XPLMGetDatai_f + * + * Data provider function pointers. + * + * These define the function pointers you provide to get or set data. Note + * that you are passed a generic pointer for each one. This is the same + * pointer you pass in your register routine; you can use it to locate plugin + * variables, etc. + * + * The semantics of your callbacks are the same as the dataref accessor above + * - basically routines like XPLMGetDatai are just pass-throughs from a caller + * to your plugin. Be particularly mindful in implementing array dataref + * read-write accessors; you are responsible for avoiding overruns, supporting + * offset read/writes, and handling a read with a NULL buffer. + * + */ +typedef int (* XPLMGetDatai_f)( + void * inRefcon); + +/* + * XPLMSetDatai_f + * + */ +typedef void (* XPLMSetDatai_f)( + void * inRefcon, + int inValue); + +/* + * XPLMGetDataf_f + * + */ +typedef float (* XPLMGetDataf_f)( + void * inRefcon); + +/* + * XPLMSetDataf_f + * + */ +typedef void (* XPLMSetDataf_f)( + void * inRefcon, + float inValue); + +/* + * XPLMGetDatad_f + * + */ +typedef double (* XPLMGetDatad_f)( + void * inRefcon); + +/* + * XPLMSetDatad_f + * + */ +typedef void (* XPLMSetDatad_f)( + void * inRefcon, + double inValue); + +/* + * XPLMGetDatavi_f + * + */ +typedef int (* XPLMGetDatavi_f)( + void * inRefcon, + int * outValues, /* Can be NULL */ + int inOffset, + int inMax); + +/* + * XPLMSetDatavi_f + * + */ +typedef void (* XPLMSetDatavi_f)( + void * inRefcon, + int * inValues, + int inOffset, + int inCount); + +/* + * XPLMGetDatavf_f + * + */ +typedef int (* XPLMGetDatavf_f)( + void * inRefcon, + float * outValues, /* Can be NULL */ + int inOffset, + int inMax); + +/* + * XPLMSetDatavf_f + * + */ +typedef void (* XPLMSetDatavf_f)( + void * inRefcon, + float * inValues, + int inOffset, + int inCount); + +/* + * XPLMGetDatab_f + * + */ +typedef int (* XPLMGetDatab_f)( + void * inRefcon, + void * outValue, /* Can be NULL */ + int inOffset, + int inMaxLength); + +/* + * XPLMSetDatab_f + * + */ +typedef void (* XPLMSetDatab_f)( + void * inRefcon, + void * inValue, + int inOffset, + int inLength); + +/* + * XPLMRegisterDataAccessor + * + * This routine creates a new item of data that can be read and written. Pass + * in the data's full name for searching, the type(s) of the data for + * accessing, and whether the data can be written to. For each data type you + * support, pass in a read accessor function and a write accessor function if + * necessary. Pass NULL for data types you do not support or write accessors + * if you are read-only. + * + * You are returned a data ref for the new item of data created. You can use + * this data ref to unregister your data later or read or write from it. + * + */ +XPLM_API XPLMDataRef XPLMRegisterDataAccessor( + const char * inDataName, + XPLMDataTypeID inDataType, + int inIsWritable, + XPLMGetDatai_f inReadInt, + XPLMSetDatai_f inWriteInt, + XPLMGetDataf_f inReadFloat, + XPLMSetDataf_f inWriteFloat, + XPLMGetDatad_f inReadDouble, + XPLMSetDatad_f inWriteDouble, + XPLMGetDatavi_f inReadIntArray, + XPLMSetDatavi_f inWriteIntArray, + XPLMGetDatavf_f inReadFloatArray, + XPLMSetDatavf_f inWriteFloatArray, + XPLMGetDatab_f inReadData, + XPLMSetDatab_f inWriteData, + void * inReadRefcon, + void * inWriteRefcon); + +/* + * XPLMUnregisterDataAccessor + * + * Use this routine to unregister any data accessors you may have registered. + * You unregister a data ref by the XPLMDataRef you get back from + * registration. Once you unregister a data ref, your function pointer will + * not be called anymore. + * + */ +XPLM_API void XPLMUnregisterDataAccessor( + XPLMDataRef inDataRef); + +/*************************************************************************** + * SHARING DATA BETWEEN MULTIPLE PLUGINS + ***************************************************************************/ +/* + * The data reference registration APIs from the previous section allow a + * plugin to publish data in a one-owner manner; the plugin that publishes the + * data reference owns the real memory that the data ref uses. This is + * satisfactory for most cases, but there are also cases where plugnis need to + * share actual data. + * + * With a shared data reference, no one plugin owns the actual memory for the + * data reference; the plugin SDK allocates that for you. When the first + * plugin asks to 'share' the data, the memory is allocated. When the data is + * changed, every plugin that is sharing the data is notified. + * + * Shared data references differ from the 'owned' data references from the + * previous section in a few ways: + * + * * With shared data references, any plugin can create the data reference; + * with owned plugins one plugin must create the data reference and others + * subscribe. (This can be a problem if you don't know which set of plugins + * will be present). + * + * * With shared data references, every plugin that is sharing the data is + * notified when the data is changed. With owned data references, only the + * one owner is notified when the data is changed. + * + * * With shared data references, you cannot access the physical memory of the + * data reference; you must use the XPLMGet... and XPLMSet... APIs. With an + * owned data reference, the one owning data reference can manipulate the + * data reference's memory in any way it sees fit. + * + * Shared data references solve two problems: if you need to have a data + * reference used by several plugins but do not know which plugins will be + * installed, or if all plugins sharing data need to be notified when that + * data is changed, use shared data references. + * + */ + + +/* + * XPLMDataChanged_f + * + * An XPLMDataChanged_f is a callback that the XPLM calls whenever any other + * plug-in modifies shared data. A refcon you provide is passed back to help + * identify which data is being changed. In response, you may want to call one + * of the XPLMGetDataxxx routines to find the new value of the data. + * + */ +typedef void (* XPLMDataChanged_f)( + void * inRefcon); + +/* + * XPLMShareData + * + * This routine connects a plug-in to shared data, creating the shared data if + * necessary. inDataName is a standard path for the data ref, and inDataType + * specifies the type. This function will create the data if it does not + * exist. If the data already exists but the type does not match, an error is + * returned, so it is important that plug-in authors collaborate to establish + * public standards for shared data. + * + * If a notificationFunc is passed in and is not NULL, that notification + * function will be called whenever the data is modified. The notification + * refcon will be passed to it. This allows your plug-in to know which shared + * data was changed if multiple shared data are handled by one callback, or if + * the plug-in does not use global variables. + * + * A one is returned for successfully creating or finding the shared data; a + * zero if the data already exists but is of the wrong type. + * + */ +XPLM_API int XPLMShareData( + const char * inDataName, + XPLMDataTypeID inDataType, + XPLMDataChanged_f inNotificationFunc, + void * inNotificationRefcon); + +/* + * XPLMUnshareData + * + * This routine removes your notification function for shared data. Call it + * when done with the data to stop receiving change notifications. Arguments + * must match XPLMShareData. The actual memory will not necessarily be freed, + * since other plug-ins could be using it. + * + */ +XPLM_API int XPLMUnshareData( + const char * inDataName, + XPLMDataTypeID inDataType, + XPLMDataChanged_f inNotificationFunc, + void * inNotificationRefcon); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/SDK/CHeaders/XPLM/XPLMDefs.h b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/XPLM/XPLMDefs.h new file mode 100644 index 0000000..2e95b81 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/XPLM/XPLMDefs.h @@ -0,0 +1,514 @@ +#ifndef _XPLMDefs_h_ +#define _XPLMDefs_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPLMDefs + ***************************************************************************/ +/* + * This file is contains the cross-platform and basic definitions for the + * X-Plane SDK. + * + * The preprocessor macros APL and IBM must be defined to specify the + * compilation target; define APL to 1 and IBM 0 to compile on Macintosh and + * APL to 0 and IBM to 1 for Windows. You must specify these macro definitions + * before including XPLMDefs.h or any other XPLM headers. You can do this + * using the -D command line option or a preprocessor header. + * + */ + + +#ifdef __cplusplus +extern "C" { +#endif + +#if IBM +#include +#else +#include +#endif +/*************************************************************************** + * DLL Definitions + ***************************************************************************/ +/* + * These definitions control the importing and exporting of functions within + * the DLL. + * + * You can prefix your five required callbacks with the PLUGIN_API macro to + * declare them as exported C functions. The XPLM_API macro identifies + * functions that are provided to you via the plugin SDK. (Link against + * XPLM.lib to use these functions.) + * + */ + + +#ifdef __cplusplus + #if APL + #if __GNUC__ >= 4 + #define PLUGIN_API extern "C" __attribute__((visibility("default"))) + #elif __MACH__ + #define PLUGIN_API extern "C" + #else + #define PLUGIN_API extern "C" __declspec(dllexport) + #endif + #elif IBM + #define PLUGIN_API extern "C" __declspec(dllexport) + #elif LIN + #if __GNUC__ >= 4 + #define PLUGIN_API extern "C" __attribute__((visibility("default"))) + #else + #define PLUGIN_API extern "C" + #endif + #else + #error "Platform not defined!" + #endif +#else + #if APL + #if __GNUC__ >= 4 + #define PLUGIN_API __attribute__((visibility("default"))) + #elif __MACH__ + #define PLUGIN_API + #else + #define PLUGIN_API __declspec(dllexport) + #endif + #elif IBM + #define PLUGIN_API __declspec(dllexport) + #elif LIN + #if __GNUC__ >= 4 + #define PLUGIN_API __attribute__((visibility("default"))) + #else + #define PLUGIN_API + #endif + #else + #error "Platform not defined!" + #endif +#endif + +#if APL + #if XPLM + #if __GNUC__ >= 4 + #define XPLM_API __attribute__((visibility("default"))) + #elif __MACH__ + #define XPLM_API + #else + #define XPLM_API __declspec(dllexport) + #endif + #else + #define XPLM_API + #endif +#elif IBM + #if XPLM + #define XPLM_API __declspec(dllexport) + #else + #define XPLM_API __declspec(dllimport) + #endif +#elif LIN + #if XPLM + #if __GNUC__ >= 4 + #define XPLM_API __attribute__((visibility("default"))) + #else + #define XPLM_API + #endif + #else + #define XPLM_API + #endif +#else + #error "Platform not defined!" +#endif + +/*************************************************************************** + * GLOBAL DEFINITIONS + ***************************************************************************/ +/* + * These definitions are used in all parts of the SDK. + * + */ + + +/* + * XPLMPluginID + * + * Each plug-in is identified by a unique integer ID. This ID can be used to + * disable or enable a plug-in, or discover what plug-in is 'running' at the + * time. A plug-in ID is unique within the currently running instance of + * X-Plane unless plug-ins are reloaded. Plug-ins may receive a different + * unique ID each time they are loaded. This includes the unloading and + * reloading of plugins that are part of the user's aircraft. + * + * For persistent identification of plug-ins, use XPLMFindPluginBySignature in + * XPLMUtiltiies.h + * + * -1 indicates no plug-in. + * + */ +typedef int XPLMPluginID; + +/* No plugin. */ +#define XPLM_NO_PLUGIN_ID (-1) + +/* X-Plane itself */ +#define XPLM_PLUGIN_XPLANE (0) + +/* The current XPLM revision is 4.00 (400). */ +#define kXPLM_Version (400) + +/* + * XPLMKeyFlags + * + * These bitfields define modifier keys in a platform independent way. When a + * key is pressed, a series of messages are sent to your plugin. The down + * flag is set in the first of these messages, and the up flag in the last. + * While the key is held down, messages are sent with neither to indicate that + * the key is being held down as a repeated character. + * + * The control flag is mapped to the control flag on Macintosh and PC. + * Generally X-Plane uses the control key and not the command key on + * Macintosh, providing a consistent interface across platforms that does not + * necessarily match the Macintosh user interface guidelines. There is not + * yet a way for plugins to access the Macintosh control keys without using + * #ifdefed code. + * + */ +enum { + /* The shift key is down */ + xplm_ShiftFlag = 1, + + /* The option or alt key is down */ + xplm_OptionAltFlag = 2, + + /* The control key is down* */ + xplm_ControlFlag = 4, + + /* The key is being pressed down */ + xplm_DownFlag = 8, + + /* The key is being released */ + xplm_UpFlag = 16, + + +}; +typedef int XPLMKeyFlags; + +/*************************************************************************** + * ASCII CONTROL KEY CODES + ***************************************************************************/ +/* + * These definitions define how various control keys are mapped to ASCII key + * codes. Not all key presses generate an ASCII value, so plugin code should + * be prepared to see null characters come from the keyboard...this usually + * represents a key stroke that has no equivalent ASCII, like a page-down + * press. Use virtual key codes to find these key strokes. + * + * ASCII key codes take into account modifier keys; shift keys will affect + * capitals and punctuation; control key combinations may have no vaild ASCII + * and produce NULL. To detect control-key combinations, use virtual key + * codes, not ASCII keys. + * + */ + + +#define XPLM_KEY_RETURN 13 + +#define XPLM_KEY_ESCAPE 27 + +#define XPLM_KEY_TAB 9 + +#define XPLM_KEY_DELETE 8 + +#define XPLM_KEY_LEFT 28 + +#define XPLM_KEY_RIGHT 29 + +#define XPLM_KEY_UP 30 + +#define XPLM_KEY_DOWN 31 + +#define XPLM_KEY_0 48 + +#define XPLM_KEY_1 49 + +#define XPLM_KEY_2 50 + +#define XPLM_KEY_3 51 + +#define XPLM_KEY_4 52 + +#define XPLM_KEY_5 53 + +#define XPLM_KEY_6 54 + +#define XPLM_KEY_7 55 + +#define XPLM_KEY_8 56 + +#define XPLM_KEY_9 57 + +#define XPLM_KEY_DECIMAL 46 + +/*************************************************************************** + * VIRTUAL KEY CODES + ***************************************************************************/ +/* + * These are cross-platform defines for every distinct keyboard press on the + * computer. Every physical key on the keyboard has a virtual key code. So + * the "two" key on the top row of the main keyboard has a different code from + * the "two" key on the numeric key pad. But the 'w' and 'W' character are + * indistinguishable by virtual key code because they are the same physical + * key (one with and one without the shift key). + * + * Use virtual key codes to detect keystrokes that do not have ASCII + * equivalents, allow the user to map the numeric keypad separately from the + * main keyboard, and detect control key and other modifier-key combinations + * that generate ASCII control key sequences (many of which are not available + * directly via character keys in the SDK). + * + * To assign virtual key codes we started with the Microsoft set but made some + * additions and changes. A few differences: + * + * 1. Modifier keys are not available as virtual key codes. You cannot get + * distinct modifier press and release messages. Please do not try to use + * modifier keys as regular keys; doing so will almost certainly interfere + * with users' abilities to use the native X-Plane key bindings. + * 2. Some keys that do not exist on both Mac and PC keyboards are removed. + * 3. Do not assume that the values of these keystrokes are interchangeable + * with MS v-keys. + * + */ + + +#define XPLM_VK_BACK 0x08 + +#define XPLM_VK_TAB 0x09 + +#define XPLM_VK_CLEAR 0x0C + +#define XPLM_VK_RETURN 0x0D + +#define XPLM_VK_ESCAPE 0x1B + +#define XPLM_VK_SPACE 0x20 + +#define XPLM_VK_PRIOR 0x21 + +#define XPLM_VK_NEXT 0x22 + +#define XPLM_VK_END 0x23 + +#define XPLM_VK_HOME 0x24 + +#define XPLM_VK_LEFT 0x25 + +#define XPLM_VK_UP 0x26 + +#define XPLM_VK_RIGHT 0x27 + +#define XPLM_VK_DOWN 0x28 + +#define XPLM_VK_SELECT 0x29 + +#define XPLM_VK_PRINT 0x2A + +#define XPLM_VK_EXECUTE 0x2B + +#define XPLM_VK_SNAPSHOT 0x2C + +#define XPLM_VK_INSERT 0x2D + +#define XPLM_VK_DELETE 0x2E + +#define XPLM_VK_HELP 0x2F + +/* XPLM_VK_0 thru XPLM_VK_9 are the same as ASCII '0' thru '9' (0x30 - 0x39) */ +#define XPLM_VK_0 0x30 + +#define XPLM_VK_1 0x31 + +#define XPLM_VK_2 0x32 + +#define XPLM_VK_3 0x33 + +#define XPLM_VK_4 0x34 + +#define XPLM_VK_5 0x35 + +#define XPLM_VK_6 0x36 + +#define XPLM_VK_7 0x37 + +#define XPLM_VK_8 0x38 + +#define XPLM_VK_9 0x39 + +/* XPLM_VK_A thru XPLM_VK_Z are the same as ASCII 'A' thru 'Z' (0x41 - 0x5A) */ +#define XPLM_VK_A 0x41 + +#define XPLM_VK_B 0x42 + +#define XPLM_VK_C 0x43 + +#define XPLM_VK_D 0x44 + +#define XPLM_VK_E 0x45 + +#define XPLM_VK_F 0x46 + +#define XPLM_VK_G 0x47 + +#define XPLM_VK_H 0x48 + +#define XPLM_VK_I 0x49 + +#define XPLM_VK_J 0x4A + +#define XPLM_VK_K 0x4B + +#define XPLM_VK_L 0x4C + +#define XPLM_VK_M 0x4D + +#define XPLM_VK_N 0x4E + +#define XPLM_VK_O 0x4F + +#define XPLM_VK_P 0x50 + +#define XPLM_VK_Q 0x51 + +#define XPLM_VK_R 0x52 + +#define XPLM_VK_S 0x53 + +#define XPLM_VK_T 0x54 + +#define XPLM_VK_U 0x55 + +#define XPLM_VK_V 0x56 + +#define XPLM_VK_W 0x57 + +#define XPLM_VK_X 0x58 + +#define XPLM_VK_Y 0x59 + +#define XPLM_VK_Z 0x5A + +#define XPLM_VK_NUMPAD0 0x60 + +#define XPLM_VK_NUMPAD1 0x61 + +#define XPLM_VK_NUMPAD2 0x62 + +#define XPLM_VK_NUMPAD3 0x63 + +#define XPLM_VK_NUMPAD4 0x64 + +#define XPLM_VK_NUMPAD5 0x65 + +#define XPLM_VK_NUMPAD6 0x66 + +#define XPLM_VK_NUMPAD7 0x67 + +#define XPLM_VK_NUMPAD8 0x68 + +#define XPLM_VK_NUMPAD9 0x69 + +#define XPLM_VK_MULTIPLY 0x6A + +#define XPLM_VK_ADD 0x6B + +#define XPLM_VK_SEPARATOR 0x6C + +#define XPLM_VK_SUBTRACT 0x6D + +#define XPLM_VK_DECIMAL 0x6E + +#define XPLM_VK_DIVIDE 0x6F + +#define XPLM_VK_F1 0x70 + +#define XPLM_VK_F2 0x71 + +#define XPLM_VK_F3 0x72 + +#define XPLM_VK_F4 0x73 + +#define XPLM_VK_F5 0x74 + +#define XPLM_VK_F6 0x75 + +#define XPLM_VK_F7 0x76 + +#define XPLM_VK_F8 0x77 + +#define XPLM_VK_F9 0x78 + +#define XPLM_VK_F10 0x79 + +#define XPLM_VK_F11 0x7A + +#define XPLM_VK_F12 0x7B + +#define XPLM_VK_F13 0x7C + +#define XPLM_VK_F14 0x7D + +#define XPLM_VK_F15 0x7E + +#define XPLM_VK_F16 0x7F + +#define XPLM_VK_F17 0x80 + +#define XPLM_VK_F18 0x81 + +#define XPLM_VK_F19 0x82 + +#define XPLM_VK_F20 0x83 + +#define XPLM_VK_F21 0x84 + +#define XPLM_VK_F22 0x85 + +#define XPLM_VK_F23 0x86 + +#define XPLM_VK_F24 0x87 + +/* The following definitions are extended and are not based on the Microsoft * + * key set. */ +#define XPLM_VK_EQUAL 0xB0 + +#define XPLM_VK_MINUS 0xB1 + +#define XPLM_VK_RBRACE 0xB2 + +#define XPLM_VK_LBRACE 0xB3 + +#define XPLM_VK_QUOTE 0xB4 + +#define XPLM_VK_SEMICOLON 0xB5 + +#define XPLM_VK_BACKSLASH 0xB6 + +#define XPLM_VK_COMMA 0xB7 + +#define XPLM_VK_SLASH 0xB8 + +#define XPLM_VK_PERIOD 0xB9 + +#define XPLM_VK_BACKQUOTE 0xBA + +#define XPLM_VK_ENTER 0xBB + +#define XPLM_VK_NUMPAD_ENT 0xBC + +#define XPLM_VK_NUMPAD_EQ 0xBD + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/SDK/CHeaders/XPLM/XPLMDisplay.h b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/XPLM/XPLMDisplay.h new file mode 100644 index 0000000..db5006d --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/XPLM/XPLMDisplay.h @@ -0,0 +1,1658 @@ +#ifndef _XPLMDisplay_h_ +#define _XPLMDisplay_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPLMDisplay + ***************************************************************************/ +/* + * This API provides the basic hooks to draw in X-Plane and create user + * interface. All X-Plane drawing is done in OpenGL. The X-Plane plug-in + * manager takes care of properly setting up the OpenGL context and matrices. + * You do not decide when in your code's execution to draw; X-Plane tells you + * (via callbacks) when it is ready to have your plugin draw. + * + * X-Plane's drawing strategy is straightforward: every "frame" the screen is + * rendered by drawing the 3-D scene (dome, ground, objects, airplanes, etc.) + * and then drawing the cockpit on top of it. Alpha blending is used to + * overlay the cockpit over the world (and the gauges over the panel, etc.). + * X-Plane user interface elements (including windows like the map, the main + * menu, etc.) are then drawn on top of the cockpit. + * + * There are two ways you can draw: directly and in a window. + * + * Direct drawing (deprecated!---more on that below) involves drawing to the + * screen before or after X-Plane finishes a phase of drawing. When you draw + * directly, you can specify whether X-Plane is to complete this phase or not. + * This allows you to do three things: draw before X-Plane does (under it), + * draw after X-Plane does (over it), or draw instead of X-Plane. + * + * To draw directly, you register a callback and specify which phase you want + * to intercept. The plug-in manager will call you over and over to draw that + * phase. + * + * Direct drawing allows you to override scenery, panels, or anything. Note + * that you cannot assume that you are the only plug-in drawing at this phase. + * + * Direct drawing is deprecated; at some point in the X-Plane 11 run, it will + * likely become unsupported entirely as X-Plane transitions from OpenGL to + * modern graphics API backends (e.g., Vulkan, Metal, etc.). In the long term, + * plugins should use the XPLMInstance API for drawing 3-D objects---this will + * be much more efficient than general 3-D OpenGL drawing, and it will + * actually be supported by the new graphics backends. We do not yet know what + * the post-transition API for generic 3-D drawing will look like (if it + * exists at all). + * + * In contrast to direct drawing, window drawing provides a higher level + * functionality. With window drawing, you create a 2-D window that takes up a + * portion of the screen. Window drawing is always two dimensional. Window + * drawing is front-to-back controlled; you can specify that you want your + * window to be brought on top, and other plug-ins may put their window on top + * of you. Window drawing also allows you to sign up for key presses and + * receive mouse clicks. + * + * Drawing into the screen of an avionics device, like a GPS or a Primary + * Flight Display, is a way to extend or replace X-Plane's avionics. Most + * screens can be displayed both in a 3d cockpit or + * 2d panel, and also in separate popup windows. By installing drawing + * callbacks for a certain avionics device, you can change or extend the + * appearance of that device regardless whether it's installed in a 3d + * cockpit or used in a separate display for home cockpits because you leave + * the window managing to X-Plane. + * + * There are three ways to get keystrokes: + * + * 1. If you create a window, the window can take keyboard focus. It will + * then receive all keystrokes. If no window has focus, X-Plane receives + * keystrokes. Use this to implement typing in dialog boxes, etc. Only + * one window may have focus at a time; your window will be notified if it + * loses focus. + * 2. If you need low level access to the keystroke stream, install a key + * sniffer. Key sniffers can be installed above everything or right in + * front of the sim. + * 3. If you would like to associate key strokes with commands/functions in + * your plug-in, you should simply register a command (via + * XPLMCreateCommand()) and allow users to bind whatever key they choose to + * that command. Another (now deprecated) method of doing so is to use a + * hot key---a key-specific callback. Hotkeys are sent based on virtual + * key strokes, so any key may be distinctly mapped with any modifiers. + * Hot keys can be remapped by other plug-ins. As a plug-in, you don't + * have to worry about what your hot key ends up mapped to; other plug-ins + * may provide a UI for remapping keystrokes. So hotkeys allow a user to + * resolve conflicts and customize keystrokes. + * + */ + +#include "XPLMDefs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*************************************************************************** + * DRAWING CALLBACKS + ***************************************************************************/ +/* + * Basic drawing callbacks, for low level intercepting of X-Plane's render + * loop. The purpose of drawing callbacks is to provide targeted additions or + * replacements to X-Plane's graphics environment (for example, to add extra + * custom objects, or replace drawing of the AI aircraft). Do not assume that + * the drawing callbacks will be called in the order implied by the + * enumerations. Also do not assume that each drawing phase ends before + * another begins; they may be nested. + * + * Note that all APIs in this section are deprecated, and will likely be + * removed during the X-Plane 11 run as part of the transition to + * Vulkan/Metal/etc. See the XPLMInstance API for future-proof drawing of 3-D + * objects. + * + */ + + +/* + * XPLMDrawingPhase + * + * This constant indicates which part of drawing we are in. Drawing is done + * from the back to the front. We get a callback before or after each item. + * Metaphases provide access to the beginning and end of the 3d (scene) and + * 2d (cockpit) drawing in a manner that is independent of new phases added + * via X-Plane implementation. + * + * **NOTE**: As of XPLM302 the legacy 3D drawing phases (xplm_Phase_FirstScene + * to xplm_Phase_LastScene) are deprecated. When running under X-Plane 11.50 + * with the modern Vulkan or Metal backend, X-Plane will no longer call + * these drawing phases. There is a new drawing phase, xplm_Phase_Modern3D, + * which is supported under OpenGL and Vulkan which is called out roughly + * where the old before xplm_Phase_Airplanes phase was for blending. This + * phase is *NOT* supported under Metal and comes with potentially + * substantial performance overhead. Please do *NOT* opt into this phase if + * you don't do any actual drawing that requires the depth buffer in some + * way! + * + * **WARNING**: As X-Plane's scenery evolves, some drawing phases may cease to + * exist and new ones may be invented. If you need a particularly specific + * use of these codes, consult Austin and/or be prepared to revise your code + * as X-Plane evolves. + * + */ +enum { +#if defined(XPLM_DEPRECATED) + /* Deprecated as of XPLM302. This is the earliest point at which you can draw * + * in 3-d. */ + xplm_Phase_FirstScene = 0, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated as of XPLM302. Drawing of land and water. */ + xplm_Phase_Terrain = 5, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated as of XPLM302. Drawing runways and other airport detail. */ + xplm_Phase_Airports = 10, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated as of XPLM302. Drawing roads, trails, trains, etc. */ + xplm_Phase_Vectors = 15, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated as of XPLM302. 3-d objects (houses, smokestacks, etc. */ + xplm_Phase_Objects = 20, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated as of XPLM302. External views of airplanes, both yours and the * + * AI aircraft. */ + xplm_Phase_Airplanes = 25, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated as of XPLM302. This is the last point at which you can draw in * + * 3-d. */ + xplm_Phase_LastScene = 30, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM302) + /* A chance to do modern 3D drawing. */ + xplm_Phase_Modern3D = 31, + +#endif /* XPLM302 */ + /* This is the first phase where you can draw in 2-d. */ + xplm_Phase_FirstCockpit = 35, + + /* The non-moving parts of the aircraft panel. */ + xplm_Phase_Panel = 40, + + /* The moving parts of the aircraft panel. */ + xplm_Phase_Gauges = 45, + + /* Floating windows from plugins. */ + xplm_Phase_Window = 50, + + /* The last chance to draw in 2d. */ + xplm_Phase_LastCockpit = 55, + +#if defined(XPLM200) + /* Removed as of XPLM300; Use the full-blown XPLMMap API instead. */ + xplm_Phase_LocalMap3D = 100, + +#endif /* XPLM200 */ +#if defined(XPLM200) + /* Removed as of XPLM300; Use the full-blown XPLMMap API instead. */ + xplm_Phase_LocalMap2D = 101, + +#endif /* XPLM200 */ +#if defined(XPLM200) + /* Removed as of XPLM300; Use the full-blown XPLMMap API instead. */ + xplm_Phase_LocalMapProfile = 102, + +#endif /* XPLM200 */ + +}; +typedef int XPLMDrawingPhase; + +/* + * XPLMDrawCallback_f + * + * This is the prototype for a low level drawing callback. You are passed in + * the phase and whether it is before or after. If you are before the phase, + * return 1 to let X-Plane draw or 0 to suppress X-Plane drawing. If you are + * after the phase the return value is ignored. + * + * Refcon is a unique value that you specify when registering the callback, + * allowing you to slip a pointer to your own data to the callback. + * + * Upon entry the OpenGL context will be correctly set up for you and OpenGL + * will be in 'local' coordinates for 3d drawing and panel coordinates for 2d + * drawing. The OpenGL state (texturing, etc.) will be unknown. + * + */ +typedef int (* XPLMDrawCallback_f)( + XPLMDrawingPhase inPhase, + int inIsBefore, + void * inRefcon); + +/* + * XPLMRegisterDrawCallback + * + * This routine registers a low level drawing callback. Pass in the phase you + * want to be called for and whether you want to be called before or after. + * This routine returns 1 if the registration was successful, or 0 if the + * phase does not exist in this version of X-Plane. You may register a + * callback multiple times for the same or different phases as long as the + * refcon is unique each time. + * + * Note that this function will likely be removed during the X-Plane 11 run as + * part of the transition to Vulkan/Metal/etc. See the XPLMInstance API for + * future-proof drawing of 3-D objects. + * + */ +XPLM_API int XPLMRegisterDrawCallback( + XPLMDrawCallback_f inCallback, + XPLMDrawingPhase inPhase, + int inWantsBefore, + void * inRefcon); + +/* + * XPLMUnregisterDrawCallback + * + * This routine unregisters a draw callback. You must unregister a callback + * for each time you register a callback if you have registered it multiple + * times with different refcons. The routine returns 1 if it can find the + * callback to unregister, 0 otherwise. + * + * Note that this function will likely be removed during the X-Plane 11 run as + * part of the transition to Vulkan/Metal/etc. See the XPLMInstance API for + * future-proof drawing of 3-D objects. + * + */ +XPLM_API int XPLMUnregisterDrawCallback( + XPLMDrawCallback_f inCallback, + XPLMDrawingPhase inPhase, + int inWantsBefore, + void * inRefcon); + +#if defined(XPLM400) +/*************************************************************************** + * AVIONICS API + ***************************************************************************/ +/* + * Drawing callbacks for before and after X-Plane draws the instrument screen + * can be registered for every cockpit device. If the user plane does not + * have the device installed, your callback will not be called! Use the + * return value to enable or disable X-Plane's drawing. By drawing into the + * framebuffer of the avionics device, your modifications will be visible + * regardless whether the device's screen is in a 3d cockpit or a popup + * window. + * + */ + + +/* + * XPLMDeviceID + * + * This constant indicates the device we want to override or enhance. We can + * get a callback before or after each item. + * + */ +enum { + /* GNS430, pilot side. */ + xplm_device_GNS430_1 = 0, + + /* GNS430, copilot side. */ + xplm_device_GNS430_2 = 1, + + /* GNS530, pilot side. */ + xplm_device_GNS530_1 = 2, + + /* GNS530, copilot side. */ + xplm_device_GNS530_2 = 3, + + /* generic airliner CDU, pilot side. */ + xplm_device_CDU739_1 = 4, + + /* generic airliner CDU, copilot side. */ + xplm_device_CDU739_2 = 5, + + /* G1000 Primary Flight Display, pilot side. */ + xplm_device_G1000_PFD_1 = 6, + + /* G1000 Multifunction Display. */ + xplm_device_G1000_MFD = 7, + + /* G1000 Primary Flight Display, copilot side. */ + xplm_device_G1000_PFD_2 = 8, + + /* Primus CDU, pilot side. */ + xplm_device_CDU815_1 = 9, + + /* Primus CDU, copilot side. */ + xplm_device_CDU815_2 = 10, + + /* Primus Primary Flight Display, pilot side. */ + xplm_device_Primus_PFD_1 = 11, + + /* Primus Primary Flight Display, copilot side. */ + xplm_device_Primus_PFD_2 = 12, + + /* Primus Multifunction Display, pilot side. */ + xplm_device_Primus_MFD_1 = 13, + + /* Primus Multifunction Display, copilot side. */ + xplm_device_Primus_MFD_2 = 14, + + /* Primus Multifunction Display, central. */ + xplm_device_Primus_MFD_3 = 15, + + /* Primus Radio Management Unit, pilot side. */ + xplm_device_Primus_RMU_1 = 16, + + /* Primus Radio Management Unit, copilot side. */ + xplm_device_Primus_RMU_2 = 17, + + +}; +typedef int XPLMDeviceID; + +/* + * XPLMAvionicsCallback_f + * + * This is the prototype for your drawing callback. You are passed in the + * device you are enhancing/replacing, and whether it is before or after + * X-Plane drawing. If you are before X-Plane, return 1 to let X-Plane draw or + * 0 to suppress X-Plane drawing. If you are after the phase the return value + * is ignored. + * + * Refcon is a unique value that you specify when registering the callback, + * allowing you to slip a pointer to your own data to the callback. + * + * Upon entry the OpenGL context will be correctly set up for you and OpenGL + * will be in panel coordinates for 2d drawing. The OpenGL state (texturing, + * etc.) will be unknown. + * + */ +typedef int (* XPLMAvionicsCallback_f)( + XPLMDeviceID inDeviceID, + int inIsBefore, + void * inRefcon); + +/* + * XPLMAvionicsID + * + * This is an opaque identifier for an avionics display that you enhance or + * replace. When you register your callbacks (via + * XPLMRegisterAvionicsCallbacksEx()), you will specify callbacks to handle + * drawing, and get back such a handle. + * + */ +typedef void * XPLMAvionicsID; + +/* + * XPLMCustomizeAvionics_t + * + * The XPLMCustomizeAvionics_t structure defines all of the parameters used to + * replace or enhance avionics for using XPLMRegisterAvionicsCallbacksEx(). + * The structure will be expanded in future SDK APIs to include more features. + * Always set the structSize member to the size of your struct in bytes! + * + */ +typedef struct { + /* Used to inform XPLMRegisterAvionicsCallbacksEx() of the SDK version you * + * compiled against; should always be set to sizeof(XPLMCustomizeAvionics_t) */ + int structSize; + /* Which avionics device you want your drawing applied to. */ + XPLMDeviceID deviceId; + /* The draw callback to be called before X-Plane draws. */ + XPLMAvionicsCallback_f drawCallbackBefore; + /* The draw callback to be called after X-Plane has drawn. */ + XPLMAvionicsCallback_f drawCallbackAfter; + /* A reference which will be passed into each of your draw callbacks. Use this* + * to pass information to yourself as needed. */ + void * refcon; +} XPLMCustomizeAvionics_t; + +/* + * XPLMRegisterAvionicsCallbacksEx + * + * This routine registers your callbacks for a device. This returns a handle. + * If the returned handle is NULL, there was a problem interpreting your + * input, most likely the struct size was wrong for your SDK version. If the + * returned handle is not NULL, your callbacks will be called according to + * schedule as long as your plugin is not deactivated, or unloaded, or your + * call XPLMUnregisterAvionicsCallbacks(). + * + */ +XPLM_API XPLMAvionicsID XPLMRegisterAvionicsCallbacksEx( + XPLMCustomizeAvionics_t * inParams); + +/* + * XPLMUnregisterAvionicsCallbacks + * + * This routine unregisters your callbacks for a device. They will no longer + * be called. + * + */ +XPLM_API void XPLMUnregisterAvionicsCallbacks( + XPLMAvionicsID inAvionicsId); + +#endif /* XPLM400 */ +/*************************************************************************** + * WINDOW API + ***************************************************************************/ +/* + * The window API provides a high-level abstraction for drawing with UI + * interaction. + * + * Windows may operate in one of two modes: legacy (for plugins compiled + * against old versions of the XPLM, as well as windows created via the + * deprecated XPLMCreateWindow() function, rather than XPLMCreateWindowEx()), + * or modern (for windows compiled against the XPLM300 or newer API, and + * created via XPLMCreateWindowEx()). + * + * Modern windows have access to new X-Plane 11 windowing features, like + * support for new positioning modes (including being "popped out" into their + * own first-class window in the operating system). They can also optionally + * be decorated in the style of X-Plane 11 windows (like the map). + * + * Modern windows operate in "boxel" units. A boxel ("box of pixels") is a + * unit of virtual pixels which, depending on X-Plane's scaling, may + * correspond to an arbitrary NxN "box" of real pixels on screen. Because + * X-Plane handles this scaling automatically, you can effectively treat the + * units as though you were simply drawing in pixels, and know that when + * X-Plane is running with 150% or 200% scaling, your drawing will be + * automatically scaled (and likewise all mouse coordinates, screen bounds, + * etc. will also be auto-scaled). + * + * In contrast, legacy windows draw in true screen pixels, and thus tend to + * look quite small when X-Plane is operating in a scaled mode. + * + * Legacy windows have their origin in the lower left of the main X-Plane + * window. In contrast, since modern windows are not constrained to the main + * window, they have their origin in the lower left of the entire global + * desktop space, and the lower left of the main X-Plane window is not + * guaranteed to be (0, 0). In both cases, x increases as you move left, and y + * increases as you move up. + * + */ + + +/* + * XPLMWindowID + * + * This is an opaque identifier for a window. You use it to control your + * window. When you create a window (via either XPLMCreateWindow() or + * XPLMCreateWindowEx()), you will specify callbacks to handle drawing, mouse + * interaction, etc. + * + */ +typedef void * XPLMWindowID; + +/* + * XPLMDrawWindow_f + * + * A callback to handle 2-D drawing of your window. You are passed in your + * window and its refcon. Draw the window. You can use other XPLM functions + * from this header to find the current dimensions of your window, etc. When + * this callback is called, the OpenGL context will be set properly for 2-D + * window drawing. + * + * **Note**: Because you are drawing your window over a background, you can + * make a translucent window easily by simply not filling in your entire + * window's bounds. + * + */ +typedef void (* XPLMDrawWindow_f)( + XPLMWindowID inWindowID, + void * inRefcon); + +/* + * XPLMHandleKey_f + * + * This function is called when a key is pressed or keyboard focus is taken + * away from your window. If losingFocus is 1, you are losing the keyboard + * focus, otherwise a key was pressed and inKey contains its character. + * + * The window ID passed in will be your window for key presses, or the other + * window taking focus when losing focus. Note that in the modern plugin + * system, often focus is taken by the window manager itself; for this resaon, + * the window ID may be zero when losing focus, and you should not write code + * that depends onit. + * + * The refcon passed in will be the one from registration, for both key + * presses and losing focus. + * + * Warning: this API declares virtual keys as a signed character; however the + * VKEY #define macros in XPLMDefs.h define the vkeys using unsigned values + * (that is 0x80 instead of -0x80). So you may need to cast the incoming vkey + * to an unsigned char to get correct comparisons in C. + * + */ +typedef void (* XPLMHandleKey_f)( + XPLMWindowID inWindowID, + char inKey, + XPLMKeyFlags inFlags, + char inVirtualKey, + void * inRefcon, + int losingFocus); + +/* + * XPLMMouseStatus + * + * When the mouse is clicked, your mouse click routine is called repeatedly. + * It is first called with the mouse down message. It is then called zero or + * more times with the mouse-drag message, and finally it is called once with + * the mouse up message. All of these messages will be directed to the same + * window; you are guaranteed to not receive a drag or mouse-up event without + * first receiving the corresponding mouse-down. + * + */ +enum { + xplm_MouseDown = 1, + + xplm_MouseDrag = 2, + + xplm_MouseUp = 3, + + +}; +typedef int XPLMMouseStatus; + +/* + * XPLMHandleMouseClick_f + * + * You receive this call for one of three events: + * + * - when the user clicks the mouse button down + * - (optionally) when the user drags the mouse after a down-click, but before + * the up-click + * - when the user releases the down-clicked mouse button. + * + * You receive the x and y of the click, your window, and a refcon. Return 1 + * to consume the click, or 0 to pass it through. + * + * WARNING: passing clicks through windows (as of this writing) causes mouse + * tracking problems in X-Plane; do not use this feature! + * + * The units for x and y values match the units used in your window. Thus, for + * "modern" windows (those created via XPLMCreateWindowEx() and compiled + * against the XPLM300 library), the units are boxels, while legacy windows + * will get pixels. Legacy windows have their origin in the lower left of the + * main X-Plane window, while modern windows have their origin in the lower + * left of the global desktop space. In both cases, x increases as you move + * right, and y increases as you move up. + * + */ +typedef int (* XPLMHandleMouseClick_f)( + XPLMWindowID inWindowID, + int x, + int y, + XPLMMouseStatus inMouse, + void * inRefcon); + +#if defined(XPLM200) +/* + * XPLMCursorStatus + * + * XPLMCursorStatus describes how you would like X-Plane to manage the cursor. + * See XPLMHandleCursor_f for more info. + * + */ +enum { + /* X-Plane manages the cursor normally, plugin does not affect the cusrsor. */ + xplm_CursorDefault = 0, + + /* X-Plane hides the cursor. */ + xplm_CursorHidden = 1, + + /* X-Plane shows the cursor as the default arrow. */ + xplm_CursorArrow = 2, + + /* X-Plane shows the cursor but lets you select an OS cursor. */ + xplm_CursorCustom = 3, + + +}; +typedef int XPLMCursorStatus; +#endif /* XPLM200 */ + +#if defined(XPLM200) +/* + * XPLMHandleCursor_f + * + * The SDK calls your cursor status callback when the mouse is over your + * plugin window. Return a cursor status code to indicate how you would like + * X-Plane to manage the cursor. If you return xplm_CursorDefault, the SDK + * will try lower-Z-order plugin windows, then let the sim manage the cursor. + * + * Note: you should never show or hide the cursor yourself---these APIs are + * typically reference-counted and thus cannot safely and predictably be used + * by the SDK. Instead return one of xplm_CursorHidden to hide the cursor or + * xplm_CursorArrow/xplm_CursorCustom to show the cursor. + * + * If you want to implement a custom cursor by drawing a cursor in OpenGL, use + * xplm_CursorHidden to hide the OS cursor and draw the cursor using a 2-d + * drawing callback (after xplm_Phase_Window is probably a good choice, but + * see deprecation warnings on the drawing APIs!). If you want to use a + * custom OS-based cursor, use xplm_CursorCustom to ask X-Plane to show the + * cursor but not affect its image. You can then use an OS specific call like + * SetThemeCursor (Mac) or SetCursor/LoadCursor (Windows). + * + * The units for x and y values match the units used in your window. Thus, for + * "modern" windows (those created via XPLMCreateWindowEx() and compiled + * against the XPLM300 library), the units are boxels, while legacy windows + * will get pixels. Legacy windows have their origin in the lower left of the + * main X-Plane window, while modern windows have their origin in the lower + * left of the global desktop space. In both cases, x increases as you move + * right, and y increases as you move up. + * + */ +typedef XPLMCursorStatus (* XPLMHandleCursor_f)( + XPLMWindowID inWindowID, + int x, + int y, + void * inRefcon); +#endif /* XPLM200 */ + +#if defined(XPLM200) +/* + * XPLMHandleMouseWheel_f + * + * The SDK calls your mouse wheel callback when one of the mouse wheels is + * scrolled within your window. Return 1 to consume the mouse wheel movement + * or 0 to pass them on to a lower window. (If your window appears opaque to + * the user, you should consume mouse wheel scrolling even if it does + * nothing.) The number of "clicks" indicates how far the wheel was turned + * since the last callback. The wheel is 0 for the vertical axis or 1 for the + * horizontal axis (for OS/mouse combinations that support this). + * + * The units for x and y values match the units used in your window. Thus, for + * "modern" windows (those created via XPLMCreateWindowEx() and compiled + * against the XPLM300 library), the units are boxels, while legacy windows + * will get pixels. Legacy windows have their origin in the lower left of the + * main X-Plane window, while modern windows have their origin in the lower + * left of the global desktop space. In both cases, x increases as you move + * right, and y increases as you move up. + * + */ +typedef int (* XPLMHandleMouseWheel_f)( + XPLMWindowID inWindowID, + int x, + int y, + int wheel, + int clicks, + void * inRefcon); +#endif /* XPLM200 */ + +#if defined(XPLM300) +/* + * XPLMWindowLayer + * + * XPLMWindowLayer describes where in the ordering of windows X-Plane should + * place a particular window. Windows in higher layers cover windows in lower + * layers. So, a given window might be at the top of its particular layer, but + * it might still be obscured by a window in a higher layer. (This happens + * frequently when floating windows, like X-Plane's map, are covered by a + * modal alert.) + * + * Your window's layer can only be specified when you create the window (in + * the XPLMCreateWindow_t you pass to XPLMCreateWindowEx()). For this reason, + * layering only applies to windows created with new X-Plane 11 GUI features. + * (Windows created using the older XPLMCreateWindow(), or windows compiled + * against a pre-XPLM300 version of the SDK will simply be placed in the + * flight overlay window layer.) + * + */ +enum { + /* The lowest layer, used for HUD-like displays while flying. */ + xplm_WindowLayerFlightOverlay = 0, + + /* Windows that "float" over the sim, like the X-Plane 11 map does. If you are* + * not sure which layer to create your window in, choose floating. */ + xplm_WindowLayerFloatingWindows = 1, + + /* An interruptive modal that covers the sim with a transparent black overlay * + * to draw the user's focus to the alert */ + xplm_WindowLayerModal = 2, + + /* "Growl"-style notifications that are visible in a corner of the screen, * + * even over modals */ + xplm_WindowLayerGrowlNotifications = 3, + + +}; +typedef int XPLMWindowLayer; +#endif /* XPLM300 */ + +#if defined(XPLM301) +/* + * XPLMWindowDecoration + * + * XPLMWindowDecoration describes how "modern" windows will be displayed. This + * impacts both how X-Plane draws your window as well as certain mouse + * handlers. + * + * Your window's decoration can only be specified when you create the window + * (in the XPLMCreateWindow_t you pass to XPLMCreateWindowEx()). + * + */ +enum { + /* X-Plane will draw no decoration for your window, and apply no automatic * + * click handlers. The window will not stop click from passing through its * + * bounds. This is suitable for "windows" which request, say, the full screen * + * bounds, then only draw in a small portion of the available area. */ + xplm_WindowDecorationNone = 0, + + /* The default decoration for "native" windows, like the map. Provides a solid* + * background, as well as click handlers for resizing and dragging the window.*/ + xplm_WindowDecorationRoundRectangle = 1, + + /* X-Plane will draw no decoration for your window, nor will it provide resize* + * handlers for your window edges, but it will stop clicks from passing * + * through your windows bounds. */ + xplm_WindowDecorationSelfDecorated = 2, + + /* Like self-decorated, but with resizing; X-Plane will draw no decoration for* + * your window, but it will stop clicks from passing through your windows * + * bounds, and provide automatic mouse handlers for resizing. */ + xplm_WindowDecorationSelfDecoratedResizable = 3, + + +}; +typedef int XPLMWindowDecoration; +#endif /* XPLM301 */ + +#if defined(XPLM200) +/* + * XPLMCreateWindow_t + * + * The XPMCreateWindow_t structure defines all of the parameters used to + * create a modern window using XPLMCreateWindowEx(). The structure will be + * expanded in future SDK APIs to include more features. Always set the + * structSize member to the size of your struct in bytes! + * + * All windows created by this function in the XPLM300 version of the API are + * created with the new X-Plane 11 GUI features. This means your plugin will + * get to "know" about the existence of X-Plane windows other than the main + * window. All drawing and mouse callbacks for your window will occur in + * "boxels," giving your windows automatic support for high-DPI scaling in + * X-Plane. In addition, your windows can opt-in to decoration with the + * X-Plane 11 window styling, and you can use the + * XPLMSetWindowPositioningMode() API to make your window "popped out" into a + * first-class operating system window. + * + * Note that this requires dealing with your window's bounds in "global + * desktop" positioning units, rather than the traditional panel coordinate + * system. In global desktop coordinates, the main X-Plane window may not have + * its origin at coordinate (0, 0), and your own window may have negative + * coordinates. Assuming you don't implicitly assume (0, 0) as your origin, + * the only API change you should need is to start using + * XPLMGetMouseLocationGlobal() rather than XPLMGetMouseLocation(), and + * XPLMGetScreenBoundsGlobal() instead of XPLMGetScreenSize(). + * + * If you ask to be decorated as a floating window, you'll get the blue window + * control bar and blue backing that you see in X-Plane 11's normal "floating" + * windows (like the map). + * + */ +typedef struct { + /* Used to inform XPLMCreateWindowEx() of the SDK version you compiled * + * against; should always be set to sizeof(XPLMCreateWindow_t) */ + int structSize; + /* Left bound, in global desktop boxels */ + int left; + /* Top bound, in global desktop boxels */ + int top; + /* Right bound, in global desktop boxels */ + int right; + /* Bottom bound, in global desktop boxels */ + int bottom; + int visible; + XPLMDrawWindow_f drawWindowFunc; + /* A callback to handle the user left-clicking within your window (or NULL to * + * ignore left clicks) */ + XPLMHandleMouseClick_f handleMouseClickFunc; + XPLMHandleKey_f handleKeyFunc; + XPLMHandleCursor_f handleCursorFunc; + XPLMHandleMouseWheel_f handleMouseWheelFunc; + /* A reference which will be passed into each of your window callbacks. Use * + * this to pass information to yourself as needed. */ + void * refcon; +#if defined(XPLM301) + /* Specifies the type of X-Plane 11-style "wrapper" you want around your * + * window, if any */ + XPLMWindowDecoration decorateAsFloatingWindow; +#endif /* XPLM301 */ +#if defined(XPLM300) + XPLMWindowLayer layer; +#endif /* XPLM300 */ +#if defined(XPLM300) + /* A callback to handle the user right-clicking within your window (or NULL to* + * ignore right clicks) */ + XPLMHandleMouseClick_f handleRightClickFunc; +#endif /* XPLM300 */ +} XPLMCreateWindow_t; +#endif /* XPLM200 */ + +#if defined(XPLM200) +/* + * XPLMCreateWindowEx + * + * This routine creates a new "modern" window. You pass in an + * XPLMCreateWindow_t structure with all of the fields set in. You must set + * the structSize of the structure to the size of the actual structure you + * used. Also, you must provide functions for every callback---you may not + * leave them null! (If you do not support the cursor or mouse wheel, use + * functions that return the default values.) + * + */ +XPLM_API XPLMWindowID XPLMCreateWindowEx( + XPLMCreateWindow_t * inParams); +#endif /* XPLM200 */ + +/* + * XPLMCreateWindow + * + * Deprecated as of XPLM300. + * + * This routine creates a new legacy window. Unlike modern windows (created + * via XPLMCreateWindowEx()), legacy windows do not have access to X-Plane 11 + * features like automatic scaling for high-DPI screens, native window styles, + * or support for being "popped out" into first-class operating system + * windows. + * + * Pass in the dimensions and offsets to the window's bottom left corner from + * the bottom left of the screen. You can specify whether the window is + * initially visible or not. Also, you pass in three callbacks to run the + * window and a refcon. This function returns a window ID you can use to + * refer to the new window. + * + * NOTE: Legacy windows do not have "frames"; you are responsible for drawing + * the background and frame of the window. Higher level libraries have + * routines which make this easy. + * + */ +XPLM_API XPLMWindowID XPLMCreateWindow( + int inLeft, + int inTop, + int inRight, + int inBottom, + int inIsVisible, + XPLMDrawWindow_f inDrawCallback, + XPLMHandleKey_f inKeyCallback, + XPLMHandleMouseClick_f inMouseCallback, + void * inRefcon); + +/* + * XPLMDestroyWindow + * + * This routine destroys a window. The window's callbacks are not called + * after this call. Keyboard focus is removed from the window before + * destroying it. + * + */ +XPLM_API void XPLMDestroyWindow( + XPLMWindowID inWindowID); + +/* + * XPLMGetScreenSize + * + * This routine returns the size of the main X-Plane OpenGL window in pixels. + * This number can be used to get a rough idea of the amount of detail the + * user will be able to see when drawing in 3-d. + * + */ +XPLM_API void XPLMGetScreenSize( + int * outWidth, /* Can be NULL */ + int * outHeight); /* Can be NULL */ + +#if defined(XPLM300) +/* + * XPLMGetScreenBoundsGlobal + * + * This routine returns the bounds of the "global" X-Plane desktop, in boxels. + * Unlike the non-global version XPLMGetScreenSize(), this is multi-monitor + * aware. There are three primary consequences of multimonitor awareness. + * + * First, if the user is running X-Plane in full-screen on two or more + * monitors (typically configured using one full-screen window per monitor), + * the global desktop will be sized to include all X-Plane windows. + * + * Second, the origin of the screen coordinates is not guaranteed to be (0, + * 0). Suppose the user has two displays side-by-side, both running at 1080p. + * Suppose further that they've configured their OS to make the left display + * their "primary" monitor, and that X-Plane is running in full-screen on + * their right monitor only. In this case, the global desktop bounds would be + * the rectangle from (1920, 0) to (3840, 1080). If the user later asked + * X-Plane to draw on their primary monitor as well, the bounds would change + * to (0, 0) to (3840, 1080). + * + * Finally, if the usable area of the virtual desktop is not a perfect + * rectangle (for instance, because the monitors have different resolutions or + * because one monitor is configured in the operating system to be above and + * to the right of the other), the global desktop will include any wasted + * space. Thus, if you have two 1080p monitors, and monitor 2 is configured to + * have its bottom left touch monitor 1's upper right, your global desktop + * area would be the rectangle from (0, 0) to (3840, 2160). + * + * Note that popped-out windows (windows drawn in their own operating system + * windows, rather than "floating" within X-Plane) are not included in these + * bounds. + * + */ +XPLM_API void XPLMGetScreenBoundsGlobal( + int * outLeft, /* Can be NULL */ + int * outTop, /* Can be NULL */ + int * outRight, /* Can be NULL */ + int * outBottom); /* Can be NULL */ +#endif /* XPLM300 */ + +#if defined(XPLM300) +/* + * XPLMReceiveMonitorBoundsGlobal_f + * + * This function is informed of the global bounds (in boxels) of a particular + * monitor within the X-Plane global desktop space. Note that X-Plane must be + * running in full screen on a monitor in order for that monitor to be passed + * to you in this callback. + * + */ +typedef void (* XPLMReceiveMonitorBoundsGlobal_f)( + int inMonitorIndex, + int inLeftBx, + int inTopBx, + int inRightBx, + int inBottomBx, + void * inRefcon); +#endif /* XPLM300 */ + +#if defined(XPLM300) +/* + * XPLMGetAllMonitorBoundsGlobal + * + * This routine immediately calls you back with the bounds (in boxels) of each + * full-screen X-Plane window within the X-Plane global desktop space. Note + * that if a monitor is *not* covered by an X-Plane window, you cannot get its + * bounds this way. Likewise, monitors with only an X-Plane window (not in + * full-screen mode) will not be included. + * + * If X-Plane is running in full-screen and your monitors are of the same size + * and configured contiguously in the OS, then the combined global bounds of + * all full-screen monitors will match the total global desktop bounds, as + * returned by XPLMGetScreenBoundsGlobal(). (Of course, if X-Plane is running + * in windowed mode, this will not be the case. Likewise, if you have + * differently sized monitors, the global desktop space will include wasted + * space.) + * + * Note that this function's monitor indices match those provided by + * XPLMGetAllMonitorBoundsOS(), but the coordinates are different (since the + * X-Plane global desktop may not match the operating system's global desktop, + * and one X-Plane boxel may be larger than one pixel due to 150% or 200% + * scaling). + * + */ +XPLM_API void XPLMGetAllMonitorBoundsGlobal( + XPLMReceiveMonitorBoundsGlobal_f inMonitorBoundsCallback, + void * inRefcon); +#endif /* XPLM300 */ + +#if defined(XPLM300) +/* + * XPLMReceiveMonitorBoundsOS_f + * + * This function is informed of the global bounds (in pixels) of a particular + * monitor within the operating system's global desktop space. Note that a + * monitor index being passed to you here does not indicate that X-Plane is + * running in full screen on this monitor, or even that any X-Plane windows + * exist on this monitor. + * + */ +typedef void (* XPLMReceiveMonitorBoundsOS_f)( + int inMonitorIndex, + int inLeftPx, + int inTopPx, + int inRightPx, + int inBottomPx, + void * inRefcon); +#endif /* XPLM300 */ + +#if defined(XPLM300) +/* + * XPLMGetAllMonitorBoundsOS + * + * This routine immediately calls you back with the bounds (in pixels) of each + * monitor within the operating system's global desktop space. Note that + * unlike XPLMGetAllMonitorBoundsGlobal(), this may include monitors that have + * no X-Plane window on them. + * + * Note that this function's monitor indices match those provided by + * XPLMGetAllMonitorBoundsGlobal(), but the coordinates are different (since + * the X-Plane global desktop may not match the operating system's global + * desktop, and one X-Plane boxel may be larger than one pixel). + * + */ +XPLM_API void XPLMGetAllMonitorBoundsOS( + XPLMReceiveMonitorBoundsOS_f inMonitorBoundsCallback, + void * inRefcon); +#endif /* XPLM300 */ + +/* + * XPLMGetMouseLocation + * + * Deprecated in XPLM300. Modern windows should use + * XPLMGetMouseLocationGlobal() instead. + * + * This routine returns the current mouse location in pixels relative to the + * main X-Plane window. The bottom left corner of the main window is (0, 0). + * Pass NULL to not receive info about either parameter. + * + * Because this function gives the mouse position relative to the main X-Plane + * window (rather than in global bounds), this function should only be used by + * legacy windows. Modern windows should instead get the mouse position in + * global desktop coordinates using XPLMGetMouseLocationGlobal(). + * + * Note that unlike XPLMGetMouseLocationGlobal(), if the mouse goes outside + * the user's main monitor (for instance, to a pop out window or a secondary + * monitor), this function will not reflect it. + * + */ +XPLM_API void XPLMGetMouseLocation( + int * outX, /* Can be NULL */ + int * outY); /* Can be NULL */ + +#if defined(XPLM300) +/* + * XPLMGetMouseLocationGlobal + * + * Returns the current mouse location in global desktop boxels. Unlike + * XPLMGetMouseLocation(), the bottom left of the main X-Plane window is not + * guaranteed to be (0, 0)---instead, the origin is the lower left of the + * entire global desktop space. In addition, this routine gives the real mouse + * location when the mouse goes to X-Plane windows other than the primary + * display. Thus, it can be used with both pop-out windows and secondary + * monitors. + * + * This is the mouse location function to use with modern windows (i.e., those + * created by XPLMCreateWindowEx()). + * + * Pass NULL to not receive info about either parameter. + * + */ +XPLM_API void XPLMGetMouseLocationGlobal( + int * outX, /* Can be NULL */ + int * outY); /* Can be NULL */ +#endif /* XPLM300 */ + +/* + * XPLMGetWindowGeometry + * + * This routine returns the position and size of a window. The units and + * coordinate system vary depending on the type of window you have. + * + * If this is a legacy window (one compiled against a pre-XPLM300 version of + * the SDK, or an XPLM300 window that was not created using + * XPLMCreateWindowEx()), the units are pixels relative to the main X-Plane + * display. + * + * If, on the other hand, this is a new X-Plane 11-style window (compiled + * against the XPLM300 SDK and created using XPLMCreateWindowEx()), the units + * are global desktop boxels. + * + * Pass NULL to not receive any paramter. + * + */ +XPLM_API void XPLMGetWindowGeometry( + XPLMWindowID inWindowID, + int * outLeft, /* Can be NULL */ + int * outTop, /* Can be NULL */ + int * outRight, /* Can be NULL */ + int * outBottom); /* Can be NULL */ + +/* + * XPLMSetWindowGeometry + * + * This routine allows you to set the position and size of a window. + * + * The units and coordinate system match those of XPLMGetWindowGeometry(). + * That is, modern windows use global desktop boxel coordinates, while legacy + * windows use pixels relative to the main X-Plane display. + * + * Note that this only applies to "floating" windows (that is, windows that + * are drawn within the X-Plane simulation windows, rather than being "popped + * out" into their own first-class operating system windows). To set the + * position of windows whose positioning mode is xplm_WindowPopOut, you'll + * need to instead use XPLMSetWindowGeometryOS(). + * + */ +XPLM_API void XPLMSetWindowGeometry( + XPLMWindowID inWindowID, + int inLeft, + int inTop, + int inRight, + int inBottom); + +#if defined(XPLM300) +/* + * XPLMGetWindowGeometryOS + * + * This routine returns the position and size of a "popped out" window (i.e., + * a window whose positioning mode is xplm_WindowPopOut), in operating system + * pixels. Pass NULL to not receive any parameter. + * + */ +XPLM_API void XPLMGetWindowGeometryOS( + XPLMWindowID inWindowID, + int * outLeft, /* Can be NULL */ + int * outTop, /* Can be NULL */ + int * outRight, /* Can be NULL */ + int * outBottom); /* Can be NULL */ +#endif /* XPLM300 */ + +#if defined(XPLM300) +/* + * XPLMSetWindowGeometryOS + * + * This routine allows you to set the position and size, in operating system + * pixel coordinates, of a popped out window (that is, a window whose + * positioning mode is xplm_WindowPopOut, which exists outside the X-Plane + * simulation window, in its own first-class operating system window). + * + * Note that you are responsible for ensuring both that your window is popped + * out (using XPLMWindowIsPoppedOut()) and that a monitor really exists at the + * OS coordinates you provide (using XPLMGetAllMonitorBoundsOS()). + * + */ +XPLM_API void XPLMSetWindowGeometryOS( + XPLMWindowID inWindowID, + int inLeft, + int inTop, + int inRight, + int inBottom); +#endif /* XPLM300 */ + +#if defined(XPLM301) +/* + * XPLMGetWindowGeometryVR + * + * Returns the width and height, in boxels, of a window in VR. Note that you + * are responsible for ensuring your window is in VR (using + * XPLMWindowIsInVR()). + * + */ +XPLM_API void XPLMGetWindowGeometryVR( + XPLMWindowID inWindowID, + int * outWidthBoxels, /* Can be NULL */ + int * outHeightBoxels); /* Can be NULL */ +#endif /* XPLM301 */ + +#if defined(XPLM301) +/* + * XPLMSetWindowGeometryVR + * + * This routine allows you to set the size, in boxels, of a window in VR (that + * is, a window whose positioning mode is xplm_WindowVR). + * + * Note that you are responsible for ensuring your window is in VR (using + * XPLMWindowIsInVR()). + * + */ +XPLM_API void XPLMSetWindowGeometryVR( + XPLMWindowID inWindowID, + int widthBoxels, + int heightBoxels); +#endif /* XPLM301 */ + +/* + * XPLMGetWindowIsVisible + * + * Returns true (1) if the specified window is visible. + * + */ +XPLM_API int XPLMGetWindowIsVisible( + XPLMWindowID inWindowID); + +/* + * XPLMSetWindowIsVisible + * + * This routine shows or hides a window. + * + */ +XPLM_API void XPLMSetWindowIsVisible( + XPLMWindowID inWindowID, + int inIsVisible); + +#if defined(XPLM300) +/* + * XPLMWindowIsPoppedOut + * + * True if this window has been popped out (making it a first-class window in + * the operating system), which in turn is true if and only if you have set + * the window's positioning mode to xplm_WindowPopOut. + * + * Only applies to modern windows. (Windows created using the deprecated + * XPLMCreateWindow(), or windows compiled against a pre-XPLM300 version of + * the SDK cannot be popped out.) + * + */ +XPLM_API int XPLMWindowIsPoppedOut( + XPLMWindowID inWindowID); +#endif /* XPLM300 */ + +#if defined(XPLM301) +/* + * XPLMWindowIsInVR + * + * True if this window has been moved to the virtual reality (VR) headset, + * which in turn is true if and only if you have set the window's positioning + * mode to xplm_WindowVR. + * + * Only applies to modern windows. (Windows created using the deprecated + * XPLMCreateWindow(), or windows compiled against a pre-XPLM301 version of + * the SDK cannot be moved to VR.) + * + */ +XPLM_API int XPLMWindowIsInVR( + XPLMWindowID inWindowID); +#endif /* XPLM301 */ + +#if defined(XPLM300) +/* + * XPLMSetWindowGravity + * + * A window's "gravity" controls how the window shifts as the whole X-Plane + * window resizes. A gravity of 1 means the window maintains its positioning + * relative to the right or top edges, 0 the left/bottom, and 0.5 keeps it + * centered. + * + * Default gravity is (0, 1, 0, 1), meaning your window will maintain its + * position relative to the top left and will not change size as its + * containing window grows. + * + * If you wanted, say, a window that sticks to the top of the screen (with a + * constant height), but which grows to take the full width of the window, you + * would pass (0, 1, 1, 1). Because your left and right edges would maintain + * their positioning relative to their respective edges of the screen, the + * whole width of your window would change with the X-Plane window. + * + * Only applies to modern windows. (Windows created using the deprecated + * XPLMCreateWindow(), or windows compiled against a pre-XPLM300 version of + * the SDK will simply get the default gravity.) + * + */ +XPLM_API void XPLMSetWindowGravity( + XPLMWindowID inWindowID, + float inLeftGravity, + float inTopGravity, + float inRightGravity, + float inBottomGravity); +#endif /* XPLM300 */ + +#if defined(XPLM300) +/* + * XPLMSetWindowResizingLimits + * + * Sets the minimum and maximum size of the client rectangle of the given + * window. (That is, it does not include any window styling that you might + * have asked X-Plane to apply on your behalf.) All resizing operations are + * constrained to these sizes. + * + * Only applies to modern windows. (Windows created using the deprecated + * XPLMCreateWindow(), or windows compiled against a pre-XPLM300 version of + * the SDK will have no minimum or maximum size.) + * + */ +XPLM_API void XPLMSetWindowResizingLimits( + XPLMWindowID inWindowID, + int inMinWidthBoxels, + int inMinHeightBoxels, + int inMaxWidthBoxels, + int inMaxHeightBoxels); +#endif /* XPLM300 */ + +#if defined(XPLM300) +/* + * XPLMWindowPositioningMode + * + * XPLMWindowPositionMode describes how X-Plane will position your window on + * the user's screen. X-Plane will maintain this positioning mode even as the + * user resizes their window or adds/removes full-screen monitors. + * + * Positioning mode can only be set for "modern" windows (that is, windows + * created using XPLMCreateWindowEx() and compiled against the XPLM300 SDK). + * Windows created using the deprecated XPLMCreateWindow(), or windows + * compiled against a pre-XPLM300 version of the SDK will simply get the + * "free" positioning mode. + * + */ +enum { + /* The default positioning mode. Set the window geometry and its future * + * position will be determined by its window gravity, resizing limits, and * + * user interactions. */ + xplm_WindowPositionFree = 0, + + /* Keep the window centered on the monitor you specify */ + xplm_WindowCenterOnMonitor = 1, + + /* Keep the window full screen on the monitor you specify */ + xplm_WindowFullScreenOnMonitor = 2, + + /* Like gui_window_full_screen_on_monitor, but stretches over *all* monitors * + * and popout windows. This is an obscure one... unless you have a very good * + * reason to need it, you probably don't! */ + xplm_WindowFullScreenOnAllMonitors = 3, + + /* A first-class window in the operating system, completely separate from the * + * X-Plane window(s) */ + xplm_WindowPopOut = 4, + +#if defined(XPLM301) + /* A floating window visible on the VR headset */ + xplm_WindowVR = 5, + +#endif /* XPLM301 */ + +}; +typedef int XPLMWindowPositioningMode; +#endif /* XPLM300 */ + +#if defined(XPLM300) +/* + * XPLMSetWindowPositioningMode + * + * Sets the policy for how X-Plane will position your window. + * + * Some positioning modes apply to a particular monitor. For those modes, you + * can pass a negative monitor index to position the window on the main + * X-Plane monitor (the screen with the X-Plane menu bar at the top). Or, if + * you have a specific monitor you want to position your window on, you can + * pass a real monitor index as received from, e.g., + * XPLMGetAllMonitorBoundsOS(). + * + * Only applies to modern windows. (Windows created using the deprecated + * XPLMCreateWindow(), or windows compiled against a pre-XPLM300 version of + * the SDK will always use xplm_WindowPositionFree.) + * + */ +XPLM_API void XPLMSetWindowPositioningMode( + XPLMWindowID inWindowID, + XPLMWindowPositioningMode inPositioningMode, + int inMonitorIndex); +#endif /* XPLM300 */ + +#if defined(XPLM300) +/* + * XPLMSetWindowTitle + * + * Sets the name for a window. This only applies to windows that opted-in to + * styling as an X-Plane 11 floating window (i.e., with styling mode + * xplm_WindowDecorationRoundRectangle) when they were created using + * XPLMCreateWindowEx(). + * + */ +XPLM_API void XPLMSetWindowTitle( + XPLMWindowID inWindowID, + const char * inWindowTitle); +#endif /* XPLM300 */ + +/* + * XPLMGetWindowRefCon + * + * Returns a window's reference constant, the unique value you can use for + * your own purposes. + * + */ +XPLM_API void * XPLMGetWindowRefCon( + XPLMWindowID inWindowID); + +/* + * XPLMSetWindowRefCon + * + * Sets a window's reference constant. Use this to pass data to yourself in + * the callbacks. + * + */ +XPLM_API void XPLMSetWindowRefCon( + XPLMWindowID inWindowID, + void * inRefcon); + +/* + * XPLMTakeKeyboardFocus + * + * This routine gives a specific window keyboard focus. Keystrokes will be + * sent to that window. Pass a window ID of 0 to remove keyboard focus from + * any plugin-created windows and instead pass keyboard strokes directly to + * X-Plane. + * + */ +XPLM_API void XPLMTakeKeyboardFocus( + XPLMWindowID inWindow); + +/* + * XPLMHasKeyboardFocus + * + * Returns true (1) if the indicated window has keyboard focus. Pass a window + * ID of 0 to see if no plugin window has focus, and all keystrokes will go + * directly to X-Plane. + * + */ +XPLM_API int XPLMHasKeyboardFocus( + XPLMWindowID inWindow); + +/* + * XPLMBringWindowToFront + * + * This routine brings the window to the front of the Z-order for its layer. + * Windows are brought to the front automatically when they are created. + * Beyond that, you should make sure you are front before handling mouse + * clicks. + * + * Note that this only brings your window to the front of its layer + * (XPLMWindowLayer). Thus, if you have a window in the floating window layer + * (xplm_WindowLayerFloatingWindows), but there is a modal window (in layer + * xplm_WindowLayerModal) above you, you would still not be the true frontmost + * window after calling this. (After all, the window layers are strictly + * ordered, and no window in a lower layer can ever be above any window in a + * higher one.) + * + */ +XPLM_API void XPLMBringWindowToFront( + XPLMWindowID inWindow); + +/* + * XPLMIsWindowInFront + * + * This routine returns true if the window you passed in is the frontmost + * visible window in its layer (XPLMWindowLayer). + * + * Thus, if you have a window at the front of the floating window layer + * (xplm_WindowLayerFloatingWindows), this will return true even if there is a + * modal window (in layer xplm_WindowLayerModal) above you. (Not to worry, + * though: in such a case, X-Plane will not pass clicks or keyboard input down + * to your layer until the window above stops "eating" the input.) + * + * Note that legacy windows are always placed in layer + * xplm_WindowLayerFlightOverlay, while modern-style windows default to + * xplm_WindowLayerFloatingWindows. This means it's perfectly consistent to + * have two different plugin-created windows (one legacy, one modern) *both* + * be in the front (of their different layers!) at the same time. + * + */ +XPLM_API int XPLMIsWindowInFront( + XPLMWindowID inWindow); + +/*************************************************************************** + * KEY SNIFFERS + ***************************************************************************/ +/* + * Low-level keyboard handlers. Allows for intercepting keystrokes outside the + * normal rules of the user interface. + * + */ + + +/* + * XPLMKeySniffer_f + * + * This is the prototype for a low level key-sniffing function. Window-based + * UI _should not use this_! The windowing system provides high-level + * mediated keyboard access, via the callbacks you attach to your + * XPLMCreateWindow_t. By comparison, the key sniffer provides low level + * keyboard access. + * + * Key sniffers are provided to allow libraries to provide non-windowed user + * interaction. For example, the MUI library uses a key sniffer to do pop-up + * text entry. + * + * Return 1 to pass the key on to the next sniffer, the window manager, + * X-Plane, or whomever is down stream. Return 0 to consume the key. + * + * Warning: this API declares virtual keys as a signed character; however the + * VKEY #define macros in XPLMDefs.h define the vkeys using unsigned values + * (that is 0x80 instead of -0x80). So you may need to cast the incoming vkey + * to an unsigned char to get correct comparisons in C. + * + */ +typedef int (* XPLMKeySniffer_f)( + char inChar, + XPLMKeyFlags inFlags, + char inVirtualKey, + void * inRefcon); + +/* + * XPLMRegisterKeySniffer + * + * This routine registers a key sniffing callback. You specify whether you + * want to sniff before the window system, or only sniff keys the window + * system does not consume. You should ALMOST ALWAYS sniff non-control keys + * after the window system. When the window system consumes a key, it is + * because the user has "focused" a window. Consuming the key or taking + * action based on the key will produce very weird results. Returns + * 1 if successful. + * + */ +XPLM_API int XPLMRegisterKeySniffer( + XPLMKeySniffer_f inCallback, + int inBeforeWindows, + void * inRefcon); + +/* + * XPLMUnregisterKeySniffer + * + * This routine unregisters a key sniffer. You must unregister a key sniffer + * for every time you register one with the exact same signature. Returns 1 + * if successful. + * + */ +XPLM_API int XPLMUnregisterKeySniffer( + XPLMKeySniffer_f inCallback, + int inBeforeWindows, + void * inRefcon); + +/*************************************************************************** + * HOT KEYS + ***************************************************************************/ +/* + * Keystrokes that can be managed by others. These are lower-level than window + * keyboard handlers (i.e., callbacks you attach to your XPLMCreateWindow_t), + * but higher level than key sniffers. + * + */ + + +/* + * XPLMHotKey_f + * + * Your hot key callback simply takes a pointer of your choosing. + * + */ +typedef void (* XPLMHotKey_f)( + void * inRefcon); + +/* + * XPLMHotKeyID + * + * An opaque ID used to identify a hot key. + * + */ +typedef void * XPLMHotKeyID; + +/* + * XPLMRegisterHotKey + * + * This routine registers a hot key. You specify your preferred key stroke + * virtual key/flag combination, a description of what your callback does (so + * other plug-ins can describe the plug-in to the user for remapping) and a + * callback function and opaque pointer to pass in). A new hot key ID is + * returned. During execution, the actual key associated with your hot key + * may change, but you are insulated from this. + * + */ +XPLM_API XPLMHotKeyID XPLMRegisterHotKey( + char inVirtualKey, + XPLMKeyFlags inFlags, + const char * inDescription, + XPLMHotKey_f inCallback, + void * inRefcon); + +/* + * XPLMUnregisterHotKey + * + * Unregisters a hot key. You can only unregister your own hot keys. + * + */ +XPLM_API void XPLMUnregisterHotKey( + XPLMHotKeyID inHotKey); + +/* + * XPLMCountHotKeys + * + * Returns the number of current hot keys. + * + */ +XPLM_API int XPLMCountHotKeys(void); + +/* + * XPLMGetNthHotKey + * + * Returns a hot key by index, for iteration on all hot keys. + * + */ +XPLM_API XPLMHotKeyID XPLMGetNthHotKey( + int inIndex); + +/* + * XPLMGetHotKeyInfo + * + * Returns information about the hot key. Return NULL for any parameter you + * don't want info about. The description should be at least 512 chars long. + * + */ +XPLM_API void XPLMGetHotKeyInfo( + XPLMHotKeyID inHotKey, + char * outVirtualKey, /* Can be NULL */ + XPLMKeyFlags * outFlags, /* Can be NULL */ + char * outDescription, /* Can be NULL */ + XPLMPluginID * outPlugin); /* Can be NULL */ + +/* + * XPLMSetHotKeyCombination + * + * Remaps a hot key's keystrokes. You may remap another plugin's keystrokes. + * + */ +XPLM_API void XPLMSetHotKeyCombination( + XPLMHotKeyID inHotKey, + char inVirtualKey, + XPLMKeyFlags inFlags); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/SDK/CHeaders/XPLM/XPLMGraphics.h b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/XPLM/XPLMGraphics.h new file mode 100644 index 0000000..d7aef52 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/XPLM/XPLMGraphics.h @@ -0,0 +1,437 @@ +#ifndef _XPLMGraphics_h_ +#define _XPLMGraphics_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPLMGraphics + ***************************************************************************/ +/* + * A few notes on coordinate systems: + * + * X-Plane uses three kinds of coordinates. Global coordinates are specified + * as latitude, longitude and elevation. This coordinate system never changes + * but is not very precise. + * + * OpenGL (or 'local') coordinates are cartesian and shift with the plane. + * They offer more precision and are used for 3-d OpenGL drawing. The X axis + * is aligned east-west with positive X meaning east. The Y axis is aligned + * straight up and down at the point 0,0,0 (but since the earth is round it is + * not truly straight up and down at other points). The Z axis is aligned + * north-south at 0, 0, 0 with positive Z pointing south (but since the earth + * is round it isn't exactly north-south as you move east or west of 0, 0, 0). + * One unit is one meter and the point 0,0,0 is on the surface of the earth at + * sea level for some latitude and longitude picked by the sim such that the + * user's aircraft is reasonably nearby. + * + * 2-d Panel coordinates are 2d, with the X axis horizontal and the Y axis + * vertical. The point 0,0 is the bottom left and 1024,768 is the upper + * right of the screen. This is true no matter what resolution the user's + * monitor is in; when running in higher resolution, graphics will be + * scaled. + * + * Use X-Plane's routines to convert between global and local coordinates. Do + * not attempt to do this conversion yourself; the precise 'roundness' of + * X-Plane's physics model may not match your own, and (to make things + * weirder) the user can potentially customize the physics of the current + * planet. + * + */ + +#include "XPLMDefs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*************************************************************************** + * X-PLANE GRAPHICS + ***************************************************************************/ +/* + * These routines allow you to use OpenGL with X-Plane. + * + */ + + +/* + * XPLMTextureID + * + * XPLM Texture IDs name well-known textures in the sim for you to use. This + * allows you to recycle textures from X-Plane, saving VRAM. + * + * *Warning*: do not use these enums. The only remaining use they have is to + * access the legacy compatibility v10 UI texture; if you need this, get it + * via the Widgets library. + * + */ +enum { + /* The bitmap that contains window outlines, button outlines, fonts, etc. */ + xplm_Tex_GeneralInterface = 0, + +#if defined(XPLM_DEPRECATED) + /* The exterior paint for the user's aircraft (daytime). */ + xplm_Tex_AircraftPaint = 1, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* The exterior light map for the user's aircraft. */ + xplm_Tex_AircraftLiteMap = 2, + +#endif /* XPLM_DEPRECATED */ + +}; +typedef int XPLMTextureID; + +/* + * XPLMSetGraphicsState + * + * XPLMSetGraphicsState changes OpenGL's fixed function pipeline state. You + * are not responsible for restoring any state that is accessed via + * XPLMSetGraphicsState, but you are responsible for not accessing this state + * directly. + * + * - inEnableFog - enables or disables fog, equivalent to: glEnable(GL_FOG); + * - inNumberTexUnits - enables or disables a number of multitexturing units. + * If the number is 0, 2d texturing is disabled entirely, as in + * glDisable(GL_TEXTURE_2D); Otherwise, 2d texturing is enabled, and a + * number of multitexturing units are enabled sequentially, starting with + * unit 0, e.g. glActiveTextureARB(GL_TEXTURE0_ARB); glEnable + * (GL_TEXTURE_2D); + * - inEnableLighting - enables or disables OpenGL lighting, e.g. + * glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); + * - inEnableAlphaTesting - enables or disables the alpha test per pixel, e.g. + * glEnable(GL_ALPHA_TEST); + * - inEnableAlphaBlending - enables or disables alpha blending per pixel, + * e.g. glEnable(GL_BLEND); + * - inEnableDepthTesting - enables per pixel depth testing, as in + * glEnable(GL_DEPTH_TEST); + * - inEnableDepthWriting - enables writing back of depth information to the + * depth bufffer, as in glDepthMask(GL_TRUE); + * + * The purpose of this function is to change OpenGL state while keeping + * X-Plane aware of the state changes; this keeps X-Plane from getting + * surprised by OGL state changes, and prevents X-Plane and plug-ins from + * having to set all state before all draws; XPLMSetGraphicsState internally + * skips calls to change state that is already properly enabled. + * + * X-Plane does not have a 'default' OGL state for plug-ins with respect to + * the above state vector; plug-ins should totally set OGL state using this + * API before drawing. Use XPLMSetGraphicsState instead of any of the above + * OpenGL calls. + * + * WARNING: Any routine that performs drawing (e.g. XPLMDrawString or widget + * code) may change X-Plane's state. Always set state before drawing after + * unknown code has executed. + * + * *Deprecation Warnings*: X-Plane's lighting and fog environemnt is + * significantly more complex than the fixed function pipeline can express; + * do not assume that lighting and fog state is a good approximation for 3-d + * drawing. Prefer to use XPLMInstancing to draw objects. All calls to + * XPLMSetGraphicsState should have no fog or lighting. + * + */ +XPLM_API void XPLMSetGraphicsState( + int inEnableFog, + int inNumberTexUnits, + int inEnableLighting, + int inEnableAlphaTesting, + int inEnableAlphaBlending, + int inEnableDepthTesting, + int inEnableDepthWriting); + +/* + * XPLMBindTexture2d + * + * XPLMBindTexture2d changes what texture is bound to the 2d texturing + * target. This routine caches the current 2d texture across all texturing + * units in the sim and plug-ins, preventing extraneous binding. For + * example, consider several plug-ins running in series; if they all use the + * 'general interface' bitmap to do UI, calling this function will skip the + * rebinding of the general interface texture on all but the first plug-in, + * which can provide better frame rate son some graphics cards. + * + * inTextureID is the ID of the texture object to bind; inTextureUnit is a + * zero-based texture unit (e.g. 0 for the first one), up to a maximum of 4 + * units. (This number may increase in future versions of X-Plane.) + * + * Use this routine instead of glBindTexture(GL_TEXTURE_2D, ....); + * + */ +XPLM_API void XPLMBindTexture2d( + int inTextureNum, + int inTextureUnit); + +/* + * XPLMGenerateTextureNumbers + * + * Use this routine instead of glGenTextures to generate new texture object + * IDs. This routine historically ensured that plugins don't use texure IDs + * that X-Plane is reserving for its own use. + * + */ +XPLM_API void XPLMGenerateTextureNumbers( + int * outTextureIDs, + int inCount); + +#if defined(XPLM_DEPRECATED) +/* + * XPLMGetTexture + * + * XPLMGetTexture returns the OpenGL texture ID of an X-Plane texture based on + * a generic identifying code. For example, you can get the texture for + * X-Plane's UI bitmaps. + * + */ +XPLM_API int XPLMGetTexture( + XPLMTextureID inTexture); +#endif /* XPLM_DEPRECATED */ + +/* + * XPLMWorldToLocal + * + * This routine translates coordinates from latitude, longitude, and altitude + * to local scene coordinates. Latitude and longitude are in decimal degrees, + * and altitude is in meters MSL (mean sea level). The XYZ coordinates are in + * meters in the local OpenGL coordinate system. + * + */ +XPLM_API void XPLMWorldToLocal( + double inLatitude, + double inLongitude, + double inAltitude, + double * outX, + double * outY, + double * outZ); + +/* + * XPLMLocalToWorld + * + * This routine translates a local coordinate triplet back into latitude, + * longitude, and altitude. Latitude and longitude are in decimal degrees, + * and altitude is in meters MSL (mean sea level). The XYZ coordinates are in + * meters in the local OpenGL coordinate system. + * + * NOTE: world coordinates are less precise than local coordinates; you should + * try to avoid round tripping from local to world and back. + * + */ +XPLM_API void XPLMLocalToWorld( + double inX, + double inY, + double inZ, + double * outLatitude, + double * outLongitude, + double * outAltitude); + +/* + * XPLMDrawTranslucentDarkBox + * + * This routine draws a translucent dark box, partially obscuring parts of the + * screen but making text easy to read. This is the same graphics primitive + * used by X-Plane to show text files and ATC info. + * + */ +XPLM_API void XPLMDrawTranslucentDarkBox( + int inLeft, + int inTop, + int inRight, + int inBottom); + +/*************************************************************************** + * X-PLANE TEXT + ***************************************************************************/ + +/* + * XPLMFontID + * + * X-Plane features some fixed-character fonts. Each font may have its own + * metrics. + * + * WARNING: Some of these fonts are no longer supported or may have changed + * geometries. For maximum copmatibility, see the comments below. + * + * Note: X-Plane 7 supports proportional-spaced fonts. Since no measuring + * routine is available yet, the SDK will normally draw using a fixed-width + * font. You can use a dataref to enable proportional font drawing on XP7 if + * you want to. + * + */ +enum { + /* Mono-spaced font for user interface. Available in all versions of the SDK.*/ + xplmFont_Basic = 0, + +#if defined(XPLM_DEPRECATED) + /* Deprecated, do not use. */ + xplmFont_Menus = 1, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated, do not use. */ + xplmFont_Metal = 2, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated, do not use. */ + xplmFont_Led = 3, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated, do not use. */ + xplmFont_LedWide = 4, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated, do not use. */ + xplmFont_PanelHUD = 5, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated, do not use. */ + xplmFont_PanelEFIS = 6, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated, do not use. */ + xplmFont_PanelGPS = 7, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated, do not use. */ + xplmFont_RadiosGA = 8, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated, do not use. */ + xplmFont_RadiosBC = 9, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated, do not use. */ + xplmFont_RadiosHM = 10, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated, do not use. */ + xplmFont_RadiosGANarrow = 11, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated, do not use. */ + xplmFont_RadiosBCNarrow = 12, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated, do not use. */ + xplmFont_RadiosHMNarrow = 13, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated, do not use. */ + xplmFont_Timer = 14, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated, do not use. */ + xplmFont_FullRound = 15, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated, do not use. */ + xplmFont_SmallRound = 16, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated, do not use. */ + xplmFont_Menus_Localized = 17, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM200) + /* Proportional UI font. */ + xplmFont_Proportional = 18, + +#endif /* XPLM200 */ + +}; +typedef int XPLMFontID; + +/* + * XPLMDrawString + * + * This routine draws a NULL termianted string in a given font. Pass in the + * lower left pixel that the character is to be drawn onto. Also pass the + * character and font ID. This function returns the x offset plus the width of + * all drawn characters. The color to draw in is specified as a pointer to an + * array of three floating point colors, representing RGB intensities from 0.0 + * to 1.0. + * + */ +XPLM_API void XPLMDrawString( + float * inColorRGB, + int inXOffset, + int inYOffset, + char * inChar, + int * inWordWrapWidth, /* Can be NULL */ + XPLMFontID inFontID); + +/* + * XPLMDrawNumber + * + * This routine draws a number similar to the digit editing fields in + * PlaneMaker and data output display in X-Plane. Pass in a color, a + * position, a floating point value, and formatting info. Specify how many + * integer and how many decimal digits to show and whether to show a sign, as + * well as a character set. This routine returns the xOffset plus width of the + * string drawn. + * + */ +XPLM_API void XPLMDrawNumber( + float * inColorRGB, + int inXOffset, + int inYOffset, + double inValue, + int inDigits, + int inDecimals, + int inShowSign, + XPLMFontID inFontID); + +/* + * XPLMGetFontDimensions + * + * This routine returns the width and height of a character in a given font. + * It also tells you if the font only supports numeric digits. Pass NULL if + * you don't need a given field. Note that for a proportional font the width + * will be an arbitrary, hopefully average width. + * + */ +XPLM_API void XPLMGetFontDimensions( + XPLMFontID inFontID, + int * outCharWidth, /* Can be NULL */ + int * outCharHeight, /* Can be NULL */ + int * outDigitsOnly); /* Can be NULL */ + +#if defined(XPLM200) +/* + * XPLMMeasureString + * + * This routine returns the width in pixels of a string using a given font. + * The string is passed as a pointer plus length (and does not need to be null + * terminated); this is used to allow for measuring substrings. The return + * value is floating point; it is possible that future font drawing may allow + * for fractional pixels. + * + */ +XPLM_API float XPLMMeasureString( + XPLMFontID inFontID, + const char * inChar, + int inNumChars); +#endif /* XPLM200 */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/SDK/CHeaders/XPLM/XPLMInstance.h b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/XPLM/XPLMInstance.h new file mode 100644 index 0000000..d2a8f2c --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/XPLM/XPLMInstance.h @@ -0,0 +1,136 @@ +#ifndef _XPLMInstance_h_ +#define _XPLMInstance_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPLMInstance + ***************************************************************************/ +/* + * This API provides instanced drawing of X-Plane objects (.obj files). In + * contrast to old drawing APIs, which required you to draw your own objects + * per-frame, the instancing API allows you to simply register an OBJ for + * drawing, then move or manipulate it later (as needed). + * + * This provides one tremendous benefit: it keeps all dataref operations for + * your object in one place. Because datarefs are main thread only, allowing + * dataref access anywhere is a serious performance bottleneck for the + * simulator---the whole simulator has to pause and wait for each dataref + * access. This performance penalty will only grow worse as X-Plane moves + * toward an ever more heavily multithreaded engine. + * + * The instancing API allows X-Plane to isolate all dataref manipulations for + * all plugin object drawing to one place, potentially providing huge + * performance gains. + * + * Here's how it works: + * + * When an instance is created, it provides a list of all datarefs you want to + * manipulate in for the OBJ in the future. This list of datarefs replaces the + * ad-hoc collections of dataref objects previously used by art assets. Then, + * per-frame, you can manipulate the instance by passing in a "block" of + * packed floats representing the current values of the datarefs for your + * instance. (Note that the ordering of this set of packed floats must exactly + * match the ordering of the datarefs when you created your instance.) + * + */ + +#include "XPLMDefs.h" +#include "XPLMScenery.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*************************************************************************** + * Instance Creation and Destruction + ***************************************************************************/ +/* + * Registers and unregisters instances. + * + */ + + +/* + * XPLMInstanceRef + * + * An opaque handle to an instance. + * + */ +typedef void * XPLMInstanceRef; + +/* + * XPLMCreateInstance + * + * XPLMCreateInstance creates a new instance, managed by your plug-in, and + * returns a handle to the instance. A few important requirements: + * + * * The object passed in must be fully loaded and returned from the XPLM + * before you can create your instance; you cannot pass a null obj ref, nor + * can you change the ref later. + * + * * If you use any custom datarefs in your object, they must be registered + * before the object is loaded. This is true even if their data will be + * provided via the instance dataref list. + * + * * The instance dataref array must be a valid ptr to an array of at least + * one item that is null terminated. That is, if you do not want any + * datarefs, you must passa ptr to an array with a null item. You cannot + * pass null for this. + * + */ +XPLM_API XPLMInstanceRef XPLMCreateInstance( + XPLMObjectRef obj, + const char ** datarefs); + +/* + * XPLMDestroyInstance + * + * XPLMDestroyInstance destroys and deallocates your instance; once called, + * you are still responsible for releasing the OBJ ref. + * + * Tip: you can release your OBJ ref after you call XPLMCreateInstance as long + * as you never use it again; the instance will maintain its own reference to + * the OBJ and the object OBJ be deallocated when the instance is destroyed. + * + */ +XPLM_API void XPLMDestroyInstance( + XPLMInstanceRef instance); + +/*************************************************************************** + * Instance Manipulation + ***************************************************************************/ + +/* + * XPLMInstanceSetPosition + * + * Updates both the position of the instance and all datarefs you registered + * for it. Call this from a flight loop callback or UI callback. + * + * __DO NOT__ call XPLMInstanceSetPosition from a drawing callback; the whole + * point of instancing is that you do not need any drawing callbacks. Setting + * instance data from a drawing callback may have undefined consequences, and + * the drawing callback hurts FPS unnecessarily. + * + * The memory pointed to by the data pointer must be large enough to hold one + * float for every data ref you have registered, and must contain valid + * floating point data. + * + * BUG: before X-Plane 11.50, if you have no dataref registered, you must + * still pass a valid pointer for data and not null. + * + */ +XPLM_API void XPLMInstanceSetPosition( + XPLMInstanceRef instance, + const XPLMDrawInfo_t * new_position, + const float * data); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/SDK/CHeaders/XPLM/XPLMMap.h b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/XPLM/XPLMMap.h new file mode 100644 index 0000000..8297471 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/XPLM/XPLMMap.h @@ -0,0 +1,628 @@ +#ifndef _XPLMMap_h_ +#define _XPLMMap_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPLMMap + ***************************************************************************/ +/* + * This API allows you to create new layers within X-Plane maps. Your layers + * can draw arbitrary OpenGL, but they conveniently also have access to + * X-Plane's built-in icon and label drawing functions. + * + * As of X-Plane 11, map drawing happens in three stages: + * + * 1. backgrounds and "fill," + * 2. icons, and + * 3. labels. + * + * Thus, all background drawing gets layered beneath all icons, which likewise + * get layered beneath all labels. Within each stage, the map obeys a + * consistent layer ordering, such that "fill" layers (layers that cover a + * large amount of map area, like the terrain and clouds) appear beneath + * "markings" layers (like airport icons). This ensures that layers with fine + * details don't get obscured by layers with larger details. + * + * The XPLM map API reflects both aspects of this draw layering: you can + * register a layer as providing either markings or fill, and X-Plane will + * draw your fill layers beneath your markings layers (regardless of + * registration order). Likewise, you are guaranteed that your layer's icons + * (added from within an icon callback) will go above your layer's OpenGL + * drawing, and your labels will go above your icons. + * + * The XPLM guarantees that all plugin-created fill layers go on top of all + * native X-Plane fill layers, and all plugin-created markings layers go on + * top of all X-Plane markings layers (with the exception of the aircraft + * icons). It also guarantees that the draw order of your own plugin's layers + * will be consistent. But, for layers created by different plugins, the only + * guarantee is that we will draw all of one plugin's layers of each type + * (fill, then markings), then all of the others'; we don't guarantee which + * plugin's fill and markings layers go on top of the other's. + * + * As of X-Plane 11, maps use true cartographic projections for their drawing, + * and different maps may use different projections. For that reason, all + * drawing calls include an opaque handle for the projection you should use to + * do the drawing. Any time you would draw at a particular latitude/longitude, + * you'll need to ask the projection to translate that position into "map + * coordinates." (Note that the projection is guaranteed not to change between + * calls to your prepare-cache hook, so if you cache your map coordinates + * ahead of time, there's no need to re-project them when you actually draw.) + * + * In addition to mapping normal latitude/longitude locations into map + * coordinates, the projection APIs also let you know the current heading for + * north. (Since X-Plane 11 maps can rotate to match the heading of the user's + * aircraft, it's not safe to assume that north is at zero degrees rotation.) + * + */ + +#include "XPLMDefs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(XPLM300) +/*************************************************************************** + * DRAWING CALLBACKS + ***************************************************************************/ +/* + * When you create a new map layer (using XPLMCreateMapLayer), you can provide + * any or all of these callbacks. They allow you to insert your own OpenGL + * drawing, text labels, and icons into the X-Plane map at the appropriate + * places, allowing your layer to behave as similarly to X-Plane's built-in + * layers as possible. + * + */ + + +/* + * XPLMMapLayerID + * + * This is an opaque handle for a plugin-created map layer. Pass it to the map + * drawing APIs from an appropriate callback to draw in the layer you created. + * + */ +typedef void * XPLMMapLayerID; + +/* + * XPLMMapProjectionID + * + * This is an opaque handle for a map projection. Pass it to the projection + * APIs to translate between map coordinates and latitude/longitudes. + * + */ +typedef void * XPLMMapProjectionID; + +/* + * XPLMMapStyle + * + * Indicates the visual style being drawn by the map. In X-Plane, the user can + * choose between a number of map types, and different map types may have use + * a different visual representation for the same elements (for instance, the + * visual style of the terrain layer changes drastically between the VFR and + * IFR layers), or certain layers may be disabled entirely in some map types + * (e.g., localizers are only visible in the IFR low-enroute style). + * + */ +enum { + xplm_MapStyle_VFR_Sectional = 0, + + xplm_MapStyle_IFR_LowEnroute = 1, + + xplm_MapStyle_IFR_HighEnroute = 2, + + +}; +typedef int XPLMMapStyle; + +/* + * XPLMMapDrawingCallback_f + * + * This is the OpenGL map drawing callback for plugin-created map layers. You + * can perform arbitrary OpenGL drawing from this callback, with one + * exception: changes to the Z-buffer are not permitted, and will result in + * map drawing errors. + * + * All drawing done from within this callback appears beneath all built-in + * X-Plane icons and labels, but above the built-in "fill" layers (layers + * providing major details, like terrain and water). Note, however, that the + * relative ordering between the drawing callbacks of different plugins is not + * guaranteed. + * + */ +typedef void (* XPLMMapDrawingCallback_f)( + XPLMMapLayerID inLayer, + const float * inMapBoundsLeftTopRightBottom, + float zoomRatio, + float mapUnitsPerUserInterfaceUnit, + XPLMMapStyle mapStyle, + XPLMMapProjectionID projection, + void * inRefcon); + +/* + * XPLMMapIconDrawingCallback_f + * + * This is the icon drawing callback that enables plugin-created map layers to + * draw icons using X-Plane's built-in icon drawing functionality. You can + * request an arbitrary number of PNG icons to be drawn via + * XPLMDrawMapIconFromSheet() from within this callback, but you may not + * perform any OpenGL drawing here. + * + * Icons enqueued by this function will appear above all OpenGL drawing + * (performed by your optional XPLMMapDrawingCallback_f), and above all + * built-in X-Plane map icons of the same layer type ("fill" or "markings," as + * determined by the XPLMMapLayerType in your XPLMCreateMapLayer_t). Note, + * however, that the relative ordering between the drawing callbacks of + * different plugins is not guaranteed. + * + */ +typedef void (* XPLMMapIconDrawingCallback_f)( + XPLMMapLayerID inLayer, + const float * inMapBoundsLeftTopRightBottom, + float zoomRatio, + float mapUnitsPerUserInterfaceUnit, + XPLMMapStyle mapStyle, + XPLMMapProjectionID projection, + void * inRefcon); + +/* + * XPLMMapLabelDrawingCallback_f + * + * This is the label drawing callback that enables plugin-created map layers + * to draw text labels using X-Plane's built-in labeling functionality. You + * can request an arbitrary number of text labels to be drawn via + * XPLMDrawMapLabel() from within this callback, but you may not perform any + * OpenGL drawing here. + * + * Labels enqueued by this function will appear above all OpenGL drawing + * (performed by your optional XPLMMapDrawingCallback_f), and above all + * built-in map icons and labels of the same layer type ("fill" or "markings," + * as determined by the XPLMMapLayerType in your XPLMCreateMapLayer_t). Note, + * however, that the relative ordering between the drawing callbacks of + * different plugins is not guaranteed. + * + */ +typedef void (* XPLMMapLabelDrawingCallback_f)( + XPLMMapLayerID inLayer, + const float * inMapBoundsLeftTopRightBottom, + float zoomRatio, + float mapUnitsPerUserInterfaceUnit, + XPLMMapStyle mapStyle, + XPLMMapProjectionID projection, + void * inRefcon); + +#endif /* XPLM300 */ +#if defined(XPLM300) +/*************************************************************************** + * LAYER MANAGEMENT CALLBACKS + ***************************************************************************/ +/* + * These are various "bookkeeping" callbacks that your map layer can receive + * (if you provide the callback in your XPLMCreateMapLayer_t). They allow you + * to manage the lifecycle of your layer, as well as cache any + * computationally-intensive preparation you might need for drawing. + * + */ + + +/* + * XPLMMapPrepareCacheCallback_f + * + * A callback used to allow you to cache whatever information your layer needs + * to draw in the current map area. + * + * This is called each time the map's total bounds change. This is typically + * triggered by new DSFs being loaded, such that X-Plane discards old, + * now-distant DSFs and pulls in new ones. At that point, the available bounds + * of the map also change to match the new DSF area. + * + * By caching just the information you need to draw in this area, your future + * draw calls can be made faster, since you'll be able to simply "splat" your + * precomputed information each frame. + * + * We guarantee that the map projection will not change between successive + * prepare cache calls, nor will any draw call give you bounds outside these + * total map bounds. So, if you cache the projected map coordinates of all the + * items you might want to draw in the total map area, you can be guaranteed + * that no draw call will be asked to do any new work. + * + */ +typedef void (* XPLMMapPrepareCacheCallback_f)( + XPLMMapLayerID inLayer, + const float * inTotalMapBoundsLeftTopRightBottom, + XPLMMapProjectionID projection, + void * inRefcon); + +/* + * XPLMMapWillBeDeletedCallback_f + * + * Called just before your map layer gets deleted. Because SDK-created map + * layers have the same lifetime as the X-Plane map that contains them, if the + * map gets unloaded from memory, your layer will too. + * + */ +typedef void (* XPLMMapWillBeDeletedCallback_f)( + XPLMMapLayerID inLayer, + void * inRefcon); + +#endif /* XPLM300 */ +#if defined(XPLM300) +/*************************************************************************** + * MAP LAYER CREATION AND DESTRUCTION + ***************************************************************************/ +/* + * Enables the creation of new map layers. Layers are created for a particular + * instance of the X-Plane map. For instance, if you want your layer to appear + * in both the normal map interface and the Instructor Operator Station (IOS), + * you would need two separate calls to XPLMCreateMapLayer(), with two + * different values for your XPLMCreateMapLayer_t::layer_name. + * + * Your layer's lifetime will be determined by the lifetime of the map it is + * created in. If the map is destroyed (on the X-Plane side), your layer will + * be too, and you'll receive a callback to your + * XPLMMapWillBeDeletedCallback_f. + * + */ + + +/* + * XPLMMapLayerType + * + * Indicates the type of map layer you are creating. Fill layers will always + * be drawn beneath markings layers. + * + */ +enum { + /* A layer that draws "fill" graphics, like weather patterns, terrain, etc. * + * Fill layers frequently cover a large portion of the visible map area. */ + xplm_MapLayer_Fill = 0, + + /* A layer that provides markings for particular map features, like NAVAIDs, * + * airports, etc. Even dense markings layers cover a small portion of the * + * total map area. */ + xplm_MapLayer_Markings = 1, + + +}; +typedef int XPLMMapLayerType; + +/* Globally unique identifier for X-Plane's Map window, used as the * + * mapToCreateLayerIn parameter in XPLMCreateMapLayer_t */ +#define XPLM_MAP_USER_INTERFACE "XPLM_MAP_USER_INTERFACE" + +/* Globally unique identifier for X-Plane's Instructor Operator Station * + * window, used as the mapToCreateLayerIn parameter in XPLMCreateMapLayer_t */ +#define XPLM_MAP_IOS "XPLM_MAP_IOS" + +/* + * XPLMCreateMapLayer_t + * + * This structure defines all of the parameters used to create a map layer + * using XPLMCreateMapLayer. The structure will be expanded in future SDK APIs + * to include more features. Always set the structSize member to the size of + * your struct in bytes! + * + * Each layer must be associated with exactly one map instance in X-Plane. + * That map, and that map alone, will call your callbacks. Likewise, when that + * map is deleted, your layer will be as well. + * + */ +typedef struct { + /* Used to inform XPLMCreateMapLayer() of the SDK version you compiled * + * against; should always be set to sizeof(XPLMCreateMapLayer_t) */ + int structSize; + /* Globally unique string identifying the map you want this layer to appear * + * in. As of XPLM300, this is limited to one of XPLM_MAP_USER_INTERFACE or * + * XPLM_MAP_IOS */ + const char * mapToCreateLayerIn; + /* The type of layer you are creating, used to determine draw order (all * + * plugin-created markings layers are drawn above all plugin-created fill * + * layers) */ + XPLMMapLayerType layerType; + /* Optional callback to inform you this layer is being deleted (due to its * + * owning map being destroyed) */ + XPLMMapWillBeDeletedCallback_f willBeDeletedCallback; + /* Optional callback you want to use to prepare your draw cache when the map * + * bounds change (set to NULL if you don't want this callback) */ + XPLMMapPrepareCacheCallback_f prepCacheCallback; + /* Optional callback you want to use for arbitrary OpenGL drawing, which goes * + * beneath all icons in the map's layering system (set to NULL if you don't * + * want this callback) */ + XPLMMapDrawingCallback_f drawCallback; + /* Optional callback you want to use for drawing icons, which go above all * + * built-in X-Plane icons (except the aircraft) in the map's layering system * + * (set to NULL if you don't want this callback) */ + XPLMMapIconDrawingCallback_f iconCallback; + /* Optional callback you want to use for drawing map labels, which go above * + * all built-in X-Plane icons and labels (except those of aircraft) in the * + * map's layering system (set to NULL if you don't want this callback) */ + XPLMMapLabelDrawingCallback_f labelCallback; + /* True if you want a checkbox to be created in the map UI to toggle this * + * layer on and off; false if the layer should simply always be enabled */ + int showUiToggle; + /* Short label to use for this layer in the user interface */ + const char * layerName; + /* A reference to arbitrary data that will be passed to your callbacks */ + void * refcon; +} XPLMCreateMapLayer_t; + +/* + * XPLMCreateMapLayer + * + * This routine creates a new map layer. You pass in an XPLMCreateMapLayer_t + * structure with all of the fields set in. You must set the structSize of + * the structure to the size of the actual structure you used. + * + * Returns NULL if the layer creation failed. This happens most frequently + * because the map you specified in your + * XPLMCreateMapLayer_t::mapToCreateLayerIn field doesn't exist (that is, if + * XPLMMapExists() returns 0 for the specified map). You can use + * XPLMRegisterMapCreationHook() to get a notification each time a new map is + * opened in X-Plane, at which time you can create layers in it. + * + */ +XPLM_API XPLMMapLayerID XPLMCreateMapLayer( + XPLMCreateMapLayer_t * inParams); + +/* + * XPLMDestroyMapLayer + * + * Destroys a map layer you created (calling your + * XPLMMapWillBeDeletedCallback_f if applicable). Returns true if a deletion + * took place. + * + */ +XPLM_API int XPLMDestroyMapLayer( + XPLMMapLayerID inLayer); + +/* + * XPLMMapCreatedCallback_f + * + * A callback to notify your plugin that a new map has been created in + * X-Plane. This is the best time to add a custom map layer using + * XPLMCreateMapLayer(). + * + * No OpenGL drawing is permitted within this callback. + * + */ +typedef void (* XPLMMapCreatedCallback_f)( + const char * mapIdentifier, + void * refcon); + +/* + * XPLMRegisterMapCreationHook + * + * Registers your callback to receive a notification each time a new map is + * constructed in X-Plane. This callback is the best time to add your custom + * map layer using XPLMCreateMapLayer(). + * + * Note that you will not be notified about any maps that already exist---you + * can use XPLMMapExists() to check for maps that were created previously. + * + */ +XPLM_API void XPLMRegisterMapCreationHook( + XPLMMapCreatedCallback_f callback, + void * refcon); + +/* + * XPLMMapExists + * + * Returns 1 if the map with the specified identifier already exists in + * X-Plane. In that case, you can safely call XPLMCreateMapLayer() specifying + * that your layer should be added to that map. + * + */ +XPLM_API int XPLMMapExists( + const char * mapIdentifier); + +#endif /* XPLM300 */ +#if defined(XPLM300) +/*************************************************************************** + * MAP DRAWING + ***************************************************************************/ +/* + * These APIs are only valid from within a map drawing callback (one of + * XPLMIconDrawingCallback_t or XPLMMapLabelDrawingCallback_f). Your drawing + * callbacks are registered when you create a new map layer as part of your + * XPLMCreateMapLayer_t. The functions here hook into X-Plane's built-in map + * drawing functionality for icons and labels, so that you get a consistent + * style with the rest of the X-Plane map. + * + * Note that the X-Plane 11 map introduces a strict ordering: layers of type + * xplm_MapLayer_Fill get drawn beneath all xplm_MapLayer_Markings layers. + * Likewise, all OpenGL drawing (performed in your layer's + * XPLMMapDrawingCallback_f) will appear beneath any icons and labels you + * draw. + * + */ + + +/* + * XPLMMapOrientation + * + * Indicates whether a map element should be match its rotation to the map + * itself, or to the user interface. For instance, the map itself may be + * rotated such that "up" matches the user's aircraft, but you may want to + * draw a text label such that it is always rotated zero degrees relative to + * the user's perspective. In that case, you would have it draw with UI + * orientation. + * + */ +enum { + /* Orient such that a 0 degree rotation matches the map's north */ + xplm_MapOrientation_Map = 0, + + /* Orient such that a 0 degree rotation is "up" relative to the user interface*/ + xplm_MapOrientation_UI = 1, + + +}; +typedef int XPLMMapOrientation; + +/* + * XPLMDrawMapIconFromSheet + * + * Enables plugin-created map layers to draw PNG icons using X-Plane's + * built-in icon drawing functionality. Only valid from within an + * XPLMIconDrawingCallback_t (but you can request an arbitrary number of icons + * to be drawn from within your callback). + * + * X-Plane will automatically manage the memory for your texture so that it + * only has to be loaded from disk once as long as you continue drawing it + * per-frame. (When you stop drawing it, the memory may purged in a "garbage + * collection" pass, require a load from disk in the future.) + * + * Instead of having X-Plane draw a full PNG, this method allows you to use UV + * coordinates to request a portion of the image to be drawn. This allows you + * to use a single texture load (of an icon sheet, for example) to draw many + * icons. Doing so is much more efficient than drawing a dozen different small + * PNGs. + * + * The UV coordinates used here treat the texture you load as being comprised + * of a number of identically sized "cells." You specify the width and height + * in cells (ds and dt, respectively), as well as the coordinates within the + * cell grid for the sub-image you'd like to draw. + * + * Note that you can use different ds and dt values in subsequent calls with + * the same texture sheet. This enables you to use icons of different sizes in + * the same sheet if you arrange them properly in the PNG. + * + * This function is only valid from within an XPLMIconDrawingCallback_t (but + * you can request an arbitrary number of icons to be drawn from within your + * callback). + * + */ +XPLM_API void XPLMDrawMapIconFromSheet( + XPLMMapLayerID layer, + const char * inPngPath, + int s, + int t, + int ds, + int dt, + float mapX, + float mapY, + XPLMMapOrientation orientation, + float rotationDegrees, + float mapWidth); + +/* + * XPLMDrawMapLabel + * + * Enables plugin-created map layers to draw text labels using X-Plane's + * built-in labeling functionality. Only valid from within an + * XPLMMapLabelDrawingCallback_f (but you can request an arbitrary number of + * text labels to be drawn from within your callback). + * + */ +XPLM_API void XPLMDrawMapLabel( + XPLMMapLayerID layer, + const char * inText, + float mapX, + float mapY, + XPLMMapOrientation orientation, + float rotationDegrees); + +#endif /* XPLM300 */ +#if defined(XPLM300) +/*************************************************************************** + * MAP PROJECTIONS + ***************************************************************************/ +/* + * As of X-Plane 11, the map draws using true cartographic projections, and + * different maps may use different projections. Thus, to draw at a particular + * latitude and longitude, you must first transform your real-world + * coordinates into map coordinates. + * + * The map projection is also responsible for giving you the current scale of + * the map. That is, the projection can tell you how many map units correspond + * to 1 meter at a given point. + * + * Finally, the map projection can give you the current rotation of the map. + * Since X-Plane 11 maps can rotate to match the heading of the aircraft, the + * map's rotation can potentially change every frame. + * + */ + + +/* + * XPLMMapProject + * + * Projects a latitude/longitude into map coordinates. This is the inverse of + * XPLMMapUnproject(). + * + * Only valid from within a map layer callback (one of + * XPLMMapPrepareCacheCallback_f, XPLMMapDrawingCallback_f, + * XPLMMapIconDrawingCallback_f, or XPLMMapLabelDrawingCallback_f.) + * + */ +XPLM_API void XPLMMapProject( + XPLMMapProjectionID projection, + double latitude, + double longitude, + float * outX, + float * outY); + +/* + * XPLMMapUnproject + * + * Transforms map coordinates back into a latitude and longitude. This is the + * inverse of XPLMMapProject(). + * + * Only valid from within a map layer callback (one of + * XPLMMapPrepareCacheCallback_f, XPLMMapDrawingCallback_f, + * XPLMMapIconDrawingCallback_f, or XPLMMapLabelDrawingCallback_f.) + * + */ +XPLM_API void XPLMMapUnproject( + XPLMMapProjectionID projection, + float mapX, + float mapY, + double * outLatitude, + double * outLongitude); + +/* + * XPLMMapScaleMeter + * + * Returns the number of map units that correspond to a distance of one meter + * at a given set of map coordinates. + * + * Only valid from within a map layer callback (one of + * XPLMMapPrepareCacheCallback_f, XPLMMapDrawingCallback_f, + * XPLMMapIconDrawingCallback_f, or XPLMMapLabelDrawingCallback_f.) + * + */ +XPLM_API float XPLMMapScaleMeter( + XPLMMapProjectionID projection, + float mapX, + float mapY); + +/* + * XPLMMapGetNorthHeading + * + * Returns the heading (in degrees clockwise) from the positive Y axis in the + * cartesian mapping coordinate system to true north at the point passed in. + * You can use it as a clockwise rotational offset to align icons and other + * 2-d drawing with true north on the map, compensating for rotations in the + * map due to projection. + * + * Only valid from within a map layer callback (one of + * XPLMMapPrepareCacheCallback_f, XPLMMapDrawingCallback_f, + * XPLMMapIconDrawingCallback_f, or XPLMMapLabelDrawingCallback_f.) + * + */ +XPLM_API float XPLMMapGetNorthHeading( + XPLMMapProjectionID projection, + float mapX, + float mapY); + +#endif /* XPLM300 */ +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/SDK/CHeaders/XPLM/XPLMMenus.h b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/XPLM/XPLMMenus.h new file mode 100644 index 0000000..f5802ab --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/XPLM/XPLMMenus.h @@ -0,0 +1,290 @@ +#ifndef _XPLMMenus_h_ +#define _XPLMMenus_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPLMMenus + ***************************************************************************/ +/* + * Plug-ins can create menus in the menu bar of X-Plane. This is done by + * creating a menu and then creating items. Menus are referred to by an + * opaque ID. Items are referred to by (zero-based) index number. + * + * Menus are "sandboxed" between plugins---no plugin can access the menus of + * any other plugin. Furthermore, all menu indices are relative to your + * plugin's menus only; if your plugin creates two sub-menus in the Plugins + * menu at different times, it doesn't matter how many other plugins also + * create sub-menus of Plugins in the intervening time: your sub-menus will be + * given menu indices 0 and 1. (The SDK does some work in the back-end to + * filter out menus that are irrelevant to your plugin in order to deliver + * this consistency for each plugin.) + * + * When you create a menu item, you specify how we should handle clicks on + * that menu item. You can either have the XPLM trigger a callback (the + * XPLMMenuHandler_f associated with the menu that contains the item), or you + * can simply have a command be triggered (with no associated call to your + * menu handler). The advantage of the latter method is that X-Plane will + * display any keyboard shortcuts associated with the command. (In contrast, + * there are no keyboard shortcuts associated with menu handler callbacks with + * specific parameters.) + * + * Menu text in X-Plane is UTF8; X-Plane's character set covers latin, greek + * and cyrillic characters, Katakana, as well as some Japanese symbols. Some + * APIs have a inDeprecatedAndIgnored parameter that used to select a + * character set; since X-Plane 9 all localization is done via UTF-8 only. + * + */ + +#include "XPLMDefs.h" +#include "XPLMUtilities.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*************************************************************************** + * XPLM MENUS + ***************************************************************************/ + +/* + * XPLMMenuCheck + * + * These enumerations define the various 'check' states for an X-Plane menu. + * 'checking' in X-Plane actually appears as a light which may or may not be + * lit. So there are three possible states. + * + */ +enum { + /* there is no symbol to the left of the menu item. */ + xplm_Menu_NoCheck = 0, + + /* the menu has a mark next to it that is unmarked (not lit). */ + xplm_Menu_Unchecked = 1, + + /* the menu has a mark next to it that is checked (lit). */ + xplm_Menu_Checked = 2, + + +}; +typedef int XPLMMenuCheck; + +/* + * XPLMMenuID + * + * This is a unique ID for each menu you create. + * + */ +typedef void * XPLMMenuID; + +/* + * XPLMMenuHandler_f + * + * A menu handler function takes two reference pointers, one for the menu + * (specified when the menu was created) and one for the item (specified when + * the item was created). + * + */ +typedef void (* XPLMMenuHandler_f)( + void * inMenuRef, + void * inItemRef); + +/* + * XPLMFindPluginsMenu + * + * This function returns the ID of the plug-ins menu, which is created for you + * at startup. + * + */ +XPLM_API XPLMMenuID XPLMFindPluginsMenu(void); + +#if defined(XPLM300) +/* + * XPLMFindAircraftMenu + * + * This function returns the ID of the menu for the currently-loaded aircraft, + * used for showing aircraft-specific commands. + * + * The aircraft menu is created by X-Plane at startup, but it remains hidden + * until it is populated via XPLMAppendMenuItem() or + * XPLMAppendMenuItemWithCommand(). + * + * Only plugins loaded with the user's current aircraft are allowed to access + * the aircraft menu. For all other plugins, this will return NULL, and any + * attempts to add menu items to it will fail. + * + */ +XPLM_API XPLMMenuID XPLMFindAircraftMenu(void); +#endif /* XPLM300 */ + +/* + * XPLMCreateMenu + * + * This function creates a new menu and returns its ID. It returns NULL if + * the menu cannot be created. Pass in a parent menu ID and an item index to + * create a submenu, or NULL for the parent menu to put the menu in the menu + * bar. The menu's name is only used if the menu is in the menubar. You also + * pass a handler function and a menu reference value. Pass NULL for the + * handler if you do not need callbacks from the menu (for example, if it only + * contains submenus). + * + * Important: you must pass a valid, non-empty menu title even if the menu is + * a submenu where the title is not visible. + * + */ +XPLM_API XPLMMenuID XPLMCreateMenu( + const char * inName, + XPLMMenuID inParentMenu, + int inParentItem, + XPLMMenuHandler_f inHandler, + void * inMenuRef); + +/* + * XPLMDestroyMenu + * + * This function destroys a menu that you have created. Use this to remove a + * submenu if necessary. (Normally this function will not be necessary.) + * + */ +XPLM_API void XPLMDestroyMenu( + XPLMMenuID inMenuID); + +/* + * XPLMClearAllMenuItems + * + * This function removes all menu items from a menu, allowing you to rebuild + * it. Use this function if you need to change the number of items on a menu. + * + */ +XPLM_API void XPLMClearAllMenuItems( + XPLMMenuID inMenuID); + +/* + * XPLMAppendMenuItem + * + * This routine appends a new menu item to the bottom of a menu and returns + * its index. Pass in the menu to add the item to, the items name, and a void + * * ref for this item. + * + * Returns a negative index if the append failed (due to an invalid parent + * menu argument). + * + * Note that all menu indices returned are relative to your plugin's menus + * only; if your plugin creates two sub-menus in the Plugins menu at different + * times, it doesn't matter how many other plugins also create sub-menus of + * Plugins in the intervening time: your sub-menus will be given menu indices + * 0 and 1. (The SDK does some work in the back-end to filter out menus that + * are irrelevant to your plugin in order to deliver this consistency for each + * plugin.) + * + */ +XPLM_API int XPLMAppendMenuItem( + XPLMMenuID inMenu, + const char * inItemName, + void * inItemRef, + int inDeprecatedAndIgnored); + +#if defined(XPLM300) +/* + * XPLMAppendMenuItemWithCommand + * + * Like XPLMAppendMenuItem(), but instead of the new menu item triggering the + * XPLMMenuHandler_f of the containiner menu, it will simply execute the + * command you pass in. Using a command for your menu item allows the user to + * bind a keyboard shortcut to the command and see that shortcut represented + * in the menu. + * + * Returns a negative index if the append failed (due to an invalid parent + * menu argument). + * + * Like XPLMAppendMenuItem(), all menu indices are relative to your plugin's + * menus only. + * + */ +XPLM_API int XPLMAppendMenuItemWithCommand( + XPLMMenuID inMenu, + const char * inItemName, + XPLMCommandRef inCommandToExecute); +#endif /* XPLM300 */ + +/* + * XPLMAppendMenuSeparator + * + * This routine adds a separator to the end of a menu. + * + * Returns a negative index if the append failed (due to an invalid parent + * menu argument). + * + */ +XPLM_API void XPLMAppendMenuSeparator( + XPLMMenuID inMenu); + +/* + * XPLMSetMenuItemName + * + * This routine changes the name of an existing menu item. Pass in the menu + * ID and the index of the menu item. + * + */ +XPLM_API void XPLMSetMenuItemName( + XPLMMenuID inMenu, + int inIndex, + const char * inItemName, + int inDeprecatedAndIgnored); + +/* + * XPLMCheckMenuItem + * + * Set whether a menu item is checked. Pass in the menu ID and item index. + * + */ +XPLM_API void XPLMCheckMenuItem( + XPLMMenuID inMenu, + int index, + XPLMMenuCheck inCheck); + +/* + * XPLMCheckMenuItemState + * + * This routine returns whether a menu item is checked or not. A menu item's + * check mark may be on or off, or a menu may not have an icon at all. + * + */ +XPLM_API void XPLMCheckMenuItemState( + XPLMMenuID inMenu, + int index, + XPLMMenuCheck * outCheck); + +/* + * XPLMEnableMenuItem + * + * Sets whether this menu item is enabled. Items start out enabled. + * + */ +XPLM_API void XPLMEnableMenuItem( + XPLMMenuID inMenu, + int index, + int enabled); + +#if defined(XPLM210) +/* + * XPLMRemoveMenuItem + * + * Removes one item from a menu. Note that all menu items below are moved up + * one; your plugin must track the change in index numbers. + * + */ +XPLM_API void XPLMRemoveMenuItem( + XPLMMenuID inMenu, + int inIndex); +#endif /* XPLM210 */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/SDK/CHeaders/XPLM/XPLMNavigation.h b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/XPLM/XPLMNavigation.h new file mode 100644 index 0000000..716caf0 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/XPLM/XPLMNavigation.h @@ -0,0 +1,362 @@ +#ifndef _XPLMNavigation_h_ +#define _XPLMNavigation_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPLMNavigation + ***************************************************************************/ +/* + * The XPLM Navigation APIs give you some access to the navigation databases + * inside X-Plane. X-Plane stores all navigation information in RAM, so by + * using these APIs you can gain access to most information without having to + * go to disk or parse the files yourself. + * + * You can also use this API to program the FMS. You must use the navigation + * APIs to find the nav-aids you want to program into the FMS, since the FMS + * is powered internally by X-Plane's navigation database. + * + */ + +#include "XPLMDefs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*************************************************************************** + * NAVIGATION DATABASE ACCESS + ***************************************************************************/ + +/* + * XPLMNavType + * + * These enumerations define the different types of navaids. They are each + * defined with a separate bit so that they may be bit-wise added together to + * form sets of nav-aid types. + * + * NOTE: xplm_Nav_LatLon is a specific lat-lon coordinate entered into the + * FMS. It will not exist in the database, and cannot be programmed into the + * FMS. Querying the FMS for navaids will return it. Use + * XPLMSetFMSEntryLatLon to set a lat/lon waypoint. + * + */ +enum { + xplm_Nav_Unknown = 0, + + xplm_Nav_Airport = 1, + + xplm_Nav_NDB = 2, + + xplm_Nav_VOR = 4, + + xplm_Nav_ILS = 8, + + xplm_Nav_Localizer = 16, + + xplm_Nav_GlideSlope = 32, + + xplm_Nav_OuterMarker = 64, + + xplm_Nav_MiddleMarker = 128, + + xplm_Nav_InnerMarker = 256, + + xplm_Nav_Fix = 512, + + xplm_Nav_DME = 1024, + + xplm_Nav_LatLon = 2048, + + +}; +typedef int XPLMNavType; + +/* + * XPLMNavRef + * + * XPLMNavRef is an iterator into the navigation database. The navigation + * database is essentially an array, but it is not necessarily densely + * populated. The only assumption you can safely make is that like-typed + * nav-aids are grouped together. + * + * Use XPLMNavRef to refer to a nav-aid. + * + * XPLM_NAV_NOT_FOUND is returned by functions that return an XPLMNavRef when + * the iterator must be invalid. + * + */ +typedef int XPLMNavRef; + +#define XPLM_NAV_NOT_FOUND -1 + +/* + * XPLMGetFirstNavAid + * + * This returns the very first navaid in the database. Use this to traverse + * the entire database. Returns XPLM_NAV_NOT_FOUND if the nav database is + * empty. + * + */ +XPLM_API XPLMNavRef XPLMGetFirstNavAid(void); + +/* + * XPLMGetNextNavAid + * + * Given a valid nav aid ref, this routine returns the next navaid. It + * returns XPLM_NAV_NOT_FOUND if the nav aid passed in was invalid or if the + * navaid passed in was the last one in the database. Use this routine to + * iterate across all like-typed navaids or the entire database. + * + */ +XPLM_API XPLMNavRef XPLMGetNextNavAid( + XPLMNavRef inNavAidRef); + +/* + * XPLMFindFirstNavAidOfType + * + * This routine returns the ref of the first navaid of the given type in the + * database or XPLM_NAV_NOT_FOUND if there are no navaids of that type in the + * database. You must pass exactly one nav aid type to this routine. + * + */ +XPLM_API XPLMNavRef XPLMFindFirstNavAidOfType( + XPLMNavType inType); + +/* + * XPLMFindLastNavAidOfType + * + * This routine returns the ref of the last navaid of the given type in the + * database or XPLM_NAV_NOT_FOUND if there are no navaids of that type in the + * database. You must pass exactly one nav aid type to this routine. + * + */ +XPLM_API XPLMNavRef XPLMFindLastNavAidOfType( + XPLMNavType inType); + +/* + * XPLMFindNavAid + * + * This routine provides a number of searching capabilities for the nav + * database. XPLMFindNavAid will search through every nav aid whose type is + * within inType (multiple types may be added together) and return any + * nav-aids found based on the following rules: + * + * * If inLat and inLon are not NULL, the navaid nearest to that lat/lon will + * be returned, otherwise the last navaid found will be returned. + * + * * If inFrequency is not NULL, then any navaids considered must match this + * frequency. Note that this will screen out radio beacons that do not have + * frequency data published (like inner markers) but not fixes and airports. + * + * * If inNameFragment is not NULL, only navaids that contain the fragment in + * their name will be returned. + * + * * If inIDFragment is not NULL, only navaids that contain the fragment in + * their IDs will be returned. + * + * This routine provides a simple way to do a number of useful searches: + * * Find the nearest navaid on this frequency. + * * Find the nearest airport. + * * Find the VOR whose ID is "KBOS". + * * Find the nearest airport whose name contains "Chicago". + * + */ +XPLM_API XPLMNavRef XPLMFindNavAid( + const char * inNameFragment, /* Can be NULL */ + const char * inIDFragment, /* Can be NULL */ + float * inLat, /* Can be NULL */ + float * inLon, /* Can be NULL */ + int * inFrequency, /* Can be NULL */ + XPLMNavType inType); + +/* + * XPLMGetNavAidInfo + * + * This routine returns information about a navaid. Any non-null field is + * filled out with information if it is available. + * + * Frequencies are in the nav.dat convention as described in the X-Plane nav + * database FAQ: NDB frequencies are exact, all others are multiplied by 100. + * + * The buffer for IDs should be at least 6 chars and the buffer for names + * should be at least 41 chars, but since these values are likely to go up, I + * recommend passing at least 32 chars for IDs and 256 chars for names when + * possible. + * + * The outReg parameter tells if the navaid is within the local "region" of + * loaded DSFs. (This information may not be particularly useful to plugins.) + * The parameter is a single byte value 1 for true or 0 for false, not a C + * string. + * + */ +XPLM_API void XPLMGetNavAidInfo( + XPLMNavRef inRef, + XPLMNavType * outType, /* Can be NULL */ + float * outLatitude, /* Can be NULL */ + float * outLongitude, /* Can be NULL */ + float * outHeight, /* Can be NULL */ + int * outFrequency, /* Can be NULL */ + float * outHeading, /* Can be NULL */ + char * outID, /* Can be NULL */ + char * outName, /* Can be NULL */ + char * outReg); /* Can be NULL */ + +/*************************************************************************** + * FLIGHT MANAGEMENT COMPUTER + ***************************************************************************/ +/* + * Note: the FMS works based on an array of entries. Indices into the array + * are zero-based. Each entry is a nav-aid plus an altitude. The FMS tracks + * the currently displayed entry and the entry that it is flying to. + * + * The FMS must be programmed with contiguous entries, so clearing an entry at + * the end shortens the effective flight plan. There is a max of 100 + * waypoints in the flight plan. + * + */ + + +/* + * XPLMCountFMSEntries + * + * This routine returns the number of entries in the FMS. + * + */ +XPLM_API int XPLMCountFMSEntries(void); + +/* + * XPLMGetDisplayedFMSEntry + * + * This routine returns the index of the entry the pilot is viewing. + * + */ +XPLM_API int XPLMGetDisplayedFMSEntry(void); + +/* + * XPLMGetDestinationFMSEntry + * + * This routine returns the index of the entry the FMS is flying to. + * + */ +XPLM_API int XPLMGetDestinationFMSEntry(void); + +/* + * XPLMSetDisplayedFMSEntry + * + * This routine changes which entry the FMS is showing to the index specified. + * + */ +XPLM_API void XPLMSetDisplayedFMSEntry( + int inIndex); + +/* + * XPLMSetDestinationFMSEntry + * + * This routine changes which entry the FMS is flying the aircraft toward. + * + */ +XPLM_API void XPLMSetDestinationFMSEntry( + int inIndex); + +/* + * XPLMGetFMSEntryInfo + * + * This routine returns information about a given FMS entry. If the entry is + * an airport or navaid, a reference to a nav entry can be returned allowing + * you to find additional information (such as a frequency, ILS heading, name, + * etc.). Note that this reference can be XPLM_NAV_NOT_FOUND until the + * information has been looked up asynchronously, so after flightplan changes, + * it might take up to a second for this field to become populated. The other + * information is available immediately. For a lat/lon entry, the lat/lon is + * returned by this routine but the navaid cannot be looked up (and the + * reference will be XPLM_NAV_NOT_FOUND). FMS name entry buffers should be at + * least 256 chars in length. + * + * WARNING: Due to a bug in X-Plane prior to 11.31, the navaid reference will + * not be set to XPLM_NAV_NOT_FOUND while no data is available, and instead + * just remain the value of the variable that you passed the pointer to. + * Therefore, always initialize the variable to XPLM_NAV_NOT_FOUND before + * passing the pointer to this function. + * + */ +XPLM_API void XPLMGetFMSEntryInfo( + int inIndex, + XPLMNavType * outType, /* Can be NULL */ + char * outID, /* Can be NULL */ + XPLMNavRef * outRef, /* Can be NULL */ + int * outAltitude, /* Can be NULL */ + float * outLat, /* Can be NULL */ + float * outLon); /* Can be NULL */ + +/* + * XPLMSetFMSEntryInfo + * + * This routine changes an entry in the FMS to have the destination navaid + * passed in and the altitude specified. Use this only for airports, fixes, + * and radio-beacon navaids. Currently of radio beacons, the FMS can only + * support VORs and NDBs. Use the routines below to clear or fly to a lat/lon. + * + */ +XPLM_API void XPLMSetFMSEntryInfo( + int inIndex, + XPLMNavRef inRef, + int inAltitude); + +/* + * XPLMSetFMSEntryLatLon + * + * This routine changes the entry in the FMS to a lat/lon entry with the given + * coordinates. + * + */ +XPLM_API void XPLMSetFMSEntryLatLon( + int inIndex, + float inLat, + float inLon, + int inAltitude); + +/* + * XPLMClearFMSEntry + * + * This routine clears the given entry, potentially shortening the flight + * plan. + * + */ +XPLM_API void XPLMClearFMSEntry( + int inIndex); + +/*************************************************************************** + * GPS RECEIVER + ***************************************************************************/ +/* + * These APIs let you read data from the GPS unit. + * + */ + +/* + * XPLMGetGPSDestinationType + * + * This routine returns the type of the currently selected GPS destination, + * one of fix, airport, VOR or NDB. + * + */ +XPLM_API XPLMNavType XPLMGetGPSDestinationType(void); + +/* + * XPLMGetGPSDestination + * + * This routine returns the current GPS destination. + * + */ +XPLM_API XPLMNavRef XPLMGetGPSDestination(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/SDK/CHeaders/XPLM/XPLMPlanes.h b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/XPLM/XPLMPlanes.h new file mode 100644 index 0000000..486302d --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/XPLM/XPLMPlanes.h @@ -0,0 +1,287 @@ +#ifndef _XPLMPlanes_h_ +#define _XPLMPlanes_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPLMPlanes + ***************************************************************************/ +/* + * The XPLMPlanes APIs allow you to control the various aircraft in X-Plane, + * both the user's and the sim's. + * + * *Note*: unlike almost all other APIs in the SDK, aircraft paths are _full_ + * file system paths for historical reasons. You'll need to prefix all + * relative paths with the X-Plane path as accessed via XPLMGetSystemPath. + * + */ + +#include "XPLMDefs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*************************************************************************** + * USER AIRCRAFT ACCESS + ***************************************************************************/ + +/* + * XPLMSetUsersAircraft + * + * This routine changes the user's aircraft. Note that this will reinitialize + * the user to be on the nearest airport's first runway. Pass in a full path + * (hard drive and everything including the .acf extension) to the .acf file. + * + */ +XPLM_API void XPLMSetUsersAircraft( + const char * inAircraftPath); +/* + * XPLMPlaceUserAtAirport + * + * This routine places the user at a given airport. Specify the airport by + * its X-Plane airport ID (e.g. 'KBOS'). + * + */ +XPLM_API void XPLMPlaceUserAtAirport( + const char * inAirportCode); +#if defined(XPLM300) +/* + * XPLMPlaceUserAtLocation + * + * Places the user at a specific location after performing any necessary + * scenery loads. + * + * As with in-air starts initiated from the X-Plane user interface, the + * aircraft will always start with its engines running, regardless of the + * user's preferences (i.e., regardless of what the dataref + * `sim/operation/prefs/startup_running` says). + * + */ +XPLM_API void XPLMPlaceUserAtLocation( + double latitudeDegrees, + double longitudeDegrees, + float elevationMetersMSL, + float headingDegreesTrue, + float speedMetersPerSecond); +#endif /* XPLM300 */ +/*************************************************************************** + * GLOBAL AIRCRAFT ACCESS + ***************************************************************************/ + +/* The user's aircraft is always index 0. */ +#define XPLM_USER_AIRCRAFT 0 +#if defined(XPLM_DEPRECATED) +/* + * XPLMPlaneDrawState_t + * + * This structure contains additional plane parameter info to be passed to + * draw plane. Make sure to fill in the size of the structure field with + * sizeof(XPLMDrawPlaneState_t) so that the XPLM can tell how many fields you + * knew about when compiling your plugin (since more fields may be added + * later). + * + * Most of these fields are ratios from 0 to 1 for control input. X-Plane + * calculates what the actual controls look like based on the .acf file for + * that airplane. Note for the yoke inputs, this is what the pilot of the + * plane has commanded (post artificial stability system if there were one) + * and affects aelerons, rudder, etc. It is not necessarily related to the + * actual position of the plane! + * + */ +typedef struct { + /* The size of the draw state struct. */ + int structSize; + /* A ratio from [0..1] describing how far the landing gear is extended. */ + float gearPosition; + /* Ratio of flap deployment, 0 = up, 1 = full deploy. */ + float flapRatio; + /* Ratio of spoiler deployment, 0 = none, 1 = full deploy. */ + float spoilerRatio; + /* Ratio of speed brake deployment, 0 = none, 1 = full deploy. */ + float speedBrakeRatio; + /* Ratio of slat deployment, 0 = none, 1 = full deploy. */ + float slatRatio; + /* Wing sweep ratio, 0 = forward, 1 = swept. */ + float wingSweep; + /* Thrust power, 0 = none, 1 = full fwd, -1 = full reverse. */ + float thrust; + /* Total pitch input for this plane. */ + float yokePitch; + /* Total Heading input for this plane. */ + float yokeHeading; + /* Total Roll input for this plane. */ + float yokeRoll; +} XPLMPlaneDrawState_t; +#endif /* XPLM_DEPRECATED */ +/* + * XPLMCountAircraft + * + * This function returns the number of aircraft X-Plane is capable of having, + * as well as the number of aircraft that are currently active. These numbers + * count the user's aircraft. It can also return the plugin that is currently + * controlling aircraft. In X-Plane 7, this routine reflects the number of + * aircraft the user has enabled in the rendering options window. + * + */ +XPLM_API void XPLMCountAircraft( + int * outTotalAircraft, + int * outActiveAircraft, + XPLMPluginID * outController); +/* + * XPLMGetNthAircraftModel + * + * This function returns the aircraft model for the Nth aircraft. Indices are + * zero based, with zero being the user's aircraft. The file name should be + * at least 256 chars in length; the path should be at least 512 chars in + * length. + * + */ +XPLM_API void XPLMGetNthAircraftModel( + int inIndex, + char * outFileName, + char * outPath); +/*************************************************************************** + * EXCLUSIVE AIRCRAFT ACCESS + ***************************************************************************/ +/* + * The following routines require exclusive access to the airplane APIs. Only + * one plugin may have this access at a time. + * + */ + + +/* + * XPLMPlanesAvailable_f + * + * Your airplanes available callback is called when another plugin gives up + * access to the multiplayer planes. Use this to wait for access to + * multiplayer. + * + */ +typedef void (* XPLMPlanesAvailable_f)( + void * inRefcon); + +/* + * XPLMAcquirePlanes + * + * XPLMAcquirePlanes grants your plugin exclusive access to the aircraft. It + * returns 1 if you gain access, 0 if you do not. + * + * inAircraft - pass in an array of pointers to strings specifying the planes + * you want loaded. For any plane index you do not want loaded, pass a + * 0-length string. Other strings should be full paths with the .acf + * extension. NULL terminates this array, or pass NULL if there are no planes + * you want loaded. + * + * If you pass in a callback and do not receive access to the planes your + * callback will be called when the airplanes are available. If you do receive + * airplane access, your callback will not be called. + * + */ +XPLM_API int XPLMAcquirePlanes( + char ** inAircraft, /* Can be NULL */ + XPLMPlanesAvailable_f inCallback, + void * inRefcon); + +/* + * XPLMReleasePlanes + * + * Call this function to release access to the planes. Note that if you are + * disabled, access to planes is released for you and you must reacquire it. + * + */ +XPLM_API void XPLMReleasePlanes(void); + +/* + * XPLMSetActiveAircraftCount + * + * This routine sets the number of active planes. If you pass in a number + * higher than the total number of planes availables, only the total number of + * planes available is actually used. + * + */ +XPLM_API void XPLMSetActiveAircraftCount( + int inCount); + +/* + * XPLMSetAircraftModel + * + * This routine loads an aircraft model. It may only be called if you have + * exclusive access to the airplane APIs. Pass in the path of the model with + * the .acf extension. The index is zero based, but you may not pass in 0 + * (use XPLMSetUsersAircraft to load the user's aircracft). + * + */ +XPLM_API void XPLMSetAircraftModel( + int inIndex, + const char * inAircraftPath); + +/* + * XPLMDisableAIForPlane + * + * This routine turns off X-Plane's AI for a given plane. The plane will + * continue to draw and be a real plane in X-Plane, but will not move itself. + * + */ +XPLM_API void XPLMDisableAIForPlane( + int inPlaneIndex); + +#if defined(XPLM_DEPRECATED) +/* + * XPLMDrawAircraft + * + * WARNING: Aircraft drawing via this API is deprecated and will not work in + * future versions of X-Plane. Use XPLMInstance for 3-d drawing of custom + * aircraft models. + * + * This routine draws an aircraft. It can only be called from a 3-d drawing + * callback. Pass in the position of the plane in OpenGL local coordinates + * and the orientation of the plane. A 1 for full drawing indicates that the + * whole plane must be drawn; a 0 indicates you only need the nav lights + * drawn. (This saves rendering time when planes are far away.) + * + */ +XPLM_API void XPLMDrawAircraft( + int inPlaneIndex, + float inX, + float inY, + float inZ, + float inPitch, + float inRoll, + float inYaw, + int inFullDraw, + XPLMPlaneDrawState_t * inDrawStateInfo); +#endif /* XPLM_DEPRECATED */ + +#if defined(XPLM_DEPRECATED) +/* + * XPLMReinitUsersPlane + * + * WARNING: DO NOT USE. Use XPLMPlaceUserAtAirport or + * XPLMPlaceUserAtLocation. + * + * This function recomputes the derived flight model data from the aircraft + * structure in memory. If you have used the data access layer to modify the + * aircraft structure, use this routine to resynchronize X-Plane; since + * X-Plane works at least partly from derived values, the sim will not behave + * properly until this is called. + * + * WARNING: this routine does not necessarily place the airplane at the + * airport; use XPLMSetUsersAircraft to be compatible. This routine is + * provided to do special experimentation with flight models without resetting + * flight. + * + */ +XPLM_API void XPLMReinitUsersPlane(void); +#endif /* XPLM_DEPRECATED */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/SDK/CHeaders/XPLM/XPLMPlugin.h b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/XPLM/XPLMPlugin.h new file mode 100644 index 0000000..be5d06c --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/XPLM/XPLMPlugin.h @@ -0,0 +1,422 @@ +#ifndef _XPLMPlugin_h_ +#define _XPLMPlugin_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPLMPlugin + ***************************************************************************/ +/* + * These APIs provide facilities to find and work with other plugins and + * manage other plugins. + * + */ + +#include "XPLMDefs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*************************************************************************** + * FINDING PLUGINS + ***************************************************************************/ +/* + * These APIs allow you to find another plugin or yourself, or iterate across + * all plugins. For example, if you wrote an FMS plugin that needed to talk + * to an autopilot plugin, you could use these APIs to locate the autopilot + * plugin. + * + */ + + +/* + * XPLMGetMyID + * + * This routine returns the plugin ID of the calling plug-in. Call this to + * get your own ID. + * + */ +XPLM_API XPLMPluginID XPLMGetMyID(void); + +/* + * XPLMCountPlugins + * + * This routine returns the total number of plug-ins that are loaded, both + * disabled and enabled. + * + */ +XPLM_API int XPLMCountPlugins(void); + +/* + * XPLMGetNthPlugin + * + * This routine returns the ID of a plug-in by index. Index is 0 based from 0 + * to XPLMCountPlugins-1, inclusive. Plugins may be returned in any arbitrary + * order. + * + */ +XPLM_API XPLMPluginID XPLMGetNthPlugin( + int inIndex); + +/* + * XPLMFindPluginByPath + * + * This routine returns the plug-in ID of the plug-in whose file exists at the + * passed in absolute file system path. XPLM_NO_PLUGIN_ID is returned if the + * path does not point to a currently loaded plug-in. + * + */ +XPLM_API XPLMPluginID XPLMFindPluginByPath( + const char * inPath); + +/* + * XPLMFindPluginBySignature + * + * This routine returns the plug-in ID of the plug-in whose signature matches + * what is passed in or XPLM_NO_PLUGIN_ID if no running plug-in has this + * signature. Signatures are the best way to identify another plug-in as they + * are independent of the file system path of a plug-in or the human-readable + * plug-in name, and should be unique for all plug-ins. Use this routine to + * locate another plugin that your plugin interoperates with + * + */ +XPLM_API XPLMPluginID XPLMFindPluginBySignature( + const char * inSignature); + +/* + * XPLMGetPluginInfo + * + * This routine returns information about a plug-in. Each parameter should be + * a pointer to a buffer of at least + * 256 characters, or NULL to not receive the information. + * + * outName - the human-readable name of the plug-in. outFilePath - the + * absolute file path to the file that contains this plug-in. outSignature - a + * unique string that identifies this plug-in. outDescription - a + * human-readable description of this plug-in. + * + */ +XPLM_API void XPLMGetPluginInfo( + XPLMPluginID inPlugin, + char * outName, /* Can be NULL */ + char * outFilePath, /* Can be NULL */ + char * outSignature, /* Can be NULL */ + char * outDescription); /* Can be NULL */ + +/*************************************************************************** + * ENABLING/DISABLING PLUG-INS + ***************************************************************************/ +/* + * These routines are used to work with plug-ins and manage them. Most + * plugins will not need to use these APIs. + * + */ + + +/* + * XPLMIsPluginEnabled + * + * Returns whether the specified plug-in is enabled for running. + * + */ +XPLM_API int XPLMIsPluginEnabled( + XPLMPluginID inPluginID); + +/* + * XPLMEnablePlugin + * + * This routine enables a plug-in if it is not already enabled. It returns 1 + * if the plugin was enabled or successfully enables itself, 0 if it does not. + * Plugins may fail to enable (for example, if resources cannot be acquired) + * by returning 0 from their XPluginEnable callback. + * + */ +XPLM_API int XPLMEnablePlugin( + XPLMPluginID inPluginID); + +/* + * XPLMDisablePlugin + * + * This routine disableds an enabled plug-in. + * + */ +XPLM_API void XPLMDisablePlugin( + XPLMPluginID inPluginID); + +/* + * XPLMReloadPlugins + * + * This routine reloads all plug-ins. Once this routine is called and you + * return from the callback you were within (e.g. a menu select callback) you + * will receive your XPluginDisable and XPluginStop callbacks and your DLL + * will be unloaded, then the start process happens as if the sim was starting + * up. + * + */ +XPLM_API void XPLMReloadPlugins(void); + +/*************************************************************************** + * INTERPLUGIN MESSAGING + ***************************************************************************/ +/* + * Plugin messages are defined as 32-bit integers. Messages below 0x00FFFFFF + * are reserved for X-Plane and the plugin SDK. + * + * Messages come with a pointer parameter; the meaning of this pointer depends + * on the message itself. In some messages, the pointer parameter contains an + * actual typed pointer to data that can be inspected in the plugin; in these + * cases the documentation will state that the parameter "points to" + * information. + * + * in other cases, the value of the pointer is actually an integral number + * stuffed into the pointer's storage. In these second cases, the pointer + * parameter needs to be cast, not dereferenced. In these caess, the + * documentation will state that the parameter "contains" a value, which will + * always be an integral type. + * + * Some messages don't use the pointer parameter - in this case your plugin + * should ignore it. + * + * Messages have two conceptual uses: notifications and commands. Commands + * are sent from one plugin to another to induce behavior; notifications are + * sent from one plugin to all others for informational purposes. It is + * important that commands and notifications not have the same values because + * this could cause a notification sent by one plugin to accidentally induce a + * command in another. + * + * By convention, plugin-defined notifications should have the high bit set + * (e.g. be greater or equal to unsigned 0x8000000) while commands should have + * this bit be cleared. + * + * The following messages are sent to your plugin by X-Plane. + * + */ + + +/* This message is sent to your plugin whenever the user's plane crashes. The * + * parameter is ignored. */ +#define XPLM_MSG_PLANE_CRASHED 101 + +/* This message is sent to your plugin whenever a new plane is loaded. The * + * parameter contains the index number of the plane being loaded; 0 indicates * + * the user's plane. */ +#define XPLM_MSG_PLANE_LOADED 102 + +/* This messages is sent whenever the user's plane is positioned at a new * + * airport. The parameter is ignored. */ +#define XPLM_MSG_AIRPORT_LOADED 103 + +/* This message is sent whenever new scenery is loaded. Use datarefs to * + * determine the new scenery files that were loaded. The parameter is ignored.*/ +#define XPLM_MSG_SCENERY_LOADED 104 + +/* This message is sent whenever the user adjusts the number of X-Plane * + * aircraft models. You must use XPLMCountPlanes to find out how many planes * + * are now available. This message will only be sent in XP7 and higher * + * because in XP6 the number of aircraft is not user-adjustable. The parameter* + * is ignored. */ +#define XPLM_MSG_AIRPLANE_COUNT_CHANGED 105 + +#if defined(XPLM200) +/* This message is sent to your plugin whenever a plane is unloaded. The * + * parameter contains the index number of the plane being unloaded; 0 * + * indicates the user's plane. The parameter is of type int, passed as the * + * value of the pointer. (That is: the parameter is an int, not a pointer to * + * an int.) */ +#define XPLM_MSG_PLANE_UNLOADED 106 +#endif /* XPLM200 */ + +#if defined(XPLM210) +/* This message is sent to your plugin right before X-Plane writes its * + * preferences file. You can use this for two purposes: to write your own * + * preferences, and to modify any datarefs to influence preferences output. * + * For example, if your plugin temporarily modifies saved preferences, you can* + * put them back to their default values here to avoid having the tweaks be * + * persisted if your plugin is not loaded on the next invocation of X-Plane. * + * The parameter is ignored. */ +#define XPLM_MSG_WILL_WRITE_PREFS 107 +#endif /* XPLM210 */ + +#if defined(XPLM210) +/* This message is sent to your plugin right after a livery is loaded for an * + * airplane. You can use this to check the new livery (via datarefs) and * + * react accordingly. The parameter contains the index number of the aircraft* + * whose livery is changing. */ +#define XPLM_MSG_LIVERY_LOADED 108 +#endif /* XPLM210 */ + +#if defined(XPLM301) +/* Sent to your plugin right before X-Plane enters virtual reality mode (at * + * which time any windows that are not positioned in VR mode will no longer be* + * visible to the user). The parameter is unused and should be ignored. */ +#define XPLM_MSG_ENTERED_VR 109 +#endif /* XPLM301 */ + +#if defined(XPLM301) +/* Sent to your plugin right before X-Plane leaves virtual reality mode (at * + * which time you may want to clean up windows that are positioned in VR * + * mode). The parameter is unused and should be ignored. */ +#define XPLM_MSG_EXITING_VR 110 +#endif /* XPLM301 */ + +#if defined(XPLM303) +/* Sent to your plugin if another plugin wants to take over AI planes. If you * + * are a synthetic traffic provider, that probably means a plugin for an * + * online network has connected and wants to supply aircraft flown by real * + * humans and you should cease to provide synthetic traffic. If however you * + * are providing online traffic from real humans, you probably don't want to * + * disconnect, in which case you just ignore this message. The sender is the * + * plugin ID of the plugin asking for control of the planes now. You can use * + * it to find out who is requesting and whether you should yield to them. * + * Synthetic traffic providers should always yield to online networks. The * + * parameter is unused and should be ignored. */ +#define XPLM_MSG_RELEASE_PLANES 111 +#endif /* XPLM303 */ + +/* + * XPLMSendMessageToPlugin + * + * This function sends a message to another plug-in or X-Plane. Pass + * XPLM_NO_PLUGIN_ID to broadcast to all plug-ins. Only enabled plug-ins with + * a message receive function receive the message. + * + */ +XPLM_API void XPLMSendMessageToPlugin( + XPLMPluginID inPlugin, + int inMessage, + void * inParam); + +#if defined(XPLM200) +/*************************************************************************** + * Plugin Features API + ***************************************************************************/ +/* + * The plugin features API allows your plugin to "sign up" for additional + * capabilities and plugin system features that are normally disabled for + * backward compatibility. This allows advanced plugins to "opt-in" to new + * behavior. + * + * Each feature is defined by a permanent string name. The feature string + * names will vary with the particular installation of X-Plane, so plugins + * should not expect a feature to be guaranteed present. + * + * XPLM_WANTS_REFLECTIONS + * ---------------------- + * + * Available in the SDK 2.0 and later for X-Plane 9, enabling this capability + * causes your plugin to receive drawing hook callbacks when X-Plane builds + * its off-screen reflection and shadow rendering passes. Plugins should + * enable this and examine the dataref sim/graphics/view/plane_render_type to + * determine whether the drawing callback is for a reflection, shadow + * calculation, or the main screen. Rendering can be simlified or omitted for + * reflections, and non-solid drawing should be skipped for shadow + * calculations. + * + * **Note**: direct drawing via draw callbacks is not recommended; use the + * XPLMInstance API to create object models instead. + * + * XPLM_USE_NATIVE_PATHS + * --------------------- + * + * available in the SDK 2.1 and later for X-Plane 10, this modifies the plugin + * system to use Unix-style paths on all operating systems. With this enabled: + * + * * OS X paths will match the native OS X Unix. + * * Windows will use forward slashes but preserve C:\ or another drive letter + * when using complete file paths. + * * Linux uses its native file system path scheme. + * + * Without this enabled: + * + * * OS X will use CFM file paths separated by a colon. + * * Windows will use back-slashes and conventional DOS paths. + * * Linux uses its native file system path scheme. + * + * All plugins should enable this feature on OS X to access the native file + * system. + * + * XPLM_USE_NATIVE_WIDGET_WINDOWS + * ------------------------------ + * + * Available in the SDK 3.0.2 SDK, this capability tells the widgets library + * to use new, modern X-Plane backed XPLMDisplay windows to anchor all widget + * trees. Without it, widgets will always use legacy windows. + * + * Plugins should enable this to allow their widget hierarchies to respond to + * the user's UI size settings and to map widget-based windwos to a VR HMD. + * + * Before enabling this, make sure any custom widget code in your plugin is + * prepared to cope with the UI coordinate system not being th same as the + * OpenGL window coordinate system. + * + */ + + +/* + * XPLMFeatureEnumerator_f + * + * You pass an XPLMFeatureEnumerator_f to get a list of all features supported + * by a given version running version of X-Plane. This routine is called once + * for each feature. + * + */ +typedef void (* XPLMFeatureEnumerator_f)( + const char * inFeature, + void * inRef); + +/* + * XPLMHasFeature + * + * This returns 1 if the given installation of X-Plane supports a feature, or + * 0 if it does not. + * + */ +XPLM_API int XPLMHasFeature( + const char * inFeature); + +/* + * XPLMIsFeatureEnabled + * + * This returns 1 if a feature is currently enabled for your plugin, or 0 if + * it is not enabled. It is an error to call this routine with an unsupported + * feature. + * + */ +XPLM_API int XPLMIsFeatureEnabled( + const char * inFeature); + +/* + * XPLMEnableFeature + * + * This routine enables or disables a feature for your plugin. This will + * change the running behavior of X-Plane and your plugin in some way, + * depending on the feature. + * + */ +XPLM_API void XPLMEnableFeature( + const char * inFeature, + int inEnable); + +/* + * XPLMEnumerateFeatures + * + * This routine calls your enumerator callback once for each feature that this + * running version of X-Plane supports. Use this routine to determine all of + * the features that X-Plane can support. + * + */ +XPLM_API void XPLMEnumerateFeatures( + XPLMFeatureEnumerator_f inEnumerator, + void * inRef); + +#endif /* XPLM200 */ +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/SDK/CHeaders/XPLM/XPLMProcessing.h b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/XPLM/XPLMProcessing.h new file mode 100644 index 0000000..94ef0c4 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/XPLM/XPLMProcessing.h @@ -0,0 +1,264 @@ +#ifndef _XPLMProcessing_h_ +#define _XPLMProcessing_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPLMProcessing + ***************************************************************************/ +/* + * This API allows you to get regular callbacks during the flight loop, the + * part of X-Plane where the plane's position calculates the physics of + * flight, etc. Use these APIs to accomplish periodic tasks like logging data + * and performing I/O. + * + * You can receive a callback either just before or just after the per-frame + * physics calculations happen - you can use post-FM callbacks to "patch" the + * flight model after it has run. + * + * If the user has set the number of flight model iterations per frame greater + * than one your plugin will _not_ see this; these integrations run on the + * sub-section of the flight model where iterations improve responsiveness + * (e.g. physical integration, not simple systems tracking) and are thus + * opaque to plugins. + * + * Flight loop scheduling, when scheduled by time, is scheduled by a "first + * callback after the deadline" schedule, e.g. your callbacks will always be + * slightly late to ensure that we don't run faster than your deadline. + * + * WARNING: Do NOT use these callbacks to draw! You cannot draw during flight + * loop callbacks. Use the drawing callbacks (see XPLMDisplay for more info) + * for graphics. (One exception: you can use a post-flight loop callback to + * update your own off-screen FBOs.) + * + */ + +#include "XPLMDefs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*************************************************************************** + * FLIGHT LOOP CALLBACKS + ***************************************************************************/ + +#if defined(XPLM210) +/* + * XPLMFlightLoopPhaseType + * + * You can register a flight loop callback to run either before or after the + * flight model is integrated by X-Plane. + * + */ +enum { + /* Your callback runs before X-Plane integrates the flight model. */ + xplm_FlightLoop_Phase_BeforeFlightModel = 0, + + /* Your callback runs after X-Plane integrates the flight model. */ + xplm_FlightLoop_Phase_AfterFlightModel = 1, + + +}; +typedef int XPLMFlightLoopPhaseType; +#endif /* XPLM210 */ + +#if defined(XPLM210) +/* + * XPLMFlightLoopID + * + * This is an opaque identifier for a flight loop callback. You can use this + * identifier to easily track and remove your callbacks, or to use the new + * flight loop APIs. + * + */ +typedef void * XPLMFlightLoopID; +#endif /* XPLM210 */ + +/* + * XPLMFlightLoop_f + * + * This is your flight loop callback. Each time the flight loop is iterated + * through, you receive this call at the end. + * + * Flight loop callbacks receive a number of input timing parameters. These + * input timing parameters are not particularly useful; you may need to track + * your own timing data (e.g. by reading datarefs). The input parameters are: + * + * - inElapsedSinceLastCall: the wall time since your last callback. + * - inElapsedTimeSinceLastFlightLoop: the wall time since any flight loop was + * dispatched. + * - inCounter: a monotonically increasing counter, bumped once per flight + * loop dispatch from the sim. + * - inRefcon: your own ptr constant from when you regitered yor callback. + * + * Your return value controls when you will next be called. + * + * - Return 0 to stop receiving callbacks. + * - Pass a positive number to specify how many seconds until the next + * callback. (You will be called at or after this time, not before.) + * - Pass a negative number to specify how many loops must go by until you + * are called. For example, -1.0 means call me the very next loop. + * + * Try to run your flight loop as infrequently as is practical, and suspend it + * (using return value 0) when you do not need it; lots of flight loop + * callbacks that do nothing lowers X-Plane's frame rate. + * + * Your callback will NOT be unregistered if you return 0; it will merely be + * inactive. + * + */ +typedef float (* XPLMFlightLoop_f)( + float inElapsedSinceLastCall, + float inElapsedTimeSinceLastFlightLoop, + int inCounter, + void * inRefcon); + +#if defined(XPLM210) +/* + * XPLMCreateFlightLoop_t + * + * XPLMCreateFlightLoop_t contains the parameters to create a new flight loop + * callback. The strsucture can be expanded in future SDKs - always set + * structSize to the size of your structure in bytes. + * + */ +typedef struct { + int structSize; + XPLMFlightLoopPhaseType phase; + XPLMFlightLoop_f callbackFunc; + void * refcon; +} XPLMCreateFlightLoop_t; +#endif /* XPLM210 */ + +/* + * XPLMGetElapsedTime + * + * This routine returns the elapsed time since the sim started up in decimal + * seconds. This is a wall timer; it keeps counting upward even if the sim is + * pasued. + * + * __WARNING__: XPLMGetElapsedTime is not a very good timer! It lacks + * precision in both its data type and its source. Do not attempt to use it + * for timing critical applications like network multiplayer. + * + */ +XPLM_API float XPLMGetElapsedTime(void); + +/* + * XPLMGetCycleNumber + * + * This routine returns a counter starting at zero for each sim cycle + * computed/video frame rendered. + * + */ +XPLM_API int XPLMGetCycleNumber(void); + +/* + * XPLMRegisterFlightLoopCallback + * + * This routine registers your flight loop callback. Pass in a pointer to a + * flight loop function and a refcon. inInterval defines when you will be + * called. Pass in a positive number to specify seconds from registration time + * to the next callback. Pass in a negative number to indicate when you will + * be called (e.g. pass -1 to be called at the next cylcle). Pass 0 to not be + * called; your callback will be inactive. + * + * (This legacy function only installs pre-flight-loop callbacks; use + * XPLMCreateFlightLoop for more control.) + * + */ +XPLM_API void XPLMRegisterFlightLoopCallback( + XPLMFlightLoop_f inFlightLoop, + float inInterval, + void * inRefcon); + +/* + * XPLMUnregisterFlightLoopCallback + * + * This routine unregisters your flight loop callback. Do NOT call it from + * your flight loop callback. Once your flight loop callback is unregistered, + * it will not be called again. + * + * Only use this on flight loops registered via + * XPLMRegisterFlightLoopCallback. + * + */ +XPLM_API void XPLMUnregisterFlightLoopCallback( + XPLMFlightLoop_f inFlightLoop, + void * inRefcon); + +/* + * XPLMSetFlightLoopCallbackInterval + * + * This routine sets when a callback will be called. Do NOT call it from your + * callback; use the return value of the callback to change your callback + * interval from inside your callback. + * + * inInterval is formatted the same way as in XPLMRegisterFlightLoopCallback; + * positive for seconds, negative for cycles, and 0 for deactivating the + * callback. If inRelativeToNow is 1, times are from the time of this call; + * otherwise they are from the time the callback was last called (or the time + * it was registered if it has never been called. + * + */ +XPLM_API void XPLMSetFlightLoopCallbackInterval( + XPLMFlightLoop_f inFlightLoop, + float inInterval, + int inRelativeToNow, + void * inRefcon); + +#if defined(XPLM210) +/* + * XPLMCreateFlightLoop + * + * This routine creates a flight loop callback and returns its ID. The flight + * loop callback is created using the input param struct, and is inited to be + * unscheduled. + * + */ +XPLM_API XPLMFlightLoopID XPLMCreateFlightLoop( + XPLMCreateFlightLoop_t * inParams); +#endif /* XPLM210 */ + +#if defined(XPLM210) +/* + * XPLMDestroyFlightLoop + * + * This routine destroys a flight loop callback by ID. Only call it on flight + * loops created with the newer XPLMCreateFlightLoop API. + * + */ +XPLM_API void XPLMDestroyFlightLoop( + XPLMFlightLoopID inFlightLoopID); +#endif /* XPLM210 */ + +#if defined(XPLM210) +/* + * XPLMScheduleFlightLoop + * + * This routine schedules a flight loop callback for future execution. If + * inInterval is negative, it is run in a certain number of frames based on + * the absolute value of the input. If the interval is positive, it is a + * duration in seconds. + * + * If inRelativeToNow is true, ties are interpretted relative to the time this + * routine is called; otherwise they are relative to the last call time or the + * time the flight loop was registered (if never called). + * + */ +XPLM_API void XPLMScheduleFlightLoop( + XPLMFlightLoopID inFlightLoopID, + float inInterval, + int inRelativeToNow); +#endif /* XPLM210 */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/SDK/CHeaders/XPLM/XPLMScenery.h b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/XPLM/XPLMScenery.h new file mode 100644 index 0000000..452bac9 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/XPLM/XPLMScenery.h @@ -0,0 +1,450 @@ +#ifndef _XPLMScenery_h_ +#define _XPLMScenery_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPLMScenery + ***************************************************************************/ +/* + * This package contains APIs to interact with X-Plane's scenery system. + * + */ + +#include "XPLMDefs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(XPLM200) +/*************************************************************************** + * Terrain Y-Testing + ***************************************************************************/ +/* + * The Y-testing API allows you to locate the physical scenery mesh. This + * would be used to place dynamic graphics on top of the ground in a plausible + * way or do physics interactions. + * + * The Y-test API works via probe objects, which are allocated by your plugin + * and used to query terrain. Probe objects exist both to capture which + * algorithm you have requested (see probe types) and also to cache query + * information. + * + * Performance Guidelines + * ---------------------- + * + * It is generally faster to use the same probe for nearby points and + * different probes for different points. Try not to allocate more than + * "hundreds" of probes at most. Share probes if you need more. Generally, + * probing operations are expensive, and should be avoided via caching when + * possible. + * + * Y testing returns a location on the terrain, a normal vectory, and a + * velocity vector. The normal vector tells you the slope of the terrain at + * that point. The velocity vector tells you if that terrain is moving (and is + * in meters/second). For example, if your Y test hits the aircraft carrier + * deck, this tells you the velocity of that point on the deck. + * + * Note: the Y-testing API is limited to probing the loaded scenery area, + * which is approximately 300x300 km in X-Plane 9. Probes outside this area + * will return the height of a 0 MSL sphere. + * + */ + + +/* + * XPLMProbeType + * + * XPLMProbeType defines the type of terrain probe - each probe has a + * different algorithm. (Only one type of probe is provided right now, but + * future APIs will expose more flexible or poewrful or useful probes. + * + */ +enum { + /* The Y probe gives you the location of the tallest physical scenery along * + * the Y axis going through the queried point. */ + xplm_ProbeY = 0, + + +}; +typedef int XPLMProbeType; + +/* + * XPLMProbeResult + * + * Probe results - possible results from a probe query. + * + */ +enum { + /* The probe hit terrain and returned valid values. */ + xplm_ProbeHitTerrain = 0, + + /* An error in the API call. Either the probe struct size is bad, or the * + * probe is invalid or the type is mismatched for the specific query call. */ + xplm_ProbeError = 1, + + /* The probe call succeeded but there is no terrain under this point (perhaps * + * it is off the side of the planet?) */ + xplm_ProbeMissed = 2, + + +}; +typedef int XPLMProbeResult; + +/* + * XPLMProbeRef + * + * An XPLMProbeRef is an opaque handle to a probe, used for querying the + * terrain. + * + */ +typedef void * XPLMProbeRef; + +/* + * XPLMProbeInfo_t + * + * XPLMProbeInfo_t contains the results of a probe call. Make sure to set + * structSize to the size of the struct before using it. + * + */ +typedef struct { + /* Size of structure in bytes - always set this before calling the XPLM. */ + int structSize; + /* Resulting X location of the terrain point we hit, in local OpenGL * + * coordinates. */ + float locationX; + /* Resulting Y location of the terrain point we hit, in local OpenGL * + * coordinates. */ + float locationY; + /* Resulting Z location of the terrain point we hit, in local OpenGL * + * coordinates. */ + float locationZ; + /* X component of the normal vector to the terrain we found. */ + float normalX; + /* Y component of the normal vector to the terrain we found. */ + float normalY; + /* Z component of the normal vector to the terrain we found. */ + float normalZ; + /* X component of the velocity vector of the terrain we found. */ + float velocityX; + /* Y component of the velocity vector of the terrain we found. */ + float velocityY; + /* Z component of the velocity vector of the terrain we found. */ + float velocityZ; + /* Tells if the surface we hit is water (otherwise it is land). */ + int is_wet; +} XPLMProbeInfo_t; + +/* + * XPLMCreateProbe + * + * Creates a new probe object of a given type and returns. + * + */ +XPLM_API XPLMProbeRef XPLMCreateProbe( + XPLMProbeType inProbeType); + +/* + * XPLMDestroyProbe + * + * Deallocates an existing probe object. + * + */ +XPLM_API void XPLMDestroyProbe( + XPLMProbeRef inProbe); + +/* + * XPLMProbeTerrainXYZ + * + * Probes the terrain. Pass in the XYZ coordinate of the probe point, a probe + * object, and an XPLMProbeInfo_t struct that has its structSize member set + * properly. Other fields are filled in if we hit terrain, and a probe result + * is returned. + * + */ +XPLM_API XPLMProbeResult XPLMProbeTerrainXYZ( + XPLMProbeRef inProbe, + float inX, + float inY, + float inZ, + XPLMProbeInfo_t * outInfo); + +#endif /* XPLM200 */ +#if defined(XPLM300) +/*************************************************************************** + * Magnetic Variation + ***************************************************************************/ +/* + * Use the magnetic variation (more properly, the "magnetic declination") API + * to find the offset of magnetic north from true north at a given latitude + * and longitude within the simulator. + * + * In the real world, the Earth's magnetic field is irregular, such that true + * north (the direction along a meridian toward the north pole) does not + * necessarily match what a magnetic compass shows as north. + * + * Using this API ensures that you present the same offsets to users as + * X-Plane's built-in instruments. + * + */ + + +/* + * XPLMGetMagneticVariation + * + * Returns X-Plane's simulated magnetic variation (declination) at the + * indication latitude and longitude. + * + */ +XPLM_API float XPLMGetMagneticVariation( + double latitude, + double longitude); + +/* + * XPLMDegTrueToDegMagnetic + * + * Converts a heading in degrees relative to true north into a value relative + * to magnetic north at the user's current location. + * + */ +XPLM_API float XPLMDegTrueToDegMagnetic( + float headingDegreesTrue); + +/* + * XPLMDegMagneticToDegTrue + * + * Converts a heading in degrees relative to magnetic north at the user's + * current location into a value relative to true north. + * + */ +XPLM_API float XPLMDegMagneticToDegTrue( + float headingDegreesMagnetic); + +#endif /* XPLM300 */ +/*************************************************************************** + * Object Drawing + ***************************************************************************/ +/* + * The object drawing routines let you load and draw X-Plane OBJ files. + * Objects are loaded by file path and managed via an opaque handle. X-Plane + * naturally reference counts objects, so it is important that you balance + * every successful call to XPLMLoadObject with a call to XPLMUnloadObject! + * + */ + + +#if defined(XPLM200) +/* + * XPLMObjectRef + * + * An XPLMObjectRef is a opaque handle to an .obj file that has been loaded + * into memory. + * + */ +typedef void * XPLMObjectRef; +#endif /* XPLM200 */ + +#if defined(XPLM200) +/* + * XPLMDrawInfo_t + * + * The XPLMDrawInfo_t structure contains positioning info for one object that + * is to be drawn. Be sure to set structSize to the size of the structure for + * future expansion. + * + */ +typedef struct { + /* Set this to the size of this structure! */ + int structSize; + /* X location of the object in local coordinates. */ + float x; + /* Y location of the object in local coordinates. */ + float y; + /* Z location of the object in local coordinates. */ + float z; + /* Pitch in degres to rotate the object, positive is up. */ + float pitch; + /* Heading in local coordinates to rotate the object, clockwise. */ + float heading; + /* Roll to rotate the object. */ + float roll; +} XPLMDrawInfo_t; +#endif /* XPLM200 */ + +#if defined(XPLM210) +/* + * XPLMObjectLoaded_f + * + * You provide this callback when loading an object asynchronously; it will be + * called once the object is loaded. Your refcon is passed back. The object + * ref passed in is the newly loaded object (ready for use) or NULL if an + * error occured. + * + * If your plugin is disabled, this callback will be delivered as soon as the + * plugin is re-enabled. If your plugin is unloaded before this callback is + * ever called, the SDK will release the object handle for you. + * + */ +typedef void (* XPLMObjectLoaded_f)( + XPLMObjectRef inObject, + void * inRefcon); +#endif /* XPLM210 */ + +#if defined(XPLM200) +/* + * XPLMLoadObject + * + * This routine loads an OBJ file and returns a handle to it. If X-Plane has + * already loaded the object, the handle to the existing object is returned. + * Do not assume you will get the same handle back twice, but do make sure to + * call unload once for every load to avoid "leaking" objects. The object will + * be purged from memory when no plugins and no scenery are using it. + * + * The path for the object must be relative to the X-System base folder. If + * the path is in the root of the X-System folder you may need to prepend ./ + * to it; loading objects in the root of the X-System folder is STRONGLY + * discouraged - your plugin should not dump art resources in the root folder! + * + * XPLMLoadObject will return NULL if the object cannot be loaded (either + * because it is not found or the file is misformatted). This routine will + * load any object that can be used in the X-Plane scenery system. + * + * It is important that the datarefs an object uses for animation already be + * loaded before you load the object. For this reason it may be necessary to + * defer object loading until the sim has fully started. + * + */ +XPLM_API XPLMObjectRef XPLMLoadObject( + const char * inPath); +#endif /* XPLM200 */ + +#if defined(XPLM210) +/* + * XPLMLoadObjectAsync + * + * This routine loads an object asynchronously; control is returned to you + * immediately while X-Plane loads the object. The sim will not stop flying + * while the object loads. For large objects, it may be several seconds before + * the load finishes. + * + * You provide a callback function that is called once the load has completed. + * Note that if the object cannot be loaded, you will not find out until the + * callback function is called with a NULL object handle. + * + * There is no way to cancel an asynchronous object load; you must wait for + * the load to complete and then release the object if it is no longer + * desired. + * + */ +XPLM_API void XPLMLoadObjectAsync( + const char * inPath, + XPLMObjectLoaded_f inCallback, + void * inRefcon); +#endif /* XPLM210 */ + +#if defined(XPLM_DEPRECATED) +/* + * XPLMDrawObjects + * + * __Deprecation Warning__: use XPLMInstancing to draw 3-d objects by creating + * instances, rather than these APIs from draw callbacks. + * + * XPLMDrawObjects draws an object from an OBJ file one or more times. You + * pass in the object and an array of XPLMDrawInfo_t structs, one for each + * place you would like the object to be drawn. + * + * X-Plane will attempt to cull the objects based on LOD and visibility, and + * will pick the appropriate LOD. + * + * Lighting is a boolean; pass 1 to show the night version of object with + * night-only lights lit up. Pass 0 to show the daytime version of the object. + * + * earth_relative controls the coordinate system. If this is 1, the rotations + * you specify are applied to the object after its coordinate system is + * transformed from local to earth-relative coordinates -- that is, an object + * with no rotations will point toward true north and the Y axis will be up + * against gravity. If this is 0, the object is drawn with your rotations from + * local coordanates -- that is, an object with no rotations is drawn pointing + * down the -Z axis and the Y axis of the object matches the local coordinate + * Y axis. + * + */ +XPLM_API void XPLMDrawObjects( + XPLMObjectRef inObject, + int inCount, + XPLMDrawInfo_t * inLocations, + int lighting, + int earth_relative); +#endif /* XPLM_DEPRECATED */ + +#if defined(XPLM200) +/* + * XPLMUnloadObject + * + * This routine marks an object as no longer being used by your plugin. + * Objects are reference counted: once no plugins are using an object, it is + * purged from memory. Make sure to call XPLMUnloadObject once for each + * successful call to XPLMLoadObject. + * + */ +XPLM_API void XPLMUnloadObject( + XPLMObjectRef inObject); +#endif /* XPLM200 */ + +#if defined(XPLM200) +/*************************************************************************** + * Library Access + ***************************************************************************/ +/* + * The library access routines allow you to locate scenery objects via the + * X-Plane library system. Right now library access is only provided for + * objects, allowing plugin-drawn objects to be extended using the library + * system. + * + */ + + +/* + * XPLMLibraryEnumerator_f + * + * An XPLMLibraryEnumerator_f is a callback you provide that is called once + * for each library element that is located. The returned paths will be + * relative to the X-System folder. + * + */ +typedef void (* XPLMLibraryEnumerator_f)( + const char * inFilePath, + void * inRef); + +/* + * XPLMLookupObjects + * + * This routine looks up a virtual path in the library system and returns all + * matching elements. You provide a callback - one virtual path may match many + * objects in the library. XPLMLookupObjects returns the number of objects + * found. + * + * The latitude and longitude parameters specify the location the object will + * be used. The library system allows for scenery packages to only provide + * objects to certain local locations. Only objects that are allowed at the + * latitude/longitude you provide will be returned. + * + */ +XPLM_API int XPLMLookupObjects( + const char * inPath, + float inLatitude, + float inLongitude, + XPLMLibraryEnumerator_f enumerator, + void * ref); + +#endif /* XPLM200 */ +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/SDK/CHeaders/XPLM/XPLMUtilities.h b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/XPLM/XPLMUtilities.h new file mode 100644 index 0000000..bec319e --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDK/CHeaders/XPLM/XPLMUtilities.h @@ -0,0 +1,970 @@ +#ifndef _XPLMUtilities_h_ +#define _XPLMUtilities_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPLMUtilities + ***************************************************************************/ + +#include "XPLMDefs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*************************************************************************** + * FILE UTILITIES + ***************************************************************************/ +/* + * The XPLMUtilities file APIs provide some basic file and path functions for + * use with X-Plane. + * + * Directory Separators + * -------------------- + * + * The XPLM has two modes it can work in: + * + * * X-Plane native paths: all paths are UTF8 strings, using the unix forward + * slash (/) as the directory separating character. In native path mode, + * you use the same path format for all three operating systems. + * + * * Legacy OS paths: the directroy separator is \ for Windows, : for OS X, + * and / for Linux; OS paths are encoded in MacRoman for OS X using legacy + * HFS conventions, use the application code page for multi-byte encoding + * on Unix using DOS path conventions, and use UTF-8 for Linux. + * + * While legacy OS paths are the default, we strongly encourage you to opt in + * to native paths using the XPLMEnableFeature API. + * + * * All OS X plugins should enable native paths all of the time; if you do + * not do this, you will have to convert all paths back from HFS to Unix + * (and deal with MacRoman) - code written using native paths and the C + * file APIs "just works" on OS X. + * + * * For Linux plugins, there is no difference between the two encodings. + * + * * Windows plugins will need to convert the UTF8 file paths to UTF16 for + * use with the "wide" APIs. While it might seem tempting to stick with + * legacy OS paths (and just use the "ANSI" Windows APIs), X-Plane is fully + * unicode-capable, and will often be installed in paths where the user's + * directories have no ACP encoding. + * + * Full and Relative Paths + * ----------------------- + * + * Some of these APIs use full paths, but others use paths relative to the + * user's X-Plane installation. This is documented on a per-API basis. + * + */ + + +#if defined(XPLM200) +/* + * XPLMDataFileType + * + * These enums define types of data files you can load or unload using the + * SDK. + * + */ +enum { + /* A situation (.sit) file, which starts off a flight in a given * + * configuration. */ + xplm_DataFile_Situation = 1, + + /* A situation movie (.smo) file, which replays a past flight. */ + xplm_DataFile_ReplayMovie = 2, + + +}; +typedef int XPLMDataFileType; +#endif /* XPLM200 */ + +/* + * XPLMGetSystemPath + * + * This function returns the full path to the X-System folder. Note that this + * is a directory path, so it ends in a trailing : or /. + * + * The buffer you pass should be at least 512 characters long. The path is + * returned using the current native or OS path conventions. + * + */ +XPLM_API void XPLMGetSystemPath( + char * outSystemPath); + +/* + * XPLMGetPrefsPath + * + * This routine returns a full path to a file that is within X-Plane's + * preferences directory. (You should remove the file name back to the last + * directory separator to get the preferences directory using + * XPLMExtractFileAndPath.) + * + * The buffer you pass should be at least 512 characters long. The path is + * returned using the current native or OS path conventions. + * + */ +XPLM_API void XPLMGetPrefsPath( + char * outPrefsPath); + +/* + * XPLMGetDirectorySeparator + * + * This routine returns a string with one char and a null terminator that is + * the directory separator for the current platform. This allows you to write + * code that concatinates directory paths without having to #ifdef for + * platform. The character returned will reflect the current file path mode. + * + */ +XPLM_API const char * XPLMGetDirectorySeparator(void); + +/* + * XPLMExtractFileAndPath + * + * Given a full path to a file, this routine separates the path from the file. + * If the path is a partial directory (e.g. ends in : or \) the trailing + * directory separator is removed. This routine works in-place; a pointer to + * the file part of the buffer is returned; the original buffer still starts + * with the path and is null terminated with no trailing separator. + * + */ +XPLM_API char * XPLMExtractFileAndPath( + char * inFullPath); + +/* + * XPLMGetDirectoryContents + * + * This routine returns a list of files in a directory (specified by a full + * path, no trailing : or \). The output is returned as a list of NULL + * terminated strings. An index array (if specified) is filled with pointers + * into the strings. The last file is indicated by a zero-length string (and + * NULL in the indices). This routine will return 1 if you had capacity for + * all files or 0 if you did not. You can also skip a given number of files. + * + * * inDirectoryPath - a null terminated C string containing the full path to + * the directory with no trailing directory char. + * + * * inFirstReturn - the zero-based index of the first file in the directory + * to return. (Usually zero to fetch all in one pass.) + * + * * outFileNames - a buffer to receive a series of sequential null + * terminated C-string file names. A zero-length C string will be appended + * to the very end. + * + * * inFileNameBufSize - the size of the file name buffer in bytes. + * + * * outIndices - a pointer to an array of character pointers that will + * become an index into the directory. The last file will be followed by a + * NULL value. Pass NULL if you do not want indexing information. + * + * * inIndexCount - the max size of the index in entries. + * + * * outTotalFiles - if not NULL, this is filled in with the number of files + * in the directory. + * + * * outReturnedFiles - if not NULL, the number of files returned by this + * iteration. + * + * Return value: 1 if all info could be returned, 0 if there was a buffer + * overrun. + * + * WARNING: Before X-Plane 7 this routine did not properly iterate through + * directories. If X-Plane + * 6 compatibility is needed, use your own code to iterate directories. + * + */ +XPLM_API int XPLMGetDirectoryContents( + const char * inDirectoryPath, + int inFirstReturn, + char * outFileNames, + int inFileNameBufSize, + char ** outIndices, /* Can be NULL */ + int inIndexCount, + int * outTotalFiles, /* Can be NULL */ + int * outReturnedFiles); /* Can be NULL */ + +#if defined(XPLM200) +/* + * XPLMLoadDataFile + * + * Loads a data file of a given type. Paths must be relative to the X-System + * folder. To clear the replay, pass a NULL file name (this is only valid with + * replay movies, not sit files). + * + */ +XPLM_API int XPLMLoadDataFile( + XPLMDataFileType inFileType, + const char * inFilePath); /* Can be NULL */ +#endif /* XPLM200 */ + +#if defined(XPLM200) +/* + * XPLMSaveDataFile + * + * Saves the current situation or replay; paths are relative to the X-System + * folder. + * + */ +XPLM_API int XPLMSaveDataFile( + XPLMDataFileType inFileType, + const char * inFilePath); +#endif /* XPLM200 */ + +/*************************************************************************** + * X-PLANE MISC + ***************************************************************************/ + +/* + * XPLMHostApplicationID + * + * While the plug-in SDK is only accessible to plugins running inside X-Plane, + * the original authors considered extending the API to other applications + * that shared basic infrastructure with X-Plane. These enumerations are + * hold-overs from that original roadmap; all values other than X-Plane are + * deprecated. Your plugin should never need this enumeration. + * + */ +enum { + xplm_Host_Unknown = 0, + + xplm_Host_XPlane = 1, + +#if defined(XPLM_DEPRECATED) + xplm_Host_PlaneMaker = 2, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + xplm_Host_WorldMaker = 3, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + xplm_Host_Briefer = 4, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + xplm_Host_PartMaker = 5, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + xplm_Host_YoungsMod = 6, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + xplm_Host_XAuto = 7, + +#endif /* XPLM_DEPRECATED */ + +}; +typedef int XPLMHostApplicationID; + +/* + * XPLMLanguageCode + * + * These enums define what language the sim is running in. These enumerations + * do not imply that the sim can or does run in all of these languages; they + * simply provide a known encoding in the event that a given sim version is + * localized to a certain language. + * + */ +enum { + xplm_Language_Unknown = 0, + + xplm_Language_English = 1, + + xplm_Language_French = 2, + + xplm_Language_German = 3, + + xplm_Language_Italian = 4, + + xplm_Language_Spanish = 5, + + xplm_Language_Korean = 6, + +#if defined(XPLM200) + xplm_Language_Russian = 7, + +#endif /* XPLM200 */ +#if defined(XPLM200) + xplm_Language_Greek = 8, + +#endif /* XPLM200 */ +#if defined(XPLM200) + xplm_Language_Japanese = 9, + +#endif /* XPLM200 */ +#if defined(XPLM300) + xplm_Language_Chinese = 10, + +#endif /* XPLM300 */ + +}; +typedef int XPLMLanguageCode; + +#if defined(XPLM200) +/* + * XPLMError_f + * + * An XPLM error callback is a function that you provide to receive debugging + * information from the plugin SDK. See XPLMSetErrorCallback for more + * information. NOTE: for the sake of debugging, your error callback will be + * called even if your plugin is not enabled, allowing you to receive debug + * info in your XPluginStart and XPluginStop callbacks. To avoid causing logic + * errors in the management code, do not call any other plugin routines from + * your error callback - it is only meant for catching errors in the + * debugging. + * + */ +typedef void (* XPLMError_f)( + const char * inMessage); +#endif /* XPLM200 */ + +#if defined(XPLM_DEPRECATED) +/* + * XPLMInitialized + * + * Deprecated: This function returns 1 if X-Plane has properly initialized the + * plug-in system. If this routine returns 0, many XPLM functions will not + * work. + * + * NOTE: because plugins are always called from within the XPLM, there is no + * need to check for initialization; it will always return 1. This routine is + * deprecated - you do not need to check it before continuing within your + * plugin. + * + */ +XPLM_API int XPLMInitialized(void); +#endif /* XPLM_DEPRECATED */ + +/* + * XPLMGetVersions + * + * This routine returns the revision of both X-Plane and the XPLM DLL. All + * versions are three-digit decimal numbers (e.g. 606 for version 6.06 of + * X-Plane); the current revision of the XPLM is 200 (2.00). This routine also + * returns the host ID of the app running us. + * + * The most common use of this routine is to special-case around X-Plane + * version-specific behavior. + * + */ +XPLM_API void XPLMGetVersions( + int * outXPlaneVersion, + int * outXPLMVersion, + XPLMHostApplicationID * outHostID); + +/* + * XPLMGetLanguage + * + * This routine returns the langauge the sim is running in. + * + */ +XPLM_API XPLMLanguageCode XPLMGetLanguage(void); + +#if defined(XPLM200) +/* + * XPLMFindSymbol + * + * This routine will attempt to find the symbol passed in the inString + * parameter. If the symbol is found a pointer the function is returned, + * othewise the function will return NULL. + * + * You can use XPLMFindSymbol to utilize newer SDK API features without + * requiring newer versions of the SDK (and X-Plane) as your minimum X-Plane + * version as follows: + * + * * Define the XPLMnnn macro to the minimum required XPLM version you will + * ship with (e.g. XPLM210 for X-Plane 10 compatibility). + * + * * Use XPLMGetVersions and XPLMFindSymbol to detect that the host sim is + * new enough to use new functions and resolve function pointers. + * + * * Conditionally use the new functions if and only if XPLMFindSymbol only + * returns a non- NULL pointer. + * + * Warning: you should always check the XPLM API version as well as the + * results of XPLMFindSymbol to determine if funtionality is safe to use. + * + * To use functionality via XPLMFindSymbol you will need to copy your own + * definitions of the X-Plane API prototypes and cast the returned pointer to + * the correct type. + * + */ +XPLM_API void * XPLMFindSymbol( + const char * inString); +#endif /* XPLM200 */ + +#if defined(XPLM200) +/* + * XPLMSetErrorCallback + * + * XPLMSetErrorCallback installs an error-reporting callback for your plugin. + * Normally the plugin system performs minimum diagnostics to maximize + * performance. When you install an error callback, you will receive calls due + * to certain plugin errors, such as passing bad parameters or incorrect data. + * + * Important: the error callback determines *programming* errors, e.g. bad API + * parameters. Every error that is returned by the error callback represents a + * mistake in your plugin that you should fix. Error callbacks are not used to + * report expected run-time problems (e.g. disk I/O errors). + * + * The intention is for you to install the error callback during debug + * sections and put a break-point inside your callback. This will cause you to + * break into the debugger from within the SDK at the point in your plugin + * where you made an illegal call. + * + * Installing an error callback may activate error checking code that would + * not normally run, and this may adversely affect performance, so do not + * leave error callbacks installed in shipping plugins. Since the only useful + * response to an error is to change code, error callbacks are not useful "in + * the field". + * + */ +XPLM_API void XPLMSetErrorCallback( + XPLMError_f inCallback); +#endif /* XPLM200 */ + +/* + * XPLMDebugString + * + * This routine outputs a C-style string to the Log.txt file. The file is + * immediately flushed so you will not lose data. (This does cause a + * performance penalty.) + * + * Please do *not* leave routine diagnostic logging enabled in your shipping + * plugin. The X-Plane Log file is shared by X-Plane and every plugin in the + * system, and plugins that (when functioning normally) print verbose log + * output make it difficult for developers to find error conditions from other + * parts of the system. + * + */ +XPLM_API void XPLMDebugString( + const char * inString); + +/* + * XPLMSpeakString + * + * This function displays the string in a translucent overlay over the current + * display and also speaks the string if text-to-speech is enabled. The string + * is spoken asynchronously, this function returns immediately. This function + * may not speak or print depending on user preferences. + * + */ +XPLM_API void XPLMSpeakString( + const char * inString); + +/* + * XPLMGetVirtualKeyDescription + * + * Given a virtual key code (as defined in XPLMDefs.h) this routine returns a + * human-readable string describing the character. This routine is provided + * for showing users what keyboard mappings they have set up. The string may + * read 'unknown' or be a blank or NULL string if the virtual key is unknown. + * + */ +XPLM_API const char * XPLMGetVirtualKeyDescription( + char inVirtualKey); + +/* + * XPLMReloadScenery + * + * XPLMReloadScenery reloads the current set of scenery. You can use this + * function in two typical ways: simply call it to reload the scenery, picking + * up any new installed scenery, .env files, etc. from disk. Or, change the + * lat/ref and lon/ref data refs and then call this function to shift the + * scenery environment. This routine is equivalent to picking "reload + * scenery" from the developer menu. + * + */ +XPLM_API void XPLMReloadScenery(void); + +#if defined(XPLM200) +/*************************************************************************** + * X-PLANE COMMAND MANAGEMENT + ***************************************************************************/ +/* + * The command management APIs let plugins interact with the command-system in + * X-Plane, the abstraction behind keyboard presses and joystick buttons. This + * API lets you create new commands and modify the behavior (or get + * notification) of existing ones. + * + * X-Plane Command Phases + * ---------------------- + * + * X-Plane commands are not instantaneous; they operate over a duration. + * (Think of a joystick button press - you can press, hold down, and then + * release the joystick button; X-Plane commands model this entire process.) + * + * An X-Plane command consists of three phases: a beginning, continuous + * repetition, and an ending. The command may be repeated zero times in its + * duration, followed by one command ending. Command begin and end messges are + * balanced, but a command may be bound to more than one event source (e.g. a + * keyboard key and a joystick button), in which case you may receive a second + * begin during before any end). + * + * When you issue commands in the plugin system, you *must* balance every call + * to XPLMCommandBegin with a call to XPLMCommandEnd with the same command + * reference. + * + * Command Behavior Modification + * ----------------------------- + * + * You can register a callback to handle a command either before or after + * X-Plane does; if you receive the command before X-Plane you have the option + * to either let X-Plane handle the command or hide the command from X-Plane. + * This lets plugins both augment commands and replace them. + * + * If you register for an existing command, be sure that you are *consistent* + * in letting X-Plane handle or not handle the command; you are responsible + * for passing a *balanced* number of begin and end messages to X-Plane. (E.g. + * it is not legal to pass all the begin messages to X-Plane but hide all the + * end messages). + * + */ + + +/* + * XPLMCommandPhase + * + * The phases of a command. + * + */ +enum { + /* The command is being started. */ + xplm_CommandBegin = 0, + + /* The command is continuing to execute. */ + xplm_CommandContinue = 1, + + /* The command has ended. */ + xplm_CommandEnd = 2, + + +}; +typedef int XPLMCommandPhase; + +/* + * XPLMCommandRef + * + * A command ref is an opaque identifier for an X-Plane command. Command + * references stay the same for the life of your plugin but not between + * executions of X-Plane. Command refs are used to execute commands, create + * commands, and create callbacks for particular commands. + * + * Note that a command is not "owned" by a particular plugin. Since many + * plugins may participate in a command's execution, the command does not go + * away if the plugin that created it is unloaded. + * + */ +typedef void * XPLMCommandRef; + +/* + * XPLMCommandCallback_f + * + * A command callback is a function in your plugin that is called when a + * command is pressed. Your callback receives the command reference for the + * particular command, the phase of the command that is executing, and a + * reference pointer that you specify when registering the callback. + * + * Your command handler should return 1 to let processing of the command + * continue to other plugins and X-Plane, or 0 to halt processing, potentially + * bypassing X-Plane code. + * + */ +typedef int (* XPLMCommandCallback_f)( + XPLMCommandRef inCommand, + XPLMCommandPhase inPhase, + void * inRefcon); + +/* + * XPLMFindCommand + * + * XPLMFindCommand looks up a command by name, and returns its command + * reference or NULL if the command does not exist. + * + */ +XPLM_API XPLMCommandRef XPLMFindCommand( + const char * inName); + +/* + * XPLMCommandBegin + * + * XPLMCommandBegin starts the execution of a command, specified by its + * command reference. The command is "held down" until XPLMCommandEnd is + * called. You must balance each XPLMCommandBegin call with an XPLMCommandEnd + * call. + * + */ +XPLM_API void XPLMCommandBegin( + XPLMCommandRef inCommand); + +/* + * XPLMCommandEnd + * + * XPLMCommandEnd ends the execution of a given command that was started with + * XPLMCommandBegin. You must not issue XPLMCommandEnd for a command you did + * not begin. + * + */ +XPLM_API void XPLMCommandEnd( + XPLMCommandRef inCommand); + +/* + * XPLMCommandOnce + * + * This executes a given command momentarily, that is, the command begins and + * ends immediately. This is the equivalent of calling XPLMCommandBegin() and + * XPLMCommandEnd() back ot back. + * + */ +XPLM_API void XPLMCommandOnce( + XPLMCommandRef inCommand); + +/* + * XPLMCreateCommand + * + * XPLMCreateCommand creates a new command for a given string. If the command + * already exists, the existing command reference is returned. The description + * may appear in user interface contexts, such as the joystick configuration + * screen. + * + */ +XPLM_API XPLMCommandRef XPLMCreateCommand( + const char * inName, + const char * inDescription); + +/* + * XPLMRegisterCommandHandler + * + * XPLMRegisterCommandHandler registers a callback to be called when a command + * is executed. You provide a callback with a reference pointer. + * + * If inBefore is true, your command handler callback will be executed before + * X-Plane executes the command, and returning 0 from your callback will + * disable X-Plane's processing of the command. If inBefore is false, your + * callback will run after X-Plane. (You can register a single callback both + * before and after a command.) + * + */ +XPLM_API void XPLMRegisterCommandHandler( + XPLMCommandRef inComand, + XPLMCommandCallback_f inHandler, + int inBefore, + void * inRefcon); + +/* + * XPLMUnregisterCommandHandler + * + * XPLMUnregisterCommandHandler removes a command callback registered with + * XPLMRegisterCommandHandler. + * + */ +XPLM_API void XPLMUnregisterCommandHandler( + XPLMCommandRef inComand, + XPLMCommandCallback_f inHandler, + int inBefore, + void * inRefcon); + +#endif /* XPLM200 */ +#if defined(XPLM_DEPRECATED) +/*************************************************************************** + * X-PLANE USER INTERACTION + ***************************************************************************/ +/* + * WARNING: The legacy user interaction API is deprecated; while it was the + * only way to run commands in X-Plane 6,7 and 8, it is obsolete, and was + * replaced by the command system API in X-Plane 9. You should not use this + * API; replace any of the calls below with XPLMCommand invocations based on + * persistent command strings. The documentation that follows is for historic + * reference only. + * + * The legacy user interaction APIs let you simulate commands the user can do + * with a joystick, keyboard etc. Note that it is generally safer for future + * compatibility to use one of these commands than to manipulate the + * underlying sim data. + * + */ + + +/* + * XPLMCommandKeyID + * + * These enums represent all the keystrokes available within X-Plane. They can + * be sent to X-Plane directly. For example, you can reverse thrust using + * these enumerations. + * + */ +enum { + xplm_key_pause=0, + xplm_key_revthrust, + xplm_key_jettison, + xplm_key_brakesreg, + xplm_key_brakesmax, + xplm_key_gear, + xplm_key_timedn, + xplm_key_timeup, + xplm_key_fadec, + xplm_key_otto_dis, + xplm_key_otto_atr, + xplm_key_otto_asi, + xplm_key_otto_hdg, + xplm_key_otto_gps, + xplm_key_otto_lev, + xplm_key_otto_hnav, + xplm_key_otto_alt, + xplm_key_otto_vvi, + xplm_key_otto_vnav, + xplm_key_otto_nav1, + xplm_key_otto_nav2, + xplm_key_targ_dn, + xplm_key_targ_up, + xplm_key_hdgdn, + xplm_key_hdgup, + xplm_key_barodn, + xplm_key_baroup, + xplm_key_obs1dn, + xplm_key_obs1up, + xplm_key_obs2dn, + xplm_key_obs2up, + xplm_key_com1_1, + xplm_key_com1_2, + xplm_key_com1_3, + xplm_key_com1_4, + xplm_key_nav1_1, + xplm_key_nav1_2, + xplm_key_nav1_3, + xplm_key_nav1_4, + xplm_key_com2_1, + xplm_key_com2_2, + xplm_key_com2_3, + xplm_key_com2_4, + xplm_key_nav2_1, + xplm_key_nav2_2, + xplm_key_nav2_3, + xplm_key_nav2_4, + xplm_key_adf_1, + xplm_key_adf_2, + xplm_key_adf_3, + xplm_key_adf_4, + xplm_key_adf_5, + xplm_key_adf_6, + xplm_key_transpon_1, + xplm_key_transpon_2, + xplm_key_transpon_3, + xplm_key_transpon_4, + xplm_key_transpon_5, + xplm_key_transpon_6, + xplm_key_transpon_7, + xplm_key_transpon_8, + xplm_key_flapsup, + xplm_key_flapsdn, + xplm_key_cheatoff, + xplm_key_cheaton, + xplm_key_sbrkoff, + xplm_key_sbrkon, + xplm_key_ailtrimL, + xplm_key_ailtrimR, + xplm_key_rudtrimL, + xplm_key_rudtrimR, + xplm_key_elvtrimD, + xplm_key_elvtrimU, + xplm_key_forward, + xplm_key_down, + xplm_key_left, + xplm_key_right, + xplm_key_back, + xplm_key_tower, + xplm_key_runway, + xplm_key_chase, + xplm_key_free1, + xplm_key_free2, + xplm_key_spot, + xplm_key_fullscrn1, + xplm_key_fullscrn2, + xplm_key_tanspan, + xplm_key_smoke, + xplm_key_map, + xplm_key_zoomin, + xplm_key_zoomout, + xplm_key_cycledump, + xplm_key_replay, + xplm_key_tranID, + xplm_key_max +}; +typedef int XPLMCommandKeyID; + +/* + * XPLMCommandButtonID + * + * These are enumerations for all of the things you can do with a joystick + * button in X-Plane. They currently match the buttons menu in the equipment + * setup dialog, but these enums will be stable even if they change in + * X-Plane. + * + */ +enum { + xplm_joy_nothing=0, + xplm_joy_start_all, + xplm_joy_start_0, + xplm_joy_start_1, + xplm_joy_start_2, + xplm_joy_start_3, + xplm_joy_start_4, + xplm_joy_start_5, + xplm_joy_start_6, + xplm_joy_start_7, + xplm_joy_throt_up, + xplm_joy_throt_dn, + xplm_joy_prop_up, + xplm_joy_prop_dn, + xplm_joy_mixt_up, + xplm_joy_mixt_dn, + xplm_joy_carb_tog, + xplm_joy_carb_on, + xplm_joy_carb_off, + xplm_joy_trev, + xplm_joy_trm_up, + xplm_joy_trm_dn, + xplm_joy_rot_trm_up, + xplm_joy_rot_trm_dn, + xplm_joy_rud_lft, + xplm_joy_rud_cntr, + xplm_joy_rud_rgt, + xplm_joy_ail_lft, + xplm_joy_ail_cntr, + xplm_joy_ail_rgt, + xplm_joy_B_rud_lft, + xplm_joy_B_rud_rgt, + xplm_joy_look_up, + xplm_joy_look_dn, + xplm_joy_look_lft, + xplm_joy_look_rgt, + xplm_joy_glance_l, + xplm_joy_glance_r, + xplm_joy_v_fnh, + xplm_joy_v_fwh, + xplm_joy_v_tra, + xplm_joy_v_twr, + xplm_joy_v_run, + xplm_joy_v_cha, + xplm_joy_v_fr1, + xplm_joy_v_fr2, + xplm_joy_v_spo, + xplm_joy_flapsup, + xplm_joy_flapsdn, + xplm_joy_vctswpfwd, + xplm_joy_vctswpaft, + xplm_joy_gear_tog, + xplm_joy_gear_up, + xplm_joy_gear_down, + xplm_joy_lft_brake, + xplm_joy_rgt_brake, + xplm_joy_brakesREG, + xplm_joy_brakesMAX, + xplm_joy_speedbrake, + xplm_joy_ott_dis, + xplm_joy_ott_atr, + xplm_joy_ott_asi, + xplm_joy_ott_hdg, + xplm_joy_ott_alt, + xplm_joy_ott_vvi, + xplm_joy_tim_start, + xplm_joy_tim_reset, + xplm_joy_ecam_up, + xplm_joy_ecam_dn, + xplm_joy_fadec, + xplm_joy_yaw_damp, + xplm_joy_art_stab, + xplm_joy_chute, + xplm_joy_JATO, + xplm_joy_arrest, + xplm_joy_jettison, + xplm_joy_fuel_dump, + xplm_joy_puffsmoke, + xplm_joy_prerotate, + xplm_joy_UL_prerot, + xplm_joy_UL_collec, + xplm_joy_TOGA, + xplm_joy_shutdown, + xplm_joy_con_atc, + xplm_joy_fail_now, + xplm_joy_pause, + xplm_joy_rock_up, + xplm_joy_rock_dn, + xplm_joy_rock_lft, + xplm_joy_rock_rgt, + xplm_joy_rock_for, + xplm_joy_rock_aft, + xplm_joy_idle_hilo, + xplm_joy_lanlights, + xplm_joy_max +}; +typedef int XPLMCommandButtonID; + +/* + * XPLMSimulateKeyPress + * + * This function simulates a key being pressed for X-Plane. The keystroke goes + * directly to X-Plane; it is never sent to any plug-ins. However, since this + * is a raw key stroke it may be mapped by the keys file or enter text into a + * field. + * + * Deprecated: use XPLMCommandOnce + * + */ +XPLM_API void XPLMSimulateKeyPress( + int inKeyType, + int inKey); + +/* + * XPLMCommandKeyStroke + * + * This routine simulates a command-key stroke. However, the keys are done by + * function, not by actual letter, so this function works even if the user has + * remapped their keyboard. Examples of things you might do with this include + * pausing the simulator. + * + * Deprecated: use XPLMCommandOnce + * + */ +XPLM_API void XPLMCommandKeyStroke( + XPLMCommandKeyID inKey); + +/* + * XPLMCommandButtonPress + * + * This function simulates any of the actions that might be taken by pressing + * a joystick button. However, this lets you call the command directly rather + * than have to know which button is mapped where. Important: you must release + * each button you press. The APIs are separate so that you can 'hold down' a + * button for a fixed amount of time. + * + * Deprecated: use XPLMCommandBegin. + * + */ +XPLM_API void XPLMCommandButtonPress( + XPLMCommandButtonID inButton); + +/* + * XPLMCommandButtonRelease + * + * This function simulates any of the actions that might be taken by pressing + * a joystick button. See XPLMCommandButtonPress. + * + * Deprecated: use XPLMCommandEnd. + * + */ +XPLM_API void XPLMCommandButtonRelease( + XPLMCommandButtonID inButton); + +#endif /* XPLM_DEPRECATED */ +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/SDK/Delphi/Widgets/XPStandardWidgets.pas b/XPLPro_Plugin_Source/SDK/SDK/Delphi/Widgets/XPStandardWidgets.pas new file mode 100644 index 0000000..d77f383 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDK/Delphi/Widgets/XPStandardWidgets.pas @@ -0,0 +1,470 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPStandardWidgets; +INTERFACE +{ + ## THEORY OF OPERATION + + The standard widgets are widgets built into the widgets library. While you + can gain access to the widget function that drives them, you generally use + them by calling XPCreateWidget and then listening for special messages, + etc. + + The standard widgets often send mesages to themselves when the user + performs an event; these messages are sent up the widget hierarchy until + they are handled. So you can add a widget proc directly to a push button + (for example) to intercept the message when it is clicked, or you can put + one widget proc on a window for all of the push buttons in the window. Most + of these messages contain the original widget ID as a parameter so you can + know which widget is messaging no matter who it is sent to. +} + +USES + XPWidgetDefs; + {$A4} +{___________________________________________________________________________ + * MAIN WINDOW + ___________________________________________________________________________} +{ + The main window widget class provides a "window" as the user knows it. + These windows are dragable and can be selected. Use them to create floating + windows and non-modal dialogs. +} + + +CONST + xpWidgetClass_MainWindow = 1; + + { + Main Window Type Values + + These type values are used to control the appearance of a main window. + } + { The standard main window; pin stripes on XP7, metal frame on XP 6. } + xpMainWindowStyle_MainWindow = 0 +; + { A translucent dark gray window, like the one ATC messages appear in. } + xpMainWindowStyle_Translucent = 1 +; + + { + Main Window Properties + } + { This property specifies the type of window. Set to one of the main window } + { types above. } + xpProperty_MainWindowType = 1100 +; + { This property specifies whether the main window has close boxes in its } + { corners. } + xpProperty_MainWindowHasCloseBoxes = 1200 +; + + { + MainWindow Messages + } + { This message is sent when the close buttons are pressed for your window. } + xpMessage_CloseButtonPushed = 1200 +; + +{___________________________________________________________________________ + * SUB WINDOW + ___________________________________________________________________________} +{ + X-Plane dialogs are divided into separate areas; the sub window widgets + allow you to make these areas. Create one main window and place several + subwindows inside it. Then place your controls inside the subwindows. +} + + +CONST + xpWidgetClass_SubWindow = 2; + + { + SubWindow Type Values + + These values control the appearance of the subwindow. + } + { A panel that sits inside a main window. } + xpSubWindowStyle_SubWindow = 0 +; + { A screen that sits inside a panel for showing text information. } + xpSubWindowStyle_Screen = 2 +; + { A list view for scrolling lists. } + xpSubWindowStyle_ListView = 3 +; + + { + SubWindow Properties + } + { This property specifies the type of window. Set to one of the subwindow } + { types above. } + xpProperty_SubWindowType = 1200 +; + +{___________________________________________________________________________ + * BUTTON + ___________________________________________________________________________} +{ + The button class provides a number of different button styles and + behaviors, including push buttons, radio buttons, check boxes, etc. The + button label appears on or next to the button depending on the button's + appearance, or type. + + The button's behavior is a separate property that dictates who it hilights + and what kinds of messages it sends. Since behavior and type are different, + you can do strange things like make check boxes that act as push buttons or + push buttons with radio button behavior. + + In X-Plane 6 there were no check box graphics. The result is the following + behavior: in X-Plane + 6 all check box and radio buttons are round (radio-button style) buttons; + in X-Plane 7 they are all square (check-box style) buttons. In a future + version of X-Plane, the xpButtonBehavior enums will provide the correct + graphic (check box or radio button) giving the expected result. +} + + +CONST + xpWidgetClass_Button = 3; + + { + Button Types + + These define the visual appearance of buttons but not how they respond to + the mouse. + } + { This is a standard push button, like an 'OK' or 'Cancel' button in a dialog} + { box. } + xpPushButton = 0 +; + { A check box or radio button. Use this and the button behaviors below to } + { get the desired behavior. } + xpRadioButton = 1 +; + { A window close box. } + xpWindowCloseBox = 3 +; + { A small down arrow. } + xpLittleDownArrow = 5 +; + { A small up arrow. } + xpLittleUpArrow = 6 +; + + { + Button Behavior Values + + These define how the button responds to mouse clicks. + } + { Standard push button behavior. The button hilites while the mouse is } + { clicked over it and unhilites when the mouse is moved outside of it or } + { released. If the mouse is released over the button, the } + { xpMsg_PushButtonPressed message is sent. } + xpButtonBehaviorPushButton = 0 +; + { Check box behavior. The button immediately toggles its value when the mouse} + { is clicked and sends out a xpMsg_ButtonStateChanged message. } + xpButtonBehaviorCheckBox = 1 +; + { Radio button behavior. The button immediately sets its state to one and } + { sends out a xpMsg_ButtonStateChanged message if it was not already set to } + { one. You must turn off other radio buttons in a group in your code. } + xpButtonBehaviorRadioButton = 2 +; + + { + Button Properties + } + { This property sets the visual type of button. Use one of the button types } + { above. } + xpProperty_ButtonType = 1300 +; + { This property sets the button's behavior. Use one of the button behaviors } + { above. } + xpProperty_ButtonBehavior = 1301 +; + { This property tells whether a check box or radio button is "checked" or } + { not. Not used for push buttons. } + xpProperty_ButtonState = 1302 +; + + { + Button Messages + + These messages are sent by the button to itself and then up the widget + chain when the button is clicked. (You may intercept them by providing a + widget handler for the button itself or by providing a handler in a parent + widget.) + } + { This message is sent when the user completes a click and release in a } + { button with push button behavior. Parameter one of the message is the } + { widget ID of the button. This message is dispatched up the widget } + { hierarchy. } + xpMsg_PushButtonPressed = 1300 +; + { This message is sent when a button is clicked that has radio button or } + { check box behavior and its value changes. (Note that if the value changes } + { by setting a property you do not receive this message!) Parameter one is } + { the widget ID of the button, parameter 2 is the new state value, either } + { zero or one. This message is dispatched up the widget hierarchy. } + xpMsg_ButtonStateChanged = 1301 +; + +{___________________________________________________________________________ + * TEXT FIELD + ___________________________________________________________________________} +{ + The text field widget provides an editable text field including mouse + selection and keyboard navigation. The contents of the text field are its + descriptor. (The descriptor changes as the user types.) + + The text field can have a number of types, that effect the visual layout of + the text field. The text field sends messages to itself so you may control + its behavior. + + If you need to filter keystrokes, add a new handler and intercept the key + press message. Since key presses are passed by pointer, you can modify the + keystroke and pass it through to the text field widget. + + WARNING: in X-Plane before 7.10 (including 6.70) null characters could + crash X-Plane. To prevent this, wrap this object with a filter function + (more instructions can be found on the SDK website). +} + + +CONST + xpWidgetClass_TextField = 4; + + { + Text Field Type Values + + These control the look of the text field. + } + { A field for text entry. } + xpTextEntryField = 0 +; + { A transparent text field. The user can type and the text is drawn, but no } + { background is drawn. You can draw your own background by adding a widget } + { handler and prehandling the draw message. } + xpTextTransparent = 3 +; + { A translucent edit field, dark gray. } + xpTextTranslucent = 4 +; + + { + Text Field Properties + } + { This is the character position the selection starts at, zero based. If it } + { is the same as the end insertion point, the insertion point is not a } + { selection. } + xpProperty_EditFieldSelStart = 1400 +; + { This is the character position of the end of the selection. } + xpProperty_EditFieldSelEnd = 1401 +; + { This is the character position a drag was started at if the user is } + { dragging to select text, or -1 if a drag is not in progress. } + xpProperty_EditFieldSelDragStart = 1402 +; + { This is the type of text field to display, from the above list. } + xpProperty_TextFieldType = 1403 +; + { Set this property to 1 to password protect the field. Characters will be } + { drawn as *s even though the descriptor will contain plain-text. } + xpProperty_PasswordMode = 1404 +; + { The max number of characters you can enter, if limited. Zero means } + { unlimited. } + xpProperty_MaxCharacters = 1405 +; + { The first visible character on the left. This effectively scrolls the text} + { field. } + xpProperty_ScrollPosition = 1406 +; + { The font to draw the field's text with. (An XPLMFontID.) } + xpProperty_Font = 1407 +; + { This is the active side of the insert selection. (Internal) } + xpProperty_ActiveEditSide = 1408 +; + + { + Text Field Messages + } + { The text field sends this message to itself when its text changes. It sends} + { the message up the call chain; param1 is the text field's widget ID. } + xpMsg_TextFieldChanged = 1400 +; + +{___________________________________________________________________________ + * SCROLL BAR + ___________________________________________________________________________} +{ + A standard scroll bar or slider control. The scroll bar has a minimum, + maximum and current value that is updated when the user drags it. The + scroll bar sends continuous messages as it is dragged. +} + + +CONST + xpWidgetClass_ScrollBar = 5; + + { + Scroll Bar Type Values + + This defines how the scroll bar looks. + } + { A standard X-Plane scroll bar (with arrows on the ends). } + xpScrollBarTypeScrollBar = 0 +; + { A slider, no arrows. } + xpScrollBarTypeSlider = 1 +; + + { + Scroll Bar Properties + } + { The current position of the thumb (in between the min and max, inclusive) } + xpProperty_ScrollBarSliderPosition = 1500 +; + { The value the scroll bar has when the thumb is in the lowest position. } + xpProperty_ScrollBarMin = 1501 +; + { The value the scroll bar has when the thumb is in the highest position. } + xpProperty_ScrollBarMax = 1502 +; + { How many units to move the scroll bar when clicking next to the thumb. The } + { scroll bar always moves one unit when the arrows are clicked. } + xpProperty_ScrollBarPageAmount = 1503 +; + { The type of scrollbar from the enums above. } + xpProperty_ScrollBarType = 1504 +; + { Used internally. } + xpProperty_ScrollBarSlop = 1505 +; + + { + Scroll Bar Messages + } + { The scroll bar sends this message when the slider position changes. It } + { sends the message up the call chain; param1 is the Scroll Bar widget ID. } + xpMsg_ScrollBarSliderPositionChanged = 1500 +; + +{___________________________________________________________________________ + * CAPTION + ___________________________________________________________________________} +{ + A caption is a simple widget that shows its descriptor as a string, useful + for labeling parts of a window. It always shows its descriptor as its + string and is otherwise transparent. +} + + +CONST + xpWidgetClass_Caption = 6; + + { + Caption Properties + } + { This property specifies whether the caption is lit; use lit captions } + { against screens. } + xpProperty_CaptionLit = 1600 +; + +{___________________________________________________________________________ + * GENERAL GRAPHICS + ___________________________________________________________________________} +{ + The general graphics widget can show one of many icons available from + X-Plane. +} + + +CONST + xpWidgetClass_GeneralGraphics = 7; + + { + General Graphics Types Values + + These define the icon for the general graphics. + } + xpShip = 4 +; + xpILSGlideScope = 5 +; + xpMarkerLeft = 6 +; + xp_Airport = 7 +; + xpNDB = 8 +; + xpVOR = 9 +; + xpRadioTower = 10 +; + xpAircraftCarrier = 11 +; + xpFire = 12 +; + xpMarkerRight = 13 +; + xpCustomObject = 14 +; + xpCoolingTower = 15 +; + xpSmokeStack = 16 +; + xpBuilding = 17 +; + xpPowerLine = 18 +; + xpVORWithCompassRose = 19 +; + xpOilPlatform = 21 +; + xpOilPlatformSmall = 22 +; + xpWayPoint = 23 +; + + { + General Graphics Properties + } + { This property controls the type of icon that is drawn. } + xpProperty_GeneralGraphicsType = 1700 +; + +{___________________________________________________________________________ + * PROGRESS INDICATOR + ___________________________________________________________________________} +{ + This widget implements a progress indicator as seen when X-Plane starts up. +} + +CONST + xpWidgetClass_Progress = 8; + + { + Progress Indicator Properties + } + { This is the current value of the progress indicator. } + xpProperty_ProgressPosition = 1800 +; + { This is the minimum value, equivalent to 0% filled. } + xpProperty_ProgressMin = 1801 +; + { This is the maximum value, equivalent to 100% filled. } + xpProperty_ProgressMax = 1802 +; + + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/SDK/Delphi/Widgets/XPUIGraphics.pas b/XPLPro_Plugin_Source/SDK/SDK/Delphi/Widgets/XPUIGraphics.pas new file mode 100644 index 0000000..65e0636 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDK/Delphi/Widgets/XPUIGraphics.pas @@ -0,0 +1,342 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPUIGraphics; +INTERFACE + +USES + XPWidgetDefs; + {$A4} +{___________________________________________________________________________ + * UI GRAPHICS + ___________________________________________________________________________} + + { + XPWindowStyle + + There are a few built-in window styles in X-Plane that you can use. + + Note that X-Plane 6 does not offer real shadow-compositing; you must make + sure to put a window on top of another window of the right style to the + shadows work, etc. This applies to elements with insets and shadows. The + rules are: + + Sub windows must go on top of main windows, and screens and list views on + top of subwindows. Only help and main windows can be over the main screen. + + With X-Plane 7 any window or element may be placed over any other element. + + Some windows are scaled by stretching, some by repeating. The drawing + routines know which scaling method to use. The list view cannot be rescaled + in X-Plane 6 because it has both a repeating pattern and a gradient in one + element. All other elements can be rescaled. + } +TYPE + XPWindowStyle = ( + { An LCD screen that shows help. } + xpWindow_Help = 0 + + { A dialog box window. } + ,xpWindow_MainWindow = 1 + + { A panel or frame within a dialog box window. } + ,xpWindow_SubWindow = 2 + + { An LCD screen within a panel to hold text displays. } + ,xpWindow_Screen = 4 + + { A list view within a panel for scrolling file names, etc. } + ,xpWindow_ListView = 5 + + ); + PXPWindowStyle = ^XPWindowStyle; + + { + XPDrawWindow + + This routine draws a window of the given dimensions at the given offset on + the virtual screen in a given style. The window is automatically scaled as + appropriate using a bitmap scaling technique (scaling or repeating) as + appropriate to the style. + } + PROCEDURE XPDrawWindow( + inX1 : Integer; + inY1 : Integer; + inX2 : Integer; + inY2 : Integer; + inStyle : XPWindowStyle); + cdecl; external XPWIDGETS.DLL; + + { + XPGetWindowDefaultDimensions + + This routine returns the default dimensions for a window. Output is either + a minimum or fixed value depending on whether the window is scalable. + } + PROCEDURE XPGetWindowDefaultDimensions( + inStyle : XPWindowStyle; + outWidth : PInteger; { Can be nil } + outHeight : PInteger); { Can be nil } + cdecl; external XPWIDGETS.DLL; + + { + XPElementStyle + + Elements are individually drawable UI things like push buttons, etc. The + style defines what kind of element you are drawing. Elements can be + stretched in one or two dimensions (depending on the element). Some + elements can be lit. + + In X-Plane 6 some elements must be drawn over metal. Some are scalable and + some are not. Any element can be drawn anywhere in X-Plane 7. + + Scalable Axis Required Background + } +TYPE + XPElementStyle = ( + { x metal } + xpElement_TextField = 6 + + { none metal } + ,xpElement_CheckBox = 9 + + { none metal } + ,xpElement_CheckBoxLit = 10 + + { none window header } + ,xpElement_WindowCloseBox = 14 + + { none window header } + ,xpElement_WindowCloseBoxPressed = 15 + + { x metal } + ,xpElement_PushButton = 16 + + { x metal } + ,xpElement_PushButtonLit = 17 + + { none any } + ,xpElement_OilPlatform = 24 + + { none any } + ,xpElement_OilPlatformSmall = 25 + + { none any } + ,xpElement_Ship = 26 + + { none any } + ,xpElement_ILSGlideScope = 27 + + { none any } + ,xpElement_MarkerLeft = 28 + + { none any } + ,xpElement_Airport = 29 + + { none any } + ,xpElement_Waypoint = 30 + + { none any } + ,xpElement_NDB = 31 + + { none any } + ,xpElement_VOR = 32 + + { none any } + ,xpElement_RadioTower = 33 + + { none any } + ,xpElement_AircraftCarrier = 34 + + { none any } + ,xpElement_Fire = 35 + + { none any } + ,xpElement_MarkerRight = 36 + + { none any } + ,xpElement_CustomObject = 37 + + { none any } + ,xpElement_CoolingTower = 38 + + { none any } + ,xpElement_SmokeStack = 39 + + { none any } + ,xpElement_Building = 40 + + { none any } + ,xpElement_PowerLine = 41 + + { none metal } + ,xpElement_CopyButtons = 45 + + { none metal } + ,xpElement_CopyButtonsWithEditingGrid = 46 + + { x, y metal } + ,xpElement_EditingGrid = 47 + + { THIS CAN PROBABLY BE REMOVED } + ,xpElement_ScrollBar = 48 + + { none any } + ,xpElement_VORWithCompassRose = 49 + + { none metal } + ,xpElement_Zoomer = 51 + + { x, y metal } + ,xpElement_TextFieldMiddle = 52 + + { none metal } + ,xpElement_LittleDownArrow = 53 + + { none metal } + ,xpElement_LittleUpArrow = 54 + + { none metal } + ,xpElement_WindowDragBar = 61 + + { none metal } + ,xpElement_WindowDragBarSmooth = 62 + + ); + PXPElementStyle = ^XPElementStyle; + + { + XPDrawElement + + XPDrawElement draws a given element at an offset on the virtual screen in + set dimensions. + *Even* if the element is not scalable, it will be scaled if the width and + height do not match the preferred dimensions; it'll just look ugly. Pass + inLit to see the lit version of the element; if the element cannot be lit + this is ignored. + } + PROCEDURE XPDrawElement( + inX1 : Integer; + inY1 : Integer; + inX2 : Integer; + inY2 : Integer; + inStyle : XPElementStyle; + inLit : Integer); + cdecl; external XPWIDGETS.DLL; + + { + XPGetElementDefaultDimensions + + This routine returns the recommended or minimum dimensions of a given UI + element. outCanBeLit tells whether the element has both a lit and unlit + state. Pass `NULL` to not receive any of these parameters. + } + PROCEDURE XPGetElementDefaultDimensions( + inStyle : XPElementStyle; + outWidth : PInteger; { Can be nil } + outHeight : PInteger; { Can be nil } + outCanBeLit : PInteger); { Can be nil } + cdecl; external XPWIDGETS.DLL; + + { + XPTrackStyle + + A track is a UI element that displays a value vertically or horizontally. + X-Plane has three kinds of tracks: scroll bars, sliders, and progress bars. + Tracks can be displayed either horizontally or vertically; tracks will + choose their own layout based on the larger dimension of their dimensions + (e.g. they know if they are tall or wide). Sliders may be lit or unlit + (showing the user manipulating them). + + - ScrollBar: this is a standard scroll bar with arrows and a thumb to drag. + - Slider: this is a simple track with a ball in the middle that can be + slid. + - Progress: this is a progress indicator showing how a long task is going. + } +TYPE + XPTrackStyle = ( + { not over metal can be lit can be rotated } + xpTrack_ScrollBar = 0 + + { over metal can be lit can be rotated } + ,xpTrack_Slider = 1 + + { over metal cannot be lit cannot be rotated } + ,xpTrack_Progress = 2 + + ); + PXPTrackStyle = ^XPTrackStyle; + + { + XPDrawTrack + + This routine draws a track. You pass in the track dimensions and size; the + track picks the optimal orientation for these dimensions. Pass in the + track's minimum current and maximum values; the indicator will be + positioned appropriately. You can also specify whether the track is lit or + not. + } + PROCEDURE XPDrawTrack( + inX1 : Integer; + inY1 : Integer; + inX2 : Integer; + inY2 : Integer; + inMin : Integer; + inMax : Integer; + inValue : Integer; + inTrackStyle : XPTrackStyle; + inLit : Integer); + cdecl; external XPWIDGETS.DLL; + + { + XPGetTrackDefaultDimensions + + This routine returns a track's default smaller dimension; all tracks are + scalable in the larger dimension. It also returns whether a track can be + lit. + } + PROCEDURE XPGetTrackDefaultDimensions( + inStyle : XPTrackStyle; + outWidth : PInteger; + outCanBeLit : PInteger); + cdecl; external XPWIDGETS.DLL; + + { + XPGetTrackMetrics + + This routine returns the metrics of a track. If you want to write UI code + to manipulate a track, this routine helps you know where the mouse + locations are. For most other elements, the rectangle the element is drawn + in is enough information. However, the scrollbar drawing routine does some + automatic placement; this routine lets you know where things ended up. You + pass almost everything you would pass to the draw routine. You get out the + orientation, and other useful stuff. + + Besides orientation, you get five dimensions for the five parts of a + scrollbar, which are the down button, down area (area before the thumb), + the thumb, and the up area and button. For horizontal scrollers, the left + button decreases; for vertical scrollers, the top button decreases. + } + PROCEDURE XPGetTrackMetrics( + inX1 : Integer; + inY1 : Integer; + inX2 : Integer; + inY2 : Integer; + inMin : Integer; + inMax : Integer; + inValue : Integer; + inTrackStyle : XPTrackStyle; + outIsVertical : PInteger; + outDownBtnSize : PInteger; + outDownPageSize : PInteger; + outThumbSize : PInteger; + outUpPageSize : PInteger; + outUpBtnSize : PInteger); + cdecl; external XPWIDGETS.DLL; + + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/SDK/Delphi/Widgets/XPWidgetDefs.pas b/XPLPro_Plugin_Source/SDK/SDK/Delphi/Widgets/XPWidgetDefs.pas new file mode 100644 index 0000000..1cc342f --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDK/Delphi/Widgets/XPWidgetDefs.pas @@ -0,0 +1,427 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPWidgetDefs; +INTERFACE + +USES + XPLMDefs; + {$A4} +{___________________________________________________________________________ + * WIDGET DEFINITIONS + ___________________________________________________________________________} +{ + A widget is a call-back driven screen entity like a push-button, window, + text entry field, etc. + + Use the widget API to create widgets of various classes. You can nest them + into trees of widgets to create complex user interfaces. +} + + +TYPE + { + XPWidgetID + + A Widget ID is an opaque unique non-zero handle identifying your widget. + Use 0 to specify "no widget". This type is defined as wide enough to hold a + pointer. You receive a widget ID when you create a new widget and then use + that widget ID to further refer to the widget. + } + XPWidgetID = pointer; + PXPWidgetID = ^XPWidgetID; + + { + XPWidgetPropertyID + + Properties are values attached to instances of your widgets. A property is + identified by a 32-bit ID and its value is the width of a pointer. + + Each widget instance may have a property or not have it. When you set a + property on a widget for the first time, the property is added to the + widget; it then stays there for the life of the widget. + + Some property IDs are predefined by the widget package; you can make up + your own property IDs as well. + } + XPWidgetPropertyID = ( + { A window's refcon is an opaque value used by client code to find other data} + { based on it. } + xpProperty_Refcon = 0 + + { These properties are used by the utlities to implement dragging. } + ,xpProperty_Dragging = 1 + + ,xpProperty_DragXOff = 2 + + ,xpProperty_DragYOff = 3 + + { Is the widget hilited? (For widgets that support this kind of thing.) } + ,xpProperty_Hilited = 4 + + { Is there a C++ object attached to this widget? } + ,xpProperty_Object = 5 + + { If this property is 1, the widget package will use OpenGL to restrict } + { drawing to the Wiget's exposed rectangle. } + ,xpProperty_Clip = 6 + + { Is this widget enabled (for those that have a disabled state too)? } + ,xpProperty_Enabled = 7 + + { NOTE: Property IDs 1 - 999 are reserved for the widgets library. } + { } + { NOTE: Property IDs 1000 - 9999 are allocated to the standard widget classes} + { provided with the library. } + { } + { Properties 1000 - 1099 are for widget class 0, 1100 - 1199 for widget class} + { 1, etc. } + ,xpProperty_UserStart = 10000 + + ); + PXPWidgetPropertyID = ^XPWidgetPropertyID; + + { + XPMouseState_t + + When the mouse is clicked or dragged, a pointer to this structure is passed + to your widget function. + } + XPMouseState_t = RECORD + x : Integer; + y : Integer; + { Mouse Button number, left = 0 (right button not yet supported. } + button : Integer; +{$IFDEF XPLM200} + { Scroll wheel delta (button in this case would be the wheel axis number). } + delta : Integer; +{$ENDIF XPLM200} + END; + PXPMouseState_t = ^XPMouseState_t; + + { + XPKeyState_t + + When a key is pressed, a pointer to this struct is passed to your widget + function. + } + XPKeyState_t = RECORD + { The ASCII key that was pressed. WARNING: this may be 0 for some non-ASCII } + { key sequences. } + key : XPLMChar; + { The flags. Make sure to check this if you only want key-downs! } + flags : XPLMKeyFlags; + { The virtual key code for the key } + vkey : XPLMChar; + END; + PXPKeyState_t = ^XPKeyState_t; + + { + XPWidgetGeometryChange_t + + This structure contains the deltas for your widget's geometry when it + changes. + } + XPWidgetGeometryChange_t = RECORD + dx : Integer; + { +Y = the widget moved up } + dy : Integer; + dwidth : Integer; + dheight : Integer; + END; + PXPWidgetGeometryChange_t = ^XPWidgetGeometryChange_t; + + { + XPDispatchMode + + The dispatching modes describe how the widgets library sends out messages. + Currently there are three modes: + } + XPDispatchMode = ( + { The message will only be sent to the target widget. } + xpMode_Direct = 0 + + { The message is sent to the target widget, then up the chain of parents } + { until the message is handled or a parentless widget is reached. } + ,xpMode_UpChain = 1 + + { The message is sent to the target widget and then all of its children } + { recursively depth-first. } + ,xpMode_Recursive = 2 + + { The message is snet just to the target, but goes to every callback, even if} + { it is handled. } + ,xpMode_DirectAllCallbacks = 3 + + { The message is only sent to the very first handler even if it is not } + { accepted. (This is really only useful for some internal widget library } + { functions.) } + ,xpMode_Once = 4 + + ); + PXPDispatchMode = ^XPDispatchMode; + + { + XPWidgetClass + + Widget classes define predefined widget types. A widget class basically + specifies from a library the widget function to be used for the widget. + Most widgets can be made right from classes. + } + XPWidgetClass = Integer; + PXPWidgetClass = ^XPWidgetClass; + +CONST + { An unspecified widget class. Other widget classes are in } + { XPStandardWidgets.h } + xpWidgetClass_None = 0; + +{___________________________________________________________________________ + * WIDGET MESSAGES + ___________________________________________________________________________} + + { + XPWidgetMessage + + Widgets receive 32-bit messages indicating what action is to be taken or + notifications of events. The list of messages may be expanded. + } +TYPE + XPWidgetMessage = ( + { No message, should not be sent. } + xpMsg_None = 0 + + { The create message is sent once per widget that is created with your widget} + { function and once for any widget that has your widget function attached. } + { } + { Dispatching: Direct } + { } + { Param 1: 1 if you are being added as a subclass, 0 if the widget is first } + { being created. } + ,xpMsg_Create = 1 + + { The destroy message is sent once for each message that is destroyed that } + { has your widget function. } + { } + { Dispatching: Direct for all } + { } + { Param 1: 1 if being deleted by a recursive delete to the parent, 0 for } + { explicit deletion. } + ,xpMsg_Destroy = 2 + + { The paint message is sent to your widget to draw itself. The paint message } + { is the bare-bones message; in response you must draw yourself, draw your } + { children, set up clipping and culling, check for visibility, etc. If you } + { don't want to do all of this, ignore the paint message and a draw message } + { (see below) will be sent to you. } + { } + { Dispatching: Direct } + ,xpMsg_Paint = 3 + + { The draw message is sent to your widget when it is time to draw yourself. } + { OpenGL will be set up to draw in 2-d global screen coordinates, but you } + { should use the XPLM to set up OpenGL state. } + { } + { Dispatching: Direct } + ,xpMsg_Draw = 4 + + { The key press message is sent once per key that is pressed. The first } + { parameter is the type of key code (integer or char) and the second is the } + { code itself. By handling this event, you consume the key stroke. } + { } + { Handling this message 'consumes' the keystroke; not handling it passes it } + { to your parent widget. } + { } + { Dispatching: Up Chain } + { } + { Param 1: A pointer to an XPKeyState_t structure with the keystroke. } + ,xpMsg_KeyPress = 5 + + { Keyboard focus is being given to you. By handling this message you accept } + { keyboard focus. The first parameter will be one if a child of yours gave up} + { focus to you, 0 if someone set focus on you explicitly. } + { } + { Handling this message accepts focus; not handling refuses focus. } + { } + { Dispatching: direct } + { } + { Param 1: 1 if you are gaining focus because your child is giving it up, 0 } + { if someone is explicitly giving you focus. } + ,xpMsg_KeyTakeFocus = 6 + + { Keyboard focus is being taken away from you. The first parameter will be } + { one if you are losing focus because another widget is taking it, or 0 if } + { someone called the API to make you lose focus explicitly. } + { } + { Dispatching: Direct } + { } + { Param 1: 1 if focus is being taken by another widget, 0 if code requested } + { to remove focus. } + ,xpMsg_KeyLoseFocus = 7 + + { You receive one mousedown event per click with a mouse-state structure } + { pointed to by parameter 1, by accepting this you eat the click, otherwise } + { your parent gets it. You will not receive drag and mouse up messages if you} + { do not accept the down message. } + { } + { Handling this message consumes the mouse click, not handling it passes it } + { to the next widget. You can act 'transparent' as a window by never handling} + { moues clicks to certain areas. } + { } + { Dispatching: Up chain NOTE: Technically this is direct dispatched, but the } + { widgets library will shop it to each widget until one consumes the click, } + { making it effectively "up chain". } + { } + { Param 1: A pointer to an XPMouseState_t containing the mouse status. } + ,xpMsg_MouseDown = 8 + + { You receive a series of mouse drag messages (typically one per frame in the} + { sim) as the mouse is moved once you have accepted a mouse down message. } + { Parameter one points to a mouse-state structure describing the mouse } + { location. You will continue to receive these until the mouse button is } + { released. You may receive multiple mouse state messages with the same mouse} + { position. You will receive mouse drag events even if the mouse is dragged } + { out of your current or original bounds at the time of the mouse down. } + { } + { Dispatching: Direct } + { } + { Param 1: A pointer to an XPMouseState_t containing the mouse status. } + ,xpMsg_MouseDrag = 9 + + { The mouseup event is sent once when the mouse button is released after a } + { drag or click. You only receive this message if you accept the mouseDown } + { message. Parameter one points to a mouse state structure. } + { } + { Dispatching: Direct } + { } + { Param 1: A pointer to an XPMouseState_t containing the mouse status. } + ,xpMsg_MouseUp = 10 + + { Your geometry or a child's geometry is being changed. } + { } + { Dispatching: Up chain } + { } + { Param 1: The widget ID of the original reshaped target. } + { } + { Param 2: A pointer to a XPWidgetGeometryChange_t struct describing the } + { change. } + ,xpMsg_Reshape = 11 + + { Your exposed area has changed. } + { } + { Dispatching: Direct } + ,xpMsg_ExposedChanged = 12 + + { A child has been added to you. The child's ID is passed in parameter one. } + { } + { Dispatching: Direct } + { } + { Param 1: The Widget ID of the child being added. } + ,xpMsg_AcceptChild = 13 + + { A child has been removed from to you. The child's ID is passed in parameter} + { one. } + { } + { Dispatching: Direct } + { } + { Param 1: The Widget ID of the child being removed. } + ,xpMsg_LoseChild = 14 + + { You now have a new parent, or have no parent. The parent's ID is passed in,} + { or 0 for no parent. } + { } + { Dispatching: Direct } + { } + { Param 1: The Widget ID of your parent } + ,xpMsg_AcceptParent = 15 + + { You or a child has been shown. Note that this does not include you being } + { shown because your parent was shown, you were put in a new parent, your } + { root was shown, etc. } + { } + { Dispatching: Up chain } + { } + { Param 1: The widget ID of the shown widget. } + ,xpMsg_Shown = 16 + + { You have been hidden. See limitations above. } + { } + { Dispatching: Up chain } + { } + { Param 1: The widget ID of the hidden widget. } + ,xpMsg_Hidden = 17 + + { Your descriptor has changed. } + { } + { Dispatching: Direct } + ,xpMsg_DescriptorChanged = 18 + + { A property has changed. Param 1 contains the property ID. } + { } + { Dispatching: Direct } + { } + { Param 1: The Property ID being changed. } + { } + { Param 2: The new property value } + ,xpMsg_PropertyChanged = 19 + +{$IFDEF XPLM200} + { The mouse wheel has moved. } + { } + { Return 1 to consume the mouse wheel move, or 0 to pass the message to a } + { parent. Dispatching: Up chain } + { } + { Param 1: A pointer to an XPMouseState_t containing the mouse status. } + ,xpMsg_MouseWheel = 20 +{$ENDIF XPLM200} + +{$IFDEF XPLM200} + { The cursor is over your widget. If you consume this message, change the } + { XPLMCursorStatus value to indicate the desired result, with the same rules } + { as in XPLMDisplay.h. } + { } + { Return 1 to consume this message, 0 to pass it on. } + { } + { Dispatching: Up chain Param 1: A pointer to an XPMouseState_t struct } + { containing the mouse status. } + { } + { Param 2: A pointer to a XPLMCursorStatus - set this to the cursor result } + { you desire. } + ,xpMsg_CursorAdjust = 21 +{$ENDIF XPLM200} + + { NOTE: Message IDs 1000 - 9999 are allocated to the standard widget classes } + { provided with the library with 1000 - 1099 for widget class 0, 1100 - 1199 } + { for widget class 1, etc. Message IDs 10,000 and beyond are for plugin use. } + ,xpMsg_UserStart = 10000 + + ); + PXPWidgetMessage = ^XPWidgetMessage; + +{___________________________________________________________________________ + * WIDGET CALLBACK FUNCTION + ___________________________________________________________________________} + + { + XPWidgetFunc_t + + This function defines your custom widget's behavior. It will be called by + the widgets library to send messages to your widget. The message and widget + ID are passed in, as well as two ptr-width signed parameters whose meaning + varies with the message. Return 1 to indicate that you have processed the + message, 0 to indicate that you have not. For any message that is not + understood, return 0. + } +TYPE + XPWidgetFunc_t = FUNCTION( + inMessage : XPWidgetMessage; + inWidget : XPWidgetID; + inParam1 : intptr_t; + inParam2 : intptr_t) : Integer; cdecl; + + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/SDK/Delphi/Widgets/XPWidgetUtils.pas b/XPLPro_Plugin_Source/SDK/SDK/Delphi/Widgets/XPWidgetUtils.pas new file mode 100644 index 0000000..9621126 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDK/Delphi/Widgets/XPWidgetUtils.pas @@ -0,0 +1,197 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPWidgetUtils; +INTERFACE +{ + ## USAGE NOTES + + The XPWidgetUtils library contains useful functions that make writing and + using widgets less of a pain. + + One set of functions are the widget behavior functions. These functions + each add specific useful behaviors to widgets. They can be used in two + manners: + + 1. You can add a widget behavior function to a widget as a callback proc + using the XPAddWidgetCallback function. The widget will gain that + behavior. Remember that the last function you add has highest priority. + You can use this to change or augment the behavior of an existing + finished widget. + 2. You can call a widget function from inside your own widget function. + This allows you to include useful behaviors in custom-built widgets. A + number of the standard widgets get their behavior from this library. To + do this, call the behavior function from your function first. If it + returns 1, that means it handled the event and you don't need to; simply + return 1. +} + +USES + XPWidgetDefs; + {$A4} +{___________________________________________________________________________ + * GENERAL UTILITIES + ___________________________________________________________________________} + + + { + XPWidgetCreate_t + + This structure contains all of the parameters needed to create a wiget. It + is used with XPUCreateWidgets to create widgets in bulk from an array. All + parameters correspond to those of XPCreateWidget except for the container + index. + + If the container index is equal to the index of a widget in the array, the + widget in the array passed to XPUCreateWidgets is used as the parent of + this widget. Note that if you pass an index greater than your own position + in the array, the parent you are requesting will not exist yet. + + If the container index is NO_PARENT, the parent widget is specified as + NULL. If the container index is PARAM_PARENT, the widget passed into + XPUCreateWidgets is used. + } +TYPE + XPWidgetCreate_t = RECORD + left : Integer; + top : Integer; + right : Integer; + bottom : Integer; + visible : Integer; + descriptor : XPLMString; + { Whether ethis widget is a root wiget } + isRoot : Integer; + { The index of the widget to contain within, or a constant } + containerIndex : Integer; + widgetClass : XPWidgetClass; + END; + PXPWidgetCreate_t = ^XPWidgetCreate_t; + +CONST + NO_PARENT = -1; + + PARAM_PARENT = -2; + + + { + XPUCreateWidgets + + This function creates a series of widgets from a table (see + XPCreateWidget_t above). Pass in an array of widget creation structures and + an array of widget IDs that will receive each widget. + + Widget parents are specified by index into the created widget table, + allowing you to create nested widget structures. You can create multiple + widget trees in one table. Generally you should create widget trees from + the top down. + + You can also pass in a widget ID that will be used when the widget's parent + is listed as PARAM_PARENT; this allows you to embed widgets created with + XPUCreateWidgets in a widget created previously. + } + PROCEDURE XPUCreateWidgets( + inWidgetDefs : PXPWidgetCreate_t; + inCount : Integer; + inParamParent : XPWidgetID; + ioWidgets : PXPWidgetID); + cdecl; external XPWIDGETS.DLL; + + { + XPUMoveWidgetBy + + Simply moves a widget by an amount, +x = right, +y=up, without resizing the + widget. + } + PROCEDURE XPUMoveWidgetBy( + inWidget : XPWidgetID; + inDeltaX : Integer; + inDeltaY : Integer); + cdecl; external XPWIDGETS.DLL; + +{___________________________________________________________________________ + * LAYOUT MANAGERS + ___________________________________________________________________________} +{ + The layout managers are widget behavior functions for handling where + widgets move. Layout managers can be called from a widget function or + attached to a widget later. +} + + + { + XPUFixedLayout + + This function causes the widget to maintain its children in fixed position + relative to itself as it is resized. Use this on the top level 'window' + widget for your window. + } + FUNCTION XPUFixedLayout( + inMessage : XPWidgetMessage; + inWidget : XPWidgetID; + inParam1 : intptr_t; + inParam2 : intptr_t) : Integer; + cdecl; external XPWIDGETS.DLL; + +{___________________________________________________________________________ + * WIDGET PROC BEHAVIORS + ___________________________________________________________________________} +{ + These widget behavior functions add other useful behaviors to widgets. + These functions cannot be attached to a widget; they must be called from + your widget function. +} + + + { + XPUSelectIfNeeded + + This causes the widget to bring its window to the foreground if it is not + already. inEatClick specifies whether clicks in the background should be + consumed by bringin the window to the foreground. + } + FUNCTION XPUSelectIfNeeded( + inMessage : XPWidgetMessage; + inWidget : XPWidgetID; + inParam1 : intptr_t; + inParam2 : intptr_t; + inEatClick : Integer) : Integer; + cdecl; external XPWIDGETS.DLL; + + { + XPUDefocusKeyboard + + This causes a click in the widget to send keyboard focus back to X-Plane. + This stops editing of any text fields, etc. + } + FUNCTION XPUDefocusKeyboard( + inMessage : XPWidgetMessage; + inWidget : XPWidgetID; + inParam1 : intptr_t; + inParam2 : intptr_t; + inEatClick : Integer) : Integer; + cdecl; external XPWIDGETS.DLL; + + { + XPUDragWidget + + XPUDragWidget drags the widget in response to mouse clicks. Pass in not + only the event, but the global coordinates of the drag region, which might + be a sub-region of your widget (for example, a title bar). + } + FUNCTION XPUDragWidget( + inMessage : XPWidgetMessage; + inWidget : XPWidgetID; + inParam1 : intptr_t; + inParam2 : intptr_t; + inLeft : Integer; + inTop : Integer; + inRight : Integer; + inBottom : Integer) : Integer; + cdecl; external XPWIDGETS.DLL; + + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/SDK/Delphi/Widgets/XPWidgets.pas b/XPLPro_Plugin_Source/SDK/SDK/Delphi/Widgets/XPWidgets.pas new file mode 100644 index 0000000..46ae542 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDK/Delphi/Widgets/XPWidgets.pas @@ -0,0 +1,527 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPWidgets; +INTERFACE +{ + ## THEORY OF OPERATION AND NOTES + + Widgets are persistent view 'objects' for X-Plane. A widget is an object + referenced by its opaque handle (widget ID) and the APIs in this file. You + cannot access the widget's guts directly. Every Widget has the following + intrinsic data: + + - A bounding box defined in global screen coordinates with 0,0 in the + bottom left and +y = up, +x = right. + - A visible box, which is the intersection of the bounding box with the + widget's parents visible box. + - Zero or one parent widgets. (Always zero if the widget is a root widget. + - Zero or more child widgets. + - Whether the widget is a root. Root widgets are the top level plugin + windows. + - Whether the widget is visible. + - A text string descriptor, whose meaning varies from widget to widget. + - An arbitrary set of 32 bit integral properties defined by 32-bit integral + keys. This is how specific widgets store specific data. + - A list of widget callbacks proc that implements the widgets behaviors. + + The Widgets library sends messages to widgets to request specific behaviors + or notify the widget of things. + + Widgets may have more than one callback function, in which case messages + are sent to the most recently added callback function until the message is + handled. Messages may also be sent to parents or children; see the + XPWidgetDefs.h header file for the different widget message dispatching + functions. By adding a callback function to a window you can 'subclass' its + behavior. + + A set of standard widgets are provided that serve common UI purposes. You + can also customize or implement entirely custom widgets. + + Widgets are different than other view hierarchies (most notably Win32, + which they bear a striking resemblance to) in the following ways: + + - Not all behavior can be patched. State that is managed by the XPWidgets + DLL and not by individual widgets cannot be customized. + - All coordinates are in global screen coordinates. Coordinates are not + relative to an enclosing widget, nor are they relative to a display + window. + - Widget messages are always dispatched synchronously, and there is no + concept of scheduling an update or a dirty region. Messages originate + from X-Plane as the sim cycle goes by. Since X-Plane is constantly + redrawing, so are widgets; there is no need to mark a part of a widget as + 'needing redrawing' because redrawing happens frequently whether the + widget needs it or not. + - Any widget may be a 'root' widget, causing it to be drawn; there is no + relationship between widget class and rootness. Root widgets are + imlemented as XPLMDisply windows. +} + +USES + XPWidgetDefs, XPLMDisplay; + {$A4} +{___________________________________________________________________________ + * WIDGET CREATION AND MANAGEMENT + ___________________________________________________________________________} + + { + XPCreateWidget + + This function creates a new widget and returns the new widget's ID to you. + If the widget creation fails for some reason, it returns NULL. Widget + creation will fail either if you pass a bad class ID or if there is not + adequate memory. + + Input Parameters: + + - Top, left, bottom, and right in global screen coordinates defining the + widget's location on the screen. + - inVisible is 1 if the widget should be drawn, 0 to start the widget as + hidden. + - inDescriptor is a null terminated string that will become the widget's + descriptor. + - inIsRoot is 1 if this is going to be a root widget, 0 if it will not be. + - inContainer is the ID of this widget's container. It must be 0 for a root + widget. for a non-root widget, pass the widget ID of the widget to place + this widget within. If this widget is not going to start inside another + widget, pass 0; this new widget will then just be floating off in space + (and will not be drawn until it is placed in a widget. + - inClass is the class of the widget to draw. Use one of the predefined + class-IDs to create a standard widget. + + A note on widget embedding: a widget is only called (and will be drawn, + etc.) if it is placed within a widget that will be called. Root widgets are + always called. So it is possible to have whole chains of widgets that are + simply not called. You can preconstruct widget trees and then place them + into root widgets later to activate them if you wish. + } + FUNCTION XPCreateWidget( + inLeft : Integer; + inTop : Integer; + inRight : Integer; + inBottom : Integer; + inVisible : Integer; + inDescriptor : XPLMString; + inIsRoot : Integer; + inContainer : XPWidgetID; + inClass : XPWidgetClass) : XPWidgetID; + cdecl; external XPWIDGETS.DLL; + + { + XPCreateCustomWidget + + This function is the same as XPCreateWidget except that instead of passing + a class ID, you pass your widget callback function pointer defining the + widget. Use this function to define a custom widget. All parameters are the + same as XPCreateWidget, except that the widget class has been replaced with + the widget function. + } + FUNCTION XPCreateCustomWidget( + inLeft : Integer; + inTop : Integer; + inRight : Integer; + inBottom : Integer; + inVisible : Integer; + inDescriptor : XPLMString; + inIsRoot : Integer; + inContainer : XPWidgetID; + inCallback : XPWidgetFunc_t) : XPWidgetID; + cdecl; external XPWIDGETS.DLL; + + { + XPDestroyWidget + + This class destroys a widget. Pass in the ID of the widget to kill. If you + pass 1 for inDestroyChilren, the widget's children will be destroyed first, + then this widget will be destroyed. (Furthermore, the widget's children + will be destroyed with the inDestroyChildren flag set to 1, so the + destruction will recurse down the widget tree.) If you pass 0 for this + flag, the child widgets will simply end up with their parent set to 0. + } + PROCEDURE XPDestroyWidget( + inWidget : XPWidgetID; + inDestroyChildren : Integer); + cdecl; external XPWIDGETS.DLL; + + { + XPSendMessageToWidget + + This sends any message to a widget. You should probably not go around + simulating the predefined messages that the widgets library defines for + you. You may however define custom messages for your widgets and send them + with this method. + + This method supports several dispatching patterns; see XPDispatchMode for + more info. The function returns 1 if the message was handled, 0 if it was + not. + + For each widget that receives the message (see the dispatching modes), each + widget function from the most recently installed to the oldest one receives + the message in order until it is handled. + } + FUNCTION XPSendMessageToWidget( + inWidget : XPWidgetID; + inMessage : XPWidgetMessage; + inMode : XPDispatchMode; + inParam1 : intptr_t; + inParam2 : intptr_t) : Integer; + cdecl; external XPWIDGETS.DLL; + +{___________________________________________________________________________ + * WIDGET POSITIONING AND VISIBILITY + ___________________________________________________________________________} + + { + XPPlaceWidgetWithin + + This function changes which container a widget resides in. You may NOT use + this function on a root widget! inSubWidget is the widget that will be + moved. Pass a widget ID in inContainer to make inSubWidget be a child of + inContainer. It will become the last/closest widget in the container. Pass + 0 to remove the widget from any container. Any call to this other than + passing the widget ID of the old parent of the affected widget will cause + the widget to be removed from its old parent. Placing a widget within its + own parent simply makes it the last widget. + + NOTE: this routine does not reposition the sub widget in global + coordinates. If the container has layout management code, it will + reposition the subwidget for you, otherwise you must do it with + SetWidgetGeometry. + } + PROCEDURE XPPlaceWidgetWithin( + inSubWidget : XPWidgetID; + inContainer : XPWidgetID); + cdecl; external XPWIDGETS.DLL; + + { + XPCountChildWidgets + + This routine returns the number of widgets another widget contains. + } + FUNCTION XPCountChildWidgets( + inWidget : XPWidgetID) : Integer; + cdecl; external XPWIDGETS.DLL; + + { + XPGetNthChildWidget + + This routine returns the widget ID of a child widget by index. Indexes are + 0 based, from 0 to one minus the number of widgets in the parent, + inclusive. If the index is invalid, 0 is returned. + } + FUNCTION XPGetNthChildWidget( + inWidget : XPWidgetID; + inIndex : Integer) : XPWidgetID; + cdecl; external XPWIDGETS.DLL; + + { + XPGetParentWidget + + Returns the parent of a widget, or 0 if the widget has no parent. Root + widgets never have parents and therefore always return 0. + } + FUNCTION XPGetParentWidget( + inWidget : XPWidgetID) : XPWidgetID; + cdecl; external XPWIDGETS.DLL; + + { + XPShowWidget + + This routine makes a widget visible if it is not already. Note that if a + widget is not in a rooted widget hierarchy or one of its parents is not + visible, it will still not be visible to the user. + } + PROCEDURE XPShowWidget( + inWidget : XPWidgetID); + cdecl; external XPWIDGETS.DLL; + + { + XPHideWidget + + Makes a widget invisible. See XPShowWidget for considerations of when a + widget might not be visible despite its own visibility state. + } + PROCEDURE XPHideWidget( + inWidget : XPWidgetID); + cdecl; external XPWIDGETS.DLL; + + { + XPIsWidgetVisible + + This returns 1 if a widget is visible, 0 if it is not. Note that this + routine takes into consideration whether a parent is invisible. Use this + routine to tell if the user can see the widget. + } + FUNCTION XPIsWidgetVisible( + inWidget : XPWidgetID) : Integer; + cdecl; external XPWIDGETS.DLL; + + { + XPFindRootWidget + + Returns the Widget ID of the root widget that contains the passed in widget + or NULL if the passed in widget is not in a rooted hierarchy. + } + FUNCTION XPFindRootWidget( + inWidget : XPWidgetID) : XPWidgetID; + cdecl; external XPWIDGETS.DLL; + + { + XPBringRootWidgetToFront + + This routine makes the specified widget be in the front most widget + hierarchy. If this widget is a root widget, its widget hierarchy comes to + front, otherwise the widget's root is brought to the front. If this widget + is not in an active widget hiearchy (e.g. there is no root widget at the + top of the tree), this routine does nothing. + } + PROCEDURE XPBringRootWidgetToFront( + inWidget : XPWidgetID); + cdecl; external XPWIDGETS.DLL; + + { + XPIsWidgetInFront + + This routine returns true if this widget's hierarchy is the front most + hierarchy. It returns false if the widget's hierarchy is not in front, or + if the widget is not in a rooted hierarchy. + } + FUNCTION XPIsWidgetInFront( + inWidget : XPWidgetID) : Integer; + cdecl; external XPWIDGETS.DLL; + + { + XPGetWidgetGeometry + + This routine returns the bounding box of a widget in global coordinates. + Pass NULL for any parameter you are not interested in. + } + PROCEDURE XPGetWidgetGeometry( + inWidget : XPWidgetID; + outLeft : PInteger; { Can be nil } + outTop : PInteger; { Can be nil } + outRight : PInteger; { Can be nil } + outBottom : PInteger); { Can be nil } + cdecl; external XPWIDGETS.DLL; + + { + XPSetWidgetGeometry + + This function changes the bounding box of a widget. + } + PROCEDURE XPSetWidgetGeometry( + inWidget : XPWidgetID; + inLeft : Integer; + inTop : Integer; + inRight : Integer; + inBottom : Integer); + cdecl; external XPWIDGETS.DLL; + + { + XPGetWidgetForLocation + + Given a widget and a location, this routine returns the widget ID of the + child of that widget that owns that location. If inRecursive is true then + this will return a child of a child of a widget as it tries to find the + deepest widget at that location. If inVisibleOnly is true, then only + visible widgets are considered, otherwise all widgets are considered. The + widget ID passed for inContainer will be returned if the location is in + that widget but not in a child widget. 0 is returned if the location is not + in the container. + + NOTE: if a widget's geometry extends outside its parents geometry, it will + not be returned by this call for mouse locations outside the parent + geometry. The parent geometry limits the child's eligibility for mouse + location. + } + FUNCTION XPGetWidgetForLocation( + inContainer : XPWidgetID; + inXOffset : Integer; + inYOffset : Integer; + inRecursive : Integer; + inVisibleOnly : Integer) : XPWidgetID; + cdecl; external XPWIDGETS.DLL; + + { + XPGetWidgetExposedGeometry + + This routine returns the bounds of the area of a widget that is completely + within its parent widgets. Since a widget's bounding box can be outside its + parent, part of its area will not be elligible for mouse clicks and should + not draw. Use XPGetWidgetGeometry to find out what area defines your + widget's shape, but use this routine to find out what area to actually draw + into. Note that the widget library does not use OpenGL clipping to keep + frame rates up, although you could use it internally. + } + PROCEDURE XPGetWidgetExposedGeometry( + inWidgetID : XPWidgetID; + outLeft : PInteger; { Can be nil } + outTop : PInteger; { Can be nil } + outRight : PInteger; { Can be nil } + outBottom : PInteger); { Can be nil } + cdecl; external XPWIDGETS.DLL; + +{___________________________________________________________________________ + * ACCESSING WIDGET DATA + ___________________________________________________________________________} + + { + XPSetWidgetDescriptor + + Every widget has a descriptor, which is a text string. What the text string + is used for varies from widget to widget; for example, a push button's text + is its descriptor, a caption shows its descriptor, and a text field's + descriptor is the text being edited. In other words, the usage for the text + varies from widget to widget, but this API provides a universal and + convenient way to get at it. While not all UI widgets need their + descriptor, many do. + } + PROCEDURE XPSetWidgetDescriptor( + inWidget : XPWidgetID; + inDescriptor : XPLMString); + cdecl; external XPWIDGETS.DLL; + + { + XPGetWidgetDescriptor + + This routine returns the widget's descriptor. Pass in the length of the + buffer you are going to receive the descriptor in. The descriptor will be + null terminated for you. This routine returns the length of the actual + descriptor; if you pass NULL for outDescriptor, you can get the + descriptor's length without getting its text. If the length of the + descriptor exceeds your buffer length, the buffer will not be null + terminated (this routine has 'strncpy' semantics). + } + FUNCTION XPGetWidgetDescriptor( + inWidget : XPWidgetID; + outDescriptor : XPLMString; + inMaxDescLength : Integer) : Integer; + cdecl; external XPWIDGETS.DLL; + + { + XPGetWidgetUnderlyingWindow + + Returns the window (from the XPLMDisplay API) that backs your widget + window. If you have opted in to modern windows, via a call to + XPLMEnableFeature("XPLM_USE_NATIVE_WIDGET_WINDOWS", 1), you can use the + returned window ID for display APIs like XPLMSetWindowPositioningMode(), + allowing you to pop the widget window out into a real OS window, or move it + into VR. + } + FUNCTION XPGetWidgetUnderlyingWindow( + inWidget : XPWidgetID) : XPLMWindowID; + cdecl; external XPWIDGETS.DLL; + + { + XPSetWidgetProperty + + This function sets a widget's property. Properties are arbitrary values + associated by a widget by ID. + } + PROCEDURE XPSetWidgetProperty( + inWidget : XPWidgetID; + inProperty : XPWidgetPropertyID; + inValue : intptr_t); + cdecl; external XPWIDGETS.DLL; + + { + XPGetWidgetProperty + + This routine returns the value of a widget's property, or 0 if the property + is not defined. If you need to know whether the property is defined, pass a + pointer to an int for inExists; the existence of that property will be + returned in the int. Pass NULL for inExists if you do not need this + information. + } + FUNCTION XPGetWidgetProperty( + inWidget : XPWidgetID; + inProperty : XPWidgetPropertyID; + inExists : PInteger) : intptr_t; { Can be nil } + cdecl; external XPWIDGETS.DLL; + +{___________________________________________________________________________ + * KEYBOARD MANAGEMENT + ___________________________________________________________________________} + + { + XPSetKeyboardFocus + + Controls which widget will receive keystrokes. Pass the widget ID of the + widget to get the keys. Note that if the widget does not care about + keystrokes, they will go to the parent widget, and if no widget cares about + them, they go to X-Plane. + + If you set the keyboard focus to widget ID 0, X-Plane gets keyboard focus. + + This routine returns the widget ID that ended up with keyboard focus, or 0 + for X-Plane. + + Keyboard focus is not changed if the new widget will not accept it. For + setting to X-Plane, keyboard focus is always accepted. + } + FUNCTION XPSetKeyboardFocus( + inWidget : XPWidgetID) : XPWidgetID; + cdecl; external XPWIDGETS.DLL; + + { + XPLoseKeyboardFocus + + This causes the specified widget to lose focus; focus is passed to its + parent, or the next parent that will accept it. This routine does nothing + if this widget does not have focus. + } + PROCEDURE XPLoseKeyboardFocus( + inWidget : XPWidgetID); + cdecl; external XPWIDGETS.DLL; + + { + XPGetWidgetWithFocus + + This routine returns the widget that has keyboard focus, or 0 if X-Plane + has keyboard focus or some other plugin window that does not have widgets + has focus. + } + FUNCTION XPGetWidgetWithFocus: XPWidgetID; + cdecl; external XPWIDGETS.DLL; + +{___________________________________________________________________________ + * CREATING CUSTOM WIDGETS + ___________________________________________________________________________} + + { + XPAddWidgetCallback + + This function adds a new widget callback to a widget. This widget callback + supercedes any existing ones and will receive messages first; if it does + not handle messages they will go on to be handled by pre-existing widgets. + + The widget function will remain on the widget for the life of the widget. + The creation message will be sent to the new callback immediately with the + widget ID, and the destruction message will be sent before the other widget + function receives a destruction message. + + This provides a way to 'subclass' an existing widget. By providing a second + hook that only handles certain widget messages, you can customize or extend + widget behavior. + } + PROCEDURE XPAddWidgetCallback( + inWidget : XPWidgetID; + inNewCallback : XPWidgetFunc_t); + cdecl; external XPWIDGETS.DLL; + + { + XPGetWidgetClassFunc + + Given a widget class, this function returns the callbacks that power that + widget class. + } + FUNCTION XPGetWidgetClassFunc( + inWidgetClass : XPWidgetClass) : XPWidgetFunc_t; + cdecl; external XPWIDGETS.DLL; + + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/SDK/Delphi/XPLM/XPLMCamera.pas b/XPLPro_Plugin_Source/SDK/SDK/Delphi/XPLM/XPLMCamera.pas new file mode 100644 index 0000000..ad76fa4 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDK/Delphi/XPLM/XPLMCamera.pas @@ -0,0 +1,155 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPLMCamera; +INTERFACE +{ + The XPLMCamera APIs allow plug-ins to control the camera angle in X-Plane. + This has a number of applications, including but not limited to: + + - Creating new views (including dynamic/user-controllable views) for the + user. + - Creating applications that use X-Plane as a renderer of scenery, + aircrafts, or both. + + The camera is controlled via six parameters: a location in OpenGL + coordinates and pitch, roll and yaw, similar to an airplane's position. + OpenGL coordinate info is described in detail in the XPLMGraphics + documentation; generally you should use the XPLMGraphics routines to + convert from world to local coordinates. The camera's orientation starts + facing level with the ground directly up the negative-Z axis (approximately + north) with the horizon horizontal. It is then rotated clockwise for yaw, + pitched up for positive pitch, and rolled clockwise around the vector it is + looking along for roll. + + You control the camera either either until the user selects a new view or + permanently (the later being similar to how UDP camera control works). You + control the camera by registering a callback per frame from which you + calculate the new camera positions. This guarantees smooth camera motion. + + Use the XPLMDataAccess APIs to get information like the position of the + aircraft, etc. for complex camera positioning. + + Note: if your goal is to move the virtual pilot in the cockpit, this API is + not needed; simply update the datarefs for the pilot's head position. + + For custom exterior cameras, set the camera's mode to an external view + first to get correct sound and 2-d panel behavior. +} + +USES + XPLMDefs; + {$A4} +{___________________________________________________________________________ + * CAMERA CONTROL + ___________________________________________________________________________} + + { + XPLMCameraControlDuration + + This enumeration states how long you want to retain control of the camera. + You can retain it indefinitely or until the user selects a new view. + } +TYPE + XPLMCameraControlDuration = ( + { Control the camera until the user picks a new view. } + xplm_ControlCameraUntilViewChanges = 1 + + { Control the camera until your plugin is disabled or another plugin forcably} + { takes control. } + ,xplm_ControlCameraForever = 2 + + ); + PXPLMCameraControlDuration = ^XPLMCameraControlDuration; + + { + XPLMCameraPosition_t + + This structure contains a full specification of the camera. X, Y, and Z are + the camera's position in OpenGL coordiantes; pitch, roll, and yaw are + rotations from a camera facing flat north in degrees. Positive pitch means + nose up, positive roll means roll right, and positive yaw means yaw right, + all in degrees. Zoom is a zoom factor, with 1.0 meaning normal zoom and 2.0 + magnifying by 2x (objects appear larger). + } + XPLMCameraPosition_t = RECORD + x : Single; + y : Single; + z : Single; + pitch : Single; + heading : Single; + roll : Single; + zoom : Single; + END; + PXPLMCameraPosition_t = ^XPLMCameraPosition_t; + + { + XPLMCameraControl_f + + You use an XPLMCameraControl function to provide continuous control over + the camera. You are passed in a structure in which to put the new camera + position; modify it and return 1 to reposition the camera. Return 0 to + surrender control of the camera; camera control will be handled by X-Plane + on this draw loop. The contents of the structure as you are called are + undefined. + + If X-Plane is taking camera control away from you, this function will be + called with inIsLosingControl set to 1 and ioCameraPosition NULL. + } + XPLMCameraControl_f = FUNCTION( + outCameraPosition : PXPLMCameraPosition_t; { Can be nil } + inIsLosingControl : Integer; + inRefcon : pointer) : Integer; cdecl; + + { + XPLMControlCamera + + This function repositions the camera on the next drawing cycle. You must + pass a non-null control function. Specify in inHowLong how long you'd like + control (indefinitely or until a new view mode is set by the user). + } + PROCEDURE XPLMControlCamera( + inHowLong : XPLMCameraControlDuration; + inControlFunc : XPLMCameraControl_f; + inRefcon : pointer); + cdecl; external XPLM_DLL; + + { + XPLMDontControlCamera + + This function stops you from controlling the camera. If you have a camera + control function, it will not be called with an inIsLosingControl flag. + X-Plane will control the camera on the next cycle. + + For maximum compatibility you should not use this routine unless you are in + posession of the camera. + } + PROCEDURE XPLMDontControlCamera; + cdecl; external XPLM_DLL; + + { + XPLMIsCameraBeingControlled + + This routine returns 1 if the camera is being controlled, zero if it is + not. If it is and you pass in a pointer to a camera control duration, the + current control duration will be returned. + } + FUNCTION XPLMIsCameraBeingControlled( + outCameraControlDuration: PXPLMCameraControlDuration) : Integer; { Can be nil } + cdecl; external XPLM_DLL; + + { + XPLMReadCameraPosition + + This function reads the current camera position. + } + PROCEDURE XPLMReadCameraPosition( + outCameraPosition : PXPLMCameraPosition_t); + cdecl; external XPLM_DLL; + + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/SDK/Delphi/XPLM/XPLMDataAccess.pas b/XPLPro_Plugin_Source/SDK/SDK/Delphi/XPLM/XPLMDataAccess.pas new file mode 100644 index 0000000..1ad210e --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDK/Delphi/XPLM/XPLMDataAccess.pas @@ -0,0 +1,690 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPLMDataAccess; +INTERFACE +{ + The data access API gives you a generic, flexible, high performance way to + read and write data to and from X-Plane and other plug-ins. For example, + this API allows you to read and set the nav radios, get the plane location, + determine the current effective graphics frame rate, etc. + + The data access APIs are the way that you read and write data from the sim + as well as other plugins. + + The API works using opaque data references. A data reference is a source of + data; you do not know where it comes from, but once you have it you can + read the data quickly and possibly write it. + + Dataref Lookup + -------------- + + Data references are identified by verbose, permanent string names; by + convention these names use path separates to form a hierarchy of datarefs, + e.g. (sim/cockpit/radios/nav1_freq_hz). The actual opaque numeric value of + the data reference, as returned by the XPLM API, is implementation defined + and changes each time X-Plane is launched; therefore you need to look up + the dataref by path every time your plugin runs. + + The task of looking up a data reference is relatively expensive; look up + your data references once based on the verbose path strings, and save the + opaque data reference value for the duration of your plugin's operation. + Reading and writing data references is relatively fast (the cost is + equivalent to two function calls through function pointers). + + X-Plane publishes over 4000 datarefs; a complete list may be found in the + reference section of the SDK online documentation (from the SDK home page, + choose Documentation). + + Dataref Types + ------------- + + A note on typing: you must know the correct data type to read and write. + APIs are provided for reading and writing data in a number of ways. You can + also double check the data type for a data ref. Automatic type conversion + is not done for you. + + Dataref types are a set, e.g. a dataref can be more than one type. When + this happens, you can choose which API you want to use to read. For + example, it is not uncommon for a dataref to be of type float and double. + This means you can use either XPLMGetDatad or XPLMGetDataf to read it. + + Creating New Datarefs + --------------------- + + X-Plane provides datarefs that come with the sim, but plugins can also + create their own datarefs. A plugin creates a dataref by registering + function callbacks to read and write the dataref. The XPLM will call your + plugin each time some other plugin (or X-Plane) tries to read or write the + dataref. You must provide a read (and optional write) callback for each + data type you support. + + A note for plugins sharing data with other plugins: the load order of + plugins is not guaranteed. To make sure that every plugin publishing data + has published their data references before other plugins try to subscribe, + publish your data references in your start routine but resolve them the + first time your 'enable' routine is called, or the first time they are + needed in code. + + When a plugin that created a dataref is unloaded, it becomes "orphaned". + The dataref handle continues to be usable, but the dataref is not writable, + and reading it will always return 0 (or 0 items for arrays). If the plugin + is reloaded and re-registers the dataref, the handle becomes un-orphaned + and works again. +} + +USES + XPLMDefs; + {$A4} +{___________________________________________________________________________ + * READING AND WRITING DATA + ___________________________________________________________________________} +{ + These routines allow you to access data from within X-Plane and sometimes + modify it. +} + + +TYPE + { + XPLMDataRef + + A data ref is an opaque handle to data provided by the simulator or another + plugin. It uniquely identifies one variable (or array of variables) over + the lifetime of your plugin. You never hard code these values; you always + get them from XPLMFindDataRef. + } + XPLMDataRef = pointer; + PXPLMDataRef = ^XPLMDataRef; + + { + XPLMDataTypeID + + This is an enumeration that defines the type of the data behind a data + reference. This allows you to sanity check that the data type matches what + you expect. But for the most part, you will know the type of data you are + expecting from the online documentation. + + Data types each take a bit field; it is legal to have a single dataref be + more than one type of data. Whe this happens, you can pick any matching + get/set API. + } + XPLMDataTypeID = ( + { Data of a type the current XPLM doesn't do. } + xplmType_Unknown = 0 + + { A single 4-byte integer, native endian. } + ,xplmType_Int = 1 + + { A single 4-byte float, native endian. } + ,xplmType_Float = 2 + + { A single 8-byte double, native endian. } + ,xplmType_Double = 4 + + { An array of 4-byte floats, native endian. } + ,xplmType_FloatArray = 8 + + { An array of 4-byte integers, native endian. } + ,xplmType_IntArray = 16 + + { A variable block of data. } + ,xplmType_Data = 32 + + ); + PXPLMDataTypeID = ^XPLMDataTypeID; + + { + XPLMFindDataRef + + Given a c-style string that names the data ref, this routine looks up the + actual opaque XPLMDataRef that you use to read and write the data. The + string names for datarefs are published on the X-Plane SDK web site. + + This function returns NULL if the data ref cannot be found. + + NOTE: this function is relatively expensive; save the XPLMDataRef this + function returns for future use. Do not look up your data ref by string + every time you need to read or write it. + } + FUNCTION XPLMFindDataRef( + inDataRefName : XPLMString) : XPLMDataRef; + cdecl; external XPLM_DLL; + + { + XPLMCanWriteDataRef + + Given a data ref, this routine returns true if you can successfully set the + data, false otherwise. Some datarefs are read-only. + + NOTE: even if a dataref is marked writable, it may not act writable. This + can happen for datarefs that X-Plane writes to on every frame of + simulation. In some cases, the dataref is writable but you have to set a + separate "override" dataref to 1 to stop X-Plane from writing it. + } + FUNCTION XPLMCanWriteDataRef( + inDataRef : XPLMDataRef) : Integer; + cdecl; external XPLM_DLL; + + { + XPLMIsDataRefGood + + This function returns true if the passed in handle is a valid dataref that + is not orphaned. + + Note: there is normally no need to call this function; datarefs returned by + XPLMFindDataRef remain valid (but possibly orphaned) unless there is a + complete plugin reload (in which case your plugin is reloaded anyway). + Orphaned datarefs can be safely read and return 0. Therefore you never need + to call XPLMIsDataRefGood to 'check' the safety of a dataref. + (XPLMIsDatarefGood performs some slow checking of the handle validity, so + it has a perormance cost.) + } + FUNCTION XPLMIsDataRefGood( + inDataRef : XPLMDataRef) : Integer; + cdecl; external XPLM_DLL; + + { + XPLMGetDataRefTypes + + This routine returns the types of the data ref for accessor use. If a data + ref is available in multiple data types, the bit-wise OR of these types + will be returned. + } + FUNCTION XPLMGetDataRefTypes( + inDataRef : XPLMDataRef) : XPLMDataTypeID; + cdecl; external XPLM_DLL; + +{___________________________________________________________________________ + * DATA ACCESSORS + ___________________________________________________________________________} +{ + These routines read and write the data references. For each supported data + type there is a reader and a writer. + + If the data ref is orphaned or the plugin that provides it is disabled or + there is a type mismatch, the functions that read data will return 0 as a + default value or not modify the passed in memory. The plugins that write + data will not write under these circumstances or if the data ref is + read-only. + + NOTE: to keep the overhead of reading datarefs low, these routines do not + do full validation of a dataref; passing a junk value for a dataref can + result in crashing the sim. The get/set APIs do check for NULL. + + For array-style datarefs, you specify the number of items to read/write and + the offset into the array; the actual number of items read or written is + returned. This may be less to prevent an array-out-of-bounds error. +} + + + { + XPLMGetDatai + + Read an integer data ref and return its value. The return value is the + dataref value or 0 if the dataref is NULL or the plugin is disabled. + } + FUNCTION XPLMGetDatai( + inDataRef : XPLMDataRef) : Integer; + cdecl; external XPLM_DLL; + + { + XPLMSetDatai + + Write a new value to an integer data ref. This routine is a no-op if the + plugin publishing the dataref is disabled, the dataref is NULL, or the + dataref is not writable. + } + PROCEDURE XPLMSetDatai( + inDataRef : XPLMDataRef; + inValue : Integer); + cdecl; external XPLM_DLL; + + { + XPLMGetDataf + + Read a single precision floating point dataref and return its value. The + return value is the dataref value or 0.0 if the dataref is NULL or the + plugin is disabled. + } + FUNCTION XPLMGetDataf( + inDataRef : XPLMDataRef) : Single; + cdecl; external XPLM_DLL; + + { + XPLMSetDataf + + Write a new value to a single precision floating point data ref. This + routine is a no-op if the plugin publishing the dataref is disabled, the + dataref is NULL, or the dataref is not writable. + } + PROCEDURE XPLMSetDataf( + inDataRef : XPLMDataRef; + inValue : Single); + cdecl; external XPLM_DLL; + + { + XPLMGetDatad + + Read a double precision floating point dataref and return its value. The + return value is the dataref value or 0.0 if the dataref is NULL or the + plugin is disabled. + } + FUNCTION XPLMGetDatad( + inDataRef : XPLMDataRef) : Real; + cdecl; external XPLM_DLL; + + { + XPLMSetDatad + + Write a new value to a double precision floating point data ref. This + routine is a no-op if the plugin publishing the dataref is disabled, the + dataref is NULL, or the dataref is not writable. + } + PROCEDURE XPLMSetDatad( + inDataRef : XPLMDataRef; + inValue : Real); + cdecl; external XPLM_DLL; + + { + XPLMGetDatavi + + Read a part of an integer array dataref. If you pass NULL for outValues, + the routine will return the size of the array, ignoring inOffset and inMax. + + If outValues is not NULL, then up to inMax values are copied from the + dataref into outValues, starting at inOffset in the dataref. If inMax + + inOffset is larger than the size of the dataref, less than inMax values + will be copied. The number of values copied is returned. + + Note: the semantics of array datarefs are entirely implemented by the + plugin (or X-Plane) that provides the dataref, not the SDK itself; the + above description is how these datarefs are intended to work, but a rogue + plugin may have different behavior. + } + FUNCTION XPLMGetDatavi( + inDataRef : XPLMDataRef; + outValues : PInteger; { Can be nil } + inOffset : Integer; + inMax : Integer) : Integer; + cdecl; external XPLM_DLL; + + { + XPLMSetDatavi + + Write part or all of an integer array dataref. The values passed by + inValues are written into the dataref starting at inOffset. Up to inCount + values are written; however if the values would write "off the end" of the + dataref array, then fewer values are written. + + Note: the semantics of array datarefs are entirely implemented by the + plugin (or X-Plane) that provides the dataref, not the SDK itself; the + above description is how these datarefs are intended to work, but a rogue + plugin may have different behavior. + } + PROCEDURE XPLMSetDatavi( + inDataRef : XPLMDataRef; + inValues : PInteger; + inoffset : Integer; + inCount : Integer); + cdecl; external XPLM_DLL; + + { + XPLMGetDatavf + + Read a part of a single precision floating point array dataref. If you pass + NULL for outVaules, the routine will return the size of the array, ignoring + inOffset and inMax. + + If outValues is not NULL, then up to inMax values are copied from the + dataref into outValues, starting at inOffset in the dataref. If inMax + + inOffset is larger than the size of the dataref, less than inMax values + will be copied. The number of values copied is returned. + + Note: the semantics of array datarefs are entirely implemented by the + plugin (or X-Plane) that provides the dataref, not the SDK itself; the + above description is how these datarefs are intended to work, but a rogue + plugin may have different behavior. + } + FUNCTION XPLMGetDatavf( + inDataRef : XPLMDataRef; + outValues : PSingle; { Can be nil } + inOffset : Integer; + inMax : Integer) : Integer; + cdecl; external XPLM_DLL; + + { + XPLMSetDatavf + + Write part or all of a single precision floating point array dataref. The + values passed by inValues are written into the dataref starting at + inOffset. Up to inCount values are written; however if the values would + write "off the end" of the dataref array, then fewer values are written. + + Note: the semantics of array datarefs are entirely implemented by the + plugin (or X-Plane) that provides the dataref, not the SDK itself; the + above description is how these datarefs are intended to work, but a rogue + plugin may have different behavior. + } + PROCEDURE XPLMSetDatavf( + inDataRef : XPLMDataRef; + inValues : PSingle; + inoffset : Integer; + inCount : Integer); + cdecl; external XPLM_DLL; + + { + XPLMGetDatab + + Read a part of a byte array dataref. If you pass NULL for outVaules, the + routine will return the size of the array, ignoring inOffset and inMax. + + If outValues is not NULL, then up to inMax values are copied from the + dataref into outValues, starting at inOffset in the dataref. If inMax + + inOffset is larger than the size of the dataref, less than inMax values + will be copied. The number of values copied is returned. + + Note: the semantics of array datarefs are entirely implemented by the + plugin (or X-Plane) that provides the dataref, not the SDK itself; the + above description is how these datarefs are intended to work, but a rogue + plugin may have different behavior. + } + FUNCTION XPLMGetDatab( + inDataRef : XPLMDataRef; + outValue : pointer; { Can be nil } + inOffset : Integer; + inMaxBytes : Integer) : Integer; + cdecl; external XPLM_DLL; + + { + XPLMSetDatab + + Write part or all of a byte array dataref. The values passed by inValues + are written into the dataref starting at inOffset. Up to inCount values are + written; however if the values would write "off the end" of the dataref + array, then fewer values are written. + + Note: the semantics of array datarefs are entirely implemented by the + plugin (or X-Plane) that provides the dataref, not the SDK itself; the + above description is how these datarefs are intended to work, but a rogue + plugin may have different behavior. + } + PROCEDURE XPLMSetDatab( + inDataRef : XPLMDataRef; + inValue : pointer; + inOffset : Integer; + inLength : Integer); + cdecl; external XPLM_DLL; + +{___________________________________________________________________________ + * PUBLISHING YOUR PLUGIN'S DATA + ___________________________________________________________________________} +{ + These functions allow you to create data references that other plug-ins and + X-Plane can access via the above data access APIs. Data references + published by other plugins operate the same as ones published by X-Plane in + all manners except that your data reference will not be available to other + plugins if/when your plugin is disabled. + + You share data by registering data provider callback functions. When a + plug-in requests your data, these callbacks are then called. You provide + one callback to return the value when a plugin 'reads' it and another to + change the value when a plugin 'writes' it. + + Important: you must pick a prefix for your datarefs other than "sim/" - + this prefix is reserved for X-Plane. The X-Plane SDK website contains a + registry where authors can select a unique first word for dataref names, to + prevent dataref collisions between plugins. +} + + + { + XPLMGetDatai_f + + Data provider function pointers. + + These define the function pointers you provide to get or set data. Note + that you are passed a generic pointer for each one. This is the same + pointer you pass in your register routine; you can use it to locate plugin + variables, etc. + + The semantics of your callbacks are the same as the dataref accessor above + - basically routines like XPLMGetDatai are just pass-throughs from a caller + to your plugin. Be particularly mindful in implementing array dataref + read-write accessors; you are responsible for avoiding overruns, supporting + offset read/writes, and handling a read with a NULL buffer. + } +TYPE + XPLMGetDatai_f = FUNCTION( + inRefcon : pointer) : Integer; cdecl; + + { + XPLMSetDatai_f + } + XPLMSetDatai_f = PROCEDURE( + inRefcon : pointer; + inValue : Integer); cdecl; + + { + XPLMGetDataf_f + } + XPLMGetDataf_f = FUNCTION( + inRefcon : pointer) : Single; cdecl; + + { + XPLMSetDataf_f + } + XPLMSetDataf_f = PROCEDURE( + inRefcon : pointer; + inValue : Single); cdecl; + + { + XPLMGetDatad_f + } + XPLMGetDatad_f = FUNCTION( + inRefcon : pointer) : Real; cdecl; + + { + XPLMSetDatad_f + } + XPLMSetDatad_f = PROCEDURE( + inRefcon : pointer; + inValue : Real); cdecl; + + { + XPLMGetDatavi_f + } + XPLMGetDatavi_f = FUNCTION( + inRefcon : pointer; + outValues : PInteger; { Can be nil } + inOffset : Integer; + inMax : Integer) : Integer; cdecl; + + { + XPLMSetDatavi_f + } + XPLMSetDatavi_f = PROCEDURE( + inRefcon : pointer; + inValues : PInteger; + inOffset : Integer; + inCount : Integer); cdecl; + + { + XPLMGetDatavf_f + } + XPLMGetDatavf_f = FUNCTION( + inRefcon : pointer; + outValues : PSingle; { Can be nil } + inOffset : Integer; + inMax : Integer) : Integer; cdecl; + + { + XPLMSetDatavf_f + } + XPLMSetDatavf_f = PROCEDURE( + inRefcon : pointer; + inValues : PSingle; + inOffset : Integer; + inCount : Integer); cdecl; + + { + XPLMGetDatab_f + } + XPLMGetDatab_f = FUNCTION( + inRefcon : pointer; + outValue : pointer; { Can be nil } + inOffset : Integer; + inMaxLength : Integer) : Integer; cdecl; + + { + XPLMSetDatab_f + } + XPLMSetDatab_f = PROCEDURE( + inRefcon : pointer; + inValue : pointer; + inOffset : Integer; + inLength : Integer); cdecl; + + { + XPLMRegisterDataAccessor + + This routine creates a new item of data that can be read and written. Pass + in the data's full name for searching, the type(s) of the data for + accessing, and whether the data can be written to. For each data type you + support, pass in a read accessor function and a write accessor function if + necessary. Pass NULL for data types you do not support or write accessors + if you are read-only. + + You are returned a data ref for the new item of data created. You can use + this data ref to unregister your data later or read or write from it. + } + FUNCTION XPLMRegisterDataAccessor( + inDataName : XPLMString; + inDataType : XPLMDataTypeID; + inIsWritable : Integer; + inReadInt : XPLMGetDatai_f; + inWriteInt : XPLMSetDatai_f; + inReadFloat : XPLMGetDataf_f; + inWriteFloat : XPLMSetDataf_f; + inReadDouble : XPLMGetDatad_f; + inWriteDouble : XPLMSetDatad_f; + inReadIntArray : XPLMGetDatavi_f; + inWriteIntArray : XPLMSetDatavi_f; + inReadFloatArray : XPLMGetDatavf_f; + inWriteFloatArray : XPLMSetDatavf_f; + inReadData : XPLMGetDatab_f; + inWriteData : XPLMSetDatab_f; + inReadRefcon : pointer; + inWriteRefcon : pointer) : XPLMDataRef; + cdecl; external XPLM_DLL; + + { + XPLMUnregisterDataAccessor + + Use this routine to unregister any data accessors you may have registered. + You unregister a data ref by the XPLMDataRef you get back from + registration. Once you unregister a data ref, your function pointer will + not be called anymore. + } + PROCEDURE XPLMUnregisterDataAccessor( + inDataRef : XPLMDataRef); + cdecl; external XPLM_DLL; + +{___________________________________________________________________________ + * SHARING DATA BETWEEN MULTIPLE PLUGINS + ___________________________________________________________________________} +{ + The data reference registration APIs from the previous section allow a + plugin to publish data in a one-owner manner; the plugin that publishes the + data reference owns the real memory that the data ref uses. This is + satisfactory for most cases, but there are also cases where plugnis need to + share actual data. + + With a shared data reference, no one plugin owns the actual memory for the + data reference; the plugin SDK allocates that for you. When the first + plugin asks to 'share' the data, the memory is allocated. When the data is + changed, every plugin that is sharing the data is notified. + + Shared data references differ from the 'owned' data references from the + previous section in a few ways: + + * With shared data references, any plugin can create the data reference; + with owned plugins one plugin must create the data reference and others + subscribe. (This can be a problem if you don't know which set of plugins + will be present). + + * With shared data references, every plugin that is sharing the data is + notified when the data is changed. With owned data references, only the + one owner is notified when the data is changed. + + * With shared data references, you cannot access the physical memory of the + data reference; you must use the XPLMGet... and XPLMSet... APIs. With an + owned data reference, the one owning data reference can manipulate the + data reference's memory in any way it sees fit. + + Shared data references solve two problems: if you need to have a data + reference used by several plugins but do not know which plugins will be + installed, or if all plugins sharing data need to be notified when that + data is changed, use shared data references. +} + + + { + XPLMDataChanged_f + + An XPLMDataChanged_f is a callback that the XPLM calls whenever any other + plug-in modifies shared data. A refcon you provide is passed back to help + identify which data is being changed. In response, you may want to call one + of the XPLMGetDataxxx routines to find the new value of the data. + } +TYPE + XPLMDataChanged_f = PROCEDURE( + inRefcon : pointer); cdecl; + + { + XPLMShareData + + This routine connects a plug-in to shared data, creating the shared data if + necessary. inDataName is a standard path for the data ref, and inDataType + specifies the type. This function will create the data if it does not + exist. If the data already exists but the type does not match, an error is + returned, so it is important that plug-in authors collaborate to establish + public standards for shared data. + + If a notificationFunc is passed in and is not NULL, that notification + function will be called whenever the data is modified. The notification + refcon will be passed to it. This allows your plug-in to know which shared + data was changed if multiple shared data are handled by one callback, or if + the plug-in does not use global variables. + + A one is returned for successfully creating or finding the shared data; a + zero if the data already exists but is of the wrong type. + } + FUNCTION XPLMShareData( + inDataName : XPLMString; + inDataType : XPLMDataTypeID; + inNotificationFunc : XPLMDataChanged_f; + inNotificationRefcon: pointer) : Integer; + cdecl; external XPLM_DLL; + + { + XPLMUnshareData + + This routine removes your notification function for shared data. Call it + when done with the data to stop receiving change notifications. Arguments + must match XPLMShareData. The actual memory will not necessarily be freed, + since other plug-ins could be using it. + } + FUNCTION XPLMUnshareData( + inDataName : XPLMString; + inDataType : XPLMDataTypeID; + inNotificationFunc : XPLMDataChanged_f; + inNotificationRefcon: pointer) : Integer; + cdecl; external XPLM_DLL; + + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/SDK/Delphi/XPLM/XPLMDefs.pas b/XPLPro_Plugin_Source/SDK/SDK/Delphi/XPLM/XPLMDefs.pas new file mode 100644 index 0000000..b614085 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDK/Delphi/XPLM/XPLMDefs.pas @@ -0,0 +1,438 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPLMDefs; +INTERFACE +{ + This file is contains the cross-platform and basic definitions for the + X-Plane SDK. + + The preprocessor macros APL and IBM must be defined to specify the + compilation target; define APL to 1 and IBM 0 to compile on Macintosh and + APL to 0 and IBM to 1 for Windows. You must specify these macro definitions + before including XPLMDefs.h or any other XPLM headers. You can do this + using the -D command line option or a preprocessor header. +} + + {$A4} +{$IFDEF LINUX} + {$DEFINE KYLIX} +{$ENDIF} +TYPE +{$IFNDEF DELPHI} +{$IFNDEF KYLIX} + Pchar = ^char; + Ppchar = ^Pchar; + Psingle = ^single; + Pinteger = ^integer; +{$ENDIF} +{$ENDIF} + Preal = ^real; + Plongint = ^longint; +{___________________________________________________________________________ + * DLL Definitions + ___________________________________________________________________________} +{ + These definitions control the importing and exporting of functions within + the DLL. + + You can prefix your five required callbacks with the PLUGIN_API macro to + declare them as exported C functions. The XPLM_API macro identifies + functions that are provided to you via the plugin SDK. (Link against + XPLM.lib to use these functions.) +} + + + +{___________________________________________________________________________ + * GLOBAL DEFINITIONS + ___________________________________________________________________________} +{ + These definitions are used in all parts of the SDK. +} + + +TYPE + { + XPLMPluginID + + Each plug-in is identified by a unique integer ID. This ID can be used to + disable or enable a plug-in, or discover what plug-in is 'running' at the + time. A plug-in ID is unique within the currently running instance of + X-Plane unless plug-ins are reloaded. Plug-ins may receive a different + unique ID each time they are loaded. This includes the unloading and + reloading of plugins that are part of the user's aircraft. + + For persistent identification of plug-ins, use XPLMFindPluginBySignature in + XPLMUtiltiies.h + + -1 indicates no plug-in. + } + XPLMPluginID = Integer; + PXPLMPluginID = ^XPLMPluginID; + +CONST + { No plugin. } + XPLM_NO_PLUGIN_ID = (-1); + + { X-Plane itself } + XPLM_PLUGIN_XPLANE = (0); + + { The current XPLM revision is 4.00 (400). } + kXPLM_Version = (400); + + { + XPLMKeyFlags + + These bitfields define modifier keys in a platform independent way. When a + key is pressed, a series of messages are sent to your plugin. The down + flag is set in the first of these messages, and the up flag in the last. + While the key is held down, messages are sent with neither to indicate that + the key is being held down as a repeated character. + + The control flag is mapped to the control flag on Macintosh and PC. + Generally X-Plane uses the control key and not the command key on + Macintosh, providing a consistent interface across platforms that does not + necessarily match the Macintosh user interface guidelines. There is not + yet a way for plugins to access the Macintosh control keys without using + #ifdefed code. + } +TYPE + XPLMKeyFlags = ( + { The shift key is down } + xplm_ShiftFlag = 1 + + { The option or alt key is down } + ,xplm_OptionAltFlag = 2 + + { The control key is down* } + ,xplm_ControlFlag = 4 + + { The key is being pressed down } + ,xplm_DownFlag = 8 + + { The key is being released } + ,xplm_UpFlag = 16 + + ); + PXPLMKeyFlags = ^XPLMKeyFlags; + +{___________________________________________________________________________ + * ASCII CONTROL KEY CODES + ___________________________________________________________________________} +{ + These definitions define how various control keys are mapped to ASCII key + codes. Not all key presses generate an ASCII value, so plugin code should + be prepared to see null characters come from the keyboard...this usually + represents a key stroke that has no equivalent ASCII, like a page-down + press. Use virtual key codes to find these key strokes. + + ASCII key codes take into account modifier keys; shift keys will affect + capitals and punctuation; control key combinations may have no vaild ASCII + and produce NULL. To detect control-key combinations, use virtual key + codes, not ASCII keys. +} + + +CONST + XPLM_KEY_RETURN = 13; + + XPLM_KEY_ESCAPE = 27; + + XPLM_KEY_TAB = 9; + + XPLM_KEY_DELETE = 8; + + XPLM_KEY_LEFT = 28; + + XPLM_KEY_RIGHT = 29; + + XPLM_KEY_UP = 30; + + XPLM_KEY_DOWN = 31; + + XPLM_KEY_0 = 48; + + XPLM_KEY_1 = 49; + + XPLM_KEY_2 = 50; + + XPLM_KEY_3 = 51; + + XPLM_KEY_4 = 52; + + XPLM_KEY_5 = 53; + + XPLM_KEY_6 = 54; + + XPLM_KEY_7 = 55; + + XPLM_KEY_8 = 56; + + XPLM_KEY_9 = 57; + + XPLM_KEY_DECIMAL = 46; + +{___________________________________________________________________________ + * VIRTUAL KEY CODES + ___________________________________________________________________________} +{ + These are cross-platform defines for every distinct keyboard press on the + computer. Every physical key on the keyboard has a virtual key code. So + the "two" key on the top row of the main keyboard has a different code from + the "two" key on the numeric key pad. But the 'w' and 'W' character are + indistinguishable by virtual key code because they are the same physical + key (one with and one without the shift key). + + Use virtual key codes to detect keystrokes that do not have ASCII + equivalents, allow the user to map the numeric keypad separately from the + main keyboard, and detect control key and other modifier-key combinations + that generate ASCII control key sequences (many of which are not available + directly via character keys in the SDK). + + To assign virtual key codes we started with the Microsoft set but made some + additions and changes. A few differences: + + 1. Modifier keys are not available as virtual key codes. You cannot get + distinct modifier press and release messages. Please do not try to use + modifier keys as regular keys; doing so will almost certainly interfere + with users' abilities to use the native X-Plane key bindings. + 2. Some keys that do not exist on both Mac and PC keyboards are removed. + 3. Do not assume that the values of these keystrokes are interchangeable + with MS v-keys. +} + + +CONST + XPLM_VK_BACK = $08; + + XPLM_VK_TAB = $09; + + XPLM_VK_CLEAR = $0C; + + XPLM_VK_RETURN = $0D; + + XPLM_VK_ESCAPE = $1B; + + XPLM_VK_SPACE = $20; + + XPLM_VK_PRIOR = $21; + + XPLM_VK_NEXT = $22; + + XPLM_VK_END = $23; + + XPLM_VK_HOME = $24; + + XPLM_VK_LEFT = $25; + + XPLM_VK_UP = $26; + + XPLM_VK_RIGHT = $27; + + XPLM_VK_DOWN = $28; + + XPLM_VK_SELECT = $29; + + XPLM_VK_PRINT = $2A; + + XPLM_VK_EXECUTE = $2B; + + XPLM_VK_SNAPSHOT = $2C; + + XPLM_VK_INSERT = $2D; + + XPLM_VK_DELETE = $2E; + + XPLM_VK_HELP = $2F; + + { XPLM_VK_0 thru XPLM_VK_9 are the same as ASCII '0' thru '9' (0x30 - 0x39) } + XPLM_VK_0 = $30; + + XPLM_VK_1 = $31; + + XPLM_VK_2 = $32; + + XPLM_VK_3 = $33; + + XPLM_VK_4 = $34; + + XPLM_VK_5 = $35; + + XPLM_VK_6 = $36; + + XPLM_VK_7 = $37; + + XPLM_VK_8 = $38; + + XPLM_VK_9 = $39; + + { XPLM_VK_A thru XPLM_VK_Z are the same as ASCII 'A' thru 'Z' (0x41 - 0x5A) } + XPLM_VK_A = $41; + + XPLM_VK_B = $42; + + XPLM_VK_C = $43; + + XPLM_VK_D = $44; + + XPLM_VK_E = $45; + + XPLM_VK_F = $46; + + XPLM_VK_G = $47; + + XPLM_VK_H = $48; + + XPLM_VK_I = $49; + + XPLM_VK_J = $4A; + + XPLM_VK_K = $4B; + + XPLM_VK_L = $4C; + + XPLM_VK_M = $4D; + + XPLM_VK_N = $4E; + + XPLM_VK_O = $4F; + + XPLM_VK_P = $50; + + XPLM_VK_Q = $51; + + XPLM_VK_R = $52; + + XPLM_VK_S = $53; + + XPLM_VK_T = $54; + + XPLM_VK_U = $55; + + XPLM_VK_V = $56; + + XPLM_VK_W = $57; + + XPLM_VK_X = $58; + + XPLM_VK_Y = $59; + + XPLM_VK_Z = $5A; + + XPLM_VK_NUMPAD0 = $60; + + XPLM_VK_NUMPAD1 = $61; + + XPLM_VK_NUMPAD2 = $62; + + XPLM_VK_NUMPAD3 = $63; + + XPLM_VK_NUMPAD4 = $64; + + XPLM_VK_NUMPAD5 = $65; + + XPLM_VK_NUMPAD6 = $66; + + XPLM_VK_NUMPAD7 = $67; + + XPLM_VK_NUMPAD8 = $68; + + XPLM_VK_NUMPAD9 = $69; + + XPLM_VK_MULTIPLY = $6A; + + XPLM_VK_ADD = $6B; + + XPLM_VK_SEPARATOR = $6C; + + XPLM_VK_SUBTRACT = $6D; + + XPLM_VK_DECIMAL = $6E; + + XPLM_VK_DIVIDE = $6F; + + XPLM_VK_F1 = $70; + + XPLM_VK_F2 = $71; + + XPLM_VK_F3 = $72; + + XPLM_VK_F4 = $73; + + XPLM_VK_F5 = $74; + + XPLM_VK_F6 = $75; + + XPLM_VK_F7 = $76; + + XPLM_VK_F8 = $77; + + XPLM_VK_F9 = $78; + + XPLM_VK_F10 = $79; + + XPLM_VK_F11 = $7A; + + XPLM_VK_F12 = $7B; + + XPLM_VK_F13 = $7C; + + XPLM_VK_F14 = $7D; + + XPLM_VK_F15 = $7E; + + XPLM_VK_F16 = $7F; + + XPLM_VK_F17 = $80; + + XPLM_VK_F18 = $81; + + XPLM_VK_F19 = $82; + + XPLM_VK_F20 = $83; + + XPLM_VK_F21 = $84; + + XPLM_VK_F22 = $85; + + XPLM_VK_F23 = $86; + + XPLM_VK_F24 = $87; + + { The following definitions are extended and are not based on the Microsoft } + { key set. } + XPLM_VK_EQUAL = $B0; + + XPLM_VK_MINUS = $B1; + + XPLM_VK_RBRACE = $B2; + + XPLM_VK_LBRACE = $B3; + + XPLM_VK_QUOTE = $B4; + + XPLM_VK_SEMICOLON = $B5; + + XPLM_VK_BACKSLASH = $B6; + + XPLM_VK_COMMA = $B7; + + XPLM_VK_SLASH = $B8; + + XPLM_VK_PERIOD = $B9; + + XPLM_VK_BACKQUOTE = $BA; + + XPLM_VK_ENTER = $BB; + + XPLM_VK_NUMPAD_ENT = $BC; + + XPLM_VK_NUMPAD_EQ = $BD; + + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/SDK/Delphi/XPLM/XPLMDisplay.pas b/XPLPro_Plugin_Source/SDK/SDK/Delphi/XPLM/XPLMDisplay.pas new file mode 100644 index 0000000..ee4242c --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDK/Delphi/XPLM/XPLMDisplay.pas @@ -0,0 +1,1630 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPLMDisplay; +INTERFACE +{ + This API provides the basic hooks to draw in X-Plane and create user + interface. All X-Plane drawing is done in OpenGL. The X-Plane plug-in + manager takes care of properly setting up the OpenGL context and matrices. + You do not decide when in your code's execution to draw; X-Plane tells you + (via callbacks) when it is ready to have your plugin draw. + + X-Plane's drawing strategy is straightforward: every "frame" the screen is + rendered by drawing the 3-D scene (dome, ground, objects, airplanes, etc.) + and then drawing the cockpit on top of it. Alpha blending is used to + overlay the cockpit over the world (and the gauges over the panel, etc.). + X-Plane user interface elements (including windows like the map, the main + menu, etc.) are then drawn on top of the cockpit. + + There are two ways you can draw: directly and in a window. + + Direct drawing (deprecated!---more on that below) involves drawing to the + screen before or after X-Plane finishes a phase of drawing. When you draw + directly, you can specify whether X-Plane is to complete this phase or not. + This allows you to do three things: draw before X-Plane does (under it), + draw after X-Plane does (over it), or draw instead of X-Plane. + + To draw directly, you register a callback and specify which phase you want + to intercept. The plug-in manager will call you over and over to draw that + phase. + + Direct drawing allows you to override scenery, panels, or anything. Note + that you cannot assume that you are the only plug-in drawing at this phase. + + Direct drawing is deprecated; at some point in the X-Plane 11 run, it will + likely become unsupported entirely as X-Plane transitions from OpenGL to + modern graphics API backends (e.g., Vulkan, Metal, etc.). In the long term, + plugins should use the XPLMInstance API for drawing 3-D objects---this will + be much more efficient than general 3-D OpenGL drawing, and it will + actually be supported by the new graphics backends. We do not yet know what + the post-transition API for generic 3-D drawing will look like (if it + exists at all). + + In contrast to direct drawing, window drawing provides a higher level + functionality. With window drawing, you create a 2-D window that takes up a + portion of the screen. Window drawing is always two dimensional. Window + drawing is front-to-back controlled; you can specify that you want your + window to be brought on top, and other plug-ins may put their window on top + of you. Window drawing also allows you to sign up for key presses and + receive mouse clicks. + + Drawing into the screen of an avionics device, like a GPS or a Primary + Flight Display, is a way to extend or replace X-Plane's avionics. Most + screens can be displayed both in a 3d cockpit or + 2d panel, and also in separate popup windows. By installing drawing + callbacks for a certain avionics device, you can change or extend the + appearance of that device regardless whether it's installed in a 3d + cockpit or used in a separate display for home cockpits because you leave + the window managing to X-Plane. + + There are three ways to get keystrokes: + + 1. If you create a window, the window can take keyboard focus. It will + then receive all keystrokes. If no window has focus, X-Plane receives + keystrokes. Use this to implement typing in dialog boxes, etc. Only + one window may have focus at a time; your window will be notified if it + loses focus. + 2. If you need low level access to the keystroke stream, install a key + sniffer. Key sniffers can be installed above everything or right in + front of the sim. + 3. If you would like to associate key strokes with commands/functions in + your plug-in, you should simply register a command (via + XPLMCreateCommand()) and allow users to bind whatever key they choose to + that command. Another (now deprecated) method of doing so is to use a + hot key---a key-specific callback. Hotkeys are sent based on virtual + key strokes, so any key may be distinctly mapped with any modifiers. + Hot keys can be remapped by other plug-ins. As a plug-in, you don't + have to worry about what your hot key ends up mapped to; other plug-ins + may provide a UI for remapping keystrokes. So hotkeys allow a user to + resolve conflicts and customize keystrokes. +} + +USES + XPLMDefs; + {$A4} +{___________________________________________________________________________ + * DRAWING CALLBACKS + ___________________________________________________________________________} +{ + Basic drawing callbacks, for low level intercepting of X-Plane's render + loop. The purpose of drawing callbacks is to provide targeted additions or + replacements to X-Plane's graphics environment (for example, to add extra + custom objects, or replace drawing of the AI aircraft). Do not assume that + the drawing callbacks will be called in the order implied by the + enumerations. Also do not assume that each drawing phase ends before + another begins; they may be nested. + + Note that all APIs in this section are deprecated, and will likely be + removed during the X-Plane 11 run as part of the transition to + Vulkan/Metal/etc. See the XPLMInstance API for future-proof drawing of 3-D + objects. +} + + + { + XPLMDrawingPhase + + This constant indicates which part of drawing we are in. Drawing is done + from the back to the front. We get a callback before or after each item. + Metaphases provide access to the beginning and end of the 3d (scene) and + 2d (cockpit) drawing in a manner that is independent of new phases added + via X-Plane implementation. + + **NOTE**: As of XPLM302 the legacy 3D drawing phases (xplm_Phase_FirstScene + to xplm_Phase_LastScene) are deprecated. When running under X-Plane 11.50 + with the modern Vulkan or Metal backend, X-Plane will no longer call + these drawing phases. There is a new drawing phase, xplm_Phase_Modern3D, + which is supported under OpenGL and Vulkan which is called out roughly + where the old before xplm_Phase_Airplanes phase was for blending. This + phase is *NOT* supported under Metal and comes with potentially + substantial performance overhead. Please do *NOT* opt into this phase if + you don't do any actual drawing that requires the depth buffer in some + way! + + **WARNING**: As X-Plane's scenery evolves, some drawing phases may cease to + exist and new ones may be invented. If you need a particularly specific + use of these codes, consult Austin and/or be prepared to revise your code + as X-Plane evolves. + } +TYPE + XPLMDrawingPhase = ( +{$IFDEF XPLM_DEPRECATED} + { Deprecated as of XPLM302. This is the earliest point at which you can draw } + { in 3-d. } + xplm_Phase_FirstScene = 0 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated as of XPLM302. Drawing of land and water. } + ,xplm_Phase_Terrain = 5 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated as of XPLM302. Drawing runways and other airport detail. } + ,xplm_Phase_Airports = 10 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated as of XPLM302. Drawing roads, trails, trains, etc. } + ,xplm_Phase_Vectors = 15 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated as of XPLM302. 3-d objects (houses, smokestacks, etc. } + ,xplm_Phase_Objects = 20 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated as of XPLM302. External views of airplanes, both yours and the } + { AI aircraft. } + ,xplm_Phase_Airplanes = 25 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated as of XPLM302. This is the last point at which you can draw in } + { 3-d. } + ,xplm_Phase_LastScene = 30 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM302} + { A chance to do modern 3D drawing. } + ,xplm_Phase_Modern3D = 31 +{$ENDIF XPLM302} + + { This is the first phase where you can draw in 2-d. } + ,xplm_Phase_FirstCockpit = 35 + + { The non-moving parts of the aircraft panel. } + ,xplm_Phase_Panel = 40 + + { The moving parts of the aircraft panel. } + ,xplm_Phase_Gauges = 45 + + { Floating windows from plugins. } + ,xplm_Phase_Window = 50 + + { The last chance to draw in 2d. } + ,xplm_Phase_LastCockpit = 55 + +{$IFDEF XPLM200} + { Removed as of XPLM300; Use the full-blown XPLMMap API instead. } + ,xplm_Phase_LocalMap3D = 100 +{$ENDIF XPLM200} + +{$IFDEF XPLM200} + { Removed as of XPLM300; Use the full-blown XPLMMap API instead. } + ,xplm_Phase_LocalMap2D = 101 +{$ENDIF XPLM200} + +{$IFDEF XPLM200} + { Removed as of XPLM300; Use the full-blown XPLMMap API instead. } + ,xplm_Phase_LocalMapProfile = 102 +{$ENDIF XPLM200} + + ); + PXPLMDrawingPhase = ^XPLMDrawingPhase; + + { + XPLMDrawCallback_f + + This is the prototype for a low level drawing callback. You are passed in + the phase and whether it is before or after. If you are before the phase, + return 1 to let X-Plane draw or 0 to suppress X-Plane drawing. If you are + after the phase the return value is ignored. + + Refcon is a unique value that you specify when registering the callback, + allowing you to slip a pointer to your own data to the callback. + + Upon entry the OpenGL context will be correctly set up for you and OpenGL + will be in 'local' coordinates for 3d drawing and panel coordinates for 2d + drawing. The OpenGL state (texturing, etc.) will be unknown. + } + XPLMDrawCallback_f = FUNCTION( + inPhase : XPLMDrawingPhase; + inIsBefore : Integer; + inRefcon : pointer) : Integer; cdecl; + + { + XPLMRegisterDrawCallback + + This routine registers a low level drawing callback. Pass in the phase you + want to be called for and whether you want to be called before or after. + This routine returns 1 if the registration was successful, or 0 if the + phase does not exist in this version of X-Plane. You may register a + callback multiple times for the same or different phases as long as the + refcon is unique each time. + + Note that this function will likely be removed during the X-Plane 11 run as + part of the transition to Vulkan/Metal/etc. See the XPLMInstance API for + future-proof drawing of 3-D objects. + } + FUNCTION XPLMRegisterDrawCallback( + inCallback : XPLMDrawCallback_f; + inPhase : XPLMDrawingPhase; + inWantsBefore : Integer; + inRefcon : pointer) : Integer; + cdecl; external XPLM_DLL; + + { + XPLMUnregisterDrawCallback + + This routine unregisters a draw callback. You must unregister a callback + for each time you register a callback if you have registered it multiple + times with different refcons. The routine returns 1 if it can find the + callback to unregister, 0 otherwise. + + Note that this function will likely be removed during the X-Plane 11 run as + part of the transition to Vulkan/Metal/etc. See the XPLMInstance API for + future-proof drawing of 3-D objects. + } + FUNCTION XPLMUnregisterDrawCallback( + inCallback : XPLMDrawCallback_f; + inPhase : XPLMDrawingPhase; + inWantsBefore : Integer; + inRefcon : pointer) : Integer; + cdecl; external XPLM_DLL; + +{$IFDEF XPLM400} +{___________________________________________________________________________ + * AVIONICS API + ___________________________________________________________________________} +{ + Drawing callbacks for before and after X-Plane draws the instrument screen + can be registered for every cockpit device. If the user plane does not + have the device installed, your callback will not be called! Use the + return value to enable or disable X-Plane's drawing. By drawing into the + framebuffer of the avionics device, your modifications will be visible + regardless whether the device's screen is in a 3d cockpit or a popup + window. +} + + + { + XPLMDeviceID + + This constant indicates the device we want to override or enhance. We can + get a callback before or after each item. + } +TYPE + XPLMDeviceID = ( + { GNS430, pilot side. } + xplm_device_GNS430_1 = 0 + + { GNS430, copilot side. } + ,xplm_device_GNS430_2 = 1 + + { GNS530, pilot side. } + ,xplm_device_GNS530_1 = 2 + + { GNS530, copilot side. } + ,xplm_device_GNS530_2 = 3 + + { generic airliner CDU, pilot side. } + ,xplm_device_CDU739_1 = 4 + + { generic airliner CDU, copilot side. } + ,xplm_device_CDU739_2 = 5 + + { G1000 Primary Flight Display, pilot side. } + ,xplm_device_G1000_PFD_1 = 6 + + { G1000 Multifunction Display. } + ,xplm_device_G1000_MFD = 7 + + { G1000 Primary Flight Display, copilot side. } + ,xplm_device_G1000_PFD_2 = 8 + + { Primus CDU, pilot side. } + ,xplm_device_CDU815_1 = 9 + + { Primus CDU, copilot side. } + ,xplm_device_CDU815_2 = 10 + + { Primus Primary Flight Display, pilot side. } + ,xplm_device_Primus_PFD_1 = 11 + + { Primus Primary Flight Display, copilot side. } + ,xplm_device_Primus_PFD_2 = 12 + + { Primus Multifunction Display, pilot side. } + ,xplm_device_Primus_MFD_1 = 13 + + { Primus Multifunction Display, copilot side. } + ,xplm_device_Primus_MFD_2 = 14 + + { Primus Multifunction Display, central. } + ,xplm_device_Primus_MFD_3 = 15 + + { Primus Radio Management Unit, pilot side. } + ,xplm_device_Primus_RMU_1 = 16 + + { Primus Radio Management Unit, copilot side. } + ,xplm_device_Primus_RMU_2 = 17 + + ); + PXPLMDeviceID = ^XPLMDeviceID; + + { + XPLMAvionicsCallback_f + + This is the prototype for your drawing callback. You are passed in the + device you are enhancing/replacing, and whether it is before or after + X-Plane drawing. If you are before X-Plane, return 1 to let X-Plane draw or + 0 to suppress X-Plane drawing. If you are after the phase the return value + is ignored. + + Refcon is a unique value that you specify when registering the callback, + allowing you to slip a pointer to your own data to the callback. + + Upon entry the OpenGL context will be correctly set up for you and OpenGL + will be in panel coordinates for 2d drawing. The OpenGL state (texturing, + etc.) will be unknown. + } + XPLMAvionicsCallback_f = FUNCTION( + inDeviceID : XPLMDeviceID; + inIsBefore : Integer; + inRefcon : pointer) : Integer; cdecl; + + { + XPLMAvionicsID + + This is an opaque identifier for an avionics display that you enhance or + replace. When you register your callbacks (via + XPLMRegisterAvionicsCallbacksEx()), you will specify callbacks to handle + drawing, and get back such a handle. + } + XPLMAvionicsID = pointer; + PXPLMAvionicsID = ^XPLMAvionicsID; + + { + XPLMCustomizeAvionics_t + + The XPLMCustomizeAvionics_t structure defines all of the parameters used to + replace or enhance avionics for using XPLMRegisterAvionicsCallbacksEx(). + The structure will be expanded in future SDK APIs to include more features. + Always set the structSize member to the size of your struct in bytes! + } + XPLMCustomizeAvionics_t = RECORD + { Used to inform XPLMRegisterAvionicsCallbacksEx() of the SDK version you } + { compiled against; should always be set to sizeof(XPLMCustomizeAvionics_t) } + structSize : Integer; + { Which avionics device you want your drawing applied to. } + deviceId : XPLMDeviceID; + { The draw callback to be called before X-Plane draws. } + drawCallbackBefore : XPLMAvionicsCallback_f; + { The draw callback to be called after X-Plane has drawn. } + drawCallbackAfter : XPLMAvionicsCallback_f; + { A reference which will be passed into each of your draw callbacks. Use this} + { to pass information to yourself as needed. } + refcon : pointer; + END; + PXPLMCustomizeAvionics_t = ^XPLMCustomizeAvionics_t; + + { + XPLMRegisterAvionicsCallbacksEx + + This routine registers your callbacks for a device. This returns a handle. + If the returned handle is NULL, there was a problem interpreting your + input, most likely the struct size was wrong for your SDK version. If the + returned handle is not NULL, your callbacks will be called according to + schedule as long as your plugin is not deactivated, or unloaded, or your + call XPLMUnregisterAvionicsCallbacks(). + } + FUNCTION XPLMRegisterAvionicsCallbacksEx( + inParams : PXPLMCustomizeAvionics_t) : XPLMAvionicsID; + cdecl; external XPLM_DLL; + + { + XPLMUnregisterAvionicsCallbacks + + This routine unregisters your callbacks for a device. They will no longer + be called. + } + PROCEDURE XPLMUnregisterAvionicsCallbacks( + inAvionicsId : XPLMAvionicsID); + cdecl; external XPLM_DLL; + +{$ENDIF XPLM400} +{___________________________________________________________________________ + * WINDOW API + ___________________________________________________________________________} +{ + The window API provides a high-level abstraction for drawing with UI + interaction. + + Windows may operate in one of two modes: legacy (for plugins compiled + against old versions of the XPLM, as well as windows created via the + deprecated XPLMCreateWindow() function, rather than XPLMCreateWindowEx()), + or modern (for windows compiled against the XPLM300 or newer API, and + created via XPLMCreateWindowEx()). + + Modern windows have access to new X-Plane 11 windowing features, like + support for new positioning modes (including being "popped out" into their + own first-class window in the operating system). They can also optionally + be decorated in the style of X-Plane 11 windows (like the map). + + Modern windows operate in "boxel" units. A boxel ("box of pixels") is a + unit of virtual pixels which, depending on X-Plane's scaling, may + correspond to an arbitrary NxN "box" of real pixels on screen. Because + X-Plane handles this scaling automatically, you can effectively treat the + units as though you were simply drawing in pixels, and know that when + X-Plane is running with 150% or 200% scaling, your drawing will be + automatically scaled (and likewise all mouse coordinates, screen bounds, + etc. will also be auto-scaled). + + In contrast, legacy windows draw in true screen pixels, and thus tend to + look quite small when X-Plane is operating in a scaled mode. + + Legacy windows have their origin in the lower left of the main X-Plane + window. In contrast, since modern windows are not constrained to the main + window, they have their origin in the lower left of the entire global + desktop space, and the lower left of the main X-Plane window is not + guaranteed to be (0, 0). In both cases, x increases as you move left, and y + increases as you move up. +} + + +TYPE + { + XPLMWindowID + + This is an opaque identifier for a window. You use it to control your + window. When you create a window (via either XPLMCreateWindow() or + XPLMCreateWindowEx()), you will specify callbacks to handle drawing, mouse + interaction, etc. + } + XPLMWindowID = pointer; + PXPLMWindowID = ^XPLMWindowID; + + { + XPLMDrawWindow_f + + A callback to handle 2-D drawing of your window. You are passed in your + window and its refcon. Draw the window. You can use other XPLM functions + from this header to find the current dimensions of your window, etc. When + this callback is called, the OpenGL context will be set properly for 2-D + window drawing. + + **Note**: Because you are drawing your window over a background, you can + make a translucent window easily by simply not filling in your entire + window's bounds. + } + XPLMDrawWindow_f = PROCEDURE( + inWindowID : XPLMWindowID; + inRefcon : pointer); cdecl; + + { + XPLMHandleKey_f + + This function is called when a key is pressed or keyboard focus is taken + away from your window. If losingFocus is 1, you are losing the keyboard + focus, otherwise a key was pressed and inKey contains its character. + + The window ID passed in will be your window for key presses, or the other + window taking focus when losing focus. Note that in the modern plugin + system, often focus is taken by the window manager itself; for this resaon, + the window ID may be zero when losing focus, and you should not write code + that depends onit. + + The refcon passed in will be the one from registration, for both key + presses and losing focus. + + Warning: this API declares virtual keys as a signed character; however the + VKEY #define macros in XPLMDefs.h define the vkeys using unsigned values + (that is 0x80 instead of -0x80). So you may need to cast the incoming vkey + to an unsigned char to get correct comparisons in C. + } + XPLMHandleKey_f = PROCEDURE( + inWindowID : XPLMWindowID; + inKey : XPLMChar; + inFlags : XPLMKeyFlags; + inVirtualKey : XPLMChar; + inRefcon : pointer; + losingFocus : Integer); cdecl; + + { + XPLMMouseStatus + + When the mouse is clicked, your mouse click routine is called repeatedly. + It is first called with the mouse down message. It is then called zero or + more times with the mouse-drag message, and finally it is called once with + the mouse up message. All of these messages will be directed to the same + window; you are guaranteed to not receive a drag or mouse-up event without + first receiving the corresponding mouse-down. + } + XPLMMouseStatus = ( + xplm_MouseDown = 1 + + ,xplm_MouseDrag = 2 + + ,xplm_MouseUp = 3 + + ); + PXPLMMouseStatus = ^XPLMMouseStatus; + + { + XPLMHandleMouseClick_f + + You receive this call for one of three events: + + - when the user clicks the mouse button down + - (optionally) when the user drags the mouse after a down-click, but before + the up-click + - when the user releases the down-clicked mouse button. + + You receive the x and y of the click, your window, and a refcon. Return 1 + to consume the click, or 0 to pass it through. + + WARNING: passing clicks through windows (as of this writing) causes mouse + tracking problems in X-Plane; do not use this feature! + + The units for x and y values match the units used in your window. Thus, for + "modern" windows (those created via XPLMCreateWindowEx() and compiled + against the XPLM300 library), the units are boxels, while legacy windows + will get pixels. Legacy windows have their origin in the lower left of the + main X-Plane window, while modern windows have their origin in the lower + left of the global desktop space. In both cases, x increases as you move + right, and y increases as you move up. + } + XPLMHandleMouseClick_f = FUNCTION( + inWindowID : XPLMWindowID; + x : Integer; + y : Integer; + inMouse : XPLMMouseStatus; + inRefcon : pointer) : Integer; cdecl; + +{$IFDEF XPLM200} + { + XPLMCursorStatus + + XPLMCursorStatus describes how you would like X-Plane to manage the cursor. + See XPLMHandleCursor_f for more info. + } +TYPE + XPLMCursorStatus = ( + { X-Plane manages the cursor normally, plugin does not affect the cusrsor. } + xplm_CursorDefault = 0 + + { X-Plane hides the cursor. } + ,xplm_CursorHidden = 1 + + { X-Plane shows the cursor as the default arrow. } + ,xplm_CursorArrow = 2 + + { X-Plane shows the cursor but lets you select an OS cursor. } + ,xplm_CursorCustom = 3 + + ); + PXPLMCursorStatus = ^XPLMCursorStatus; +{$ENDIF XPLM200} + +{$IFDEF XPLM200} + { + XPLMHandleCursor_f + + The SDK calls your cursor status callback when the mouse is over your + plugin window. Return a cursor status code to indicate how you would like + X-Plane to manage the cursor. If you return xplm_CursorDefault, the SDK + will try lower-Z-order plugin windows, then let the sim manage the cursor. + + Note: you should never show or hide the cursor yourself---these APIs are + typically reference-counted and thus cannot safely and predictably be used + by the SDK. Instead return one of xplm_CursorHidden to hide the cursor or + xplm_CursorArrow/xplm_CursorCustom to show the cursor. + + If you want to implement a custom cursor by drawing a cursor in OpenGL, use + xplm_CursorHidden to hide the OS cursor and draw the cursor using a 2-d + drawing callback (after xplm_Phase_Window is probably a good choice, but + see deprecation warnings on the drawing APIs!). If you want to use a + custom OS-based cursor, use xplm_CursorCustom to ask X-Plane to show the + cursor but not affect its image. You can then use an OS specific call like + SetThemeCursor (Mac) or SetCursor/LoadCursor (Windows). + + The units for x and y values match the units used in your window. Thus, for + "modern" windows (those created via XPLMCreateWindowEx() and compiled + against the XPLM300 library), the units are boxels, while legacy windows + will get pixels. Legacy windows have their origin in the lower left of the + main X-Plane window, while modern windows have their origin in the lower + left of the global desktop space. In both cases, x increases as you move + right, and y increases as you move up. + } + XPLMHandleCursor_f = FUNCTION( + inWindowID : XPLMWindowID; + x : Integer; + y : Integer; + inRefcon : pointer) : XPLMCursorStatus; cdecl; +{$ENDIF XPLM200} + +{$IFDEF XPLM200} + { + XPLMHandleMouseWheel_f + + The SDK calls your mouse wheel callback when one of the mouse wheels is + scrolled within your window. Return 1 to consume the mouse wheel movement + or 0 to pass them on to a lower window. (If your window appears opaque to + the user, you should consume mouse wheel scrolling even if it does + nothing.) The number of "clicks" indicates how far the wheel was turned + since the last callback. The wheel is 0 for the vertical axis or 1 for the + horizontal axis (for OS/mouse combinations that support this). + + The units for x and y values match the units used in your window. Thus, for + "modern" windows (those created via XPLMCreateWindowEx() and compiled + against the XPLM300 library), the units are boxels, while legacy windows + will get pixels. Legacy windows have their origin in the lower left of the + main X-Plane window, while modern windows have their origin in the lower + left of the global desktop space. In both cases, x increases as you move + right, and y increases as you move up. + } + XPLMHandleMouseWheel_f = FUNCTION( + inWindowID : XPLMWindowID; + x : Integer; + y : Integer; + wheel : Integer; + clicks : Integer; + inRefcon : pointer) : Integer; cdecl; +{$ENDIF XPLM200} + +{$IFDEF XPLM300} + { + XPLMWindowLayer + + XPLMWindowLayer describes where in the ordering of windows X-Plane should + place a particular window. Windows in higher layers cover windows in lower + layers. So, a given window might be at the top of its particular layer, but + it might still be obscured by a window in a higher layer. (This happens + frequently when floating windows, like X-Plane's map, are covered by a + modal alert.) + + Your window's layer can only be specified when you create the window (in + the XPLMCreateWindow_t you pass to XPLMCreateWindowEx()). For this reason, + layering only applies to windows created with new X-Plane 11 GUI features. + (Windows created using the older XPLMCreateWindow(), or windows compiled + against a pre-XPLM300 version of the SDK will simply be placed in the + flight overlay window layer.) + } +TYPE + XPLMWindowLayer = ( + { The lowest layer, used for HUD-like displays while flying. } + xplm_WindowLayerFlightOverlay = 0 + + { Windows that "float" over the sim, like the X-Plane 11 map does. If you are} + { not sure which layer to create your window in, choose floating. } + ,xplm_WindowLayerFloatingWindows = 1 + + { An interruptive modal that covers the sim with a transparent black overlay } + { to draw the user's focus to the alert } + ,xplm_WindowLayerModal = 2 + + { "Growl"-style notifications that are visible in a corner of the screen, } + { even over modals } + ,xplm_WindowLayerGrowlNotifications = 3 + + ); + PXPLMWindowLayer = ^XPLMWindowLayer; +{$ENDIF XPLM300} + +{$IFDEF XPLM301} + { + XPLMWindowDecoration + + XPLMWindowDecoration describes how "modern" windows will be displayed. This + impacts both how X-Plane draws your window as well as certain mouse + handlers. + + Your window's decoration can only be specified when you create the window + (in the XPLMCreateWindow_t you pass to XPLMCreateWindowEx()). + } +TYPE + XPLMWindowDecoration = ( + { X-Plane will draw no decoration for your window, and apply no automatic } + { click handlers. The window will not stop click from passing through its } + { bounds. This is suitable for "windows" which request, say, the full screen } + { bounds, then only draw in a small portion of the available area. } + xplm_WindowDecorationNone = 0 + + { The default decoration for "native" windows, like the map. Provides a solid} + { background, as well as click handlers for resizing and dragging the window.} + ,xplm_WindowDecorationRoundRectangle = 1 + + { X-Plane will draw no decoration for your window, nor will it provide resize} + { handlers for your window edges, but it will stop clicks from passing } + { through your windows bounds. } + ,xplm_WindowDecorationSelfDecorated = 2 + + { Like self-decorated, but with resizing; X-Plane will draw no decoration for} + { your window, but it will stop clicks from passing through your windows } + { bounds, and provide automatic mouse handlers for resizing. } + ,xplm_WindowDecorationSelfDecoratedResizable = 3 + + ); + PXPLMWindowDecoration = ^XPLMWindowDecoration; +{$ENDIF XPLM301} + +{$IFDEF XPLM200} + { + XPLMCreateWindow_t + + The XPMCreateWindow_t structure defines all of the parameters used to + create a modern window using XPLMCreateWindowEx(). The structure will be + expanded in future SDK APIs to include more features. Always set the + structSize member to the size of your struct in bytes! + + All windows created by this function in the XPLM300 version of the API are + created with the new X-Plane 11 GUI features. This means your plugin will + get to "know" about the existence of X-Plane windows other than the main + window. All drawing and mouse callbacks for your window will occur in + "boxels," giving your windows automatic support for high-DPI scaling in + X-Plane. In addition, your windows can opt-in to decoration with the + X-Plane 11 window styling, and you can use the + XPLMSetWindowPositioningMode() API to make your window "popped out" into a + first-class operating system window. + + Note that this requires dealing with your window's bounds in "global + desktop" positioning units, rather than the traditional panel coordinate + system. In global desktop coordinates, the main X-Plane window may not have + its origin at coordinate (0, 0), and your own window may have negative + coordinates. Assuming you don't implicitly assume (0, 0) as your origin, + the only API change you should need is to start using + XPLMGetMouseLocationGlobal() rather than XPLMGetMouseLocation(), and + XPLMGetScreenBoundsGlobal() instead of XPLMGetScreenSize(). + + If you ask to be decorated as a floating window, you'll get the blue window + control bar and blue backing that you see in X-Plane 11's normal "floating" + windows (like the map). + } +TYPE + XPLMCreateWindow_t = RECORD + { Used to inform XPLMCreateWindowEx() of the SDK version you compiled } + { against; should always be set to sizeof(XPLMCreateWindow_t) } + structSize : Integer; + { Left bound, in global desktop boxels } + left : Integer; + { Top bound, in global desktop boxels } + top : Integer; + { Right bound, in global desktop boxels } + right : Integer; + { Bottom bound, in global desktop boxels } + bottom : Integer; + visible : Integer; + drawWindowFunc : XPLMDrawWindow_f; + { A callback to handle the user left-clicking within your window (or NULL to } + { ignore left clicks) } + handleMouseClickFunc : XPLMHandleMouseClick_f; + handleKeyFunc : XPLMHandleKey_f; + handleCursorFunc : XPLMHandleCursor_f; + handleMouseWheelFunc : XPLMHandleMouseWheel_f; + { A reference which will be passed into each of your window callbacks. Use } + { this to pass information to yourself as needed. } + refcon : pointer; +{$IFDEF XPLM301} + { Specifies the type of X-Plane 11-style "wrapper" you want around your } + { window, if any } + decorateAsFloatingWindow : XPLMWindowDecoration; +{$ENDIF XPLM301} +{$IFDEF XPLM300} + layer : XPLMWindowLayer; +{$ENDIF XPLM300} +{$IFDEF XPLM300} + { A callback to handle the user right-clicking within your window (or NULL to} + { ignore right clicks) } + handleRightClickFunc : XPLMHandleMouseClick_f; +{$ENDIF XPLM300} + END; + PXPLMCreateWindow_t = ^XPLMCreateWindow_t; +{$ENDIF XPLM200} + +{$IFDEF XPLM200} + { + XPLMCreateWindowEx + + This routine creates a new "modern" window. You pass in an + XPLMCreateWindow_t structure with all of the fields set in. You must set + the structSize of the structure to the size of the actual structure you + used. Also, you must provide functions for every callback---you may not + leave them null! (If you do not support the cursor or mouse wheel, use + functions that return the default values.) + } + FUNCTION XPLMCreateWindowEx( + inParams : PXPLMCreateWindow_t) : XPLMWindowID; + cdecl; external XPLM_DLL; +{$ENDIF XPLM200} + + { + XPLMCreateWindow + + Deprecated as of XPLM300. + + This routine creates a new legacy window. Unlike modern windows (created + via XPLMCreateWindowEx()), legacy windows do not have access to X-Plane 11 + features like automatic scaling for high-DPI screens, native window styles, + or support for being "popped out" into first-class operating system + windows. + + Pass in the dimensions and offsets to the window's bottom left corner from + the bottom left of the screen. You can specify whether the window is + initially visible or not. Also, you pass in three callbacks to run the + window and a refcon. This function returns a window ID you can use to + refer to the new window. + + NOTE: Legacy windows do not have "frames"; you are responsible for drawing + the background and frame of the window. Higher level libraries have + routines which make this easy. + } + FUNCTION XPLMCreateWindow( + inLeft : Integer; + inTop : Integer; + inRight : Integer; + inBottom : Integer; + inIsVisible : Integer; + inDrawCallback : XPLMDrawWindow_f; + inKeyCallback : XPLMHandleKey_f; + inMouseCallback : XPLMHandleMouseClick_f; + inRefcon : pointer) : XPLMWindowID; + cdecl; external XPLM_DLL; + + { + XPLMDestroyWindow + + This routine destroys a window. The window's callbacks are not called + after this call. Keyboard focus is removed from the window before + destroying it. + } + PROCEDURE XPLMDestroyWindow( + inWindowID : XPLMWindowID); + cdecl; external XPLM_DLL; + + { + XPLMGetScreenSize + + This routine returns the size of the main X-Plane OpenGL window in pixels. + This number can be used to get a rough idea of the amount of detail the + user will be able to see when drawing in 3-d. + } + PROCEDURE XPLMGetScreenSize( + outWidth : PInteger; { Can be nil } + outHeight : PInteger); { Can be nil } + cdecl; external XPLM_DLL; + +{$IFDEF XPLM300} + { + XPLMGetScreenBoundsGlobal + + This routine returns the bounds of the "global" X-Plane desktop, in boxels. + Unlike the non-global version XPLMGetScreenSize(), this is multi-monitor + aware. There are three primary consequences of multimonitor awareness. + + First, if the user is running X-Plane in full-screen on two or more + monitors (typically configured using one full-screen window per monitor), + the global desktop will be sized to include all X-Plane windows. + + Second, the origin of the screen coordinates is not guaranteed to be (0, + 0). Suppose the user has two displays side-by-side, both running at 1080p. + Suppose further that they've configured their OS to make the left display + their "primary" monitor, and that X-Plane is running in full-screen on + their right monitor only. In this case, the global desktop bounds would be + the rectangle from (1920, 0) to (3840, 1080). If the user later asked + X-Plane to draw on their primary monitor as well, the bounds would change + to (0, 0) to (3840, 1080). + + Finally, if the usable area of the virtual desktop is not a perfect + rectangle (for instance, because the monitors have different resolutions or + because one monitor is configured in the operating system to be above and + to the right of the other), the global desktop will include any wasted + space. Thus, if you have two 1080p monitors, and monitor 2 is configured to + have its bottom left touch monitor 1's upper right, your global desktop + area would be the rectangle from (0, 0) to (3840, 2160). + + Note that popped-out windows (windows drawn in their own operating system + windows, rather than "floating" within X-Plane) are not included in these + bounds. + } + PROCEDURE XPLMGetScreenBoundsGlobal( + outLeft : PInteger; { Can be nil } + outTop : PInteger; { Can be nil } + outRight : PInteger; { Can be nil } + outBottom : PInteger); { Can be nil } + cdecl; external XPLM_DLL; +{$ENDIF XPLM300} + +{$IFDEF XPLM300} + { + XPLMReceiveMonitorBoundsGlobal_f + + This function is informed of the global bounds (in boxels) of a particular + monitor within the X-Plane global desktop space. Note that X-Plane must be + running in full screen on a monitor in order for that monitor to be passed + to you in this callback. + } +TYPE + XPLMReceiveMonitorBoundsGlobal_f = PROCEDURE( + inMonitorIndex : Integer; + inLeftBx : Integer; + inTopBx : Integer; + inRightBx : Integer; + inBottomBx : Integer; + inRefcon : pointer); cdecl; +{$ENDIF XPLM300} + +{$IFDEF XPLM300} + { + XPLMGetAllMonitorBoundsGlobal + + This routine immediately calls you back with the bounds (in boxels) of each + full-screen X-Plane window within the X-Plane global desktop space. Note + that if a monitor is *not* covered by an X-Plane window, you cannot get its + bounds this way. Likewise, monitors with only an X-Plane window (not in + full-screen mode) will not be included. + + If X-Plane is running in full-screen and your monitors are of the same size + and configured contiguously in the OS, then the combined global bounds of + all full-screen monitors will match the total global desktop bounds, as + returned by XPLMGetScreenBoundsGlobal(). (Of course, if X-Plane is running + in windowed mode, this will not be the case. Likewise, if you have + differently sized monitors, the global desktop space will include wasted + space.) + + Note that this function's monitor indices match those provided by + XPLMGetAllMonitorBoundsOS(), but the coordinates are different (since the + X-Plane global desktop may not match the operating system's global desktop, + and one X-Plane boxel may be larger than one pixel due to 150% or 200% + scaling). + } + PROCEDURE XPLMGetAllMonitorBoundsGlobal( + inMonitorBoundsCallback: XPLMReceiveMonitorBoundsGlobal_f; + inRefcon : pointer); + cdecl; external XPLM_DLL; +{$ENDIF XPLM300} + +{$IFDEF XPLM300} + { + XPLMReceiveMonitorBoundsOS_f + + This function is informed of the global bounds (in pixels) of a particular + monitor within the operating system's global desktop space. Note that a + monitor index being passed to you here does not indicate that X-Plane is + running in full screen on this monitor, or even that any X-Plane windows + exist on this monitor. + } +TYPE + XPLMReceiveMonitorBoundsOS_f = PROCEDURE( + inMonitorIndex : Integer; + inLeftPx : Integer; + inTopPx : Integer; + inRightPx : Integer; + inBottomPx : Integer; + inRefcon : pointer); cdecl; +{$ENDIF XPLM300} + +{$IFDEF XPLM300} + { + XPLMGetAllMonitorBoundsOS + + This routine immediately calls you back with the bounds (in pixels) of each + monitor within the operating system's global desktop space. Note that + unlike XPLMGetAllMonitorBoundsGlobal(), this may include monitors that have + no X-Plane window on them. + + Note that this function's monitor indices match those provided by + XPLMGetAllMonitorBoundsGlobal(), but the coordinates are different (since + the X-Plane global desktop may not match the operating system's global + desktop, and one X-Plane boxel may be larger than one pixel). + } + PROCEDURE XPLMGetAllMonitorBoundsOS( + inMonitorBoundsCallback: XPLMReceiveMonitorBoundsOS_f; + inRefcon : pointer); + cdecl; external XPLM_DLL; +{$ENDIF XPLM300} + + { + XPLMGetMouseLocation + + Deprecated in XPLM300. Modern windows should use + XPLMGetMouseLocationGlobal() instead. + + This routine returns the current mouse location in pixels relative to the + main X-Plane window. The bottom left corner of the main window is (0, 0). + Pass NULL to not receive info about either parameter. + + Because this function gives the mouse position relative to the main X-Plane + window (rather than in global bounds), this function should only be used by + legacy windows. Modern windows should instead get the mouse position in + global desktop coordinates using XPLMGetMouseLocationGlobal(). + + Note that unlike XPLMGetMouseLocationGlobal(), if the mouse goes outside + the user's main monitor (for instance, to a pop out window or a secondary + monitor), this function will not reflect it. + } + PROCEDURE XPLMGetMouseLocation( + outX : PInteger; { Can be nil } + outY : PInteger); { Can be nil } + cdecl; external XPLM_DLL; + +{$IFDEF XPLM300} + { + XPLMGetMouseLocationGlobal + + Returns the current mouse location in global desktop boxels. Unlike + XPLMGetMouseLocation(), the bottom left of the main X-Plane window is not + guaranteed to be (0, 0)---instead, the origin is the lower left of the + entire global desktop space. In addition, this routine gives the real mouse + location when the mouse goes to X-Plane windows other than the primary + display. Thus, it can be used with both pop-out windows and secondary + monitors. + + This is the mouse location function to use with modern windows (i.e., those + created by XPLMCreateWindowEx()). + + Pass NULL to not receive info about either parameter. + } + PROCEDURE XPLMGetMouseLocationGlobal( + outX : PInteger; { Can be nil } + outY : PInteger); { Can be nil } + cdecl; external XPLM_DLL; +{$ENDIF XPLM300} + + { + XPLMGetWindowGeometry + + This routine returns the position and size of a window. The units and + coordinate system vary depending on the type of window you have. + + If this is a legacy window (one compiled against a pre-XPLM300 version of + the SDK, or an XPLM300 window that was not created using + XPLMCreateWindowEx()), the units are pixels relative to the main X-Plane + display. + + If, on the other hand, this is a new X-Plane 11-style window (compiled + against the XPLM300 SDK and created using XPLMCreateWindowEx()), the units + are global desktop boxels. + + Pass NULL to not receive any paramter. + } + PROCEDURE XPLMGetWindowGeometry( + inWindowID : XPLMWindowID; + outLeft : PInteger; { Can be nil } + outTop : PInteger; { Can be nil } + outRight : PInteger; { Can be nil } + outBottom : PInteger); { Can be nil } + cdecl; external XPLM_DLL; + + { + XPLMSetWindowGeometry + + This routine allows you to set the position and size of a window. + + The units and coordinate system match those of XPLMGetWindowGeometry(). + That is, modern windows use global desktop boxel coordinates, while legacy + windows use pixels relative to the main X-Plane display. + + Note that this only applies to "floating" windows (that is, windows that + are drawn within the X-Plane simulation windows, rather than being "popped + out" into their own first-class operating system windows). To set the + position of windows whose positioning mode is xplm_WindowPopOut, you'll + need to instead use XPLMSetWindowGeometryOS(). + } + PROCEDURE XPLMSetWindowGeometry( + inWindowID : XPLMWindowID; + inLeft : Integer; + inTop : Integer; + inRight : Integer; + inBottom : Integer); + cdecl; external XPLM_DLL; + +{$IFDEF XPLM300} + { + XPLMGetWindowGeometryOS + + This routine returns the position and size of a "popped out" window (i.e., + a window whose positioning mode is xplm_WindowPopOut), in operating system + pixels. Pass NULL to not receive any parameter. + } + PROCEDURE XPLMGetWindowGeometryOS( + inWindowID : XPLMWindowID; + outLeft : PInteger; { Can be nil } + outTop : PInteger; { Can be nil } + outRight : PInteger; { Can be nil } + outBottom : PInteger); { Can be nil } + cdecl; external XPLM_DLL; +{$ENDIF XPLM300} + +{$IFDEF XPLM300} + { + XPLMSetWindowGeometryOS + + This routine allows you to set the position and size, in operating system + pixel coordinates, of a popped out window (that is, a window whose + positioning mode is xplm_WindowPopOut, which exists outside the X-Plane + simulation window, in its own first-class operating system window). + + Note that you are responsible for ensuring both that your window is popped + out (using XPLMWindowIsPoppedOut()) and that a monitor really exists at the + OS coordinates you provide (using XPLMGetAllMonitorBoundsOS()). + } + PROCEDURE XPLMSetWindowGeometryOS( + inWindowID : XPLMWindowID; + inLeft : Integer; + inTop : Integer; + inRight : Integer; + inBottom : Integer); + cdecl; external XPLM_DLL; +{$ENDIF XPLM300} + +{$IFDEF XPLM301} + { + XPLMGetWindowGeometryVR + + Returns the width and height, in boxels, of a window in VR. Note that you + are responsible for ensuring your window is in VR (using + XPLMWindowIsInVR()). + } + PROCEDURE XPLMGetWindowGeometryVR( + inWindowID : XPLMWindowID; + outWidthBoxels : PInteger; { Can be nil } + outHeightBoxels : PInteger); { Can be nil } + cdecl; external XPLM_DLL; +{$ENDIF XPLM301} + +{$IFDEF XPLM301} + { + XPLMSetWindowGeometryVR + + This routine allows you to set the size, in boxels, of a window in VR (that + is, a window whose positioning mode is xplm_WindowVR). + + Note that you are responsible for ensuring your window is in VR (using + XPLMWindowIsInVR()). + } + PROCEDURE XPLMSetWindowGeometryVR( + inWindowID : XPLMWindowID; + widthBoxels : Integer; + heightBoxels : Integer); + cdecl; external XPLM_DLL; +{$ENDIF XPLM301} + + { + XPLMGetWindowIsVisible + + Returns true (1) if the specified window is visible. + } + FUNCTION XPLMGetWindowIsVisible( + inWindowID : XPLMWindowID) : Integer; + cdecl; external XPLM_DLL; + + { + XPLMSetWindowIsVisible + + This routine shows or hides a window. + } + PROCEDURE XPLMSetWindowIsVisible( + inWindowID : XPLMWindowID; + inIsVisible : Integer); + cdecl; external XPLM_DLL; + +{$IFDEF XPLM300} + { + XPLMWindowIsPoppedOut + + True if this window has been popped out (making it a first-class window in + the operating system), which in turn is true if and only if you have set + the window's positioning mode to xplm_WindowPopOut. + + Only applies to modern windows. (Windows created using the deprecated + XPLMCreateWindow(), or windows compiled against a pre-XPLM300 version of + the SDK cannot be popped out.) + } + FUNCTION XPLMWindowIsPoppedOut( + inWindowID : XPLMWindowID) : Integer; + cdecl; external XPLM_DLL; +{$ENDIF XPLM300} + +{$IFDEF XPLM301} + { + XPLMWindowIsInVR + + True if this window has been moved to the virtual reality (VR) headset, + which in turn is true if and only if you have set the window's positioning + mode to xplm_WindowVR. + + Only applies to modern windows. (Windows created using the deprecated + XPLMCreateWindow(), or windows compiled against a pre-XPLM301 version of + the SDK cannot be moved to VR.) + } + FUNCTION XPLMWindowIsInVR( + inWindowID : XPLMWindowID) : Integer; + cdecl; external XPLM_DLL; +{$ENDIF XPLM301} + +{$IFDEF XPLM300} + { + XPLMSetWindowGravity + + A window's "gravity" controls how the window shifts as the whole X-Plane + window resizes. A gravity of 1 means the window maintains its positioning + relative to the right or top edges, 0 the left/bottom, and 0.5 keeps it + centered. + + Default gravity is (0, 1, 0, 1), meaning your window will maintain its + position relative to the top left and will not change size as its + containing window grows. + + If you wanted, say, a window that sticks to the top of the screen (with a + constant height), but which grows to take the full width of the window, you + would pass (0, 1, 1, 1). Because your left and right edges would maintain + their positioning relative to their respective edges of the screen, the + whole width of your window would change with the X-Plane window. + + Only applies to modern windows. (Windows created using the deprecated + XPLMCreateWindow(), or windows compiled against a pre-XPLM300 version of + the SDK will simply get the default gravity.) + } + PROCEDURE XPLMSetWindowGravity( + inWindowID : XPLMWindowID; + inLeftGravity : Single; + inTopGravity : Single; + inRightGravity : Single; + inBottomGravity : Single); + cdecl; external XPLM_DLL; +{$ENDIF XPLM300} + +{$IFDEF XPLM300} + { + XPLMSetWindowResizingLimits + + Sets the minimum and maximum size of the client rectangle of the given + window. (That is, it does not include any window styling that you might + have asked X-Plane to apply on your behalf.) All resizing operations are + constrained to these sizes. + + Only applies to modern windows. (Windows created using the deprecated + XPLMCreateWindow(), or windows compiled against a pre-XPLM300 version of + the SDK will have no minimum or maximum size.) + } + PROCEDURE XPLMSetWindowResizingLimits( + inWindowID : XPLMWindowID; + inMinWidthBoxels : Integer; + inMinHeightBoxels : Integer; + inMaxWidthBoxels : Integer; + inMaxHeightBoxels : Integer); + cdecl; external XPLM_DLL; +{$ENDIF XPLM300} + +{$IFDEF XPLM300} + { + XPLMWindowPositioningMode + + XPLMWindowPositionMode describes how X-Plane will position your window on + the user's screen. X-Plane will maintain this positioning mode even as the + user resizes their window or adds/removes full-screen monitors. + + Positioning mode can only be set for "modern" windows (that is, windows + created using XPLMCreateWindowEx() and compiled against the XPLM300 SDK). + Windows created using the deprecated XPLMCreateWindow(), or windows + compiled against a pre-XPLM300 version of the SDK will simply get the + "free" positioning mode. + } +TYPE + XPLMWindowPositioningMode = ( + { The default positioning mode. Set the window geometry and its future } + { position will be determined by its window gravity, resizing limits, and } + { user interactions. } + xplm_WindowPositionFree = 0 + + { Keep the window centered on the monitor you specify } + ,xplm_WindowCenterOnMonitor = 1 + + { Keep the window full screen on the monitor you specify } + ,xplm_WindowFullScreenOnMonitor = 2 + + { Like gui_window_full_screen_on_monitor, but stretches over *all* monitors } + { and popout windows. This is an obscure one... unless you have a very good } + { reason to need it, you probably don't! } + ,xplm_WindowFullScreenOnAllMonitors = 3 + + { A first-class window in the operating system, completely separate from the } + { X-Plane window(s) } + ,xplm_WindowPopOut = 4 + +{$IFDEF XPLM301} + { A floating window visible on the VR headset } + ,xplm_WindowVR = 5 +{$ENDIF XPLM301} + + ); + PXPLMWindowPositioningMode = ^XPLMWindowPositioningMode; +{$ENDIF XPLM300} + +{$IFDEF XPLM300} + { + XPLMSetWindowPositioningMode + + Sets the policy for how X-Plane will position your window. + + Some positioning modes apply to a particular monitor. For those modes, you + can pass a negative monitor index to position the window on the main + X-Plane monitor (the screen with the X-Plane menu bar at the top). Or, if + you have a specific monitor you want to position your window on, you can + pass a real monitor index as received from, e.g., + XPLMGetAllMonitorBoundsOS(). + + Only applies to modern windows. (Windows created using the deprecated + XPLMCreateWindow(), or windows compiled against a pre-XPLM300 version of + the SDK will always use xplm_WindowPositionFree.) + } + PROCEDURE XPLMSetWindowPositioningMode( + inWindowID : XPLMWindowID; + inPositioningMode : XPLMWindowPositioningMode; + inMonitorIndex : Integer); + cdecl; external XPLM_DLL; +{$ENDIF XPLM300} + +{$IFDEF XPLM300} + { + XPLMSetWindowTitle + + Sets the name for a window. This only applies to windows that opted-in to + styling as an X-Plane 11 floating window (i.e., with styling mode + xplm_WindowDecorationRoundRectangle) when they were created using + XPLMCreateWindowEx(). + } + PROCEDURE XPLMSetWindowTitle( + inWindowID : XPLMWindowID; + inWindowTitle : XPLMString); + cdecl; external XPLM_DLL; +{$ENDIF XPLM300} + + { + XPLMGetWindowRefCon + + Returns a window's reference constant, the unique value you can use for + your own purposes. + } + FUNCTION XPLMGetWindowRefCon( + inWindowID : XPLMWindowID) : pointer; + cdecl; external XPLM_DLL; + + { + XPLMSetWindowRefCon + + Sets a window's reference constant. Use this to pass data to yourself in + the callbacks. + } + PROCEDURE XPLMSetWindowRefCon( + inWindowID : XPLMWindowID; + inRefcon : pointer); + cdecl; external XPLM_DLL; + + { + XPLMTakeKeyboardFocus + + This routine gives a specific window keyboard focus. Keystrokes will be + sent to that window. Pass a window ID of 0 to remove keyboard focus from + any plugin-created windows and instead pass keyboard strokes directly to + X-Plane. + } + PROCEDURE XPLMTakeKeyboardFocus( + inWindow : XPLMWindowID); + cdecl; external XPLM_DLL; + + { + XPLMHasKeyboardFocus + + Returns true (1) if the indicated window has keyboard focus. Pass a window + ID of 0 to see if no plugin window has focus, and all keystrokes will go + directly to X-Plane. + } + FUNCTION XPLMHasKeyboardFocus( + inWindow : XPLMWindowID) : Integer; + cdecl; external XPLM_DLL; + + { + XPLMBringWindowToFront + + This routine brings the window to the front of the Z-order for its layer. + Windows are brought to the front automatically when they are created. + Beyond that, you should make sure you are front before handling mouse + clicks. + + Note that this only brings your window to the front of its layer + (XPLMWindowLayer). Thus, if you have a window in the floating window layer + (xplm_WindowLayerFloatingWindows), but there is a modal window (in layer + xplm_WindowLayerModal) above you, you would still not be the true frontmost + window after calling this. (After all, the window layers are strictly + ordered, and no window in a lower layer can ever be above any window in a + higher one.) + } + PROCEDURE XPLMBringWindowToFront( + inWindow : XPLMWindowID); + cdecl; external XPLM_DLL; + + { + XPLMIsWindowInFront + + This routine returns true if the window you passed in is the frontmost + visible window in its layer (XPLMWindowLayer). + + Thus, if you have a window at the front of the floating window layer + (xplm_WindowLayerFloatingWindows), this will return true even if there is a + modal window (in layer xplm_WindowLayerModal) above you. (Not to worry, + though: in such a case, X-Plane will not pass clicks or keyboard input down + to your layer until the window above stops "eating" the input.) + + Note that legacy windows are always placed in layer + xplm_WindowLayerFlightOverlay, while modern-style windows default to + xplm_WindowLayerFloatingWindows. This means it's perfectly consistent to + have two different plugin-created windows (one legacy, one modern) *both* + be in the front (of their different layers!) at the same time. + } + FUNCTION XPLMIsWindowInFront( + inWindow : XPLMWindowID) : Integer; + cdecl; external XPLM_DLL; + +{___________________________________________________________________________ + * KEY SNIFFERS + ___________________________________________________________________________} +{ + Low-level keyboard handlers. Allows for intercepting keystrokes outside the + normal rules of the user interface. +} + + + { + XPLMKeySniffer_f + + This is the prototype for a low level key-sniffing function. Window-based + UI _should not use this_! The windowing system provides high-level + mediated keyboard access, via the callbacks you attach to your + XPLMCreateWindow_t. By comparison, the key sniffer provides low level + keyboard access. + + Key sniffers are provided to allow libraries to provide non-windowed user + interaction. For example, the MUI library uses a key sniffer to do pop-up + text entry. + + Return 1 to pass the key on to the next sniffer, the window manager, + X-Plane, or whomever is down stream. Return 0 to consume the key. + + Warning: this API declares virtual keys as a signed character; however the + VKEY #define macros in XPLMDefs.h define the vkeys using unsigned values + (that is 0x80 instead of -0x80). So you may need to cast the incoming vkey + to an unsigned char to get correct comparisons in C. + } +TYPE + XPLMKeySniffer_f = FUNCTION( + inChar : XPLMChar; + inFlags : XPLMKeyFlags; + inVirtualKey : XPLMChar; + inRefcon : pointer) : Integer; cdecl; + + { + XPLMRegisterKeySniffer + + This routine registers a key sniffing callback. You specify whether you + want to sniff before the window system, or only sniff keys the window + system does not consume. You should ALMOST ALWAYS sniff non-control keys + after the window system. When the window system consumes a key, it is + because the user has "focused" a window. Consuming the key or taking + action based on the key will produce very weird results. Returns + 1 if successful. + } + FUNCTION XPLMRegisterKeySniffer( + inCallback : XPLMKeySniffer_f; + inBeforeWindows : Integer; + inRefcon : pointer) : Integer; + cdecl; external XPLM_DLL; + + { + XPLMUnregisterKeySniffer + + This routine unregisters a key sniffer. You must unregister a key sniffer + for every time you register one with the exact same signature. Returns 1 + if successful. + } + FUNCTION XPLMUnregisterKeySniffer( + inCallback : XPLMKeySniffer_f; + inBeforeWindows : Integer; + inRefcon : pointer) : Integer; + cdecl; external XPLM_DLL; + +{___________________________________________________________________________ + * HOT KEYS + ___________________________________________________________________________} +{ + Keystrokes that can be managed by others. These are lower-level than window + keyboard handlers (i.e., callbacks you attach to your XPLMCreateWindow_t), + but higher level than key sniffers. +} + + + { + XPLMHotKey_f + + Your hot key callback simply takes a pointer of your choosing. + } +TYPE + XPLMHotKey_f = PROCEDURE( + inRefcon : pointer); cdecl; + + { + XPLMHotKeyID + + An opaque ID used to identify a hot key. + } + XPLMHotKeyID = pointer; + PXPLMHotKeyID = ^XPLMHotKeyID; + + { + XPLMRegisterHotKey + + This routine registers a hot key. You specify your preferred key stroke + virtual key/flag combination, a description of what your callback does (so + other plug-ins can describe the plug-in to the user for remapping) and a + callback function and opaque pointer to pass in). A new hot key ID is + returned. During execution, the actual key associated with your hot key + may change, but you are insulated from this. + } + FUNCTION XPLMRegisterHotKey( + inVirtualKey : XPLMChar; + inFlags : XPLMKeyFlags; + inDescription : XPLMString; + inCallback : XPLMHotKey_f; + inRefcon : pointer) : XPLMHotKeyID; + cdecl; external XPLM_DLL; + + { + XPLMUnregisterHotKey + + Unregisters a hot key. You can only unregister your own hot keys. + } + PROCEDURE XPLMUnregisterHotKey( + inHotKey : XPLMHotKeyID); + cdecl; external XPLM_DLL; + + { + XPLMCountHotKeys + + Returns the number of current hot keys. + } + FUNCTION XPLMCountHotKeys: Integer; + cdecl; external XPLM_DLL; + + { + XPLMGetNthHotKey + + Returns a hot key by index, for iteration on all hot keys. + } + FUNCTION XPLMGetNthHotKey( + inIndex : Integer) : XPLMHotKeyID; + cdecl; external XPLM_DLL; + + { + XPLMGetHotKeyInfo + + Returns information about the hot key. Return NULL for any parameter you + don't want info about. The description should be at least 512 chars long. + } + PROCEDURE XPLMGetHotKeyInfo( + inHotKey : XPLMHotKeyID; + outVirtualKey : XPLMString; { Can be nil } + outFlags : PXPLMKeyFlags; { Can be nil } + outDescription : XPLMString; { Can be nil } + outPlugin : PXPLMPluginID); { Can be nil } + cdecl; external XPLM_DLL; + + { + XPLMSetHotKeyCombination + + Remaps a hot key's keystrokes. You may remap another plugin's keystrokes. + } + PROCEDURE XPLMSetHotKeyCombination( + inHotKey : XPLMHotKeyID; + inVirtualKey : XPLMChar; + inFlags : XPLMKeyFlags); + cdecl; external XPLM_DLL; + + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/SDK/Delphi/XPLM/XPLMGraphics.pas b/XPLPro_Plugin_Source/SDK/SDK/Delphi/XPLM/XPLMGraphics.pas new file mode 100644 index 0000000..20ff61a --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDK/Delphi/XPLM/XPLMGraphics.pas @@ -0,0 +1,424 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPLMGraphics; +INTERFACE +{ + A few notes on coordinate systems: + + X-Plane uses three kinds of coordinates. Global coordinates are specified + as latitude, longitude and elevation. This coordinate system never changes + but is not very precise. + + OpenGL (or 'local') coordinates are cartesian and shift with the plane. + They offer more precision and are used for 3-d OpenGL drawing. The X axis + is aligned east-west with positive X meaning east. The Y axis is aligned + straight up and down at the point 0,0,0 (but since the earth is round it is + not truly straight up and down at other points). The Z axis is aligned + north-south at 0, 0, 0 with positive Z pointing south (but since the earth + is round it isn't exactly north-south as you move east or west of 0, 0, 0). + One unit is one meter and the point 0,0,0 is on the surface of the earth at + sea level for some latitude and longitude picked by the sim such that the + user's aircraft is reasonably nearby. + + 2-d Panel coordinates are 2d, with the X axis horizontal and the Y axis + vertical. The point 0,0 is the bottom left and 1024,768 is the upper + right of the screen. This is true no matter what resolution the user's + monitor is in; when running in higher resolution, graphics will be + scaled. + + Use X-Plane's routines to convert between global and local coordinates. Do + not attempt to do this conversion yourself; the precise 'roundness' of + X-Plane's physics model may not match your own, and (to make things + weirder) the user can potentially customize the physics of the current + planet. +} + +USES + XPLMDefs; + {$A4} +{___________________________________________________________________________ + * X-PLANE GRAPHICS + ___________________________________________________________________________} +{ + These routines allow you to use OpenGL with X-Plane. +} + + + { + XPLMTextureID + + XPLM Texture IDs name well-known textures in the sim for you to use. This + allows you to recycle textures from X-Plane, saving VRAM. + + *Warning*: do not use these enums. The only remaining use they have is to + access the legacy compatibility v10 UI texture; if you need this, get it + via the Widgets library. + } +TYPE + XPLMTextureID = ( + { The bitmap that contains window outlines, button outlines, fonts, etc. } + xplm_Tex_GeneralInterface = 0 + +{$IFDEF XPLM_DEPRECATED} + { The exterior paint for the user's aircraft (daytime). } + ,xplm_Tex_AircraftPaint = 1 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { The exterior light map for the user's aircraft. } + ,xplm_Tex_AircraftLiteMap = 2 +{$ENDIF XPLM_DEPRECATED} + + ); + PXPLMTextureID = ^XPLMTextureID; + + { + XPLMSetGraphicsState + + XPLMSetGraphicsState changes OpenGL's fixed function pipeline state. You + are not responsible for restoring any state that is accessed via + XPLMSetGraphicsState, but you are responsible for not accessing this state + directly. + + - inEnableFog - enables or disables fog, equivalent to: glEnable(GL_FOG); + - inNumberTexUnits - enables or disables a number of multitexturing units. + If the number is 0, 2d texturing is disabled entirely, as in + glDisable(GL_TEXTURE_2D); Otherwise, 2d texturing is enabled, and a + number of multitexturing units are enabled sequentially, starting with + unit 0, e.g. glActiveTextureARB(GL_TEXTURE0_ARB); glEnable + (GL_TEXTURE_2D); + - inEnableLighting - enables or disables OpenGL lighting, e.g. + glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); + - inEnableAlphaTesting - enables or disables the alpha test per pixel, e.g. + glEnable(GL_ALPHA_TEST); + - inEnableAlphaBlending - enables or disables alpha blending per pixel, + e.g. glEnable(GL_BLEND); + - inEnableDepthTesting - enables per pixel depth testing, as in + glEnable(GL_DEPTH_TEST); + - inEnableDepthWriting - enables writing back of depth information to the + depth bufffer, as in glDepthMask(GL_TRUE); + + The purpose of this function is to change OpenGL state while keeping + X-Plane aware of the state changes; this keeps X-Plane from getting + surprised by OGL state changes, and prevents X-Plane and plug-ins from + having to set all state before all draws; XPLMSetGraphicsState internally + skips calls to change state that is already properly enabled. + + X-Plane does not have a 'default' OGL state for plug-ins with respect to + the above state vector; plug-ins should totally set OGL state using this + API before drawing. Use XPLMSetGraphicsState instead of any of the above + OpenGL calls. + + WARNING: Any routine that performs drawing (e.g. XPLMDrawString or widget + code) may change X-Plane's state. Always set state before drawing after + unknown code has executed. + + *Deprecation Warnings*: X-Plane's lighting and fog environemnt is + significantly more complex than the fixed function pipeline can express; + do not assume that lighting and fog state is a good approximation for 3-d + drawing. Prefer to use XPLMInstancing to draw objects. All calls to + XPLMSetGraphicsState should have no fog or lighting. + } + PROCEDURE XPLMSetGraphicsState( + inEnableFog : Integer; + inNumberTexUnits : Integer; + inEnableLighting : Integer; + inEnableAlphaTesting: Integer; + inEnableAlphaBlending: Integer; + inEnableDepthTesting: Integer; + inEnableDepthWriting: Integer); + cdecl; external XPLM_DLL; + + { + XPLMBindTexture2d + + XPLMBindTexture2d changes what texture is bound to the 2d texturing + target. This routine caches the current 2d texture across all texturing + units in the sim and plug-ins, preventing extraneous binding. For + example, consider several plug-ins running in series; if they all use the + 'general interface' bitmap to do UI, calling this function will skip the + rebinding of the general interface texture on all but the first plug-in, + which can provide better frame rate son some graphics cards. + + inTextureID is the ID of the texture object to bind; inTextureUnit is a + zero-based texture unit (e.g. 0 for the first one), up to a maximum of 4 + units. (This number may increase in future versions of X-Plane.) + + Use this routine instead of glBindTexture(GL_TEXTURE_2D, ....); + } + PROCEDURE XPLMBindTexture2d( + inTextureNum : Integer; + inTextureUnit : Integer); + cdecl; external XPLM_DLL; + + { + XPLMGenerateTextureNumbers + + Use this routine instead of glGenTextures to generate new texture object + IDs. This routine historically ensured that plugins don't use texure IDs + that X-Plane is reserving for its own use. + } + PROCEDURE XPLMGenerateTextureNumbers( + outTextureIDs : PInteger; + inCount : Integer); + cdecl; external XPLM_DLL; + +{$IFDEF XPLM_DEPRECATED} + { + XPLMGetTexture + + XPLMGetTexture returns the OpenGL texture ID of an X-Plane texture based on + a generic identifying code. For example, you can get the texture for + X-Plane's UI bitmaps. + } + FUNCTION XPLMGetTexture( + inTexture : XPLMTextureID) : Integer; + cdecl; external XPLM_DLL; +{$ENDIF XPLM_DEPRECATED} + + { + XPLMWorldToLocal + + This routine translates coordinates from latitude, longitude, and altitude + to local scene coordinates. Latitude and longitude are in decimal degrees, + and altitude is in meters MSL (mean sea level). The XYZ coordinates are in + meters in the local OpenGL coordinate system. + } + PROCEDURE XPLMWorldToLocal( + inLatitude : Real; + inLongitude : Real; + inAltitude : Real; + outX : PReal; + outY : PReal; + outZ : PReal); + cdecl; external XPLM_DLL; + + { + XPLMLocalToWorld + + This routine translates a local coordinate triplet back into latitude, + longitude, and altitude. Latitude and longitude are in decimal degrees, + and altitude is in meters MSL (mean sea level). The XYZ coordinates are in + meters in the local OpenGL coordinate system. + + NOTE: world coordinates are less precise than local coordinates; you should + try to avoid round tripping from local to world and back. + } + PROCEDURE XPLMLocalToWorld( + inX : Real; + inY : Real; + inZ : Real; + outLatitude : PReal; + outLongitude : PReal; + outAltitude : PReal); + cdecl; external XPLM_DLL; + + { + XPLMDrawTranslucentDarkBox + + This routine draws a translucent dark box, partially obscuring parts of the + screen but making text easy to read. This is the same graphics primitive + used by X-Plane to show text files and ATC info. + } + PROCEDURE XPLMDrawTranslucentDarkBox( + inLeft : Integer; + inTop : Integer; + inRight : Integer; + inBottom : Integer); + cdecl; external XPLM_DLL; + +{___________________________________________________________________________ + * X-PLANE TEXT + ___________________________________________________________________________} + + { + XPLMFontID + + X-Plane features some fixed-character fonts. Each font may have its own + metrics. + + WARNING: Some of these fonts are no longer supported or may have changed + geometries. For maximum copmatibility, see the comments below. + + Note: X-Plane 7 supports proportional-spaced fonts. Since no measuring + routine is available yet, the SDK will normally draw using a fixed-width + font. You can use a dataref to enable proportional font drawing on XP7 if + you want to. + } +TYPE + XPLMFontID = ( + { Mono-spaced font for user interface. Available in all versions of the SDK.} + xplmFont_Basic = 0 + +{$IFDEF XPLM_DEPRECATED} + { Deprecated, do not use. } + ,xplmFont_Menus = 1 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated, do not use. } + ,xplmFont_Metal = 2 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated, do not use. } + ,xplmFont_Led = 3 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated, do not use. } + ,xplmFont_LedWide = 4 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated, do not use. } + ,xplmFont_PanelHUD = 5 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated, do not use. } + ,xplmFont_PanelEFIS = 6 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated, do not use. } + ,xplmFont_PanelGPS = 7 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated, do not use. } + ,xplmFont_RadiosGA = 8 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated, do not use. } + ,xplmFont_RadiosBC = 9 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated, do not use. } + ,xplmFont_RadiosHM = 10 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated, do not use. } + ,xplmFont_RadiosGANarrow = 11 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated, do not use. } + ,xplmFont_RadiosBCNarrow = 12 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated, do not use. } + ,xplmFont_RadiosHMNarrow = 13 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated, do not use. } + ,xplmFont_Timer = 14 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated, do not use. } + ,xplmFont_FullRound = 15 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated, do not use. } + ,xplmFont_SmallRound = 16 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated, do not use. } + ,xplmFont_Menus_Localized = 17 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM200} + { Proportional UI font. } + ,xplmFont_Proportional = 18 +{$ENDIF XPLM200} + + ); + PXPLMFontID = ^XPLMFontID; + + { + XPLMDrawString + + This routine draws a NULL termianted string in a given font. Pass in the + lower left pixel that the character is to be drawn onto. Also pass the + character and font ID. This function returns the x offset plus the width of + all drawn characters. The color to draw in is specified as a pointer to an + array of three floating point colors, representing RGB intensities from 0.0 + to 1.0. + } + PROCEDURE XPLMDrawString( + inColorRGB : PSingle; + inXOffset : Integer; + inYOffset : Integer; + inChar : XPLMString; + inWordWrapWidth : PInteger; { Can be nil } + inFontID : XPLMFontID); + cdecl; external XPLM_DLL; + + { + XPLMDrawNumber + + This routine draws a number similar to the digit editing fields in + PlaneMaker and data output display in X-Plane. Pass in a color, a + position, a floating point value, and formatting info. Specify how many + integer and how many decimal digits to show and whether to show a sign, as + well as a character set. This routine returns the xOffset plus width of the + string drawn. + } + PROCEDURE XPLMDrawNumber( + inColorRGB : PSingle; + inXOffset : Integer; + inYOffset : Integer; + inValue : Real; + inDigits : Integer; + inDecimals : Integer; + inShowSign : Integer; + inFontID : XPLMFontID); + cdecl; external XPLM_DLL; + + { + XPLMGetFontDimensions + + This routine returns the width and height of a character in a given font. + It also tells you if the font only supports numeric digits. Pass NULL if + you don't need a given field. Note that for a proportional font the width + will be an arbitrary, hopefully average width. + } + PROCEDURE XPLMGetFontDimensions( + inFontID : XPLMFontID; + outCharWidth : PInteger; { Can be nil } + outCharHeight : PInteger; { Can be nil } + outDigitsOnly : PInteger); { Can be nil } + cdecl; external XPLM_DLL; + +{$IFDEF XPLM200} + { + XPLMMeasureString + + This routine returns the width in pixels of a string using a given font. + The string is passed as a pointer plus length (and does not need to be null + terminated); this is used to allow for measuring substrings. The return + value is floating point; it is possible that future font drawing may allow + for fractional pixels. + } + FUNCTION XPLMMeasureString( + inFontID : XPLMFontID; + inChar : XPLMString; + inNumChars : Integer) : Single; + cdecl; external XPLM_DLL; +{$ENDIF XPLM200} + + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/SDK/Delphi/XPLM/XPLMInstance.pas b/XPLPro_Plugin_Source/SDK/SDK/Delphi/XPLM/XPLMInstance.pas new file mode 100644 index 0000000..a38d2bb --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDK/Delphi/XPLM/XPLMInstance.pas @@ -0,0 +1,125 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPLMInstance; +INTERFACE +{ + This API provides instanced drawing of X-Plane objects (.obj files). In + contrast to old drawing APIs, which required you to draw your own objects + per-frame, the instancing API allows you to simply register an OBJ for + drawing, then move or manipulate it later (as needed). + + This provides one tremendous benefit: it keeps all dataref operations for + your object in one place. Because datarefs are main thread only, allowing + dataref access anywhere is a serious performance bottleneck for the + simulator---the whole simulator has to pause and wait for each dataref + access. This performance penalty will only grow worse as X-Plane moves + toward an ever more heavily multithreaded engine. + + The instancing API allows X-Plane to isolate all dataref manipulations for + all plugin object drawing to one place, potentially providing huge + performance gains. + + Here's how it works: + + When an instance is created, it provides a list of all datarefs you want to + manipulate in for the OBJ in the future. This list of datarefs replaces the + ad-hoc collections of dataref objects previously used by art assets. Then, + per-frame, you can manipulate the instance by passing in a "block" of + packed floats representing the current values of the datarefs for your + instance. (Note that the ordering of this set of packed floats must exactly + match the ordering of the datarefs when you created your instance.) +} + +USES + XPLMDefs, XPLMScenery; + {$A4} +{___________________________________________________________________________ + * Instance Creation and Destruction + ___________________________________________________________________________} +{ + Registers and unregisters instances. +} + + +TYPE + { + XPLMInstanceRef + + An opaque handle to an instance. + } + XPLMInstanceRef = pointer; + PXPLMInstanceRef = ^XPLMInstanceRef; + + { + XPLMCreateInstance + + XPLMCreateInstance creates a new instance, managed by your plug-in, and + returns a handle to the instance. A few important requirements: + + * The object passed in must be fully loaded and returned from the XPLM + before you can create your instance; you cannot pass a null obj ref, nor + can you change the ref later. + + * If you use any custom datarefs in your object, they must be registered + before the object is loaded. This is true even if their data will be + provided via the instance dataref list. + + * The instance dataref array must be a valid ptr to an array of at least + one item that is null terminated. That is, if you do not want any + datarefs, you must passa ptr to an array with a null item. You cannot + pass null for this. + } + FUNCTION XPLMCreateInstance( + obj : XPLMObjectRef; + datarefs : PXPLMString) : XPLMInstanceRef; + cdecl; external XPLM_DLL; + + { + XPLMDestroyInstance + + XPLMDestroyInstance destroys and deallocates your instance; once called, + you are still responsible for releasing the OBJ ref. + + Tip: you can release your OBJ ref after you call XPLMCreateInstance as long + as you never use it again; the instance will maintain its own reference to + the OBJ and the object OBJ be deallocated when the instance is destroyed. + } + PROCEDURE XPLMDestroyInstance( + instance : XPLMInstanceRef); + cdecl; external XPLM_DLL; + +{___________________________________________________________________________ + * Instance Manipulation + ___________________________________________________________________________} + + { + XPLMInstanceSetPosition + + Updates both the position of the instance and all datarefs you registered + for it. Call this from a flight loop callback or UI callback. + + __DO NOT__ call XPLMInstanceSetPosition from a drawing callback; the whole + point of instancing is that you do not need any drawing callbacks. Setting + instance data from a drawing callback may have undefined consequences, and + the drawing callback hurts FPS unnecessarily. + + The memory pointed to by the data pointer must be large enough to hold one + float for every data ref you have registered, and must contain valid + floating point data. + + BUG: before X-Plane 11.50, if you have no dataref registered, you must + still pass a valid pointer for data and not null. + } + PROCEDURE XPLMInstanceSetPosition( + instance : XPLMInstanceRef; + new_position : PXPLMDrawInfo_t; + data : PSingle); + cdecl; external XPLM_DLL; + + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/SDK/Delphi/XPLM/XPLMMap.pas b/XPLPro_Plugin_Source/SDK/SDK/Delphi/XPLM/XPLMMap.pas new file mode 100644 index 0000000..ea00ee0 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDK/Delphi/XPLM/XPLMMap.pas @@ -0,0 +1,608 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPLMMap; +INTERFACE +{ + This API allows you to create new layers within X-Plane maps. Your layers + can draw arbitrary OpenGL, but they conveniently also have access to + X-Plane's built-in icon and label drawing functions. + + As of X-Plane 11, map drawing happens in three stages: + + 1. backgrounds and "fill," + 2. icons, and + 3. labels. + + Thus, all background drawing gets layered beneath all icons, which likewise + get layered beneath all labels. Within each stage, the map obeys a + consistent layer ordering, such that "fill" layers (layers that cover a + large amount of map area, like the terrain and clouds) appear beneath + "markings" layers (like airport icons). This ensures that layers with fine + details don't get obscured by layers with larger details. + + The XPLM map API reflects both aspects of this draw layering: you can + register a layer as providing either markings or fill, and X-Plane will + draw your fill layers beneath your markings layers (regardless of + registration order). Likewise, you are guaranteed that your layer's icons + (added from within an icon callback) will go above your layer's OpenGL + drawing, and your labels will go above your icons. + + The XPLM guarantees that all plugin-created fill layers go on top of all + native X-Plane fill layers, and all plugin-created markings layers go on + top of all X-Plane markings layers (with the exception of the aircraft + icons). It also guarantees that the draw order of your own plugin's layers + will be consistent. But, for layers created by different plugins, the only + guarantee is that we will draw all of one plugin's layers of each type + (fill, then markings), then all of the others'; we don't guarantee which + plugin's fill and markings layers go on top of the other's. + + As of X-Plane 11, maps use true cartographic projections for their drawing, + and different maps may use different projections. For that reason, all + drawing calls include an opaque handle for the projection you should use to + do the drawing. Any time you would draw at a particular latitude/longitude, + you'll need to ask the projection to translate that position into "map + coordinates." (Note that the projection is guaranteed not to change between + calls to your prepare-cache hook, so if you cache your map coordinates + ahead of time, there's no need to re-project them when you actually draw.) + + In addition to mapping normal latitude/longitude locations into map + coordinates, the projection APIs also let you know the current heading for + north. (Since X-Plane 11 maps can rotate to match the heading of the user's + aircraft, it's not safe to assume that north is at zero degrees rotation.) +} + +USES + XPLMDefs; + {$A4} +{$IFDEF XPLM300} +{___________________________________________________________________________ + * DRAWING CALLBACKS + ___________________________________________________________________________} +{ + When you create a new map layer (using XPLMCreateMapLayer), you can provide + any or all of these callbacks. They allow you to insert your own OpenGL + drawing, text labels, and icons into the X-Plane map at the appropriate + places, allowing your layer to behave as similarly to X-Plane's built-in + layers as possible. +} + + +TYPE + { + XPLMMapLayerID + + This is an opaque handle for a plugin-created map layer. Pass it to the map + drawing APIs from an appropriate callback to draw in the layer you created. + } + XPLMMapLayerID = pointer; + PXPLMMapLayerID = ^XPLMMapLayerID; + + { + XPLMMapProjectionID + + This is an opaque handle for a map projection. Pass it to the projection + APIs to translate between map coordinates and latitude/longitudes. + } + XPLMMapProjectionID = pointer; + PXPLMMapProjectionID = ^XPLMMapProjectionID; + + { + XPLMMapStyle + + Indicates the visual style being drawn by the map. In X-Plane, the user can + choose between a number of map types, and different map types may have use + a different visual representation for the same elements (for instance, the + visual style of the terrain layer changes drastically between the VFR and + IFR layers), or certain layers may be disabled entirely in some map types + (e.g., localizers are only visible in the IFR low-enroute style). + } + XPLMMapStyle = ( + xplm_MapStyle_VFR_Sectional = 0 + + ,xplm_MapStyle_IFR_LowEnroute = 1 + + ,xplm_MapStyle_IFR_HighEnroute = 2 + + ); + PXPLMMapStyle = ^XPLMMapStyle; + + { + XPLMMapDrawingCallback_f + + This is the OpenGL map drawing callback for plugin-created map layers. You + can perform arbitrary OpenGL drawing from this callback, with one + exception: changes to the Z-buffer are not permitted, and will result in + map drawing errors. + + All drawing done from within this callback appears beneath all built-in + X-Plane icons and labels, but above the built-in "fill" layers (layers + providing major details, like terrain and water). Note, however, that the + relative ordering between the drawing callbacks of different plugins is not + guaranteed. + } + XPLMMapDrawingCallback_f = PROCEDURE( + inLayer : XPLMMapLayerID; + inMapBoundsLeftTopRightBottom: PSingle; + zoomRatio : Single; + mapUnitsPerUserInterfaceUnit: Single; + mapStyle : XPLMMapStyle; + projection : XPLMMapProjectionID; + inRefcon : pointer); cdecl; + + { + XPLMMapIconDrawingCallback_f + + This is the icon drawing callback that enables plugin-created map layers to + draw icons using X-Plane's built-in icon drawing functionality. You can + request an arbitrary number of PNG icons to be drawn via + XPLMDrawMapIconFromSheet() from within this callback, but you may not + perform any OpenGL drawing here. + + Icons enqueued by this function will appear above all OpenGL drawing + (performed by your optional XPLMMapDrawingCallback_f), and above all + built-in X-Plane map icons of the same layer type ("fill" or "markings," as + determined by the XPLMMapLayerType in your XPLMCreateMapLayer_t). Note, + however, that the relative ordering between the drawing callbacks of + different plugins is not guaranteed. + } + XPLMMapIconDrawingCallback_f = PROCEDURE( + inLayer : XPLMMapLayerID; + inMapBoundsLeftTopRightBottom: PSingle; + zoomRatio : Single; + mapUnitsPerUserInterfaceUnit: Single; + mapStyle : XPLMMapStyle; + projection : XPLMMapProjectionID; + inRefcon : pointer); cdecl; + + { + XPLMMapLabelDrawingCallback_f + + This is the label drawing callback that enables plugin-created map layers + to draw text labels using X-Plane's built-in labeling functionality. You + can request an arbitrary number of text labels to be drawn via + XPLMDrawMapLabel() from within this callback, but you may not perform any + OpenGL drawing here. + + Labels enqueued by this function will appear above all OpenGL drawing + (performed by your optional XPLMMapDrawingCallback_f), and above all + built-in map icons and labels of the same layer type ("fill" or "markings," + as determined by the XPLMMapLayerType in your XPLMCreateMapLayer_t). Note, + however, that the relative ordering between the drawing callbacks of + different plugins is not guaranteed. + } + XPLMMapLabelDrawingCallback_f = PROCEDURE( + inLayer : XPLMMapLayerID; + inMapBoundsLeftTopRightBottom: PSingle; + zoomRatio : Single; + mapUnitsPerUserInterfaceUnit: Single; + mapStyle : XPLMMapStyle; + projection : XPLMMapProjectionID; + inRefcon : pointer); cdecl; + +{$ENDIF XPLM300} +{$IFDEF XPLM300} +{___________________________________________________________________________ + * LAYER MANAGEMENT CALLBACKS + ___________________________________________________________________________} +{ + These are various "bookkeeping" callbacks that your map layer can receive + (if you provide the callback in your XPLMCreateMapLayer_t). They allow you + to manage the lifecycle of your layer, as well as cache any + computationally-intensive preparation you might need for drawing. +} + + + { + XPLMMapPrepareCacheCallback_f + + A callback used to allow you to cache whatever information your layer needs + to draw in the current map area. + + This is called each time the map's total bounds change. This is typically + triggered by new DSFs being loaded, such that X-Plane discards old, + now-distant DSFs and pulls in new ones. At that point, the available bounds + of the map also change to match the new DSF area. + + By caching just the information you need to draw in this area, your future + draw calls can be made faster, since you'll be able to simply "splat" your + precomputed information each frame. + + We guarantee that the map projection will not change between successive + prepare cache calls, nor will any draw call give you bounds outside these + total map bounds. So, if you cache the projected map coordinates of all the + items you might want to draw in the total map area, you can be guaranteed + that no draw call will be asked to do any new work. + } +TYPE + XPLMMapPrepareCacheCallback_f = PROCEDURE( + inLayer : XPLMMapLayerID; + inTotalMapBoundsLeftTopRightBottom: PSingle; + projection : XPLMMapProjectionID; + inRefcon : pointer); cdecl; + + { + XPLMMapWillBeDeletedCallback_f + + Called just before your map layer gets deleted. Because SDK-created map + layers have the same lifetime as the X-Plane map that contains them, if the + map gets unloaded from memory, your layer will too. + } + XPLMMapWillBeDeletedCallback_f = PROCEDURE( + inLayer : XPLMMapLayerID; + inRefcon : pointer); cdecl; + +{$ENDIF XPLM300} +{$IFDEF XPLM300} +{___________________________________________________________________________ + * MAP LAYER CREATION AND DESTRUCTION + ___________________________________________________________________________} +{ + Enables the creation of new map layers. Layers are created for a particular + instance of the X-Plane map. For instance, if you want your layer to appear + in both the normal map interface and the Instructor Operator Station (IOS), + you would need two separate calls to XPLMCreateMapLayer(), with two + different values for your XPLMCreateMapLayer_t::layer_name. + + Your layer's lifetime will be determined by the lifetime of the map it is + created in. If the map is destroyed (on the X-Plane side), your layer will + be too, and you'll receive a callback to your + XPLMMapWillBeDeletedCallback_f. +} + + + { + XPLMMapLayerType + + Indicates the type of map layer you are creating. Fill layers will always + be drawn beneath markings layers. + } +TYPE + XPLMMapLayerType = ( + { A layer that draws "fill" graphics, like weather patterns, terrain, etc. } + { Fill layers frequently cover a large portion of the visible map area. } + xplm_MapLayer_Fill = 0 + + { A layer that provides markings for particular map features, like NAVAIDs, } + { airports, etc. Even dense markings layers cover a small portion of the } + { total map area. } + ,xplm_MapLayer_Markings = 1 + + ); + PXPLMMapLayerType = ^XPLMMapLayerType; + +CONST + { Globally unique identifier for X-Plane's Map window, used as the } + { mapToCreateLayerIn parameter in XPLMCreateMapLayer_t } + XPLM_MAP_USER_INTERFACE = "XPLM_MAP_USER_INTERFACE"; + + { Globally unique identifier for X-Plane's Instructor Operator Station } + { window, used as the mapToCreateLayerIn parameter in XPLMCreateMapLayer_t } + XPLM_MAP_IOS = "XPLM_MAP_IOS"; + + { + XPLMCreateMapLayer_t + + This structure defines all of the parameters used to create a map layer + using XPLMCreateMapLayer. The structure will be expanded in future SDK APIs + to include more features. Always set the structSize member to the size of + your struct in bytes! + + Each layer must be associated with exactly one map instance in X-Plane. + That map, and that map alone, will call your callbacks. Likewise, when that + map is deleted, your layer will be as well. + } +TYPE + XPLMCreateMapLayer_t = RECORD + { Used to inform XPLMCreateMapLayer() of the SDK version you compiled } + { against; should always be set to sizeof(XPLMCreateMapLayer_t) } + structSize : Integer; + { Globally unique string identifying the map you want this layer to appear } + { in. As of XPLM300, this is limited to one of XPLM_MAP_USER_INTERFACE or } + { XPLM_MAP_IOS } + mapToCreateLayerIn : XPLMString; + { The type of layer you are creating, used to determine draw order (all } + { plugin-created markings layers are drawn above all plugin-created fill } + { layers) } + layerType : XPLMMapLayerType; + { Optional callback to inform you this layer is being deleted (due to its } + { owning map being destroyed) } + willBeDeletedCallback : XPLMMapWillBeDeletedCallback_f; + { Optional callback you want to use to prepare your draw cache when the map } + { bounds change (set to NULL if you don't want this callback) } + prepCacheCallback : XPLMMapPrepareCacheCallback_f; + { Optional callback you want to use for arbitrary OpenGL drawing, which goes } + { beneath all icons in the map's layering system (set to NULL if you don't } + { want this callback) } + drawCallback : XPLMMapDrawingCallback_f; + { Optional callback you want to use for drawing icons, which go above all } + { built-in X-Plane icons (except the aircraft) in the map's layering system } + { (set to NULL if you don't want this callback) } + iconCallback : XPLMMapIconDrawingCallback_f; + { Optional callback you want to use for drawing map labels, which go above } + { all built-in X-Plane icons and labels (except those of aircraft) in the } + { map's layering system (set to NULL if you don't want this callback) } + labelCallback : XPLMMapLabelDrawingCallback_f; + { True if you want a checkbox to be created in the map UI to toggle this } + { layer on and off; false if the layer should simply always be enabled } + showUiToggle : Integer; + { Short label to use for this layer in the user interface } + layerName : XPLMString; + { A reference to arbitrary data that will be passed to your callbacks } + refcon : pointer; + END; + PXPLMCreateMapLayer_t = ^XPLMCreateMapLayer_t; + + { + XPLMCreateMapLayer + + This routine creates a new map layer. You pass in an XPLMCreateMapLayer_t + structure with all of the fields set in. You must set the structSize of + the structure to the size of the actual structure you used. + + Returns NULL if the layer creation failed. This happens most frequently + because the map you specified in your + XPLMCreateMapLayer_t::mapToCreateLayerIn field doesn't exist (that is, if + XPLMMapExists() returns 0 for the specified map). You can use + XPLMRegisterMapCreationHook() to get a notification each time a new map is + opened in X-Plane, at which time you can create layers in it. + } + FUNCTION XPLMCreateMapLayer( + inParams : PXPLMCreateMapLayer_t) : XPLMMapLayerID; + cdecl; external XPLM_DLL; + + { + XPLMDestroyMapLayer + + Destroys a map layer you created (calling your + XPLMMapWillBeDeletedCallback_f if applicable). Returns true if a deletion + took place. + } + FUNCTION XPLMDestroyMapLayer( + inLayer : XPLMMapLayerID) : Integer; + cdecl; external XPLM_DLL; + + { + XPLMMapCreatedCallback_f + + A callback to notify your plugin that a new map has been created in + X-Plane. This is the best time to add a custom map layer using + XPLMCreateMapLayer(). + + No OpenGL drawing is permitted within this callback. + } +TYPE + XPLMMapCreatedCallback_f = PROCEDURE( + mapIdentifier : XPLMString; + refcon : pointer); cdecl; + + { + XPLMRegisterMapCreationHook + + Registers your callback to receive a notification each time a new map is + constructed in X-Plane. This callback is the best time to add your custom + map layer using XPLMCreateMapLayer(). + + Note that you will not be notified about any maps that already exist---you + can use XPLMMapExists() to check for maps that were created previously. + } + PROCEDURE XPLMRegisterMapCreationHook( + callback : XPLMMapCreatedCallback_f; + refcon : pointer); + cdecl; external XPLM_DLL; + + { + XPLMMapExists + + Returns 1 if the map with the specified identifier already exists in + X-Plane. In that case, you can safely call XPLMCreateMapLayer() specifying + that your layer should be added to that map. + } + FUNCTION XPLMMapExists( + mapIdentifier : XPLMString) : Integer; + cdecl; external XPLM_DLL; + +{$ENDIF XPLM300} +{$IFDEF XPLM300} +{___________________________________________________________________________ + * MAP DRAWING + ___________________________________________________________________________} +{ + These APIs are only valid from within a map drawing callback (one of + XPLMIconDrawingCallback_t or XPLMMapLabelDrawingCallback_f). Your drawing + callbacks are registered when you create a new map layer as part of your + XPLMCreateMapLayer_t. The functions here hook into X-Plane's built-in map + drawing functionality for icons and labels, so that you get a consistent + style with the rest of the X-Plane map. + + Note that the X-Plane 11 map introduces a strict ordering: layers of type + xplm_MapLayer_Fill get drawn beneath all xplm_MapLayer_Markings layers. + Likewise, all OpenGL drawing (performed in your layer's + XPLMMapDrawingCallback_f) will appear beneath any icons and labels you + draw. +} + + + { + XPLMMapOrientation + + Indicates whether a map element should be match its rotation to the map + itself, or to the user interface. For instance, the map itself may be + rotated such that "up" matches the user's aircraft, but you may want to + draw a text label such that it is always rotated zero degrees relative to + the user's perspective. In that case, you would have it draw with UI + orientation. + } +TYPE + XPLMMapOrientation = ( + { Orient such that a 0 degree rotation matches the map's north } + xplm_MapOrientation_Map = 0 + + { Orient such that a 0 degree rotation is "up" relative to the user interface} + ,xplm_MapOrientation_UI = 1 + + ); + PXPLMMapOrientation = ^XPLMMapOrientation; + + { + XPLMDrawMapIconFromSheet + + Enables plugin-created map layers to draw PNG icons using X-Plane's + built-in icon drawing functionality. Only valid from within an + XPLMIconDrawingCallback_t (but you can request an arbitrary number of icons + to be drawn from within your callback). + + X-Plane will automatically manage the memory for your texture so that it + only has to be loaded from disk once as long as you continue drawing it + per-frame. (When you stop drawing it, the memory may purged in a "garbage + collection" pass, require a load from disk in the future.) + + Instead of having X-Plane draw a full PNG, this method allows you to use UV + coordinates to request a portion of the image to be drawn. This allows you + to use a single texture load (of an icon sheet, for example) to draw many + icons. Doing so is much more efficient than drawing a dozen different small + PNGs. + + The UV coordinates used here treat the texture you load as being comprised + of a number of identically sized "cells." You specify the width and height + in cells (ds and dt, respectively), as well as the coordinates within the + cell grid for the sub-image you'd like to draw. + + Note that you can use different ds and dt values in subsequent calls with + the same texture sheet. This enables you to use icons of different sizes in + the same sheet if you arrange them properly in the PNG. + + This function is only valid from within an XPLMIconDrawingCallback_t (but + you can request an arbitrary number of icons to be drawn from within your + callback). + } + PROCEDURE XPLMDrawMapIconFromSheet( + layer : XPLMMapLayerID; + inPngPath : XPLMString; + s : Integer; + t : Integer; + ds : Integer; + dt : Integer; + mapX : Single; + mapY : Single; + orientation : XPLMMapOrientation; + rotationDegrees : Single; + mapWidth : Single); + cdecl; external XPLM_DLL; + + { + XPLMDrawMapLabel + + Enables plugin-created map layers to draw text labels using X-Plane's + built-in labeling functionality. Only valid from within an + XPLMMapLabelDrawingCallback_f (but you can request an arbitrary number of + text labels to be drawn from within your callback). + } + PROCEDURE XPLMDrawMapLabel( + layer : XPLMMapLayerID; + inText : XPLMString; + mapX : Single; + mapY : Single; + orientation : XPLMMapOrientation; + rotationDegrees : Single); + cdecl; external XPLM_DLL; + +{$ENDIF XPLM300} +{$IFDEF XPLM300} +{___________________________________________________________________________ + * MAP PROJECTIONS + ___________________________________________________________________________} +{ + As of X-Plane 11, the map draws using true cartographic projections, and + different maps may use different projections. Thus, to draw at a particular + latitude and longitude, you must first transform your real-world + coordinates into map coordinates. + + The map projection is also responsible for giving you the current scale of + the map. That is, the projection can tell you how many map units correspond + to 1 meter at a given point. + + Finally, the map projection can give you the current rotation of the map. + Since X-Plane 11 maps can rotate to match the heading of the aircraft, the + map's rotation can potentially change every frame. +} + + + { + XPLMMapProject + + Projects a latitude/longitude into map coordinates. This is the inverse of + XPLMMapUnproject(). + + Only valid from within a map layer callback (one of + XPLMMapPrepareCacheCallback_f, XPLMMapDrawingCallback_f, + XPLMMapIconDrawingCallback_f, or XPLMMapLabelDrawingCallback_f.) + } + PROCEDURE XPLMMapProject( + projection : XPLMMapProjectionID; + latitude : Real; + longitude : Real; + outX : PSingle; + outY : PSingle); + cdecl; external XPLM_DLL; + + { + XPLMMapUnproject + + Transforms map coordinates back into a latitude and longitude. This is the + inverse of XPLMMapProject(). + + Only valid from within a map layer callback (one of + XPLMMapPrepareCacheCallback_f, XPLMMapDrawingCallback_f, + XPLMMapIconDrawingCallback_f, or XPLMMapLabelDrawingCallback_f.) + } + PROCEDURE XPLMMapUnproject( + projection : XPLMMapProjectionID; + mapX : Single; + mapY : Single; + outLatitude : PReal; + outLongitude : PReal); + cdecl; external XPLM_DLL; + + { + XPLMMapScaleMeter + + Returns the number of map units that correspond to a distance of one meter + at a given set of map coordinates. + + Only valid from within a map layer callback (one of + XPLMMapPrepareCacheCallback_f, XPLMMapDrawingCallback_f, + XPLMMapIconDrawingCallback_f, or XPLMMapLabelDrawingCallback_f.) + } + FUNCTION XPLMMapScaleMeter( + projection : XPLMMapProjectionID; + mapX : Single; + mapY : Single) : Single; + cdecl; external XPLM_DLL; + + { + XPLMMapGetNorthHeading + + Returns the heading (in degrees clockwise) from the positive Y axis in the + cartesian mapping coordinate system to true north at the point passed in. + You can use it as a clockwise rotational offset to align icons and other + 2-d drawing with true north on the map, compensating for rotations in the + map due to projection. + + Only valid from within a map layer callback (one of + XPLMMapPrepareCacheCallback_f, XPLMMapDrawingCallback_f, + XPLMMapIconDrawingCallback_f, or XPLMMapLabelDrawingCallback_f.) + } + FUNCTION XPLMMapGetNorthHeading( + projection : XPLMMapProjectionID; + mapX : Single; + mapY : Single) : Single; + cdecl; external XPLM_DLL; + +{$ENDIF XPLM300} + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/SDK/Delphi/XPLM/XPLMMenus.pas b/XPLPro_Plugin_Source/SDK/SDK/Delphi/XPLM/XPLMMenus.pas new file mode 100644 index 0000000..754a434 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDK/Delphi/XPLM/XPLMMenus.pas @@ -0,0 +1,277 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPLMMenus; +INTERFACE +{ + Plug-ins can create menus in the menu bar of X-Plane. This is done by + creating a menu and then creating items. Menus are referred to by an + opaque ID. Items are referred to by (zero-based) index number. + + Menus are "sandboxed" between plugins---no plugin can access the menus of + any other plugin. Furthermore, all menu indices are relative to your + plugin's menus only; if your plugin creates two sub-menus in the Plugins + menu at different times, it doesn't matter how many other plugins also + create sub-menus of Plugins in the intervening time: your sub-menus will be + given menu indices 0 and 1. (The SDK does some work in the back-end to + filter out menus that are irrelevant to your plugin in order to deliver + this consistency for each plugin.) + + When you create a menu item, you specify how we should handle clicks on + that menu item. You can either have the XPLM trigger a callback (the + XPLMMenuHandler_f associated with the menu that contains the item), or you + can simply have a command be triggered (with no associated call to your + menu handler). The advantage of the latter method is that X-Plane will + display any keyboard shortcuts associated with the command. (In contrast, + there are no keyboard shortcuts associated with menu handler callbacks with + specific parameters.) + + Menu text in X-Plane is UTF8; X-Plane's character set covers latin, greek + and cyrillic characters, Katakana, as well as some Japanese symbols. Some + APIs have a inDeprecatedAndIgnored parameter that used to select a + character set; since X-Plane 9 all localization is done via UTF-8 only. +} + +USES + XPLMDefs, XPLMUtilities; + {$A4} +{___________________________________________________________________________ + * XPLM MENUS + ___________________________________________________________________________} + + { + XPLMMenuCheck + + These enumerations define the various 'check' states for an X-Plane menu. + 'checking' in X-Plane actually appears as a light which may or may not be + lit. So there are three possible states. + } +TYPE + XPLMMenuCheck = ( + { there is no symbol to the left of the menu item. } + xplm_Menu_NoCheck = 0 + + { the menu has a mark next to it that is unmarked (not lit). } + ,xplm_Menu_Unchecked = 1 + + { the menu has a mark next to it that is checked (lit). } + ,xplm_Menu_Checked = 2 + + ); + PXPLMMenuCheck = ^XPLMMenuCheck; + + { + XPLMMenuID + + This is a unique ID for each menu you create. + } + XPLMMenuID = pointer; + PXPLMMenuID = ^XPLMMenuID; + + { + XPLMMenuHandler_f + + A menu handler function takes two reference pointers, one for the menu + (specified when the menu was created) and one for the item (specified when + the item was created). + } + XPLMMenuHandler_f = PROCEDURE( + inMenuRef : pointer; + inItemRef : pointer); cdecl; + + { + XPLMFindPluginsMenu + + This function returns the ID of the plug-ins menu, which is created for you + at startup. + } + FUNCTION XPLMFindPluginsMenu: XPLMMenuID; + cdecl; external XPLM_DLL; + +{$IFDEF XPLM300} + { + XPLMFindAircraftMenu + + This function returns the ID of the menu for the currently-loaded aircraft, + used for showing aircraft-specific commands. + + The aircraft menu is created by X-Plane at startup, but it remains hidden + until it is populated via XPLMAppendMenuItem() or + XPLMAppendMenuItemWithCommand(). + + Only plugins loaded with the user's current aircraft are allowed to access + the aircraft menu. For all other plugins, this will return NULL, and any + attempts to add menu items to it will fail. + } + FUNCTION XPLMFindAircraftMenu: XPLMMenuID; + cdecl; external XPLM_DLL; +{$ENDIF XPLM300} + + { + XPLMCreateMenu + + This function creates a new menu and returns its ID. It returns NULL if + the menu cannot be created. Pass in a parent menu ID and an item index to + create a submenu, or NULL for the parent menu to put the menu in the menu + bar. The menu's name is only used if the menu is in the menubar. You also + pass a handler function and a menu reference value. Pass NULL for the + handler if you do not need callbacks from the menu (for example, if it only + contains submenus). + + Important: you must pass a valid, non-empty menu title even if the menu is + a submenu where the title is not visible. + } + FUNCTION XPLMCreateMenu( + inName : XPLMString; + inParentMenu : XPLMMenuID; + inParentItem : Integer; + inHandler : XPLMMenuHandler_f; + inMenuRef : pointer) : XPLMMenuID; + cdecl; external XPLM_DLL; + + { + XPLMDestroyMenu + + This function destroys a menu that you have created. Use this to remove a + submenu if necessary. (Normally this function will not be necessary.) + } + PROCEDURE XPLMDestroyMenu( + inMenuID : XPLMMenuID); + cdecl; external XPLM_DLL; + + { + XPLMClearAllMenuItems + + This function removes all menu items from a menu, allowing you to rebuild + it. Use this function if you need to change the number of items on a menu. + } + PROCEDURE XPLMClearAllMenuItems( + inMenuID : XPLMMenuID); + cdecl; external XPLM_DLL; + + { + XPLMAppendMenuItem + + This routine appends a new menu item to the bottom of a menu and returns + its index. Pass in the menu to add the item to, the items name, and a void + * ref for this item. + + Returns a negative index if the append failed (due to an invalid parent + menu argument). + + Note that all menu indices returned are relative to your plugin's menus + only; if your plugin creates two sub-menus in the Plugins menu at different + times, it doesn't matter how many other plugins also create sub-menus of + Plugins in the intervening time: your sub-menus will be given menu indices + 0 and 1. (The SDK does some work in the back-end to filter out menus that + are irrelevant to your plugin in order to deliver this consistency for each + plugin.) + } + FUNCTION XPLMAppendMenuItem( + inMenu : XPLMMenuID; + inItemName : XPLMString; + inItemRef : pointer; + inDeprecatedAndIgnored: Integer) : Integer; + cdecl; external XPLM_DLL; + +{$IFDEF XPLM300} + { + XPLMAppendMenuItemWithCommand + + Like XPLMAppendMenuItem(), but instead of the new menu item triggering the + XPLMMenuHandler_f of the containiner menu, it will simply execute the + command you pass in. Using a command for your menu item allows the user to + bind a keyboard shortcut to the command and see that shortcut represented + in the menu. + + Returns a negative index if the append failed (due to an invalid parent + menu argument). + + Like XPLMAppendMenuItem(), all menu indices are relative to your plugin's + menus only. + } + FUNCTION XPLMAppendMenuItemWithCommand( + inMenu : XPLMMenuID; + inItemName : XPLMString; + inCommandToExecute : XPLMCommandRef) : Integer; + cdecl; external XPLM_DLL; +{$ENDIF XPLM300} + + { + XPLMAppendMenuSeparator + + This routine adds a separator to the end of a menu. + + Returns a negative index if the append failed (due to an invalid parent + menu argument). + } + PROCEDURE XPLMAppendMenuSeparator( + inMenu : XPLMMenuID); + cdecl; external XPLM_DLL; + + { + XPLMSetMenuItemName + + This routine changes the name of an existing menu item. Pass in the menu + ID and the index of the menu item. + } + PROCEDURE XPLMSetMenuItemName( + inMenu : XPLMMenuID; + inIndex : Integer; + inItemName : XPLMString; + inDeprecatedAndIgnored: Integer); + cdecl; external XPLM_DLL; + + { + XPLMCheckMenuItem + + Set whether a menu item is checked. Pass in the menu ID and item index. + } + PROCEDURE XPLMCheckMenuItem( + inMenu : XPLMMenuID; + index : Integer; + inCheck : XPLMMenuCheck); + cdecl; external XPLM_DLL; + + { + XPLMCheckMenuItemState + + This routine returns whether a menu item is checked or not. A menu item's + check mark may be on or off, or a menu may not have an icon at all. + } + PROCEDURE XPLMCheckMenuItemState( + inMenu : XPLMMenuID; + index : Integer; + outCheck : PXPLMMenuCheck); + cdecl; external XPLM_DLL; + + { + XPLMEnableMenuItem + + Sets whether this menu item is enabled. Items start out enabled. + } + PROCEDURE XPLMEnableMenuItem( + inMenu : XPLMMenuID; + index : Integer; + enabled : Integer); + cdecl; external XPLM_DLL; + +{$IFDEF XPLM210} + { + XPLMRemoveMenuItem + + Removes one item from a menu. Note that all menu items below are moved up + one; your plugin must track the change in index numbers. + } + PROCEDURE XPLMRemoveMenuItem( + inMenu : XPLMMenuID; + inIndex : Integer); + cdecl; external XPLM_DLL; +{$ENDIF XPLM210} + + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/SDK/Delphi/XPLM/XPLMNavigation.pas b/XPLPro_Plugin_Source/SDK/SDK/Delphi/XPLM/XPLMNavigation.pas new file mode 100644 index 0000000..044b99b --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDK/Delphi/XPLM/XPLMNavigation.pas @@ -0,0 +1,350 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPLMNavigation; +INTERFACE +{ + The XPLM Navigation APIs give you some access to the navigation databases + inside X-Plane. X-Plane stores all navigation information in RAM, so by + using these APIs you can gain access to most information without having to + go to disk or parse the files yourself. + + You can also use this API to program the FMS. You must use the navigation + APIs to find the nav-aids you want to program into the FMS, since the FMS + is powered internally by X-Plane's navigation database. +} + +USES + XPLMDefs; + {$A4} +{___________________________________________________________________________ + * NAVIGATION DATABASE ACCESS + ___________________________________________________________________________} + + { + XPLMNavType + + These enumerations define the different types of navaids. They are each + defined with a separate bit so that they may be bit-wise added together to + form sets of nav-aid types. + + NOTE: xplm_Nav_LatLon is a specific lat-lon coordinate entered into the + FMS. It will not exist in the database, and cannot be programmed into the + FMS. Querying the FMS for navaids will return it. Use + XPLMSetFMSEntryLatLon to set a lat/lon waypoint. + } +TYPE + XPLMNavType = ( + xplm_Nav_Unknown = 0 + + ,xplm_Nav_Airport = 1 + + ,xplm_Nav_NDB = 2 + + ,xplm_Nav_VOR = 4 + + ,xplm_Nav_ILS = 8 + + ,xplm_Nav_Localizer = 16 + + ,xplm_Nav_GlideSlope = 32 + + ,xplm_Nav_OuterMarker = 64 + + ,xplm_Nav_MiddleMarker = 128 + + ,xplm_Nav_InnerMarker = 256 + + ,xplm_Nav_Fix = 512 + + ,xplm_Nav_DME = 1024 + + ,xplm_Nav_LatLon = 2048 + + ); + PXPLMNavType = ^XPLMNavType; + + { + XPLMNavRef + + XPLMNavRef is an iterator into the navigation database. The navigation + database is essentially an array, but it is not necessarily densely + populated. The only assumption you can safely make is that like-typed + nav-aids are grouped together. + + Use XPLMNavRef to refer to a nav-aid. + + XPLM_NAV_NOT_FOUND is returned by functions that return an XPLMNavRef when + the iterator must be invalid. + } + XPLMNavRef = Integer; + PXPLMNavRef = ^XPLMNavRef; + +CONST + XPLM_NAV_NOT_FOUND = -1; + + { + XPLMGetFirstNavAid + + This returns the very first navaid in the database. Use this to traverse + the entire database. Returns XPLM_NAV_NOT_FOUND if the nav database is + empty. + } + FUNCTION XPLMGetFirstNavAid: XPLMNavRef; + cdecl; external XPLM_DLL; + + { + XPLMGetNextNavAid + + Given a valid nav aid ref, this routine returns the next navaid. It + returns XPLM_NAV_NOT_FOUND if the nav aid passed in was invalid or if the + navaid passed in was the last one in the database. Use this routine to + iterate across all like-typed navaids or the entire database. + } + FUNCTION XPLMGetNextNavAid( + inNavAidRef : XPLMNavRef) : XPLMNavRef; + cdecl; external XPLM_DLL; + + { + XPLMFindFirstNavAidOfType + + This routine returns the ref of the first navaid of the given type in the + database or XPLM_NAV_NOT_FOUND if there are no navaids of that type in the + database. You must pass exactly one nav aid type to this routine. + } + FUNCTION XPLMFindFirstNavAidOfType( + inType : XPLMNavType) : XPLMNavRef; + cdecl; external XPLM_DLL; + + { + XPLMFindLastNavAidOfType + + This routine returns the ref of the last navaid of the given type in the + database or XPLM_NAV_NOT_FOUND if there are no navaids of that type in the + database. You must pass exactly one nav aid type to this routine. + } + FUNCTION XPLMFindLastNavAidOfType( + inType : XPLMNavType) : XPLMNavRef; + cdecl; external XPLM_DLL; + + { + XPLMFindNavAid + + This routine provides a number of searching capabilities for the nav + database. XPLMFindNavAid will search through every nav aid whose type is + within inType (multiple types may be added together) and return any + nav-aids found based on the following rules: + + * If inLat and inLon are not NULL, the navaid nearest to that lat/lon will + be returned, otherwise the last navaid found will be returned. + + * If inFrequency is not NULL, then any navaids considered must match this + frequency. Note that this will screen out radio beacons that do not have + frequency data published (like inner markers) but not fixes and airports. + + * If inNameFragment is not NULL, only navaids that contain the fragment in + their name will be returned. + + * If inIDFragment is not NULL, only navaids that contain the fragment in + their IDs will be returned. + + This routine provides a simple way to do a number of useful searches: + * Find the nearest navaid on this frequency. + * Find the nearest airport. + * Find the VOR whose ID is "KBOS". + * Find the nearest airport whose name contains "Chicago". + } + FUNCTION XPLMFindNavAid( + inNameFragment : XPLMString; { Can be nil } + inIDFragment : XPLMString; { Can be nil } + inLat : PSingle; { Can be nil } + inLon : PSingle; { Can be nil } + inFrequency : PInteger; { Can be nil } + inType : XPLMNavType) : XPLMNavRef; + cdecl; external XPLM_DLL; + + { + XPLMGetNavAidInfo + + This routine returns information about a navaid. Any non-null field is + filled out with information if it is available. + + Frequencies are in the nav.dat convention as described in the X-Plane nav + database FAQ: NDB frequencies are exact, all others are multiplied by 100. + + The buffer for IDs should be at least 6 chars and the buffer for names + should be at least 41 chars, but since these values are likely to go up, I + recommend passing at least 32 chars for IDs and 256 chars for names when + possible. + + The outReg parameter tells if the navaid is within the local "region" of + loaded DSFs. (This information may not be particularly useful to plugins.) + The parameter is a single byte value 1 for true or 0 for false, not a C + string. + } + PROCEDURE XPLMGetNavAidInfo( + inRef : XPLMNavRef; + outType : PXPLMNavType; { Can be nil } + outLatitude : PSingle; { Can be nil } + outLongitude : PSingle; { Can be nil } + outHeight : PSingle; { Can be nil } + outFrequency : PInteger; { Can be nil } + outHeading : PSingle; { Can be nil } + outID : XPLMString; { Can be nil } + outName : XPLMString; { Can be nil } + outReg : XPLMString); { Can be nil } + cdecl; external XPLM_DLL; + +{___________________________________________________________________________ + * FLIGHT MANAGEMENT COMPUTER + ___________________________________________________________________________} +{ + Note: the FMS works based on an array of entries. Indices into the array + are zero-based. Each entry is a nav-aid plus an altitude. The FMS tracks + the currently displayed entry and the entry that it is flying to. + + The FMS must be programmed with contiguous entries, so clearing an entry at + the end shortens the effective flight plan. There is a max of 100 + waypoints in the flight plan. +} + + + { + XPLMCountFMSEntries + + This routine returns the number of entries in the FMS. + } + FUNCTION XPLMCountFMSEntries: Integer; + cdecl; external XPLM_DLL; + + { + XPLMGetDisplayedFMSEntry + + This routine returns the index of the entry the pilot is viewing. + } + FUNCTION XPLMGetDisplayedFMSEntry: Integer; + cdecl; external XPLM_DLL; + + { + XPLMGetDestinationFMSEntry + + This routine returns the index of the entry the FMS is flying to. + } + FUNCTION XPLMGetDestinationFMSEntry: Integer; + cdecl; external XPLM_DLL; + + { + XPLMSetDisplayedFMSEntry + + This routine changes which entry the FMS is showing to the index specified. + } + PROCEDURE XPLMSetDisplayedFMSEntry( + inIndex : Integer); + cdecl; external XPLM_DLL; + + { + XPLMSetDestinationFMSEntry + + This routine changes which entry the FMS is flying the aircraft toward. + } + PROCEDURE XPLMSetDestinationFMSEntry( + inIndex : Integer); + cdecl; external XPLM_DLL; + + { + XPLMGetFMSEntryInfo + + This routine returns information about a given FMS entry. If the entry is + an airport or navaid, a reference to a nav entry can be returned allowing + you to find additional information (such as a frequency, ILS heading, name, + etc.). Note that this reference can be XPLM_NAV_NOT_FOUND until the + information has been looked up asynchronously, so after flightplan changes, + it might take up to a second for this field to become populated. The other + information is available immediately. For a lat/lon entry, the lat/lon is + returned by this routine but the navaid cannot be looked up (and the + reference will be XPLM_NAV_NOT_FOUND). FMS name entry buffers should be at + least 256 chars in length. + + WARNING: Due to a bug in X-Plane prior to 11.31, the navaid reference will + not be set to XPLM_NAV_NOT_FOUND while no data is available, and instead + just remain the value of the variable that you passed the pointer to. + Therefore, always initialize the variable to XPLM_NAV_NOT_FOUND before + passing the pointer to this function. + } + PROCEDURE XPLMGetFMSEntryInfo( + inIndex : Integer; + outType : PXPLMNavType; { Can be nil } + outID : XPLMString; { Can be nil } + outRef : PXPLMNavRef; { Can be nil } + outAltitude : PInteger; { Can be nil } + outLat : PSingle; { Can be nil } + outLon : PSingle); { Can be nil } + cdecl; external XPLM_DLL; + + { + XPLMSetFMSEntryInfo + + This routine changes an entry in the FMS to have the destination navaid + passed in and the altitude specified. Use this only for airports, fixes, + and radio-beacon navaids. Currently of radio beacons, the FMS can only + support VORs and NDBs. Use the routines below to clear or fly to a lat/lon. + } + PROCEDURE XPLMSetFMSEntryInfo( + inIndex : Integer; + inRef : XPLMNavRef; + inAltitude : Integer); + cdecl; external XPLM_DLL; + + { + XPLMSetFMSEntryLatLon + + This routine changes the entry in the FMS to a lat/lon entry with the given + coordinates. + } + PROCEDURE XPLMSetFMSEntryLatLon( + inIndex : Integer; + inLat : Single; + inLon : Single; + inAltitude : Integer); + cdecl; external XPLM_DLL; + + { + XPLMClearFMSEntry + + This routine clears the given entry, potentially shortening the flight + plan. + } + PROCEDURE XPLMClearFMSEntry( + inIndex : Integer); + cdecl; external XPLM_DLL; + +{___________________________________________________________________________ + * GPS RECEIVER + ___________________________________________________________________________} +{ + These APIs let you read data from the GPS unit. +} + + { + XPLMGetGPSDestinationType + + This routine returns the type of the currently selected GPS destination, + one of fix, airport, VOR or NDB. + } + FUNCTION XPLMGetGPSDestinationType: XPLMNavType; + cdecl; external XPLM_DLL; + + { + XPLMGetGPSDestination + + This routine returns the current GPS destination. + } + FUNCTION XPLMGetGPSDestination: XPLMNavRef; + cdecl; external XPLM_DLL; + + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/SDK/Delphi/XPLM/XPLMPlanes.pas b/XPLPro_Plugin_Source/SDK/SDK/Delphi/XPLM/XPLMPlanes.pas new file mode 100644 index 0000000..3801f0a --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDK/Delphi/XPLM/XPLMPlanes.pas @@ -0,0 +1,278 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPLMPlanes; +INTERFACE +{ + The XPLMPlanes APIs allow you to control the various aircraft in X-Plane, + both the user's and the sim's. + + *Note*: unlike almost all other APIs in the SDK, aircraft paths are _full_ + file system paths for historical reasons. You'll need to prefix all + relative paths with the X-Plane path as accessed via XPLMGetSystemPath. +} + +USES + XPLMDefs; + {$A4} +{___________________________________________________________________________ + * USER AIRCRAFT ACCESS + ___________________________________________________________________________} + + { + XPLMSetUsersAircraft + + This routine changes the user's aircraft. Note that this will reinitialize + the user to be on the nearest airport's first runway. Pass in a full path + (hard drive and everything including the .acf extension) to the .acf file. + } + PROCEDURE XPLMSetUsersAircraft( + inAircraftPath : XPLMString); + cdecl; external XPLM_DLL; + { + XPLMPlaceUserAtAirport + + This routine places the user at a given airport. Specify the airport by + its X-Plane airport ID (e.g. 'KBOS'). + } + PROCEDURE XPLMPlaceUserAtAirport( + inAirportCode : XPLMString); + cdecl; external XPLM_DLL; +{$IFDEF XPLM300} + { + XPLMPlaceUserAtLocation + + Places the user at a specific location after performing any necessary + scenery loads. + + As with in-air starts initiated from the X-Plane user interface, the + aircraft will always start with its engines running, regardless of the + user's preferences (i.e., regardless of what the dataref + `sim/operation/prefs/startup_running` says). + } + PROCEDURE XPLMPlaceUserAtLocation( + latitudeDegrees : Real; + longitudeDegrees : Real; + elevationMetersMSL : Single; + headingDegreesTrue : Single; + speedMetersPerSecond: Single); + cdecl; external XPLM_DLL; +{$ENDIF XPLM300} +{___________________________________________________________________________ + * GLOBAL AIRCRAFT ACCESS + ___________________________________________________________________________} + +CONST + { The user's aircraft is always index 0. } + XPLM_USER_AIRCRAFT = 0; +{$IFDEF XPLM_DEPRECATED} + { + XPLMPlaneDrawState_t + + This structure contains additional plane parameter info to be passed to + draw plane. Make sure to fill in the size of the structure field with + sizeof(XPLMDrawPlaneState_t) so that the XPLM can tell how many fields you + knew about when compiling your plugin (since more fields may be added + later). + + Most of these fields are ratios from 0 to 1 for control input. X-Plane + calculates what the actual controls look like based on the .acf file for + that airplane. Note for the yoke inputs, this is what the pilot of the + plane has commanded (post artificial stability system if there were one) + and affects aelerons, rudder, etc. It is not necessarily related to the + actual position of the plane! + } +TYPE + XPLMPlaneDrawState_t = RECORD + { The size of the draw state struct. } + structSize : Integer; + { A ratio from [0..1] describing how far the landing gear is extended. } + gearPosition : Single; + { Ratio of flap deployment, 0 = up, 1 = full deploy. } + flapRatio : Single; + { Ratio of spoiler deployment, 0 = none, 1 = full deploy. } + spoilerRatio : Single; + { Ratio of speed brake deployment, 0 = none, 1 = full deploy. } + speedBrakeRatio : Single; + { Ratio of slat deployment, 0 = none, 1 = full deploy. } + slatRatio : Single; + { Wing sweep ratio, 0 = forward, 1 = swept. } + wingSweep : Single; + { Thrust power, 0 = none, 1 = full fwd, -1 = full reverse. } + thrust : Single; + { Total pitch input for this plane. } + yokePitch : Single; + { Total Heading input for this plane. } + yokeHeading : Single; + { Total Roll input for this plane. } + yokeRoll : Single; + END; + PXPLMPlaneDrawState_t = ^XPLMPlaneDrawState_t; +{$ENDIF XPLM_DEPRECATED} + { + XPLMCountAircraft + + This function returns the number of aircraft X-Plane is capable of having, + as well as the number of aircraft that are currently active. These numbers + count the user's aircraft. It can also return the plugin that is currently + controlling aircraft. In X-Plane 7, this routine reflects the number of + aircraft the user has enabled in the rendering options window. + } + PROCEDURE XPLMCountAircraft( + outTotalAircraft : PInteger; + outActiveAircraft : PInteger; + outController : PXPLMPluginID); + cdecl; external XPLM_DLL; + { + XPLMGetNthAircraftModel + + This function returns the aircraft model for the Nth aircraft. Indices are + zero based, with zero being the user's aircraft. The file name should be + at least 256 chars in length; the path should be at least 512 chars in + length. + } + PROCEDURE XPLMGetNthAircraftModel( + inIndex : Integer; + outFileName : XPLMString; + outPath : XPLMString); + cdecl; external XPLM_DLL; +{___________________________________________________________________________ + * EXCLUSIVE AIRCRAFT ACCESS + ___________________________________________________________________________} +{ + The following routines require exclusive access to the airplane APIs. Only + one plugin may have this access at a time. +} + + + { + XPLMPlanesAvailable_f + + Your airplanes available callback is called when another plugin gives up + access to the multiplayer planes. Use this to wait for access to + multiplayer. + } +TYPE + XPLMPlanesAvailable_f = PROCEDURE( + inRefcon : pointer); cdecl; + + { + XPLMAcquirePlanes + + XPLMAcquirePlanes grants your plugin exclusive access to the aircraft. It + returns 1 if you gain access, 0 if you do not. + + inAircraft - pass in an array of pointers to strings specifying the planes + you want loaded. For any plane index you do not want loaded, pass a + 0-length string. Other strings should be full paths with the .acf + extension. NULL terminates this array, or pass NULL if there are no planes + you want loaded. + + If you pass in a callback and do not receive access to the planes your + callback will be called when the airplanes are available. If you do receive + airplane access, your callback will not be called. + } + FUNCTION XPLMAcquirePlanes( + inAircraft : PXPLMString; { Can be nil } + inCallback : XPLMPlanesAvailable_f; + inRefcon : pointer) : Integer; + cdecl; external XPLM_DLL; + + { + XPLMReleasePlanes + + Call this function to release access to the planes. Note that if you are + disabled, access to planes is released for you and you must reacquire it. + } + PROCEDURE XPLMReleasePlanes; + cdecl; external XPLM_DLL; + + { + XPLMSetActiveAircraftCount + + This routine sets the number of active planes. If you pass in a number + higher than the total number of planes availables, only the total number of + planes available is actually used. + } + PROCEDURE XPLMSetActiveAircraftCount( + inCount : Integer); + cdecl; external XPLM_DLL; + + { + XPLMSetAircraftModel + + This routine loads an aircraft model. It may only be called if you have + exclusive access to the airplane APIs. Pass in the path of the model with + the .acf extension. The index is zero based, but you may not pass in 0 + (use XPLMSetUsersAircraft to load the user's aircracft). + } + PROCEDURE XPLMSetAircraftModel( + inIndex : Integer; + inAircraftPath : XPLMString); + cdecl; external XPLM_DLL; + + { + XPLMDisableAIForPlane + + This routine turns off X-Plane's AI for a given plane. The plane will + continue to draw and be a real plane in X-Plane, but will not move itself. + } + PROCEDURE XPLMDisableAIForPlane( + inPlaneIndex : Integer); + cdecl; external XPLM_DLL; + +{$IFDEF XPLM_DEPRECATED} + { + XPLMDrawAircraft + + WARNING: Aircraft drawing via this API is deprecated and will not work in + future versions of X-Plane. Use XPLMInstance for 3-d drawing of custom + aircraft models. + + This routine draws an aircraft. It can only be called from a 3-d drawing + callback. Pass in the position of the plane in OpenGL local coordinates + and the orientation of the plane. A 1 for full drawing indicates that the + whole plane must be drawn; a 0 indicates you only need the nav lights + drawn. (This saves rendering time when planes are far away.) + } + PROCEDURE XPLMDrawAircraft( + inPlaneIndex : Integer; + inX : Single; + inY : Single; + inZ : Single; + inPitch : Single; + inRoll : Single; + inYaw : Single; + inFullDraw : Integer; + inDrawStateInfo : PXPLMPlaneDrawState_t); + cdecl; external XPLM_DLL; +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { + XPLMReinitUsersPlane + + WARNING: DO NOT USE. Use XPLMPlaceUserAtAirport or + XPLMPlaceUserAtLocation. + + This function recomputes the derived flight model data from the aircraft + structure in memory. If you have used the data access layer to modify the + aircraft structure, use this routine to resynchronize X-Plane; since + X-Plane works at least partly from derived values, the sim will not behave + properly until this is called. + + WARNING: this routine does not necessarily place the airplane at the + airport; use XPLMSetUsersAircraft to be compatible. This routine is + provided to do special experimentation with flight models without resetting + flight. + } + PROCEDURE XPLMReinitUsersPlane; + cdecl; external XPLM_DLL; +{$ENDIF XPLM_DEPRECATED} + + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/SDK/Delphi/XPLM/XPLMPlugin.pas b/XPLPro_Plugin_Source/SDK/SDK/Delphi/XPLM/XPLMPlugin.pas new file mode 100644 index 0000000..83fbb73 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDK/Delphi/XPLM/XPLMPlugin.pas @@ -0,0 +1,413 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPLMPlugin; +INTERFACE +{ + These APIs provide facilities to find and work with other plugins and + manage other plugins. +} + +USES + XPLMDefs; + {$A4} +{___________________________________________________________________________ + * FINDING PLUGINS + ___________________________________________________________________________} +{ + These APIs allow you to find another plugin or yourself, or iterate across + all plugins. For example, if you wrote an FMS plugin that needed to talk + to an autopilot plugin, you could use these APIs to locate the autopilot + plugin. +} + + + { + XPLMGetMyID + + This routine returns the plugin ID of the calling plug-in. Call this to + get your own ID. + } + FUNCTION XPLMGetMyID: XPLMPluginID; + cdecl; external XPLM_DLL; + + { + XPLMCountPlugins + + This routine returns the total number of plug-ins that are loaded, both + disabled and enabled. + } + FUNCTION XPLMCountPlugins: Integer; + cdecl; external XPLM_DLL; + + { + XPLMGetNthPlugin + + This routine returns the ID of a plug-in by index. Index is 0 based from 0 + to XPLMCountPlugins-1, inclusive. Plugins may be returned in any arbitrary + order. + } + FUNCTION XPLMGetNthPlugin( + inIndex : Integer) : XPLMPluginID; + cdecl; external XPLM_DLL; + + { + XPLMFindPluginByPath + + This routine returns the plug-in ID of the plug-in whose file exists at the + passed in absolute file system path. XPLM_NO_PLUGIN_ID is returned if the + path does not point to a currently loaded plug-in. + } + FUNCTION XPLMFindPluginByPath( + inPath : XPLMString) : XPLMPluginID; + cdecl; external XPLM_DLL; + + { + XPLMFindPluginBySignature + + This routine returns the plug-in ID of the plug-in whose signature matches + what is passed in or XPLM_NO_PLUGIN_ID if no running plug-in has this + signature. Signatures are the best way to identify another plug-in as they + are independent of the file system path of a plug-in or the human-readable + plug-in name, and should be unique for all plug-ins. Use this routine to + locate another plugin that your plugin interoperates with + } + FUNCTION XPLMFindPluginBySignature( + inSignature : XPLMString) : XPLMPluginID; + cdecl; external XPLM_DLL; + + { + XPLMGetPluginInfo + + This routine returns information about a plug-in. Each parameter should be + a pointer to a buffer of at least + 256 characters, or NULL to not receive the information. + + outName - the human-readable name of the plug-in. outFilePath - the + absolute file path to the file that contains this plug-in. outSignature - a + unique string that identifies this plug-in. outDescription - a + human-readable description of this plug-in. + } + PROCEDURE XPLMGetPluginInfo( + inPlugin : XPLMPluginID; + outName : XPLMString; { Can be nil } + outFilePath : XPLMString; { Can be nil } + outSignature : XPLMString; { Can be nil } + outDescription : XPLMString); { Can be nil } + cdecl; external XPLM_DLL; + +{___________________________________________________________________________ + * ENABLING/DISABLING PLUG-INS + ___________________________________________________________________________} +{ + These routines are used to work with plug-ins and manage them. Most + plugins will not need to use these APIs. +} + + + { + XPLMIsPluginEnabled + + Returns whether the specified plug-in is enabled for running. + } + FUNCTION XPLMIsPluginEnabled( + inPluginID : XPLMPluginID) : Integer; + cdecl; external XPLM_DLL; + + { + XPLMEnablePlugin + + This routine enables a plug-in if it is not already enabled. It returns 1 + if the plugin was enabled or successfully enables itself, 0 if it does not. + Plugins may fail to enable (for example, if resources cannot be acquired) + by returning 0 from their XPluginEnable callback. + } + FUNCTION XPLMEnablePlugin( + inPluginID : XPLMPluginID) : Integer; + cdecl; external XPLM_DLL; + + { + XPLMDisablePlugin + + This routine disableds an enabled plug-in. + } + PROCEDURE XPLMDisablePlugin( + inPluginID : XPLMPluginID); + cdecl; external XPLM_DLL; + + { + XPLMReloadPlugins + + This routine reloads all plug-ins. Once this routine is called and you + return from the callback you were within (e.g. a menu select callback) you + will receive your XPluginDisable and XPluginStop callbacks and your DLL + will be unloaded, then the start process happens as if the sim was starting + up. + } + PROCEDURE XPLMReloadPlugins; + cdecl; external XPLM_DLL; + +{___________________________________________________________________________ + * INTERPLUGIN MESSAGING + ___________________________________________________________________________} +{ + Plugin messages are defined as 32-bit integers. Messages below 0x00FFFFFF + are reserved for X-Plane and the plugin SDK. + + Messages come with a pointer parameter; the meaning of this pointer depends + on the message itself. In some messages, the pointer parameter contains an + actual typed pointer to data that can be inspected in the plugin; in these + cases the documentation will state that the parameter "points to" + information. + + in other cases, the value of the pointer is actually an integral number + stuffed into the pointer's storage. In these second cases, the pointer + parameter needs to be cast, not dereferenced. In these caess, the + documentation will state that the parameter "contains" a value, which will + always be an integral type. + + Some messages don't use the pointer parameter - in this case your plugin + should ignore it. + + Messages have two conceptual uses: notifications and commands. Commands + are sent from one plugin to another to induce behavior; notifications are + sent from one plugin to all others for informational purposes. It is + important that commands and notifications not have the same values because + this could cause a notification sent by one plugin to accidentally induce a + command in another. + + By convention, plugin-defined notifications should have the high bit set + (e.g. be greater or equal to unsigned 0x8000000) while commands should have + this bit be cleared. + + The following messages are sent to your plugin by X-Plane. +} + + +CONST + { This message is sent to your plugin whenever the user's plane crashes. The } + { parameter is ignored. } + XPLM_MSG_PLANE_CRASHED = 101; + + { This message is sent to your plugin whenever a new plane is loaded. The } + { parameter contains the index number of the plane being loaded; 0 indicates } + { the user's plane. } + XPLM_MSG_PLANE_LOADED = 102; + + { This messages is sent whenever the user's plane is positioned at a new } + { airport. The parameter is ignored. } + XPLM_MSG_AIRPORT_LOADED = 103; + + { This message is sent whenever new scenery is loaded. Use datarefs to } + { determine the new scenery files that were loaded. The parameter is ignored.} + XPLM_MSG_SCENERY_LOADED = 104; + + { This message is sent whenever the user adjusts the number of X-Plane } + { aircraft models. You must use XPLMCountPlanes to find out how many planes } + { are now available. This message will only be sent in XP7 and higher } + { because in XP6 the number of aircraft is not user-adjustable. The parameter} + { is ignored. } + XPLM_MSG_AIRPLANE_COUNT_CHANGED = 105; + +{$IFDEF XPLM200} +CONST + { This message is sent to your plugin whenever a plane is unloaded. The } + { parameter contains the index number of the plane being unloaded; 0 } + { indicates the user's plane. The parameter is of type int, passed as the } + { value of the pointer. (That is: the parameter is an int, not a pointer to } + { an int.) } + XPLM_MSG_PLANE_UNLOADED = 106; +{$ENDIF XPLM200} + +{$IFDEF XPLM210} +CONST + { This message is sent to your plugin right before X-Plane writes its } + { preferences file. You can use this for two purposes: to write your own } + { preferences, and to modify any datarefs to influence preferences output. } + { For example, if your plugin temporarily modifies saved preferences, you can} + { put them back to their default values here to avoid having the tweaks be } + { persisted if your plugin is not loaded on the next invocation of X-Plane. } + { The parameter is ignored. } + XPLM_MSG_WILL_WRITE_PREFS = 107; +{$ENDIF XPLM210} + +{$IFDEF XPLM210} + { This message is sent to your plugin right after a livery is loaded for an } + { airplane. You can use this to check the new livery (via datarefs) and } + { react accordingly. The parameter contains the index number of the aircraft} + { whose livery is changing. } + XPLM_MSG_LIVERY_LOADED = 108; +{$ENDIF XPLM210} + +{$IFDEF XPLM301} +CONST + { Sent to your plugin right before X-Plane enters virtual reality mode (at } + { which time any windows that are not positioned in VR mode will no longer be} + { visible to the user). The parameter is unused and should be ignored. } + XPLM_MSG_ENTERED_VR = 109; +{$ENDIF XPLM301} + +{$IFDEF XPLM301} + { Sent to your plugin right before X-Plane leaves virtual reality mode (at } + { which time you may want to clean up windows that are positioned in VR } + { mode). The parameter is unused and should be ignored. } + XPLM_MSG_EXITING_VR = 110; +{$ENDIF XPLM301} + +{$IFDEF XPLM303} +CONST + { Sent to your plugin if another plugin wants to take over AI planes. If you } + { are a synthetic traffic provider, that probably means a plugin for an } + { online network has connected and wants to supply aircraft flown by real } + { humans and you should cease to provide synthetic traffic. If however you } + { are providing online traffic from real humans, you probably don't want to } + { disconnect, in which case you just ignore this message. The sender is the } + { plugin ID of the plugin asking for control of the planes now. You can use } + { it to find out who is requesting and whether you should yield to them. } + { Synthetic traffic providers should always yield to online networks. The } + { parameter is unused and should be ignored. } + XPLM_MSG_RELEASE_PLANES = 111; +{$ENDIF XPLM303} + + { + XPLMSendMessageToPlugin + + This function sends a message to another plug-in or X-Plane. Pass + XPLM_NO_PLUGIN_ID to broadcast to all plug-ins. Only enabled plug-ins with + a message receive function receive the message. + } + PROCEDURE XPLMSendMessageToPlugin( + inPlugin : XPLMPluginID; + inMessage : Integer; + inParam : pointer); + cdecl; external XPLM_DLL; + +{$IFDEF XPLM200} +{___________________________________________________________________________ + * Plugin Features API + ___________________________________________________________________________} +{ + The plugin features API allows your plugin to "sign up" for additional + capabilities and plugin system features that are normally disabled for + backward compatibility. This allows advanced plugins to "opt-in" to new + behavior. + + Each feature is defined by a permanent string name. The feature string + names will vary with the particular installation of X-Plane, so plugins + should not expect a feature to be guaranteed present. + + XPLM_WANTS_REFLECTIONS + ---------------------- + + Available in the SDK 2.0 and later for X-Plane 9, enabling this capability + causes your plugin to receive drawing hook callbacks when X-Plane builds + its off-screen reflection and shadow rendering passes. Plugins should + enable this and examine the dataref sim/graphics/view/plane_render_type to + determine whether the drawing callback is for a reflection, shadow + calculation, or the main screen. Rendering can be simlified or omitted for + reflections, and non-solid drawing should be skipped for shadow + calculations. + + **Note**: direct drawing via draw callbacks is not recommended; use the + XPLMInstance API to create object models instead. + + XPLM_USE_NATIVE_PATHS + --------------------- + + available in the SDK 2.1 and later for X-Plane 10, this modifies the plugin + system to use Unix-style paths on all operating systems. With this enabled: + + * OS X paths will match the native OS X Unix. + * Windows will use forward slashes but preserve C:\ or another drive letter + when using complete file paths. + * Linux uses its native file system path scheme. + + Without this enabled: + + * OS X will use CFM file paths separated by a colon. + * Windows will use back-slashes and conventional DOS paths. + * Linux uses its native file system path scheme. + + All plugins should enable this feature on OS X to access the native file + system. + + XPLM_USE_NATIVE_WIDGET_WINDOWS + ------------------------------ + + Available in the SDK 3.0.2 SDK, this capability tells the widgets library + to use new, modern X-Plane backed XPLMDisplay windows to anchor all widget + trees. Without it, widgets will always use legacy windows. + + Plugins should enable this to allow their widget hierarchies to respond to + the user's UI size settings and to map widget-based windwos to a VR HMD. + + Before enabling this, make sure any custom widget code in your plugin is + prepared to cope with the UI coordinate system not being th same as the + OpenGL window coordinate system. +} + + + { + XPLMFeatureEnumerator_f + + You pass an XPLMFeatureEnumerator_f to get a list of all features supported + by a given version running version of X-Plane. This routine is called once + for each feature. + } +TYPE + XPLMFeatureEnumerator_f = PROCEDURE( + inFeature : XPLMString; + inRef : pointer); cdecl; + + { + XPLMHasFeature + + This returns 1 if the given installation of X-Plane supports a feature, or + 0 if it does not. + } + FUNCTION XPLMHasFeature( + inFeature : XPLMString) : Integer; + cdecl; external XPLM_DLL; + + { + XPLMIsFeatureEnabled + + This returns 1 if a feature is currently enabled for your plugin, or 0 if + it is not enabled. It is an error to call this routine with an unsupported + feature. + } + FUNCTION XPLMIsFeatureEnabled( + inFeature : XPLMString) : Integer; + cdecl; external XPLM_DLL; + + { + XPLMEnableFeature + + This routine enables or disables a feature for your plugin. This will + change the running behavior of X-Plane and your plugin in some way, + depending on the feature. + } + PROCEDURE XPLMEnableFeature( + inFeature : XPLMString; + inEnable : Integer); + cdecl; external XPLM_DLL; + + { + XPLMEnumerateFeatures + + This routine calls your enumerator callback once for each feature that this + running version of X-Plane supports. Use this routine to determine all of + the features that X-Plane can support. + } + PROCEDURE XPLMEnumerateFeatures( + inEnumerator : XPLMFeatureEnumerator_f; + inRef : pointer); + cdecl; external XPLM_DLL; + +{$ENDIF XPLM200} + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/SDK/Delphi/XPLM/XPLMProcessing.pas b/XPLPro_Plugin_Source/SDK/SDK/Delphi/XPLM/XPLMProcessing.pas new file mode 100644 index 0000000..e09b6e5 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDK/Delphi/XPLM/XPLMProcessing.pas @@ -0,0 +1,254 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPLMProcessing; +INTERFACE +{ + This API allows you to get regular callbacks during the flight loop, the + part of X-Plane where the plane's position calculates the physics of + flight, etc. Use these APIs to accomplish periodic tasks like logging data + and performing I/O. + + You can receive a callback either just before or just after the per-frame + physics calculations happen - you can use post-FM callbacks to "patch" the + flight model after it has run. + + If the user has set the number of flight model iterations per frame greater + than one your plugin will _not_ see this; these integrations run on the + sub-section of the flight model where iterations improve responsiveness + (e.g. physical integration, not simple systems tracking) and are thus + opaque to plugins. + + Flight loop scheduling, when scheduled by time, is scheduled by a "first + callback after the deadline" schedule, e.g. your callbacks will always be + slightly late to ensure that we don't run faster than your deadline. + + WARNING: Do NOT use these callbacks to draw! You cannot draw during flight + loop callbacks. Use the drawing callbacks (see XPLMDisplay for more info) + for graphics. (One exception: you can use a post-flight loop callback to + update your own off-screen FBOs.) +} + +USES + XPLMDefs; + {$A4} +{___________________________________________________________________________ + * FLIGHT LOOP CALLBACKS + ___________________________________________________________________________} + +{$IFDEF XPLM210} + { + XPLMFlightLoopPhaseType + + You can register a flight loop callback to run either before or after the + flight model is integrated by X-Plane. + } +TYPE + XPLMFlightLoopPhaseType = ( + { Your callback runs before X-Plane integrates the flight model. } + xplm_FlightLoop_Phase_BeforeFlightModel = 0 + + { Your callback runs after X-Plane integrates the flight model. } + ,xplm_FlightLoop_Phase_AfterFlightModel = 1 + + ); + PXPLMFlightLoopPhaseType = ^XPLMFlightLoopPhaseType; +{$ENDIF XPLM210} + +{$IFDEF XPLM210} + { + XPLMFlightLoopID + + This is an opaque identifier for a flight loop callback. You can use this + identifier to easily track and remove your callbacks, or to use the new + flight loop APIs. + } + XPLMFlightLoopID = pointer; + PXPLMFlightLoopID = ^XPLMFlightLoopID; +{$ENDIF XPLM210} + + { + XPLMFlightLoop_f + + This is your flight loop callback. Each time the flight loop is iterated + through, you receive this call at the end. + + Flight loop callbacks receive a number of input timing parameters. These + input timing parameters are not particularly useful; you may need to track + your own timing data (e.g. by reading datarefs). The input parameters are: + + - inElapsedSinceLastCall: the wall time since your last callback. + - inElapsedTimeSinceLastFlightLoop: the wall time since any flight loop was + dispatched. + - inCounter: a monotonically increasing counter, bumped once per flight + loop dispatch from the sim. + - inRefcon: your own ptr constant from when you regitered yor callback. + + Your return value controls when you will next be called. + + - Return 0 to stop receiving callbacks. + - Pass a positive number to specify how many seconds until the next + callback. (You will be called at or after this time, not before.) + - Pass a negative number to specify how many loops must go by until you + are called. For example, -1.0 means call me the very next loop. + + Try to run your flight loop as infrequently as is practical, and suspend it + (using return value 0) when you do not need it; lots of flight loop + callbacks that do nothing lowers X-Plane's frame rate. + + Your callback will NOT be unregistered if you return 0; it will merely be + inactive. + } +TYPE + XPLMFlightLoop_f = FUNCTION( + inElapsedSinceLastCall: Single; + inElapsedTimeSinceLastFlightLoop: Single; + inCounter : Integer; + inRefcon : pointer) : Single; cdecl; + +{$IFDEF XPLM210} + { + XPLMCreateFlightLoop_t + + XPLMCreateFlightLoop_t contains the parameters to create a new flight loop + callback. The strsucture can be expanded in future SDKs - always set + structSize to the size of your structure in bytes. + } +TYPE + XPLMCreateFlightLoop_t = RECORD + structSize : Integer; + phase : XPLMFlightLoopPhaseType; + callbackFunc : XPLMFlightLoop_f; + refcon : pointer; + END; + PXPLMCreateFlightLoop_t = ^XPLMCreateFlightLoop_t; +{$ENDIF XPLM210} + + { + XPLMGetElapsedTime + + This routine returns the elapsed time since the sim started up in decimal + seconds. This is a wall timer; it keeps counting upward even if the sim is + pasued. + + __WARNING__: XPLMGetElapsedTime is not a very good timer! It lacks + precision in both its data type and its source. Do not attempt to use it + for timing critical applications like network multiplayer. + } + FUNCTION XPLMGetElapsedTime: Single; + cdecl; external XPLM_DLL; + + { + XPLMGetCycleNumber + + This routine returns a counter starting at zero for each sim cycle + computed/video frame rendered. + } + FUNCTION XPLMGetCycleNumber: Integer; + cdecl; external XPLM_DLL; + + { + XPLMRegisterFlightLoopCallback + + This routine registers your flight loop callback. Pass in a pointer to a + flight loop function and a refcon. inInterval defines when you will be + called. Pass in a positive number to specify seconds from registration time + to the next callback. Pass in a negative number to indicate when you will + be called (e.g. pass -1 to be called at the next cylcle). Pass 0 to not be + called; your callback will be inactive. + + (This legacy function only installs pre-flight-loop callbacks; use + XPLMCreateFlightLoop for more control.) + } + PROCEDURE XPLMRegisterFlightLoopCallback( + inFlightLoop : XPLMFlightLoop_f; + inInterval : Single; + inRefcon : pointer); + cdecl; external XPLM_DLL; + + { + XPLMUnregisterFlightLoopCallback + + This routine unregisters your flight loop callback. Do NOT call it from + your flight loop callback. Once your flight loop callback is unregistered, + it will not be called again. + + Only use this on flight loops registered via + XPLMRegisterFlightLoopCallback. + } + PROCEDURE XPLMUnregisterFlightLoopCallback( + inFlightLoop : XPLMFlightLoop_f; + inRefcon : pointer); + cdecl; external XPLM_DLL; + + { + XPLMSetFlightLoopCallbackInterval + + This routine sets when a callback will be called. Do NOT call it from your + callback; use the return value of the callback to change your callback + interval from inside your callback. + + inInterval is formatted the same way as in XPLMRegisterFlightLoopCallback; + positive for seconds, negative for cycles, and 0 for deactivating the + callback. If inRelativeToNow is 1, times are from the time of this call; + otherwise they are from the time the callback was last called (or the time + it was registered if it has never been called. + } + PROCEDURE XPLMSetFlightLoopCallbackInterval( + inFlightLoop : XPLMFlightLoop_f; + inInterval : Single; + inRelativeToNow : Integer; + inRefcon : pointer); + cdecl; external XPLM_DLL; + +{$IFDEF XPLM210} + { + XPLMCreateFlightLoop + + This routine creates a flight loop callback and returns its ID. The flight + loop callback is created using the input param struct, and is inited to be + unscheduled. + } + FUNCTION XPLMCreateFlightLoop( + inParams : PXPLMCreateFlightLoop_t) : XPLMFlightLoopID; + cdecl; external XPLM_DLL; +{$ENDIF XPLM210} + +{$IFDEF XPLM210} + { + XPLMDestroyFlightLoop + + This routine destroys a flight loop callback by ID. Only call it on flight + loops created with the newer XPLMCreateFlightLoop API. + } + PROCEDURE XPLMDestroyFlightLoop( + inFlightLoopID : XPLMFlightLoopID); + cdecl; external XPLM_DLL; +{$ENDIF XPLM210} + +{$IFDEF XPLM210} + { + XPLMScheduleFlightLoop + + This routine schedules a flight loop callback for future execution. If + inInterval is negative, it is run in a certain number of frames based on + the absolute value of the input. If the interval is positive, it is a + duration in seconds. + + If inRelativeToNow is true, ties are interpretted relative to the time this + routine is called; otherwise they are relative to the last call time or the + time the flight loop was registered (if never called). + } + PROCEDURE XPLMScheduleFlightLoop( + inFlightLoopID : XPLMFlightLoopID; + inInterval : Single; + inRelativeToNow : Integer); + cdecl; external XPLM_DLL; +{$ENDIF XPLM210} + + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/SDK/Delphi/XPLM/XPLMScenery.pas b/XPLPro_Plugin_Source/SDK/SDK/Delphi/XPLM/XPLMScenery.pas new file mode 100644 index 0000000..a585830 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDK/Delphi/XPLM/XPLMScenery.pas @@ -0,0 +1,434 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPLMScenery; +INTERFACE +{ + This package contains APIs to interact with X-Plane's scenery system. +} + +USES + XPLMDefs; + {$A4} +{$IFDEF XPLM200} +{___________________________________________________________________________ + * Terrain Y-Testing + ___________________________________________________________________________} +{ + The Y-testing API allows you to locate the physical scenery mesh. This + would be used to place dynamic graphics on top of the ground in a plausible + way or do physics interactions. + + The Y-test API works via probe objects, which are allocated by your plugin + and used to query terrain. Probe objects exist both to capture which + algorithm you have requested (see probe types) and also to cache query + information. + + Performance Guidelines + ---------------------- + + It is generally faster to use the same probe for nearby points and + different probes for different points. Try not to allocate more than + "hundreds" of probes at most. Share probes if you need more. Generally, + probing operations are expensive, and should be avoided via caching when + possible. + + Y testing returns a location on the terrain, a normal vectory, and a + velocity vector. The normal vector tells you the slope of the terrain at + that point. The velocity vector tells you if that terrain is moving (and is + in meters/second). For example, if your Y test hits the aircraft carrier + deck, this tells you the velocity of that point on the deck. + + Note: the Y-testing API is limited to probing the loaded scenery area, + which is approximately 300x300 km in X-Plane 9. Probes outside this area + will return the height of a 0 MSL sphere. +} + + + { + XPLMProbeType + + XPLMProbeType defines the type of terrain probe - each probe has a + different algorithm. (Only one type of probe is provided right now, but + future APIs will expose more flexible or poewrful or useful probes. + } +TYPE + XPLMProbeType = ( + { The Y probe gives you the location of the tallest physical scenery along } + { the Y axis going through the queried point. } + xplm_ProbeY = 0 + + ); + PXPLMProbeType = ^XPLMProbeType; + + { + XPLMProbeResult + + Probe results - possible results from a probe query. + } + XPLMProbeResult = ( + { The probe hit terrain and returned valid values. } + xplm_ProbeHitTerrain = 0 + + { An error in the API call. Either the probe struct size is bad, or the } + { probe is invalid or the type is mismatched for the specific query call. } + ,xplm_ProbeError = 1 + + { The probe call succeeded but there is no terrain under this point (perhaps } + { it is off the side of the planet?) } + ,xplm_ProbeMissed = 2 + + ); + PXPLMProbeResult = ^XPLMProbeResult; + + { + XPLMProbeRef + + An XPLMProbeRef is an opaque handle to a probe, used for querying the + terrain. + } + XPLMProbeRef = pointer; + PXPLMProbeRef = ^XPLMProbeRef; + + { + XPLMProbeInfo_t + + XPLMProbeInfo_t contains the results of a probe call. Make sure to set + structSize to the size of the struct before using it. + } + XPLMProbeInfo_t = RECORD + { Size of structure in bytes - always set this before calling the XPLM. } + structSize : Integer; + { Resulting X location of the terrain point we hit, in local OpenGL } + { coordinates. } + locationX : Single; + { Resulting Y location of the terrain point we hit, in local OpenGL } + { coordinates. } + locationY : Single; + { Resulting Z location of the terrain point we hit, in local OpenGL } + { coordinates. } + locationZ : Single; + { X component of the normal vector to the terrain we found. } + normalX : Single; + { Y component of the normal vector to the terrain we found. } + normalY : Single; + { Z component of the normal vector to the terrain we found. } + normalZ : Single; + { X component of the velocity vector of the terrain we found. } + velocityX : Single; + { Y component of the velocity vector of the terrain we found. } + velocityY : Single; + { Z component of the velocity vector of the terrain we found. } + velocityZ : Single; + { Tells if the surface we hit is water (otherwise it is land). } + is_wet : Integer; + END; + PXPLMProbeInfo_t = ^XPLMProbeInfo_t; + + { + XPLMCreateProbe + + Creates a new probe object of a given type and returns. + } + FUNCTION XPLMCreateProbe( + inProbeType : XPLMProbeType) : XPLMProbeRef; + cdecl; external XPLM_DLL; + + { + XPLMDestroyProbe + + Deallocates an existing probe object. + } + PROCEDURE XPLMDestroyProbe( + inProbe : XPLMProbeRef); + cdecl; external XPLM_DLL; + + { + XPLMProbeTerrainXYZ + + Probes the terrain. Pass in the XYZ coordinate of the probe point, a probe + object, and an XPLMProbeInfo_t struct that has its structSize member set + properly. Other fields are filled in if we hit terrain, and a probe result + is returned. + } + FUNCTION XPLMProbeTerrainXYZ( + inProbe : XPLMProbeRef; + inX : Single; + inY : Single; + inZ : Single; + outInfo : PXPLMProbeInfo_t) : XPLMProbeResult; + cdecl; external XPLM_DLL; + +{$ENDIF XPLM200} +{$IFDEF XPLM300} +{___________________________________________________________________________ + * Magnetic Variation + ___________________________________________________________________________} +{ + Use the magnetic variation (more properly, the "magnetic declination") API + to find the offset of magnetic north from true north at a given latitude + and longitude within the simulator. + + In the real world, the Earth's magnetic field is irregular, such that true + north (the direction along a meridian toward the north pole) does not + necessarily match what a magnetic compass shows as north. + + Using this API ensures that you present the same offsets to users as + X-Plane's built-in instruments. +} + + + { + XPLMGetMagneticVariation + + Returns X-Plane's simulated magnetic variation (declination) at the + indication latitude and longitude. + } + FUNCTION XPLMGetMagneticVariation( + latitude : Real; + longitude : Real) : Single; + cdecl; external XPLM_DLL; + + { + XPLMDegTrueToDegMagnetic + + Converts a heading in degrees relative to true north into a value relative + to magnetic north at the user's current location. + } + FUNCTION XPLMDegTrueToDegMagnetic( + headingDegreesTrue : Single) : Single; + cdecl; external XPLM_DLL; + + { + XPLMDegMagneticToDegTrue + + Converts a heading in degrees relative to magnetic north at the user's + current location into a value relative to true north. + } + FUNCTION XPLMDegMagneticToDegTrue( + headingDegreesMagnetic: Single) : Single; + cdecl; external XPLM_DLL; + +{$ENDIF XPLM300} +{___________________________________________________________________________ + * Object Drawing + ___________________________________________________________________________} +{ + The object drawing routines let you load and draw X-Plane OBJ files. + Objects are loaded by file path and managed via an opaque handle. X-Plane + naturally reference counts objects, so it is important that you balance + every successful call to XPLMLoadObject with a call to XPLMUnloadObject! +} + + +{$IFDEF XPLM200} +TYPE + { + XPLMObjectRef + + An XPLMObjectRef is a opaque handle to an .obj file that has been loaded + into memory. + } + XPLMObjectRef = pointer; + PXPLMObjectRef = ^XPLMObjectRef; +{$ENDIF XPLM200} + +{$IFDEF XPLM200} + { + XPLMDrawInfo_t + + The XPLMDrawInfo_t structure contains positioning info for one object that + is to be drawn. Be sure to set structSize to the size of the structure for + future expansion. + } + XPLMDrawInfo_t = RECORD + { Set this to the size of this structure! } + structSize : Integer; + { X location of the object in local coordinates. } + x : Single; + { Y location of the object in local coordinates. } + y : Single; + { Z location of the object in local coordinates. } + z : Single; + { Pitch in degres to rotate the object, positive is up. } + pitch : Single; + { Heading in local coordinates to rotate the object, clockwise. } + heading : Single; + { Roll to rotate the object. } + roll : Single; + END; + PXPLMDrawInfo_t = ^XPLMDrawInfo_t; +{$ENDIF XPLM200} + +{$IFDEF XPLM210} + { + XPLMObjectLoaded_f + + You provide this callback when loading an object asynchronously; it will be + called once the object is loaded. Your refcon is passed back. The object + ref passed in is the newly loaded object (ready for use) or NULL if an + error occured. + + If your plugin is disabled, this callback will be delivered as soon as the + plugin is re-enabled. If your plugin is unloaded before this callback is + ever called, the SDK will release the object handle for you. + } +TYPE + XPLMObjectLoaded_f = PROCEDURE( + inObject : XPLMObjectRef; + inRefcon : pointer); cdecl; +{$ENDIF XPLM210} + +{$IFDEF XPLM200} + { + XPLMLoadObject + + This routine loads an OBJ file and returns a handle to it. If X-Plane has + already loaded the object, the handle to the existing object is returned. + Do not assume you will get the same handle back twice, but do make sure to + call unload once for every load to avoid "leaking" objects. The object will + be purged from memory when no plugins and no scenery are using it. + + The path for the object must be relative to the X-System base folder. If + the path is in the root of the X-System folder you may need to prepend ./ + to it; loading objects in the root of the X-System folder is STRONGLY + discouraged - your plugin should not dump art resources in the root folder! + + XPLMLoadObject will return NULL if the object cannot be loaded (either + because it is not found or the file is misformatted). This routine will + load any object that can be used in the X-Plane scenery system. + + It is important that the datarefs an object uses for animation already be + loaded before you load the object. For this reason it may be necessary to + defer object loading until the sim has fully started. + } + FUNCTION XPLMLoadObject( + inPath : XPLMString) : XPLMObjectRef; + cdecl; external XPLM_DLL; +{$ENDIF XPLM200} + +{$IFDEF XPLM210} + { + XPLMLoadObjectAsync + + This routine loads an object asynchronously; control is returned to you + immediately while X-Plane loads the object. The sim will not stop flying + while the object loads. For large objects, it may be several seconds before + the load finishes. + + You provide a callback function that is called once the load has completed. + Note that if the object cannot be loaded, you will not find out until the + callback function is called with a NULL object handle. + + There is no way to cancel an asynchronous object load; you must wait for + the load to complete and then release the object if it is no longer + desired. + } + PROCEDURE XPLMLoadObjectAsync( + inPath : XPLMString; + inCallback : XPLMObjectLoaded_f; + inRefcon : pointer); + cdecl; external XPLM_DLL; +{$ENDIF XPLM210} + +{$IFDEF XPLM_DEPRECATED} + { + XPLMDrawObjects + + __Deprecation Warning__: use XPLMInstancing to draw 3-d objects by creating + instances, rather than these APIs from draw callbacks. + + XPLMDrawObjects draws an object from an OBJ file one or more times. You + pass in the object and an array of XPLMDrawInfo_t structs, one for each + place you would like the object to be drawn. + + X-Plane will attempt to cull the objects based on LOD and visibility, and + will pick the appropriate LOD. + + Lighting is a boolean; pass 1 to show the night version of object with + night-only lights lit up. Pass 0 to show the daytime version of the object. + + earth_relative controls the coordinate system. If this is 1, the rotations + you specify are applied to the object after its coordinate system is + transformed from local to earth-relative coordinates -- that is, an object + with no rotations will point toward true north and the Y axis will be up + against gravity. If this is 0, the object is drawn with your rotations from + local coordanates -- that is, an object with no rotations is drawn pointing + down the -Z axis and the Y axis of the object matches the local coordinate + Y axis. + } + PROCEDURE XPLMDrawObjects( + inObject : XPLMObjectRef; + inCount : Integer; + inLocations : PXPLMDrawInfo_t; + lighting : Integer; + earth_relative : Integer); + cdecl; external XPLM_DLL; +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM200} + { + XPLMUnloadObject + + This routine marks an object as no longer being used by your plugin. + Objects are reference counted: once no plugins are using an object, it is + purged from memory. Make sure to call XPLMUnloadObject once for each + successful call to XPLMLoadObject. + } + PROCEDURE XPLMUnloadObject( + inObject : XPLMObjectRef); + cdecl; external XPLM_DLL; +{$ENDIF XPLM200} + +{$IFDEF XPLM200} +{___________________________________________________________________________ + * Library Access + ___________________________________________________________________________} +{ + The library access routines allow you to locate scenery objects via the + X-Plane library system. Right now library access is only provided for + objects, allowing plugin-drawn objects to be extended using the library + system. +} + + + { + XPLMLibraryEnumerator_f + + An XPLMLibraryEnumerator_f is a callback you provide that is called once + for each library element that is located. The returned paths will be + relative to the X-System folder. + } +TYPE + XPLMLibraryEnumerator_f = PROCEDURE( + inFilePath : XPLMString; + inRef : pointer); cdecl; + + { + XPLMLookupObjects + + This routine looks up a virtual path in the library system and returns all + matching elements. You provide a callback - one virtual path may match many + objects in the library. XPLMLookupObjects returns the number of objects + found. + + The latitude and longitude parameters specify the location the object will + be used. The library system allows for scenery packages to only provide + objects to certain local locations. Only objects that are allowed at the + latitude/longitude you provide will be returned. + } + FUNCTION XPLMLookupObjects( + inPath : XPLMString; + inLatitude : Single; + inLongitude : Single; + enumerator : XPLMLibraryEnumerator_f; + ref : pointer) : Integer; + cdecl; external XPLM_DLL; + +{$ENDIF XPLM200} + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/SDK/Delphi/XPLM/XPLMUtilities.pas b/XPLPro_Plugin_Source/SDK/SDK/Delphi/XPLM/XPLMUtilities.pas new file mode 100644 index 0000000..121e28b --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDK/Delphi/XPLM/XPLMUtilities.pas @@ -0,0 +1,951 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPLMUtilities; +INTERFACE + +USES + XPLMDefs; + {$A4} +{___________________________________________________________________________ + * FILE UTILITIES + ___________________________________________________________________________} +{ + The XPLMUtilities file APIs provide some basic file and path functions for + use with X-Plane. + + Directory Separators + -------------------- + + The XPLM has two modes it can work in: + + * X-Plane native paths: all paths are UTF8 strings, using the unix forward + slash (/) as the directory separating character. In native path mode, + you use the same path format for all three operating systems. + + * Legacy OS paths: the directroy separator is \ for Windows, : for OS X, + and / for Linux; OS paths are encoded in MacRoman for OS X using legacy + HFS conventions, use the application code page for multi-byte encoding + on Unix using DOS path conventions, and use UTF-8 for Linux. + + While legacy OS paths are the default, we strongly encourage you to opt in + to native paths using the XPLMEnableFeature API. + + * All OS X plugins should enable native paths all of the time; if you do + not do this, you will have to convert all paths back from HFS to Unix + (and deal with MacRoman) - code written using native paths and the C + file APIs "just works" on OS X. + + * For Linux plugins, there is no difference between the two encodings. + + * Windows plugins will need to convert the UTF8 file paths to UTF16 for + use with the "wide" APIs. While it might seem tempting to stick with + legacy OS paths (and just use the "ANSI" Windows APIs), X-Plane is fully + unicode-capable, and will often be installed in paths where the user's + directories have no ACP encoding. + + Full and Relative Paths + ----------------------- + + Some of these APIs use full paths, but others use paths relative to the + user's X-Plane installation. This is documented on a per-API basis. +} + + +{$IFDEF XPLM200} + { + XPLMDataFileType + + These enums define types of data files you can load or unload using the + SDK. + } +TYPE + XPLMDataFileType = ( + { A situation (.sit) file, which starts off a flight in a given } + { configuration. } + xplm_DataFile_Situation = 1 + + { A situation movie (.smo) file, which replays a past flight. } + ,xplm_DataFile_ReplayMovie = 2 + + ); + PXPLMDataFileType = ^XPLMDataFileType; +{$ENDIF XPLM200} + + { + XPLMGetSystemPath + + This function returns the full path to the X-System folder. Note that this + is a directory path, so it ends in a trailing : or /. + + The buffer you pass should be at least 512 characters long. The path is + returned using the current native or OS path conventions. + } + PROCEDURE XPLMGetSystemPath( + outSystemPath : XPLMString); + cdecl; external XPLM_DLL; + + { + XPLMGetPrefsPath + + This routine returns a full path to a file that is within X-Plane's + preferences directory. (You should remove the file name back to the last + directory separator to get the preferences directory using + XPLMExtractFileAndPath.) + + The buffer you pass should be at least 512 characters long. The path is + returned using the current native or OS path conventions. + } + PROCEDURE XPLMGetPrefsPath( + outPrefsPath : XPLMString); + cdecl; external XPLM_DLL; + + { + XPLMGetDirectorySeparator + + This routine returns a string with one char and a null terminator that is + the directory separator for the current platform. This allows you to write + code that concatinates directory paths without having to #ifdef for + platform. The character returned will reflect the current file path mode. + } + FUNCTION XPLMGetDirectorySeparator: XPLMString; + cdecl; external XPLM_DLL; + + { + XPLMExtractFileAndPath + + Given a full path to a file, this routine separates the path from the file. + If the path is a partial directory (e.g. ends in : or \) the trailing + directory separator is removed. This routine works in-place; a pointer to + the file part of the buffer is returned; the original buffer still starts + with the path and is null terminated with no trailing separator. + } + FUNCTION XPLMExtractFileAndPath( + inFullPath : XPLMString) : XPLMString; + cdecl; external XPLM_DLL; + + { + XPLMGetDirectoryContents + + This routine returns a list of files in a directory (specified by a full + path, no trailing : or \). The output is returned as a list of NULL + terminated strings. An index array (if specified) is filled with pointers + into the strings. The last file is indicated by a zero-length string (and + NULL in the indices). This routine will return 1 if you had capacity for + all files or 0 if you did not. You can also skip a given number of files. + + * inDirectoryPath - a null terminated C string containing the full path to + the directory with no trailing directory char. + + * inFirstReturn - the zero-based index of the first file in the directory + to return. (Usually zero to fetch all in one pass.) + + * outFileNames - a buffer to receive a series of sequential null + terminated C-string file names. A zero-length C string will be appended + to the very end. + + * inFileNameBufSize - the size of the file name buffer in bytes. + + * outIndices - a pointer to an array of character pointers that will + become an index into the directory. The last file will be followed by a + NULL value. Pass NULL if you do not want indexing information. + + * inIndexCount - the max size of the index in entries. + + * outTotalFiles - if not NULL, this is filled in with the number of files + in the directory. + + * outReturnedFiles - if not NULL, the number of files returned by this + iteration. + + Return value: 1 if all info could be returned, 0 if there was a buffer + overrun. + + WARNING: Before X-Plane 7 this routine did not properly iterate through + directories. If X-Plane + 6 compatibility is needed, use your own code to iterate directories. + } + FUNCTION XPLMGetDirectoryContents( + inDirectoryPath : XPLMString; + inFirstReturn : Integer; + outFileNames : XPLMString; + inFileNameBufSize : Integer; + outIndices : PXPLMString; { Can be nil } + inIndexCount : Integer; + outTotalFiles : PInteger; { Can be nil } + outReturnedFiles : PInteger) : Integer; { Can be nil } + cdecl; external XPLM_DLL; + +{$IFDEF XPLM200} + { + XPLMLoadDataFile + + Loads a data file of a given type. Paths must be relative to the X-System + folder. To clear the replay, pass a NULL file name (this is only valid with + replay movies, not sit files). + } + FUNCTION XPLMLoadDataFile( + inFileType : XPLMDataFileType; + inFilePath : XPLMString) : Integer; { Can be nil } + cdecl; external XPLM_DLL; +{$ENDIF XPLM200} + +{$IFDEF XPLM200} + { + XPLMSaveDataFile + + Saves the current situation or replay; paths are relative to the X-System + folder. + } + FUNCTION XPLMSaveDataFile( + inFileType : XPLMDataFileType; + inFilePath : XPLMString) : Integer; + cdecl; external XPLM_DLL; +{$ENDIF XPLM200} + +{___________________________________________________________________________ + * X-PLANE MISC + ___________________________________________________________________________} + + { + XPLMHostApplicationID + + While the plug-in SDK is only accessible to plugins running inside X-Plane, + the original authors considered extending the API to other applications + that shared basic infrastructure with X-Plane. These enumerations are + hold-overs from that original roadmap; all values other than X-Plane are + deprecated. Your plugin should never need this enumeration. + } +TYPE + XPLMHostApplicationID = ( + xplm_Host_Unknown = 0 + + ,xplm_Host_XPlane = 1 + +{$IFDEF XPLM_DEPRECATED} + ,xplm_Host_PlaneMaker = 2 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + ,xplm_Host_WorldMaker = 3 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + ,xplm_Host_Briefer = 4 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + ,xplm_Host_PartMaker = 5 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + ,xplm_Host_YoungsMod = 6 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + ,xplm_Host_XAuto = 7 +{$ENDIF XPLM_DEPRECATED} + + ); + PXPLMHostApplicationID = ^XPLMHostApplicationID; + + { + XPLMLanguageCode + + These enums define what language the sim is running in. These enumerations + do not imply that the sim can or does run in all of these languages; they + simply provide a known encoding in the event that a given sim version is + localized to a certain language. + } + XPLMLanguageCode = ( + xplm_Language_Unknown = 0 + + ,xplm_Language_English = 1 + + ,xplm_Language_French = 2 + + ,xplm_Language_German = 3 + + ,xplm_Language_Italian = 4 + + ,xplm_Language_Spanish = 5 + + ,xplm_Language_Korean = 6 + +{$IFDEF XPLM200} + ,xplm_Language_Russian = 7 +{$ENDIF XPLM200} + +{$IFDEF XPLM200} + ,xplm_Language_Greek = 8 +{$ENDIF XPLM200} + +{$IFDEF XPLM200} + ,xplm_Language_Japanese = 9 +{$ENDIF XPLM200} + +{$IFDEF XPLM300} + ,xplm_Language_Chinese = 10 +{$ENDIF XPLM300} + + ); + PXPLMLanguageCode = ^XPLMLanguageCode; + +{$IFDEF XPLM200} + { + XPLMError_f + + An XPLM error callback is a function that you provide to receive debugging + information from the plugin SDK. See XPLMSetErrorCallback for more + information. NOTE: for the sake of debugging, your error callback will be + called even if your plugin is not enabled, allowing you to receive debug + info in your XPluginStart and XPluginStop callbacks. To avoid causing logic + errors in the management code, do not call any other plugin routines from + your error callback - it is only meant for catching errors in the + debugging. + } +TYPE + XPLMError_f = PROCEDURE( + inMessage : XPLMString); cdecl; +{$ENDIF XPLM200} + +{$IFDEF XPLM_DEPRECATED} + { + XPLMInitialized + + Deprecated: This function returns 1 if X-Plane has properly initialized the + plug-in system. If this routine returns 0, many XPLM functions will not + work. + + NOTE: because plugins are always called from within the XPLM, there is no + need to check for initialization; it will always return 1. This routine is + deprecated - you do not need to check it before continuing within your + plugin. + } + FUNCTION XPLMInitialized: Integer; + cdecl; external XPLM_DLL; +{$ENDIF XPLM_DEPRECATED} + + { + XPLMGetVersions + + This routine returns the revision of both X-Plane and the XPLM DLL. All + versions are three-digit decimal numbers (e.g. 606 for version 6.06 of + X-Plane); the current revision of the XPLM is 200 (2.00). This routine also + returns the host ID of the app running us. + + The most common use of this routine is to special-case around X-Plane + version-specific behavior. + } + PROCEDURE XPLMGetVersions( + outXPlaneVersion : PInteger; + outXPLMVersion : PInteger; + outHostID : PXPLMHostApplicationID); + cdecl; external XPLM_DLL; + + { + XPLMGetLanguage + + This routine returns the langauge the sim is running in. + } + FUNCTION XPLMGetLanguage: XPLMLanguageCode; + cdecl; external XPLM_DLL; + +{$IFDEF XPLM200} + { + XPLMFindSymbol + + This routine will attempt to find the symbol passed in the inString + parameter. If the symbol is found a pointer the function is returned, + othewise the function will return NULL. + + You can use XPLMFindSymbol to utilize newer SDK API features without + requiring newer versions of the SDK (and X-Plane) as your minimum X-Plane + version as follows: + + * Define the XPLMnnn macro to the minimum required XPLM version you will + ship with (e.g. XPLM210 for X-Plane 10 compatibility). + + * Use XPLMGetVersions and XPLMFindSymbol to detect that the host sim is + new enough to use new functions and resolve function pointers. + + * Conditionally use the new functions if and only if XPLMFindSymbol only + returns a non- NULL pointer. + + Warning: you should always check the XPLM API version as well as the + results of XPLMFindSymbol to determine if funtionality is safe to use. + + To use functionality via XPLMFindSymbol you will need to copy your own + definitions of the X-Plane API prototypes and cast the returned pointer to + the correct type. + } + FUNCTION XPLMFindSymbol( + inString : XPLMString) : pointer; + cdecl; external XPLM_DLL; +{$ENDIF XPLM200} + +{$IFDEF XPLM200} + { + XPLMSetErrorCallback + + XPLMSetErrorCallback installs an error-reporting callback for your plugin. + Normally the plugin system performs minimum diagnostics to maximize + performance. When you install an error callback, you will receive calls due + to certain plugin errors, such as passing bad parameters or incorrect data. + + Important: the error callback determines *programming* errors, e.g. bad API + parameters. Every error that is returned by the error callback represents a + mistake in your plugin that you should fix. Error callbacks are not used to + report expected run-time problems (e.g. disk I/O errors). + + The intention is for you to install the error callback during debug + sections and put a break-point inside your callback. This will cause you to + break into the debugger from within the SDK at the point in your plugin + where you made an illegal call. + + Installing an error callback may activate error checking code that would + not normally run, and this may adversely affect performance, so do not + leave error callbacks installed in shipping plugins. Since the only useful + response to an error is to change code, error callbacks are not useful "in + the field". + } + PROCEDURE XPLMSetErrorCallback( + inCallback : XPLMError_f); + cdecl; external XPLM_DLL; +{$ENDIF XPLM200} + + { + XPLMDebugString + + This routine outputs a C-style string to the Log.txt file. The file is + immediately flushed so you will not lose data. (This does cause a + performance penalty.) + + Please do *not* leave routine diagnostic logging enabled in your shipping + plugin. The X-Plane Log file is shared by X-Plane and every plugin in the + system, and plugins that (when functioning normally) print verbose log + output make it difficult for developers to find error conditions from other + parts of the system. + } + PROCEDURE XPLMDebugString( + inString : XPLMString); + cdecl; external XPLM_DLL; + + { + XPLMSpeakString + + This function displays the string in a translucent overlay over the current + display and also speaks the string if text-to-speech is enabled. The string + is spoken asynchronously, this function returns immediately. This function + may not speak or print depending on user preferences. + } + PROCEDURE XPLMSpeakString( + inString : XPLMString); + cdecl; external XPLM_DLL; + + { + XPLMGetVirtualKeyDescription + + Given a virtual key code (as defined in XPLMDefs.h) this routine returns a + human-readable string describing the character. This routine is provided + for showing users what keyboard mappings they have set up. The string may + read 'unknown' or be a blank or NULL string if the virtual key is unknown. + } + FUNCTION XPLMGetVirtualKeyDescription( + inVirtualKey : XPLMChar) : XPLMString; + cdecl; external XPLM_DLL; + + { + XPLMReloadScenery + + XPLMReloadScenery reloads the current set of scenery. You can use this + function in two typical ways: simply call it to reload the scenery, picking + up any new installed scenery, .env files, etc. from disk. Or, change the + lat/ref and lon/ref data refs and then call this function to shift the + scenery environment. This routine is equivalent to picking "reload + scenery" from the developer menu. + } + PROCEDURE XPLMReloadScenery; + cdecl; external XPLM_DLL; + +{$IFDEF XPLM200} +{___________________________________________________________________________ + * X-PLANE COMMAND MANAGEMENT + ___________________________________________________________________________} +{ + The command management APIs let plugins interact with the command-system in + X-Plane, the abstraction behind keyboard presses and joystick buttons. This + API lets you create new commands and modify the behavior (or get + notification) of existing ones. + + X-Plane Command Phases + ---------------------- + + X-Plane commands are not instantaneous; they operate over a duration. + (Think of a joystick button press - you can press, hold down, and then + release the joystick button; X-Plane commands model this entire process.) + + An X-Plane command consists of three phases: a beginning, continuous + repetition, and an ending. The command may be repeated zero times in its + duration, followed by one command ending. Command begin and end messges are + balanced, but a command may be bound to more than one event source (e.g. a + keyboard key and a joystick button), in which case you may receive a second + begin during before any end). + + When you issue commands in the plugin system, you *must* balance every call + to XPLMCommandBegin with a call to XPLMCommandEnd with the same command + reference. + + Command Behavior Modification + ----------------------------- + + You can register a callback to handle a command either before or after + X-Plane does; if you receive the command before X-Plane you have the option + to either let X-Plane handle the command or hide the command from X-Plane. + This lets plugins both augment commands and replace them. + + If you register for an existing command, be sure that you are *consistent* + in letting X-Plane handle or not handle the command; you are responsible + for passing a *balanced* number of begin and end messages to X-Plane. (E.g. + it is not legal to pass all the begin messages to X-Plane but hide all the + end messages). +} + + + { + XPLMCommandPhase + + The phases of a command. + } +TYPE + XPLMCommandPhase = ( + { The command is being started. } + xplm_CommandBegin = 0 + + { The command is continuing to execute. } + ,xplm_CommandContinue = 1 + + { The command has ended. } + ,xplm_CommandEnd = 2 + + ); + PXPLMCommandPhase = ^XPLMCommandPhase; + + { + XPLMCommandRef + + A command ref is an opaque identifier for an X-Plane command. Command + references stay the same for the life of your plugin but not between + executions of X-Plane. Command refs are used to execute commands, create + commands, and create callbacks for particular commands. + + Note that a command is not "owned" by a particular plugin. Since many + plugins may participate in a command's execution, the command does not go + away if the plugin that created it is unloaded. + } + XPLMCommandRef = pointer; + PXPLMCommandRef = ^XPLMCommandRef; + + { + XPLMCommandCallback_f + + A command callback is a function in your plugin that is called when a + command is pressed. Your callback receives the command reference for the + particular command, the phase of the command that is executing, and a + reference pointer that you specify when registering the callback. + + Your command handler should return 1 to let processing of the command + continue to other plugins and X-Plane, or 0 to halt processing, potentially + bypassing X-Plane code. + } + XPLMCommandCallback_f = FUNCTION( + inCommand : XPLMCommandRef; + inPhase : XPLMCommandPhase; + inRefcon : pointer) : Integer; cdecl; + + { + XPLMFindCommand + + XPLMFindCommand looks up a command by name, and returns its command + reference or NULL if the command does not exist. + } + FUNCTION XPLMFindCommand( + inName : XPLMString) : XPLMCommandRef; + cdecl; external XPLM_DLL; + + { + XPLMCommandBegin + + XPLMCommandBegin starts the execution of a command, specified by its + command reference. The command is "held down" until XPLMCommandEnd is + called. You must balance each XPLMCommandBegin call with an XPLMCommandEnd + call. + } + PROCEDURE XPLMCommandBegin( + inCommand : XPLMCommandRef); + cdecl; external XPLM_DLL; + + { + XPLMCommandEnd + + XPLMCommandEnd ends the execution of a given command that was started with + XPLMCommandBegin. You must not issue XPLMCommandEnd for a command you did + not begin. + } + PROCEDURE XPLMCommandEnd( + inCommand : XPLMCommandRef); + cdecl; external XPLM_DLL; + + { + XPLMCommandOnce + + This executes a given command momentarily, that is, the command begins and + ends immediately. This is the equivalent of calling XPLMCommandBegin() and + XPLMCommandEnd() back ot back. + } + PROCEDURE XPLMCommandOnce( + inCommand : XPLMCommandRef); + cdecl; external XPLM_DLL; + + { + XPLMCreateCommand + + XPLMCreateCommand creates a new command for a given string. If the command + already exists, the existing command reference is returned. The description + may appear in user interface contexts, such as the joystick configuration + screen. + } + FUNCTION XPLMCreateCommand( + inName : XPLMString; + inDescription : XPLMString) : XPLMCommandRef; + cdecl; external XPLM_DLL; + + { + XPLMRegisterCommandHandler + + XPLMRegisterCommandHandler registers a callback to be called when a command + is executed. You provide a callback with a reference pointer. + + If inBefore is true, your command handler callback will be executed before + X-Plane executes the command, and returning 0 from your callback will + disable X-Plane's processing of the command. If inBefore is false, your + callback will run after X-Plane. (You can register a single callback both + before and after a command.) + } + PROCEDURE XPLMRegisterCommandHandler( + inComand : XPLMCommandRef; + inHandler : XPLMCommandCallback_f; + inBefore : Integer; + inRefcon : pointer); + cdecl; external XPLM_DLL; + + { + XPLMUnregisterCommandHandler + + XPLMUnregisterCommandHandler removes a command callback registered with + XPLMRegisterCommandHandler. + } + PROCEDURE XPLMUnregisterCommandHandler( + inComand : XPLMCommandRef; + inHandler : XPLMCommandCallback_f; + inBefore : Integer; + inRefcon : pointer); + cdecl; external XPLM_DLL; + +{$ENDIF XPLM200} +{$IFDEF XPLM_DEPRECATED} +{___________________________________________________________________________ + * X-PLANE USER INTERACTION + ___________________________________________________________________________} +{ + WARNING: The legacy user interaction API is deprecated; while it was the + only way to run commands in X-Plane 6,7 and 8, it is obsolete, and was + replaced by the command system API in X-Plane 9. You should not use this + API; replace any of the calls below with XPLMCommand invocations based on + persistent command strings. The documentation that follows is for historic + reference only. + + The legacy user interaction APIs let you simulate commands the user can do + with a joystick, keyboard etc. Note that it is generally safer for future + compatibility to use one of these commands than to manipulate the + underlying sim data. +} + + + { + XPLMCommandKeyID + + These enums represent all the keystrokes available within X-Plane. They can + be sent to X-Plane directly. For example, you can reverse thrust using + these enumerations. + } +TYPE + XPLMCommandKeyID = ( + xplm_key_pause=0, + xplm_key_revthrust, + xplm_key_jettison, + xplm_key_brakesreg, + xplm_key_brakesmax, + xplm_key_gear, + xplm_key_timedn, + xplm_key_timeup, + xplm_key_fadec, + xplm_key_otto_dis, + xplm_key_otto_atr, + xplm_key_otto_asi, + xplm_key_otto_hdg, + xplm_key_otto_gps, + xplm_key_otto_lev, + xplm_key_otto_hnav, + xplm_key_otto_alt, + xplm_key_otto_vvi, + xplm_key_otto_vnav, + xplm_key_otto_nav1, + xplm_key_otto_nav2, + xplm_key_targ_dn, + xplm_key_targ_up, + xplm_key_hdgdn, + xplm_key_hdgup, + xplm_key_barodn, + xplm_key_baroup, + xplm_key_obs1dn, + xplm_key_obs1up, + xplm_key_obs2dn, + xplm_key_obs2up, + xplm_key_com1_1, + xplm_key_com1_2, + xplm_key_com1_3, + xplm_key_com1_4, + xplm_key_nav1_1, + xplm_key_nav1_2, + xplm_key_nav1_3, + xplm_key_nav1_4, + xplm_key_com2_1, + xplm_key_com2_2, + xplm_key_com2_3, + xplm_key_com2_4, + xplm_key_nav2_1, + xplm_key_nav2_2, + xplm_key_nav2_3, + xplm_key_nav2_4, + xplm_key_adf_1, + xplm_key_adf_2, + xplm_key_adf_3, + xplm_key_adf_4, + xplm_key_adf_5, + xplm_key_adf_6, + xplm_key_transpon_1, + xplm_key_transpon_2, + xplm_key_transpon_3, + xplm_key_transpon_4, + xplm_key_transpon_5, + xplm_key_transpon_6, + xplm_key_transpon_7, + xplm_key_transpon_8, + xplm_key_flapsup, + xplm_key_flapsdn, + xplm_key_cheatoff, + xplm_key_cheaton, + xplm_key_sbrkoff, + xplm_key_sbrkon, + xplm_key_ailtrimL, + xplm_key_ailtrimR, + xplm_key_rudtrimL, + xplm_key_rudtrimR, + xplm_key_elvtrimD, + xplm_key_elvtrimU, + xplm_key_forward, + xplm_key_down, + xplm_key_left, + xplm_key_right, + xplm_key_back, + xplm_key_tower, + xplm_key_runway, + xplm_key_chase, + xplm_key_free1, + xplm_key_free2, + xplm_key_spot, + xplm_key_fullscrn1, + xplm_key_fullscrn2, + xplm_key_tanspan, + xplm_key_smoke, + xplm_key_map, + xplm_key_zoomin, + xplm_key_zoomout, + xplm_key_cycledump, + xplm_key_replay, + xplm_key_tranID, + xplm_key_max + ); + PXPLMCommandKeyID = ^XPLMCommandKeyID; + + { + XPLMCommandButtonID + + These are enumerations for all of the things you can do with a joystick + button in X-Plane. They currently match the buttons menu in the equipment + setup dialog, but these enums will be stable even if they change in + X-Plane. + } + XPLMCommandButtonID = ( + xplm_joy_nothing=0, + xplm_joy_start_all, + xplm_joy_start_0, + xplm_joy_start_1, + xplm_joy_start_2, + xplm_joy_start_3, + xplm_joy_start_4, + xplm_joy_start_5, + xplm_joy_start_6, + xplm_joy_start_7, + xplm_joy_throt_up, + xplm_joy_throt_dn, + xplm_joy_prop_up, + xplm_joy_prop_dn, + xplm_joy_mixt_up, + xplm_joy_mixt_dn, + xplm_joy_carb_tog, + xplm_joy_carb_on, + xplm_joy_carb_off, + xplm_joy_trev, + xplm_joy_trm_up, + xplm_joy_trm_dn, + xplm_joy_rot_trm_up, + xplm_joy_rot_trm_dn, + xplm_joy_rud_lft, + xplm_joy_rud_cntr, + xplm_joy_rud_rgt, + xplm_joy_ail_lft, + xplm_joy_ail_cntr, + xplm_joy_ail_rgt, + xplm_joy_B_rud_lft, + xplm_joy_B_rud_rgt, + xplm_joy_look_up, + xplm_joy_look_dn, + xplm_joy_look_lft, + xplm_joy_look_rgt, + xplm_joy_glance_l, + xplm_joy_glance_r, + xplm_joy_v_fnh, + xplm_joy_v_fwh, + xplm_joy_v_tra, + xplm_joy_v_twr, + xplm_joy_v_run, + xplm_joy_v_cha, + xplm_joy_v_fr1, + xplm_joy_v_fr2, + xplm_joy_v_spo, + xplm_joy_flapsup, + xplm_joy_flapsdn, + xplm_joy_vctswpfwd, + xplm_joy_vctswpaft, + xplm_joy_gear_tog, + xplm_joy_gear_up, + xplm_joy_gear_down, + xplm_joy_lft_brake, + xplm_joy_rgt_brake, + xplm_joy_brakesREG, + xplm_joy_brakesMAX, + xplm_joy_speedbrake, + xplm_joy_ott_dis, + xplm_joy_ott_atr, + xplm_joy_ott_asi, + xplm_joy_ott_hdg, + xplm_joy_ott_alt, + xplm_joy_ott_vvi, + xplm_joy_tim_start, + xplm_joy_tim_reset, + xplm_joy_ecam_up, + xplm_joy_ecam_dn, + xplm_joy_fadec, + xplm_joy_yaw_damp, + xplm_joy_art_stab, + xplm_joy_chute, + xplm_joy_JATO, + xplm_joy_arrest, + xplm_joy_jettison, + xplm_joy_fuel_dump, + xplm_joy_puffsmoke, + xplm_joy_prerotate, + xplm_joy_UL_prerot, + xplm_joy_UL_collec, + xplm_joy_TOGA, + xplm_joy_shutdown, + xplm_joy_con_atc, + xplm_joy_fail_now, + xplm_joy_pause, + xplm_joy_rock_up, + xplm_joy_rock_dn, + xplm_joy_rock_lft, + xplm_joy_rock_rgt, + xplm_joy_rock_for, + xplm_joy_rock_aft, + xplm_joy_idle_hilo, + xplm_joy_lanlights, + xplm_joy_max + ); + PXPLMCommandButtonID = ^XPLMCommandButtonID; + + { + XPLMSimulateKeyPress + + This function simulates a key being pressed for X-Plane. The keystroke goes + directly to X-Plane; it is never sent to any plug-ins. However, since this + is a raw key stroke it may be mapped by the keys file or enter text into a + field. + + Deprecated: use XPLMCommandOnce + } + PROCEDURE XPLMSimulateKeyPress( + inKeyType : Integer; + inKey : Integer); + cdecl; external XPLM_DLL; + + { + XPLMCommandKeyStroke + + This routine simulates a command-key stroke. However, the keys are done by + function, not by actual letter, so this function works even if the user has + remapped their keyboard. Examples of things you might do with this include + pausing the simulator. + + Deprecated: use XPLMCommandOnce + } + PROCEDURE XPLMCommandKeyStroke( + inKey : XPLMCommandKeyID); + cdecl; external XPLM_DLL; + + { + XPLMCommandButtonPress + + This function simulates any of the actions that might be taken by pressing + a joystick button. However, this lets you call the command directly rather + than have to know which button is mapped where. Important: you must release + each button you press. The APIs are separate so that you can 'hold down' a + button for a fixed amount of time. + + Deprecated: use XPLMCommandBegin. + } + PROCEDURE XPLMCommandButtonPress( + inButton : XPLMCommandButtonID); + cdecl; external XPLM_DLL; + + { + XPLMCommandButtonRelease + + This function simulates any of the actions that might be taken by pressing + a joystick button. See XPLMCommandButtonPress. + + Deprecated: use XPLMCommandEnd. + } + PROCEDURE XPLMCommandButtonRelease( + inButton : XPLMCommandButtonID); + cdecl; external XPLM_DLL; + +{$ENDIF XPLM_DEPRECATED} + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/SDK/Libraries/Mac/XPLM.framework/XPLM b/XPLPro_Plugin_Source/SDK/SDK/Libraries/Mac/XPLM.framework/XPLM new file mode 100644 index 0000000..99a7a72 Binary files /dev/null and b/XPLPro_Plugin_Source/SDK/SDK/Libraries/Mac/XPLM.framework/XPLM differ diff --git a/XPLPro_Plugin_Source/SDK/SDK/Libraries/Mac/XPWidgets.framework/XPWidgets b/XPLPro_Plugin_Source/SDK/SDK/Libraries/Mac/XPWidgets.framework/XPWidgets new file mode 100644 index 0000000..16944be Binary files /dev/null and b/XPLPro_Plugin_Source/SDK/SDK/Libraries/Mac/XPWidgets.framework/XPWidgets differ diff --git a/XPLPro_Plugin_Source/SDK/SDK/README.txt b/XPLPro_Plugin_Source/SDK/SDK/README.txt new file mode 100644 index 0000000..e7090b5 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDK/README.txt @@ -0,0 +1,222 @@ +------------------------------------------------------------------------------- + THE X-PLANE PLUGIN SDK +------------------------------------------------------------------------------- + +This download contains the files necessary to build plugins for X-Plane. The +X-Plane plugin website is: + +http://https://developer.x-plane.com/sdk/ + +The website contains full documentation on the SDK including tech notes, sample +plugins, sample code, contact information, and links to the latest versions of +this SDK. + +------------------------------------------------------------------------------- + SDK FILES +------------------------------------------------------------------------------- + +license.txt Copyright information for this download. +README.txt This document +CHeaders Header files for compiling C/C++ plugins +Delphi Interfaces for compiling Pascal plugins +Libraries Import libraries for linking on Windows + and frameworks for linking on Mac. + +Note: there are no import/link-time libraries for Linux; on Linux, plugins +simply leave SDK symbols undefined and they are discovered at runtime. The +SDK website explains this process in more detail. + +------------------------------------------------------------------------------- + RELEASE NOTES +------------------------------------------------------------------------------- + +This section contains per-release notes for the history of the X-Plane SDK. + +X-PLane SDK Release 4.0.0 beta 1 9/18/2022 + +The 4.0.0 SDK adds support for ARM64 Macs. The 4.0 SDK is supported by X-Plane +12. The new SDK adds support for drawing hooks that draw directly to the G1000 +and other avionic cockpit devices. + +X-Plane SDK Release 3.0.2 4/29/2020 + +The SDK 3.0.2 adds the modern 3-d drawing callback for interoperability with +Metal and Vulkan, and deprecates most older drawing callbacks. + +X-Plane SDK Release 3.0.1 3/5/2018 + +The SDK 3.0.1 API adds new messages and APIs to support VR. + +X-Plane SDK Release 3.0.0 11/2/7/2017 + +The SDK 3.0 API supports new features and new packaging for plugins. The 3.0 +SDK requires X-Plane 11.0 or newer. New features include: + + - Display APIs to match X-Plane 11's UI. + - New map APIs. Legacy 2-d map draw callbacks are deprecated. + - Aircraft-plugins get their own menu + - Aircraft placement by lat-lon-elevation. + - Magnetic variation queries + - Chinese language support + - New instancing API + +The 3.0 SDK supports a new plugin packaging schema: + + //.xpl + +where ABI is one of mac_x64, win_x64 or lin_x64. The new schema is preferred, +so you can pack a version of your plugin that requires 3.0 with this scheme +and include a legacy 2.x plugin using hte old scheme for X-Plane 10 +compatibility. + +Please use the new scheme where possible - having a unique file name for each +DLL makes crash reports easier to read and triage. + +The 3.0 SDK drops support for 32-bit plugins; if you need to ship a 32-bit +plugin for 32-bit X-Plane 10, shipping using two schemes and two binaries may +be the best option. + +X-Plane SDK Release 2.1.3 11/14/13 + +Fixed XPC Wrappers to use int and intptr_t instead of long. This fixes +crashes for plugins on 64-bit Windows. + +X-Plane SDK Release 2.1.2 RC2 1/15/13 + +Removed headers from frameworks, as they don't work; updated README. + +X-Plane SDK Release 2.1.2 RC1 1/12/13 + +The 2.1.2 SDK adds frameworks for the XPLM and XPWidgets; Mac developers +can link directly against these frameworks and avoid unresolved symbols +and flat namespace problems. The frameworks produce plugins that will +work on X-Plane 8, 9, and 10 depending on the plugin CPU architecture, +minimum system SDK, and XPLM API revision number. + +X-Plane SDK Release 2.1.1 RC1 10/29/12 + +The 2.1.1 update to the SDK provides 64-bit build materials. + +X-Plane SDK Release 2.1.0 RC1 3/31/12 + +This is the first release of the version 2.1 X-Plane SDK. This version of the +SDK exposes new APIs. + +This API also replaces all references to "long" with int or intptr_t, +depending on whether the integer needs to be wide enough to hold coerced +pointers. Most of the time, int is used; the notable exception is the widgets +library where params and properties can contain pointers to user data. + +This change is not an ABI change - compiled plugins will work unmodified. +However for some compilers, you may need to replace long with int or intptr_t +in your code. + +X-Plane SDK Release 2.0.1 RC1 7/21/10 + +This release adds symbol visibility macros for GCC 4 on Linux and corrects a few +function documentation comments. + +X-Plane SDK Release 2.0 RC1 7/11/08 + +This release includes a corrected XPLM.lib for windows with exports for some of +the new 2.0 APIs. + +X-Plane SDK Release 2.0 Beta 2 4/23/08 + +This release includes new APIs for reading and writing data files and drawing +hooks for the local map screen, as well as some minor tweaks: + +- Sim version is 2.0 in the headers. +- unload plane msg marked as 2.0 only. +- New enumerations for additional languages. +- Function level docs improved. + +X-Plane SDK Release 2.0 Beta 1 1/19/08 + +This is the first release of the version 2.0 X-Plane SDK. CFM support has +been removed, and the license has been simplified, reflecting that it only has +to cover the SDK include/import lib files and not the sample code or examples. + +X-Plane SDK Release 1.0.2 1/5/05 + +The headers of the SDK are modified to support Kylix. No changes for Mac, +Windows, or C users. Headers now have SDK version numbers. + +X-Plane SDK Release 1.0.1 12/29/04 + +The headers of this SDK are modified to support Linux complication. No changes +for Mac and Windows users. + +X-Plane SDK Release Candidate 1 + +Only one slight change in the enums: the enum xpProperty_SubWindowHasCloseBoxes +in XPStandardWidgets.h has been changed to xpProperty_MainWindowHasCloseBoxes. +Its value has not been changed, so you will need to search-and-replace your code +when using this version of the SDK, but already-compiled plugins will experience +no different operation. + +The documentation has been revised for all headers to revise changes made to the +SDK over the course of beta. + +X-Plane SDK Beta 5 + +This version of the SDK features a number of enumeration changes to reflect the +X-Plane interface more correctly. This became crucial when X-Plane 7's new user +interface was released. With X-Plane in release candidates hopefully beta 5 of +the SDK could be the last one. Please see: + +www.xsquawkbox.net/xpsdk/newui.html + +For a comprehensive description of all the enumeration changes. For most +plugins (no developers reported using the deprecated enumerations), a simple +search and replace should suffice. Plugins compiled against the beta 4 SDK that +do not use now-unsupported graphics will continue to work correctly. + +X-Plane SDK Beta 4 + +This release corrects two problems with the Pascal headers: function pointer +types are now declared cdecl (since this is how the SDK calls them), and the +import library for the widget callbacks is now XPWIDGETS.DLL as it should be. + +X-Plane SDK Beta 3 + +This release finally features full documentation and a stable widgets API, as +well as a few other minor bug fixes. + +Starting with beta 3, the DLLs necessary to run plugins ship with X-Plane 660. +The SDK will work with X-Plane 660 RC3 and later. The XPWidgets DLL now lives +in the Resources/plugins folder. + +Starting with beta 3, extra plugins, documentation, sample code, and sample +projects are now featured directly on the web in the new X-Plane SDK library. +They are not included in the SDK zip file; the zip file only contains headers +and lib files for the SDK. + +X-Plane SDK Beta 2 + +You must recompile your plugin for the beta 2 plugin SDK! Plugins compiled +against the beta 1 SDK will not work with X-Plane 660 or the new XPLM.DLL. + +A huge number of data refs have been added. Unfortunately the documentation +is thin. Use the data ref tester plugin to view the data refs in real time +and find what you need. + +The data ref APIs have also changed to allow for arrays of integers as well +as floats. Some sim variables are now arrays that were previously many +individual items. + +A new drawing phase is available for replacing aircraft graphics. The +texturing APIs in XPLMGraphics have been revised. The most notable change is +that you cannot use the SDK to load your textures. (This functionality was +broken and never worked in beta 1.) See the x-plane-dev list for sample code +on how to load your own bitmaps. + +X-Plane can reload plugins on the fly. Use the Plugin Enabler plugin to reload +your plugin. On the Mac you can throw the old DLL in the trash and put a new +one in its place to reload a new version of the plugin. On the PC, an alert +comes up; while this alert is up you can swap your plugins' DLL. This allows +you to recompile your plugin without rebooting the sim. + +Delphi Pascal interfaces and sample code are in the SDK. Thanks to Billy +Verreynne for his hard work on this. + diff --git a/XPLPro_Plugin_Source/SDK/SDK/license.txt b/XPLPro_Plugin_Source/SDK/SDK/license.txt new file mode 100644 index 0000000..8b9cbfc --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDK/license.txt @@ -0,0 +1,27 @@ +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. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/Widgets/XPStandardWidgets.h b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/Widgets/XPStandardWidgets.h new file mode 100644 index 0000000..42d4987 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/Widgets/XPStandardWidgets.h @@ -0,0 +1,556 @@ +#ifndef _XPStandardWidgets_h_ +#define _XPStandardWidgets_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPStandardWidgets + ***************************************************************************/ +/* + * ## THEORY OF OPERATION + * + * The standard widgets are widgets built into the widgets library. While you + * can gain access to the widget function that drives them, you generally use + * them by calling XPCreateWidget and then listening for special messages, + * etc. + * + * The standard widgets often send mesages to themselves when the user + * performs an event; these messages are sent up the widget hierarchy until + * they are handled. So you can add a widget proc directly to a push button + * (for example) to intercept the message when it is clicked, or you can put + * one widget proc on a window for all of the push buttons in the window. Most + * of these messages contain the original widget ID as a parameter so you can + * know which widget is messaging no matter who it is sent to. + * + */ + +#include "XPWidgetDefs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*************************************************************************** + * MAIN WINDOW + ***************************************************************************/ +/* + * The main window widget class provides a "window" as the user knows it. + * These windows are dragable and can be selected. Use them to create floating + * windows and non-modal dialogs. + * + */ + + +#define xpWidgetClass_MainWindow 1 + +/* + * Main Window Type Values + * + * These type values are used to control the appearance of a main window. + * + */ +enum { + /* The standard main window; pin stripes on XP7, metal frame on XP 6. */ + xpMainWindowStyle_MainWindow = 0, + + /* A translucent dark gray window, like the one ATC messages appear in. */ + xpMainWindowStyle_Translucent = 1, + + +}; + +/* + * Main Window Properties + * + */ +enum { + /* This property specifies the type of window. Set to one of the main window * + * types above. */ + xpProperty_MainWindowType = 1100, + + /* This property specifies whether the main window has close boxes in its * + * corners. */ + xpProperty_MainWindowHasCloseBoxes = 1200, + + +}; + +/* + * MainWindow Messages + * + */ +enum { + /* This message is sent when the close buttons are pressed for your window. */ + xpMessage_CloseButtonPushed = 1200, + + +}; + +/*************************************************************************** + * SUB WINDOW + ***************************************************************************/ +/* + * X-Plane dialogs are divided into separate areas; the sub window widgets + * allow you to make these areas. Create one main window and place several + * subwindows inside it. Then place your controls inside the subwindows. + * + */ + + +#define xpWidgetClass_SubWindow 2 + +/* + * SubWindow Type Values + * + * These values control the appearance of the subwindow. + * + */ +enum { + /* A panel that sits inside a main window. */ + xpSubWindowStyle_SubWindow = 0, + + /* A screen that sits inside a panel for showing text information. */ + xpSubWindowStyle_Screen = 2, + + /* A list view for scrolling lists. */ + xpSubWindowStyle_ListView = 3, + + +}; + +/* + * SubWindow Properties + * + */ +enum { + /* This property specifies the type of window. Set to one of the subwindow * + * types above. */ + xpProperty_SubWindowType = 1200, + + +}; + +/*************************************************************************** + * BUTTON + ***************************************************************************/ +/* + * The button class provides a number of different button styles and + * behaviors, including push buttons, radio buttons, check boxes, etc. The + * button label appears on or next to the button depending on the button's + * appearance, or type. + * + * The button's behavior is a separate property that dictates who it hilights + * and what kinds of messages it sends. Since behavior and type are different, + * you can do strange things like make check boxes that act as push buttons or + * push buttons with radio button behavior. + * + * In X-Plane 6 there were no check box graphics. The result is the following + * behavior: in X-Plane + * 6 all check box and radio buttons are round (radio-button style) buttons; + * in X-Plane 7 they are all square (check-box style) buttons. In a future + * version of X-Plane, the xpButtonBehavior enums will provide the correct + * graphic (check box or radio button) giving the expected result. + * + */ + + +#define xpWidgetClass_Button 3 + +/* + * Button Types + * + * These define the visual appearance of buttons but not how they respond to + * the mouse. + * + */ +enum { + /* This is a standard push button, like an 'OK' or 'Cancel' button in a dialog* + * box. */ + xpPushButton = 0, + + /* A check box or radio button. Use this and the button behaviors below to * + * get the desired behavior. */ + xpRadioButton = 1, + + /* A window close box. */ + xpWindowCloseBox = 3, + + /* A small down arrow. */ + xpLittleDownArrow = 5, + + /* A small up arrow. */ + xpLittleUpArrow = 6, + + +}; + +/* + * Button Behavior Values + * + * These define how the button responds to mouse clicks. + * + */ +enum { + /* Standard push button behavior. The button hilites while the mouse is * + * clicked over it and unhilites when the mouse is moved outside of it or * + * released. If the mouse is released over the button, the * + * xpMsg_PushButtonPressed message is sent. */ + xpButtonBehaviorPushButton = 0, + + /* Check box behavior. The button immediately toggles its value when the mouse* + * is clicked and sends out a xpMsg_ButtonStateChanged message. */ + xpButtonBehaviorCheckBox = 1, + + /* Radio button behavior. The button immediately sets its state to one and * + * sends out a xpMsg_ButtonStateChanged message if it was not already set to * + * one. You must turn off other radio buttons in a group in your code. */ + xpButtonBehaviorRadioButton = 2, + + +}; + +/* + * Button Properties + * + */ +enum { + /* This property sets the visual type of button. Use one of the button types * + * above. */ + xpProperty_ButtonType = 1300, + + /* This property sets the button's behavior. Use one of the button behaviors * + * above. */ + xpProperty_ButtonBehavior = 1301, + + /* This property tells whether a check box or radio button is "checked" or * + * not. Not used for push buttons. */ + xpProperty_ButtonState = 1302, + + +}; + +/* + * Button Messages + * + * These messages are sent by the button to itself and then up the widget + * chain when the button is clicked. (You may intercept them by providing a + * widget handler for the button itself or by providing a handler in a parent + * widget.) + * + */ +enum { + /* This message is sent when the user completes a click and release in a * + * button with push button behavior. Parameter one of the message is the * + * widget ID of the button. This message is dispatched up the widget * + * hierarchy. */ + xpMsg_PushButtonPressed = 1300, + + /* This message is sent when a button is clicked that has radio button or * + * check box behavior and its value changes. (Note that if the value changes * + * by setting a property you do not receive this message!) Parameter one is * + * the widget ID of the button, parameter 2 is the new state value, either * + * zero or one. This message is dispatched up the widget hierarchy. */ + xpMsg_ButtonStateChanged = 1301, + + +}; + +/*************************************************************************** + * TEXT FIELD + ***************************************************************************/ +/* + * The text field widget provides an editable text field including mouse + * selection and keyboard navigation. The contents of the text field are its + * descriptor. (The descriptor changes as the user types.) + * + * The text field can have a number of types, that effect the visual layout of + * the text field. The text field sends messages to itself so you may control + * its behavior. + * + * If you need to filter keystrokes, add a new handler and intercept the key + * press message. Since key presses are passed by pointer, you can modify the + * keystroke and pass it through to the text field widget. + * + * WARNING: in X-Plane before 7.10 (including 6.70) null characters could + * crash X-Plane. To prevent this, wrap this object with a filter function + * (more instructions can be found on the SDK website). + * + */ + + +#define xpWidgetClass_TextField 4 + +/* + * Text Field Type Values + * + * These control the look of the text field. + * + */ +enum { + /* A field for text entry. */ + xpTextEntryField = 0, + + /* A transparent text field. The user can type and the text is drawn, but no * + * background is drawn. You can draw your own background by adding a widget * + * handler and prehandling the draw message. */ + xpTextTransparent = 3, + + /* A translucent edit field, dark gray. */ + xpTextTranslucent = 4, + + +}; + +/* + * Text Field Properties + * + */ +enum { + /* This is the character position the selection starts at, zero based. If it * + * is the same as the end insertion point, the insertion point is not a * + * selection. */ + xpProperty_EditFieldSelStart = 1400, + + /* This is the character position of the end of the selection. */ + xpProperty_EditFieldSelEnd = 1401, + + /* This is the character position a drag was started at if the user is * + * dragging to select text, or -1 if a drag is not in progress. */ + xpProperty_EditFieldSelDragStart = 1402, + + /* This is the type of text field to display, from the above list. */ + xpProperty_TextFieldType = 1403, + + /* Set this property to 1 to password protect the field. Characters will be * + * drawn as *s even though the descriptor will contain plain-text. */ + xpProperty_PasswordMode = 1404, + + /* The max number of characters you can enter, if limited. Zero means * + * unlimited. */ + xpProperty_MaxCharacters = 1405, + + /* The first visible character on the left. This effectively scrolls the text* + * field. */ + xpProperty_ScrollPosition = 1406, + + /* The font to draw the field's text with. (An XPLMFontID.) */ + xpProperty_Font = 1407, + + /* This is the active side of the insert selection. (Internal) */ + xpProperty_ActiveEditSide = 1408, + + +}; + +/* + * Text Field Messages + * + */ +enum { + /* The text field sends this message to itself when its text changes. It sends* + * the message up the call chain; param1 is the text field's widget ID. */ + xpMsg_TextFieldChanged = 1400, + + +}; + +/*************************************************************************** + * SCROLL BAR + ***************************************************************************/ +/* + * A standard scroll bar or slider control. The scroll bar has a minimum, + * maximum and current value that is updated when the user drags it. The + * scroll bar sends continuous messages as it is dragged. + * + */ + + +#define xpWidgetClass_ScrollBar 5 + +/* + * Scroll Bar Type Values + * + * This defines how the scroll bar looks. + * + */ +enum { + /* A standard X-Plane scroll bar (with arrows on the ends). */ + xpScrollBarTypeScrollBar = 0, + + /* A slider, no arrows. */ + xpScrollBarTypeSlider = 1, + + +}; + +/* + * Scroll Bar Properties + * + */ +enum { + /* The current position of the thumb (in between the min and max, inclusive) */ + xpProperty_ScrollBarSliderPosition = 1500, + + /* The value the scroll bar has when the thumb is in the lowest position. */ + xpProperty_ScrollBarMin = 1501, + + /* The value the scroll bar has when the thumb is in the highest position. */ + xpProperty_ScrollBarMax = 1502, + + /* How many units to move the scroll bar when clicking next to the thumb. The * + * scroll bar always moves one unit when the arrows are clicked. */ + xpProperty_ScrollBarPageAmount = 1503, + + /* The type of scrollbar from the enums above. */ + xpProperty_ScrollBarType = 1504, + + /* Used internally. */ + xpProperty_ScrollBarSlop = 1505, + + +}; + +/* + * Scroll Bar Messages + * + */ +enum { + /* The scroll bar sends this message when the slider position changes. It * + * sends the message up the call chain; param1 is the Scroll Bar widget ID. */ + xpMsg_ScrollBarSliderPositionChanged = 1500, + + +}; + +/*************************************************************************** + * CAPTION + ***************************************************************************/ +/* + * A caption is a simple widget that shows its descriptor as a string, useful + * for labeling parts of a window. It always shows its descriptor as its + * string and is otherwise transparent. + * + */ + + +#define xpWidgetClass_Caption 6 + +/* + * Caption Properties + * + */ +enum { + /* This property specifies whether the caption is lit; use lit captions * + * against screens. */ + xpProperty_CaptionLit = 1600, + + +}; + +/*************************************************************************** + * GENERAL GRAPHICS + ***************************************************************************/ +/* + * The general graphics widget can show one of many icons available from + * X-Plane. + * + */ + + +#define xpWidgetClass_GeneralGraphics 7 + +/* + * General Graphics Types Values + * + * These define the icon for the general graphics. + * + */ +enum { + xpShip = 4, + + xpILSGlideScope = 5, + + xpMarkerLeft = 6, + + xp_Airport = 7, + + xpNDB = 8, + + xpVOR = 9, + + xpRadioTower = 10, + + xpAircraftCarrier = 11, + + xpFire = 12, + + xpMarkerRight = 13, + + xpCustomObject = 14, + + xpCoolingTower = 15, + + xpSmokeStack = 16, + + xpBuilding = 17, + + xpPowerLine = 18, + + xpVORWithCompassRose = 19, + + xpOilPlatform = 21, + + xpOilPlatformSmall = 22, + + xpWayPoint = 23, + + +}; + +/* + * General Graphics Properties + * + */ +enum { + /* This property controls the type of icon that is drawn. */ + xpProperty_GeneralGraphicsType = 1700, + + +}; + +/*************************************************************************** + * PROGRESS INDICATOR + ***************************************************************************/ +/* + * This widget implements a progress indicator as seen when X-Plane starts up. + * + */ + +#define xpWidgetClass_Progress 8 + +/* + * Progress Indicator Properties + * + */ +enum { + /* This is the current value of the progress indicator. */ + xpProperty_ProgressPosition = 1800, + + /* This is the minimum value, equivalent to 0% filled. */ + xpProperty_ProgressMin = 1801, + + /* This is the maximum value, equivalent to 100% filled. */ + xpProperty_ProgressMax = 1802, + + +}; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/Widgets/XPUIGraphics.h b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/Widgets/XPUIGraphics.h new file mode 100644 index 0000000..b70e0f6 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/Widgets/XPUIGraphics.h @@ -0,0 +1,354 @@ +#ifndef _XPUIGraphics_h_ +#define _XPUIGraphics_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPUIGraphics + ***************************************************************************/ + +#include "XPWidgetDefs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*************************************************************************** + * UI GRAPHICS + ***************************************************************************/ + +/* + * XPWindowStyle + * + * There are a few built-in window styles in X-Plane that you can use. + * + * Note that X-Plane 6 does not offer real shadow-compositing; you must make + * sure to put a window on top of another window of the right style to the + * shadows work, etc. This applies to elements with insets and shadows. The + * rules are: + * + * Sub windows must go on top of main windows, and screens and list views on + * top of subwindows. Only help and main windows can be over the main screen. + * + * With X-Plane 7 any window or element may be placed over any other element. + * + * Some windows are scaled by stretching, some by repeating. The drawing + * routines know which scaling method to use. The list view cannot be rescaled + * in X-Plane 6 because it has both a repeating pattern and a gradient in one + * element. All other elements can be rescaled. + * + */ +enum { + /* An LCD screen that shows help. */ + xpWindow_Help = 0, + + /* A dialog box window. */ + xpWindow_MainWindow = 1, + + /* A panel or frame within a dialog box window. */ + xpWindow_SubWindow = 2, + + /* An LCD screen within a panel to hold text displays. */ + xpWindow_Screen = 4, + + /* A list view within a panel for scrolling file names, etc. */ + xpWindow_ListView = 5, + + +}; +typedef int XPWindowStyle; + +/* + * XPDrawWindow + * + * This routine draws a window of the given dimensions at the given offset on + * the virtual screen in a given style. The window is automatically scaled as + * appropriate using a bitmap scaling technique (scaling or repeating) as + * appropriate to the style. + * + */ +WIDGET_API void XPDrawWindow( + int inX1, + int inY1, + int inX2, + int inY2, + XPWindowStyle inStyle); + +/* + * XPGetWindowDefaultDimensions + * + * This routine returns the default dimensions for a window. Output is either + * a minimum or fixed value depending on whether the window is scalable. + * + */ +WIDGET_API void XPGetWindowDefaultDimensions( + XPWindowStyle inStyle, + int * outWidth, /* Can be NULL */ + int * outHeight); /* Can be NULL */ + +/* + * XPElementStyle + * + * Elements are individually drawable UI things like push buttons, etc. The + * style defines what kind of element you are drawing. Elements can be + * stretched in one or two dimensions (depending on the element). Some + * elements can be lit. + * + * In X-Plane 6 some elements must be drawn over metal. Some are scalable and + * some are not. Any element can be drawn anywhere in X-Plane 7. + * + * Scalable Axis Required Background + * + */ +enum { + /* x metal */ + xpElement_TextField = 6, + + /* none metal */ + xpElement_CheckBox = 9, + + /* none metal */ + xpElement_CheckBoxLit = 10, + + /* none window header */ + xpElement_WindowCloseBox = 14, + + /* none window header */ + xpElement_WindowCloseBoxPressed = 15, + + /* x metal */ + xpElement_PushButton = 16, + + /* x metal */ + xpElement_PushButtonLit = 17, + + /* none any */ + xpElement_OilPlatform = 24, + + /* none any */ + xpElement_OilPlatformSmall = 25, + + /* none any */ + xpElement_Ship = 26, + + /* none any */ + xpElement_ILSGlideScope = 27, + + /* none any */ + xpElement_MarkerLeft = 28, + + /* none any */ + xpElement_Airport = 29, + + /* none any */ + xpElement_Waypoint = 30, + + /* none any */ + xpElement_NDB = 31, + + /* none any */ + xpElement_VOR = 32, + + /* none any */ + xpElement_RadioTower = 33, + + /* none any */ + xpElement_AircraftCarrier = 34, + + /* none any */ + xpElement_Fire = 35, + + /* none any */ + xpElement_MarkerRight = 36, + + /* none any */ + xpElement_CustomObject = 37, + + /* none any */ + xpElement_CoolingTower = 38, + + /* none any */ + xpElement_SmokeStack = 39, + + /* none any */ + xpElement_Building = 40, + + /* none any */ + xpElement_PowerLine = 41, + + /* none metal */ + xpElement_CopyButtons = 45, + + /* none metal */ + xpElement_CopyButtonsWithEditingGrid = 46, + + /* x, y metal */ + xpElement_EditingGrid = 47, + + /* THIS CAN PROBABLY BE REMOVED */ + xpElement_ScrollBar = 48, + + /* none any */ + xpElement_VORWithCompassRose = 49, + + /* none metal */ + xpElement_Zoomer = 51, + + /* x, y metal */ + xpElement_TextFieldMiddle = 52, + + /* none metal */ + xpElement_LittleDownArrow = 53, + + /* none metal */ + xpElement_LittleUpArrow = 54, + + /* none metal */ + xpElement_WindowDragBar = 61, + + /* none metal */ + xpElement_WindowDragBarSmooth = 62, + + +}; +typedef int XPElementStyle; + +/* + * XPDrawElement + * + * XPDrawElement draws a given element at an offset on the virtual screen in + * set dimensions. + * *Even* if the element is not scalable, it will be scaled if the width and + * height do not match the preferred dimensions; it'll just look ugly. Pass + * inLit to see the lit version of the element; if the element cannot be lit + * this is ignored. + * + */ +WIDGET_API void XPDrawElement( + int inX1, + int inY1, + int inX2, + int inY2, + XPElementStyle inStyle, + int inLit); + +/* + * XPGetElementDefaultDimensions + * + * This routine returns the recommended or minimum dimensions of a given UI + * element. outCanBeLit tells whether the element has both a lit and unlit + * state. Pass `NULL` to not receive any of these parameters. + * + */ +WIDGET_API void XPGetElementDefaultDimensions( + XPElementStyle inStyle, + int * outWidth, /* Can be NULL */ + int * outHeight, /* Can be NULL */ + int * outCanBeLit); /* Can be NULL */ + +/* + * XPTrackStyle + * + * A track is a UI element that displays a value vertically or horizontally. + * X-Plane has three kinds of tracks: scroll bars, sliders, and progress bars. + * Tracks can be displayed either horizontally or vertically; tracks will + * choose their own layout based on the larger dimension of their dimensions + * (e.g. they know if they are tall or wide). Sliders may be lit or unlit + * (showing the user manipulating them). + * + * - ScrollBar: this is a standard scroll bar with arrows and a thumb to drag. + * - Slider: this is a simple track with a ball in the middle that can be + * slid. + * - Progress: this is a progress indicator showing how a long task is going. + * + */ +enum { + /* not over metal can be lit can be rotated */ + xpTrack_ScrollBar = 0, + + /* over metal can be lit can be rotated */ + xpTrack_Slider = 1, + + /* over metal cannot be lit cannot be rotated */ + xpTrack_Progress = 2, + + +}; +typedef int XPTrackStyle; + +/* + * XPDrawTrack + * + * This routine draws a track. You pass in the track dimensions and size; the + * track picks the optimal orientation for these dimensions. Pass in the + * track's minimum current and maximum values; the indicator will be + * positioned appropriately. You can also specify whether the track is lit or + * not. + * + */ +WIDGET_API void XPDrawTrack( + int inX1, + int inY1, + int inX2, + int inY2, + int inMin, + int inMax, + int inValue, + XPTrackStyle inTrackStyle, + int inLit); + +/* + * XPGetTrackDefaultDimensions + * + * This routine returns a track's default smaller dimension; all tracks are + * scalable in the larger dimension. It also returns whether a track can be + * lit. + * + */ +WIDGET_API void XPGetTrackDefaultDimensions( + XPTrackStyle inStyle, + int * outWidth, + int * outCanBeLit); + +/* + * XPGetTrackMetrics + * + * This routine returns the metrics of a track. If you want to write UI code + * to manipulate a track, this routine helps you know where the mouse + * locations are. For most other elements, the rectangle the element is drawn + * in is enough information. However, the scrollbar drawing routine does some + * automatic placement; this routine lets you know where things ended up. You + * pass almost everything you would pass to the draw routine. You get out the + * orientation, and other useful stuff. + * + * Besides orientation, you get five dimensions for the five parts of a + * scrollbar, which are the down button, down area (area before the thumb), + * the thumb, and the up area and button. For horizontal scrollers, the left + * button decreases; for vertical scrollers, the top button decreases. + * + */ +WIDGET_API void XPGetTrackMetrics( + int inX1, + int inY1, + int inX2, + int inY2, + int inMin, + int inMax, + int inValue, + XPTrackStyle inTrackStyle, + int * outIsVertical, + int * outDownBtnSize, + int * outDownPageSize, + int * outThumbSize, + int * outUpPageSize, + int * outUpBtnSize); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/Widgets/XPWidgetDefs.h b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/Widgets/XPWidgetDefs.h new file mode 100644 index 0000000..c1b2341 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/Widgets/XPWidgetDefs.h @@ -0,0 +1,472 @@ +#ifndef _XPWidgetDefs_h_ +#define _XPWidgetDefs_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPWidgetDefs + ***************************************************************************/ + +#include "XPLMDefs.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +#if APL + #if XPWIDGETS + #if __GNUC__ >= 4 + #define WIDGET_API __attribute__((visibility("default"))) + #elif __MACH__ + #define WIDGET_API + #else + #define WIDGET_API __declspec(dllexport) + #endif + #else + #define WIDGET_API + #endif +#elif IBM + #if XPWIDGETS + #define WIDGET_API __declspec(dllexport) + #else + #define WIDGET_API __declspec(dllimport) + #endif +#elif LIN + #if XPWIDGETS + #if __GNUC__ >= 4 + #define WIDGET_API __attribute__((visibility("default"))) + #else + #define WIDGET_API + #endif + #else + #define WIDGET_API + #endif +#else +#pragma error "Platform not defined!" +#endif + /*************************************************************************** + * WIDGET DEFINITIONS + ***************************************************************************/ +/* + * A widget is a call-back driven screen entity like a push-button, window, + * text entry field, etc. + * + * Use the widget API to create widgets of various classes. You can nest them + * into trees of widgets to create complex user interfaces. + * + */ + + +/* + * XPWidgetID + * + * A Widget ID is an opaque unique non-zero handle identifying your widget. + * Use 0 to specify "no widget". This type is defined as wide enough to hold a + * pointer. You receive a widget ID when you create a new widget and then use + * that widget ID to further refer to the widget. + * + */ +typedef void * XPWidgetID; + +/* + * XPWidgetPropertyID + * + * Properties are values attached to instances of your widgets. A property is + * identified by a 32-bit ID and its value is the width of a pointer. + * + * Each widget instance may have a property or not have it. When you set a + * property on a widget for the first time, the property is added to the + * widget; it then stays there for the life of the widget. + * + * Some property IDs are predefined by the widget package; you can make up + * your own property IDs as well. + * + */ +enum { + /* A window's refcon is an opaque value used by client code to find other data* + * based on it. */ + xpProperty_Refcon = 0, + + /* These properties are used by the utlities to implement dragging. */ + xpProperty_Dragging = 1, + + xpProperty_DragXOff = 2, + + xpProperty_DragYOff = 3, + + /* Is the widget hilited? (For widgets that support this kind of thing.) */ + xpProperty_Hilited = 4, + + /* Is there a C++ object attached to this widget? */ + xpProperty_Object = 5, + + /* If this property is 1, the widget package will use OpenGL to restrict * + * drawing to the Wiget's exposed rectangle. */ + xpProperty_Clip = 6, + + /* Is this widget enabled (for those that have a disabled state too)? */ + xpProperty_Enabled = 7, + + /* NOTE: Property IDs 1 - 999 are reserved for the widgets library. * + * * + * NOTE: Property IDs 1000 - 9999 are allocated to the standard widget classes* + * provided with the library. * + * * + * Properties 1000 - 1099 are for widget class 0, 1100 - 1199 for widget class* + * 1, etc. */ + xpProperty_UserStart = 10000, + + +}; +typedef int XPWidgetPropertyID; + +/* + * XPMouseState_t + * + * When the mouse is clicked or dragged, a pointer to this structure is passed + * to your widget function. + * + */ +typedef struct { + int x; + int y; + /* Mouse Button number, left = 0 (right button not yet supported. */ + int button; +#if defined(XPLM200) + /* Scroll wheel delta (button in this case would be the wheel axis number). */ + int delta; +#endif /* XPLM200 */ +} XPMouseState_t; + +/* + * XPKeyState_t + * + * When a key is pressed, a pointer to this struct is passed to your widget + * function. + * + */ +typedef struct { + /* The ASCII key that was pressed. WARNING: this may be 0 for some non-ASCII * + * key sequences. */ + char key; + /* The flags. Make sure to check this if you only want key-downs! */ + XPLMKeyFlags flags; + /* The virtual key code for the key */ + char vkey; +} XPKeyState_t; + +/* + * XPWidgetGeometryChange_t + * + * This structure contains the deltas for your widget's geometry when it + * changes. + * + */ +typedef struct { + int dx; + /* +Y = the widget moved up */ + int dy; + int dwidth; + int dheight; +} XPWidgetGeometryChange_t; + +/* + * XPDispatchMode + * + * The dispatching modes describe how the widgets library sends out messages. + * Currently there are three modes: + * + */ +enum { + /* The message will only be sent to the target widget. */ + xpMode_Direct = 0, + + /* The message is sent to the target widget, then up the chain of parents * + * until the message is handled or a parentless widget is reached. */ + xpMode_UpChain = 1, + + /* The message is sent to the target widget and then all of its children * + * recursively depth-first. */ + xpMode_Recursive = 2, + + /* The message is snet just to the target, but goes to every callback, even if* + * it is handled. */ + xpMode_DirectAllCallbacks = 3, + + /* The message is only sent to the very first handler even if it is not * + * accepted. (This is really only useful for some internal widget library * + * functions.) */ + xpMode_Once = 4, + + +}; +typedef int XPDispatchMode; + +/* + * XPWidgetClass + * + * Widget classes define predefined widget types. A widget class basically + * specifies from a library the widget function to be used for the widget. + * Most widgets can be made right from classes. + * + */ +typedef int XPWidgetClass; + +/* An unspecified widget class. Other widget classes are in * + * XPStandardWidgets.h */ +#define xpWidgetClass_None 0 + +/*************************************************************************** + * WIDGET MESSAGES + ***************************************************************************/ + +/* + * XPWidgetMessage + * + * Widgets receive 32-bit messages indicating what action is to be taken or + * notifications of events. The list of messages may be expanded. + * + */ +enum { + /* No message, should not be sent. */ + xpMsg_None = 0, + + /* The create message is sent once per widget that is created with your widget* + * function and once for any widget that has your widget function attached. * + * * + * Dispatching: Direct * + * * + * Param 1: 1 if you are being added as a subclass, 0 if the widget is first * + * being created. */ + xpMsg_Create = 1, + + /* The destroy message is sent once for each message that is destroyed that * + * has your widget function. * + * * + * Dispatching: Direct for all * + * * + * Param 1: 1 if being deleted by a recursive delete to the parent, 0 for * + * explicit deletion. */ + xpMsg_Destroy = 2, + + /* The paint message is sent to your widget to draw itself. The paint message * + * is the bare-bones message; in response you must draw yourself, draw your * + * children, set up clipping and culling, check for visibility, etc. If you * + * don't want to do all of this, ignore the paint message and a draw message * + * (see below) will be sent to you. * + * * + * Dispatching: Direct */ + xpMsg_Paint = 3, + + /* The draw message is sent to your widget when it is time to draw yourself. * + * OpenGL will be set up to draw in 2-d global screen coordinates, but you * + * should use the XPLM to set up OpenGL state. * + * * + * Dispatching: Direct */ + xpMsg_Draw = 4, + + /* The key press message is sent once per key that is pressed. The first * + * parameter is the type of key code (integer or char) and the second is the * + * code itself. By handling this event, you consume the key stroke. * + * * + * Handling this message 'consumes' the keystroke; not handling it passes it * + * to your parent widget. * + * * + * Dispatching: Up Chain * + * * + * Param 1: A pointer to an XPKeyState_t structure with the keystroke. */ + xpMsg_KeyPress = 5, + + /* Keyboard focus is being given to you. By handling this message you accept * + * keyboard focus. The first parameter will be one if a child of yours gave up* + * focus to you, 0 if someone set focus on you explicitly. * + * * + * Handling this message accepts focus; not handling refuses focus. * + * * + * Dispatching: direct * + * * + * Param 1: 1 if you are gaining focus because your child is giving it up, 0 * + * if someone is explicitly giving you focus. */ + xpMsg_KeyTakeFocus = 6, + + /* Keyboard focus is being taken away from you. The first parameter will be * + * one if you are losing focus because another widget is taking it, or 0 if * + * someone called the API to make you lose focus explicitly. * + * * + * Dispatching: Direct * + * * + * Param 1: 1 if focus is being taken by another widget, 0 if code requested * + * to remove focus. */ + xpMsg_KeyLoseFocus = 7, + + /* You receive one mousedown event per click with a mouse-state structure * + * pointed to by parameter 1, by accepting this you eat the click, otherwise * + * your parent gets it. You will not receive drag and mouse up messages if you* + * do not accept the down message. * + * * + * Handling this message consumes the mouse click, not handling it passes it * + * to the next widget. You can act 'transparent' as a window by never handling* + * moues clicks to certain areas. * + * * + * Dispatching: Up chain NOTE: Technically this is direct dispatched, but the * + * widgets library will shop it to each widget until one consumes the click, * + * making it effectively "up chain". * + * * + * Param 1: A pointer to an XPMouseState_t containing the mouse status. */ + xpMsg_MouseDown = 8, + + /* You receive a series of mouse drag messages (typically one per frame in the* + * sim) as the mouse is moved once you have accepted a mouse down message. * + * Parameter one points to a mouse-state structure describing the mouse * + * location. You will continue to receive these until the mouse button is * + * released. You may receive multiple mouse state messages with the same mouse* + * position. You will receive mouse drag events even if the mouse is dragged * + * out of your current or original bounds at the time of the mouse down. * + * * + * Dispatching: Direct * + * * + * Param 1: A pointer to an XPMouseState_t containing the mouse status. */ + xpMsg_MouseDrag = 9, + + /* The mouseup event is sent once when the mouse button is released after a * + * drag or click. You only receive this message if you accept the mouseDown * + * message. Parameter one points to a mouse state structure. * + * * + * Dispatching: Direct * + * * + * Param 1: A pointer to an XPMouseState_t containing the mouse status. */ + xpMsg_MouseUp = 10, + + /* Your geometry or a child's geometry is being changed. * + * * + * Dispatching: Up chain * + * * + * Param 1: The widget ID of the original reshaped target. * + * * + * Param 2: A pointer to a XPWidgetGeometryChange_t struct describing the * + * change. */ + xpMsg_Reshape = 11, + + /* Your exposed area has changed. * + * * + * Dispatching: Direct */ + xpMsg_ExposedChanged = 12, + + /* A child has been added to you. The child's ID is passed in parameter one. * + * * + * Dispatching: Direct * + * * + * Param 1: The Widget ID of the child being added. */ + xpMsg_AcceptChild = 13, + + /* A child has been removed from to you. The child's ID is passed in parameter* + * one. * + * * + * Dispatching: Direct * + * * + * Param 1: The Widget ID of the child being removed. */ + xpMsg_LoseChild = 14, + + /* You now have a new parent, or have no parent. The parent's ID is passed in,* + * or 0 for no parent. * + * * + * Dispatching: Direct * + * * + * Param 1: The Widget ID of your parent */ + xpMsg_AcceptParent = 15, + + /* You or a child has been shown. Note that this does not include you being * + * shown because your parent was shown, you were put in a new parent, your * + * root was shown, etc. * + * * + * Dispatching: Up chain * + * * + * Param 1: The widget ID of the shown widget. */ + xpMsg_Shown = 16, + + /* You have been hidden. See limitations above. * + * * + * Dispatching: Up chain * + * * + * Param 1: The widget ID of the hidden widget. */ + xpMsg_Hidden = 17, + + /* Your descriptor has changed. * + * * + * Dispatching: Direct */ + xpMsg_DescriptorChanged = 18, + + /* A property has changed. Param 1 contains the property ID. * + * * + * Dispatching: Direct * + * * + * Param 1: The Property ID being changed. * + * * + * Param 2: The new property value */ + xpMsg_PropertyChanged = 19, + +#if defined(XPLM200) + /* The mouse wheel has moved. * + * * + * Return 1 to consume the mouse wheel move, or 0 to pass the message to a * + * parent. Dispatching: Up chain * + * * + * Param 1: A pointer to an XPMouseState_t containing the mouse status. */ + xpMsg_MouseWheel = 20, + +#endif /* XPLM200 */ +#if defined(XPLM200) + /* The cursor is over your widget. If you consume this message, change the * + * XPLMCursorStatus value to indicate the desired result, with the same rules * + * as in XPLMDisplay.h. * + * * + * Return 1 to consume this message, 0 to pass it on. * + * * + * Dispatching: Up chain Param 1: A pointer to an XPMouseState_t struct * + * containing the mouse status. * + * * + * Param 2: A pointer to a XPLMCursorStatus - set this to the cursor result * + * you desire. */ + xpMsg_CursorAdjust = 21, + +#endif /* XPLM200 */ + /* NOTE: Message IDs 1000 - 9999 are allocated to the standard widget classes * + * provided with the library with 1000 - 1099 for widget class 0, 1100 - 1199 * + * for widget class 1, etc. Message IDs 10,000 and beyond are for plugin use. */ + xpMsg_UserStart = 10000, + + +}; +typedef int XPWidgetMessage; + +/*************************************************************************** + * WIDGET CALLBACK FUNCTION + ***************************************************************************/ + +/* + * XPWidgetFunc_t + * + * This function defines your custom widget's behavior. It will be called by + * the widgets library to send messages to your widget. The message and widget + * ID are passed in, as well as two ptr-width signed parameters whose meaning + * varies with the message. Return 1 to indicate that you have processed the + * message, 0 to indicate that you have not. For any message that is not + * understood, return 0. + * + */ +typedef int (* XPWidgetFunc_t)( + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/Widgets/XPWidgetUtils.h b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/Widgets/XPWidgetUtils.h new file mode 100644 index 0000000..ff757f7 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/Widgets/XPWidgetUtils.h @@ -0,0 +1,232 @@ +#ifndef _XPWidgetUtils_h_ +#define _XPWidgetUtils_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPWidgetUtils + ***************************************************************************/ +/* + * ## USAGE NOTES + * + * The XPWidgetUtils library contains useful functions that make writing and + * using widgets less of a pain. + * + * One set of functions are the widget behavior functions. These functions + * each add specific useful behaviors to widgets. They can be used in two + * manners: + * + * 1. You can add a widget behavior function to a widget as a callback proc + * using the XPAddWidgetCallback function. The widget will gain that + * behavior. Remember that the last function you add has highest priority. + * You can use this to change or augment the behavior of an existing + * finished widget. + * 2. You can call a widget function from inside your own widget function. + * This allows you to include useful behaviors in custom-built widgets. A + * number of the standard widgets get their behavior from this library. To + * do this, call the behavior function from your function first. If it + * returns 1, that means it handled the event and you don't need to; simply + * return 1. + * + */ + +#include "XPWidgetDefs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*************************************************************************** + * GENERAL UTILITIES + ***************************************************************************/ + + + +/* + * Convenience accessors + * + * It can be clumsy accessing the variables passed in by pointer to a struct + * for mouse and reshape messages; these accessors let you simply pass in the param + * right from the arguments of your widget proc and get back the value you want. + * + */ +#define MOUSE_X(param) (((XPMouseState_t *) (param))->x) +#define MOUSE_Y(param) (((XPMouseState_t *) (param))->y) + +#define DELTA_X(param) (((XPWidgetGeometryChange_t *) (param))->dx) +#define DELTA_Y(param) (((XPWidgetGeometryChange_t *) (param))->dy) +#define DELTA_W(param) (((XPWidgetGeometryChange_t *) (param))->dwidth) +#define DELTA_H(param) (((XPWidgetGeometryChange_t *) (param))->dheight) + +#define KEY_CHAR(param) (((XPKeyState_t *) (param))->key) +#define KEY_FLAGS(param) (((XPKeyState_t *) (param))->flags) +#define KEY_VKEY(param) (((XPKeyState_t *) (param))->vkey) + +#define IN_RECT(x, y, l, t, r, b) \ + (((x) >= (l)) && ((x) <= (r)) && ((y) >= (b)) && ((y) <= (t))) + +/* + * XPWidgetCreate_t + * + * This structure contains all of the parameters needed to create a wiget. It + * is used with XPUCreateWidgets to create widgets in bulk from an array. All + * parameters correspond to those of XPCreateWidget except for the container + * index. + * + * If the container index is equal to the index of a widget in the array, the + * widget in the array passed to XPUCreateWidgets is used as the parent of + * this widget. Note that if you pass an index greater than your own position + * in the array, the parent you are requesting will not exist yet. + * + * If the container index is NO_PARENT, the parent widget is specified as + * NULL. If the container index is PARAM_PARENT, the widget passed into + * XPUCreateWidgets is used. + * + */ +typedef struct { + int left; + int top; + int right; + int bottom; + int visible; + const char * descriptor; + /* Whether ethis widget is a root wiget */ + int isRoot; + /* The index of the widget to contain within, or a constant */ + int containerIndex; + XPWidgetClass widgetClass; +} XPWidgetCreate_t; + +#define NO_PARENT -1 + +#define PARAM_PARENT -2 + +#define WIDGET_COUNT(x) ((sizeof(x) / sizeof(XPWidgetCreate_t))) + +/* + * XPUCreateWidgets + * + * This function creates a series of widgets from a table (see + * XPCreateWidget_t above). Pass in an array of widget creation structures and + * an array of widget IDs that will receive each widget. + * + * Widget parents are specified by index into the created widget table, + * allowing you to create nested widget structures. You can create multiple + * widget trees in one table. Generally you should create widget trees from + * the top down. + * + * You can also pass in a widget ID that will be used when the widget's parent + * is listed as PARAM_PARENT; this allows you to embed widgets created with + * XPUCreateWidgets in a widget created previously. + * + */ +WIDGET_API void XPUCreateWidgets( + const XPWidgetCreate_t * inWidgetDefs, + int inCount, + XPWidgetID inParamParent, + XPWidgetID * ioWidgets); + +/* + * XPUMoveWidgetBy + * + * Simply moves a widget by an amount, +x = right, +y=up, without resizing the + * widget. + * + */ +WIDGET_API void XPUMoveWidgetBy( + XPWidgetID inWidget, + int inDeltaX, + int inDeltaY); + +/*************************************************************************** + * LAYOUT MANAGERS + ***************************************************************************/ +/* + * The layout managers are widget behavior functions for handling where + * widgets move. Layout managers can be called from a widget function or + * attached to a widget later. + * + */ + + +/* + * XPUFixedLayout + * + * This function causes the widget to maintain its children in fixed position + * relative to itself as it is resized. Use this on the top level 'window' + * widget for your window. + * + */ +WIDGET_API int XPUFixedLayout( + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2); + +/*************************************************************************** + * WIDGET PROC BEHAVIORS + ***************************************************************************/ +/* + * These widget behavior functions add other useful behaviors to widgets. + * These functions cannot be attached to a widget; they must be called from + * your widget function. + * + */ + + +/* + * XPUSelectIfNeeded + * + * This causes the widget to bring its window to the foreground if it is not + * already. inEatClick specifies whether clicks in the background should be + * consumed by bringin the window to the foreground. + * + */ +WIDGET_API int XPUSelectIfNeeded( + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2, + int inEatClick); + +/* + * XPUDefocusKeyboard + * + * This causes a click in the widget to send keyboard focus back to X-Plane. + * This stops editing of any text fields, etc. + * + */ +WIDGET_API int XPUDefocusKeyboard( + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2, + int inEatClick); + +/* + * XPUDragWidget + * + * XPUDragWidget drags the widget in response to mouse clicks. Pass in not + * only the event, but the global coordinates of the drag region, which might + * be a sub-region of your widget (for example, a title bar). + * + */ +WIDGET_API int XPUDragWidget( + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2, + int inLeft, + int inTop, + int inRight, + int inBottom); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/Widgets/XPWidgets.h b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/Widgets/XPWidgets.h new file mode 100644 index 0000000..f4423e2 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/Widgets/XPWidgets.h @@ -0,0 +1,538 @@ +#ifndef _XPWidgets_h_ +#define _XPWidgets_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPWidgets + ***************************************************************************/ +/* + * ## THEORY OF OPERATION AND NOTES + * + * Widgets are persistent view 'objects' for X-Plane. A widget is an object + * referenced by its opaque handle (widget ID) and the APIs in this file. You + * cannot access the widget's guts directly. Every Widget has the following + * intrinsic data: + * + * - A bounding box defined in global screen coordinates with 0,0 in the + * bottom left and +y = up, +x = right. + * - A visible box, which is the intersection of the bounding box with the + * widget's parents visible box. + * - Zero or one parent widgets. (Always zero if the widget is a root widget. + * - Zero or more child widgets. + * - Whether the widget is a root. Root widgets are the top level plugin + * windows. + * - Whether the widget is visible. + * - A text string descriptor, whose meaning varies from widget to widget. + * - An arbitrary set of 32 bit integral properties defined by 32-bit integral + * keys. This is how specific widgets store specific data. + * - A list of widget callbacks proc that implements the widgets behaviors. + * + * The Widgets library sends messages to widgets to request specific behaviors + * or notify the widget of things. + * + * Widgets may have more than one callback function, in which case messages + * are sent to the most recently added callback function until the message is + * handled. Messages may also be sent to parents or children; see the + * XPWidgetDefs.h header file for the different widget message dispatching + * functions. By adding a callback function to a window you can 'subclass' its + * behavior. + * + * A set of standard widgets are provided that serve common UI purposes. You + * can also customize or implement entirely custom widgets. + * + * Widgets are different than other view hierarchies (most notably Win32, + * which they bear a striking resemblance to) in the following ways: + * + * - Not all behavior can be patched. State that is managed by the XPWidgets + * DLL and not by individual widgets cannot be customized. + * - All coordinates are in global screen coordinates. Coordinates are not + * relative to an enclosing widget, nor are they relative to a display + * window. + * - Widget messages are always dispatched synchronously, and there is no + * concept of scheduling an update or a dirty region. Messages originate + * from X-Plane as the sim cycle goes by. Since X-Plane is constantly + * redrawing, so are widgets; there is no need to mark a part of a widget as + * 'needing redrawing' because redrawing happens frequently whether the + * widget needs it or not. + * - Any widget may be a 'root' widget, causing it to be drawn; there is no + * relationship between widget class and rootness. Root widgets are + * imlemented as XPLMDisply windows. + * + */ + +#include "XPWidgetDefs.h" +#include "XPLMDisplay.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*************************************************************************** + * WIDGET CREATION AND MANAGEMENT + ***************************************************************************/ + +/* + * XPCreateWidget + * + * This function creates a new widget and returns the new widget's ID to you. + * If the widget creation fails for some reason, it returns NULL. Widget + * creation will fail either if you pass a bad class ID or if there is not + * adequate memory. + * + * Input Parameters: + * + * - Top, left, bottom, and right in global screen coordinates defining the + * widget's location on the screen. + * - inVisible is 1 if the widget should be drawn, 0 to start the widget as + * hidden. + * - inDescriptor is a null terminated string that will become the widget's + * descriptor. + * - inIsRoot is 1 if this is going to be a root widget, 0 if it will not be. + * - inContainer is the ID of this widget's container. It must be 0 for a root + * widget. for a non-root widget, pass the widget ID of the widget to place + * this widget within. If this widget is not going to start inside another + * widget, pass 0; this new widget will then just be floating off in space + * (and will not be drawn until it is placed in a widget. + * - inClass is the class of the widget to draw. Use one of the predefined + * class-IDs to create a standard widget. + * + * A note on widget embedding: a widget is only called (and will be drawn, + * etc.) if it is placed within a widget that will be called. Root widgets are + * always called. So it is possible to have whole chains of widgets that are + * simply not called. You can preconstruct widget trees and then place them + * into root widgets later to activate them if you wish. + * + */ +WIDGET_API XPWidgetID XPCreateWidget( + int inLeft, + int inTop, + int inRight, + int inBottom, + int inVisible, + const char * inDescriptor, + int inIsRoot, + XPWidgetID inContainer, + XPWidgetClass inClass); + +/* + * XPCreateCustomWidget + * + * This function is the same as XPCreateWidget except that instead of passing + * a class ID, you pass your widget callback function pointer defining the + * widget. Use this function to define a custom widget. All parameters are the + * same as XPCreateWidget, except that the widget class has been replaced with + * the widget function. + * + */ +WIDGET_API XPWidgetID XPCreateCustomWidget( + int inLeft, + int inTop, + int inRight, + int inBottom, + int inVisible, + const char * inDescriptor, + int inIsRoot, + XPWidgetID inContainer, + XPWidgetFunc_t inCallback); + +/* + * XPDestroyWidget + * + * This class destroys a widget. Pass in the ID of the widget to kill. If you + * pass 1 for inDestroyChilren, the widget's children will be destroyed first, + * then this widget will be destroyed. (Furthermore, the widget's children + * will be destroyed with the inDestroyChildren flag set to 1, so the + * destruction will recurse down the widget tree.) If you pass 0 for this + * flag, the child widgets will simply end up with their parent set to 0. + * + */ +WIDGET_API void XPDestroyWidget( + XPWidgetID inWidget, + int inDestroyChildren); + +/* + * XPSendMessageToWidget + * + * This sends any message to a widget. You should probably not go around + * simulating the predefined messages that the widgets library defines for + * you. You may however define custom messages for your widgets and send them + * with this method. + * + * This method supports several dispatching patterns; see XPDispatchMode for + * more info. The function returns 1 if the message was handled, 0 if it was + * not. + * + * For each widget that receives the message (see the dispatching modes), each + * widget function from the most recently installed to the oldest one receives + * the message in order until it is handled. + * + */ +WIDGET_API int XPSendMessageToWidget( + XPWidgetID inWidget, + XPWidgetMessage inMessage, + XPDispatchMode inMode, + intptr_t inParam1, + intptr_t inParam2); + +/*************************************************************************** + * WIDGET POSITIONING AND VISIBILITY + ***************************************************************************/ + +/* + * XPPlaceWidgetWithin + * + * This function changes which container a widget resides in. You may NOT use + * this function on a root widget! inSubWidget is the widget that will be + * moved. Pass a widget ID in inContainer to make inSubWidget be a child of + * inContainer. It will become the last/closest widget in the container. Pass + * 0 to remove the widget from any container. Any call to this other than + * passing the widget ID of the old parent of the affected widget will cause + * the widget to be removed from its old parent. Placing a widget within its + * own parent simply makes it the last widget. + * + * NOTE: this routine does not reposition the sub widget in global + * coordinates. If the container has layout management code, it will + * reposition the subwidget for you, otherwise you must do it with + * SetWidgetGeometry. + * + */ +WIDGET_API void XPPlaceWidgetWithin( + XPWidgetID inSubWidget, + XPWidgetID inContainer); + +/* + * XPCountChildWidgets + * + * This routine returns the number of widgets another widget contains. + * + */ +WIDGET_API int XPCountChildWidgets( + XPWidgetID inWidget); + +/* + * XPGetNthChildWidget + * + * This routine returns the widget ID of a child widget by index. Indexes are + * 0 based, from 0 to one minus the number of widgets in the parent, + * inclusive. If the index is invalid, 0 is returned. + * + */ +WIDGET_API XPWidgetID XPGetNthChildWidget( + XPWidgetID inWidget, + int inIndex); + +/* + * XPGetParentWidget + * + * Returns the parent of a widget, or 0 if the widget has no parent. Root + * widgets never have parents and therefore always return 0. + * + */ +WIDGET_API XPWidgetID XPGetParentWidget( + XPWidgetID inWidget); + +/* + * XPShowWidget + * + * This routine makes a widget visible if it is not already. Note that if a + * widget is not in a rooted widget hierarchy or one of its parents is not + * visible, it will still not be visible to the user. + * + */ +WIDGET_API void XPShowWidget( + XPWidgetID inWidget); + +/* + * XPHideWidget + * + * Makes a widget invisible. See XPShowWidget for considerations of when a + * widget might not be visible despite its own visibility state. + * + */ +WIDGET_API void XPHideWidget( + XPWidgetID inWidget); + +/* + * XPIsWidgetVisible + * + * This returns 1 if a widget is visible, 0 if it is not. Note that this + * routine takes into consideration whether a parent is invisible. Use this + * routine to tell if the user can see the widget. + * + */ +WIDGET_API int XPIsWidgetVisible( + XPWidgetID inWidget); + +/* + * XPFindRootWidget + * + * Returns the Widget ID of the root widget that contains the passed in widget + * or NULL if the passed in widget is not in a rooted hierarchy. + * + */ +WIDGET_API XPWidgetID XPFindRootWidget( + XPWidgetID inWidget); + +/* + * XPBringRootWidgetToFront + * + * This routine makes the specified widget be in the front most widget + * hierarchy. If this widget is a root widget, its widget hierarchy comes to + * front, otherwise the widget's root is brought to the front. If this widget + * is not in an active widget hiearchy (e.g. there is no root widget at the + * top of the tree), this routine does nothing. + * + */ +WIDGET_API void XPBringRootWidgetToFront( + XPWidgetID inWidget); + +/* + * XPIsWidgetInFront + * + * This routine returns true if this widget's hierarchy is the front most + * hierarchy. It returns false if the widget's hierarchy is not in front, or + * if the widget is not in a rooted hierarchy. + * + */ +WIDGET_API int XPIsWidgetInFront( + XPWidgetID inWidget); + +/* + * XPGetWidgetGeometry + * + * This routine returns the bounding box of a widget in global coordinates. + * Pass NULL for any parameter you are not interested in. + * + */ +WIDGET_API void XPGetWidgetGeometry( + XPWidgetID inWidget, + int * outLeft, /* Can be NULL */ + int * outTop, /* Can be NULL */ + int * outRight, /* Can be NULL */ + int * outBottom); /* Can be NULL */ + +/* + * XPSetWidgetGeometry + * + * This function changes the bounding box of a widget. + * + */ +WIDGET_API void XPSetWidgetGeometry( + XPWidgetID inWidget, + int inLeft, + int inTop, + int inRight, + int inBottom); + +/* + * XPGetWidgetForLocation + * + * Given a widget and a location, this routine returns the widget ID of the + * child of that widget that owns that location. If inRecursive is true then + * this will return a child of a child of a widget as it tries to find the + * deepest widget at that location. If inVisibleOnly is true, then only + * visible widgets are considered, otherwise all widgets are considered. The + * widget ID passed for inContainer will be returned if the location is in + * that widget but not in a child widget. 0 is returned if the location is not + * in the container. + * + * NOTE: if a widget's geometry extends outside its parents geometry, it will + * not be returned by this call for mouse locations outside the parent + * geometry. The parent geometry limits the child's eligibility for mouse + * location. + * + */ +WIDGET_API XPWidgetID XPGetWidgetForLocation( + XPWidgetID inContainer, + int inXOffset, + int inYOffset, + int inRecursive, + int inVisibleOnly); + +/* + * XPGetWidgetExposedGeometry + * + * This routine returns the bounds of the area of a widget that is completely + * within its parent widgets. Since a widget's bounding box can be outside its + * parent, part of its area will not be elligible for mouse clicks and should + * not draw. Use XPGetWidgetGeometry to find out what area defines your + * widget's shape, but use this routine to find out what area to actually draw + * into. Note that the widget library does not use OpenGL clipping to keep + * frame rates up, although you could use it internally. + * + */ +WIDGET_API void XPGetWidgetExposedGeometry( + XPWidgetID inWidgetID, + int * outLeft, /* Can be NULL */ + int * outTop, /* Can be NULL */ + int * outRight, /* Can be NULL */ + int * outBottom); /* Can be NULL */ + +/*************************************************************************** + * ACCESSING WIDGET DATA + ***************************************************************************/ + +/* + * XPSetWidgetDescriptor + * + * Every widget has a descriptor, which is a text string. What the text string + * is used for varies from widget to widget; for example, a push button's text + * is its descriptor, a caption shows its descriptor, and a text field's + * descriptor is the text being edited. In other words, the usage for the text + * varies from widget to widget, but this API provides a universal and + * convenient way to get at it. While not all UI widgets need their + * descriptor, many do. + * + */ +WIDGET_API void XPSetWidgetDescriptor( + XPWidgetID inWidget, + const char * inDescriptor); + +/* + * XPGetWidgetDescriptor + * + * This routine returns the widget's descriptor. Pass in the length of the + * buffer you are going to receive the descriptor in. The descriptor will be + * null terminated for you. This routine returns the length of the actual + * descriptor; if you pass NULL for outDescriptor, you can get the + * descriptor's length without getting its text. If the length of the + * descriptor exceeds your buffer length, the buffer will not be null + * terminated (this routine has 'strncpy' semantics). + * + */ +WIDGET_API int XPGetWidgetDescriptor( + XPWidgetID inWidget, + char * outDescriptor, + int inMaxDescLength); + +/* + * XPGetWidgetUnderlyingWindow + * + * Returns the window (from the XPLMDisplay API) that backs your widget + * window. If you have opted in to modern windows, via a call to + * XPLMEnableFeature("XPLM_USE_NATIVE_WIDGET_WINDOWS", 1), you can use the + * returned window ID for display APIs like XPLMSetWindowPositioningMode(), + * allowing you to pop the widget window out into a real OS window, or move it + * into VR. + * + */ +WIDGET_API XPLMWindowID XPGetWidgetUnderlyingWindow( + XPWidgetID inWidget); + +/* + * XPSetWidgetProperty + * + * This function sets a widget's property. Properties are arbitrary values + * associated by a widget by ID. + * + */ +WIDGET_API void XPSetWidgetProperty( + XPWidgetID inWidget, + XPWidgetPropertyID inProperty, + intptr_t inValue); + +/* + * XPGetWidgetProperty + * + * This routine returns the value of a widget's property, or 0 if the property + * is not defined. If you need to know whether the property is defined, pass a + * pointer to an int for inExists; the existence of that property will be + * returned in the int. Pass NULL for inExists if you do not need this + * information. + * + */ +WIDGET_API intptr_t XPGetWidgetProperty( + XPWidgetID inWidget, + XPWidgetPropertyID inProperty, + int * inExists); /* Can be NULL */ + +/*************************************************************************** + * KEYBOARD MANAGEMENT + ***************************************************************************/ + +/* + * XPSetKeyboardFocus + * + * Controls which widget will receive keystrokes. Pass the widget ID of the + * widget to get the keys. Note that if the widget does not care about + * keystrokes, they will go to the parent widget, and if no widget cares about + * them, they go to X-Plane. + * + * If you set the keyboard focus to widget ID 0, X-Plane gets keyboard focus. + * + * This routine returns the widget ID that ended up with keyboard focus, or 0 + * for X-Plane. + * + * Keyboard focus is not changed if the new widget will not accept it. For + * setting to X-Plane, keyboard focus is always accepted. + * + */ +WIDGET_API XPWidgetID XPSetKeyboardFocus( + XPWidgetID inWidget); + +/* + * XPLoseKeyboardFocus + * + * This causes the specified widget to lose focus; focus is passed to its + * parent, or the next parent that will accept it. This routine does nothing + * if this widget does not have focus. + * + */ +WIDGET_API void XPLoseKeyboardFocus( + XPWidgetID inWidget); + +/* + * XPGetWidgetWithFocus + * + * This routine returns the widget that has keyboard focus, or 0 if X-Plane + * has keyboard focus or some other plugin window that does not have widgets + * has focus. + * + */ +WIDGET_API XPWidgetID XPGetWidgetWithFocus(void); + +/*************************************************************************** + * CREATING CUSTOM WIDGETS + ***************************************************************************/ + +/* + * XPAddWidgetCallback + * + * This function adds a new widget callback to a widget. This widget callback + * supercedes any existing ones and will receive messages first; if it does + * not handle messages they will go on to be handled by pre-existing widgets. + * + * The widget function will remain on the widget for the life of the widget. + * The creation message will be sent to the new callback immediately with the + * widget ID, and the destruction message will be sent before the other widget + * function receives a destruction message. + * + * This provides a way to 'subclass' an existing widget. By providing a second + * hook that only handles certain widget messages, you can customize or extend + * widget behavior. + * + */ +WIDGET_API void XPAddWidgetCallback( + XPWidgetID inWidget, + XPWidgetFunc_t inNewCallback); + +/* + * XPGetWidgetClassFunc + * + * Given a widget class, this function returns the callbacks that power that + * widget class. + * + */ +WIDGET_API XPWidgetFunc_t XPGetWidgetClassFunc( + XPWidgetClass inWidgetClass); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/Wrappers/XPCBroadcaster.cpp b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/Wrappers/XPCBroadcaster.cpp new file mode 100644 index 0000000..5fe6218 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/Wrappers/XPCBroadcaster.cpp @@ -0,0 +1,56 @@ +#include "XPCBroadcaster.h" +#include "XPCListener.h" + +XPCBroadcaster::XPCBroadcaster() : + mIterator(NULL) +{ +} + +XPCBroadcaster::~XPCBroadcaster() +{ + ListenerVector::iterator iter; + mIterator = &iter; + for (iter = mListeners.begin(); iter != mListeners.end(); ++iter) + { + (*iter)->BroadcasterRemoved(this); + } +} + +void XPCBroadcaster::AddListener( + XPCListener * inListener) +{ + mListeners.push_back(inListener); + inListener->BroadcasterAdded(this); +} + +void XPCBroadcaster::RemoveListener( + XPCListener * inListener) +{ + ListenerVector::iterator iter = std::find + (mListeners.begin(), mListeners.end(), inListener); + if (iter == mListeners.end()) + return; + + if (mIterator != NULL) + { + if (*mIterator >= iter) + (*mIterator)--; + } + + mListeners.erase(iter); + inListener->BroadcasterRemoved(this); +} + +void XPCBroadcaster::BroadcastMessage( + int inMessage, + void * inParam) +{ + ListenerVector::iterator iter; + mIterator = &iter; + for (iter = mListeners.begin(); iter != mListeners.end(); ++iter) + { + (*iter)->ListenToMessage(inMessage, inParam); + } + mIterator = NULL; +} + diff --git a/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/Wrappers/XPCBroadcaster.h b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/Wrappers/XPCBroadcaster.h new file mode 100644 index 0000000..8f34a05 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/Wrappers/XPCBroadcaster.h @@ -0,0 +1,38 @@ +#ifndef _XPCBroadcaster_h_ +#define _XPCBroadcaster_h_ + +#include +#include + +class XPCListener; + +class XPCBroadcaster { +public: + + XPCBroadcaster(); + virtual ~XPCBroadcaster(); + + void AddListener( + XPCListener * inListener); + void RemoveListener( + XPCListener * inListener); + +protected: + + void BroadcastMessage( + int inMessage, + void * inParam=0); + +private: + + typedef std::vector ListenerVector; + + ListenerVector mListeners; + + // Reentrancy support + + ListenerVector::iterator * mIterator; + +}; + +#endif \ No newline at end of file diff --git a/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/Wrappers/XPCDisplay.cpp b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/Wrappers/XPCDisplay.cpp new file mode 100644 index 0000000..fc996ca --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/Wrappers/XPCDisplay.cpp @@ -0,0 +1,104 @@ +#include "XPCDisplay.h" + +XPCKeySniffer::XPCKeySniffer(int inBeforeWindows) : mBeforeWindows(inBeforeWindows) +{ + XPLMRegisterKeySniffer(KeySnifferCB, mBeforeWindows, reinterpret_cast(this)); +} + +XPCKeySniffer::~XPCKeySniffer() +{ + XPLMUnregisterKeySniffer(KeySnifferCB, mBeforeWindows, reinterpret_cast(this)); +} + + +int XPCKeySniffer::KeySnifferCB( + char inCharKey, + XPLMKeyFlags inFlags, + char inVirtualKey, + void * inRefCon) +{ + XPCKeySniffer * me = reinterpret_cast(inRefCon); + return me->HandleKeyStroke(inCharKey, inFlags, inVirtualKey); +} + +XPCWindow::XPCWindow( + int inLeft, + int inTop, + int inRight, + int inBottom, + int inIsVisible) +{ + mWindow = XPLMCreateWindow(inLeft, inTop, inRight, inBottom, inIsVisible, + DrawCB, HandleKeyCB, MouseClickCB, + reinterpret_cast(this)); +} + +XPCWindow::~XPCWindow() +{ + XPLMDestroyWindow(mWindow); +} + +void XPCWindow::GetWindowGeometry( + int * outLeft, + int * outTop, + int * outRight, + int * outBottom) +{ + XPLMGetWindowGeometry(mWindow, outLeft, outTop, outRight, outBottom); +} + +void XPCWindow::SetWindowGeometry( + int inLeft, + int inTop, + int inRight, + int inBottom) +{ + XPLMSetWindowGeometry(mWindow, inLeft, inTop, inRight, inBottom); +} + +int XPCWindow::GetWindowIsVisible(void) +{ + return XPLMGetWindowIsVisible(mWindow); +} + +void XPCWindow::SetWindowIsVisible( + int inIsVisible) +{ + XPLMSetWindowIsVisible(mWindow, inIsVisible); +} + +void XPCWindow::TakeKeyboardFocus(void) +{ + XPLMTakeKeyboardFocus(mWindow); +} + +void XPCWindow::BringWindowToFront(void) +{ + XPLMBringWindowToFront(mWindow); +} + +int XPCWindow::IsWindowInFront(void) +{ + return XPLMIsWindowInFront(mWindow); +} + +void XPCWindow::DrawCB(XPLMWindowID inWindowID, void * inRefcon) +{ + XPCWindow * me = reinterpret_cast(inRefcon); + me->DoDraw(); +} + +void XPCWindow::HandleKeyCB(XPLMWindowID inWindowID, char inKey, XPLMKeyFlags inFlags, char inVirtualKey, void * inRefcon, int losingFocus) +{ + XPCWindow * me = reinterpret_cast(inRefcon); + if (losingFocus) + me->LoseFocus(); + else + me->HandleKey(inKey, inFlags, inVirtualKey); +} + +int XPCWindow::MouseClickCB(XPLMWindowID inWindowID, int x, int y, XPLMMouseStatus inMouse, void * inRefcon) +{ + XPCWindow * me = reinterpret_cast(inRefcon); + return me->HandleClick(x, y, inMouse); +} diff --git a/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/Wrappers/XPCDisplay.h b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/Wrappers/XPCDisplay.h new file mode 100644 index 0000000..2465928 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/Wrappers/XPCDisplay.h @@ -0,0 +1,73 @@ +#ifndef _XPCDisplay_h_ +#define _XPCDisplay_h_ + +#include "XPLMDisplay.h" + +class XPCKeySniffer { +public: + + XPCKeySniffer(int inBeforeWindows); + virtual ~XPCKeySniffer(); + + virtual int HandleKeyStroke( + char inCharKey, + XPLMKeyFlags inFlags, + char inVirtualKey)=0; + +private: + + int mBeforeWindows; + + static int KeySnifferCB( + char inCharKey, + XPLMKeyFlags inFlags, + char inVirtualKey, + void * inRefCon); +}; + + + +class XPCWindow { +public: + + XPCWindow( + int inLeft, + int inTop, + int inRight, + int inBottom, + int inIsVisible); + virtual ~XPCWindow(); + + virtual void DoDraw(void)=0; + virtual void HandleKey(char inKey, XPLMKeyFlags inFlags, char inVirtualKey)=0; + virtual void LoseFocus(void)=0; + virtual int HandleClick(int x, int y, XPLMMouseStatus inMouse)=0; + + void GetWindowGeometry( + int * outLeft, + int * outTop, + int * outRight, + int * outBottom); + void SetWindowGeometry( + int inLeft, + int inTop, + int inRight, + int inBottom); + int GetWindowIsVisible(void); + void SetWindowIsVisible( + int inIsVisible); + void TakeKeyboardFocus(void); + void BringWindowToFront(void); + int IsWindowInFront(void); + +private: + + XPLMWindowID mWindow; + + static void DrawCB(XPLMWindowID inWindowID, void * inRefcon); + static void HandleKeyCB(XPLMWindowID inWindowID, char inKey, XPLMKeyFlags inFlags, char inVirtualKey, void * inRefcon, int losingFocus); + static int MouseClickCB(XPLMWindowID inWindowID, int x, int y, XPLMMouseStatus inMouse, void * inRefcon); + +}; + +#endif \ No newline at end of file diff --git a/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/Wrappers/XPCListener.cpp b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/Wrappers/XPCListener.cpp new file mode 100644 index 0000000..b4c77aa --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/Wrappers/XPCListener.cpp @@ -0,0 +1,27 @@ +#include "XPCListener.h" +#include "XPCBroadcaster.h" + +XPCListener::XPCListener() +{ +} + +XPCListener::~XPCListener() +{ + while (!mBroadcasters.empty()) + mBroadcasters.front()->RemoveListener(this); +} + +void XPCListener::BroadcasterAdded( + XPCBroadcaster * inBroadcaster) +{ + mBroadcasters.push_back(inBroadcaster); +} + +void XPCListener::BroadcasterRemoved( + XPCBroadcaster * inBroadcaster) +{ + BroadcastVector::iterator iter = std::find(mBroadcasters.begin(), + mBroadcasters.end(), inBroadcaster); + if (iter != mBroadcasters.end()) + mBroadcasters.erase(iter); +} diff --git a/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/Wrappers/XPCListener.h b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/Wrappers/XPCListener.h new file mode 100644 index 0000000..dbdd2a0 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/Wrappers/XPCListener.h @@ -0,0 +1,36 @@ +#ifndef _XPCListener_h_ +#define _XPCListener_h_ + +#include +#include + +class XPCBroadcaster; + + +class XPCListener { +public: + + XPCListener(); + virtual ~XPCListener(); + + virtual void ListenToMessage( + int inMessage, + void * inParam)=0; + +private: + + typedef std::vector BroadcastVector; + + BroadcastVector mBroadcasters; + + friend class XPCBroadcaster; + + void BroadcasterAdded( + XPCBroadcaster * inBroadcaster); + + void BroadcasterRemoved( + XPCBroadcaster * inBroadcaster); + +}; + +#endif \ No newline at end of file diff --git a/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/Wrappers/XPCProcessing.cpp b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/Wrappers/XPCProcessing.cpp new file mode 100644 index 0000000..352c05f --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/Wrappers/XPCProcessing.cpp @@ -0,0 +1,52 @@ +#include "XPCProcessing.h" +#include "XPLMUtilities.h" + +XPCProcess::XPCProcess() : + mInCallback(false), + mCallbackTime(0) +{ + XPLMRegisterFlightLoopCallback(FlightLoopCB, 0, reinterpret_cast(this)); +} + +XPCProcess::~XPCProcess() +{ + XPLMUnregisterFlightLoopCallback(FlightLoopCB, reinterpret_cast(this)); +} + +void XPCProcess::StartProcessTime(float inSeconds) +{ + mCallbackTime = inSeconds; + if (!mInCallback) + XPLMSetFlightLoopCallbackInterval( + FlightLoopCB, mCallbackTime, 1/*relative to now*/, reinterpret_cast(this)); +} + +void XPCProcess::StartProcessCycles(int inCycles) +{ + mCallbackTime = -inCycles; + if (!mInCallback) + XPLMSetFlightLoopCallbackInterval( + FlightLoopCB, mCallbackTime, 1/*relative to now*/, reinterpret_cast(this)); +} + +void XPCProcess::StopProcess(void) +{ + mCallbackTime = 0; + if (!mInCallback) + XPLMSetFlightLoopCallbackInterval( + FlightLoopCB, mCallbackTime, 1/*relative to now*/, reinterpret_cast(this)); +} + + +float XPCProcess::FlightLoopCB( + float inElapsedSinceLastCall, + float inElapsedTimeSinceLastFlightLoop, + int inCounter, + void * inRefcon) +{ + XPCProcess * me = reinterpret_cast(inRefcon); + me->mInCallback = true; + me->DoProcessing(inElapsedSinceLastCall, inElapsedTimeSinceLastFlightLoop, inCounter); + me->mInCallback = false; + return me->mCallbackTime; +} \ No newline at end of file diff --git a/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/Wrappers/XPCProcessing.h b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/Wrappers/XPCProcessing.h new file mode 100644 index 0000000..cd735e5 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/Wrappers/XPCProcessing.h @@ -0,0 +1,37 @@ +#ifndef _XPCProcessing_h_ +#define _XPCProcessing_h_ + +#include "XPLMProcessing.h" + +class XPCProcess { +public: + + XPCProcess(); + virtual ~XPCProcess(); + + void StartProcessTime(float inSeconds); + void StartProcessCycles(int inCycles); + void StopProcess(void); + + virtual void DoProcessing( + float inElapsedSinceLastCall, + float inElapsedTimeSinceLastFlightLoop, + int inCounter)=0; + +private: + + static float FlightLoopCB( + float inElapsedSinceLastCall, + float inElapsedTimeSinceLastFlightLoop, + int inCounter, + void * inRefcon); + + bool mInCallback; + float mCallbackTime; + + XPCProcess(const XPCProcess&); + XPCProcess& operator=(const XPCProcess&); + +}; + +#endif diff --git a/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/Wrappers/XPCWidget.cpp b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/Wrappers/XPCWidget.cpp new file mode 100644 index 0000000..8ef8aa3 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/Wrappers/XPCWidget.cpp @@ -0,0 +1,123 @@ +#include "XPCWidget.h" + +XPCWidget::XPCWidget( + int inLeft, + int inTop, + int inRight, + int inBottom, + bool inVisible, + const char * inDescriptor, + bool inIsRoot, + XPWidgetID inParent, + XPWidgetClass inClass) : + mWidget(NULL), + mOwnsChildren(false), + mOwnsWidget(true) +{ + mWidget = XPCreateWidget( + inLeft, inTop, inRight, inBottom, + inVisible ? 1 : 0, + inDescriptor, + inIsRoot ? 1 : 0, + inIsRoot ? NULL : inParent, + inClass); + + XPSetWidgetProperty(mWidget, xpProperty_Object, reinterpret_cast(this)); + XPAddWidgetCallback(mWidget, WidgetCallback); +} + +XPCWidget::XPCWidget( + XPWidgetID inWidget, + bool inOwnsWidget) : + mWidget(inWidget), + mOwnsChildren(false), + mOwnsWidget(inOwnsWidget) +{ + XPSetWidgetProperty(mWidget, xpProperty_Object, reinterpret_cast(this)); + XPAddWidgetCallback(mWidget, WidgetCallback); +} + +XPCWidget::~XPCWidget() +{ + if (mOwnsWidget) + XPDestroyWidget(mWidget, mOwnsChildren ? 1 : 0); +} + +void XPCWidget::SetOwnsWidget( + bool inOwnsWidget) +{ + mOwnsWidget = inOwnsWidget; +} + +void XPCWidget::SetOwnsChildren( + bool inOwnsChildren) +{ + mOwnsChildren = inOwnsChildren; +} + +XPCWidget::operator XPWidgetID () const +{ + return mWidget; +} + +XPWidgetID XPCWidget::Get(void) const +{ + return mWidget; +} + +void XPCWidget::AddAttachment( + XPCWidgetAttachment * inAttachment, + bool inOwnsAttachment, + bool inPrefilter) +{ + if (inPrefilter) + { + mAttachments.insert(mAttachments.begin(), AttachmentInfo(inAttachment, inOwnsAttachment)); + } else { + mAttachments.push_back(AttachmentInfo(inAttachment, inOwnsAttachment)); + } +} + +void XPCWidget::RemoveAttachment( + XPCWidgetAttachment * inAttachment) +{ + for (AttachmentVector::iterator iter = mAttachments.begin(); + iter != mAttachments.end(); ++iter) + { + if (iter->first == inAttachment) + { + mAttachments.erase(iter); + return; + } + } +} + +int XPCWidget::HandleWidgetMessage( + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2) +{ + return 0; +} + +int XPCWidget::WidgetCallback( + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2) +{ + XPCWidget * me = reinterpret_cast(XPGetWidgetProperty(inWidget, xpProperty_Object, NULL)); + if (me == NULL) + return 0; + + for (AttachmentVector::iterator iter = me->mAttachments.begin(); iter != + me->mAttachments.end(); ++iter) + { + int result = iter->first->HandleWidgetMessage(me, inMessage, inWidget, inParam1, inParam2); + if (result != 0) + return result; + } + + return me->HandleWidgetMessage(inMessage, inWidget, inParam1, inParam2); +} diff --git a/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/Wrappers/XPCWidget.h b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/Wrappers/XPCWidget.h new file mode 100644 index 0000000..788b56a --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/Wrappers/XPCWidget.h @@ -0,0 +1,84 @@ +#ifndef _XPCWidget_h_ +#define _XPCWidget_h_ + +#include +#include +#include "XPWidgets.h" + +class XPCWidget; + +class XPCWidgetAttachment { +public: + + virtual int HandleWidgetMessage( + XPCWidget * inObject, + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2)=0; + +}; + +class XPCWidget { +public: + + XPCWidget( + int inLeft, + int inTop, + int inRight, + int inBottom, + bool inVisible, + const char * inDescriptor, + bool inIsRoot, + XPWidgetID inParent, + XPWidgetClass inClass); + XPCWidget( + XPWidgetID inWidget, + bool inOwnsWidget); + virtual ~XPCWidget(); + + void SetOwnsWidget( + bool inOwnsWidget); + void SetOwnsChildren( + bool inOwnsChildren); + + operator XPWidgetID () const; + + XPWidgetID Get(void) const; + + void AddAttachment( + XPCWidgetAttachment * inAttachment, + bool inOwnsAttachment, + bool inPrefilter); + void RemoveAttachment( + XPCWidgetAttachment * inAttachment); + + virtual int HandleWidgetMessage( + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2); + +private: + + static int WidgetCallback( + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2); + + typedef std::pair AttachmentInfo; + typedef std::vector AttachmentVector; + + AttachmentVector mAttachments; + XPWidgetID mWidget; + bool mOwnsChildren; + bool mOwnsWidget; + + XPCWidget(); + XPCWidget(const XPCWidget&); + XPCWidget& operator=(const XPCWidget&); + +}; + +#endif \ No newline at end of file diff --git a/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/Wrappers/XPCWidgetAttachments.cpp b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/Wrappers/XPCWidgetAttachments.cpp new file mode 100644 index 0000000..d87f105 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/Wrappers/XPCWidgetAttachments.cpp @@ -0,0 +1,267 @@ +#include "XPCWidgetAttachments.h" +#include "XPStandardWidgets.h" +#include "XPWidgetUtils.h" + +static void XPCGetOrderedSubWidgets( + XPWidgetID inWidget, + std::vector& outChildren); + +XPCKeyFilterAttachment::XPCKeyFilterAttachment( + const char * inValidKeys, + const char * outValidKeys) : + mInput(inValidKeys), + mOutput(outValidKeys) +{ +} + +XPCKeyFilterAttachment::~XPCKeyFilterAttachment() +{ +} + +int XPCKeyFilterAttachment::HandleWidgetMessage( + XPCWidget * inObject, + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2) +{ + if (inMessage == xpMsg_KeyPress) + { + char& theKey = KEY_CHAR(inParam1); + std::string::size_type pos = mInput.find(theKey); + if (pos == std::string::npos) + return 1; // Not found; eat the key! + else { + theKey = mOutput[pos]; + return 0; + } // Let it live. + } + return 0; +} + + +XPCKeyMessageAttachment::XPCKeyMessageAttachment( + char inKey, + int inMessage, + void * inParam, + bool inConsume, + bool inVkey, + XPCListener * inListener) : + mKey(inKey), mMsg(inMessage), mParam(inParam), mConsume(inConsume), + mVkey(inVkey) +{ + if (inListener != NULL) + this->AddListener(inListener); +} + +XPCKeyMessageAttachment::~XPCKeyMessageAttachment() +{ +} + +int XPCKeyMessageAttachment::HandleWidgetMessage( + XPCWidget * inObject, + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2) +{ + if (inMessage == xpMsg_KeyPress) + { + char theKey = mVkey ? KEY_VKEY(inParam1) : KEY_CHAR(inParam1); + if (theKey != mKey) + return 0; + if (!(KEY_FLAGS(inParam1) & xplm_DownFlag)) + return 0; + + BroadcastMessage(mMsg, mParam); + return mConsume ? 1 : 0; + } + return 0; +} + +XPCPushButtonMessageAttachment::XPCPushButtonMessageAttachment( + XPWidgetID inWidget, + int inMessage, + void * inParam, + XPCListener * inListener) : + mMsg(inMessage), mParam(inParam), mWidget(inWidget) +{ + if (inListener != NULL) + this->AddListener(inListener); +} + +XPCPushButtonMessageAttachment::~XPCPushButtonMessageAttachment() +{ +} + +int XPCPushButtonMessageAttachment::HandleWidgetMessage( + XPCWidget * inObject, + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2) +{ + if ((inMessage == xpMsg_PushButtonPressed) && ((XPWidgetID) inParam1 == mWidget)) + { + BroadcastMessage(mMsg, mParam); + return 1; + } + + if ((inMessage == xpMsg_ButtonStateChanged) && ((XPWidgetID) inParam1 == mWidget)) + { + BroadcastMessage(mMsg, mParam); + return 1; + } + return 0; +} + +XPCSliderMessageAttachment::XPCSliderMessageAttachment( + XPWidgetID inWidget, + int inMessage, + void * inParam, + XPCListener * inListener) : + mMsg(inMessage), mParam(inParam), mWidget(inWidget) +{ + if (inListener != NULL) + this->AddListener(inListener); +} + +XPCSliderMessageAttachment::~XPCSliderMessageAttachment() +{ +} + +int XPCSliderMessageAttachment::HandleWidgetMessage( + XPCWidget * inObject, + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2) +{ + if ((inMessage == xpMsg_ScrollBarSliderPositionChanged) && ((XPWidgetID) inParam1 == mWidget)) + { + BroadcastMessage(mMsg, mParam); + return 1; + } + + return 0; +} + + +XPCCloseButtonMessageAttachment::XPCCloseButtonMessageAttachment( + XPWidgetID inWidget, + int inMessage, + void * inParam, + XPCListener * inListener) : + mMsg(inMessage), mParam(inParam), mWidget(inWidget) +{ + if (inListener != NULL) + this->AddListener(inListener); +} + +XPCCloseButtonMessageAttachment::~XPCCloseButtonMessageAttachment() +{ +} + +int XPCCloseButtonMessageAttachment::HandleWidgetMessage( + XPCWidget * inObject, + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2) +{ + if ((inMessage == xpMessage_CloseButtonPushed) && ((XPWidgetID) inParam1 == mWidget)) + { + BroadcastMessage(mMsg, mParam); + return 1; + } + + return 0; +} + +XPCTabGroupAttachment::XPCTabGroupAttachment() +{ +} + +XPCTabGroupAttachment::~XPCTabGroupAttachment() +{ +} + +int XPCTabGroupAttachment::HandleWidgetMessage( + XPCWidget * inObject, + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2) +{ + if ((inMessage == xpMsg_KeyPress) && (KEY_CHAR(inParam1) == XPLM_KEY_TAB) && + ((KEY_FLAGS(inParam1) & xplm_UpFlag) == 0)) + { + bool backwards = (KEY_FLAGS(inParam1) & xplm_ShiftFlag) != 0; + std::vector widgets; + XPCGetOrderedSubWidgets(inWidget, widgets); + int n, index = 0; + XPWidgetID focusWidget = XPGetWidgetWithFocus(); + std::vector::iterator iter = std::find(widgets.begin(), widgets.end(), focusWidget); + if (iter != widgets.end()) + { + index = std::distance(widgets.begin(), iter); + if (backwards) + index--; + else + index++; + if (index < 0) + index = widgets.size() - 1; + if (index >= widgets.size()) + index = 0; + } + + if (backwards) + { + for (n = index; n >= 0; --n) + { + if (XPGetWidgetProperty(widgets[n], xpProperty_Enabled, NULL)) + if (XPSetKeyboardFocus(widgets[n]) != NULL) + return 1; + } + for (n = widgets.size() - 1; n > index; --n) + { + if (XPGetWidgetProperty(widgets[n], xpProperty_Enabled, NULL)) + if (XPSetKeyboardFocus(widgets[n]) != NULL) + return 1; + } + } else { + for (n = index; n < widgets.size(); ++n) + { + if (XPGetWidgetProperty(widgets[n], xpProperty_Enabled, NULL)) + if (XPSetKeyboardFocus(widgets[n]) != NULL) + return 1; + } + for (n = 0; n < index; ++n) + { + if (XPGetWidgetProperty(widgets[n], xpProperty_Enabled, NULL)) + if (XPSetKeyboardFocus(widgets[n]) != NULL) + return 1; + } + } + } + return 0; +} + + + +static void XPCGetOrderedSubWidgets( + XPWidgetID inWidget, + std::vector& outChildren) +{ + outChildren.clear(); + int count = XPCountChildWidgets(inWidget); + for (int n = 0; n < count; ++n) + { + XPWidgetID child = XPGetNthChildWidget(inWidget, n); + outChildren.push_back(child); + std::vector grandChildren; + XPCGetOrderedSubWidgets(child, grandChildren); + + outChildren.insert(outChildren.end(), grandChildren.begin(), grandChildren.end()); + } +} diff --git a/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/Wrappers/XPCWidgetAttachments.h b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/Wrappers/XPCWidgetAttachments.h new file mode 100644 index 0000000..91fb587 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/Wrappers/XPCWidgetAttachments.h @@ -0,0 +1,146 @@ +#ifndef _XPCWidgetAttachments_h_ +#define _XPCWidgetAttachments_h_ + +#include + +#include "XPCWidget.h" +#include "XPCBroadcaster.h" + +class XPCKeyFilterAttachment : public XPCWidgetAttachment { +public: + + XPCKeyFilterAttachment( + const char * inValidKeys, + const char * outValidKeys); + virtual ~XPCKeyFilterAttachment(); + + virtual int HandleWidgetMessage( + XPCWidget * inObject, + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2); + +private: + + std::string mInput; + std::string mOutput; + +}; + + +class XPCKeyMessageAttachment : public XPCWidgetAttachment, public XPCBroadcaster { +public: + + XPCKeyMessageAttachment( + char inKey, + int inMessage, + void * inParam, + bool inConsume, + bool inVkey, + XPCListener * inListener); + virtual ~XPCKeyMessageAttachment(); + + virtual int HandleWidgetMessage( + XPCWidget * inObject, + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2); + +private: + + char mKey; + bool mVkey; + int mMsg; + void * mParam; + bool mConsume; + +}; + +class XPCPushButtonMessageAttachment : public XPCWidgetAttachment, XPCBroadcaster { +public: + + XPCPushButtonMessageAttachment( + XPWidgetID inWidget, + int inMessage, + void * inParam, + XPCListener * inListener); + virtual ~XPCPushButtonMessageAttachment(); + + virtual int HandleWidgetMessage( + XPCWidget * inObject, + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2); + +private: + XPWidgetID mWidget; + int mMsg; + void * mParam; +}; + +class XPCSliderMessageAttachment : public XPCWidgetAttachment, XPCBroadcaster { +public: + + XPCSliderMessageAttachment( + XPWidgetID inWidget, + int inMessage, + void * inParam, + XPCListener * inListener); + virtual ~XPCSliderMessageAttachment(); + + virtual int HandleWidgetMessage( + XPCWidget * inObject, + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2); + +private: + XPWidgetID mWidget; + int mMsg; + void * mParam; +}; + + +class XPCCloseButtonMessageAttachment : public XPCWidgetAttachment, XPCBroadcaster { +public: + + XPCCloseButtonMessageAttachment( + XPWidgetID inWidget, + int inMessage, + void * inParam, + XPCListener * inListener); + virtual ~XPCCloseButtonMessageAttachment(); + + virtual int HandleWidgetMessage( + XPCWidget * inObject, + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2); + +private: + XPWidgetID mWidget; + int mMsg; + void * mParam; +}; + +class XPCTabGroupAttachment : public XPCWidgetAttachment { +public: + + XPCTabGroupAttachment(); + virtual ~XPCTabGroupAttachment(); + + virtual int HandleWidgetMessage( + XPCWidget * inObject, + XPWidgetMessage inMessage, + XPWidgetID inWidget, + intptr_t inParam1, + intptr_t inParam2); + +}; + +#endif \ No newline at end of file diff --git a/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/XPLM/XPLMCamera.h b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/XPLM/XPLMCamera.h new file mode 100644 index 0000000..db930ef --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/XPLM/XPLMCamera.h @@ -0,0 +1,167 @@ +#ifndef _XPLMCamera_h_ +#define _XPLMCamera_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPLMCamera + ***************************************************************************/ +/* + * The XPLMCamera APIs allow plug-ins to control the camera angle in X-Plane. + * This has a number of applications, including but not limited to: + * + * - Creating new views (including dynamic/user-controllable views) for the + * user. + * - Creating applications that use X-Plane as a renderer of scenery, + * aircrafts, or both. + * + * The camera is controlled via six parameters: a location in OpenGL + * coordinates and pitch, roll and yaw, similar to an airplane's position. + * OpenGL coordinate info is described in detail in the XPLMGraphics + * documentation; generally you should use the XPLMGraphics routines to + * convert from world to local coordinates. The camera's orientation starts + * facing level with the ground directly up the negative-Z axis (approximately + * north) with the horizon horizontal. It is then rotated clockwise for yaw, + * pitched up for positive pitch, and rolled clockwise around the vector it is + * looking along for roll. + * + * You control the camera either either until the user selects a new view or + * permanently (the later being similar to how UDP camera control works). You + * control the camera by registering a callback per frame from which you + * calculate the new camera positions. This guarantees smooth camera motion. + * + * Use the XPLMDataAccess APIs to get information like the position of the + * aircraft, etc. for complex camera positioning. + * + * Note: if your goal is to move the virtual pilot in the cockpit, this API is + * not needed; simply update the datarefs for the pilot's head position. + * + * For custom exterior cameras, set the camera's mode to an external view + * first to get correct sound and 2-d panel behavior. + * + */ + +#include "XPLMDefs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*************************************************************************** + * CAMERA CONTROL + ***************************************************************************/ + +/* + * XPLMCameraControlDuration + * + * This enumeration states how long you want to retain control of the camera. + * You can retain it indefinitely or until the user selects a new view. + * + */ +enum { + /* Control the camera until the user picks a new view. */ + xplm_ControlCameraUntilViewChanges = 1, + + /* Control the camera until your plugin is disabled or another plugin forcably* + * takes control. */ + xplm_ControlCameraForever = 2, + + +}; +typedef int XPLMCameraControlDuration; + +/* + * XPLMCameraPosition_t + * + * This structure contains a full specification of the camera. X, Y, and Z are + * the camera's position in OpenGL coordiantes; pitch, roll, and yaw are + * rotations from a camera facing flat north in degrees. Positive pitch means + * nose up, positive roll means roll right, and positive yaw means yaw right, + * all in degrees. Zoom is a zoom factor, with 1.0 meaning normal zoom and 2.0 + * magnifying by 2x (objects appear larger). + * + */ +typedef struct { + float x; + float y; + float z; + float pitch; + float heading; + float roll; + float zoom; +} XPLMCameraPosition_t; + +/* + * XPLMCameraControl_f + * + * You use an XPLMCameraControl function to provide continuous control over + * the camera. You are passed in a structure in which to put the new camera + * position; modify it and return 1 to reposition the camera. Return 0 to + * surrender control of the camera; camera control will be handled by X-Plane + * on this draw loop. The contents of the structure as you are called are + * undefined. + * + * If X-Plane is taking camera control away from you, this function will be + * called with inIsLosingControl set to 1 and ioCameraPosition NULL. + * + */ +typedef int (* XPLMCameraControl_f)( + XPLMCameraPosition_t * outCameraPosition, /* Can be NULL */ + int inIsLosingControl, + void * inRefcon); + +/* + * XPLMControlCamera + * + * This function repositions the camera on the next drawing cycle. You must + * pass a non-null control function. Specify in inHowLong how long you'd like + * control (indefinitely or until a new view mode is set by the user). + * + */ +XPLM_API void XPLMControlCamera( + XPLMCameraControlDuration inHowLong, + XPLMCameraControl_f inControlFunc, + void * inRefcon); + +/* + * XPLMDontControlCamera + * + * This function stops you from controlling the camera. If you have a camera + * control function, it will not be called with an inIsLosingControl flag. + * X-Plane will control the camera on the next cycle. + * + * For maximum compatibility you should not use this routine unless you are in + * posession of the camera. + * + */ +XPLM_API void XPLMDontControlCamera(void); + +/* + * XPLMIsCameraBeingControlled + * + * This routine returns 1 if the camera is being controlled, zero if it is + * not. If it is and you pass in a pointer to a camera control duration, the + * current control duration will be returned. + * + */ +XPLM_API int XPLMIsCameraBeingControlled( + XPLMCameraControlDuration * outCameraControlDuration); /* Can be NULL */ + +/* + * XPLMReadCameraPosition + * + * This function reads the current camera position. + * + */ +XPLM_API void XPLMReadCameraPosition( + XPLMCameraPosition_t * outCameraPosition); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/XPLM/XPLMDataAccess.h b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/XPLM/XPLMDataAccess.h new file mode 100644 index 0000000..d8d1418 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/XPLM/XPLMDataAccess.h @@ -0,0 +1,716 @@ +#ifndef _XPLMDataAccess_h_ +#define _XPLMDataAccess_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPLMDataAccess + ***************************************************************************/ +/* + * The data access API gives you a generic, flexible, high performance way to + * read and write data to and from X-Plane and other plug-ins. For example, + * this API allows you to read and set the nav radios, get the plane location, + * determine the current effective graphics frame rate, etc. + * + * The data access APIs are the way that you read and write data from the sim + * as well as other plugins. + * + * The API works using opaque data references. A data reference is a source of + * data; you do not know where it comes from, but once you have it you can + * read the data quickly and possibly write it. + * + * Dataref Lookup + * -------------- + * + * Data references are identified by verbose, permanent string names; by + * convention these names use path separates to form a hierarchy of datarefs, + * e.g. (sim/cockpit/radios/nav1_freq_hz). The actual opaque numeric value of + * the data reference, as returned by the XPLM API, is implementation defined + * and changes each time X-Plane is launched; therefore you need to look up + * the dataref by path every time your plugin runs. + * + * The task of looking up a data reference is relatively expensive; look up + * your data references once based on the verbose path strings, and save the + * opaque data reference value for the duration of your plugin's operation. + * Reading and writing data references is relatively fast (the cost is + * equivalent to two function calls through function pointers). + * + * X-Plane publishes over 4000 datarefs; a complete list may be found in the + * reference section of the SDK online documentation (from the SDK home page, + * choose Documentation). + * + * Dataref Types + * ------------- + * + * A note on typing: you must know the correct data type to read and write. + * APIs are provided for reading and writing data in a number of ways. You can + * also double check the data type for a data ref. Automatic type conversion + * is not done for you. + * + * Dataref types are a set, e.g. a dataref can be more than one type. When + * this happens, you can choose which API you want to use to read. For + * example, it is not uncommon for a dataref to be of type float and double. + * This means you can use either XPLMGetDatad or XPLMGetDataf to read it. + * + * Creating New Datarefs + * --------------------- + * + * X-Plane provides datarefs that come with the sim, but plugins can also + * create their own datarefs. A plugin creates a dataref by registering + * function callbacks to read and write the dataref. The XPLM will call your + * plugin each time some other plugin (or X-Plane) tries to read or write the + * dataref. You must provide a read (and optional write) callback for each + * data type you support. + * + * A note for plugins sharing data with other plugins: the load order of + * plugins is not guaranteed. To make sure that every plugin publishing data + * has published their data references before other plugins try to subscribe, + * publish your data references in your start routine but resolve them the + * first time your 'enable' routine is called, or the first time they are + * needed in code. + * + * When a plugin that created a dataref is unloaded, it becomes "orphaned". + * The dataref handle continues to be usable, but the dataref is not writable, + * and reading it will always return 0 (or 0 items for arrays). If the plugin + * is reloaded and re-registers the dataref, the handle becomes un-orphaned + * and works again. + * + */ + +#include "XPLMDefs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*************************************************************************** + * READING AND WRITING DATA + ***************************************************************************/ +/* + * These routines allow you to access data from within X-Plane and sometimes + * modify it. + * + */ + + +/* + * XPLMDataRef + * + * A data ref is an opaque handle to data provided by the simulator or another + * plugin. It uniquely identifies one variable (or array of variables) over + * the lifetime of your plugin. You never hard code these values; you always + * get them from XPLMFindDataRef. + * + */ +typedef void * XPLMDataRef; + +/* + * XPLMDataTypeID + * + * This is an enumeration that defines the type of the data behind a data + * reference. This allows you to sanity check that the data type matches what + * you expect. But for the most part, you will know the type of data you are + * expecting from the online documentation. + * + * Data types each take a bit field; it is legal to have a single dataref be + * more than one type of data. Whe this happens, you can pick any matching + * get/set API. + * + */ +enum { + /* Data of a type the current XPLM doesn't do. */ + xplmType_Unknown = 0, + + /* A single 4-byte integer, native endian. */ + xplmType_Int = 1, + + /* A single 4-byte float, native endian. */ + xplmType_Float = 2, + + /* A single 8-byte double, native endian. */ + xplmType_Double = 4, + + /* An array of 4-byte floats, native endian. */ + xplmType_FloatArray = 8, + + /* An array of 4-byte integers, native endian. */ + xplmType_IntArray = 16, + + /* A variable block of data. */ + xplmType_Data = 32, + + +}; +typedef int XPLMDataTypeID; + +/* + * XPLMFindDataRef + * + * Given a c-style string that names the data ref, this routine looks up the + * actual opaque XPLMDataRef that you use to read and write the data. The + * string names for datarefs are published on the X-Plane SDK web site. + * + * This function returns NULL if the data ref cannot be found. + * + * NOTE: this function is relatively expensive; save the XPLMDataRef this + * function returns for future use. Do not look up your data ref by string + * every time you need to read or write it. + * + */ +XPLM_API XPLMDataRef XPLMFindDataRef( + const char * inDataRefName); + +/* + * XPLMCanWriteDataRef + * + * Given a data ref, this routine returns true if you can successfully set the + * data, false otherwise. Some datarefs are read-only. + * + * NOTE: even if a dataref is marked writable, it may not act writable. This + * can happen for datarefs that X-Plane writes to on every frame of + * simulation. In some cases, the dataref is writable but you have to set a + * separate "override" dataref to 1 to stop X-Plane from writing it. + * + */ +XPLM_API int XPLMCanWriteDataRef( + XPLMDataRef inDataRef); + +/* + * XPLMIsDataRefGood + * + * This function returns true if the passed in handle is a valid dataref that + * is not orphaned. + * + * Note: there is normally no need to call this function; datarefs returned by + * XPLMFindDataRef remain valid (but possibly orphaned) unless there is a + * complete plugin reload (in which case your plugin is reloaded anyway). + * Orphaned datarefs can be safely read and return 0. Therefore you never need + * to call XPLMIsDataRefGood to 'check' the safety of a dataref. + * (XPLMIsDatarefGood performs some slow checking of the handle validity, so + * it has a perormance cost.) + * + */ +XPLM_API int XPLMIsDataRefGood( + XPLMDataRef inDataRef); + +/* + * XPLMGetDataRefTypes + * + * This routine returns the types of the data ref for accessor use. If a data + * ref is available in multiple data types, the bit-wise OR of these types + * will be returned. + * + */ +XPLM_API XPLMDataTypeID XPLMGetDataRefTypes( + XPLMDataRef inDataRef); + +/*************************************************************************** + * DATA ACCESSORS + ***************************************************************************/ +/* + * These routines read and write the data references. For each supported data + * type there is a reader and a writer. + * + * If the data ref is orphaned or the plugin that provides it is disabled or + * there is a type mismatch, the functions that read data will return 0 as a + * default value or not modify the passed in memory. The plugins that write + * data will not write under these circumstances or if the data ref is + * read-only. + * + * NOTE: to keep the overhead of reading datarefs low, these routines do not + * do full validation of a dataref; passing a junk value for a dataref can + * result in crashing the sim. The get/set APIs do check for NULL. + * + * For array-style datarefs, you specify the number of items to read/write and + * the offset into the array; the actual number of items read or written is + * returned. This may be less to prevent an array-out-of-bounds error. + * + */ + + +/* + * XPLMGetDatai + * + * Read an integer data ref and return its value. The return value is the + * dataref value or 0 if the dataref is NULL or the plugin is disabled. + * + */ +XPLM_API int XPLMGetDatai( + XPLMDataRef inDataRef); + +/* + * XPLMSetDatai + * + * Write a new value to an integer data ref. This routine is a no-op if the + * plugin publishing the dataref is disabled, the dataref is NULL, or the + * dataref is not writable. + * + */ +XPLM_API void XPLMSetDatai( + XPLMDataRef inDataRef, + int inValue); + +/* + * XPLMGetDataf + * + * Read a single precision floating point dataref and return its value. The + * return value is the dataref value or 0.0 if the dataref is NULL or the + * plugin is disabled. + * + */ +XPLM_API float XPLMGetDataf( + XPLMDataRef inDataRef); + +/* + * XPLMSetDataf + * + * Write a new value to a single precision floating point data ref. This + * routine is a no-op if the plugin publishing the dataref is disabled, the + * dataref is NULL, or the dataref is not writable. + * + */ +XPLM_API void XPLMSetDataf( + XPLMDataRef inDataRef, + float inValue); + +/* + * XPLMGetDatad + * + * Read a double precision floating point dataref and return its value. The + * return value is the dataref value or 0.0 if the dataref is NULL or the + * plugin is disabled. + * + */ +XPLM_API double XPLMGetDatad( + XPLMDataRef inDataRef); + +/* + * XPLMSetDatad + * + * Write a new value to a double precision floating point data ref. This + * routine is a no-op if the plugin publishing the dataref is disabled, the + * dataref is NULL, or the dataref is not writable. + * + */ +XPLM_API void XPLMSetDatad( + XPLMDataRef inDataRef, + double inValue); + +/* + * XPLMGetDatavi + * + * Read a part of an integer array dataref. If you pass NULL for outValues, + * the routine will return the size of the array, ignoring inOffset and inMax. + * + * If outValues is not NULL, then up to inMax values are copied from the + * dataref into outValues, starting at inOffset in the dataref. If inMax + + * inOffset is larger than the size of the dataref, less than inMax values + * will be copied. The number of values copied is returned. + * + * Note: the semantics of array datarefs are entirely implemented by the + * plugin (or X-Plane) that provides the dataref, not the SDK itself; the + * above description is how these datarefs are intended to work, but a rogue + * plugin may have different behavior. + * + */ +XPLM_API int XPLMGetDatavi( + XPLMDataRef inDataRef, + int * outValues, /* Can be NULL */ + int inOffset, + int inMax); + +/* + * XPLMSetDatavi + * + * Write part or all of an integer array dataref. The values passed by + * inValues are written into the dataref starting at inOffset. Up to inCount + * values are written; however if the values would write "off the end" of the + * dataref array, then fewer values are written. + * + * Note: the semantics of array datarefs are entirely implemented by the + * plugin (or X-Plane) that provides the dataref, not the SDK itself; the + * above description is how these datarefs are intended to work, but a rogue + * plugin may have different behavior. + * + */ +XPLM_API void XPLMSetDatavi( + XPLMDataRef inDataRef, + int * inValues, + int inoffset, + int inCount); + +/* + * XPLMGetDatavf + * + * Read a part of a single precision floating point array dataref. If you pass + * NULL for outVaules, the routine will return the size of the array, ignoring + * inOffset and inMax. + * + * If outValues is not NULL, then up to inMax values are copied from the + * dataref into outValues, starting at inOffset in the dataref. If inMax + + * inOffset is larger than the size of the dataref, less than inMax values + * will be copied. The number of values copied is returned. + * + * Note: the semantics of array datarefs are entirely implemented by the + * plugin (or X-Plane) that provides the dataref, not the SDK itself; the + * above description is how these datarefs are intended to work, but a rogue + * plugin may have different behavior. + * + */ +XPLM_API int XPLMGetDatavf( + XPLMDataRef inDataRef, + float * outValues, /* Can be NULL */ + int inOffset, + int inMax); + +/* + * XPLMSetDatavf + * + * Write part or all of a single precision floating point array dataref. The + * values passed by inValues are written into the dataref starting at + * inOffset. Up to inCount values are written; however if the values would + * write "off the end" of the dataref array, then fewer values are written. + * + * Note: the semantics of array datarefs are entirely implemented by the + * plugin (or X-Plane) that provides the dataref, not the SDK itself; the + * above description is how these datarefs are intended to work, but a rogue + * plugin may have different behavior. + * + */ +XPLM_API void XPLMSetDatavf( + XPLMDataRef inDataRef, + float * inValues, + int inoffset, + int inCount); + +/* + * XPLMGetDatab + * + * Read a part of a byte array dataref. If you pass NULL for outVaules, the + * routine will return the size of the array, ignoring inOffset and inMax. + * + * If outValues is not NULL, then up to inMax values are copied from the + * dataref into outValues, starting at inOffset in the dataref. If inMax + + * inOffset is larger than the size of the dataref, less than inMax values + * will be copied. The number of values copied is returned. + * + * Note: the semantics of array datarefs are entirely implemented by the + * plugin (or X-Plane) that provides the dataref, not the SDK itself; the + * above description is how these datarefs are intended to work, but a rogue + * plugin may have different behavior. + * + */ +XPLM_API int XPLMGetDatab( + XPLMDataRef inDataRef, + void * outValue, /* Can be NULL */ + int inOffset, + int inMaxBytes); + +/* + * XPLMSetDatab + * + * Write part or all of a byte array dataref. The values passed by inValues + * are written into the dataref starting at inOffset. Up to inCount values are + * written; however if the values would write "off the end" of the dataref + * array, then fewer values are written. + * + * Note: the semantics of array datarefs are entirely implemented by the + * plugin (or X-Plane) that provides the dataref, not the SDK itself; the + * above description is how these datarefs are intended to work, but a rogue + * plugin may have different behavior. + * + */ +XPLM_API void XPLMSetDatab( + XPLMDataRef inDataRef, + void * inValue, + int inOffset, + int inLength); + +/*************************************************************************** + * PUBLISHING YOUR PLUGIN'S DATA + ***************************************************************************/ +/* + * These functions allow you to create data references that other plug-ins and + * X-Plane can access via the above data access APIs. Data references + * published by other plugins operate the same as ones published by X-Plane in + * all manners except that your data reference will not be available to other + * plugins if/when your plugin is disabled. + * + * You share data by registering data provider callback functions. When a + * plug-in requests your data, these callbacks are then called. You provide + * one callback to return the value when a plugin 'reads' it and another to + * change the value when a plugin 'writes' it. + * + * Important: you must pick a prefix for your datarefs other than "sim/" - + * this prefix is reserved for X-Plane. The X-Plane SDK website contains a + * registry where authors can select a unique first word for dataref names, to + * prevent dataref collisions between plugins. + * + */ + + +/* + * XPLMGetDatai_f + * + * Data provider function pointers. + * + * These define the function pointers you provide to get or set data. Note + * that you are passed a generic pointer for each one. This is the same + * pointer you pass in your register routine; you can use it to locate plugin + * variables, etc. + * + * The semantics of your callbacks are the same as the dataref accessor above + * - basically routines like XPLMGetDatai are just pass-throughs from a caller + * to your plugin. Be particularly mindful in implementing array dataref + * read-write accessors; you are responsible for avoiding overruns, supporting + * offset read/writes, and handling a read with a NULL buffer. + * + */ +typedef int (* XPLMGetDatai_f)( + void * inRefcon); + +/* + * XPLMSetDatai_f + * + */ +typedef void (* XPLMSetDatai_f)( + void * inRefcon, + int inValue); + +/* + * XPLMGetDataf_f + * + */ +typedef float (* XPLMGetDataf_f)( + void * inRefcon); + +/* + * XPLMSetDataf_f + * + */ +typedef void (* XPLMSetDataf_f)( + void * inRefcon, + float inValue); + +/* + * XPLMGetDatad_f + * + */ +typedef double (* XPLMGetDatad_f)( + void * inRefcon); + +/* + * XPLMSetDatad_f + * + */ +typedef void (* XPLMSetDatad_f)( + void * inRefcon, + double inValue); + +/* + * XPLMGetDatavi_f + * + */ +typedef int (* XPLMGetDatavi_f)( + void * inRefcon, + int * outValues, /* Can be NULL */ + int inOffset, + int inMax); + +/* + * XPLMSetDatavi_f + * + */ +typedef void (* XPLMSetDatavi_f)( + void * inRefcon, + int * inValues, + int inOffset, + int inCount); + +/* + * XPLMGetDatavf_f + * + */ +typedef int (* XPLMGetDatavf_f)( + void * inRefcon, + float * outValues, /* Can be NULL */ + int inOffset, + int inMax); + +/* + * XPLMSetDatavf_f + * + */ +typedef void (* XPLMSetDatavf_f)( + void * inRefcon, + float * inValues, + int inOffset, + int inCount); + +/* + * XPLMGetDatab_f + * + */ +typedef int (* XPLMGetDatab_f)( + void * inRefcon, + void * outValue, /* Can be NULL */ + int inOffset, + int inMaxLength); + +/* + * XPLMSetDatab_f + * + */ +typedef void (* XPLMSetDatab_f)( + void * inRefcon, + void * inValue, + int inOffset, + int inLength); + +/* + * XPLMRegisterDataAccessor + * + * This routine creates a new item of data that can be read and written. Pass + * in the data's full name for searching, the type(s) of the data for + * accessing, and whether the data can be written to. For each data type you + * support, pass in a read accessor function and a write accessor function if + * necessary. Pass NULL for data types you do not support or write accessors + * if you are read-only. + * + * You are returned a data ref for the new item of data created. You can use + * this data ref to unregister your data later or read or write from it. + * + */ +XPLM_API XPLMDataRef XPLMRegisterDataAccessor( + const char * inDataName, + XPLMDataTypeID inDataType, + int inIsWritable, + XPLMGetDatai_f inReadInt, + XPLMSetDatai_f inWriteInt, + XPLMGetDataf_f inReadFloat, + XPLMSetDataf_f inWriteFloat, + XPLMGetDatad_f inReadDouble, + XPLMSetDatad_f inWriteDouble, + XPLMGetDatavi_f inReadIntArray, + XPLMSetDatavi_f inWriteIntArray, + XPLMGetDatavf_f inReadFloatArray, + XPLMSetDatavf_f inWriteFloatArray, + XPLMGetDatab_f inReadData, + XPLMSetDatab_f inWriteData, + void * inReadRefcon, + void * inWriteRefcon); + +/* + * XPLMUnregisterDataAccessor + * + * Use this routine to unregister any data accessors you may have registered. + * You unregister a data ref by the XPLMDataRef you get back from + * registration. Once you unregister a data ref, your function pointer will + * not be called anymore. + * + */ +XPLM_API void XPLMUnregisterDataAccessor( + XPLMDataRef inDataRef); + +/*************************************************************************** + * SHARING DATA BETWEEN MULTIPLE PLUGINS + ***************************************************************************/ +/* + * The data reference registration APIs from the previous section allow a + * plugin to publish data in a one-owner manner; the plugin that publishes the + * data reference owns the real memory that the data ref uses. This is + * satisfactory for most cases, but there are also cases where plugnis need to + * share actual data. + * + * With a shared data reference, no one plugin owns the actual memory for the + * data reference; the plugin SDK allocates that for you. When the first + * plugin asks to 'share' the data, the memory is allocated. When the data is + * changed, every plugin that is sharing the data is notified. + * + * Shared data references differ from the 'owned' data references from the + * previous section in a few ways: + * + * * With shared data references, any plugin can create the data reference; + * with owned plugins one plugin must create the data reference and others + * subscribe. (This can be a problem if you don't know which set of plugins + * will be present). + * + * * With shared data references, every plugin that is sharing the data is + * notified when the data is changed. With owned data references, only the + * one owner is notified when the data is changed. + * + * * With shared data references, you cannot access the physical memory of the + * data reference; you must use the XPLMGet... and XPLMSet... APIs. With an + * owned data reference, the one owning data reference can manipulate the + * data reference's memory in any way it sees fit. + * + * Shared data references solve two problems: if you need to have a data + * reference used by several plugins but do not know which plugins will be + * installed, or if all plugins sharing data need to be notified when that + * data is changed, use shared data references. + * + */ + + +/* + * XPLMDataChanged_f + * + * An XPLMDataChanged_f is a callback that the XPLM calls whenever any other + * plug-in modifies shared data. A refcon you provide is passed back to help + * identify which data is being changed. In response, you may want to call one + * of the XPLMGetDataxxx routines to find the new value of the data. + * + */ +typedef void (* XPLMDataChanged_f)( + void * inRefcon); + +/* + * XPLMShareData + * + * This routine connects a plug-in to shared data, creating the shared data if + * necessary. inDataName is a standard path for the data ref, and inDataType + * specifies the type. This function will create the data if it does not + * exist. If the data already exists but the type does not match, an error is + * returned, so it is important that plug-in authors collaborate to establish + * public standards for shared data. + * + * If a notificationFunc is passed in and is not NULL, that notification + * function will be called whenever the data is modified. The notification + * refcon will be passed to it. This allows your plug-in to know which shared + * data was changed if multiple shared data are handled by one callback, or if + * the plug-in does not use global variables. + * + * A one is returned for successfully creating or finding the shared data; a + * zero if the data already exists but is of the wrong type. + * + */ +XPLM_API int XPLMShareData( + const char * inDataName, + XPLMDataTypeID inDataType, + XPLMDataChanged_f inNotificationFunc, + void * inNotificationRefcon); + +/* + * XPLMUnshareData + * + * This routine removes your notification function for shared data. Call it + * when done with the data to stop receiving change notifications. Arguments + * must match XPLMShareData. The actual memory will not necessarily be freed, + * since other plug-ins could be using it. + * + */ +XPLM_API int XPLMUnshareData( + const char * inDataName, + XPLMDataTypeID inDataType, + XPLMDataChanged_f inNotificationFunc, + void * inNotificationRefcon); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/XPLM/XPLMDefs.h b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/XPLM/XPLMDefs.h new file mode 100644 index 0000000..2e95b81 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/XPLM/XPLMDefs.h @@ -0,0 +1,514 @@ +#ifndef _XPLMDefs_h_ +#define _XPLMDefs_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPLMDefs + ***************************************************************************/ +/* + * This file is contains the cross-platform and basic definitions for the + * X-Plane SDK. + * + * The preprocessor macros APL and IBM must be defined to specify the + * compilation target; define APL to 1 and IBM 0 to compile on Macintosh and + * APL to 0 and IBM to 1 for Windows. You must specify these macro definitions + * before including XPLMDefs.h or any other XPLM headers. You can do this + * using the -D command line option or a preprocessor header. + * + */ + + +#ifdef __cplusplus +extern "C" { +#endif + +#if IBM +#include +#else +#include +#endif +/*************************************************************************** + * DLL Definitions + ***************************************************************************/ +/* + * These definitions control the importing and exporting of functions within + * the DLL. + * + * You can prefix your five required callbacks with the PLUGIN_API macro to + * declare them as exported C functions. The XPLM_API macro identifies + * functions that are provided to you via the plugin SDK. (Link against + * XPLM.lib to use these functions.) + * + */ + + +#ifdef __cplusplus + #if APL + #if __GNUC__ >= 4 + #define PLUGIN_API extern "C" __attribute__((visibility("default"))) + #elif __MACH__ + #define PLUGIN_API extern "C" + #else + #define PLUGIN_API extern "C" __declspec(dllexport) + #endif + #elif IBM + #define PLUGIN_API extern "C" __declspec(dllexport) + #elif LIN + #if __GNUC__ >= 4 + #define PLUGIN_API extern "C" __attribute__((visibility("default"))) + #else + #define PLUGIN_API extern "C" + #endif + #else + #error "Platform not defined!" + #endif +#else + #if APL + #if __GNUC__ >= 4 + #define PLUGIN_API __attribute__((visibility("default"))) + #elif __MACH__ + #define PLUGIN_API + #else + #define PLUGIN_API __declspec(dllexport) + #endif + #elif IBM + #define PLUGIN_API __declspec(dllexport) + #elif LIN + #if __GNUC__ >= 4 + #define PLUGIN_API __attribute__((visibility("default"))) + #else + #define PLUGIN_API + #endif + #else + #error "Platform not defined!" + #endif +#endif + +#if APL + #if XPLM + #if __GNUC__ >= 4 + #define XPLM_API __attribute__((visibility("default"))) + #elif __MACH__ + #define XPLM_API + #else + #define XPLM_API __declspec(dllexport) + #endif + #else + #define XPLM_API + #endif +#elif IBM + #if XPLM + #define XPLM_API __declspec(dllexport) + #else + #define XPLM_API __declspec(dllimport) + #endif +#elif LIN + #if XPLM + #if __GNUC__ >= 4 + #define XPLM_API __attribute__((visibility("default"))) + #else + #define XPLM_API + #endif + #else + #define XPLM_API + #endif +#else + #error "Platform not defined!" +#endif + +/*************************************************************************** + * GLOBAL DEFINITIONS + ***************************************************************************/ +/* + * These definitions are used in all parts of the SDK. + * + */ + + +/* + * XPLMPluginID + * + * Each plug-in is identified by a unique integer ID. This ID can be used to + * disable or enable a plug-in, or discover what plug-in is 'running' at the + * time. A plug-in ID is unique within the currently running instance of + * X-Plane unless plug-ins are reloaded. Plug-ins may receive a different + * unique ID each time they are loaded. This includes the unloading and + * reloading of plugins that are part of the user's aircraft. + * + * For persistent identification of plug-ins, use XPLMFindPluginBySignature in + * XPLMUtiltiies.h + * + * -1 indicates no plug-in. + * + */ +typedef int XPLMPluginID; + +/* No plugin. */ +#define XPLM_NO_PLUGIN_ID (-1) + +/* X-Plane itself */ +#define XPLM_PLUGIN_XPLANE (0) + +/* The current XPLM revision is 4.00 (400). */ +#define kXPLM_Version (400) + +/* + * XPLMKeyFlags + * + * These bitfields define modifier keys in a platform independent way. When a + * key is pressed, a series of messages are sent to your plugin. The down + * flag is set in the first of these messages, and the up flag in the last. + * While the key is held down, messages are sent with neither to indicate that + * the key is being held down as a repeated character. + * + * The control flag is mapped to the control flag on Macintosh and PC. + * Generally X-Plane uses the control key and not the command key on + * Macintosh, providing a consistent interface across platforms that does not + * necessarily match the Macintosh user interface guidelines. There is not + * yet a way for plugins to access the Macintosh control keys without using + * #ifdefed code. + * + */ +enum { + /* The shift key is down */ + xplm_ShiftFlag = 1, + + /* The option or alt key is down */ + xplm_OptionAltFlag = 2, + + /* The control key is down* */ + xplm_ControlFlag = 4, + + /* The key is being pressed down */ + xplm_DownFlag = 8, + + /* The key is being released */ + xplm_UpFlag = 16, + + +}; +typedef int XPLMKeyFlags; + +/*************************************************************************** + * ASCII CONTROL KEY CODES + ***************************************************************************/ +/* + * These definitions define how various control keys are mapped to ASCII key + * codes. Not all key presses generate an ASCII value, so plugin code should + * be prepared to see null characters come from the keyboard...this usually + * represents a key stroke that has no equivalent ASCII, like a page-down + * press. Use virtual key codes to find these key strokes. + * + * ASCII key codes take into account modifier keys; shift keys will affect + * capitals and punctuation; control key combinations may have no vaild ASCII + * and produce NULL. To detect control-key combinations, use virtual key + * codes, not ASCII keys. + * + */ + + +#define XPLM_KEY_RETURN 13 + +#define XPLM_KEY_ESCAPE 27 + +#define XPLM_KEY_TAB 9 + +#define XPLM_KEY_DELETE 8 + +#define XPLM_KEY_LEFT 28 + +#define XPLM_KEY_RIGHT 29 + +#define XPLM_KEY_UP 30 + +#define XPLM_KEY_DOWN 31 + +#define XPLM_KEY_0 48 + +#define XPLM_KEY_1 49 + +#define XPLM_KEY_2 50 + +#define XPLM_KEY_3 51 + +#define XPLM_KEY_4 52 + +#define XPLM_KEY_5 53 + +#define XPLM_KEY_6 54 + +#define XPLM_KEY_7 55 + +#define XPLM_KEY_8 56 + +#define XPLM_KEY_9 57 + +#define XPLM_KEY_DECIMAL 46 + +/*************************************************************************** + * VIRTUAL KEY CODES + ***************************************************************************/ +/* + * These are cross-platform defines for every distinct keyboard press on the + * computer. Every physical key on the keyboard has a virtual key code. So + * the "two" key on the top row of the main keyboard has a different code from + * the "two" key on the numeric key pad. But the 'w' and 'W' character are + * indistinguishable by virtual key code because they are the same physical + * key (one with and one without the shift key). + * + * Use virtual key codes to detect keystrokes that do not have ASCII + * equivalents, allow the user to map the numeric keypad separately from the + * main keyboard, and detect control key and other modifier-key combinations + * that generate ASCII control key sequences (many of which are not available + * directly via character keys in the SDK). + * + * To assign virtual key codes we started with the Microsoft set but made some + * additions and changes. A few differences: + * + * 1. Modifier keys are not available as virtual key codes. You cannot get + * distinct modifier press and release messages. Please do not try to use + * modifier keys as regular keys; doing so will almost certainly interfere + * with users' abilities to use the native X-Plane key bindings. + * 2. Some keys that do not exist on both Mac and PC keyboards are removed. + * 3. Do not assume that the values of these keystrokes are interchangeable + * with MS v-keys. + * + */ + + +#define XPLM_VK_BACK 0x08 + +#define XPLM_VK_TAB 0x09 + +#define XPLM_VK_CLEAR 0x0C + +#define XPLM_VK_RETURN 0x0D + +#define XPLM_VK_ESCAPE 0x1B + +#define XPLM_VK_SPACE 0x20 + +#define XPLM_VK_PRIOR 0x21 + +#define XPLM_VK_NEXT 0x22 + +#define XPLM_VK_END 0x23 + +#define XPLM_VK_HOME 0x24 + +#define XPLM_VK_LEFT 0x25 + +#define XPLM_VK_UP 0x26 + +#define XPLM_VK_RIGHT 0x27 + +#define XPLM_VK_DOWN 0x28 + +#define XPLM_VK_SELECT 0x29 + +#define XPLM_VK_PRINT 0x2A + +#define XPLM_VK_EXECUTE 0x2B + +#define XPLM_VK_SNAPSHOT 0x2C + +#define XPLM_VK_INSERT 0x2D + +#define XPLM_VK_DELETE 0x2E + +#define XPLM_VK_HELP 0x2F + +/* XPLM_VK_0 thru XPLM_VK_9 are the same as ASCII '0' thru '9' (0x30 - 0x39) */ +#define XPLM_VK_0 0x30 + +#define XPLM_VK_1 0x31 + +#define XPLM_VK_2 0x32 + +#define XPLM_VK_3 0x33 + +#define XPLM_VK_4 0x34 + +#define XPLM_VK_5 0x35 + +#define XPLM_VK_6 0x36 + +#define XPLM_VK_7 0x37 + +#define XPLM_VK_8 0x38 + +#define XPLM_VK_9 0x39 + +/* XPLM_VK_A thru XPLM_VK_Z are the same as ASCII 'A' thru 'Z' (0x41 - 0x5A) */ +#define XPLM_VK_A 0x41 + +#define XPLM_VK_B 0x42 + +#define XPLM_VK_C 0x43 + +#define XPLM_VK_D 0x44 + +#define XPLM_VK_E 0x45 + +#define XPLM_VK_F 0x46 + +#define XPLM_VK_G 0x47 + +#define XPLM_VK_H 0x48 + +#define XPLM_VK_I 0x49 + +#define XPLM_VK_J 0x4A + +#define XPLM_VK_K 0x4B + +#define XPLM_VK_L 0x4C + +#define XPLM_VK_M 0x4D + +#define XPLM_VK_N 0x4E + +#define XPLM_VK_O 0x4F + +#define XPLM_VK_P 0x50 + +#define XPLM_VK_Q 0x51 + +#define XPLM_VK_R 0x52 + +#define XPLM_VK_S 0x53 + +#define XPLM_VK_T 0x54 + +#define XPLM_VK_U 0x55 + +#define XPLM_VK_V 0x56 + +#define XPLM_VK_W 0x57 + +#define XPLM_VK_X 0x58 + +#define XPLM_VK_Y 0x59 + +#define XPLM_VK_Z 0x5A + +#define XPLM_VK_NUMPAD0 0x60 + +#define XPLM_VK_NUMPAD1 0x61 + +#define XPLM_VK_NUMPAD2 0x62 + +#define XPLM_VK_NUMPAD3 0x63 + +#define XPLM_VK_NUMPAD4 0x64 + +#define XPLM_VK_NUMPAD5 0x65 + +#define XPLM_VK_NUMPAD6 0x66 + +#define XPLM_VK_NUMPAD7 0x67 + +#define XPLM_VK_NUMPAD8 0x68 + +#define XPLM_VK_NUMPAD9 0x69 + +#define XPLM_VK_MULTIPLY 0x6A + +#define XPLM_VK_ADD 0x6B + +#define XPLM_VK_SEPARATOR 0x6C + +#define XPLM_VK_SUBTRACT 0x6D + +#define XPLM_VK_DECIMAL 0x6E + +#define XPLM_VK_DIVIDE 0x6F + +#define XPLM_VK_F1 0x70 + +#define XPLM_VK_F2 0x71 + +#define XPLM_VK_F3 0x72 + +#define XPLM_VK_F4 0x73 + +#define XPLM_VK_F5 0x74 + +#define XPLM_VK_F6 0x75 + +#define XPLM_VK_F7 0x76 + +#define XPLM_VK_F8 0x77 + +#define XPLM_VK_F9 0x78 + +#define XPLM_VK_F10 0x79 + +#define XPLM_VK_F11 0x7A + +#define XPLM_VK_F12 0x7B + +#define XPLM_VK_F13 0x7C + +#define XPLM_VK_F14 0x7D + +#define XPLM_VK_F15 0x7E + +#define XPLM_VK_F16 0x7F + +#define XPLM_VK_F17 0x80 + +#define XPLM_VK_F18 0x81 + +#define XPLM_VK_F19 0x82 + +#define XPLM_VK_F20 0x83 + +#define XPLM_VK_F21 0x84 + +#define XPLM_VK_F22 0x85 + +#define XPLM_VK_F23 0x86 + +#define XPLM_VK_F24 0x87 + +/* The following definitions are extended and are not based on the Microsoft * + * key set. */ +#define XPLM_VK_EQUAL 0xB0 + +#define XPLM_VK_MINUS 0xB1 + +#define XPLM_VK_RBRACE 0xB2 + +#define XPLM_VK_LBRACE 0xB3 + +#define XPLM_VK_QUOTE 0xB4 + +#define XPLM_VK_SEMICOLON 0xB5 + +#define XPLM_VK_BACKSLASH 0xB6 + +#define XPLM_VK_COMMA 0xB7 + +#define XPLM_VK_SLASH 0xB8 + +#define XPLM_VK_PERIOD 0xB9 + +#define XPLM_VK_BACKQUOTE 0xBA + +#define XPLM_VK_ENTER 0xBB + +#define XPLM_VK_NUMPAD_ENT 0xBC + +#define XPLM_VK_NUMPAD_EQ 0xBD + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/XPLM/XPLMDisplay.h b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/XPLM/XPLMDisplay.h new file mode 100644 index 0000000..db5006d --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/XPLM/XPLMDisplay.h @@ -0,0 +1,1658 @@ +#ifndef _XPLMDisplay_h_ +#define _XPLMDisplay_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPLMDisplay + ***************************************************************************/ +/* + * This API provides the basic hooks to draw in X-Plane and create user + * interface. All X-Plane drawing is done in OpenGL. The X-Plane plug-in + * manager takes care of properly setting up the OpenGL context and matrices. + * You do not decide when in your code's execution to draw; X-Plane tells you + * (via callbacks) when it is ready to have your plugin draw. + * + * X-Plane's drawing strategy is straightforward: every "frame" the screen is + * rendered by drawing the 3-D scene (dome, ground, objects, airplanes, etc.) + * and then drawing the cockpit on top of it. Alpha blending is used to + * overlay the cockpit over the world (and the gauges over the panel, etc.). + * X-Plane user interface elements (including windows like the map, the main + * menu, etc.) are then drawn on top of the cockpit. + * + * There are two ways you can draw: directly and in a window. + * + * Direct drawing (deprecated!---more on that below) involves drawing to the + * screen before or after X-Plane finishes a phase of drawing. When you draw + * directly, you can specify whether X-Plane is to complete this phase or not. + * This allows you to do three things: draw before X-Plane does (under it), + * draw after X-Plane does (over it), or draw instead of X-Plane. + * + * To draw directly, you register a callback and specify which phase you want + * to intercept. The plug-in manager will call you over and over to draw that + * phase. + * + * Direct drawing allows you to override scenery, panels, or anything. Note + * that you cannot assume that you are the only plug-in drawing at this phase. + * + * Direct drawing is deprecated; at some point in the X-Plane 11 run, it will + * likely become unsupported entirely as X-Plane transitions from OpenGL to + * modern graphics API backends (e.g., Vulkan, Metal, etc.). In the long term, + * plugins should use the XPLMInstance API for drawing 3-D objects---this will + * be much more efficient than general 3-D OpenGL drawing, and it will + * actually be supported by the new graphics backends. We do not yet know what + * the post-transition API for generic 3-D drawing will look like (if it + * exists at all). + * + * In contrast to direct drawing, window drawing provides a higher level + * functionality. With window drawing, you create a 2-D window that takes up a + * portion of the screen. Window drawing is always two dimensional. Window + * drawing is front-to-back controlled; you can specify that you want your + * window to be brought on top, and other plug-ins may put their window on top + * of you. Window drawing also allows you to sign up for key presses and + * receive mouse clicks. + * + * Drawing into the screen of an avionics device, like a GPS or a Primary + * Flight Display, is a way to extend or replace X-Plane's avionics. Most + * screens can be displayed both in a 3d cockpit or + * 2d panel, and also in separate popup windows. By installing drawing + * callbacks for a certain avionics device, you can change or extend the + * appearance of that device regardless whether it's installed in a 3d + * cockpit or used in a separate display for home cockpits because you leave + * the window managing to X-Plane. + * + * There are three ways to get keystrokes: + * + * 1. If you create a window, the window can take keyboard focus. It will + * then receive all keystrokes. If no window has focus, X-Plane receives + * keystrokes. Use this to implement typing in dialog boxes, etc. Only + * one window may have focus at a time; your window will be notified if it + * loses focus. + * 2. If you need low level access to the keystroke stream, install a key + * sniffer. Key sniffers can be installed above everything or right in + * front of the sim. + * 3. If you would like to associate key strokes with commands/functions in + * your plug-in, you should simply register a command (via + * XPLMCreateCommand()) and allow users to bind whatever key they choose to + * that command. Another (now deprecated) method of doing so is to use a + * hot key---a key-specific callback. Hotkeys are sent based on virtual + * key strokes, so any key may be distinctly mapped with any modifiers. + * Hot keys can be remapped by other plug-ins. As a plug-in, you don't + * have to worry about what your hot key ends up mapped to; other plug-ins + * may provide a UI for remapping keystrokes. So hotkeys allow a user to + * resolve conflicts and customize keystrokes. + * + */ + +#include "XPLMDefs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*************************************************************************** + * DRAWING CALLBACKS + ***************************************************************************/ +/* + * Basic drawing callbacks, for low level intercepting of X-Plane's render + * loop. The purpose of drawing callbacks is to provide targeted additions or + * replacements to X-Plane's graphics environment (for example, to add extra + * custom objects, or replace drawing of the AI aircraft). Do not assume that + * the drawing callbacks will be called in the order implied by the + * enumerations. Also do not assume that each drawing phase ends before + * another begins; they may be nested. + * + * Note that all APIs in this section are deprecated, and will likely be + * removed during the X-Plane 11 run as part of the transition to + * Vulkan/Metal/etc. See the XPLMInstance API for future-proof drawing of 3-D + * objects. + * + */ + + +/* + * XPLMDrawingPhase + * + * This constant indicates which part of drawing we are in. Drawing is done + * from the back to the front. We get a callback before or after each item. + * Metaphases provide access to the beginning and end of the 3d (scene) and + * 2d (cockpit) drawing in a manner that is independent of new phases added + * via X-Plane implementation. + * + * **NOTE**: As of XPLM302 the legacy 3D drawing phases (xplm_Phase_FirstScene + * to xplm_Phase_LastScene) are deprecated. When running under X-Plane 11.50 + * with the modern Vulkan or Metal backend, X-Plane will no longer call + * these drawing phases. There is a new drawing phase, xplm_Phase_Modern3D, + * which is supported under OpenGL and Vulkan which is called out roughly + * where the old before xplm_Phase_Airplanes phase was for blending. This + * phase is *NOT* supported under Metal and comes with potentially + * substantial performance overhead. Please do *NOT* opt into this phase if + * you don't do any actual drawing that requires the depth buffer in some + * way! + * + * **WARNING**: As X-Plane's scenery evolves, some drawing phases may cease to + * exist and new ones may be invented. If you need a particularly specific + * use of these codes, consult Austin and/or be prepared to revise your code + * as X-Plane evolves. + * + */ +enum { +#if defined(XPLM_DEPRECATED) + /* Deprecated as of XPLM302. This is the earliest point at which you can draw * + * in 3-d. */ + xplm_Phase_FirstScene = 0, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated as of XPLM302. Drawing of land and water. */ + xplm_Phase_Terrain = 5, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated as of XPLM302. Drawing runways and other airport detail. */ + xplm_Phase_Airports = 10, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated as of XPLM302. Drawing roads, trails, trains, etc. */ + xplm_Phase_Vectors = 15, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated as of XPLM302. 3-d objects (houses, smokestacks, etc. */ + xplm_Phase_Objects = 20, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated as of XPLM302. External views of airplanes, both yours and the * + * AI aircraft. */ + xplm_Phase_Airplanes = 25, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated as of XPLM302. This is the last point at which you can draw in * + * 3-d. */ + xplm_Phase_LastScene = 30, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM302) + /* A chance to do modern 3D drawing. */ + xplm_Phase_Modern3D = 31, + +#endif /* XPLM302 */ + /* This is the first phase where you can draw in 2-d. */ + xplm_Phase_FirstCockpit = 35, + + /* The non-moving parts of the aircraft panel. */ + xplm_Phase_Panel = 40, + + /* The moving parts of the aircraft panel. */ + xplm_Phase_Gauges = 45, + + /* Floating windows from plugins. */ + xplm_Phase_Window = 50, + + /* The last chance to draw in 2d. */ + xplm_Phase_LastCockpit = 55, + +#if defined(XPLM200) + /* Removed as of XPLM300; Use the full-blown XPLMMap API instead. */ + xplm_Phase_LocalMap3D = 100, + +#endif /* XPLM200 */ +#if defined(XPLM200) + /* Removed as of XPLM300; Use the full-blown XPLMMap API instead. */ + xplm_Phase_LocalMap2D = 101, + +#endif /* XPLM200 */ +#if defined(XPLM200) + /* Removed as of XPLM300; Use the full-blown XPLMMap API instead. */ + xplm_Phase_LocalMapProfile = 102, + +#endif /* XPLM200 */ + +}; +typedef int XPLMDrawingPhase; + +/* + * XPLMDrawCallback_f + * + * This is the prototype for a low level drawing callback. You are passed in + * the phase and whether it is before or after. If you are before the phase, + * return 1 to let X-Plane draw or 0 to suppress X-Plane drawing. If you are + * after the phase the return value is ignored. + * + * Refcon is a unique value that you specify when registering the callback, + * allowing you to slip a pointer to your own data to the callback. + * + * Upon entry the OpenGL context will be correctly set up for you and OpenGL + * will be in 'local' coordinates for 3d drawing and panel coordinates for 2d + * drawing. The OpenGL state (texturing, etc.) will be unknown. + * + */ +typedef int (* XPLMDrawCallback_f)( + XPLMDrawingPhase inPhase, + int inIsBefore, + void * inRefcon); + +/* + * XPLMRegisterDrawCallback + * + * This routine registers a low level drawing callback. Pass in the phase you + * want to be called for and whether you want to be called before or after. + * This routine returns 1 if the registration was successful, or 0 if the + * phase does not exist in this version of X-Plane. You may register a + * callback multiple times for the same or different phases as long as the + * refcon is unique each time. + * + * Note that this function will likely be removed during the X-Plane 11 run as + * part of the transition to Vulkan/Metal/etc. See the XPLMInstance API for + * future-proof drawing of 3-D objects. + * + */ +XPLM_API int XPLMRegisterDrawCallback( + XPLMDrawCallback_f inCallback, + XPLMDrawingPhase inPhase, + int inWantsBefore, + void * inRefcon); + +/* + * XPLMUnregisterDrawCallback + * + * This routine unregisters a draw callback. You must unregister a callback + * for each time you register a callback if you have registered it multiple + * times with different refcons. The routine returns 1 if it can find the + * callback to unregister, 0 otherwise. + * + * Note that this function will likely be removed during the X-Plane 11 run as + * part of the transition to Vulkan/Metal/etc. See the XPLMInstance API for + * future-proof drawing of 3-D objects. + * + */ +XPLM_API int XPLMUnregisterDrawCallback( + XPLMDrawCallback_f inCallback, + XPLMDrawingPhase inPhase, + int inWantsBefore, + void * inRefcon); + +#if defined(XPLM400) +/*************************************************************************** + * AVIONICS API + ***************************************************************************/ +/* + * Drawing callbacks for before and after X-Plane draws the instrument screen + * can be registered for every cockpit device. If the user plane does not + * have the device installed, your callback will not be called! Use the + * return value to enable or disable X-Plane's drawing. By drawing into the + * framebuffer of the avionics device, your modifications will be visible + * regardless whether the device's screen is in a 3d cockpit or a popup + * window. + * + */ + + +/* + * XPLMDeviceID + * + * This constant indicates the device we want to override or enhance. We can + * get a callback before or after each item. + * + */ +enum { + /* GNS430, pilot side. */ + xplm_device_GNS430_1 = 0, + + /* GNS430, copilot side. */ + xplm_device_GNS430_2 = 1, + + /* GNS530, pilot side. */ + xplm_device_GNS530_1 = 2, + + /* GNS530, copilot side. */ + xplm_device_GNS530_2 = 3, + + /* generic airliner CDU, pilot side. */ + xplm_device_CDU739_1 = 4, + + /* generic airliner CDU, copilot side. */ + xplm_device_CDU739_2 = 5, + + /* G1000 Primary Flight Display, pilot side. */ + xplm_device_G1000_PFD_1 = 6, + + /* G1000 Multifunction Display. */ + xplm_device_G1000_MFD = 7, + + /* G1000 Primary Flight Display, copilot side. */ + xplm_device_G1000_PFD_2 = 8, + + /* Primus CDU, pilot side. */ + xplm_device_CDU815_1 = 9, + + /* Primus CDU, copilot side. */ + xplm_device_CDU815_2 = 10, + + /* Primus Primary Flight Display, pilot side. */ + xplm_device_Primus_PFD_1 = 11, + + /* Primus Primary Flight Display, copilot side. */ + xplm_device_Primus_PFD_2 = 12, + + /* Primus Multifunction Display, pilot side. */ + xplm_device_Primus_MFD_1 = 13, + + /* Primus Multifunction Display, copilot side. */ + xplm_device_Primus_MFD_2 = 14, + + /* Primus Multifunction Display, central. */ + xplm_device_Primus_MFD_3 = 15, + + /* Primus Radio Management Unit, pilot side. */ + xplm_device_Primus_RMU_1 = 16, + + /* Primus Radio Management Unit, copilot side. */ + xplm_device_Primus_RMU_2 = 17, + + +}; +typedef int XPLMDeviceID; + +/* + * XPLMAvionicsCallback_f + * + * This is the prototype for your drawing callback. You are passed in the + * device you are enhancing/replacing, and whether it is before or after + * X-Plane drawing. If you are before X-Plane, return 1 to let X-Plane draw or + * 0 to suppress X-Plane drawing. If you are after the phase the return value + * is ignored. + * + * Refcon is a unique value that you specify when registering the callback, + * allowing you to slip a pointer to your own data to the callback. + * + * Upon entry the OpenGL context will be correctly set up for you and OpenGL + * will be in panel coordinates for 2d drawing. The OpenGL state (texturing, + * etc.) will be unknown. + * + */ +typedef int (* XPLMAvionicsCallback_f)( + XPLMDeviceID inDeviceID, + int inIsBefore, + void * inRefcon); + +/* + * XPLMAvionicsID + * + * This is an opaque identifier for an avionics display that you enhance or + * replace. When you register your callbacks (via + * XPLMRegisterAvionicsCallbacksEx()), you will specify callbacks to handle + * drawing, and get back such a handle. + * + */ +typedef void * XPLMAvionicsID; + +/* + * XPLMCustomizeAvionics_t + * + * The XPLMCustomizeAvionics_t structure defines all of the parameters used to + * replace or enhance avionics for using XPLMRegisterAvionicsCallbacksEx(). + * The structure will be expanded in future SDK APIs to include more features. + * Always set the structSize member to the size of your struct in bytes! + * + */ +typedef struct { + /* Used to inform XPLMRegisterAvionicsCallbacksEx() of the SDK version you * + * compiled against; should always be set to sizeof(XPLMCustomizeAvionics_t) */ + int structSize; + /* Which avionics device you want your drawing applied to. */ + XPLMDeviceID deviceId; + /* The draw callback to be called before X-Plane draws. */ + XPLMAvionicsCallback_f drawCallbackBefore; + /* The draw callback to be called after X-Plane has drawn. */ + XPLMAvionicsCallback_f drawCallbackAfter; + /* A reference which will be passed into each of your draw callbacks. Use this* + * to pass information to yourself as needed. */ + void * refcon; +} XPLMCustomizeAvionics_t; + +/* + * XPLMRegisterAvionicsCallbacksEx + * + * This routine registers your callbacks for a device. This returns a handle. + * If the returned handle is NULL, there was a problem interpreting your + * input, most likely the struct size was wrong for your SDK version. If the + * returned handle is not NULL, your callbacks will be called according to + * schedule as long as your plugin is not deactivated, or unloaded, or your + * call XPLMUnregisterAvionicsCallbacks(). + * + */ +XPLM_API XPLMAvionicsID XPLMRegisterAvionicsCallbacksEx( + XPLMCustomizeAvionics_t * inParams); + +/* + * XPLMUnregisterAvionicsCallbacks + * + * This routine unregisters your callbacks for a device. They will no longer + * be called. + * + */ +XPLM_API void XPLMUnregisterAvionicsCallbacks( + XPLMAvionicsID inAvionicsId); + +#endif /* XPLM400 */ +/*************************************************************************** + * WINDOW API + ***************************************************************************/ +/* + * The window API provides a high-level abstraction for drawing with UI + * interaction. + * + * Windows may operate in one of two modes: legacy (for plugins compiled + * against old versions of the XPLM, as well as windows created via the + * deprecated XPLMCreateWindow() function, rather than XPLMCreateWindowEx()), + * or modern (for windows compiled against the XPLM300 or newer API, and + * created via XPLMCreateWindowEx()). + * + * Modern windows have access to new X-Plane 11 windowing features, like + * support for new positioning modes (including being "popped out" into their + * own first-class window in the operating system). They can also optionally + * be decorated in the style of X-Plane 11 windows (like the map). + * + * Modern windows operate in "boxel" units. A boxel ("box of pixels") is a + * unit of virtual pixels which, depending on X-Plane's scaling, may + * correspond to an arbitrary NxN "box" of real pixels on screen. Because + * X-Plane handles this scaling automatically, you can effectively treat the + * units as though you were simply drawing in pixels, and know that when + * X-Plane is running with 150% or 200% scaling, your drawing will be + * automatically scaled (and likewise all mouse coordinates, screen bounds, + * etc. will also be auto-scaled). + * + * In contrast, legacy windows draw in true screen pixels, and thus tend to + * look quite small when X-Plane is operating in a scaled mode. + * + * Legacy windows have their origin in the lower left of the main X-Plane + * window. In contrast, since modern windows are not constrained to the main + * window, they have their origin in the lower left of the entire global + * desktop space, and the lower left of the main X-Plane window is not + * guaranteed to be (0, 0). In both cases, x increases as you move left, and y + * increases as you move up. + * + */ + + +/* + * XPLMWindowID + * + * This is an opaque identifier for a window. You use it to control your + * window. When you create a window (via either XPLMCreateWindow() or + * XPLMCreateWindowEx()), you will specify callbacks to handle drawing, mouse + * interaction, etc. + * + */ +typedef void * XPLMWindowID; + +/* + * XPLMDrawWindow_f + * + * A callback to handle 2-D drawing of your window. You are passed in your + * window and its refcon. Draw the window. You can use other XPLM functions + * from this header to find the current dimensions of your window, etc. When + * this callback is called, the OpenGL context will be set properly for 2-D + * window drawing. + * + * **Note**: Because you are drawing your window over a background, you can + * make a translucent window easily by simply not filling in your entire + * window's bounds. + * + */ +typedef void (* XPLMDrawWindow_f)( + XPLMWindowID inWindowID, + void * inRefcon); + +/* + * XPLMHandleKey_f + * + * This function is called when a key is pressed or keyboard focus is taken + * away from your window. If losingFocus is 1, you are losing the keyboard + * focus, otherwise a key was pressed and inKey contains its character. + * + * The window ID passed in will be your window for key presses, or the other + * window taking focus when losing focus. Note that in the modern plugin + * system, often focus is taken by the window manager itself; for this resaon, + * the window ID may be zero when losing focus, and you should not write code + * that depends onit. + * + * The refcon passed in will be the one from registration, for both key + * presses and losing focus. + * + * Warning: this API declares virtual keys as a signed character; however the + * VKEY #define macros in XPLMDefs.h define the vkeys using unsigned values + * (that is 0x80 instead of -0x80). So you may need to cast the incoming vkey + * to an unsigned char to get correct comparisons in C. + * + */ +typedef void (* XPLMHandleKey_f)( + XPLMWindowID inWindowID, + char inKey, + XPLMKeyFlags inFlags, + char inVirtualKey, + void * inRefcon, + int losingFocus); + +/* + * XPLMMouseStatus + * + * When the mouse is clicked, your mouse click routine is called repeatedly. + * It is first called with the mouse down message. It is then called zero or + * more times with the mouse-drag message, and finally it is called once with + * the mouse up message. All of these messages will be directed to the same + * window; you are guaranteed to not receive a drag or mouse-up event without + * first receiving the corresponding mouse-down. + * + */ +enum { + xplm_MouseDown = 1, + + xplm_MouseDrag = 2, + + xplm_MouseUp = 3, + + +}; +typedef int XPLMMouseStatus; + +/* + * XPLMHandleMouseClick_f + * + * You receive this call for one of three events: + * + * - when the user clicks the mouse button down + * - (optionally) when the user drags the mouse after a down-click, but before + * the up-click + * - when the user releases the down-clicked mouse button. + * + * You receive the x and y of the click, your window, and a refcon. Return 1 + * to consume the click, or 0 to pass it through. + * + * WARNING: passing clicks through windows (as of this writing) causes mouse + * tracking problems in X-Plane; do not use this feature! + * + * The units for x and y values match the units used in your window. Thus, for + * "modern" windows (those created via XPLMCreateWindowEx() and compiled + * against the XPLM300 library), the units are boxels, while legacy windows + * will get pixels. Legacy windows have their origin in the lower left of the + * main X-Plane window, while modern windows have their origin in the lower + * left of the global desktop space. In both cases, x increases as you move + * right, and y increases as you move up. + * + */ +typedef int (* XPLMHandleMouseClick_f)( + XPLMWindowID inWindowID, + int x, + int y, + XPLMMouseStatus inMouse, + void * inRefcon); + +#if defined(XPLM200) +/* + * XPLMCursorStatus + * + * XPLMCursorStatus describes how you would like X-Plane to manage the cursor. + * See XPLMHandleCursor_f for more info. + * + */ +enum { + /* X-Plane manages the cursor normally, plugin does not affect the cusrsor. */ + xplm_CursorDefault = 0, + + /* X-Plane hides the cursor. */ + xplm_CursorHidden = 1, + + /* X-Plane shows the cursor as the default arrow. */ + xplm_CursorArrow = 2, + + /* X-Plane shows the cursor but lets you select an OS cursor. */ + xplm_CursorCustom = 3, + + +}; +typedef int XPLMCursorStatus; +#endif /* XPLM200 */ + +#if defined(XPLM200) +/* + * XPLMHandleCursor_f + * + * The SDK calls your cursor status callback when the mouse is over your + * plugin window. Return a cursor status code to indicate how you would like + * X-Plane to manage the cursor. If you return xplm_CursorDefault, the SDK + * will try lower-Z-order plugin windows, then let the sim manage the cursor. + * + * Note: you should never show or hide the cursor yourself---these APIs are + * typically reference-counted and thus cannot safely and predictably be used + * by the SDK. Instead return one of xplm_CursorHidden to hide the cursor or + * xplm_CursorArrow/xplm_CursorCustom to show the cursor. + * + * If you want to implement a custom cursor by drawing a cursor in OpenGL, use + * xplm_CursorHidden to hide the OS cursor and draw the cursor using a 2-d + * drawing callback (after xplm_Phase_Window is probably a good choice, but + * see deprecation warnings on the drawing APIs!). If you want to use a + * custom OS-based cursor, use xplm_CursorCustom to ask X-Plane to show the + * cursor but not affect its image. You can then use an OS specific call like + * SetThemeCursor (Mac) or SetCursor/LoadCursor (Windows). + * + * The units for x and y values match the units used in your window. Thus, for + * "modern" windows (those created via XPLMCreateWindowEx() and compiled + * against the XPLM300 library), the units are boxels, while legacy windows + * will get pixels. Legacy windows have their origin in the lower left of the + * main X-Plane window, while modern windows have their origin in the lower + * left of the global desktop space. In both cases, x increases as you move + * right, and y increases as you move up. + * + */ +typedef XPLMCursorStatus (* XPLMHandleCursor_f)( + XPLMWindowID inWindowID, + int x, + int y, + void * inRefcon); +#endif /* XPLM200 */ + +#if defined(XPLM200) +/* + * XPLMHandleMouseWheel_f + * + * The SDK calls your mouse wheel callback when one of the mouse wheels is + * scrolled within your window. Return 1 to consume the mouse wheel movement + * or 0 to pass them on to a lower window. (If your window appears opaque to + * the user, you should consume mouse wheel scrolling even if it does + * nothing.) The number of "clicks" indicates how far the wheel was turned + * since the last callback. The wheel is 0 for the vertical axis or 1 for the + * horizontal axis (for OS/mouse combinations that support this). + * + * The units for x and y values match the units used in your window. Thus, for + * "modern" windows (those created via XPLMCreateWindowEx() and compiled + * against the XPLM300 library), the units are boxels, while legacy windows + * will get pixels. Legacy windows have their origin in the lower left of the + * main X-Plane window, while modern windows have their origin in the lower + * left of the global desktop space. In both cases, x increases as you move + * right, and y increases as you move up. + * + */ +typedef int (* XPLMHandleMouseWheel_f)( + XPLMWindowID inWindowID, + int x, + int y, + int wheel, + int clicks, + void * inRefcon); +#endif /* XPLM200 */ + +#if defined(XPLM300) +/* + * XPLMWindowLayer + * + * XPLMWindowLayer describes where in the ordering of windows X-Plane should + * place a particular window. Windows in higher layers cover windows in lower + * layers. So, a given window might be at the top of its particular layer, but + * it might still be obscured by a window in a higher layer. (This happens + * frequently when floating windows, like X-Plane's map, are covered by a + * modal alert.) + * + * Your window's layer can only be specified when you create the window (in + * the XPLMCreateWindow_t you pass to XPLMCreateWindowEx()). For this reason, + * layering only applies to windows created with new X-Plane 11 GUI features. + * (Windows created using the older XPLMCreateWindow(), or windows compiled + * against a pre-XPLM300 version of the SDK will simply be placed in the + * flight overlay window layer.) + * + */ +enum { + /* The lowest layer, used for HUD-like displays while flying. */ + xplm_WindowLayerFlightOverlay = 0, + + /* Windows that "float" over the sim, like the X-Plane 11 map does. If you are* + * not sure which layer to create your window in, choose floating. */ + xplm_WindowLayerFloatingWindows = 1, + + /* An interruptive modal that covers the sim with a transparent black overlay * + * to draw the user's focus to the alert */ + xplm_WindowLayerModal = 2, + + /* "Growl"-style notifications that are visible in a corner of the screen, * + * even over modals */ + xplm_WindowLayerGrowlNotifications = 3, + + +}; +typedef int XPLMWindowLayer; +#endif /* XPLM300 */ + +#if defined(XPLM301) +/* + * XPLMWindowDecoration + * + * XPLMWindowDecoration describes how "modern" windows will be displayed. This + * impacts both how X-Plane draws your window as well as certain mouse + * handlers. + * + * Your window's decoration can only be specified when you create the window + * (in the XPLMCreateWindow_t you pass to XPLMCreateWindowEx()). + * + */ +enum { + /* X-Plane will draw no decoration for your window, and apply no automatic * + * click handlers. The window will not stop click from passing through its * + * bounds. This is suitable for "windows" which request, say, the full screen * + * bounds, then only draw in a small portion of the available area. */ + xplm_WindowDecorationNone = 0, + + /* The default decoration for "native" windows, like the map. Provides a solid* + * background, as well as click handlers for resizing and dragging the window.*/ + xplm_WindowDecorationRoundRectangle = 1, + + /* X-Plane will draw no decoration for your window, nor will it provide resize* + * handlers for your window edges, but it will stop clicks from passing * + * through your windows bounds. */ + xplm_WindowDecorationSelfDecorated = 2, + + /* Like self-decorated, but with resizing; X-Plane will draw no decoration for* + * your window, but it will stop clicks from passing through your windows * + * bounds, and provide automatic mouse handlers for resizing. */ + xplm_WindowDecorationSelfDecoratedResizable = 3, + + +}; +typedef int XPLMWindowDecoration; +#endif /* XPLM301 */ + +#if defined(XPLM200) +/* + * XPLMCreateWindow_t + * + * The XPMCreateWindow_t structure defines all of the parameters used to + * create a modern window using XPLMCreateWindowEx(). The structure will be + * expanded in future SDK APIs to include more features. Always set the + * structSize member to the size of your struct in bytes! + * + * All windows created by this function in the XPLM300 version of the API are + * created with the new X-Plane 11 GUI features. This means your plugin will + * get to "know" about the existence of X-Plane windows other than the main + * window. All drawing and mouse callbacks for your window will occur in + * "boxels," giving your windows automatic support for high-DPI scaling in + * X-Plane. In addition, your windows can opt-in to decoration with the + * X-Plane 11 window styling, and you can use the + * XPLMSetWindowPositioningMode() API to make your window "popped out" into a + * first-class operating system window. + * + * Note that this requires dealing with your window's bounds in "global + * desktop" positioning units, rather than the traditional panel coordinate + * system. In global desktop coordinates, the main X-Plane window may not have + * its origin at coordinate (0, 0), and your own window may have negative + * coordinates. Assuming you don't implicitly assume (0, 0) as your origin, + * the only API change you should need is to start using + * XPLMGetMouseLocationGlobal() rather than XPLMGetMouseLocation(), and + * XPLMGetScreenBoundsGlobal() instead of XPLMGetScreenSize(). + * + * If you ask to be decorated as a floating window, you'll get the blue window + * control bar and blue backing that you see in X-Plane 11's normal "floating" + * windows (like the map). + * + */ +typedef struct { + /* Used to inform XPLMCreateWindowEx() of the SDK version you compiled * + * against; should always be set to sizeof(XPLMCreateWindow_t) */ + int structSize; + /* Left bound, in global desktop boxels */ + int left; + /* Top bound, in global desktop boxels */ + int top; + /* Right bound, in global desktop boxels */ + int right; + /* Bottom bound, in global desktop boxels */ + int bottom; + int visible; + XPLMDrawWindow_f drawWindowFunc; + /* A callback to handle the user left-clicking within your window (or NULL to * + * ignore left clicks) */ + XPLMHandleMouseClick_f handleMouseClickFunc; + XPLMHandleKey_f handleKeyFunc; + XPLMHandleCursor_f handleCursorFunc; + XPLMHandleMouseWheel_f handleMouseWheelFunc; + /* A reference which will be passed into each of your window callbacks. Use * + * this to pass information to yourself as needed. */ + void * refcon; +#if defined(XPLM301) + /* Specifies the type of X-Plane 11-style "wrapper" you want around your * + * window, if any */ + XPLMWindowDecoration decorateAsFloatingWindow; +#endif /* XPLM301 */ +#if defined(XPLM300) + XPLMWindowLayer layer; +#endif /* XPLM300 */ +#if defined(XPLM300) + /* A callback to handle the user right-clicking within your window (or NULL to* + * ignore right clicks) */ + XPLMHandleMouseClick_f handleRightClickFunc; +#endif /* XPLM300 */ +} XPLMCreateWindow_t; +#endif /* XPLM200 */ + +#if defined(XPLM200) +/* + * XPLMCreateWindowEx + * + * This routine creates a new "modern" window. You pass in an + * XPLMCreateWindow_t structure with all of the fields set in. You must set + * the structSize of the structure to the size of the actual structure you + * used. Also, you must provide functions for every callback---you may not + * leave them null! (If you do not support the cursor or mouse wheel, use + * functions that return the default values.) + * + */ +XPLM_API XPLMWindowID XPLMCreateWindowEx( + XPLMCreateWindow_t * inParams); +#endif /* XPLM200 */ + +/* + * XPLMCreateWindow + * + * Deprecated as of XPLM300. + * + * This routine creates a new legacy window. Unlike modern windows (created + * via XPLMCreateWindowEx()), legacy windows do not have access to X-Plane 11 + * features like automatic scaling for high-DPI screens, native window styles, + * or support for being "popped out" into first-class operating system + * windows. + * + * Pass in the dimensions and offsets to the window's bottom left corner from + * the bottom left of the screen. You can specify whether the window is + * initially visible or not. Also, you pass in three callbacks to run the + * window and a refcon. This function returns a window ID you can use to + * refer to the new window. + * + * NOTE: Legacy windows do not have "frames"; you are responsible for drawing + * the background and frame of the window. Higher level libraries have + * routines which make this easy. + * + */ +XPLM_API XPLMWindowID XPLMCreateWindow( + int inLeft, + int inTop, + int inRight, + int inBottom, + int inIsVisible, + XPLMDrawWindow_f inDrawCallback, + XPLMHandleKey_f inKeyCallback, + XPLMHandleMouseClick_f inMouseCallback, + void * inRefcon); + +/* + * XPLMDestroyWindow + * + * This routine destroys a window. The window's callbacks are not called + * after this call. Keyboard focus is removed from the window before + * destroying it. + * + */ +XPLM_API void XPLMDestroyWindow( + XPLMWindowID inWindowID); + +/* + * XPLMGetScreenSize + * + * This routine returns the size of the main X-Plane OpenGL window in pixels. + * This number can be used to get a rough idea of the amount of detail the + * user will be able to see when drawing in 3-d. + * + */ +XPLM_API void XPLMGetScreenSize( + int * outWidth, /* Can be NULL */ + int * outHeight); /* Can be NULL */ + +#if defined(XPLM300) +/* + * XPLMGetScreenBoundsGlobal + * + * This routine returns the bounds of the "global" X-Plane desktop, in boxels. + * Unlike the non-global version XPLMGetScreenSize(), this is multi-monitor + * aware. There are three primary consequences of multimonitor awareness. + * + * First, if the user is running X-Plane in full-screen on two or more + * monitors (typically configured using one full-screen window per monitor), + * the global desktop will be sized to include all X-Plane windows. + * + * Second, the origin of the screen coordinates is not guaranteed to be (0, + * 0). Suppose the user has two displays side-by-side, both running at 1080p. + * Suppose further that they've configured their OS to make the left display + * their "primary" monitor, and that X-Plane is running in full-screen on + * their right monitor only. In this case, the global desktop bounds would be + * the rectangle from (1920, 0) to (3840, 1080). If the user later asked + * X-Plane to draw on their primary monitor as well, the bounds would change + * to (0, 0) to (3840, 1080). + * + * Finally, if the usable area of the virtual desktop is not a perfect + * rectangle (for instance, because the monitors have different resolutions or + * because one monitor is configured in the operating system to be above and + * to the right of the other), the global desktop will include any wasted + * space. Thus, if you have two 1080p monitors, and monitor 2 is configured to + * have its bottom left touch monitor 1's upper right, your global desktop + * area would be the rectangle from (0, 0) to (3840, 2160). + * + * Note that popped-out windows (windows drawn in their own operating system + * windows, rather than "floating" within X-Plane) are not included in these + * bounds. + * + */ +XPLM_API void XPLMGetScreenBoundsGlobal( + int * outLeft, /* Can be NULL */ + int * outTop, /* Can be NULL */ + int * outRight, /* Can be NULL */ + int * outBottom); /* Can be NULL */ +#endif /* XPLM300 */ + +#if defined(XPLM300) +/* + * XPLMReceiveMonitorBoundsGlobal_f + * + * This function is informed of the global bounds (in boxels) of a particular + * monitor within the X-Plane global desktop space. Note that X-Plane must be + * running in full screen on a monitor in order for that monitor to be passed + * to you in this callback. + * + */ +typedef void (* XPLMReceiveMonitorBoundsGlobal_f)( + int inMonitorIndex, + int inLeftBx, + int inTopBx, + int inRightBx, + int inBottomBx, + void * inRefcon); +#endif /* XPLM300 */ + +#if defined(XPLM300) +/* + * XPLMGetAllMonitorBoundsGlobal + * + * This routine immediately calls you back with the bounds (in boxels) of each + * full-screen X-Plane window within the X-Plane global desktop space. Note + * that if a monitor is *not* covered by an X-Plane window, you cannot get its + * bounds this way. Likewise, monitors with only an X-Plane window (not in + * full-screen mode) will not be included. + * + * If X-Plane is running in full-screen and your monitors are of the same size + * and configured contiguously in the OS, then the combined global bounds of + * all full-screen monitors will match the total global desktop bounds, as + * returned by XPLMGetScreenBoundsGlobal(). (Of course, if X-Plane is running + * in windowed mode, this will not be the case. Likewise, if you have + * differently sized monitors, the global desktop space will include wasted + * space.) + * + * Note that this function's monitor indices match those provided by + * XPLMGetAllMonitorBoundsOS(), but the coordinates are different (since the + * X-Plane global desktop may not match the operating system's global desktop, + * and one X-Plane boxel may be larger than one pixel due to 150% or 200% + * scaling). + * + */ +XPLM_API void XPLMGetAllMonitorBoundsGlobal( + XPLMReceiveMonitorBoundsGlobal_f inMonitorBoundsCallback, + void * inRefcon); +#endif /* XPLM300 */ + +#if defined(XPLM300) +/* + * XPLMReceiveMonitorBoundsOS_f + * + * This function is informed of the global bounds (in pixels) of a particular + * monitor within the operating system's global desktop space. Note that a + * monitor index being passed to you here does not indicate that X-Plane is + * running in full screen on this monitor, or even that any X-Plane windows + * exist on this monitor. + * + */ +typedef void (* XPLMReceiveMonitorBoundsOS_f)( + int inMonitorIndex, + int inLeftPx, + int inTopPx, + int inRightPx, + int inBottomPx, + void * inRefcon); +#endif /* XPLM300 */ + +#if defined(XPLM300) +/* + * XPLMGetAllMonitorBoundsOS + * + * This routine immediately calls you back with the bounds (in pixels) of each + * monitor within the operating system's global desktop space. Note that + * unlike XPLMGetAllMonitorBoundsGlobal(), this may include monitors that have + * no X-Plane window on them. + * + * Note that this function's monitor indices match those provided by + * XPLMGetAllMonitorBoundsGlobal(), but the coordinates are different (since + * the X-Plane global desktop may not match the operating system's global + * desktop, and one X-Plane boxel may be larger than one pixel). + * + */ +XPLM_API void XPLMGetAllMonitorBoundsOS( + XPLMReceiveMonitorBoundsOS_f inMonitorBoundsCallback, + void * inRefcon); +#endif /* XPLM300 */ + +/* + * XPLMGetMouseLocation + * + * Deprecated in XPLM300. Modern windows should use + * XPLMGetMouseLocationGlobal() instead. + * + * This routine returns the current mouse location in pixels relative to the + * main X-Plane window. The bottom left corner of the main window is (0, 0). + * Pass NULL to not receive info about either parameter. + * + * Because this function gives the mouse position relative to the main X-Plane + * window (rather than in global bounds), this function should only be used by + * legacy windows. Modern windows should instead get the mouse position in + * global desktop coordinates using XPLMGetMouseLocationGlobal(). + * + * Note that unlike XPLMGetMouseLocationGlobal(), if the mouse goes outside + * the user's main monitor (for instance, to a pop out window or a secondary + * monitor), this function will not reflect it. + * + */ +XPLM_API void XPLMGetMouseLocation( + int * outX, /* Can be NULL */ + int * outY); /* Can be NULL */ + +#if defined(XPLM300) +/* + * XPLMGetMouseLocationGlobal + * + * Returns the current mouse location in global desktop boxels. Unlike + * XPLMGetMouseLocation(), the bottom left of the main X-Plane window is not + * guaranteed to be (0, 0)---instead, the origin is the lower left of the + * entire global desktop space. In addition, this routine gives the real mouse + * location when the mouse goes to X-Plane windows other than the primary + * display. Thus, it can be used with both pop-out windows and secondary + * monitors. + * + * This is the mouse location function to use with modern windows (i.e., those + * created by XPLMCreateWindowEx()). + * + * Pass NULL to not receive info about either parameter. + * + */ +XPLM_API void XPLMGetMouseLocationGlobal( + int * outX, /* Can be NULL */ + int * outY); /* Can be NULL */ +#endif /* XPLM300 */ + +/* + * XPLMGetWindowGeometry + * + * This routine returns the position and size of a window. The units and + * coordinate system vary depending on the type of window you have. + * + * If this is a legacy window (one compiled against a pre-XPLM300 version of + * the SDK, or an XPLM300 window that was not created using + * XPLMCreateWindowEx()), the units are pixels relative to the main X-Plane + * display. + * + * If, on the other hand, this is a new X-Plane 11-style window (compiled + * against the XPLM300 SDK and created using XPLMCreateWindowEx()), the units + * are global desktop boxels. + * + * Pass NULL to not receive any paramter. + * + */ +XPLM_API void XPLMGetWindowGeometry( + XPLMWindowID inWindowID, + int * outLeft, /* Can be NULL */ + int * outTop, /* Can be NULL */ + int * outRight, /* Can be NULL */ + int * outBottom); /* Can be NULL */ + +/* + * XPLMSetWindowGeometry + * + * This routine allows you to set the position and size of a window. + * + * The units and coordinate system match those of XPLMGetWindowGeometry(). + * That is, modern windows use global desktop boxel coordinates, while legacy + * windows use pixels relative to the main X-Plane display. + * + * Note that this only applies to "floating" windows (that is, windows that + * are drawn within the X-Plane simulation windows, rather than being "popped + * out" into their own first-class operating system windows). To set the + * position of windows whose positioning mode is xplm_WindowPopOut, you'll + * need to instead use XPLMSetWindowGeometryOS(). + * + */ +XPLM_API void XPLMSetWindowGeometry( + XPLMWindowID inWindowID, + int inLeft, + int inTop, + int inRight, + int inBottom); + +#if defined(XPLM300) +/* + * XPLMGetWindowGeometryOS + * + * This routine returns the position and size of a "popped out" window (i.e., + * a window whose positioning mode is xplm_WindowPopOut), in operating system + * pixels. Pass NULL to not receive any parameter. + * + */ +XPLM_API void XPLMGetWindowGeometryOS( + XPLMWindowID inWindowID, + int * outLeft, /* Can be NULL */ + int * outTop, /* Can be NULL */ + int * outRight, /* Can be NULL */ + int * outBottom); /* Can be NULL */ +#endif /* XPLM300 */ + +#if defined(XPLM300) +/* + * XPLMSetWindowGeometryOS + * + * This routine allows you to set the position and size, in operating system + * pixel coordinates, of a popped out window (that is, a window whose + * positioning mode is xplm_WindowPopOut, which exists outside the X-Plane + * simulation window, in its own first-class operating system window). + * + * Note that you are responsible for ensuring both that your window is popped + * out (using XPLMWindowIsPoppedOut()) and that a monitor really exists at the + * OS coordinates you provide (using XPLMGetAllMonitorBoundsOS()). + * + */ +XPLM_API void XPLMSetWindowGeometryOS( + XPLMWindowID inWindowID, + int inLeft, + int inTop, + int inRight, + int inBottom); +#endif /* XPLM300 */ + +#if defined(XPLM301) +/* + * XPLMGetWindowGeometryVR + * + * Returns the width and height, in boxels, of a window in VR. Note that you + * are responsible for ensuring your window is in VR (using + * XPLMWindowIsInVR()). + * + */ +XPLM_API void XPLMGetWindowGeometryVR( + XPLMWindowID inWindowID, + int * outWidthBoxels, /* Can be NULL */ + int * outHeightBoxels); /* Can be NULL */ +#endif /* XPLM301 */ + +#if defined(XPLM301) +/* + * XPLMSetWindowGeometryVR + * + * This routine allows you to set the size, in boxels, of a window in VR (that + * is, a window whose positioning mode is xplm_WindowVR). + * + * Note that you are responsible for ensuring your window is in VR (using + * XPLMWindowIsInVR()). + * + */ +XPLM_API void XPLMSetWindowGeometryVR( + XPLMWindowID inWindowID, + int widthBoxels, + int heightBoxels); +#endif /* XPLM301 */ + +/* + * XPLMGetWindowIsVisible + * + * Returns true (1) if the specified window is visible. + * + */ +XPLM_API int XPLMGetWindowIsVisible( + XPLMWindowID inWindowID); + +/* + * XPLMSetWindowIsVisible + * + * This routine shows or hides a window. + * + */ +XPLM_API void XPLMSetWindowIsVisible( + XPLMWindowID inWindowID, + int inIsVisible); + +#if defined(XPLM300) +/* + * XPLMWindowIsPoppedOut + * + * True if this window has been popped out (making it a first-class window in + * the operating system), which in turn is true if and only if you have set + * the window's positioning mode to xplm_WindowPopOut. + * + * Only applies to modern windows. (Windows created using the deprecated + * XPLMCreateWindow(), or windows compiled against a pre-XPLM300 version of + * the SDK cannot be popped out.) + * + */ +XPLM_API int XPLMWindowIsPoppedOut( + XPLMWindowID inWindowID); +#endif /* XPLM300 */ + +#if defined(XPLM301) +/* + * XPLMWindowIsInVR + * + * True if this window has been moved to the virtual reality (VR) headset, + * which in turn is true if and only if you have set the window's positioning + * mode to xplm_WindowVR. + * + * Only applies to modern windows. (Windows created using the deprecated + * XPLMCreateWindow(), or windows compiled against a pre-XPLM301 version of + * the SDK cannot be moved to VR.) + * + */ +XPLM_API int XPLMWindowIsInVR( + XPLMWindowID inWindowID); +#endif /* XPLM301 */ + +#if defined(XPLM300) +/* + * XPLMSetWindowGravity + * + * A window's "gravity" controls how the window shifts as the whole X-Plane + * window resizes. A gravity of 1 means the window maintains its positioning + * relative to the right or top edges, 0 the left/bottom, and 0.5 keeps it + * centered. + * + * Default gravity is (0, 1, 0, 1), meaning your window will maintain its + * position relative to the top left and will not change size as its + * containing window grows. + * + * If you wanted, say, a window that sticks to the top of the screen (with a + * constant height), but which grows to take the full width of the window, you + * would pass (0, 1, 1, 1). Because your left and right edges would maintain + * their positioning relative to their respective edges of the screen, the + * whole width of your window would change with the X-Plane window. + * + * Only applies to modern windows. (Windows created using the deprecated + * XPLMCreateWindow(), or windows compiled against a pre-XPLM300 version of + * the SDK will simply get the default gravity.) + * + */ +XPLM_API void XPLMSetWindowGravity( + XPLMWindowID inWindowID, + float inLeftGravity, + float inTopGravity, + float inRightGravity, + float inBottomGravity); +#endif /* XPLM300 */ + +#if defined(XPLM300) +/* + * XPLMSetWindowResizingLimits + * + * Sets the minimum and maximum size of the client rectangle of the given + * window. (That is, it does not include any window styling that you might + * have asked X-Plane to apply on your behalf.) All resizing operations are + * constrained to these sizes. + * + * Only applies to modern windows. (Windows created using the deprecated + * XPLMCreateWindow(), or windows compiled against a pre-XPLM300 version of + * the SDK will have no minimum or maximum size.) + * + */ +XPLM_API void XPLMSetWindowResizingLimits( + XPLMWindowID inWindowID, + int inMinWidthBoxels, + int inMinHeightBoxels, + int inMaxWidthBoxels, + int inMaxHeightBoxels); +#endif /* XPLM300 */ + +#if defined(XPLM300) +/* + * XPLMWindowPositioningMode + * + * XPLMWindowPositionMode describes how X-Plane will position your window on + * the user's screen. X-Plane will maintain this positioning mode even as the + * user resizes their window or adds/removes full-screen monitors. + * + * Positioning mode can only be set for "modern" windows (that is, windows + * created using XPLMCreateWindowEx() and compiled against the XPLM300 SDK). + * Windows created using the deprecated XPLMCreateWindow(), or windows + * compiled against a pre-XPLM300 version of the SDK will simply get the + * "free" positioning mode. + * + */ +enum { + /* The default positioning mode. Set the window geometry and its future * + * position will be determined by its window gravity, resizing limits, and * + * user interactions. */ + xplm_WindowPositionFree = 0, + + /* Keep the window centered on the monitor you specify */ + xplm_WindowCenterOnMonitor = 1, + + /* Keep the window full screen on the monitor you specify */ + xplm_WindowFullScreenOnMonitor = 2, + + /* Like gui_window_full_screen_on_monitor, but stretches over *all* monitors * + * and popout windows. This is an obscure one... unless you have a very good * + * reason to need it, you probably don't! */ + xplm_WindowFullScreenOnAllMonitors = 3, + + /* A first-class window in the operating system, completely separate from the * + * X-Plane window(s) */ + xplm_WindowPopOut = 4, + +#if defined(XPLM301) + /* A floating window visible on the VR headset */ + xplm_WindowVR = 5, + +#endif /* XPLM301 */ + +}; +typedef int XPLMWindowPositioningMode; +#endif /* XPLM300 */ + +#if defined(XPLM300) +/* + * XPLMSetWindowPositioningMode + * + * Sets the policy for how X-Plane will position your window. + * + * Some positioning modes apply to a particular monitor. For those modes, you + * can pass a negative monitor index to position the window on the main + * X-Plane monitor (the screen with the X-Plane menu bar at the top). Or, if + * you have a specific monitor you want to position your window on, you can + * pass a real monitor index as received from, e.g., + * XPLMGetAllMonitorBoundsOS(). + * + * Only applies to modern windows. (Windows created using the deprecated + * XPLMCreateWindow(), or windows compiled against a pre-XPLM300 version of + * the SDK will always use xplm_WindowPositionFree.) + * + */ +XPLM_API void XPLMSetWindowPositioningMode( + XPLMWindowID inWindowID, + XPLMWindowPositioningMode inPositioningMode, + int inMonitorIndex); +#endif /* XPLM300 */ + +#if defined(XPLM300) +/* + * XPLMSetWindowTitle + * + * Sets the name for a window. This only applies to windows that opted-in to + * styling as an X-Plane 11 floating window (i.e., with styling mode + * xplm_WindowDecorationRoundRectangle) when they were created using + * XPLMCreateWindowEx(). + * + */ +XPLM_API void XPLMSetWindowTitle( + XPLMWindowID inWindowID, + const char * inWindowTitle); +#endif /* XPLM300 */ + +/* + * XPLMGetWindowRefCon + * + * Returns a window's reference constant, the unique value you can use for + * your own purposes. + * + */ +XPLM_API void * XPLMGetWindowRefCon( + XPLMWindowID inWindowID); + +/* + * XPLMSetWindowRefCon + * + * Sets a window's reference constant. Use this to pass data to yourself in + * the callbacks. + * + */ +XPLM_API void XPLMSetWindowRefCon( + XPLMWindowID inWindowID, + void * inRefcon); + +/* + * XPLMTakeKeyboardFocus + * + * This routine gives a specific window keyboard focus. Keystrokes will be + * sent to that window. Pass a window ID of 0 to remove keyboard focus from + * any plugin-created windows and instead pass keyboard strokes directly to + * X-Plane. + * + */ +XPLM_API void XPLMTakeKeyboardFocus( + XPLMWindowID inWindow); + +/* + * XPLMHasKeyboardFocus + * + * Returns true (1) if the indicated window has keyboard focus. Pass a window + * ID of 0 to see if no plugin window has focus, and all keystrokes will go + * directly to X-Plane. + * + */ +XPLM_API int XPLMHasKeyboardFocus( + XPLMWindowID inWindow); + +/* + * XPLMBringWindowToFront + * + * This routine brings the window to the front of the Z-order for its layer. + * Windows are brought to the front automatically when they are created. + * Beyond that, you should make sure you are front before handling mouse + * clicks. + * + * Note that this only brings your window to the front of its layer + * (XPLMWindowLayer). Thus, if you have a window in the floating window layer + * (xplm_WindowLayerFloatingWindows), but there is a modal window (in layer + * xplm_WindowLayerModal) above you, you would still not be the true frontmost + * window after calling this. (After all, the window layers are strictly + * ordered, and no window in a lower layer can ever be above any window in a + * higher one.) + * + */ +XPLM_API void XPLMBringWindowToFront( + XPLMWindowID inWindow); + +/* + * XPLMIsWindowInFront + * + * This routine returns true if the window you passed in is the frontmost + * visible window in its layer (XPLMWindowLayer). + * + * Thus, if you have a window at the front of the floating window layer + * (xplm_WindowLayerFloatingWindows), this will return true even if there is a + * modal window (in layer xplm_WindowLayerModal) above you. (Not to worry, + * though: in such a case, X-Plane will not pass clicks or keyboard input down + * to your layer until the window above stops "eating" the input.) + * + * Note that legacy windows are always placed in layer + * xplm_WindowLayerFlightOverlay, while modern-style windows default to + * xplm_WindowLayerFloatingWindows. This means it's perfectly consistent to + * have two different plugin-created windows (one legacy, one modern) *both* + * be in the front (of their different layers!) at the same time. + * + */ +XPLM_API int XPLMIsWindowInFront( + XPLMWindowID inWindow); + +/*************************************************************************** + * KEY SNIFFERS + ***************************************************************************/ +/* + * Low-level keyboard handlers. Allows for intercepting keystrokes outside the + * normal rules of the user interface. + * + */ + + +/* + * XPLMKeySniffer_f + * + * This is the prototype for a low level key-sniffing function. Window-based + * UI _should not use this_! The windowing system provides high-level + * mediated keyboard access, via the callbacks you attach to your + * XPLMCreateWindow_t. By comparison, the key sniffer provides low level + * keyboard access. + * + * Key sniffers are provided to allow libraries to provide non-windowed user + * interaction. For example, the MUI library uses a key sniffer to do pop-up + * text entry. + * + * Return 1 to pass the key on to the next sniffer, the window manager, + * X-Plane, or whomever is down stream. Return 0 to consume the key. + * + * Warning: this API declares virtual keys as a signed character; however the + * VKEY #define macros in XPLMDefs.h define the vkeys using unsigned values + * (that is 0x80 instead of -0x80). So you may need to cast the incoming vkey + * to an unsigned char to get correct comparisons in C. + * + */ +typedef int (* XPLMKeySniffer_f)( + char inChar, + XPLMKeyFlags inFlags, + char inVirtualKey, + void * inRefcon); + +/* + * XPLMRegisterKeySniffer + * + * This routine registers a key sniffing callback. You specify whether you + * want to sniff before the window system, or only sniff keys the window + * system does not consume. You should ALMOST ALWAYS sniff non-control keys + * after the window system. When the window system consumes a key, it is + * because the user has "focused" a window. Consuming the key or taking + * action based on the key will produce very weird results. Returns + * 1 if successful. + * + */ +XPLM_API int XPLMRegisterKeySniffer( + XPLMKeySniffer_f inCallback, + int inBeforeWindows, + void * inRefcon); + +/* + * XPLMUnregisterKeySniffer + * + * This routine unregisters a key sniffer. You must unregister a key sniffer + * for every time you register one with the exact same signature. Returns 1 + * if successful. + * + */ +XPLM_API int XPLMUnregisterKeySniffer( + XPLMKeySniffer_f inCallback, + int inBeforeWindows, + void * inRefcon); + +/*************************************************************************** + * HOT KEYS + ***************************************************************************/ +/* + * Keystrokes that can be managed by others. These are lower-level than window + * keyboard handlers (i.e., callbacks you attach to your XPLMCreateWindow_t), + * but higher level than key sniffers. + * + */ + + +/* + * XPLMHotKey_f + * + * Your hot key callback simply takes a pointer of your choosing. + * + */ +typedef void (* XPLMHotKey_f)( + void * inRefcon); + +/* + * XPLMHotKeyID + * + * An opaque ID used to identify a hot key. + * + */ +typedef void * XPLMHotKeyID; + +/* + * XPLMRegisterHotKey + * + * This routine registers a hot key. You specify your preferred key stroke + * virtual key/flag combination, a description of what your callback does (so + * other plug-ins can describe the plug-in to the user for remapping) and a + * callback function and opaque pointer to pass in). A new hot key ID is + * returned. During execution, the actual key associated with your hot key + * may change, but you are insulated from this. + * + */ +XPLM_API XPLMHotKeyID XPLMRegisterHotKey( + char inVirtualKey, + XPLMKeyFlags inFlags, + const char * inDescription, + XPLMHotKey_f inCallback, + void * inRefcon); + +/* + * XPLMUnregisterHotKey + * + * Unregisters a hot key. You can only unregister your own hot keys. + * + */ +XPLM_API void XPLMUnregisterHotKey( + XPLMHotKeyID inHotKey); + +/* + * XPLMCountHotKeys + * + * Returns the number of current hot keys. + * + */ +XPLM_API int XPLMCountHotKeys(void); + +/* + * XPLMGetNthHotKey + * + * Returns a hot key by index, for iteration on all hot keys. + * + */ +XPLM_API XPLMHotKeyID XPLMGetNthHotKey( + int inIndex); + +/* + * XPLMGetHotKeyInfo + * + * Returns information about the hot key. Return NULL for any parameter you + * don't want info about. The description should be at least 512 chars long. + * + */ +XPLM_API void XPLMGetHotKeyInfo( + XPLMHotKeyID inHotKey, + char * outVirtualKey, /* Can be NULL */ + XPLMKeyFlags * outFlags, /* Can be NULL */ + char * outDescription, /* Can be NULL */ + XPLMPluginID * outPlugin); /* Can be NULL */ + +/* + * XPLMSetHotKeyCombination + * + * Remaps a hot key's keystrokes. You may remap another plugin's keystrokes. + * + */ +XPLM_API void XPLMSetHotKeyCombination( + XPLMHotKeyID inHotKey, + char inVirtualKey, + XPLMKeyFlags inFlags); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/XPLM/XPLMGraphics.h b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/XPLM/XPLMGraphics.h new file mode 100644 index 0000000..d7aef52 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/XPLM/XPLMGraphics.h @@ -0,0 +1,437 @@ +#ifndef _XPLMGraphics_h_ +#define _XPLMGraphics_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPLMGraphics + ***************************************************************************/ +/* + * A few notes on coordinate systems: + * + * X-Plane uses three kinds of coordinates. Global coordinates are specified + * as latitude, longitude and elevation. This coordinate system never changes + * but is not very precise. + * + * OpenGL (or 'local') coordinates are cartesian and shift with the plane. + * They offer more precision and are used for 3-d OpenGL drawing. The X axis + * is aligned east-west with positive X meaning east. The Y axis is aligned + * straight up and down at the point 0,0,0 (but since the earth is round it is + * not truly straight up and down at other points). The Z axis is aligned + * north-south at 0, 0, 0 with positive Z pointing south (but since the earth + * is round it isn't exactly north-south as you move east or west of 0, 0, 0). + * One unit is one meter and the point 0,0,0 is on the surface of the earth at + * sea level for some latitude and longitude picked by the sim such that the + * user's aircraft is reasonably nearby. + * + * 2-d Panel coordinates are 2d, with the X axis horizontal and the Y axis + * vertical. The point 0,0 is the bottom left and 1024,768 is the upper + * right of the screen. This is true no matter what resolution the user's + * monitor is in; when running in higher resolution, graphics will be + * scaled. + * + * Use X-Plane's routines to convert between global and local coordinates. Do + * not attempt to do this conversion yourself; the precise 'roundness' of + * X-Plane's physics model may not match your own, and (to make things + * weirder) the user can potentially customize the physics of the current + * planet. + * + */ + +#include "XPLMDefs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*************************************************************************** + * X-PLANE GRAPHICS + ***************************************************************************/ +/* + * These routines allow you to use OpenGL with X-Plane. + * + */ + + +/* + * XPLMTextureID + * + * XPLM Texture IDs name well-known textures in the sim for you to use. This + * allows you to recycle textures from X-Plane, saving VRAM. + * + * *Warning*: do not use these enums. The only remaining use they have is to + * access the legacy compatibility v10 UI texture; if you need this, get it + * via the Widgets library. + * + */ +enum { + /* The bitmap that contains window outlines, button outlines, fonts, etc. */ + xplm_Tex_GeneralInterface = 0, + +#if defined(XPLM_DEPRECATED) + /* The exterior paint for the user's aircraft (daytime). */ + xplm_Tex_AircraftPaint = 1, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* The exterior light map for the user's aircraft. */ + xplm_Tex_AircraftLiteMap = 2, + +#endif /* XPLM_DEPRECATED */ + +}; +typedef int XPLMTextureID; + +/* + * XPLMSetGraphicsState + * + * XPLMSetGraphicsState changes OpenGL's fixed function pipeline state. You + * are not responsible for restoring any state that is accessed via + * XPLMSetGraphicsState, but you are responsible for not accessing this state + * directly. + * + * - inEnableFog - enables or disables fog, equivalent to: glEnable(GL_FOG); + * - inNumberTexUnits - enables or disables a number of multitexturing units. + * If the number is 0, 2d texturing is disabled entirely, as in + * glDisable(GL_TEXTURE_2D); Otherwise, 2d texturing is enabled, and a + * number of multitexturing units are enabled sequentially, starting with + * unit 0, e.g. glActiveTextureARB(GL_TEXTURE0_ARB); glEnable + * (GL_TEXTURE_2D); + * - inEnableLighting - enables or disables OpenGL lighting, e.g. + * glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); + * - inEnableAlphaTesting - enables or disables the alpha test per pixel, e.g. + * glEnable(GL_ALPHA_TEST); + * - inEnableAlphaBlending - enables or disables alpha blending per pixel, + * e.g. glEnable(GL_BLEND); + * - inEnableDepthTesting - enables per pixel depth testing, as in + * glEnable(GL_DEPTH_TEST); + * - inEnableDepthWriting - enables writing back of depth information to the + * depth bufffer, as in glDepthMask(GL_TRUE); + * + * The purpose of this function is to change OpenGL state while keeping + * X-Plane aware of the state changes; this keeps X-Plane from getting + * surprised by OGL state changes, and prevents X-Plane and plug-ins from + * having to set all state before all draws; XPLMSetGraphicsState internally + * skips calls to change state that is already properly enabled. + * + * X-Plane does not have a 'default' OGL state for plug-ins with respect to + * the above state vector; plug-ins should totally set OGL state using this + * API before drawing. Use XPLMSetGraphicsState instead of any of the above + * OpenGL calls. + * + * WARNING: Any routine that performs drawing (e.g. XPLMDrawString or widget + * code) may change X-Plane's state. Always set state before drawing after + * unknown code has executed. + * + * *Deprecation Warnings*: X-Plane's lighting and fog environemnt is + * significantly more complex than the fixed function pipeline can express; + * do not assume that lighting and fog state is a good approximation for 3-d + * drawing. Prefer to use XPLMInstancing to draw objects. All calls to + * XPLMSetGraphicsState should have no fog or lighting. + * + */ +XPLM_API void XPLMSetGraphicsState( + int inEnableFog, + int inNumberTexUnits, + int inEnableLighting, + int inEnableAlphaTesting, + int inEnableAlphaBlending, + int inEnableDepthTesting, + int inEnableDepthWriting); + +/* + * XPLMBindTexture2d + * + * XPLMBindTexture2d changes what texture is bound to the 2d texturing + * target. This routine caches the current 2d texture across all texturing + * units in the sim and plug-ins, preventing extraneous binding. For + * example, consider several plug-ins running in series; if they all use the + * 'general interface' bitmap to do UI, calling this function will skip the + * rebinding of the general interface texture on all but the first plug-in, + * which can provide better frame rate son some graphics cards. + * + * inTextureID is the ID of the texture object to bind; inTextureUnit is a + * zero-based texture unit (e.g. 0 for the first one), up to a maximum of 4 + * units. (This number may increase in future versions of X-Plane.) + * + * Use this routine instead of glBindTexture(GL_TEXTURE_2D, ....); + * + */ +XPLM_API void XPLMBindTexture2d( + int inTextureNum, + int inTextureUnit); + +/* + * XPLMGenerateTextureNumbers + * + * Use this routine instead of glGenTextures to generate new texture object + * IDs. This routine historically ensured that plugins don't use texure IDs + * that X-Plane is reserving for its own use. + * + */ +XPLM_API void XPLMGenerateTextureNumbers( + int * outTextureIDs, + int inCount); + +#if defined(XPLM_DEPRECATED) +/* + * XPLMGetTexture + * + * XPLMGetTexture returns the OpenGL texture ID of an X-Plane texture based on + * a generic identifying code. For example, you can get the texture for + * X-Plane's UI bitmaps. + * + */ +XPLM_API int XPLMGetTexture( + XPLMTextureID inTexture); +#endif /* XPLM_DEPRECATED */ + +/* + * XPLMWorldToLocal + * + * This routine translates coordinates from latitude, longitude, and altitude + * to local scene coordinates. Latitude and longitude are in decimal degrees, + * and altitude is in meters MSL (mean sea level). The XYZ coordinates are in + * meters in the local OpenGL coordinate system. + * + */ +XPLM_API void XPLMWorldToLocal( + double inLatitude, + double inLongitude, + double inAltitude, + double * outX, + double * outY, + double * outZ); + +/* + * XPLMLocalToWorld + * + * This routine translates a local coordinate triplet back into latitude, + * longitude, and altitude. Latitude and longitude are in decimal degrees, + * and altitude is in meters MSL (mean sea level). The XYZ coordinates are in + * meters in the local OpenGL coordinate system. + * + * NOTE: world coordinates are less precise than local coordinates; you should + * try to avoid round tripping from local to world and back. + * + */ +XPLM_API void XPLMLocalToWorld( + double inX, + double inY, + double inZ, + double * outLatitude, + double * outLongitude, + double * outAltitude); + +/* + * XPLMDrawTranslucentDarkBox + * + * This routine draws a translucent dark box, partially obscuring parts of the + * screen but making text easy to read. This is the same graphics primitive + * used by X-Plane to show text files and ATC info. + * + */ +XPLM_API void XPLMDrawTranslucentDarkBox( + int inLeft, + int inTop, + int inRight, + int inBottom); + +/*************************************************************************** + * X-PLANE TEXT + ***************************************************************************/ + +/* + * XPLMFontID + * + * X-Plane features some fixed-character fonts. Each font may have its own + * metrics. + * + * WARNING: Some of these fonts are no longer supported or may have changed + * geometries. For maximum copmatibility, see the comments below. + * + * Note: X-Plane 7 supports proportional-spaced fonts. Since no measuring + * routine is available yet, the SDK will normally draw using a fixed-width + * font. You can use a dataref to enable proportional font drawing on XP7 if + * you want to. + * + */ +enum { + /* Mono-spaced font for user interface. Available in all versions of the SDK.*/ + xplmFont_Basic = 0, + +#if defined(XPLM_DEPRECATED) + /* Deprecated, do not use. */ + xplmFont_Menus = 1, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated, do not use. */ + xplmFont_Metal = 2, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated, do not use. */ + xplmFont_Led = 3, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated, do not use. */ + xplmFont_LedWide = 4, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated, do not use. */ + xplmFont_PanelHUD = 5, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated, do not use. */ + xplmFont_PanelEFIS = 6, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated, do not use. */ + xplmFont_PanelGPS = 7, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated, do not use. */ + xplmFont_RadiosGA = 8, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated, do not use. */ + xplmFont_RadiosBC = 9, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated, do not use. */ + xplmFont_RadiosHM = 10, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated, do not use. */ + xplmFont_RadiosGANarrow = 11, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated, do not use. */ + xplmFont_RadiosBCNarrow = 12, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated, do not use. */ + xplmFont_RadiosHMNarrow = 13, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated, do not use. */ + xplmFont_Timer = 14, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated, do not use. */ + xplmFont_FullRound = 15, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated, do not use. */ + xplmFont_SmallRound = 16, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + /* Deprecated, do not use. */ + xplmFont_Menus_Localized = 17, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM200) + /* Proportional UI font. */ + xplmFont_Proportional = 18, + +#endif /* XPLM200 */ + +}; +typedef int XPLMFontID; + +/* + * XPLMDrawString + * + * This routine draws a NULL termianted string in a given font. Pass in the + * lower left pixel that the character is to be drawn onto. Also pass the + * character and font ID. This function returns the x offset plus the width of + * all drawn characters. The color to draw in is specified as a pointer to an + * array of three floating point colors, representing RGB intensities from 0.0 + * to 1.0. + * + */ +XPLM_API void XPLMDrawString( + float * inColorRGB, + int inXOffset, + int inYOffset, + char * inChar, + int * inWordWrapWidth, /* Can be NULL */ + XPLMFontID inFontID); + +/* + * XPLMDrawNumber + * + * This routine draws a number similar to the digit editing fields in + * PlaneMaker and data output display in X-Plane. Pass in a color, a + * position, a floating point value, and formatting info. Specify how many + * integer and how many decimal digits to show and whether to show a sign, as + * well as a character set. This routine returns the xOffset plus width of the + * string drawn. + * + */ +XPLM_API void XPLMDrawNumber( + float * inColorRGB, + int inXOffset, + int inYOffset, + double inValue, + int inDigits, + int inDecimals, + int inShowSign, + XPLMFontID inFontID); + +/* + * XPLMGetFontDimensions + * + * This routine returns the width and height of a character in a given font. + * It also tells you if the font only supports numeric digits. Pass NULL if + * you don't need a given field. Note that for a proportional font the width + * will be an arbitrary, hopefully average width. + * + */ +XPLM_API void XPLMGetFontDimensions( + XPLMFontID inFontID, + int * outCharWidth, /* Can be NULL */ + int * outCharHeight, /* Can be NULL */ + int * outDigitsOnly); /* Can be NULL */ + +#if defined(XPLM200) +/* + * XPLMMeasureString + * + * This routine returns the width in pixels of a string using a given font. + * The string is passed as a pointer plus length (and does not need to be null + * terminated); this is used to allow for measuring substrings. The return + * value is floating point; it is possible that future font drawing may allow + * for fractional pixels. + * + */ +XPLM_API float XPLMMeasureString( + XPLMFontID inFontID, + const char * inChar, + int inNumChars); +#endif /* XPLM200 */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/XPLM/XPLMInstance.h b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/XPLM/XPLMInstance.h new file mode 100644 index 0000000..d2a8f2c --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/XPLM/XPLMInstance.h @@ -0,0 +1,136 @@ +#ifndef _XPLMInstance_h_ +#define _XPLMInstance_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPLMInstance + ***************************************************************************/ +/* + * This API provides instanced drawing of X-Plane objects (.obj files). In + * contrast to old drawing APIs, which required you to draw your own objects + * per-frame, the instancing API allows you to simply register an OBJ for + * drawing, then move or manipulate it later (as needed). + * + * This provides one tremendous benefit: it keeps all dataref operations for + * your object in one place. Because datarefs are main thread only, allowing + * dataref access anywhere is a serious performance bottleneck for the + * simulator---the whole simulator has to pause and wait for each dataref + * access. This performance penalty will only grow worse as X-Plane moves + * toward an ever more heavily multithreaded engine. + * + * The instancing API allows X-Plane to isolate all dataref manipulations for + * all plugin object drawing to one place, potentially providing huge + * performance gains. + * + * Here's how it works: + * + * When an instance is created, it provides a list of all datarefs you want to + * manipulate in for the OBJ in the future. This list of datarefs replaces the + * ad-hoc collections of dataref objects previously used by art assets. Then, + * per-frame, you can manipulate the instance by passing in a "block" of + * packed floats representing the current values of the datarefs for your + * instance. (Note that the ordering of this set of packed floats must exactly + * match the ordering of the datarefs when you created your instance.) + * + */ + +#include "XPLMDefs.h" +#include "XPLMScenery.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*************************************************************************** + * Instance Creation and Destruction + ***************************************************************************/ +/* + * Registers and unregisters instances. + * + */ + + +/* + * XPLMInstanceRef + * + * An opaque handle to an instance. + * + */ +typedef void * XPLMInstanceRef; + +/* + * XPLMCreateInstance + * + * XPLMCreateInstance creates a new instance, managed by your plug-in, and + * returns a handle to the instance. A few important requirements: + * + * * The object passed in must be fully loaded and returned from the XPLM + * before you can create your instance; you cannot pass a null obj ref, nor + * can you change the ref later. + * + * * If you use any custom datarefs in your object, they must be registered + * before the object is loaded. This is true even if their data will be + * provided via the instance dataref list. + * + * * The instance dataref array must be a valid ptr to an array of at least + * one item that is null terminated. That is, if you do not want any + * datarefs, you must passa ptr to an array with a null item. You cannot + * pass null for this. + * + */ +XPLM_API XPLMInstanceRef XPLMCreateInstance( + XPLMObjectRef obj, + const char ** datarefs); + +/* + * XPLMDestroyInstance + * + * XPLMDestroyInstance destroys and deallocates your instance; once called, + * you are still responsible for releasing the OBJ ref. + * + * Tip: you can release your OBJ ref after you call XPLMCreateInstance as long + * as you never use it again; the instance will maintain its own reference to + * the OBJ and the object OBJ be deallocated when the instance is destroyed. + * + */ +XPLM_API void XPLMDestroyInstance( + XPLMInstanceRef instance); + +/*************************************************************************** + * Instance Manipulation + ***************************************************************************/ + +/* + * XPLMInstanceSetPosition + * + * Updates both the position of the instance and all datarefs you registered + * for it. Call this from a flight loop callback or UI callback. + * + * __DO NOT__ call XPLMInstanceSetPosition from a drawing callback; the whole + * point of instancing is that you do not need any drawing callbacks. Setting + * instance data from a drawing callback may have undefined consequences, and + * the drawing callback hurts FPS unnecessarily. + * + * The memory pointed to by the data pointer must be large enough to hold one + * float for every data ref you have registered, and must contain valid + * floating point data. + * + * BUG: before X-Plane 11.50, if you have no dataref registered, you must + * still pass a valid pointer for data and not null. + * + */ +XPLM_API void XPLMInstanceSetPosition( + XPLMInstanceRef instance, + const XPLMDrawInfo_t * new_position, + const float * data); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/XPLM/XPLMMap.h b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/XPLM/XPLMMap.h new file mode 100644 index 0000000..8297471 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/XPLM/XPLMMap.h @@ -0,0 +1,628 @@ +#ifndef _XPLMMap_h_ +#define _XPLMMap_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPLMMap + ***************************************************************************/ +/* + * This API allows you to create new layers within X-Plane maps. Your layers + * can draw arbitrary OpenGL, but they conveniently also have access to + * X-Plane's built-in icon and label drawing functions. + * + * As of X-Plane 11, map drawing happens in three stages: + * + * 1. backgrounds and "fill," + * 2. icons, and + * 3. labels. + * + * Thus, all background drawing gets layered beneath all icons, which likewise + * get layered beneath all labels. Within each stage, the map obeys a + * consistent layer ordering, such that "fill" layers (layers that cover a + * large amount of map area, like the terrain and clouds) appear beneath + * "markings" layers (like airport icons). This ensures that layers with fine + * details don't get obscured by layers with larger details. + * + * The XPLM map API reflects both aspects of this draw layering: you can + * register a layer as providing either markings or fill, and X-Plane will + * draw your fill layers beneath your markings layers (regardless of + * registration order). Likewise, you are guaranteed that your layer's icons + * (added from within an icon callback) will go above your layer's OpenGL + * drawing, and your labels will go above your icons. + * + * The XPLM guarantees that all plugin-created fill layers go on top of all + * native X-Plane fill layers, and all plugin-created markings layers go on + * top of all X-Plane markings layers (with the exception of the aircraft + * icons). It also guarantees that the draw order of your own plugin's layers + * will be consistent. But, for layers created by different plugins, the only + * guarantee is that we will draw all of one plugin's layers of each type + * (fill, then markings), then all of the others'; we don't guarantee which + * plugin's fill and markings layers go on top of the other's. + * + * As of X-Plane 11, maps use true cartographic projections for their drawing, + * and different maps may use different projections. For that reason, all + * drawing calls include an opaque handle for the projection you should use to + * do the drawing. Any time you would draw at a particular latitude/longitude, + * you'll need to ask the projection to translate that position into "map + * coordinates." (Note that the projection is guaranteed not to change between + * calls to your prepare-cache hook, so if you cache your map coordinates + * ahead of time, there's no need to re-project them when you actually draw.) + * + * In addition to mapping normal latitude/longitude locations into map + * coordinates, the projection APIs also let you know the current heading for + * north. (Since X-Plane 11 maps can rotate to match the heading of the user's + * aircraft, it's not safe to assume that north is at zero degrees rotation.) + * + */ + +#include "XPLMDefs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(XPLM300) +/*************************************************************************** + * DRAWING CALLBACKS + ***************************************************************************/ +/* + * When you create a new map layer (using XPLMCreateMapLayer), you can provide + * any or all of these callbacks. They allow you to insert your own OpenGL + * drawing, text labels, and icons into the X-Plane map at the appropriate + * places, allowing your layer to behave as similarly to X-Plane's built-in + * layers as possible. + * + */ + + +/* + * XPLMMapLayerID + * + * This is an opaque handle for a plugin-created map layer. Pass it to the map + * drawing APIs from an appropriate callback to draw in the layer you created. + * + */ +typedef void * XPLMMapLayerID; + +/* + * XPLMMapProjectionID + * + * This is an opaque handle for a map projection. Pass it to the projection + * APIs to translate between map coordinates and latitude/longitudes. + * + */ +typedef void * XPLMMapProjectionID; + +/* + * XPLMMapStyle + * + * Indicates the visual style being drawn by the map. In X-Plane, the user can + * choose between a number of map types, and different map types may have use + * a different visual representation for the same elements (for instance, the + * visual style of the terrain layer changes drastically between the VFR and + * IFR layers), or certain layers may be disabled entirely in some map types + * (e.g., localizers are only visible in the IFR low-enroute style). + * + */ +enum { + xplm_MapStyle_VFR_Sectional = 0, + + xplm_MapStyle_IFR_LowEnroute = 1, + + xplm_MapStyle_IFR_HighEnroute = 2, + + +}; +typedef int XPLMMapStyle; + +/* + * XPLMMapDrawingCallback_f + * + * This is the OpenGL map drawing callback for plugin-created map layers. You + * can perform arbitrary OpenGL drawing from this callback, with one + * exception: changes to the Z-buffer are not permitted, and will result in + * map drawing errors. + * + * All drawing done from within this callback appears beneath all built-in + * X-Plane icons and labels, but above the built-in "fill" layers (layers + * providing major details, like terrain and water). Note, however, that the + * relative ordering between the drawing callbacks of different plugins is not + * guaranteed. + * + */ +typedef void (* XPLMMapDrawingCallback_f)( + XPLMMapLayerID inLayer, + const float * inMapBoundsLeftTopRightBottom, + float zoomRatio, + float mapUnitsPerUserInterfaceUnit, + XPLMMapStyle mapStyle, + XPLMMapProjectionID projection, + void * inRefcon); + +/* + * XPLMMapIconDrawingCallback_f + * + * This is the icon drawing callback that enables plugin-created map layers to + * draw icons using X-Plane's built-in icon drawing functionality. You can + * request an arbitrary number of PNG icons to be drawn via + * XPLMDrawMapIconFromSheet() from within this callback, but you may not + * perform any OpenGL drawing here. + * + * Icons enqueued by this function will appear above all OpenGL drawing + * (performed by your optional XPLMMapDrawingCallback_f), and above all + * built-in X-Plane map icons of the same layer type ("fill" or "markings," as + * determined by the XPLMMapLayerType in your XPLMCreateMapLayer_t). Note, + * however, that the relative ordering between the drawing callbacks of + * different plugins is not guaranteed. + * + */ +typedef void (* XPLMMapIconDrawingCallback_f)( + XPLMMapLayerID inLayer, + const float * inMapBoundsLeftTopRightBottom, + float zoomRatio, + float mapUnitsPerUserInterfaceUnit, + XPLMMapStyle mapStyle, + XPLMMapProjectionID projection, + void * inRefcon); + +/* + * XPLMMapLabelDrawingCallback_f + * + * This is the label drawing callback that enables plugin-created map layers + * to draw text labels using X-Plane's built-in labeling functionality. You + * can request an arbitrary number of text labels to be drawn via + * XPLMDrawMapLabel() from within this callback, but you may not perform any + * OpenGL drawing here. + * + * Labels enqueued by this function will appear above all OpenGL drawing + * (performed by your optional XPLMMapDrawingCallback_f), and above all + * built-in map icons and labels of the same layer type ("fill" or "markings," + * as determined by the XPLMMapLayerType in your XPLMCreateMapLayer_t). Note, + * however, that the relative ordering between the drawing callbacks of + * different plugins is not guaranteed. + * + */ +typedef void (* XPLMMapLabelDrawingCallback_f)( + XPLMMapLayerID inLayer, + const float * inMapBoundsLeftTopRightBottom, + float zoomRatio, + float mapUnitsPerUserInterfaceUnit, + XPLMMapStyle mapStyle, + XPLMMapProjectionID projection, + void * inRefcon); + +#endif /* XPLM300 */ +#if defined(XPLM300) +/*************************************************************************** + * LAYER MANAGEMENT CALLBACKS + ***************************************************************************/ +/* + * These are various "bookkeeping" callbacks that your map layer can receive + * (if you provide the callback in your XPLMCreateMapLayer_t). They allow you + * to manage the lifecycle of your layer, as well as cache any + * computationally-intensive preparation you might need for drawing. + * + */ + + +/* + * XPLMMapPrepareCacheCallback_f + * + * A callback used to allow you to cache whatever information your layer needs + * to draw in the current map area. + * + * This is called each time the map's total bounds change. This is typically + * triggered by new DSFs being loaded, such that X-Plane discards old, + * now-distant DSFs and pulls in new ones. At that point, the available bounds + * of the map also change to match the new DSF area. + * + * By caching just the information you need to draw in this area, your future + * draw calls can be made faster, since you'll be able to simply "splat" your + * precomputed information each frame. + * + * We guarantee that the map projection will not change between successive + * prepare cache calls, nor will any draw call give you bounds outside these + * total map bounds. So, if you cache the projected map coordinates of all the + * items you might want to draw in the total map area, you can be guaranteed + * that no draw call will be asked to do any new work. + * + */ +typedef void (* XPLMMapPrepareCacheCallback_f)( + XPLMMapLayerID inLayer, + const float * inTotalMapBoundsLeftTopRightBottom, + XPLMMapProjectionID projection, + void * inRefcon); + +/* + * XPLMMapWillBeDeletedCallback_f + * + * Called just before your map layer gets deleted. Because SDK-created map + * layers have the same lifetime as the X-Plane map that contains them, if the + * map gets unloaded from memory, your layer will too. + * + */ +typedef void (* XPLMMapWillBeDeletedCallback_f)( + XPLMMapLayerID inLayer, + void * inRefcon); + +#endif /* XPLM300 */ +#if defined(XPLM300) +/*************************************************************************** + * MAP LAYER CREATION AND DESTRUCTION + ***************************************************************************/ +/* + * Enables the creation of new map layers. Layers are created for a particular + * instance of the X-Plane map. For instance, if you want your layer to appear + * in both the normal map interface and the Instructor Operator Station (IOS), + * you would need two separate calls to XPLMCreateMapLayer(), with two + * different values for your XPLMCreateMapLayer_t::layer_name. + * + * Your layer's lifetime will be determined by the lifetime of the map it is + * created in. If the map is destroyed (on the X-Plane side), your layer will + * be too, and you'll receive a callback to your + * XPLMMapWillBeDeletedCallback_f. + * + */ + + +/* + * XPLMMapLayerType + * + * Indicates the type of map layer you are creating. Fill layers will always + * be drawn beneath markings layers. + * + */ +enum { + /* A layer that draws "fill" graphics, like weather patterns, terrain, etc. * + * Fill layers frequently cover a large portion of the visible map area. */ + xplm_MapLayer_Fill = 0, + + /* A layer that provides markings for particular map features, like NAVAIDs, * + * airports, etc. Even dense markings layers cover a small portion of the * + * total map area. */ + xplm_MapLayer_Markings = 1, + + +}; +typedef int XPLMMapLayerType; + +/* Globally unique identifier for X-Plane's Map window, used as the * + * mapToCreateLayerIn parameter in XPLMCreateMapLayer_t */ +#define XPLM_MAP_USER_INTERFACE "XPLM_MAP_USER_INTERFACE" + +/* Globally unique identifier for X-Plane's Instructor Operator Station * + * window, used as the mapToCreateLayerIn parameter in XPLMCreateMapLayer_t */ +#define XPLM_MAP_IOS "XPLM_MAP_IOS" + +/* + * XPLMCreateMapLayer_t + * + * This structure defines all of the parameters used to create a map layer + * using XPLMCreateMapLayer. The structure will be expanded in future SDK APIs + * to include more features. Always set the structSize member to the size of + * your struct in bytes! + * + * Each layer must be associated with exactly one map instance in X-Plane. + * That map, and that map alone, will call your callbacks. Likewise, when that + * map is deleted, your layer will be as well. + * + */ +typedef struct { + /* Used to inform XPLMCreateMapLayer() of the SDK version you compiled * + * against; should always be set to sizeof(XPLMCreateMapLayer_t) */ + int structSize; + /* Globally unique string identifying the map you want this layer to appear * + * in. As of XPLM300, this is limited to one of XPLM_MAP_USER_INTERFACE or * + * XPLM_MAP_IOS */ + const char * mapToCreateLayerIn; + /* The type of layer you are creating, used to determine draw order (all * + * plugin-created markings layers are drawn above all plugin-created fill * + * layers) */ + XPLMMapLayerType layerType; + /* Optional callback to inform you this layer is being deleted (due to its * + * owning map being destroyed) */ + XPLMMapWillBeDeletedCallback_f willBeDeletedCallback; + /* Optional callback you want to use to prepare your draw cache when the map * + * bounds change (set to NULL if you don't want this callback) */ + XPLMMapPrepareCacheCallback_f prepCacheCallback; + /* Optional callback you want to use for arbitrary OpenGL drawing, which goes * + * beneath all icons in the map's layering system (set to NULL if you don't * + * want this callback) */ + XPLMMapDrawingCallback_f drawCallback; + /* Optional callback you want to use for drawing icons, which go above all * + * built-in X-Plane icons (except the aircraft) in the map's layering system * + * (set to NULL if you don't want this callback) */ + XPLMMapIconDrawingCallback_f iconCallback; + /* Optional callback you want to use for drawing map labels, which go above * + * all built-in X-Plane icons and labels (except those of aircraft) in the * + * map's layering system (set to NULL if you don't want this callback) */ + XPLMMapLabelDrawingCallback_f labelCallback; + /* True if you want a checkbox to be created in the map UI to toggle this * + * layer on and off; false if the layer should simply always be enabled */ + int showUiToggle; + /* Short label to use for this layer in the user interface */ + const char * layerName; + /* A reference to arbitrary data that will be passed to your callbacks */ + void * refcon; +} XPLMCreateMapLayer_t; + +/* + * XPLMCreateMapLayer + * + * This routine creates a new map layer. You pass in an XPLMCreateMapLayer_t + * structure with all of the fields set in. You must set the structSize of + * the structure to the size of the actual structure you used. + * + * Returns NULL if the layer creation failed. This happens most frequently + * because the map you specified in your + * XPLMCreateMapLayer_t::mapToCreateLayerIn field doesn't exist (that is, if + * XPLMMapExists() returns 0 for the specified map). You can use + * XPLMRegisterMapCreationHook() to get a notification each time a new map is + * opened in X-Plane, at which time you can create layers in it. + * + */ +XPLM_API XPLMMapLayerID XPLMCreateMapLayer( + XPLMCreateMapLayer_t * inParams); + +/* + * XPLMDestroyMapLayer + * + * Destroys a map layer you created (calling your + * XPLMMapWillBeDeletedCallback_f if applicable). Returns true if a deletion + * took place. + * + */ +XPLM_API int XPLMDestroyMapLayer( + XPLMMapLayerID inLayer); + +/* + * XPLMMapCreatedCallback_f + * + * A callback to notify your plugin that a new map has been created in + * X-Plane. This is the best time to add a custom map layer using + * XPLMCreateMapLayer(). + * + * No OpenGL drawing is permitted within this callback. + * + */ +typedef void (* XPLMMapCreatedCallback_f)( + const char * mapIdentifier, + void * refcon); + +/* + * XPLMRegisterMapCreationHook + * + * Registers your callback to receive a notification each time a new map is + * constructed in X-Plane. This callback is the best time to add your custom + * map layer using XPLMCreateMapLayer(). + * + * Note that you will not be notified about any maps that already exist---you + * can use XPLMMapExists() to check for maps that were created previously. + * + */ +XPLM_API void XPLMRegisterMapCreationHook( + XPLMMapCreatedCallback_f callback, + void * refcon); + +/* + * XPLMMapExists + * + * Returns 1 if the map with the specified identifier already exists in + * X-Plane. In that case, you can safely call XPLMCreateMapLayer() specifying + * that your layer should be added to that map. + * + */ +XPLM_API int XPLMMapExists( + const char * mapIdentifier); + +#endif /* XPLM300 */ +#if defined(XPLM300) +/*************************************************************************** + * MAP DRAWING + ***************************************************************************/ +/* + * These APIs are only valid from within a map drawing callback (one of + * XPLMIconDrawingCallback_t or XPLMMapLabelDrawingCallback_f). Your drawing + * callbacks are registered when you create a new map layer as part of your + * XPLMCreateMapLayer_t. The functions here hook into X-Plane's built-in map + * drawing functionality for icons and labels, so that you get a consistent + * style with the rest of the X-Plane map. + * + * Note that the X-Plane 11 map introduces a strict ordering: layers of type + * xplm_MapLayer_Fill get drawn beneath all xplm_MapLayer_Markings layers. + * Likewise, all OpenGL drawing (performed in your layer's + * XPLMMapDrawingCallback_f) will appear beneath any icons and labels you + * draw. + * + */ + + +/* + * XPLMMapOrientation + * + * Indicates whether a map element should be match its rotation to the map + * itself, or to the user interface. For instance, the map itself may be + * rotated such that "up" matches the user's aircraft, but you may want to + * draw a text label such that it is always rotated zero degrees relative to + * the user's perspective. In that case, you would have it draw with UI + * orientation. + * + */ +enum { + /* Orient such that a 0 degree rotation matches the map's north */ + xplm_MapOrientation_Map = 0, + + /* Orient such that a 0 degree rotation is "up" relative to the user interface*/ + xplm_MapOrientation_UI = 1, + + +}; +typedef int XPLMMapOrientation; + +/* + * XPLMDrawMapIconFromSheet + * + * Enables plugin-created map layers to draw PNG icons using X-Plane's + * built-in icon drawing functionality. Only valid from within an + * XPLMIconDrawingCallback_t (but you can request an arbitrary number of icons + * to be drawn from within your callback). + * + * X-Plane will automatically manage the memory for your texture so that it + * only has to be loaded from disk once as long as you continue drawing it + * per-frame. (When you stop drawing it, the memory may purged in a "garbage + * collection" pass, require a load from disk in the future.) + * + * Instead of having X-Plane draw a full PNG, this method allows you to use UV + * coordinates to request a portion of the image to be drawn. This allows you + * to use a single texture load (of an icon sheet, for example) to draw many + * icons. Doing so is much more efficient than drawing a dozen different small + * PNGs. + * + * The UV coordinates used here treat the texture you load as being comprised + * of a number of identically sized "cells." You specify the width and height + * in cells (ds and dt, respectively), as well as the coordinates within the + * cell grid for the sub-image you'd like to draw. + * + * Note that you can use different ds and dt values in subsequent calls with + * the same texture sheet. This enables you to use icons of different sizes in + * the same sheet if you arrange them properly in the PNG. + * + * This function is only valid from within an XPLMIconDrawingCallback_t (but + * you can request an arbitrary number of icons to be drawn from within your + * callback). + * + */ +XPLM_API void XPLMDrawMapIconFromSheet( + XPLMMapLayerID layer, + const char * inPngPath, + int s, + int t, + int ds, + int dt, + float mapX, + float mapY, + XPLMMapOrientation orientation, + float rotationDegrees, + float mapWidth); + +/* + * XPLMDrawMapLabel + * + * Enables plugin-created map layers to draw text labels using X-Plane's + * built-in labeling functionality. Only valid from within an + * XPLMMapLabelDrawingCallback_f (but you can request an arbitrary number of + * text labels to be drawn from within your callback). + * + */ +XPLM_API void XPLMDrawMapLabel( + XPLMMapLayerID layer, + const char * inText, + float mapX, + float mapY, + XPLMMapOrientation orientation, + float rotationDegrees); + +#endif /* XPLM300 */ +#if defined(XPLM300) +/*************************************************************************** + * MAP PROJECTIONS + ***************************************************************************/ +/* + * As of X-Plane 11, the map draws using true cartographic projections, and + * different maps may use different projections. Thus, to draw at a particular + * latitude and longitude, you must first transform your real-world + * coordinates into map coordinates. + * + * The map projection is also responsible for giving you the current scale of + * the map. That is, the projection can tell you how many map units correspond + * to 1 meter at a given point. + * + * Finally, the map projection can give you the current rotation of the map. + * Since X-Plane 11 maps can rotate to match the heading of the aircraft, the + * map's rotation can potentially change every frame. + * + */ + + +/* + * XPLMMapProject + * + * Projects a latitude/longitude into map coordinates. This is the inverse of + * XPLMMapUnproject(). + * + * Only valid from within a map layer callback (one of + * XPLMMapPrepareCacheCallback_f, XPLMMapDrawingCallback_f, + * XPLMMapIconDrawingCallback_f, or XPLMMapLabelDrawingCallback_f.) + * + */ +XPLM_API void XPLMMapProject( + XPLMMapProjectionID projection, + double latitude, + double longitude, + float * outX, + float * outY); + +/* + * XPLMMapUnproject + * + * Transforms map coordinates back into a latitude and longitude. This is the + * inverse of XPLMMapProject(). + * + * Only valid from within a map layer callback (one of + * XPLMMapPrepareCacheCallback_f, XPLMMapDrawingCallback_f, + * XPLMMapIconDrawingCallback_f, or XPLMMapLabelDrawingCallback_f.) + * + */ +XPLM_API void XPLMMapUnproject( + XPLMMapProjectionID projection, + float mapX, + float mapY, + double * outLatitude, + double * outLongitude); + +/* + * XPLMMapScaleMeter + * + * Returns the number of map units that correspond to a distance of one meter + * at a given set of map coordinates. + * + * Only valid from within a map layer callback (one of + * XPLMMapPrepareCacheCallback_f, XPLMMapDrawingCallback_f, + * XPLMMapIconDrawingCallback_f, or XPLMMapLabelDrawingCallback_f.) + * + */ +XPLM_API float XPLMMapScaleMeter( + XPLMMapProjectionID projection, + float mapX, + float mapY); + +/* + * XPLMMapGetNorthHeading + * + * Returns the heading (in degrees clockwise) from the positive Y axis in the + * cartesian mapping coordinate system to true north at the point passed in. + * You can use it as a clockwise rotational offset to align icons and other + * 2-d drawing with true north on the map, compensating for rotations in the + * map due to projection. + * + * Only valid from within a map layer callback (one of + * XPLMMapPrepareCacheCallback_f, XPLMMapDrawingCallback_f, + * XPLMMapIconDrawingCallback_f, or XPLMMapLabelDrawingCallback_f.) + * + */ +XPLM_API float XPLMMapGetNorthHeading( + XPLMMapProjectionID projection, + float mapX, + float mapY); + +#endif /* XPLM300 */ +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/XPLM/XPLMMenus.h b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/XPLM/XPLMMenus.h new file mode 100644 index 0000000..f5802ab --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/XPLM/XPLMMenus.h @@ -0,0 +1,290 @@ +#ifndef _XPLMMenus_h_ +#define _XPLMMenus_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPLMMenus + ***************************************************************************/ +/* + * Plug-ins can create menus in the menu bar of X-Plane. This is done by + * creating a menu and then creating items. Menus are referred to by an + * opaque ID. Items are referred to by (zero-based) index number. + * + * Menus are "sandboxed" between plugins---no plugin can access the menus of + * any other plugin. Furthermore, all menu indices are relative to your + * plugin's menus only; if your plugin creates two sub-menus in the Plugins + * menu at different times, it doesn't matter how many other plugins also + * create sub-menus of Plugins in the intervening time: your sub-menus will be + * given menu indices 0 and 1. (The SDK does some work in the back-end to + * filter out menus that are irrelevant to your plugin in order to deliver + * this consistency for each plugin.) + * + * When you create a menu item, you specify how we should handle clicks on + * that menu item. You can either have the XPLM trigger a callback (the + * XPLMMenuHandler_f associated with the menu that contains the item), or you + * can simply have a command be triggered (with no associated call to your + * menu handler). The advantage of the latter method is that X-Plane will + * display any keyboard shortcuts associated with the command. (In contrast, + * there are no keyboard shortcuts associated with menu handler callbacks with + * specific parameters.) + * + * Menu text in X-Plane is UTF8; X-Plane's character set covers latin, greek + * and cyrillic characters, Katakana, as well as some Japanese symbols. Some + * APIs have a inDeprecatedAndIgnored parameter that used to select a + * character set; since X-Plane 9 all localization is done via UTF-8 only. + * + */ + +#include "XPLMDefs.h" +#include "XPLMUtilities.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*************************************************************************** + * XPLM MENUS + ***************************************************************************/ + +/* + * XPLMMenuCheck + * + * These enumerations define the various 'check' states for an X-Plane menu. + * 'checking' in X-Plane actually appears as a light which may or may not be + * lit. So there are three possible states. + * + */ +enum { + /* there is no symbol to the left of the menu item. */ + xplm_Menu_NoCheck = 0, + + /* the menu has a mark next to it that is unmarked (not lit). */ + xplm_Menu_Unchecked = 1, + + /* the menu has a mark next to it that is checked (lit). */ + xplm_Menu_Checked = 2, + + +}; +typedef int XPLMMenuCheck; + +/* + * XPLMMenuID + * + * This is a unique ID for each menu you create. + * + */ +typedef void * XPLMMenuID; + +/* + * XPLMMenuHandler_f + * + * A menu handler function takes two reference pointers, one for the menu + * (specified when the menu was created) and one for the item (specified when + * the item was created). + * + */ +typedef void (* XPLMMenuHandler_f)( + void * inMenuRef, + void * inItemRef); + +/* + * XPLMFindPluginsMenu + * + * This function returns the ID of the plug-ins menu, which is created for you + * at startup. + * + */ +XPLM_API XPLMMenuID XPLMFindPluginsMenu(void); + +#if defined(XPLM300) +/* + * XPLMFindAircraftMenu + * + * This function returns the ID of the menu for the currently-loaded aircraft, + * used for showing aircraft-specific commands. + * + * The aircraft menu is created by X-Plane at startup, but it remains hidden + * until it is populated via XPLMAppendMenuItem() or + * XPLMAppendMenuItemWithCommand(). + * + * Only plugins loaded with the user's current aircraft are allowed to access + * the aircraft menu. For all other plugins, this will return NULL, and any + * attempts to add menu items to it will fail. + * + */ +XPLM_API XPLMMenuID XPLMFindAircraftMenu(void); +#endif /* XPLM300 */ + +/* + * XPLMCreateMenu + * + * This function creates a new menu and returns its ID. It returns NULL if + * the menu cannot be created. Pass in a parent menu ID and an item index to + * create a submenu, or NULL for the parent menu to put the menu in the menu + * bar. The menu's name is only used if the menu is in the menubar. You also + * pass a handler function and a menu reference value. Pass NULL for the + * handler if you do not need callbacks from the menu (for example, if it only + * contains submenus). + * + * Important: you must pass a valid, non-empty menu title even if the menu is + * a submenu where the title is not visible. + * + */ +XPLM_API XPLMMenuID XPLMCreateMenu( + const char * inName, + XPLMMenuID inParentMenu, + int inParentItem, + XPLMMenuHandler_f inHandler, + void * inMenuRef); + +/* + * XPLMDestroyMenu + * + * This function destroys a menu that you have created. Use this to remove a + * submenu if necessary. (Normally this function will not be necessary.) + * + */ +XPLM_API void XPLMDestroyMenu( + XPLMMenuID inMenuID); + +/* + * XPLMClearAllMenuItems + * + * This function removes all menu items from a menu, allowing you to rebuild + * it. Use this function if you need to change the number of items on a menu. + * + */ +XPLM_API void XPLMClearAllMenuItems( + XPLMMenuID inMenuID); + +/* + * XPLMAppendMenuItem + * + * This routine appends a new menu item to the bottom of a menu and returns + * its index. Pass in the menu to add the item to, the items name, and a void + * * ref for this item. + * + * Returns a negative index if the append failed (due to an invalid parent + * menu argument). + * + * Note that all menu indices returned are relative to your plugin's menus + * only; if your plugin creates two sub-menus in the Plugins menu at different + * times, it doesn't matter how many other plugins also create sub-menus of + * Plugins in the intervening time: your sub-menus will be given menu indices + * 0 and 1. (The SDK does some work in the back-end to filter out menus that + * are irrelevant to your plugin in order to deliver this consistency for each + * plugin.) + * + */ +XPLM_API int XPLMAppendMenuItem( + XPLMMenuID inMenu, + const char * inItemName, + void * inItemRef, + int inDeprecatedAndIgnored); + +#if defined(XPLM300) +/* + * XPLMAppendMenuItemWithCommand + * + * Like XPLMAppendMenuItem(), but instead of the new menu item triggering the + * XPLMMenuHandler_f of the containiner menu, it will simply execute the + * command you pass in. Using a command for your menu item allows the user to + * bind a keyboard shortcut to the command and see that shortcut represented + * in the menu. + * + * Returns a negative index if the append failed (due to an invalid parent + * menu argument). + * + * Like XPLMAppendMenuItem(), all menu indices are relative to your plugin's + * menus only. + * + */ +XPLM_API int XPLMAppendMenuItemWithCommand( + XPLMMenuID inMenu, + const char * inItemName, + XPLMCommandRef inCommandToExecute); +#endif /* XPLM300 */ + +/* + * XPLMAppendMenuSeparator + * + * This routine adds a separator to the end of a menu. + * + * Returns a negative index if the append failed (due to an invalid parent + * menu argument). + * + */ +XPLM_API void XPLMAppendMenuSeparator( + XPLMMenuID inMenu); + +/* + * XPLMSetMenuItemName + * + * This routine changes the name of an existing menu item. Pass in the menu + * ID and the index of the menu item. + * + */ +XPLM_API void XPLMSetMenuItemName( + XPLMMenuID inMenu, + int inIndex, + const char * inItemName, + int inDeprecatedAndIgnored); + +/* + * XPLMCheckMenuItem + * + * Set whether a menu item is checked. Pass in the menu ID and item index. + * + */ +XPLM_API void XPLMCheckMenuItem( + XPLMMenuID inMenu, + int index, + XPLMMenuCheck inCheck); + +/* + * XPLMCheckMenuItemState + * + * This routine returns whether a menu item is checked or not. A menu item's + * check mark may be on or off, or a menu may not have an icon at all. + * + */ +XPLM_API void XPLMCheckMenuItemState( + XPLMMenuID inMenu, + int index, + XPLMMenuCheck * outCheck); + +/* + * XPLMEnableMenuItem + * + * Sets whether this menu item is enabled. Items start out enabled. + * + */ +XPLM_API void XPLMEnableMenuItem( + XPLMMenuID inMenu, + int index, + int enabled); + +#if defined(XPLM210) +/* + * XPLMRemoveMenuItem + * + * Removes one item from a menu. Note that all menu items below are moved up + * one; your plugin must track the change in index numbers. + * + */ +XPLM_API void XPLMRemoveMenuItem( + XPLMMenuID inMenu, + int inIndex); +#endif /* XPLM210 */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/XPLM/XPLMNavigation.h b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/XPLM/XPLMNavigation.h new file mode 100644 index 0000000..716caf0 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/XPLM/XPLMNavigation.h @@ -0,0 +1,362 @@ +#ifndef _XPLMNavigation_h_ +#define _XPLMNavigation_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPLMNavigation + ***************************************************************************/ +/* + * The XPLM Navigation APIs give you some access to the navigation databases + * inside X-Plane. X-Plane stores all navigation information in RAM, so by + * using these APIs you can gain access to most information without having to + * go to disk or parse the files yourself. + * + * You can also use this API to program the FMS. You must use the navigation + * APIs to find the nav-aids you want to program into the FMS, since the FMS + * is powered internally by X-Plane's navigation database. + * + */ + +#include "XPLMDefs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*************************************************************************** + * NAVIGATION DATABASE ACCESS + ***************************************************************************/ + +/* + * XPLMNavType + * + * These enumerations define the different types of navaids. They are each + * defined with a separate bit so that they may be bit-wise added together to + * form sets of nav-aid types. + * + * NOTE: xplm_Nav_LatLon is a specific lat-lon coordinate entered into the + * FMS. It will not exist in the database, and cannot be programmed into the + * FMS. Querying the FMS for navaids will return it. Use + * XPLMSetFMSEntryLatLon to set a lat/lon waypoint. + * + */ +enum { + xplm_Nav_Unknown = 0, + + xplm_Nav_Airport = 1, + + xplm_Nav_NDB = 2, + + xplm_Nav_VOR = 4, + + xplm_Nav_ILS = 8, + + xplm_Nav_Localizer = 16, + + xplm_Nav_GlideSlope = 32, + + xplm_Nav_OuterMarker = 64, + + xplm_Nav_MiddleMarker = 128, + + xplm_Nav_InnerMarker = 256, + + xplm_Nav_Fix = 512, + + xplm_Nav_DME = 1024, + + xplm_Nav_LatLon = 2048, + + +}; +typedef int XPLMNavType; + +/* + * XPLMNavRef + * + * XPLMNavRef is an iterator into the navigation database. The navigation + * database is essentially an array, but it is not necessarily densely + * populated. The only assumption you can safely make is that like-typed + * nav-aids are grouped together. + * + * Use XPLMNavRef to refer to a nav-aid. + * + * XPLM_NAV_NOT_FOUND is returned by functions that return an XPLMNavRef when + * the iterator must be invalid. + * + */ +typedef int XPLMNavRef; + +#define XPLM_NAV_NOT_FOUND -1 + +/* + * XPLMGetFirstNavAid + * + * This returns the very first navaid in the database. Use this to traverse + * the entire database. Returns XPLM_NAV_NOT_FOUND if the nav database is + * empty. + * + */ +XPLM_API XPLMNavRef XPLMGetFirstNavAid(void); + +/* + * XPLMGetNextNavAid + * + * Given a valid nav aid ref, this routine returns the next navaid. It + * returns XPLM_NAV_NOT_FOUND if the nav aid passed in was invalid or if the + * navaid passed in was the last one in the database. Use this routine to + * iterate across all like-typed navaids or the entire database. + * + */ +XPLM_API XPLMNavRef XPLMGetNextNavAid( + XPLMNavRef inNavAidRef); + +/* + * XPLMFindFirstNavAidOfType + * + * This routine returns the ref of the first navaid of the given type in the + * database or XPLM_NAV_NOT_FOUND if there are no navaids of that type in the + * database. You must pass exactly one nav aid type to this routine. + * + */ +XPLM_API XPLMNavRef XPLMFindFirstNavAidOfType( + XPLMNavType inType); + +/* + * XPLMFindLastNavAidOfType + * + * This routine returns the ref of the last navaid of the given type in the + * database or XPLM_NAV_NOT_FOUND if there are no navaids of that type in the + * database. You must pass exactly one nav aid type to this routine. + * + */ +XPLM_API XPLMNavRef XPLMFindLastNavAidOfType( + XPLMNavType inType); + +/* + * XPLMFindNavAid + * + * This routine provides a number of searching capabilities for the nav + * database. XPLMFindNavAid will search through every nav aid whose type is + * within inType (multiple types may be added together) and return any + * nav-aids found based on the following rules: + * + * * If inLat and inLon are not NULL, the navaid nearest to that lat/lon will + * be returned, otherwise the last navaid found will be returned. + * + * * If inFrequency is not NULL, then any navaids considered must match this + * frequency. Note that this will screen out radio beacons that do not have + * frequency data published (like inner markers) but not fixes and airports. + * + * * If inNameFragment is not NULL, only navaids that contain the fragment in + * their name will be returned. + * + * * If inIDFragment is not NULL, only navaids that contain the fragment in + * their IDs will be returned. + * + * This routine provides a simple way to do a number of useful searches: + * * Find the nearest navaid on this frequency. + * * Find the nearest airport. + * * Find the VOR whose ID is "KBOS". + * * Find the nearest airport whose name contains "Chicago". + * + */ +XPLM_API XPLMNavRef XPLMFindNavAid( + const char * inNameFragment, /* Can be NULL */ + const char * inIDFragment, /* Can be NULL */ + float * inLat, /* Can be NULL */ + float * inLon, /* Can be NULL */ + int * inFrequency, /* Can be NULL */ + XPLMNavType inType); + +/* + * XPLMGetNavAidInfo + * + * This routine returns information about a navaid. Any non-null field is + * filled out with information if it is available. + * + * Frequencies are in the nav.dat convention as described in the X-Plane nav + * database FAQ: NDB frequencies are exact, all others are multiplied by 100. + * + * The buffer for IDs should be at least 6 chars and the buffer for names + * should be at least 41 chars, but since these values are likely to go up, I + * recommend passing at least 32 chars for IDs and 256 chars for names when + * possible. + * + * The outReg parameter tells if the navaid is within the local "region" of + * loaded DSFs. (This information may not be particularly useful to plugins.) + * The parameter is a single byte value 1 for true or 0 for false, not a C + * string. + * + */ +XPLM_API void XPLMGetNavAidInfo( + XPLMNavRef inRef, + XPLMNavType * outType, /* Can be NULL */ + float * outLatitude, /* Can be NULL */ + float * outLongitude, /* Can be NULL */ + float * outHeight, /* Can be NULL */ + int * outFrequency, /* Can be NULL */ + float * outHeading, /* Can be NULL */ + char * outID, /* Can be NULL */ + char * outName, /* Can be NULL */ + char * outReg); /* Can be NULL */ + +/*************************************************************************** + * FLIGHT MANAGEMENT COMPUTER + ***************************************************************************/ +/* + * Note: the FMS works based on an array of entries. Indices into the array + * are zero-based. Each entry is a nav-aid plus an altitude. The FMS tracks + * the currently displayed entry and the entry that it is flying to. + * + * The FMS must be programmed with contiguous entries, so clearing an entry at + * the end shortens the effective flight plan. There is a max of 100 + * waypoints in the flight plan. + * + */ + + +/* + * XPLMCountFMSEntries + * + * This routine returns the number of entries in the FMS. + * + */ +XPLM_API int XPLMCountFMSEntries(void); + +/* + * XPLMGetDisplayedFMSEntry + * + * This routine returns the index of the entry the pilot is viewing. + * + */ +XPLM_API int XPLMGetDisplayedFMSEntry(void); + +/* + * XPLMGetDestinationFMSEntry + * + * This routine returns the index of the entry the FMS is flying to. + * + */ +XPLM_API int XPLMGetDestinationFMSEntry(void); + +/* + * XPLMSetDisplayedFMSEntry + * + * This routine changes which entry the FMS is showing to the index specified. + * + */ +XPLM_API void XPLMSetDisplayedFMSEntry( + int inIndex); + +/* + * XPLMSetDestinationFMSEntry + * + * This routine changes which entry the FMS is flying the aircraft toward. + * + */ +XPLM_API void XPLMSetDestinationFMSEntry( + int inIndex); + +/* + * XPLMGetFMSEntryInfo + * + * This routine returns information about a given FMS entry. If the entry is + * an airport or navaid, a reference to a nav entry can be returned allowing + * you to find additional information (such as a frequency, ILS heading, name, + * etc.). Note that this reference can be XPLM_NAV_NOT_FOUND until the + * information has been looked up asynchronously, so after flightplan changes, + * it might take up to a second for this field to become populated. The other + * information is available immediately. For a lat/lon entry, the lat/lon is + * returned by this routine but the navaid cannot be looked up (and the + * reference will be XPLM_NAV_NOT_FOUND). FMS name entry buffers should be at + * least 256 chars in length. + * + * WARNING: Due to a bug in X-Plane prior to 11.31, the navaid reference will + * not be set to XPLM_NAV_NOT_FOUND while no data is available, and instead + * just remain the value of the variable that you passed the pointer to. + * Therefore, always initialize the variable to XPLM_NAV_NOT_FOUND before + * passing the pointer to this function. + * + */ +XPLM_API void XPLMGetFMSEntryInfo( + int inIndex, + XPLMNavType * outType, /* Can be NULL */ + char * outID, /* Can be NULL */ + XPLMNavRef * outRef, /* Can be NULL */ + int * outAltitude, /* Can be NULL */ + float * outLat, /* Can be NULL */ + float * outLon); /* Can be NULL */ + +/* + * XPLMSetFMSEntryInfo + * + * This routine changes an entry in the FMS to have the destination navaid + * passed in and the altitude specified. Use this only for airports, fixes, + * and radio-beacon navaids. Currently of radio beacons, the FMS can only + * support VORs and NDBs. Use the routines below to clear or fly to a lat/lon. + * + */ +XPLM_API void XPLMSetFMSEntryInfo( + int inIndex, + XPLMNavRef inRef, + int inAltitude); + +/* + * XPLMSetFMSEntryLatLon + * + * This routine changes the entry in the FMS to a lat/lon entry with the given + * coordinates. + * + */ +XPLM_API void XPLMSetFMSEntryLatLon( + int inIndex, + float inLat, + float inLon, + int inAltitude); + +/* + * XPLMClearFMSEntry + * + * This routine clears the given entry, potentially shortening the flight + * plan. + * + */ +XPLM_API void XPLMClearFMSEntry( + int inIndex); + +/*************************************************************************** + * GPS RECEIVER + ***************************************************************************/ +/* + * These APIs let you read data from the GPS unit. + * + */ + +/* + * XPLMGetGPSDestinationType + * + * This routine returns the type of the currently selected GPS destination, + * one of fix, airport, VOR or NDB. + * + */ +XPLM_API XPLMNavType XPLMGetGPSDestinationType(void); + +/* + * XPLMGetGPSDestination + * + * This routine returns the current GPS destination. + * + */ +XPLM_API XPLMNavRef XPLMGetGPSDestination(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/XPLM/XPLMPlanes.h b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/XPLM/XPLMPlanes.h new file mode 100644 index 0000000..486302d --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/XPLM/XPLMPlanes.h @@ -0,0 +1,287 @@ +#ifndef _XPLMPlanes_h_ +#define _XPLMPlanes_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPLMPlanes + ***************************************************************************/ +/* + * The XPLMPlanes APIs allow you to control the various aircraft in X-Plane, + * both the user's and the sim's. + * + * *Note*: unlike almost all other APIs in the SDK, aircraft paths are _full_ + * file system paths for historical reasons. You'll need to prefix all + * relative paths with the X-Plane path as accessed via XPLMGetSystemPath. + * + */ + +#include "XPLMDefs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*************************************************************************** + * USER AIRCRAFT ACCESS + ***************************************************************************/ + +/* + * XPLMSetUsersAircraft + * + * This routine changes the user's aircraft. Note that this will reinitialize + * the user to be on the nearest airport's first runway. Pass in a full path + * (hard drive and everything including the .acf extension) to the .acf file. + * + */ +XPLM_API void XPLMSetUsersAircraft( + const char * inAircraftPath); +/* + * XPLMPlaceUserAtAirport + * + * This routine places the user at a given airport. Specify the airport by + * its X-Plane airport ID (e.g. 'KBOS'). + * + */ +XPLM_API void XPLMPlaceUserAtAirport( + const char * inAirportCode); +#if defined(XPLM300) +/* + * XPLMPlaceUserAtLocation + * + * Places the user at a specific location after performing any necessary + * scenery loads. + * + * As with in-air starts initiated from the X-Plane user interface, the + * aircraft will always start with its engines running, regardless of the + * user's preferences (i.e., regardless of what the dataref + * `sim/operation/prefs/startup_running` says). + * + */ +XPLM_API void XPLMPlaceUserAtLocation( + double latitudeDegrees, + double longitudeDegrees, + float elevationMetersMSL, + float headingDegreesTrue, + float speedMetersPerSecond); +#endif /* XPLM300 */ +/*************************************************************************** + * GLOBAL AIRCRAFT ACCESS + ***************************************************************************/ + +/* The user's aircraft is always index 0. */ +#define XPLM_USER_AIRCRAFT 0 +#if defined(XPLM_DEPRECATED) +/* + * XPLMPlaneDrawState_t + * + * This structure contains additional plane parameter info to be passed to + * draw plane. Make sure to fill in the size of the structure field with + * sizeof(XPLMDrawPlaneState_t) so that the XPLM can tell how many fields you + * knew about when compiling your plugin (since more fields may be added + * later). + * + * Most of these fields are ratios from 0 to 1 for control input. X-Plane + * calculates what the actual controls look like based on the .acf file for + * that airplane. Note for the yoke inputs, this is what the pilot of the + * plane has commanded (post artificial stability system if there were one) + * and affects aelerons, rudder, etc. It is not necessarily related to the + * actual position of the plane! + * + */ +typedef struct { + /* The size of the draw state struct. */ + int structSize; + /* A ratio from [0..1] describing how far the landing gear is extended. */ + float gearPosition; + /* Ratio of flap deployment, 0 = up, 1 = full deploy. */ + float flapRatio; + /* Ratio of spoiler deployment, 0 = none, 1 = full deploy. */ + float spoilerRatio; + /* Ratio of speed brake deployment, 0 = none, 1 = full deploy. */ + float speedBrakeRatio; + /* Ratio of slat deployment, 0 = none, 1 = full deploy. */ + float slatRatio; + /* Wing sweep ratio, 0 = forward, 1 = swept. */ + float wingSweep; + /* Thrust power, 0 = none, 1 = full fwd, -1 = full reverse. */ + float thrust; + /* Total pitch input for this plane. */ + float yokePitch; + /* Total Heading input for this plane. */ + float yokeHeading; + /* Total Roll input for this plane. */ + float yokeRoll; +} XPLMPlaneDrawState_t; +#endif /* XPLM_DEPRECATED */ +/* + * XPLMCountAircraft + * + * This function returns the number of aircraft X-Plane is capable of having, + * as well as the number of aircraft that are currently active. These numbers + * count the user's aircraft. It can also return the plugin that is currently + * controlling aircraft. In X-Plane 7, this routine reflects the number of + * aircraft the user has enabled in the rendering options window. + * + */ +XPLM_API void XPLMCountAircraft( + int * outTotalAircraft, + int * outActiveAircraft, + XPLMPluginID * outController); +/* + * XPLMGetNthAircraftModel + * + * This function returns the aircraft model for the Nth aircraft. Indices are + * zero based, with zero being the user's aircraft. The file name should be + * at least 256 chars in length; the path should be at least 512 chars in + * length. + * + */ +XPLM_API void XPLMGetNthAircraftModel( + int inIndex, + char * outFileName, + char * outPath); +/*************************************************************************** + * EXCLUSIVE AIRCRAFT ACCESS + ***************************************************************************/ +/* + * The following routines require exclusive access to the airplane APIs. Only + * one plugin may have this access at a time. + * + */ + + +/* + * XPLMPlanesAvailable_f + * + * Your airplanes available callback is called when another plugin gives up + * access to the multiplayer planes. Use this to wait for access to + * multiplayer. + * + */ +typedef void (* XPLMPlanesAvailable_f)( + void * inRefcon); + +/* + * XPLMAcquirePlanes + * + * XPLMAcquirePlanes grants your plugin exclusive access to the aircraft. It + * returns 1 if you gain access, 0 if you do not. + * + * inAircraft - pass in an array of pointers to strings specifying the planes + * you want loaded. For any plane index you do not want loaded, pass a + * 0-length string. Other strings should be full paths with the .acf + * extension. NULL terminates this array, or pass NULL if there are no planes + * you want loaded. + * + * If you pass in a callback and do not receive access to the planes your + * callback will be called when the airplanes are available. If you do receive + * airplane access, your callback will not be called. + * + */ +XPLM_API int XPLMAcquirePlanes( + char ** inAircraft, /* Can be NULL */ + XPLMPlanesAvailable_f inCallback, + void * inRefcon); + +/* + * XPLMReleasePlanes + * + * Call this function to release access to the planes. Note that if you are + * disabled, access to planes is released for you and you must reacquire it. + * + */ +XPLM_API void XPLMReleasePlanes(void); + +/* + * XPLMSetActiveAircraftCount + * + * This routine sets the number of active planes. If you pass in a number + * higher than the total number of planes availables, only the total number of + * planes available is actually used. + * + */ +XPLM_API void XPLMSetActiveAircraftCount( + int inCount); + +/* + * XPLMSetAircraftModel + * + * This routine loads an aircraft model. It may only be called if you have + * exclusive access to the airplane APIs. Pass in the path of the model with + * the .acf extension. The index is zero based, but you may not pass in 0 + * (use XPLMSetUsersAircraft to load the user's aircracft). + * + */ +XPLM_API void XPLMSetAircraftModel( + int inIndex, + const char * inAircraftPath); + +/* + * XPLMDisableAIForPlane + * + * This routine turns off X-Plane's AI for a given plane. The plane will + * continue to draw and be a real plane in X-Plane, but will not move itself. + * + */ +XPLM_API void XPLMDisableAIForPlane( + int inPlaneIndex); + +#if defined(XPLM_DEPRECATED) +/* + * XPLMDrawAircraft + * + * WARNING: Aircraft drawing via this API is deprecated and will not work in + * future versions of X-Plane. Use XPLMInstance for 3-d drawing of custom + * aircraft models. + * + * This routine draws an aircraft. It can only be called from a 3-d drawing + * callback. Pass in the position of the plane in OpenGL local coordinates + * and the orientation of the plane. A 1 for full drawing indicates that the + * whole plane must be drawn; a 0 indicates you only need the nav lights + * drawn. (This saves rendering time when planes are far away.) + * + */ +XPLM_API void XPLMDrawAircraft( + int inPlaneIndex, + float inX, + float inY, + float inZ, + float inPitch, + float inRoll, + float inYaw, + int inFullDraw, + XPLMPlaneDrawState_t * inDrawStateInfo); +#endif /* XPLM_DEPRECATED */ + +#if defined(XPLM_DEPRECATED) +/* + * XPLMReinitUsersPlane + * + * WARNING: DO NOT USE. Use XPLMPlaceUserAtAirport or + * XPLMPlaceUserAtLocation. + * + * This function recomputes the derived flight model data from the aircraft + * structure in memory. If you have used the data access layer to modify the + * aircraft structure, use this routine to resynchronize X-Plane; since + * X-Plane works at least partly from derived values, the sim will not behave + * properly until this is called. + * + * WARNING: this routine does not necessarily place the airplane at the + * airport; use XPLMSetUsersAircraft to be compatible. This routine is + * provided to do special experimentation with flight models without resetting + * flight. + * + */ +XPLM_API void XPLMReinitUsersPlane(void); +#endif /* XPLM_DEPRECATED */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/XPLM/XPLMPlugin.h b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/XPLM/XPLMPlugin.h new file mode 100644 index 0000000..be5d06c --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/XPLM/XPLMPlugin.h @@ -0,0 +1,422 @@ +#ifndef _XPLMPlugin_h_ +#define _XPLMPlugin_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPLMPlugin + ***************************************************************************/ +/* + * These APIs provide facilities to find and work with other plugins and + * manage other plugins. + * + */ + +#include "XPLMDefs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*************************************************************************** + * FINDING PLUGINS + ***************************************************************************/ +/* + * These APIs allow you to find another plugin or yourself, or iterate across + * all plugins. For example, if you wrote an FMS plugin that needed to talk + * to an autopilot plugin, you could use these APIs to locate the autopilot + * plugin. + * + */ + + +/* + * XPLMGetMyID + * + * This routine returns the plugin ID of the calling plug-in. Call this to + * get your own ID. + * + */ +XPLM_API XPLMPluginID XPLMGetMyID(void); + +/* + * XPLMCountPlugins + * + * This routine returns the total number of plug-ins that are loaded, both + * disabled and enabled. + * + */ +XPLM_API int XPLMCountPlugins(void); + +/* + * XPLMGetNthPlugin + * + * This routine returns the ID of a plug-in by index. Index is 0 based from 0 + * to XPLMCountPlugins-1, inclusive. Plugins may be returned in any arbitrary + * order. + * + */ +XPLM_API XPLMPluginID XPLMGetNthPlugin( + int inIndex); + +/* + * XPLMFindPluginByPath + * + * This routine returns the plug-in ID of the plug-in whose file exists at the + * passed in absolute file system path. XPLM_NO_PLUGIN_ID is returned if the + * path does not point to a currently loaded plug-in. + * + */ +XPLM_API XPLMPluginID XPLMFindPluginByPath( + const char * inPath); + +/* + * XPLMFindPluginBySignature + * + * This routine returns the plug-in ID of the plug-in whose signature matches + * what is passed in or XPLM_NO_PLUGIN_ID if no running plug-in has this + * signature. Signatures are the best way to identify another plug-in as they + * are independent of the file system path of a plug-in or the human-readable + * plug-in name, and should be unique for all plug-ins. Use this routine to + * locate another plugin that your plugin interoperates with + * + */ +XPLM_API XPLMPluginID XPLMFindPluginBySignature( + const char * inSignature); + +/* + * XPLMGetPluginInfo + * + * This routine returns information about a plug-in. Each parameter should be + * a pointer to a buffer of at least + * 256 characters, or NULL to not receive the information. + * + * outName - the human-readable name of the plug-in. outFilePath - the + * absolute file path to the file that contains this plug-in. outSignature - a + * unique string that identifies this plug-in. outDescription - a + * human-readable description of this plug-in. + * + */ +XPLM_API void XPLMGetPluginInfo( + XPLMPluginID inPlugin, + char * outName, /* Can be NULL */ + char * outFilePath, /* Can be NULL */ + char * outSignature, /* Can be NULL */ + char * outDescription); /* Can be NULL */ + +/*************************************************************************** + * ENABLING/DISABLING PLUG-INS + ***************************************************************************/ +/* + * These routines are used to work with plug-ins and manage them. Most + * plugins will not need to use these APIs. + * + */ + + +/* + * XPLMIsPluginEnabled + * + * Returns whether the specified plug-in is enabled for running. + * + */ +XPLM_API int XPLMIsPluginEnabled( + XPLMPluginID inPluginID); + +/* + * XPLMEnablePlugin + * + * This routine enables a plug-in if it is not already enabled. It returns 1 + * if the plugin was enabled or successfully enables itself, 0 if it does not. + * Plugins may fail to enable (for example, if resources cannot be acquired) + * by returning 0 from their XPluginEnable callback. + * + */ +XPLM_API int XPLMEnablePlugin( + XPLMPluginID inPluginID); + +/* + * XPLMDisablePlugin + * + * This routine disableds an enabled plug-in. + * + */ +XPLM_API void XPLMDisablePlugin( + XPLMPluginID inPluginID); + +/* + * XPLMReloadPlugins + * + * This routine reloads all plug-ins. Once this routine is called and you + * return from the callback you were within (e.g. a menu select callback) you + * will receive your XPluginDisable and XPluginStop callbacks and your DLL + * will be unloaded, then the start process happens as if the sim was starting + * up. + * + */ +XPLM_API void XPLMReloadPlugins(void); + +/*************************************************************************** + * INTERPLUGIN MESSAGING + ***************************************************************************/ +/* + * Plugin messages are defined as 32-bit integers. Messages below 0x00FFFFFF + * are reserved for X-Plane and the plugin SDK. + * + * Messages come with a pointer parameter; the meaning of this pointer depends + * on the message itself. In some messages, the pointer parameter contains an + * actual typed pointer to data that can be inspected in the plugin; in these + * cases the documentation will state that the parameter "points to" + * information. + * + * in other cases, the value of the pointer is actually an integral number + * stuffed into the pointer's storage. In these second cases, the pointer + * parameter needs to be cast, not dereferenced. In these caess, the + * documentation will state that the parameter "contains" a value, which will + * always be an integral type. + * + * Some messages don't use the pointer parameter - in this case your plugin + * should ignore it. + * + * Messages have two conceptual uses: notifications and commands. Commands + * are sent from one plugin to another to induce behavior; notifications are + * sent from one plugin to all others for informational purposes. It is + * important that commands and notifications not have the same values because + * this could cause a notification sent by one plugin to accidentally induce a + * command in another. + * + * By convention, plugin-defined notifications should have the high bit set + * (e.g. be greater or equal to unsigned 0x8000000) while commands should have + * this bit be cleared. + * + * The following messages are sent to your plugin by X-Plane. + * + */ + + +/* This message is sent to your plugin whenever the user's plane crashes. The * + * parameter is ignored. */ +#define XPLM_MSG_PLANE_CRASHED 101 + +/* This message is sent to your plugin whenever a new plane is loaded. The * + * parameter contains the index number of the plane being loaded; 0 indicates * + * the user's plane. */ +#define XPLM_MSG_PLANE_LOADED 102 + +/* This messages is sent whenever the user's plane is positioned at a new * + * airport. The parameter is ignored. */ +#define XPLM_MSG_AIRPORT_LOADED 103 + +/* This message is sent whenever new scenery is loaded. Use datarefs to * + * determine the new scenery files that were loaded. The parameter is ignored.*/ +#define XPLM_MSG_SCENERY_LOADED 104 + +/* This message is sent whenever the user adjusts the number of X-Plane * + * aircraft models. You must use XPLMCountPlanes to find out how many planes * + * are now available. This message will only be sent in XP7 and higher * + * because in XP6 the number of aircraft is not user-adjustable. The parameter* + * is ignored. */ +#define XPLM_MSG_AIRPLANE_COUNT_CHANGED 105 + +#if defined(XPLM200) +/* This message is sent to your plugin whenever a plane is unloaded. The * + * parameter contains the index number of the plane being unloaded; 0 * + * indicates the user's plane. The parameter is of type int, passed as the * + * value of the pointer. (That is: the parameter is an int, not a pointer to * + * an int.) */ +#define XPLM_MSG_PLANE_UNLOADED 106 +#endif /* XPLM200 */ + +#if defined(XPLM210) +/* This message is sent to your plugin right before X-Plane writes its * + * preferences file. You can use this for two purposes: to write your own * + * preferences, and to modify any datarefs to influence preferences output. * + * For example, if your plugin temporarily modifies saved preferences, you can* + * put them back to their default values here to avoid having the tweaks be * + * persisted if your plugin is not loaded on the next invocation of X-Plane. * + * The parameter is ignored. */ +#define XPLM_MSG_WILL_WRITE_PREFS 107 +#endif /* XPLM210 */ + +#if defined(XPLM210) +/* This message is sent to your plugin right after a livery is loaded for an * + * airplane. You can use this to check the new livery (via datarefs) and * + * react accordingly. The parameter contains the index number of the aircraft* + * whose livery is changing. */ +#define XPLM_MSG_LIVERY_LOADED 108 +#endif /* XPLM210 */ + +#if defined(XPLM301) +/* Sent to your plugin right before X-Plane enters virtual reality mode (at * + * which time any windows that are not positioned in VR mode will no longer be* + * visible to the user). The parameter is unused and should be ignored. */ +#define XPLM_MSG_ENTERED_VR 109 +#endif /* XPLM301 */ + +#if defined(XPLM301) +/* Sent to your plugin right before X-Plane leaves virtual reality mode (at * + * which time you may want to clean up windows that are positioned in VR * + * mode). The parameter is unused and should be ignored. */ +#define XPLM_MSG_EXITING_VR 110 +#endif /* XPLM301 */ + +#if defined(XPLM303) +/* Sent to your plugin if another plugin wants to take over AI planes. If you * + * are a synthetic traffic provider, that probably means a plugin for an * + * online network has connected and wants to supply aircraft flown by real * + * humans and you should cease to provide synthetic traffic. If however you * + * are providing online traffic from real humans, you probably don't want to * + * disconnect, in which case you just ignore this message. The sender is the * + * plugin ID of the plugin asking for control of the planes now. You can use * + * it to find out who is requesting and whether you should yield to them. * + * Synthetic traffic providers should always yield to online networks. The * + * parameter is unused and should be ignored. */ +#define XPLM_MSG_RELEASE_PLANES 111 +#endif /* XPLM303 */ + +/* + * XPLMSendMessageToPlugin + * + * This function sends a message to another plug-in or X-Plane. Pass + * XPLM_NO_PLUGIN_ID to broadcast to all plug-ins. Only enabled plug-ins with + * a message receive function receive the message. + * + */ +XPLM_API void XPLMSendMessageToPlugin( + XPLMPluginID inPlugin, + int inMessage, + void * inParam); + +#if defined(XPLM200) +/*************************************************************************** + * Plugin Features API + ***************************************************************************/ +/* + * The plugin features API allows your plugin to "sign up" for additional + * capabilities and plugin system features that are normally disabled for + * backward compatibility. This allows advanced plugins to "opt-in" to new + * behavior. + * + * Each feature is defined by a permanent string name. The feature string + * names will vary with the particular installation of X-Plane, so plugins + * should not expect a feature to be guaranteed present. + * + * XPLM_WANTS_REFLECTIONS + * ---------------------- + * + * Available in the SDK 2.0 and later for X-Plane 9, enabling this capability + * causes your plugin to receive drawing hook callbacks when X-Plane builds + * its off-screen reflection and shadow rendering passes. Plugins should + * enable this and examine the dataref sim/graphics/view/plane_render_type to + * determine whether the drawing callback is for a reflection, shadow + * calculation, or the main screen. Rendering can be simlified or omitted for + * reflections, and non-solid drawing should be skipped for shadow + * calculations. + * + * **Note**: direct drawing via draw callbacks is not recommended; use the + * XPLMInstance API to create object models instead. + * + * XPLM_USE_NATIVE_PATHS + * --------------------- + * + * available in the SDK 2.1 and later for X-Plane 10, this modifies the plugin + * system to use Unix-style paths on all operating systems. With this enabled: + * + * * OS X paths will match the native OS X Unix. + * * Windows will use forward slashes but preserve C:\ or another drive letter + * when using complete file paths. + * * Linux uses its native file system path scheme. + * + * Without this enabled: + * + * * OS X will use CFM file paths separated by a colon. + * * Windows will use back-slashes and conventional DOS paths. + * * Linux uses its native file system path scheme. + * + * All plugins should enable this feature on OS X to access the native file + * system. + * + * XPLM_USE_NATIVE_WIDGET_WINDOWS + * ------------------------------ + * + * Available in the SDK 3.0.2 SDK, this capability tells the widgets library + * to use new, modern X-Plane backed XPLMDisplay windows to anchor all widget + * trees. Without it, widgets will always use legacy windows. + * + * Plugins should enable this to allow their widget hierarchies to respond to + * the user's UI size settings and to map widget-based windwos to a VR HMD. + * + * Before enabling this, make sure any custom widget code in your plugin is + * prepared to cope with the UI coordinate system not being th same as the + * OpenGL window coordinate system. + * + */ + + +/* + * XPLMFeatureEnumerator_f + * + * You pass an XPLMFeatureEnumerator_f to get a list of all features supported + * by a given version running version of X-Plane. This routine is called once + * for each feature. + * + */ +typedef void (* XPLMFeatureEnumerator_f)( + const char * inFeature, + void * inRef); + +/* + * XPLMHasFeature + * + * This returns 1 if the given installation of X-Plane supports a feature, or + * 0 if it does not. + * + */ +XPLM_API int XPLMHasFeature( + const char * inFeature); + +/* + * XPLMIsFeatureEnabled + * + * This returns 1 if a feature is currently enabled for your plugin, or 0 if + * it is not enabled. It is an error to call this routine with an unsupported + * feature. + * + */ +XPLM_API int XPLMIsFeatureEnabled( + const char * inFeature); + +/* + * XPLMEnableFeature + * + * This routine enables or disables a feature for your plugin. This will + * change the running behavior of X-Plane and your plugin in some way, + * depending on the feature. + * + */ +XPLM_API void XPLMEnableFeature( + const char * inFeature, + int inEnable); + +/* + * XPLMEnumerateFeatures + * + * This routine calls your enumerator callback once for each feature that this + * running version of X-Plane supports. Use this routine to determine all of + * the features that X-Plane can support. + * + */ +XPLM_API void XPLMEnumerateFeatures( + XPLMFeatureEnumerator_f inEnumerator, + void * inRef); + +#endif /* XPLM200 */ +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/XPLM/XPLMProcessing.h b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/XPLM/XPLMProcessing.h new file mode 100644 index 0000000..94ef0c4 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/XPLM/XPLMProcessing.h @@ -0,0 +1,264 @@ +#ifndef _XPLMProcessing_h_ +#define _XPLMProcessing_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPLMProcessing + ***************************************************************************/ +/* + * This API allows you to get regular callbacks during the flight loop, the + * part of X-Plane where the plane's position calculates the physics of + * flight, etc. Use these APIs to accomplish periodic tasks like logging data + * and performing I/O. + * + * You can receive a callback either just before or just after the per-frame + * physics calculations happen - you can use post-FM callbacks to "patch" the + * flight model after it has run. + * + * If the user has set the number of flight model iterations per frame greater + * than one your plugin will _not_ see this; these integrations run on the + * sub-section of the flight model where iterations improve responsiveness + * (e.g. physical integration, not simple systems tracking) and are thus + * opaque to plugins. + * + * Flight loop scheduling, when scheduled by time, is scheduled by a "first + * callback after the deadline" schedule, e.g. your callbacks will always be + * slightly late to ensure that we don't run faster than your deadline. + * + * WARNING: Do NOT use these callbacks to draw! You cannot draw during flight + * loop callbacks. Use the drawing callbacks (see XPLMDisplay for more info) + * for graphics. (One exception: you can use a post-flight loop callback to + * update your own off-screen FBOs.) + * + */ + +#include "XPLMDefs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*************************************************************************** + * FLIGHT LOOP CALLBACKS + ***************************************************************************/ + +#if defined(XPLM210) +/* + * XPLMFlightLoopPhaseType + * + * You can register a flight loop callback to run either before or after the + * flight model is integrated by X-Plane. + * + */ +enum { + /* Your callback runs before X-Plane integrates the flight model. */ + xplm_FlightLoop_Phase_BeforeFlightModel = 0, + + /* Your callback runs after X-Plane integrates the flight model. */ + xplm_FlightLoop_Phase_AfterFlightModel = 1, + + +}; +typedef int XPLMFlightLoopPhaseType; +#endif /* XPLM210 */ + +#if defined(XPLM210) +/* + * XPLMFlightLoopID + * + * This is an opaque identifier for a flight loop callback. You can use this + * identifier to easily track and remove your callbacks, or to use the new + * flight loop APIs. + * + */ +typedef void * XPLMFlightLoopID; +#endif /* XPLM210 */ + +/* + * XPLMFlightLoop_f + * + * This is your flight loop callback. Each time the flight loop is iterated + * through, you receive this call at the end. + * + * Flight loop callbacks receive a number of input timing parameters. These + * input timing parameters are not particularly useful; you may need to track + * your own timing data (e.g. by reading datarefs). The input parameters are: + * + * - inElapsedSinceLastCall: the wall time since your last callback. + * - inElapsedTimeSinceLastFlightLoop: the wall time since any flight loop was + * dispatched. + * - inCounter: a monotonically increasing counter, bumped once per flight + * loop dispatch from the sim. + * - inRefcon: your own ptr constant from when you regitered yor callback. + * + * Your return value controls when you will next be called. + * + * - Return 0 to stop receiving callbacks. + * - Pass a positive number to specify how many seconds until the next + * callback. (You will be called at or after this time, not before.) + * - Pass a negative number to specify how many loops must go by until you + * are called. For example, -1.0 means call me the very next loop. + * + * Try to run your flight loop as infrequently as is practical, and suspend it + * (using return value 0) when you do not need it; lots of flight loop + * callbacks that do nothing lowers X-Plane's frame rate. + * + * Your callback will NOT be unregistered if you return 0; it will merely be + * inactive. + * + */ +typedef float (* XPLMFlightLoop_f)( + float inElapsedSinceLastCall, + float inElapsedTimeSinceLastFlightLoop, + int inCounter, + void * inRefcon); + +#if defined(XPLM210) +/* + * XPLMCreateFlightLoop_t + * + * XPLMCreateFlightLoop_t contains the parameters to create a new flight loop + * callback. The strsucture can be expanded in future SDKs - always set + * structSize to the size of your structure in bytes. + * + */ +typedef struct { + int structSize; + XPLMFlightLoopPhaseType phase; + XPLMFlightLoop_f callbackFunc; + void * refcon; +} XPLMCreateFlightLoop_t; +#endif /* XPLM210 */ + +/* + * XPLMGetElapsedTime + * + * This routine returns the elapsed time since the sim started up in decimal + * seconds. This is a wall timer; it keeps counting upward even if the sim is + * pasued. + * + * __WARNING__: XPLMGetElapsedTime is not a very good timer! It lacks + * precision in both its data type and its source. Do not attempt to use it + * for timing critical applications like network multiplayer. + * + */ +XPLM_API float XPLMGetElapsedTime(void); + +/* + * XPLMGetCycleNumber + * + * This routine returns a counter starting at zero for each sim cycle + * computed/video frame rendered. + * + */ +XPLM_API int XPLMGetCycleNumber(void); + +/* + * XPLMRegisterFlightLoopCallback + * + * This routine registers your flight loop callback. Pass in a pointer to a + * flight loop function and a refcon. inInterval defines when you will be + * called. Pass in a positive number to specify seconds from registration time + * to the next callback. Pass in a negative number to indicate when you will + * be called (e.g. pass -1 to be called at the next cylcle). Pass 0 to not be + * called; your callback will be inactive. + * + * (This legacy function only installs pre-flight-loop callbacks; use + * XPLMCreateFlightLoop for more control.) + * + */ +XPLM_API void XPLMRegisterFlightLoopCallback( + XPLMFlightLoop_f inFlightLoop, + float inInterval, + void * inRefcon); + +/* + * XPLMUnregisterFlightLoopCallback + * + * This routine unregisters your flight loop callback. Do NOT call it from + * your flight loop callback. Once your flight loop callback is unregistered, + * it will not be called again. + * + * Only use this on flight loops registered via + * XPLMRegisterFlightLoopCallback. + * + */ +XPLM_API void XPLMUnregisterFlightLoopCallback( + XPLMFlightLoop_f inFlightLoop, + void * inRefcon); + +/* + * XPLMSetFlightLoopCallbackInterval + * + * This routine sets when a callback will be called. Do NOT call it from your + * callback; use the return value of the callback to change your callback + * interval from inside your callback. + * + * inInterval is formatted the same way as in XPLMRegisterFlightLoopCallback; + * positive for seconds, negative for cycles, and 0 for deactivating the + * callback. If inRelativeToNow is 1, times are from the time of this call; + * otherwise they are from the time the callback was last called (or the time + * it was registered if it has never been called. + * + */ +XPLM_API void XPLMSetFlightLoopCallbackInterval( + XPLMFlightLoop_f inFlightLoop, + float inInterval, + int inRelativeToNow, + void * inRefcon); + +#if defined(XPLM210) +/* + * XPLMCreateFlightLoop + * + * This routine creates a flight loop callback and returns its ID. The flight + * loop callback is created using the input param struct, and is inited to be + * unscheduled. + * + */ +XPLM_API XPLMFlightLoopID XPLMCreateFlightLoop( + XPLMCreateFlightLoop_t * inParams); +#endif /* XPLM210 */ + +#if defined(XPLM210) +/* + * XPLMDestroyFlightLoop + * + * This routine destroys a flight loop callback by ID. Only call it on flight + * loops created with the newer XPLMCreateFlightLoop API. + * + */ +XPLM_API void XPLMDestroyFlightLoop( + XPLMFlightLoopID inFlightLoopID); +#endif /* XPLM210 */ + +#if defined(XPLM210) +/* + * XPLMScheduleFlightLoop + * + * This routine schedules a flight loop callback for future execution. If + * inInterval is negative, it is run in a certain number of frames based on + * the absolute value of the input. If the interval is positive, it is a + * duration in seconds. + * + * If inRelativeToNow is true, ties are interpretted relative to the time this + * routine is called; otherwise they are relative to the last call time or the + * time the flight loop was registered (if never called). + * + */ +XPLM_API void XPLMScheduleFlightLoop( + XPLMFlightLoopID inFlightLoopID, + float inInterval, + int inRelativeToNow); +#endif /* XPLM210 */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/XPLM/XPLMScenery.h b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/XPLM/XPLMScenery.h new file mode 100644 index 0000000..452bac9 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/XPLM/XPLMScenery.h @@ -0,0 +1,450 @@ +#ifndef _XPLMScenery_h_ +#define _XPLMScenery_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPLMScenery + ***************************************************************************/ +/* + * This package contains APIs to interact with X-Plane's scenery system. + * + */ + +#include "XPLMDefs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(XPLM200) +/*************************************************************************** + * Terrain Y-Testing + ***************************************************************************/ +/* + * The Y-testing API allows you to locate the physical scenery mesh. This + * would be used to place dynamic graphics on top of the ground in a plausible + * way or do physics interactions. + * + * The Y-test API works via probe objects, which are allocated by your plugin + * and used to query terrain. Probe objects exist both to capture which + * algorithm you have requested (see probe types) and also to cache query + * information. + * + * Performance Guidelines + * ---------------------- + * + * It is generally faster to use the same probe for nearby points and + * different probes for different points. Try not to allocate more than + * "hundreds" of probes at most. Share probes if you need more. Generally, + * probing operations are expensive, and should be avoided via caching when + * possible. + * + * Y testing returns a location on the terrain, a normal vectory, and a + * velocity vector. The normal vector tells you the slope of the terrain at + * that point. The velocity vector tells you if that terrain is moving (and is + * in meters/second). For example, if your Y test hits the aircraft carrier + * deck, this tells you the velocity of that point on the deck. + * + * Note: the Y-testing API is limited to probing the loaded scenery area, + * which is approximately 300x300 km in X-Plane 9. Probes outside this area + * will return the height of a 0 MSL sphere. + * + */ + + +/* + * XPLMProbeType + * + * XPLMProbeType defines the type of terrain probe - each probe has a + * different algorithm. (Only one type of probe is provided right now, but + * future APIs will expose more flexible or poewrful or useful probes. + * + */ +enum { + /* The Y probe gives you the location of the tallest physical scenery along * + * the Y axis going through the queried point. */ + xplm_ProbeY = 0, + + +}; +typedef int XPLMProbeType; + +/* + * XPLMProbeResult + * + * Probe results - possible results from a probe query. + * + */ +enum { + /* The probe hit terrain and returned valid values. */ + xplm_ProbeHitTerrain = 0, + + /* An error in the API call. Either the probe struct size is bad, or the * + * probe is invalid or the type is mismatched for the specific query call. */ + xplm_ProbeError = 1, + + /* The probe call succeeded but there is no terrain under this point (perhaps * + * it is off the side of the planet?) */ + xplm_ProbeMissed = 2, + + +}; +typedef int XPLMProbeResult; + +/* + * XPLMProbeRef + * + * An XPLMProbeRef is an opaque handle to a probe, used for querying the + * terrain. + * + */ +typedef void * XPLMProbeRef; + +/* + * XPLMProbeInfo_t + * + * XPLMProbeInfo_t contains the results of a probe call. Make sure to set + * structSize to the size of the struct before using it. + * + */ +typedef struct { + /* Size of structure in bytes - always set this before calling the XPLM. */ + int structSize; + /* Resulting X location of the terrain point we hit, in local OpenGL * + * coordinates. */ + float locationX; + /* Resulting Y location of the terrain point we hit, in local OpenGL * + * coordinates. */ + float locationY; + /* Resulting Z location of the terrain point we hit, in local OpenGL * + * coordinates. */ + float locationZ; + /* X component of the normal vector to the terrain we found. */ + float normalX; + /* Y component of the normal vector to the terrain we found. */ + float normalY; + /* Z component of the normal vector to the terrain we found. */ + float normalZ; + /* X component of the velocity vector of the terrain we found. */ + float velocityX; + /* Y component of the velocity vector of the terrain we found. */ + float velocityY; + /* Z component of the velocity vector of the terrain we found. */ + float velocityZ; + /* Tells if the surface we hit is water (otherwise it is land). */ + int is_wet; +} XPLMProbeInfo_t; + +/* + * XPLMCreateProbe + * + * Creates a new probe object of a given type and returns. + * + */ +XPLM_API XPLMProbeRef XPLMCreateProbe( + XPLMProbeType inProbeType); + +/* + * XPLMDestroyProbe + * + * Deallocates an existing probe object. + * + */ +XPLM_API void XPLMDestroyProbe( + XPLMProbeRef inProbe); + +/* + * XPLMProbeTerrainXYZ + * + * Probes the terrain. Pass in the XYZ coordinate of the probe point, a probe + * object, and an XPLMProbeInfo_t struct that has its structSize member set + * properly. Other fields are filled in if we hit terrain, and a probe result + * is returned. + * + */ +XPLM_API XPLMProbeResult XPLMProbeTerrainXYZ( + XPLMProbeRef inProbe, + float inX, + float inY, + float inZ, + XPLMProbeInfo_t * outInfo); + +#endif /* XPLM200 */ +#if defined(XPLM300) +/*************************************************************************** + * Magnetic Variation + ***************************************************************************/ +/* + * Use the magnetic variation (more properly, the "magnetic declination") API + * to find the offset of magnetic north from true north at a given latitude + * and longitude within the simulator. + * + * In the real world, the Earth's magnetic field is irregular, such that true + * north (the direction along a meridian toward the north pole) does not + * necessarily match what a magnetic compass shows as north. + * + * Using this API ensures that you present the same offsets to users as + * X-Plane's built-in instruments. + * + */ + + +/* + * XPLMGetMagneticVariation + * + * Returns X-Plane's simulated magnetic variation (declination) at the + * indication latitude and longitude. + * + */ +XPLM_API float XPLMGetMagneticVariation( + double latitude, + double longitude); + +/* + * XPLMDegTrueToDegMagnetic + * + * Converts a heading in degrees relative to true north into a value relative + * to magnetic north at the user's current location. + * + */ +XPLM_API float XPLMDegTrueToDegMagnetic( + float headingDegreesTrue); + +/* + * XPLMDegMagneticToDegTrue + * + * Converts a heading in degrees relative to magnetic north at the user's + * current location into a value relative to true north. + * + */ +XPLM_API float XPLMDegMagneticToDegTrue( + float headingDegreesMagnetic); + +#endif /* XPLM300 */ +/*************************************************************************** + * Object Drawing + ***************************************************************************/ +/* + * The object drawing routines let you load and draw X-Plane OBJ files. + * Objects are loaded by file path and managed via an opaque handle. X-Plane + * naturally reference counts objects, so it is important that you balance + * every successful call to XPLMLoadObject with a call to XPLMUnloadObject! + * + */ + + +#if defined(XPLM200) +/* + * XPLMObjectRef + * + * An XPLMObjectRef is a opaque handle to an .obj file that has been loaded + * into memory. + * + */ +typedef void * XPLMObjectRef; +#endif /* XPLM200 */ + +#if defined(XPLM200) +/* + * XPLMDrawInfo_t + * + * The XPLMDrawInfo_t structure contains positioning info for one object that + * is to be drawn. Be sure to set structSize to the size of the structure for + * future expansion. + * + */ +typedef struct { + /* Set this to the size of this structure! */ + int structSize; + /* X location of the object in local coordinates. */ + float x; + /* Y location of the object in local coordinates. */ + float y; + /* Z location of the object in local coordinates. */ + float z; + /* Pitch in degres to rotate the object, positive is up. */ + float pitch; + /* Heading in local coordinates to rotate the object, clockwise. */ + float heading; + /* Roll to rotate the object. */ + float roll; +} XPLMDrawInfo_t; +#endif /* XPLM200 */ + +#if defined(XPLM210) +/* + * XPLMObjectLoaded_f + * + * You provide this callback when loading an object asynchronously; it will be + * called once the object is loaded. Your refcon is passed back. The object + * ref passed in is the newly loaded object (ready for use) or NULL if an + * error occured. + * + * If your plugin is disabled, this callback will be delivered as soon as the + * plugin is re-enabled. If your plugin is unloaded before this callback is + * ever called, the SDK will release the object handle for you. + * + */ +typedef void (* XPLMObjectLoaded_f)( + XPLMObjectRef inObject, + void * inRefcon); +#endif /* XPLM210 */ + +#if defined(XPLM200) +/* + * XPLMLoadObject + * + * This routine loads an OBJ file and returns a handle to it. If X-Plane has + * already loaded the object, the handle to the existing object is returned. + * Do not assume you will get the same handle back twice, but do make sure to + * call unload once for every load to avoid "leaking" objects. The object will + * be purged from memory when no plugins and no scenery are using it. + * + * The path for the object must be relative to the X-System base folder. If + * the path is in the root of the X-System folder you may need to prepend ./ + * to it; loading objects in the root of the X-System folder is STRONGLY + * discouraged - your plugin should not dump art resources in the root folder! + * + * XPLMLoadObject will return NULL if the object cannot be loaded (either + * because it is not found or the file is misformatted). This routine will + * load any object that can be used in the X-Plane scenery system. + * + * It is important that the datarefs an object uses for animation already be + * loaded before you load the object. For this reason it may be necessary to + * defer object loading until the sim has fully started. + * + */ +XPLM_API XPLMObjectRef XPLMLoadObject( + const char * inPath); +#endif /* XPLM200 */ + +#if defined(XPLM210) +/* + * XPLMLoadObjectAsync + * + * This routine loads an object asynchronously; control is returned to you + * immediately while X-Plane loads the object. The sim will not stop flying + * while the object loads. For large objects, it may be several seconds before + * the load finishes. + * + * You provide a callback function that is called once the load has completed. + * Note that if the object cannot be loaded, you will not find out until the + * callback function is called with a NULL object handle. + * + * There is no way to cancel an asynchronous object load; you must wait for + * the load to complete and then release the object if it is no longer + * desired. + * + */ +XPLM_API void XPLMLoadObjectAsync( + const char * inPath, + XPLMObjectLoaded_f inCallback, + void * inRefcon); +#endif /* XPLM210 */ + +#if defined(XPLM_DEPRECATED) +/* + * XPLMDrawObjects + * + * __Deprecation Warning__: use XPLMInstancing to draw 3-d objects by creating + * instances, rather than these APIs from draw callbacks. + * + * XPLMDrawObjects draws an object from an OBJ file one or more times. You + * pass in the object and an array of XPLMDrawInfo_t structs, one for each + * place you would like the object to be drawn. + * + * X-Plane will attempt to cull the objects based on LOD and visibility, and + * will pick the appropriate LOD. + * + * Lighting is a boolean; pass 1 to show the night version of object with + * night-only lights lit up. Pass 0 to show the daytime version of the object. + * + * earth_relative controls the coordinate system. If this is 1, the rotations + * you specify are applied to the object after its coordinate system is + * transformed from local to earth-relative coordinates -- that is, an object + * with no rotations will point toward true north and the Y axis will be up + * against gravity. If this is 0, the object is drawn with your rotations from + * local coordanates -- that is, an object with no rotations is drawn pointing + * down the -Z axis and the Y axis of the object matches the local coordinate + * Y axis. + * + */ +XPLM_API void XPLMDrawObjects( + XPLMObjectRef inObject, + int inCount, + XPLMDrawInfo_t * inLocations, + int lighting, + int earth_relative); +#endif /* XPLM_DEPRECATED */ + +#if defined(XPLM200) +/* + * XPLMUnloadObject + * + * This routine marks an object as no longer being used by your plugin. + * Objects are reference counted: once no plugins are using an object, it is + * purged from memory. Make sure to call XPLMUnloadObject once for each + * successful call to XPLMLoadObject. + * + */ +XPLM_API void XPLMUnloadObject( + XPLMObjectRef inObject); +#endif /* XPLM200 */ + +#if defined(XPLM200) +/*************************************************************************** + * Library Access + ***************************************************************************/ +/* + * The library access routines allow you to locate scenery objects via the + * X-Plane library system. Right now library access is only provided for + * objects, allowing plugin-drawn objects to be extended using the library + * system. + * + */ + + +/* + * XPLMLibraryEnumerator_f + * + * An XPLMLibraryEnumerator_f is a callback you provide that is called once + * for each library element that is located. The returned paths will be + * relative to the X-System folder. + * + */ +typedef void (* XPLMLibraryEnumerator_f)( + const char * inFilePath, + void * inRef); + +/* + * XPLMLookupObjects + * + * This routine looks up a virtual path in the library system and returns all + * matching elements. You provide a callback - one virtual path may match many + * objects in the library. XPLMLookupObjects returns the number of objects + * found. + * + * The latitude and longitude parameters specify the location the object will + * be used. The library system allows for scenery packages to only provide + * objects to certain local locations. Only objects that are allowed at the + * latitude/longitude you provide will be returned. + * + */ +XPLM_API int XPLMLookupObjects( + const char * inPath, + float inLatitude, + float inLongitude, + XPLMLibraryEnumerator_f enumerator, + void * ref); + +#endif /* XPLM200 */ +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/XPLM/XPLMUtilities.h b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/XPLM/XPLMUtilities.h new file mode 100644 index 0000000..bec319e --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDKold/CHeaders/XPLM/XPLMUtilities.h @@ -0,0 +1,970 @@ +#ifndef _XPLMUtilities_h_ +#define _XPLMUtilities_h_ + +/* + * Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + * license.txt for usage. X-Plane SDK Version: 2.1.1 + * + */ + +/*************************************************************************** + * XPLMUtilities + ***************************************************************************/ + +#include "XPLMDefs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*************************************************************************** + * FILE UTILITIES + ***************************************************************************/ +/* + * The XPLMUtilities file APIs provide some basic file and path functions for + * use with X-Plane. + * + * Directory Separators + * -------------------- + * + * The XPLM has two modes it can work in: + * + * * X-Plane native paths: all paths are UTF8 strings, using the unix forward + * slash (/) as the directory separating character. In native path mode, + * you use the same path format for all three operating systems. + * + * * Legacy OS paths: the directroy separator is \ for Windows, : for OS X, + * and / for Linux; OS paths are encoded in MacRoman for OS X using legacy + * HFS conventions, use the application code page for multi-byte encoding + * on Unix using DOS path conventions, and use UTF-8 for Linux. + * + * While legacy OS paths are the default, we strongly encourage you to opt in + * to native paths using the XPLMEnableFeature API. + * + * * All OS X plugins should enable native paths all of the time; if you do + * not do this, you will have to convert all paths back from HFS to Unix + * (and deal with MacRoman) - code written using native paths and the C + * file APIs "just works" on OS X. + * + * * For Linux plugins, there is no difference between the two encodings. + * + * * Windows plugins will need to convert the UTF8 file paths to UTF16 for + * use with the "wide" APIs. While it might seem tempting to stick with + * legacy OS paths (and just use the "ANSI" Windows APIs), X-Plane is fully + * unicode-capable, and will often be installed in paths where the user's + * directories have no ACP encoding. + * + * Full and Relative Paths + * ----------------------- + * + * Some of these APIs use full paths, but others use paths relative to the + * user's X-Plane installation. This is documented on a per-API basis. + * + */ + + +#if defined(XPLM200) +/* + * XPLMDataFileType + * + * These enums define types of data files you can load or unload using the + * SDK. + * + */ +enum { + /* A situation (.sit) file, which starts off a flight in a given * + * configuration. */ + xplm_DataFile_Situation = 1, + + /* A situation movie (.smo) file, which replays a past flight. */ + xplm_DataFile_ReplayMovie = 2, + + +}; +typedef int XPLMDataFileType; +#endif /* XPLM200 */ + +/* + * XPLMGetSystemPath + * + * This function returns the full path to the X-System folder. Note that this + * is a directory path, so it ends in a trailing : or /. + * + * The buffer you pass should be at least 512 characters long. The path is + * returned using the current native or OS path conventions. + * + */ +XPLM_API void XPLMGetSystemPath( + char * outSystemPath); + +/* + * XPLMGetPrefsPath + * + * This routine returns a full path to a file that is within X-Plane's + * preferences directory. (You should remove the file name back to the last + * directory separator to get the preferences directory using + * XPLMExtractFileAndPath.) + * + * The buffer you pass should be at least 512 characters long. The path is + * returned using the current native or OS path conventions. + * + */ +XPLM_API void XPLMGetPrefsPath( + char * outPrefsPath); + +/* + * XPLMGetDirectorySeparator + * + * This routine returns a string with one char and a null terminator that is + * the directory separator for the current platform. This allows you to write + * code that concatinates directory paths without having to #ifdef for + * platform. The character returned will reflect the current file path mode. + * + */ +XPLM_API const char * XPLMGetDirectorySeparator(void); + +/* + * XPLMExtractFileAndPath + * + * Given a full path to a file, this routine separates the path from the file. + * If the path is a partial directory (e.g. ends in : or \) the trailing + * directory separator is removed. This routine works in-place; a pointer to + * the file part of the buffer is returned; the original buffer still starts + * with the path and is null terminated with no trailing separator. + * + */ +XPLM_API char * XPLMExtractFileAndPath( + char * inFullPath); + +/* + * XPLMGetDirectoryContents + * + * This routine returns a list of files in a directory (specified by a full + * path, no trailing : or \). The output is returned as a list of NULL + * terminated strings. An index array (if specified) is filled with pointers + * into the strings. The last file is indicated by a zero-length string (and + * NULL in the indices). This routine will return 1 if you had capacity for + * all files or 0 if you did not. You can also skip a given number of files. + * + * * inDirectoryPath - a null terminated C string containing the full path to + * the directory with no trailing directory char. + * + * * inFirstReturn - the zero-based index of the first file in the directory + * to return. (Usually zero to fetch all in one pass.) + * + * * outFileNames - a buffer to receive a series of sequential null + * terminated C-string file names. A zero-length C string will be appended + * to the very end. + * + * * inFileNameBufSize - the size of the file name buffer in bytes. + * + * * outIndices - a pointer to an array of character pointers that will + * become an index into the directory. The last file will be followed by a + * NULL value. Pass NULL if you do not want indexing information. + * + * * inIndexCount - the max size of the index in entries. + * + * * outTotalFiles - if not NULL, this is filled in with the number of files + * in the directory. + * + * * outReturnedFiles - if not NULL, the number of files returned by this + * iteration. + * + * Return value: 1 if all info could be returned, 0 if there was a buffer + * overrun. + * + * WARNING: Before X-Plane 7 this routine did not properly iterate through + * directories. If X-Plane + * 6 compatibility is needed, use your own code to iterate directories. + * + */ +XPLM_API int XPLMGetDirectoryContents( + const char * inDirectoryPath, + int inFirstReturn, + char * outFileNames, + int inFileNameBufSize, + char ** outIndices, /* Can be NULL */ + int inIndexCount, + int * outTotalFiles, /* Can be NULL */ + int * outReturnedFiles); /* Can be NULL */ + +#if defined(XPLM200) +/* + * XPLMLoadDataFile + * + * Loads a data file of a given type. Paths must be relative to the X-System + * folder. To clear the replay, pass a NULL file name (this is only valid with + * replay movies, not sit files). + * + */ +XPLM_API int XPLMLoadDataFile( + XPLMDataFileType inFileType, + const char * inFilePath); /* Can be NULL */ +#endif /* XPLM200 */ + +#if defined(XPLM200) +/* + * XPLMSaveDataFile + * + * Saves the current situation or replay; paths are relative to the X-System + * folder. + * + */ +XPLM_API int XPLMSaveDataFile( + XPLMDataFileType inFileType, + const char * inFilePath); +#endif /* XPLM200 */ + +/*************************************************************************** + * X-PLANE MISC + ***************************************************************************/ + +/* + * XPLMHostApplicationID + * + * While the plug-in SDK is only accessible to plugins running inside X-Plane, + * the original authors considered extending the API to other applications + * that shared basic infrastructure with X-Plane. These enumerations are + * hold-overs from that original roadmap; all values other than X-Plane are + * deprecated. Your plugin should never need this enumeration. + * + */ +enum { + xplm_Host_Unknown = 0, + + xplm_Host_XPlane = 1, + +#if defined(XPLM_DEPRECATED) + xplm_Host_PlaneMaker = 2, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + xplm_Host_WorldMaker = 3, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + xplm_Host_Briefer = 4, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + xplm_Host_PartMaker = 5, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + xplm_Host_YoungsMod = 6, + +#endif /* XPLM_DEPRECATED */ +#if defined(XPLM_DEPRECATED) + xplm_Host_XAuto = 7, + +#endif /* XPLM_DEPRECATED */ + +}; +typedef int XPLMHostApplicationID; + +/* + * XPLMLanguageCode + * + * These enums define what language the sim is running in. These enumerations + * do not imply that the sim can or does run in all of these languages; they + * simply provide a known encoding in the event that a given sim version is + * localized to a certain language. + * + */ +enum { + xplm_Language_Unknown = 0, + + xplm_Language_English = 1, + + xplm_Language_French = 2, + + xplm_Language_German = 3, + + xplm_Language_Italian = 4, + + xplm_Language_Spanish = 5, + + xplm_Language_Korean = 6, + +#if defined(XPLM200) + xplm_Language_Russian = 7, + +#endif /* XPLM200 */ +#if defined(XPLM200) + xplm_Language_Greek = 8, + +#endif /* XPLM200 */ +#if defined(XPLM200) + xplm_Language_Japanese = 9, + +#endif /* XPLM200 */ +#if defined(XPLM300) + xplm_Language_Chinese = 10, + +#endif /* XPLM300 */ + +}; +typedef int XPLMLanguageCode; + +#if defined(XPLM200) +/* + * XPLMError_f + * + * An XPLM error callback is a function that you provide to receive debugging + * information from the plugin SDK. See XPLMSetErrorCallback for more + * information. NOTE: for the sake of debugging, your error callback will be + * called even if your plugin is not enabled, allowing you to receive debug + * info in your XPluginStart and XPluginStop callbacks. To avoid causing logic + * errors in the management code, do not call any other plugin routines from + * your error callback - it is only meant for catching errors in the + * debugging. + * + */ +typedef void (* XPLMError_f)( + const char * inMessage); +#endif /* XPLM200 */ + +#if defined(XPLM_DEPRECATED) +/* + * XPLMInitialized + * + * Deprecated: This function returns 1 if X-Plane has properly initialized the + * plug-in system. If this routine returns 0, many XPLM functions will not + * work. + * + * NOTE: because plugins are always called from within the XPLM, there is no + * need to check for initialization; it will always return 1. This routine is + * deprecated - you do not need to check it before continuing within your + * plugin. + * + */ +XPLM_API int XPLMInitialized(void); +#endif /* XPLM_DEPRECATED */ + +/* + * XPLMGetVersions + * + * This routine returns the revision of both X-Plane and the XPLM DLL. All + * versions are three-digit decimal numbers (e.g. 606 for version 6.06 of + * X-Plane); the current revision of the XPLM is 200 (2.00). This routine also + * returns the host ID of the app running us. + * + * The most common use of this routine is to special-case around X-Plane + * version-specific behavior. + * + */ +XPLM_API void XPLMGetVersions( + int * outXPlaneVersion, + int * outXPLMVersion, + XPLMHostApplicationID * outHostID); + +/* + * XPLMGetLanguage + * + * This routine returns the langauge the sim is running in. + * + */ +XPLM_API XPLMLanguageCode XPLMGetLanguage(void); + +#if defined(XPLM200) +/* + * XPLMFindSymbol + * + * This routine will attempt to find the symbol passed in the inString + * parameter. If the symbol is found a pointer the function is returned, + * othewise the function will return NULL. + * + * You can use XPLMFindSymbol to utilize newer SDK API features without + * requiring newer versions of the SDK (and X-Plane) as your minimum X-Plane + * version as follows: + * + * * Define the XPLMnnn macro to the minimum required XPLM version you will + * ship with (e.g. XPLM210 for X-Plane 10 compatibility). + * + * * Use XPLMGetVersions and XPLMFindSymbol to detect that the host sim is + * new enough to use new functions and resolve function pointers. + * + * * Conditionally use the new functions if and only if XPLMFindSymbol only + * returns a non- NULL pointer. + * + * Warning: you should always check the XPLM API version as well as the + * results of XPLMFindSymbol to determine if funtionality is safe to use. + * + * To use functionality via XPLMFindSymbol you will need to copy your own + * definitions of the X-Plane API prototypes and cast the returned pointer to + * the correct type. + * + */ +XPLM_API void * XPLMFindSymbol( + const char * inString); +#endif /* XPLM200 */ + +#if defined(XPLM200) +/* + * XPLMSetErrorCallback + * + * XPLMSetErrorCallback installs an error-reporting callback for your plugin. + * Normally the plugin system performs minimum diagnostics to maximize + * performance. When you install an error callback, you will receive calls due + * to certain plugin errors, such as passing bad parameters or incorrect data. + * + * Important: the error callback determines *programming* errors, e.g. bad API + * parameters. Every error that is returned by the error callback represents a + * mistake in your plugin that you should fix. Error callbacks are not used to + * report expected run-time problems (e.g. disk I/O errors). + * + * The intention is for you to install the error callback during debug + * sections and put a break-point inside your callback. This will cause you to + * break into the debugger from within the SDK at the point in your plugin + * where you made an illegal call. + * + * Installing an error callback may activate error checking code that would + * not normally run, and this may adversely affect performance, so do not + * leave error callbacks installed in shipping plugins. Since the only useful + * response to an error is to change code, error callbacks are not useful "in + * the field". + * + */ +XPLM_API void XPLMSetErrorCallback( + XPLMError_f inCallback); +#endif /* XPLM200 */ + +/* + * XPLMDebugString + * + * This routine outputs a C-style string to the Log.txt file. The file is + * immediately flushed so you will not lose data. (This does cause a + * performance penalty.) + * + * Please do *not* leave routine diagnostic logging enabled in your shipping + * plugin. The X-Plane Log file is shared by X-Plane and every plugin in the + * system, and plugins that (when functioning normally) print verbose log + * output make it difficult for developers to find error conditions from other + * parts of the system. + * + */ +XPLM_API void XPLMDebugString( + const char * inString); + +/* + * XPLMSpeakString + * + * This function displays the string in a translucent overlay over the current + * display and also speaks the string if text-to-speech is enabled. The string + * is spoken asynchronously, this function returns immediately. This function + * may not speak or print depending on user preferences. + * + */ +XPLM_API void XPLMSpeakString( + const char * inString); + +/* + * XPLMGetVirtualKeyDescription + * + * Given a virtual key code (as defined in XPLMDefs.h) this routine returns a + * human-readable string describing the character. This routine is provided + * for showing users what keyboard mappings they have set up. The string may + * read 'unknown' or be a blank or NULL string if the virtual key is unknown. + * + */ +XPLM_API const char * XPLMGetVirtualKeyDescription( + char inVirtualKey); + +/* + * XPLMReloadScenery + * + * XPLMReloadScenery reloads the current set of scenery. You can use this + * function in two typical ways: simply call it to reload the scenery, picking + * up any new installed scenery, .env files, etc. from disk. Or, change the + * lat/ref and lon/ref data refs and then call this function to shift the + * scenery environment. This routine is equivalent to picking "reload + * scenery" from the developer menu. + * + */ +XPLM_API void XPLMReloadScenery(void); + +#if defined(XPLM200) +/*************************************************************************** + * X-PLANE COMMAND MANAGEMENT + ***************************************************************************/ +/* + * The command management APIs let plugins interact with the command-system in + * X-Plane, the abstraction behind keyboard presses and joystick buttons. This + * API lets you create new commands and modify the behavior (or get + * notification) of existing ones. + * + * X-Plane Command Phases + * ---------------------- + * + * X-Plane commands are not instantaneous; they operate over a duration. + * (Think of a joystick button press - you can press, hold down, and then + * release the joystick button; X-Plane commands model this entire process.) + * + * An X-Plane command consists of three phases: a beginning, continuous + * repetition, and an ending. The command may be repeated zero times in its + * duration, followed by one command ending. Command begin and end messges are + * balanced, but a command may be bound to more than one event source (e.g. a + * keyboard key and a joystick button), in which case you may receive a second + * begin during before any end). + * + * When you issue commands in the plugin system, you *must* balance every call + * to XPLMCommandBegin with a call to XPLMCommandEnd with the same command + * reference. + * + * Command Behavior Modification + * ----------------------------- + * + * You can register a callback to handle a command either before or after + * X-Plane does; if you receive the command before X-Plane you have the option + * to either let X-Plane handle the command or hide the command from X-Plane. + * This lets plugins both augment commands and replace them. + * + * If you register for an existing command, be sure that you are *consistent* + * in letting X-Plane handle or not handle the command; you are responsible + * for passing a *balanced* number of begin and end messages to X-Plane. (E.g. + * it is not legal to pass all the begin messages to X-Plane but hide all the + * end messages). + * + */ + + +/* + * XPLMCommandPhase + * + * The phases of a command. + * + */ +enum { + /* The command is being started. */ + xplm_CommandBegin = 0, + + /* The command is continuing to execute. */ + xplm_CommandContinue = 1, + + /* The command has ended. */ + xplm_CommandEnd = 2, + + +}; +typedef int XPLMCommandPhase; + +/* + * XPLMCommandRef + * + * A command ref is an opaque identifier for an X-Plane command. Command + * references stay the same for the life of your plugin but not between + * executions of X-Plane. Command refs are used to execute commands, create + * commands, and create callbacks for particular commands. + * + * Note that a command is not "owned" by a particular plugin. Since many + * plugins may participate in a command's execution, the command does not go + * away if the plugin that created it is unloaded. + * + */ +typedef void * XPLMCommandRef; + +/* + * XPLMCommandCallback_f + * + * A command callback is a function in your plugin that is called when a + * command is pressed. Your callback receives the command reference for the + * particular command, the phase of the command that is executing, and a + * reference pointer that you specify when registering the callback. + * + * Your command handler should return 1 to let processing of the command + * continue to other plugins and X-Plane, or 0 to halt processing, potentially + * bypassing X-Plane code. + * + */ +typedef int (* XPLMCommandCallback_f)( + XPLMCommandRef inCommand, + XPLMCommandPhase inPhase, + void * inRefcon); + +/* + * XPLMFindCommand + * + * XPLMFindCommand looks up a command by name, and returns its command + * reference or NULL if the command does not exist. + * + */ +XPLM_API XPLMCommandRef XPLMFindCommand( + const char * inName); + +/* + * XPLMCommandBegin + * + * XPLMCommandBegin starts the execution of a command, specified by its + * command reference. The command is "held down" until XPLMCommandEnd is + * called. You must balance each XPLMCommandBegin call with an XPLMCommandEnd + * call. + * + */ +XPLM_API void XPLMCommandBegin( + XPLMCommandRef inCommand); + +/* + * XPLMCommandEnd + * + * XPLMCommandEnd ends the execution of a given command that was started with + * XPLMCommandBegin. You must not issue XPLMCommandEnd for a command you did + * not begin. + * + */ +XPLM_API void XPLMCommandEnd( + XPLMCommandRef inCommand); + +/* + * XPLMCommandOnce + * + * This executes a given command momentarily, that is, the command begins and + * ends immediately. This is the equivalent of calling XPLMCommandBegin() and + * XPLMCommandEnd() back ot back. + * + */ +XPLM_API void XPLMCommandOnce( + XPLMCommandRef inCommand); + +/* + * XPLMCreateCommand + * + * XPLMCreateCommand creates a new command for a given string. If the command + * already exists, the existing command reference is returned. The description + * may appear in user interface contexts, such as the joystick configuration + * screen. + * + */ +XPLM_API XPLMCommandRef XPLMCreateCommand( + const char * inName, + const char * inDescription); + +/* + * XPLMRegisterCommandHandler + * + * XPLMRegisterCommandHandler registers a callback to be called when a command + * is executed. You provide a callback with a reference pointer. + * + * If inBefore is true, your command handler callback will be executed before + * X-Plane executes the command, and returning 0 from your callback will + * disable X-Plane's processing of the command. If inBefore is false, your + * callback will run after X-Plane. (You can register a single callback both + * before and after a command.) + * + */ +XPLM_API void XPLMRegisterCommandHandler( + XPLMCommandRef inComand, + XPLMCommandCallback_f inHandler, + int inBefore, + void * inRefcon); + +/* + * XPLMUnregisterCommandHandler + * + * XPLMUnregisterCommandHandler removes a command callback registered with + * XPLMRegisterCommandHandler. + * + */ +XPLM_API void XPLMUnregisterCommandHandler( + XPLMCommandRef inComand, + XPLMCommandCallback_f inHandler, + int inBefore, + void * inRefcon); + +#endif /* XPLM200 */ +#if defined(XPLM_DEPRECATED) +/*************************************************************************** + * X-PLANE USER INTERACTION + ***************************************************************************/ +/* + * WARNING: The legacy user interaction API is deprecated; while it was the + * only way to run commands in X-Plane 6,7 and 8, it is obsolete, and was + * replaced by the command system API in X-Plane 9. You should not use this + * API; replace any of the calls below with XPLMCommand invocations based on + * persistent command strings. The documentation that follows is for historic + * reference only. + * + * The legacy user interaction APIs let you simulate commands the user can do + * with a joystick, keyboard etc. Note that it is generally safer for future + * compatibility to use one of these commands than to manipulate the + * underlying sim data. + * + */ + + +/* + * XPLMCommandKeyID + * + * These enums represent all the keystrokes available within X-Plane. They can + * be sent to X-Plane directly. For example, you can reverse thrust using + * these enumerations. + * + */ +enum { + xplm_key_pause=0, + xplm_key_revthrust, + xplm_key_jettison, + xplm_key_brakesreg, + xplm_key_brakesmax, + xplm_key_gear, + xplm_key_timedn, + xplm_key_timeup, + xplm_key_fadec, + xplm_key_otto_dis, + xplm_key_otto_atr, + xplm_key_otto_asi, + xplm_key_otto_hdg, + xplm_key_otto_gps, + xplm_key_otto_lev, + xplm_key_otto_hnav, + xplm_key_otto_alt, + xplm_key_otto_vvi, + xplm_key_otto_vnav, + xplm_key_otto_nav1, + xplm_key_otto_nav2, + xplm_key_targ_dn, + xplm_key_targ_up, + xplm_key_hdgdn, + xplm_key_hdgup, + xplm_key_barodn, + xplm_key_baroup, + xplm_key_obs1dn, + xplm_key_obs1up, + xplm_key_obs2dn, + xplm_key_obs2up, + xplm_key_com1_1, + xplm_key_com1_2, + xplm_key_com1_3, + xplm_key_com1_4, + xplm_key_nav1_1, + xplm_key_nav1_2, + xplm_key_nav1_3, + xplm_key_nav1_4, + xplm_key_com2_1, + xplm_key_com2_2, + xplm_key_com2_3, + xplm_key_com2_4, + xplm_key_nav2_1, + xplm_key_nav2_2, + xplm_key_nav2_3, + xplm_key_nav2_4, + xplm_key_adf_1, + xplm_key_adf_2, + xplm_key_adf_3, + xplm_key_adf_4, + xplm_key_adf_5, + xplm_key_adf_6, + xplm_key_transpon_1, + xplm_key_transpon_2, + xplm_key_transpon_3, + xplm_key_transpon_4, + xplm_key_transpon_5, + xplm_key_transpon_6, + xplm_key_transpon_7, + xplm_key_transpon_8, + xplm_key_flapsup, + xplm_key_flapsdn, + xplm_key_cheatoff, + xplm_key_cheaton, + xplm_key_sbrkoff, + xplm_key_sbrkon, + xplm_key_ailtrimL, + xplm_key_ailtrimR, + xplm_key_rudtrimL, + xplm_key_rudtrimR, + xplm_key_elvtrimD, + xplm_key_elvtrimU, + xplm_key_forward, + xplm_key_down, + xplm_key_left, + xplm_key_right, + xplm_key_back, + xplm_key_tower, + xplm_key_runway, + xplm_key_chase, + xplm_key_free1, + xplm_key_free2, + xplm_key_spot, + xplm_key_fullscrn1, + xplm_key_fullscrn2, + xplm_key_tanspan, + xplm_key_smoke, + xplm_key_map, + xplm_key_zoomin, + xplm_key_zoomout, + xplm_key_cycledump, + xplm_key_replay, + xplm_key_tranID, + xplm_key_max +}; +typedef int XPLMCommandKeyID; + +/* + * XPLMCommandButtonID + * + * These are enumerations for all of the things you can do with a joystick + * button in X-Plane. They currently match the buttons menu in the equipment + * setup dialog, but these enums will be stable even if they change in + * X-Plane. + * + */ +enum { + xplm_joy_nothing=0, + xplm_joy_start_all, + xplm_joy_start_0, + xplm_joy_start_1, + xplm_joy_start_2, + xplm_joy_start_3, + xplm_joy_start_4, + xplm_joy_start_5, + xplm_joy_start_6, + xplm_joy_start_7, + xplm_joy_throt_up, + xplm_joy_throt_dn, + xplm_joy_prop_up, + xplm_joy_prop_dn, + xplm_joy_mixt_up, + xplm_joy_mixt_dn, + xplm_joy_carb_tog, + xplm_joy_carb_on, + xplm_joy_carb_off, + xplm_joy_trev, + xplm_joy_trm_up, + xplm_joy_trm_dn, + xplm_joy_rot_trm_up, + xplm_joy_rot_trm_dn, + xplm_joy_rud_lft, + xplm_joy_rud_cntr, + xplm_joy_rud_rgt, + xplm_joy_ail_lft, + xplm_joy_ail_cntr, + xplm_joy_ail_rgt, + xplm_joy_B_rud_lft, + xplm_joy_B_rud_rgt, + xplm_joy_look_up, + xplm_joy_look_dn, + xplm_joy_look_lft, + xplm_joy_look_rgt, + xplm_joy_glance_l, + xplm_joy_glance_r, + xplm_joy_v_fnh, + xplm_joy_v_fwh, + xplm_joy_v_tra, + xplm_joy_v_twr, + xplm_joy_v_run, + xplm_joy_v_cha, + xplm_joy_v_fr1, + xplm_joy_v_fr2, + xplm_joy_v_spo, + xplm_joy_flapsup, + xplm_joy_flapsdn, + xplm_joy_vctswpfwd, + xplm_joy_vctswpaft, + xplm_joy_gear_tog, + xplm_joy_gear_up, + xplm_joy_gear_down, + xplm_joy_lft_brake, + xplm_joy_rgt_brake, + xplm_joy_brakesREG, + xplm_joy_brakesMAX, + xplm_joy_speedbrake, + xplm_joy_ott_dis, + xplm_joy_ott_atr, + xplm_joy_ott_asi, + xplm_joy_ott_hdg, + xplm_joy_ott_alt, + xplm_joy_ott_vvi, + xplm_joy_tim_start, + xplm_joy_tim_reset, + xplm_joy_ecam_up, + xplm_joy_ecam_dn, + xplm_joy_fadec, + xplm_joy_yaw_damp, + xplm_joy_art_stab, + xplm_joy_chute, + xplm_joy_JATO, + xplm_joy_arrest, + xplm_joy_jettison, + xplm_joy_fuel_dump, + xplm_joy_puffsmoke, + xplm_joy_prerotate, + xplm_joy_UL_prerot, + xplm_joy_UL_collec, + xplm_joy_TOGA, + xplm_joy_shutdown, + xplm_joy_con_atc, + xplm_joy_fail_now, + xplm_joy_pause, + xplm_joy_rock_up, + xplm_joy_rock_dn, + xplm_joy_rock_lft, + xplm_joy_rock_rgt, + xplm_joy_rock_for, + xplm_joy_rock_aft, + xplm_joy_idle_hilo, + xplm_joy_lanlights, + xplm_joy_max +}; +typedef int XPLMCommandButtonID; + +/* + * XPLMSimulateKeyPress + * + * This function simulates a key being pressed for X-Plane. The keystroke goes + * directly to X-Plane; it is never sent to any plug-ins. However, since this + * is a raw key stroke it may be mapped by the keys file or enter text into a + * field. + * + * Deprecated: use XPLMCommandOnce + * + */ +XPLM_API void XPLMSimulateKeyPress( + int inKeyType, + int inKey); + +/* + * XPLMCommandKeyStroke + * + * This routine simulates a command-key stroke. However, the keys are done by + * function, not by actual letter, so this function works even if the user has + * remapped their keyboard. Examples of things you might do with this include + * pausing the simulator. + * + * Deprecated: use XPLMCommandOnce + * + */ +XPLM_API void XPLMCommandKeyStroke( + XPLMCommandKeyID inKey); + +/* + * XPLMCommandButtonPress + * + * This function simulates any of the actions that might be taken by pressing + * a joystick button. However, this lets you call the command directly rather + * than have to know which button is mapped where. Important: you must release + * each button you press. The APIs are separate so that you can 'hold down' a + * button for a fixed amount of time. + * + * Deprecated: use XPLMCommandBegin. + * + */ +XPLM_API void XPLMCommandButtonPress( + XPLMCommandButtonID inButton); + +/* + * XPLMCommandButtonRelease + * + * This function simulates any of the actions that might be taken by pressing + * a joystick button. See XPLMCommandButtonPress. + * + * Deprecated: use XPLMCommandEnd. + * + */ +XPLM_API void XPLMCommandButtonRelease( + XPLMCommandButtonID inButton); + +#endif /* XPLM_DEPRECATED */ +#ifdef __cplusplus +} +#endif + +#endif diff --git a/XPLPro_Plugin_Source/SDK/SDKold/Delphi/Widgets/XPStandardWidgets.pas b/XPLPro_Plugin_Source/SDK/SDKold/Delphi/Widgets/XPStandardWidgets.pas new file mode 100644 index 0000000..d77f383 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDKold/Delphi/Widgets/XPStandardWidgets.pas @@ -0,0 +1,470 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPStandardWidgets; +INTERFACE +{ + ## THEORY OF OPERATION + + The standard widgets are widgets built into the widgets library. While you + can gain access to the widget function that drives them, you generally use + them by calling XPCreateWidget and then listening for special messages, + etc. + + The standard widgets often send mesages to themselves when the user + performs an event; these messages are sent up the widget hierarchy until + they are handled. So you can add a widget proc directly to a push button + (for example) to intercept the message when it is clicked, or you can put + one widget proc on a window for all of the push buttons in the window. Most + of these messages contain the original widget ID as a parameter so you can + know which widget is messaging no matter who it is sent to. +} + +USES + XPWidgetDefs; + {$A4} +{___________________________________________________________________________ + * MAIN WINDOW + ___________________________________________________________________________} +{ + The main window widget class provides a "window" as the user knows it. + These windows are dragable and can be selected. Use them to create floating + windows and non-modal dialogs. +} + + +CONST + xpWidgetClass_MainWindow = 1; + + { + Main Window Type Values + + These type values are used to control the appearance of a main window. + } + { The standard main window; pin stripes on XP7, metal frame on XP 6. } + xpMainWindowStyle_MainWindow = 0 +; + { A translucent dark gray window, like the one ATC messages appear in. } + xpMainWindowStyle_Translucent = 1 +; + + { + Main Window Properties + } + { This property specifies the type of window. Set to one of the main window } + { types above. } + xpProperty_MainWindowType = 1100 +; + { This property specifies whether the main window has close boxes in its } + { corners. } + xpProperty_MainWindowHasCloseBoxes = 1200 +; + + { + MainWindow Messages + } + { This message is sent when the close buttons are pressed for your window. } + xpMessage_CloseButtonPushed = 1200 +; + +{___________________________________________________________________________ + * SUB WINDOW + ___________________________________________________________________________} +{ + X-Plane dialogs are divided into separate areas; the sub window widgets + allow you to make these areas. Create one main window and place several + subwindows inside it. Then place your controls inside the subwindows. +} + + +CONST + xpWidgetClass_SubWindow = 2; + + { + SubWindow Type Values + + These values control the appearance of the subwindow. + } + { A panel that sits inside a main window. } + xpSubWindowStyle_SubWindow = 0 +; + { A screen that sits inside a panel for showing text information. } + xpSubWindowStyle_Screen = 2 +; + { A list view for scrolling lists. } + xpSubWindowStyle_ListView = 3 +; + + { + SubWindow Properties + } + { This property specifies the type of window. Set to one of the subwindow } + { types above. } + xpProperty_SubWindowType = 1200 +; + +{___________________________________________________________________________ + * BUTTON + ___________________________________________________________________________} +{ + The button class provides a number of different button styles and + behaviors, including push buttons, radio buttons, check boxes, etc. The + button label appears on or next to the button depending on the button's + appearance, or type. + + The button's behavior is a separate property that dictates who it hilights + and what kinds of messages it sends. Since behavior and type are different, + you can do strange things like make check boxes that act as push buttons or + push buttons with radio button behavior. + + In X-Plane 6 there were no check box graphics. The result is the following + behavior: in X-Plane + 6 all check box and radio buttons are round (radio-button style) buttons; + in X-Plane 7 they are all square (check-box style) buttons. In a future + version of X-Plane, the xpButtonBehavior enums will provide the correct + graphic (check box or radio button) giving the expected result. +} + + +CONST + xpWidgetClass_Button = 3; + + { + Button Types + + These define the visual appearance of buttons but not how they respond to + the mouse. + } + { This is a standard push button, like an 'OK' or 'Cancel' button in a dialog} + { box. } + xpPushButton = 0 +; + { A check box or radio button. Use this and the button behaviors below to } + { get the desired behavior. } + xpRadioButton = 1 +; + { A window close box. } + xpWindowCloseBox = 3 +; + { A small down arrow. } + xpLittleDownArrow = 5 +; + { A small up arrow. } + xpLittleUpArrow = 6 +; + + { + Button Behavior Values + + These define how the button responds to mouse clicks. + } + { Standard push button behavior. The button hilites while the mouse is } + { clicked over it and unhilites when the mouse is moved outside of it or } + { released. If the mouse is released over the button, the } + { xpMsg_PushButtonPressed message is sent. } + xpButtonBehaviorPushButton = 0 +; + { Check box behavior. The button immediately toggles its value when the mouse} + { is clicked and sends out a xpMsg_ButtonStateChanged message. } + xpButtonBehaviorCheckBox = 1 +; + { Radio button behavior. The button immediately sets its state to one and } + { sends out a xpMsg_ButtonStateChanged message if it was not already set to } + { one. You must turn off other radio buttons in a group in your code. } + xpButtonBehaviorRadioButton = 2 +; + + { + Button Properties + } + { This property sets the visual type of button. Use one of the button types } + { above. } + xpProperty_ButtonType = 1300 +; + { This property sets the button's behavior. Use one of the button behaviors } + { above. } + xpProperty_ButtonBehavior = 1301 +; + { This property tells whether a check box or radio button is "checked" or } + { not. Not used for push buttons. } + xpProperty_ButtonState = 1302 +; + + { + Button Messages + + These messages are sent by the button to itself and then up the widget + chain when the button is clicked. (You may intercept them by providing a + widget handler for the button itself or by providing a handler in a parent + widget.) + } + { This message is sent when the user completes a click and release in a } + { button with push button behavior. Parameter one of the message is the } + { widget ID of the button. This message is dispatched up the widget } + { hierarchy. } + xpMsg_PushButtonPressed = 1300 +; + { This message is sent when a button is clicked that has radio button or } + { check box behavior and its value changes. (Note that if the value changes } + { by setting a property you do not receive this message!) Parameter one is } + { the widget ID of the button, parameter 2 is the new state value, either } + { zero or one. This message is dispatched up the widget hierarchy. } + xpMsg_ButtonStateChanged = 1301 +; + +{___________________________________________________________________________ + * TEXT FIELD + ___________________________________________________________________________} +{ + The text field widget provides an editable text field including mouse + selection and keyboard navigation. The contents of the text field are its + descriptor. (The descriptor changes as the user types.) + + The text field can have a number of types, that effect the visual layout of + the text field. The text field sends messages to itself so you may control + its behavior. + + If you need to filter keystrokes, add a new handler and intercept the key + press message. Since key presses are passed by pointer, you can modify the + keystroke and pass it through to the text field widget. + + WARNING: in X-Plane before 7.10 (including 6.70) null characters could + crash X-Plane. To prevent this, wrap this object with a filter function + (more instructions can be found on the SDK website). +} + + +CONST + xpWidgetClass_TextField = 4; + + { + Text Field Type Values + + These control the look of the text field. + } + { A field for text entry. } + xpTextEntryField = 0 +; + { A transparent text field. The user can type and the text is drawn, but no } + { background is drawn. You can draw your own background by adding a widget } + { handler and prehandling the draw message. } + xpTextTransparent = 3 +; + { A translucent edit field, dark gray. } + xpTextTranslucent = 4 +; + + { + Text Field Properties + } + { This is the character position the selection starts at, zero based. If it } + { is the same as the end insertion point, the insertion point is not a } + { selection. } + xpProperty_EditFieldSelStart = 1400 +; + { This is the character position of the end of the selection. } + xpProperty_EditFieldSelEnd = 1401 +; + { This is the character position a drag was started at if the user is } + { dragging to select text, or -1 if a drag is not in progress. } + xpProperty_EditFieldSelDragStart = 1402 +; + { This is the type of text field to display, from the above list. } + xpProperty_TextFieldType = 1403 +; + { Set this property to 1 to password protect the field. Characters will be } + { drawn as *s even though the descriptor will contain plain-text. } + xpProperty_PasswordMode = 1404 +; + { The max number of characters you can enter, if limited. Zero means } + { unlimited. } + xpProperty_MaxCharacters = 1405 +; + { The first visible character on the left. This effectively scrolls the text} + { field. } + xpProperty_ScrollPosition = 1406 +; + { The font to draw the field's text with. (An XPLMFontID.) } + xpProperty_Font = 1407 +; + { This is the active side of the insert selection. (Internal) } + xpProperty_ActiveEditSide = 1408 +; + + { + Text Field Messages + } + { The text field sends this message to itself when its text changes. It sends} + { the message up the call chain; param1 is the text field's widget ID. } + xpMsg_TextFieldChanged = 1400 +; + +{___________________________________________________________________________ + * SCROLL BAR + ___________________________________________________________________________} +{ + A standard scroll bar or slider control. The scroll bar has a minimum, + maximum and current value that is updated when the user drags it. The + scroll bar sends continuous messages as it is dragged. +} + + +CONST + xpWidgetClass_ScrollBar = 5; + + { + Scroll Bar Type Values + + This defines how the scroll bar looks. + } + { A standard X-Plane scroll bar (with arrows on the ends). } + xpScrollBarTypeScrollBar = 0 +; + { A slider, no arrows. } + xpScrollBarTypeSlider = 1 +; + + { + Scroll Bar Properties + } + { The current position of the thumb (in between the min and max, inclusive) } + xpProperty_ScrollBarSliderPosition = 1500 +; + { The value the scroll bar has when the thumb is in the lowest position. } + xpProperty_ScrollBarMin = 1501 +; + { The value the scroll bar has when the thumb is in the highest position. } + xpProperty_ScrollBarMax = 1502 +; + { How many units to move the scroll bar when clicking next to the thumb. The } + { scroll bar always moves one unit when the arrows are clicked. } + xpProperty_ScrollBarPageAmount = 1503 +; + { The type of scrollbar from the enums above. } + xpProperty_ScrollBarType = 1504 +; + { Used internally. } + xpProperty_ScrollBarSlop = 1505 +; + + { + Scroll Bar Messages + } + { The scroll bar sends this message when the slider position changes. It } + { sends the message up the call chain; param1 is the Scroll Bar widget ID. } + xpMsg_ScrollBarSliderPositionChanged = 1500 +; + +{___________________________________________________________________________ + * CAPTION + ___________________________________________________________________________} +{ + A caption is a simple widget that shows its descriptor as a string, useful + for labeling parts of a window. It always shows its descriptor as its + string and is otherwise transparent. +} + + +CONST + xpWidgetClass_Caption = 6; + + { + Caption Properties + } + { This property specifies whether the caption is lit; use lit captions } + { against screens. } + xpProperty_CaptionLit = 1600 +; + +{___________________________________________________________________________ + * GENERAL GRAPHICS + ___________________________________________________________________________} +{ + The general graphics widget can show one of many icons available from + X-Plane. +} + + +CONST + xpWidgetClass_GeneralGraphics = 7; + + { + General Graphics Types Values + + These define the icon for the general graphics. + } + xpShip = 4 +; + xpILSGlideScope = 5 +; + xpMarkerLeft = 6 +; + xp_Airport = 7 +; + xpNDB = 8 +; + xpVOR = 9 +; + xpRadioTower = 10 +; + xpAircraftCarrier = 11 +; + xpFire = 12 +; + xpMarkerRight = 13 +; + xpCustomObject = 14 +; + xpCoolingTower = 15 +; + xpSmokeStack = 16 +; + xpBuilding = 17 +; + xpPowerLine = 18 +; + xpVORWithCompassRose = 19 +; + xpOilPlatform = 21 +; + xpOilPlatformSmall = 22 +; + xpWayPoint = 23 +; + + { + General Graphics Properties + } + { This property controls the type of icon that is drawn. } + xpProperty_GeneralGraphicsType = 1700 +; + +{___________________________________________________________________________ + * PROGRESS INDICATOR + ___________________________________________________________________________} +{ + This widget implements a progress indicator as seen when X-Plane starts up. +} + +CONST + xpWidgetClass_Progress = 8; + + { + Progress Indicator Properties + } + { This is the current value of the progress indicator. } + xpProperty_ProgressPosition = 1800 +; + { This is the minimum value, equivalent to 0% filled. } + xpProperty_ProgressMin = 1801 +; + { This is the maximum value, equivalent to 100% filled. } + xpProperty_ProgressMax = 1802 +; + + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/SDKold/Delphi/Widgets/XPUIGraphics.pas b/XPLPro_Plugin_Source/SDK/SDKold/Delphi/Widgets/XPUIGraphics.pas new file mode 100644 index 0000000..65e0636 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDKold/Delphi/Widgets/XPUIGraphics.pas @@ -0,0 +1,342 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPUIGraphics; +INTERFACE + +USES + XPWidgetDefs; + {$A4} +{___________________________________________________________________________ + * UI GRAPHICS + ___________________________________________________________________________} + + { + XPWindowStyle + + There are a few built-in window styles in X-Plane that you can use. + + Note that X-Plane 6 does not offer real shadow-compositing; you must make + sure to put a window on top of another window of the right style to the + shadows work, etc. This applies to elements with insets and shadows. The + rules are: + + Sub windows must go on top of main windows, and screens and list views on + top of subwindows. Only help and main windows can be over the main screen. + + With X-Plane 7 any window or element may be placed over any other element. + + Some windows are scaled by stretching, some by repeating. The drawing + routines know which scaling method to use. The list view cannot be rescaled + in X-Plane 6 because it has both a repeating pattern and a gradient in one + element. All other elements can be rescaled. + } +TYPE + XPWindowStyle = ( + { An LCD screen that shows help. } + xpWindow_Help = 0 + + { A dialog box window. } + ,xpWindow_MainWindow = 1 + + { A panel or frame within a dialog box window. } + ,xpWindow_SubWindow = 2 + + { An LCD screen within a panel to hold text displays. } + ,xpWindow_Screen = 4 + + { A list view within a panel for scrolling file names, etc. } + ,xpWindow_ListView = 5 + + ); + PXPWindowStyle = ^XPWindowStyle; + + { + XPDrawWindow + + This routine draws a window of the given dimensions at the given offset on + the virtual screen in a given style. The window is automatically scaled as + appropriate using a bitmap scaling technique (scaling or repeating) as + appropriate to the style. + } + PROCEDURE XPDrawWindow( + inX1 : Integer; + inY1 : Integer; + inX2 : Integer; + inY2 : Integer; + inStyle : XPWindowStyle); + cdecl; external XPWIDGETS.DLL; + + { + XPGetWindowDefaultDimensions + + This routine returns the default dimensions for a window. Output is either + a minimum or fixed value depending on whether the window is scalable. + } + PROCEDURE XPGetWindowDefaultDimensions( + inStyle : XPWindowStyle; + outWidth : PInteger; { Can be nil } + outHeight : PInteger); { Can be nil } + cdecl; external XPWIDGETS.DLL; + + { + XPElementStyle + + Elements are individually drawable UI things like push buttons, etc. The + style defines what kind of element you are drawing. Elements can be + stretched in one or two dimensions (depending on the element). Some + elements can be lit. + + In X-Plane 6 some elements must be drawn over metal. Some are scalable and + some are not. Any element can be drawn anywhere in X-Plane 7. + + Scalable Axis Required Background + } +TYPE + XPElementStyle = ( + { x metal } + xpElement_TextField = 6 + + { none metal } + ,xpElement_CheckBox = 9 + + { none metal } + ,xpElement_CheckBoxLit = 10 + + { none window header } + ,xpElement_WindowCloseBox = 14 + + { none window header } + ,xpElement_WindowCloseBoxPressed = 15 + + { x metal } + ,xpElement_PushButton = 16 + + { x metal } + ,xpElement_PushButtonLit = 17 + + { none any } + ,xpElement_OilPlatform = 24 + + { none any } + ,xpElement_OilPlatformSmall = 25 + + { none any } + ,xpElement_Ship = 26 + + { none any } + ,xpElement_ILSGlideScope = 27 + + { none any } + ,xpElement_MarkerLeft = 28 + + { none any } + ,xpElement_Airport = 29 + + { none any } + ,xpElement_Waypoint = 30 + + { none any } + ,xpElement_NDB = 31 + + { none any } + ,xpElement_VOR = 32 + + { none any } + ,xpElement_RadioTower = 33 + + { none any } + ,xpElement_AircraftCarrier = 34 + + { none any } + ,xpElement_Fire = 35 + + { none any } + ,xpElement_MarkerRight = 36 + + { none any } + ,xpElement_CustomObject = 37 + + { none any } + ,xpElement_CoolingTower = 38 + + { none any } + ,xpElement_SmokeStack = 39 + + { none any } + ,xpElement_Building = 40 + + { none any } + ,xpElement_PowerLine = 41 + + { none metal } + ,xpElement_CopyButtons = 45 + + { none metal } + ,xpElement_CopyButtonsWithEditingGrid = 46 + + { x, y metal } + ,xpElement_EditingGrid = 47 + + { THIS CAN PROBABLY BE REMOVED } + ,xpElement_ScrollBar = 48 + + { none any } + ,xpElement_VORWithCompassRose = 49 + + { none metal } + ,xpElement_Zoomer = 51 + + { x, y metal } + ,xpElement_TextFieldMiddle = 52 + + { none metal } + ,xpElement_LittleDownArrow = 53 + + { none metal } + ,xpElement_LittleUpArrow = 54 + + { none metal } + ,xpElement_WindowDragBar = 61 + + { none metal } + ,xpElement_WindowDragBarSmooth = 62 + + ); + PXPElementStyle = ^XPElementStyle; + + { + XPDrawElement + + XPDrawElement draws a given element at an offset on the virtual screen in + set dimensions. + *Even* if the element is not scalable, it will be scaled if the width and + height do not match the preferred dimensions; it'll just look ugly. Pass + inLit to see the lit version of the element; if the element cannot be lit + this is ignored. + } + PROCEDURE XPDrawElement( + inX1 : Integer; + inY1 : Integer; + inX2 : Integer; + inY2 : Integer; + inStyle : XPElementStyle; + inLit : Integer); + cdecl; external XPWIDGETS.DLL; + + { + XPGetElementDefaultDimensions + + This routine returns the recommended or minimum dimensions of a given UI + element. outCanBeLit tells whether the element has both a lit and unlit + state. Pass `NULL` to not receive any of these parameters. + } + PROCEDURE XPGetElementDefaultDimensions( + inStyle : XPElementStyle; + outWidth : PInteger; { Can be nil } + outHeight : PInteger; { Can be nil } + outCanBeLit : PInteger); { Can be nil } + cdecl; external XPWIDGETS.DLL; + + { + XPTrackStyle + + A track is a UI element that displays a value vertically or horizontally. + X-Plane has three kinds of tracks: scroll bars, sliders, and progress bars. + Tracks can be displayed either horizontally or vertically; tracks will + choose their own layout based on the larger dimension of their dimensions + (e.g. they know if they are tall or wide). Sliders may be lit or unlit + (showing the user manipulating them). + + - ScrollBar: this is a standard scroll bar with arrows and a thumb to drag. + - Slider: this is a simple track with a ball in the middle that can be + slid. + - Progress: this is a progress indicator showing how a long task is going. + } +TYPE + XPTrackStyle = ( + { not over metal can be lit can be rotated } + xpTrack_ScrollBar = 0 + + { over metal can be lit can be rotated } + ,xpTrack_Slider = 1 + + { over metal cannot be lit cannot be rotated } + ,xpTrack_Progress = 2 + + ); + PXPTrackStyle = ^XPTrackStyle; + + { + XPDrawTrack + + This routine draws a track. You pass in the track dimensions and size; the + track picks the optimal orientation for these dimensions. Pass in the + track's minimum current and maximum values; the indicator will be + positioned appropriately. You can also specify whether the track is lit or + not. + } + PROCEDURE XPDrawTrack( + inX1 : Integer; + inY1 : Integer; + inX2 : Integer; + inY2 : Integer; + inMin : Integer; + inMax : Integer; + inValue : Integer; + inTrackStyle : XPTrackStyle; + inLit : Integer); + cdecl; external XPWIDGETS.DLL; + + { + XPGetTrackDefaultDimensions + + This routine returns a track's default smaller dimension; all tracks are + scalable in the larger dimension. It also returns whether a track can be + lit. + } + PROCEDURE XPGetTrackDefaultDimensions( + inStyle : XPTrackStyle; + outWidth : PInteger; + outCanBeLit : PInteger); + cdecl; external XPWIDGETS.DLL; + + { + XPGetTrackMetrics + + This routine returns the metrics of a track. If you want to write UI code + to manipulate a track, this routine helps you know where the mouse + locations are. For most other elements, the rectangle the element is drawn + in is enough information. However, the scrollbar drawing routine does some + automatic placement; this routine lets you know where things ended up. You + pass almost everything you would pass to the draw routine. You get out the + orientation, and other useful stuff. + + Besides orientation, you get five dimensions for the five parts of a + scrollbar, which are the down button, down area (area before the thumb), + the thumb, and the up area and button. For horizontal scrollers, the left + button decreases; for vertical scrollers, the top button decreases. + } + PROCEDURE XPGetTrackMetrics( + inX1 : Integer; + inY1 : Integer; + inX2 : Integer; + inY2 : Integer; + inMin : Integer; + inMax : Integer; + inValue : Integer; + inTrackStyle : XPTrackStyle; + outIsVertical : PInteger; + outDownBtnSize : PInteger; + outDownPageSize : PInteger; + outThumbSize : PInteger; + outUpPageSize : PInteger; + outUpBtnSize : PInteger); + cdecl; external XPWIDGETS.DLL; + + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/SDKold/Delphi/Widgets/XPWidgetDefs.pas b/XPLPro_Plugin_Source/SDK/SDKold/Delphi/Widgets/XPWidgetDefs.pas new file mode 100644 index 0000000..1cc342f --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDKold/Delphi/Widgets/XPWidgetDefs.pas @@ -0,0 +1,427 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPWidgetDefs; +INTERFACE + +USES + XPLMDefs; + {$A4} +{___________________________________________________________________________ + * WIDGET DEFINITIONS + ___________________________________________________________________________} +{ + A widget is a call-back driven screen entity like a push-button, window, + text entry field, etc. + + Use the widget API to create widgets of various classes. You can nest them + into trees of widgets to create complex user interfaces. +} + + +TYPE + { + XPWidgetID + + A Widget ID is an opaque unique non-zero handle identifying your widget. + Use 0 to specify "no widget". This type is defined as wide enough to hold a + pointer. You receive a widget ID when you create a new widget and then use + that widget ID to further refer to the widget. + } + XPWidgetID = pointer; + PXPWidgetID = ^XPWidgetID; + + { + XPWidgetPropertyID + + Properties are values attached to instances of your widgets. A property is + identified by a 32-bit ID and its value is the width of a pointer. + + Each widget instance may have a property or not have it. When you set a + property on a widget for the first time, the property is added to the + widget; it then stays there for the life of the widget. + + Some property IDs are predefined by the widget package; you can make up + your own property IDs as well. + } + XPWidgetPropertyID = ( + { A window's refcon is an opaque value used by client code to find other data} + { based on it. } + xpProperty_Refcon = 0 + + { These properties are used by the utlities to implement dragging. } + ,xpProperty_Dragging = 1 + + ,xpProperty_DragXOff = 2 + + ,xpProperty_DragYOff = 3 + + { Is the widget hilited? (For widgets that support this kind of thing.) } + ,xpProperty_Hilited = 4 + + { Is there a C++ object attached to this widget? } + ,xpProperty_Object = 5 + + { If this property is 1, the widget package will use OpenGL to restrict } + { drawing to the Wiget's exposed rectangle. } + ,xpProperty_Clip = 6 + + { Is this widget enabled (for those that have a disabled state too)? } + ,xpProperty_Enabled = 7 + + { NOTE: Property IDs 1 - 999 are reserved for the widgets library. } + { } + { NOTE: Property IDs 1000 - 9999 are allocated to the standard widget classes} + { provided with the library. } + { } + { Properties 1000 - 1099 are for widget class 0, 1100 - 1199 for widget class} + { 1, etc. } + ,xpProperty_UserStart = 10000 + + ); + PXPWidgetPropertyID = ^XPWidgetPropertyID; + + { + XPMouseState_t + + When the mouse is clicked or dragged, a pointer to this structure is passed + to your widget function. + } + XPMouseState_t = RECORD + x : Integer; + y : Integer; + { Mouse Button number, left = 0 (right button not yet supported. } + button : Integer; +{$IFDEF XPLM200} + { Scroll wheel delta (button in this case would be the wheel axis number). } + delta : Integer; +{$ENDIF XPLM200} + END; + PXPMouseState_t = ^XPMouseState_t; + + { + XPKeyState_t + + When a key is pressed, a pointer to this struct is passed to your widget + function. + } + XPKeyState_t = RECORD + { The ASCII key that was pressed. WARNING: this may be 0 for some non-ASCII } + { key sequences. } + key : XPLMChar; + { The flags. Make sure to check this if you only want key-downs! } + flags : XPLMKeyFlags; + { The virtual key code for the key } + vkey : XPLMChar; + END; + PXPKeyState_t = ^XPKeyState_t; + + { + XPWidgetGeometryChange_t + + This structure contains the deltas for your widget's geometry when it + changes. + } + XPWidgetGeometryChange_t = RECORD + dx : Integer; + { +Y = the widget moved up } + dy : Integer; + dwidth : Integer; + dheight : Integer; + END; + PXPWidgetGeometryChange_t = ^XPWidgetGeometryChange_t; + + { + XPDispatchMode + + The dispatching modes describe how the widgets library sends out messages. + Currently there are three modes: + } + XPDispatchMode = ( + { The message will only be sent to the target widget. } + xpMode_Direct = 0 + + { The message is sent to the target widget, then up the chain of parents } + { until the message is handled or a parentless widget is reached. } + ,xpMode_UpChain = 1 + + { The message is sent to the target widget and then all of its children } + { recursively depth-first. } + ,xpMode_Recursive = 2 + + { The message is snet just to the target, but goes to every callback, even if} + { it is handled. } + ,xpMode_DirectAllCallbacks = 3 + + { The message is only sent to the very first handler even if it is not } + { accepted. (This is really only useful for some internal widget library } + { functions.) } + ,xpMode_Once = 4 + + ); + PXPDispatchMode = ^XPDispatchMode; + + { + XPWidgetClass + + Widget classes define predefined widget types. A widget class basically + specifies from a library the widget function to be used for the widget. + Most widgets can be made right from classes. + } + XPWidgetClass = Integer; + PXPWidgetClass = ^XPWidgetClass; + +CONST + { An unspecified widget class. Other widget classes are in } + { XPStandardWidgets.h } + xpWidgetClass_None = 0; + +{___________________________________________________________________________ + * WIDGET MESSAGES + ___________________________________________________________________________} + + { + XPWidgetMessage + + Widgets receive 32-bit messages indicating what action is to be taken or + notifications of events. The list of messages may be expanded. + } +TYPE + XPWidgetMessage = ( + { No message, should not be sent. } + xpMsg_None = 0 + + { The create message is sent once per widget that is created with your widget} + { function and once for any widget that has your widget function attached. } + { } + { Dispatching: Direct } + { } + { Param 1: 1 if you are being added as a subclass, 0 if the widget is first } + { being created. } + ,xpMsg_Create = 1 + + { The destroy message is sent once for each message that is destroyed that } + { has your widget function. } + { } + { Dispatching: Direct for all } + { } + { Param 1: 1 if being deleted by a recursive delete to the parent, 0 for } + { explicit deletion. } + ,xpMsg_Destroy = 2 + + { The paint message is sent to your widget to draw itself. The paint message } + { is the bare-bones message; in response you must draw yourself, draw your } + { children, set up clipping and culling, check for visibility, etc. If you } + { don't want to do all of this, ignore the paint message and a draw message } + { (see below) will be sent to you. } + { } + { Dispatching: Direct } + ,xpMsg_Paint = 3 + + { The draw message is sent to your widget when it is time to draw yourself. } + { OpenGL will be set up to draw in 2-d global screen coordinates, but you } + { should use the XPLM to set up OpenGL state. } + { } + { Dispatching: Direct } + ,xpMsg_Draw = 4 + + { The key press message is sent once per key that is pressed. The first } + { parameter is the type of key code (integer or char) and the second is the } + { code itself. By handling this event, you consume the key stroke. } + { } + { Handling this message 'consumes' the keystroke; not handling it passes it } + { to your parent widget. } + { } + { Dispatching: Up Chain } + { } + { Param 1: A pointer to an XPKeyState_t structure with the keystroke. } + ,xpMsg_KeyPress = 5 + + { Keyboard focus is being given to you. By handling this message you accept } + { keyboard focus. The first parameter will be one if a child of yours gave up} + { focus to you, 0 if someone set focus on you explicitly. } + { } + { Handling this message accepts focus; not handling refuses focus. } + { } + { Dispatching: direct } + { } + { Param 1: 1 if you are gaining focus because your child is giving it up, 0 } + { if someone is explicitly giving you focus. } + ,xpMsg_KeyTakeFocus = 6 + + { Keyboard focus is being taken away from you. The first parameter will be } + { one if you are losing focus because another widget is taking it, or 0 if } + { someone called the API to make you lose focus explicitly. } + { } + { Dispatching: Direct } + { } + { Param 1: 1 if focus is being taken by another widget, 0 if code requested } + { to remove focus. } + ,xpMsg_KeyLoseFocus = 7 + + { You receive one mousedown event per click with a mouse-state structure } + { pointed to by parameter 1, by accepting this you eat the click, otherwise } + { your parent gets it. You will not receive drag and mouse up messages if you} + { do not accept the down message. } + { } + { Handling this message consumes the mouse click, not handling it passes it } + { to the next widget. You can act 'transparent' as a window by never handling} + { moues clicks to certain areas. } + { } + { Dispatching: Up chain NOTE: Technically this is direct dispatched, but the } + { widgets library will shop it to each widget until one consumes the click, } + { making it effectively "up chain". } + { } + { Param 1: A pointer to an XPMouseState_t containing the mouse status. } + ,xpMsg_MouseDown = 8 + + { You receive a series of mouse drag messages (typically one per frame in the} + { sim) as the mouse is moved once you have accepted a mouse down message. } + { Parameter one points to a mouse-state structure describing the mouse } + { location. You will continue to receive these until the mouse button is } + { released. You may receive multiple mouse state messages with the same mouse} + { position. You will receive mouse drag events even if the mouse is dragged } + { out of your current or original bounds at the time of the mouse down. } + { } + { Dispatching: Direct } + { } + { Param 1: A pointer to an XPMouseState_t containing the mouse status. } + ,xpMsg_MouseDrag = 9 + + { The mouseup event is sent once when the mouse button is released after a } + { drag or click. You only receive this message if you accept the mouseDown } + { message. Parameter one points to a mouse state structure. } + { } + { Dispatching: Direct } + { } + { Param 1: A pointer to an XPMouseState_t containing the mouse status. } + ,xpMsg_MouseUp = 10 + + { Your geometry or a child's geometry is being changed. } + { } + { Dispatching: Up chain } + { } + { Param 1: The widget ID of the original reshaped target. } + { } + { Param 2: A pointer to a XPWidgetGeometryChange_t struct describing the } + { change. } + ,xpMsg_Reshape = 11 + + { Your exposed area has changed. } + { } + { Dispatching: Direct } + ,xpMsg_ExposedChanged = 12 + + { A child has been added to you. The child's ID is passed in parameter one. } + { } + { Dispatching: Direct } + { } + { Param 1: The Widget ID of the child being added. } + ,xpMsg_AcceptChild = 13 + + { A child has been removed from to you. The child's ID is passed in parameter} + { one. } + { } + { Dispatching: Direct } + { } + { Param 1: The Widget ID of the child being removed. } + ,xpMsg_LoseChild = 14 + + { You now have a new parent, or have no parent. The parent's ID is passed in,} + { or 0 for no parent. } + { } + { Dispatching: Direct } + { } + { Param 1: The Widget ID of your parent } + ,xpMsg_AcceptParent = 15 + + { You or a child has been shown. Note that this does not include you being } + { shown because your parent was shown, you were put in a new parent, your } + { root was shown, etc. } + { } + { Dispatching: Up chain } + { } + { Param 1: The widget ID of the shown widget. } + ,xpMsg_Shown = 16 + + { You have been hidden. See limitations above. } + { } + { Dispatching: Up chain } + { } + { Param 1: The widget ID of the hidden widget. } + ,xpMsg_Hidden = 17 + + { Your descriptor has changed. } + { } + { Dispatching: Direct } + ,xpMsg_DescriptorChanged = 18 + + { A property has changed. Param 1 contains the property ID. } + { } + { Dispatching: Direct } + { } + { Param 1: The Property ID being changed. } + { } + { Param 2: The new property value } + ,xpMsg_PropertyChanged = 19 + +{$IFDEF XPLM200} + { The mouse wheel has moved. } + { } + { Return 1 to consume the mouse wheel move, or 0 to pass the message to a } + { parent. Dispatching: Up chain } + { } + { Param 1: A pointer to an XPMouseState_t containing the mouse status. } + ,xpMsg_MouseWheel = 20 +{$ENDIF XPLM200} + +{$IFDEF XPLM200} + { The cursor is over your widget. If you consume this message, change the } + { XPLMCursorStatus value to indicate the desired result, with the same rules } + { as in XPLMDisplay.h. } + { } + { Return 1 to consume this message, 0 to pass it on. } + { } + { Dispatching: Up chain Param 1: A pointer to an XPMouseState_t struct } + { containing the mouse status. } + { } + { Param 2: A pointer to a XPLMCursorStatus - set this to the cursor result } + { you desire. } + ,xpMsg_CursorAdjust = 21 +{$ENDIF XPLM200} + + { NOTE: Message IDs 1000 - 9999 are allocated to the standard widget classes } + { provided with the library with 1000 - 1099 for widget class 0, 1100 - 1199 } + { for widget class 1, etc. Message IDs 10,000 and beyond are for plugin use. } + ,xpMsg_UserStart = 10000 + + ); + PXPWidgetMessage = ^XPWidgetMessage; + +{___________________________________________________________________________ + * WIDGET CALLBACK FUNCTION + ___________________________________________________________________________} + + { + XPWidgetFunc_t + + This function defines your custom widget's behavior. It will be called by + the widgets library to send messages to your widget. The message and widget + ID are passed in, as well as two ptr-width signed parameters whose meaning + varies with the message. Return 1 to indicate that you have processed the + message, 0 to indicate that you have not. For any message that is not + understood, return 0. + } +TYPE + XPWidgetFunc_t = FUNCTION( + inMessage : XPWidgetMessage; + inWidget : XPWidgetID; + inParam1 : intptr_t; + inParam2 : intptr_t) : Integer; cdecl; + + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/SDKold/Delphi/Widgets/XPWidgetUtils.pas b/XPLPro_Plugin_Source/SDK/SDKold/Delphi/Widgets/XPWidgetUtils.pas new file mode 100644 index 0000000..9621126 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDKold/Delphi/Widgets/XPWidgetUtils.pas @@ -0,0 +1,197 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPWidgetUtils; +INTERFACE +{ + ## USAGE NOTES + + The XPWidgetUtils library contains useful functions that make writing and + using widgets less of a pain. + + One set of functions are the widget behavior functions. These functions + each add specific useful behaviors to widgets. They can be used in two + manners: + + 1. You can add a widget behavior function to a widget as a callback proc + using the XPAddWidgetCallback function. The widget will gain that + behavior. Remember that the last function you add has highest priority. + You can use this to change or augment the behavior of an existing + finished widget. + 2. You can call a widget function from inside your own widget function. + This allows you to include useful behaviors in custom-built widgets. A + number of the standard widgets get their behavior from this library. To + do this, call the behavior function from your function first. If it + returns 1, that means it handled the event and you don't need to; simply + return 1. +} + +USES + XPWidgetDefs; + {$A4} +{___________________________________________________________________________ + * GENERAL UTILITIES + ___________________________________________________________________________} + + + { + XPWidgetCreate_t + + This structure contains all of the parameters needed to create a wiget. It + is used with XPUCreateWidgets to create widgets in bulk from an array. All + parameters correspond to those of XPCreateWidget except for the container + index. + + If the container index is equal to the index of a widget in the array, the + widget in the array passed to XPUCreateWidgets is used as the parent of + this widget. Note that if you pass an index greater than your own position + in the array, the parent you are requesting will not exist yet. + + If the container index is NO_PARENT, the parent widget is specified as + NULL. If the container index is PARAM_PARENT, the widget passed into + XPUCreateWidgets is used. + } +TYPE + XPWidgetCreate_t = RECORD + left : Integer; + top : Integer; + right : Integer; + bottom : Integer; + visible : Integer; + descriptor : XPLMString; + { Whether ethis widget is a root wiget } + isRoot : Integer; + { The index of the widget to contain within, or a constant } + containerIndex : Integer; + widgetClass : XPWidgetClass; + END; + PXPWidgetCreate_t = ^XPWidgetCreate_t; + +CONST + NO_PARENT = -1; + + PARAM_PARENT = -2; + + + { + XPUCreateWidgets + + This function creates a series of widgets from a table (see + XPCreateWidget_t above). Pass in an array of widget creation structures and + an array of widget IDs that will receive each widget. + + Widget parents are specified by index into the created widget table, + allowing you to create nested widget structures. You can create multiple + widget trees in one table. Generally you should create widget trees from + the top down. + + You can also pass in a widget ID that will be used when the widget's parent + is listed as PARAM_PARENT; this allows you to embed widgets created with + XPUCreateWidgets in a widget created previously. + } + PROCEDURE XPUCreateWidgets( + inWidgetDefs : PXPWidgetCreate_t; + inCount : Integer; + inParamParent : XPWidgetID; + ioWidgets : PXPWidgetID); + cdecl; external XPWIDGETS.DLL; + + { + XPUMoveWidgetBy + + Simply moves a widget by an amount, +x = right, +y=up, without resizing the + widget. + } + PROCEDURE XPUMoveWidgetBy( + inWidget : XPWidgetID; + inDeltaX : Integer; + inDeltaY : Integer); + cdecl; external XPWIDGETS.DLL; + +{___________________________________________________________________________ + * LAYOUT MANAGERS + ___________________________________________________________________________} +{ + The layout managers are widget behavior functions for handling where + widgets move. Layout managers can be called from a widget function or + attached to a widget later. +} + + + { + XPUFixedLayout + + This function causes the widget to maintain its children in fixed position + relative to itself as it is resized. Use this on the top level 'window' + widget for your window. + } + FUNCTION XPUFixedLayout( + inMessage : XPWidgetMessage; + inWidget : XPWidgetID; + inParam1 : intptr_t; + inParam2 : intptr_t) : Integer; + cdecl; external XPWIDGETS.DLL; + +{___________________________________________________________________________ + * WIDGET PROC BEHAVIORS + ___________________________________________________________________________} +{ + These widget behavior functions add other useful behaviors to widgets. + These functions cannot be attached to a widget; they must be called from + your widget function. +} + + + { + XPUSelectIfNeeded + + This causes the widget to bring its window to the foreground if it is not + already. inEatClick specifies whether clicks in the background should be + consumed by bringin the window to the foreground. + } + FUNCTION XPUSelectIfNeeded( + inMessage : XPWidgetMessage; + inWidget : XPWidgetID; + inParam1 : intptr_t; + inParam2 : intptr_t; + inEatClick : Integer) : Integer; + cdecl; external XPWIDGETS.DLL; + + { + XPUDefocusKeyboard + + This causes a click in the widget to send keyboard focus back to X-Plane. + This stops editing of any text fields, etc. + } + FUNCTION XPUDefocusKeyboard( + inMessage : XPWidgetMessage; + inWidget : XPWidgetID; + inParam1 : intptr_t; + inParam2 : intptr_t; + inEatClick : Integer) : Integer; + cdecl; external XPWIDGETS.DLL; + + { + XPUDragWidget + + XPUDragWidget drags the widget in response to mouse clicks. Pass in not + only the event, but the global coordinates of the drag region, which might + be a sub-region of your widget (for example, a title bar). + } + FUNCTION XPUDragWidget( + inMessage : XPWidgetMessage; + inWidget : XPWidgetID; + inParam1 : intptr_t; + inParam2 : intptr_t; + inLeft : Integer; + inTop : Integer; + inRight : Integer; + inBottom : Integer) : Integer; + cdecl; external XPWIDGETS.DLL; + + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/SDKold/Delphi/Widgets/XPWidgets.pas b/XPLPro_Plugin_Source/SDK/SDKold/Delphi/Widgets/XPWidgets.pas new file mode 100644 index 0000000..46ae542 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDKold/Delphi/Widgets/XPWidgets.pas @@ -0,0 +1,527 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPWidgets; +INTERFACE +{ + ## THEORY OF OPERATION AND NOTES + + Widgets are persistent view 'objects' for X-Plane. A widget is an object + referenced by its opaque handle (widget ID) and the APIs in this file. You + cannot access the widget's guts directly. Every Widget has the following + intrinsic data: + + - A bounding box defined in global screen coordinates with 0,0 in the + bottom left and +y = up, +x = right. + - A visible box, which is the intersection of the bounding box with the + widget's parents visible box. + - Zero or one parent widgets. (Always zero if the widget is a root widget. + - Zero or more child widgets. + - Whether the widget is a root. Root widgets are the top level plugin + windows. + - Whether the widget is visible. + - A text string descriptor, whose meaning varies from widget to widget. + - An arbitrary set of 32 bit integral properties defined by 32-bit integral + keys. This is how specific widgets store specific data. + - A list of widget callbacks proc that implements the widgets behaviors. + + The Widgets library sends messages to widgets to request specific behaviors + or notify the widget of things. + + Widgets may have more than one callback function, in which case messages + are sent to the most recently added callback function until the message is + handled. Messages may also be sent to parents or children; see the + XPWidgetDefs.h header file for the different widget message dispatching + functions. By adding a callback function to a window you can 'subclass' its + behavior. + + A set of standard widgets are provided that serve common UI purposes. You + can also customize or implement entirely custom widgets. + + Widgets are different than other view hierarchies (most notably Win32, + which they bear a striking resemblance to) in the following ways: + + - Not all behavior can be patched. State that is managed by the XPWidgets + DLL and not by individual widgets cannot be customized. + - All coordinates are in global screen coordinates. Coordinates are not + relative to an enclosing widget, nor are they relative to a display + window. + - Widget messages are always dispatched synchronously, and there is no + concept of scheduling an update or a dirty region. Messages originate + from X-Plane as the sim cycle goes by. Since X-Plane is constantly + redrawing, so are widgets; there is no need to mark a part of a widget as + 'needing redrawing' because redrawing happens frequently whether the + widget needs it or not. + - Any widget may be a 'root' widget, causing it to be drawn; there is no + relationship between widget class and rootness. Root widgets are + imlemented as XPLMDisply windows. +} + +USES + XPWidgetDefs, XPLMDisplay; + {$A4} +{___________________________________________________________________________ + * WIDGET CREATION AND MANAGEMENT + ___________________________________________________________________________} + + { + XPCreateWidget + + This function creates a new widget and returns the new widget's ID to you. + If the widget creation fails for some reason, it returns NULL. Widget + creation will fail either if you pass a bad class ID or if there is not + adequate memory. + + Input Parameters: + + - Top, left, bottom, and right in global screen coordinates defining the + widget's location on the screen. + - inVisible is 1 if the widget should be drawn, 0 to start the widget as + hidden. + - inDescriptor is a null terminated string that will become the widget's + descriptor. + - inIsRoot is 1 if this is going to be a root widget, 0 if it will not be. + - inContainer is the ID of this widget's container. It must be 0 for a root + widget. for a non-root widget, pass the widget ID of the widget to place + this widget within. If this widget is not going to start inside another + widget, pass 0; this new widget will then just be floating off in space + (and will not be drawn until it is placed in a widget. + - inClass is the class of the widget to draw. Use one of the predefined + class-IDs to create a standard widget. + + A note on widget embedding: a widget is only called (and will be drawn, + etc.) if it is placed within a widget that will be called. Root widgets are + always called. So it is possible to have whole chains of widgets that are + simply not called. You can preconstruct widget trees and then place them + into root widgets later to activate them if you wish. + } + FUNCTION XPCreateWidget( + inLeft : Integer; + inTop : Integer; + inRight : Integer; + inBottom : Integer; + inVisible : Integer; + inDescriptor : XPLMString; + inIsRoot : Integer; + inContainer : XPWidgetID; + inClass : XPWidgetClass) : XPWidgetID; + cdecl; external XPWIDGETS.DLL; + + { + XPCreateCustomWidget + + This function is the same as XPCreateWidget except that instead of passing + a class ID, you pass your widget callback function pointer defining the + widget. Use this function to define a custom widget. All parameters are the + same as XPCreateWidget, except that the widget class has been replaced with + the widget function. + } + FUNCTION XPCreateCustomWidget( + inLeft : Integer; + inTop : Integer; + inRight : Integer; + inBottom : Integer; + inVisible : Integer; + inDescriptor : XPLMString; + inIsRoot : Integer; + inContainer : XPWidgetID; + inCallback : XPWidgetFunc_t) : XPWidgetID; + cdecl; external XPWIDGETS.DLL; + + { + XPDestroyWidget + + This class destroys a widget. Pass in the ID of the widget to kill. If you + pass 1 for inDestroyChilren, the widget's children will be destroyed first, + then this widget will be destroyed. (Furthermore, the widget's children + will be destroyed with the inDestroyChildren flag set to 1, so the + destruction will recurse down the widget tree.) If you pass 0 for this + flag, the child widgets will simply end up with their parent set to 0. + } + PROCEDURE XPDestroyWidget( + inWidget : XPWidgetID; + inDestroyChildren : Integer); + cdecl; external XPWIDGETS.DLL; + + { + XPSendMessageToWidget + + This sends any message to a widget. You should probably not go around + simulating the predefined messages that the widgets library defines for + you. You may however define custom messages for your widgets and send them + with this method. + + This method supports several dispatching patterns; see XPDispatchMode for + more info. The function returns 1 if the message was handled, 0 if it was + not. + + For each widget that receives the message (see the dispatching modes), each + widget function from the most recently installed to the oldest one receives + the message in order until it is handled. + } + FUNCTION XPSendMessageToWidget( + inWidget : XPWidgetID; + inMessage : XPWidgetMessage; + inMode : XPDispatchMode; + inParam1 : intptr_t; + inParam2 : intptr_t) : Integer; + cdecl; external XPWIDGETS.DLL; + +{___________________________________________________________________________ + * WIDGET POSITIONING AND VISIBILITY + ___________________________________________________________________________} + + { + XPPlaceWidgetWithin + + This function changes which container a widget resides in. You may NOT use + this function on a root widget! inSubWidget is the widget that will be + moved. Pass a widget ID in inContainer to make inSubWidget be a child of + inContainer. It will become the last/closest widget in the container. Pass + 0 to remove the widget from any container. Any call to this other than + passing the widget ID of the old parent of the affected widget will cause + the widget to be removed from its old parent. Placing a widget within its + own parent simply makes it the last widget. + + NOTE: this routine does not reposition the sub widget in global + coordinates. If the container has layout management code, it will + reposition the subwidget for you, otherwise you must do it with + SetWidgetGeometry. + } + PROCEDURE XPPlaceWidgetWithin( + inSubWidget : XPWidgetID; + inContainer : XPWidgetID); + cdecl; external XPWIDGETS.DLL; + + { + XPCountChildWidgets + + This routine returns the number of widgets another widget contains. + } + FUNCTION XPCountChildWidgets( + inWidget : XPWidgetID) : Integer; + cdecl; external XPWIDGETS.DLL; + + { + XPGetNthChildWidget + + This routine returns the widget ID of a child widget by index. Indexes are + 0 based, from 0 to one minus the number of widgets in the parent, + inclusive. If the index is invalid, 0 is returned. + } + FUNCTION XPGetNthChildWidget( + inWidget : XPWidgetID; + inIndex : Integer) : XPWidgetID; + cdecl; external XPWIDGETS.DLL; + + { + XPGetParentWidget + + Returns the parent of a widget, or 0 if the widget has no parent. Root + widgets never have parents and therefore always return 0. + } + FUNCTION XPGetParentWidget( + inWidget : XPWidgetID) : XPWidgetID; + cdecl; external XPWIDGETS.DLL; + + { + XPShowWidget + + This routine makes a widget visible if it is not already. Note that if a + widget is not in a rooted widget hierarchy or one of its parents is not + visible, it will still not be visible to the user. + } + PROCEDURE XPShowWidget( + inWidget : XPWidgetID); + cdecl; external XPWIDGETS.DLL; + + { + XPHideWidget + + Makes a widget invisible. See XPShowWidget for considerations of when a + widget might not be visible despite its own visibility state. + } + PROCEDURE XPHideWidget( + inWidget : XPWidgetID); + cdecl; external XPWIDGETS.DLL; + + { + XPIsWidgetVisible + + This returns 1 if a widget is visible, 0 if it is not. Note that this + routine takes into consideration whether a parent is invisible. Use this + routine to tell if the user can see the widget. + } + FUNCTION XPIsWidgetVisible( + inWidget : XPWidgetID) : Integer; + cdecl; external XPWIDGETS.DLL; + + { + XPFindRootWidget + + Returns the Widget ID of the root widget that contains the passed in widget + or NULL if the passed in widget is not in a rooted hierarchy. + } + FUNCTION XPFindRootWidget( + inWidget : XPWidgetID) : XPWidgetID; + cdecl; external XPWIDGETS.DLL; + + { + XPBringRootWidgetToFront + + This routine makes the specified widget be in the front most widget + hierarchy. If this widget is a root widget, its widget hierarchy comes to + front, otherwise the widget's root is brought to the front. If this widget + is not in an active widget hiearchy (e.g. there is no root widget at the + top of the tree), this routine does nothing. + } + PROCEDURE XPBringRootWidgetToFront( + inWidget : XPWidgetID); + cdecl; external XPWIDGETS.DLL; + + { + XPIsWidgetInFront + + This routine returns true if this widget's hierarchy is the front most + hierarchy. It returns false if the widget's hierarchy is not in front, or + if the widget is not in a rooted hierarchy. + } + FUNCTION XPIsWidgetInFront( + inWidget : XPWidgetID) : Integer; + cdecl; external XPWIDGETS.DLL; + + { + XPGetWidgetGeometry + + This routine returns the bounding box of a widget in global coordinates. + Pass NULL for any parameter you are not interested in. + } + PROCEDURE XPGetWidgetGeometry( + inWidget : XPWidgetID; + outLeft : PInteger; { Can be nil } + outTop : PInteger; { Can be nil } + outRight : PInteger; { Can be nil } + outBottom : PInteger); { Can be nil } + cdecl; external XPWIDGETS.DLL; + + { + XPSetWidgetGeometry + + This function changes the bounding box of a widget. + } + PROCEDURE XPSetWidgetGeometry( + inWidget : XPWidgetID; + inLeft : Integer; + inTop : Integer; + inRight : Integer; + inBottom : Integer); + cdecl; external XPWIDGETS.DLL; + + { + XPGetWidgetForLocation + + Given a widget and a location, this routine returns the widget ID of the + child of that widget that owns that location. If inRecursive is true then + this will return a child of a child of a widget as it tries to find the + deepest widget at that location. If inVisibleOnly is true, then only + visible widgets are considered, otherwise all widgets are considered. The + widget ID passed for inContainer will be returned if the location is in + that widget but not in a child widget. 0 is returned if the location is not + in the container. + + NOTE: if a widget's geometry extends outside its parents geometry, it will + not be returned by this call for mouse locations outside the parent + geometry. The parent geometry limits the child's eligibility for mouse + location. + } + FUNCTION XPGetWidgetForLocation( + inContainer : XPWidgetID; + inXOffset : Integer; + inYOffset : Integer; + inRecursive : Integer; + inVisibleOnly : Integer) : XPWidgetID; + cdecl; external XPWIDGETS.DLL; + + { + XPGetWidgetExposedGeometry + + This routine returns the bounds of the area of a widget that is completely + within its parent widgets. Since a widget's bounding box can be outside its + parent, part of its area will not be elligible for mouse clicks and should + not draw. Use XPGetWidgetGeometry to find out what area defines your + widget's shape, but use this routine to find out what area to actually draw + into. Note that the widget library does not use OpenGL clipping to keep + frame rates up, although you could use it internally. + } + PROCEDURE XPGetWidgetExposedGeometry( + inWidgetID : XPWidgetID; + outLeft : PInteger; { Can be nil } + outTop : PInteger; { Can be nil } + outRight : PInteger; { Can be nil } + outBottom : PInteger); { Can be nil } + cdecl; external XPWIDGETS.DLL; + +{___________________________________________________________________________ + * ACCESSING WIDGET DATA + ___________________________________________________________________________} + + { + XPSetWidgetDescriptor + + Every widget has a descriptor, which is a text string. What the text string + is used for varies from widget to widget; for example, a push button's text + is its descriptor, a caption shows its descriptor, and a text field's + descriptor is the text being edited. In other words, the usage for the text + varies from widget to widget, but this API provides a universal and + convenient way to get at it. While not all UI widgets need their + descriptor, many do. + } + PROCEDURE XPSetWidgetDescriptor( + inWidget : XPWidgetID; + inDescriptor : XPLMString); + cdecl; external XPWIDGETS.DLL; + + { + XPGetWidgetDescriptor + + This routine returns the widget's descriptor. Pass in the length of the + buffer you are going to receive the descriptor in. The descriptor will be + null terminated for you. This routine returns the length of the actual + descriptor; if you pass NULL for outDescriptor, you can get the + descriptor's length without getting its text. If the length of the + descriptor exceeds your buffer length, the buffer will not be null + terminated (this routine has 'strncpy' semantics). + } + FUNCTION XPGetWidgetDescriptor( + inWidget : XPWidgetID; + outDescriptor : XPLMString; + inMaxDescLength : Integer) : Integer; + cdecl; external XPWIDGETS.DLL; + + { + XPGetWidgetUnderlyingWindow + + Returns the window (from the XPLMDisplay API) that backs your widget + window. If you have opted in to modern windows, via a call to + XPLMEnableFeature("XPLM_USE_NATIVE_WIDGET_WINDOWS", 1), you can use the + returned window ID for display APIs like XPLMSetWindowPositioningMode(), + allowing you to pop the widget window out into a real OS window, or move it + into VR. + } + FUNCTION XPGetWidgetUnderlyingWindow( + inWidget : XPWidgetID) : XPLMWindowID; + cdecl; external XPWIDGETS.DLL; + + { + XPSetWidgetProperty + + This function sets a widget's property. Properties are arbitrary values + associated by a widget by ID. + } + PROCEDURE XPSetWidgetProperty( + inWidget : XPWidgetID; + inProperty : XPWidgetPropertyID; + inValue : intptr_t); + cdecl; external XPWIDGETS.DLL; + + { + XPGetWidgetProperty + + This routine returns the value of a widget's property, or 0 if the property + is not defined. If you need to know whether the property is defined, pass a + pointer to an int for inExists; the existence of that property will be + returned in the int. Pass NULL for inExists if you do not need this + information. + } + FUNCTION XPGetWidgetProperty( + inWidget : XPWidgetID; + inProperty : XPWidgetPropertyID; + inExists : PInteger) : intptr_t; { Can be nil } + cdecl; external XPWIDGETS.DLL; + +{___________________________________________________________________________ + * KEYBOARD MANAGEMENT + ___________________________________________________________________________} + + { + XPSetKeyboardFocus + + Controls which widget will receive keystrokes. Pass the widget ID of the + widget to get the keys. Note that if the widget does not care about + keystrokes, they will go to the parent widget, and if no widget cares about + them, they go to X-Plane. + + If you set the keyboard focus to widget ID 0, X-Plane gets keyboard focus. + + This routine returns the widget ID that ended up with keyboard focus, or 0 + for X-Plane. + + Keyboard focus is not changed if the new widget will not accept it. For + setting to X-Plane, keyboard focus is always accepted. + } + FUNCTION XPSetKeyboardFocus( + inWidget : XPWidgetID) : XPWidgetID; + cdecl; external XPWIDGETS.DLL; + + { + XPLoseKeyboardFocus + + This causes the specified widget to lose focus; focus is passed to its + parent, or the next parent that will accept it. This routine does nothing + if this widget does not have focus. + } + PROCEDURE XPLoseKeyboardFocus( + inWidget : XPWidgetID); + cdecl; external XPWIDGETS.DLL; + + { + XPGetWidgetWithFocus + + This routine returns the widget that has keyboard focus, or 0 if X-Plane + has keyboard focus or some other plugin window that does not have widgets + has focus. + } + FUNCTION XPGetWidgetWithFocus: XPWidgetID; + cdecl; external XPWIDGETS.DLL; + +{___________________________________________________________________________ + * CREATING CUSTOM WIDGETS + ___________________________________________________________________________} + + { + XPAddWidgetCallback + + This function adds a new widget callback to a widget. This widget callback + supercedes any existing ones and will receive messages first; if it does + not handle messages they will go on to be handled by pre-existing widgets. + + The widget function will remain on the widget for the life of the widget. + The creation message will be sent to the new callback immediately with the + widget ID, and the destruction message will be sent before the other widget + function receives a destruction message. + + This provides a way to 'subclass' an existing widget. By providing a second + hook that only handles certain widget messages, you can customize or extend + widget behavior. + } + PROCEDURE XPAddWidgetCallback( + inWidget : XPWidgetID; + inNewCallback : XPWidgetFunc_t); + cdecl; external XPWIDGETS.DLL; + + { + XPGetWidgetClassFunc + + Given a widget class, this function returns the callbacks that power that + widget class. + } + FUNCTION XPGetWidgetClassFunc( + inWidgetClass : XPWidgetClass) : XPWidgetFunc_t; + cdecl; external XPWIDGETS.DLL; + + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/SDKold/Delphi/XPLM/XPLMCamera.pas b/XPLPro_Plugin_Source/SDK/SDKold/Delphi/XPLM/XPLMCamera.pas new file mode 100644 index 0000000..ad76fa4 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDKold/Delphi/XPLM/XPLMCamera.pas @@ -0,0 +1,155 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPLMCamera; +INTERFACE +{ + The XPLMCamera APIs allow plug-ins to control the camera angle in X-Plane. + This has a number of applications, including but not limited to: + + - Creating new views (including dynamic/user-controllable views) for the + user. + - Creating applications that use X-Plane as a renderer of scenery, + aircrafts, or both. + + The camera is controlled via six parameters: a location in OpenGL + coordinates and pitch, roll and yaw, similar to an airplane's position. + OpenGL coordinate info is described in detail in the XPLMGraphics + documentation; generally you should use the XPLMGraphics routines to + convert from world to local coordinates. The camera's orientation starts + facing level with the ground directly up the negative-Z axis (approximately + north) with the horizon horizontal. It is then rotated clockwise for yaw, + pitched up for positive pitch, and rolled clockwise around the vector it is + looking along for roll. + + You control the camera either either until the user selects a new view or + permanently (the later being similar to how UDP camera control works). You + control the camera by registering a callback per frame from which you + calculate the new camera positions. This guarantees smooth camera motion. + + Use the XPLMDataAccess APIs to get information like the position of the + aircraft, etc. for complex camera positioning. + + Note: if your goal is to move the virtual pilot in the cockpit, this API is + not needed; simply update the datarefs for the pilot's head position. + + For custom exterior cameras, set the camera's mode to an external view + first to get correct sound and 2-d panel behavior. +} + +USES + XPLMDefs; + {$A4} +{___________________________________________________________________________ + * CAMERA CONTROL + ___________________________________________________________________________} + + { + XPLMCameraControlDuration + + This enumeration states how long you want to retain control of the camera. + You can retain it indefinitely or until the user selects a new view. + } +TYPE + XPLMCameraControlDuration = ( + { Control the camera until the user picks a new view. } + xplm_ControlCameraUntilViewChanges = 1 + + { Control the camera until your plugin is disabled or another plugin forcably} + { takes control. } + ,xplm_ControlCameraForever = 2 + + ); + PXPLMCameraControlDuration = ^XPLMCameraControlDuration; + + { + XPLMCameraPosition_t + + This structure contains a full specification of the camera. X, Y, and Z are + the camera's position in OpenGL coordiantes; pitch, roll, and yaw are + rotations from a camera facing flat north in degrees. Positive pitch means + nose up, positive roll means roll right, and positive yaw means yaw right, + all in degrees. Zoom is a zoom factor, with 1.0 meaning normal zoom and 2.0 + magnifying by 2x (objects appear larger). + } + XPLMCameraPosition_t = RECORD + x : Single; + y : Single; + z : Single; + pitch : Single; + heading : Single; + roll : Single; + zoom : Single; + END; + PXPLMCameraPosition_t = ^XPLMCameraPosition_t; + + { + XPLMCameraControl_f + + You use an XPLMCameraControl function to provide continuous control over + the camera. You are passed in a structure in which to put the new camera + position; modify it and return 1 to reposition the camera. Return 0 to + surrender control of the camera; camera control will be handled by X-Plane + on this draw loop. The contents of the structure as you are called are + undefined. + + If X-Plane is taking camera control away from you, this function will be + called with inIsLosingControl set to 1 and ioCameraPosition NULL. + } + XPLMCameraControl_f = FUNCTION( + outCameraPosition : PXPLMCameraPosition_t; { Can be nil } + inIsLosingControl : Integer; + inRefcon : pointer) : Integer; cdecl; + + { + XPLMControlCamera + + This function repositions the camera on the next drawing cycle. You must + pass a non-null control function. Specify in inHowLong how long you'd like + control (indefinitely or until a new view mode is set by the user). + } + PROCEDURE XPLMControlCamera( + inHowLong : XPLMCameraControlDuration; + inControlFunc : XPLMCameraControl_f; + inRefcon : pointer); + cdecl; external XPLM_DLL; + + { + XPLMDontControlCamera + + This function stops you from controlling the camera. If you have a camera + control function, it will not be called with an inIsLosingControl flag. + X-Plane will control the camera on the next cycle. + + For maximum compatibility you should not use this routine unless you are in + posession of the camera. + } + PROCEDURE XPLMDontControlCamera; + cdecl; external XPLM_DLL; + + { + XPLMIsCameraBeingControlled + + This routine returns 1 if the camera is being controlled, zero if it is + not. If it is and you pass in a pointer to a camera control duration, the + current control duration will be returned. + } + FUNCTION XPLMIsCameraBeingControlled( + outCameraControlDuration: PXPLMCameraControlDuration) : Integer; { Can be nil } + cdecl; external XPLM_DLL; + + { + XPLMReadCameraPosition + + This function reads the current camera position. + } + PROCEDURE XPLMReadCameraPosition( + outCameraPosition : PXPLMCameraPosition_t); + cdecl; external XPLM_DLL; + + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/SDKold/Delphi/XPLM/XPLMDataAccess.pas b/XPLPro_Plugin_Source/SDK/SDKold/Delphi/XPLM/XPLMDataAccess.pas new file mode 100644 index 0000000..1ad210e --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDKold/Delphi/XPLM/XPLMDataAccess.pas @@ -0,0 +1,690 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPLMDataAccess; +INTERFACE +{ + The data access API gives you a generic, flexible, high performance way to + read and write data to and from X-Plane and other plug-ins. For example, + this API allows you to read and set the nav radios, get the plane location, + determine the current effective graphics frame rate, etc. + + The data access APIs are the way that you read and write data from the sim + as well as other plugins. + + The API works using opaque data references. A data reference is a source of + data; you do not know where it comes from, but once you have it you can + read the data quickly and possibly write it. + + Dataref Lookup + -------------- + + Data references are identified by verbose, permanent string names; by + convention these names use path separates to form a hierarchy of datarefs, + e.g. (sim/cockpit/radios/nav1_freq_hz). The actual opaque numeric value of + the data reference, as returned by the XPLM API, is implementation defined + and changes each time X-Plane is launched; therefore you need to look up + the dataref by path every time your plugin runs. + + The task of looking up a data reference is relatively expensive; look up + your data references once based on the verbose path strings, and save the + opaque data reference value for the duration of your plugin's operation. + Reading and writing data references is relatively fast (the cost is + equivalent to two function calls through function pointers). + + X-Plane publishes over 4000 datarefs; a complete list may be found in the + reference section of the SDK online documentation (from the SDK home page, + choose Documentation). + + Dataref Types + ------------- + + A note on typing: you must know the correct data type to read and write. + APIs are provided for reading and writing data in a number of ways. You can + also double check the data type for a data ref. Automatic type conversion + is not done for you. + + Dataref types are a set, e.g. a dataref can be more than one type. When + this happens, you can choose which API you want to use to read. For + example, it is not uncommon for a dataref to be of type float and double. + This means you can use either XPLMGetDatad or XPLMGetDataf to read it. + + Creating New Datarefs + --------------------- + + X-Plane provides datarefs that come with the sim, but plugins can also + create their own datarefs. A plugin creates a dataref by registering + function callbacks to read and write the dataref. The XPLM will call your + plugin each time some other plugin (or X-Plane) tries to read or write the + dataref. You must provide a read (and optional write) callback for each + data type you support. + + A note for plugins sharing data with other plugins: the load order of + plugins is not guaranteed. To make sure that every plugin publishing data + has published their data references before other plugins try to subscribe, + publish your data references in your start routine but resolve them the + first time your 'enable' routine is called, or the first time they are + needed in code. + + When a plugin that created a dataref is unloaded, it becomes "orphaned". + The dataref handle continues to be usable, but the dataref is not writable, + and reading it will always return 0 (or 0 items for arrays). If the plugin + is reloaded and re-registers the dataref, the handle becomes un-orphaned + and works again. +} + +USES + XPLMDefs; + {$A4} +{___________________________________________________________________________ + * READING AND WRITING DATA + ___________________________________________________________________________} +{ + These routines allow you to access data from within X-Plane and sometimes + modify it. +} + + +TYPE + { + XPLMDataRef + + A data ref is an opaque handle to data provided by the simulator or another + plugin. It uniquely identifies one variable (or array of variables) over + the lifetime of your plugin. You never hard code these values; you always + get them from XPLMFindDataRef. + } + XPLMDataRef = pointer; + PXPLMDataRef = ^XPLMDataRef; + + { + XPLMDataTypeID + + This is an enumeration that defines the type of the data behind a data + reference. This allows you to sanity check that the data type matches what + you expect. But for the most part, you will know the type of data you are + expecting from the online documentation. + + Data types each take a bit field; it is legal to have a single dataref be + more than one type of data. Whe this happens, you can pick any matching + get/set API. + } + XPLMDataTypeID = ( + { Data of a type the current XPLM doesn't do. } + xplmType_Unknown = 0 + + { A single 4-byte integer, native endian. } + ,xplmType_Int = 1 + + { A single 4-byte float, native endian. } + ,xplmType_Float = 2 + + { A single 8-byte double, native endian. } + ,xplmType_Double = 4 + + { An array of 4-byte floats, native endian. } + ,xplmType_FloatArray = 8 + + { An array of 4-byte integers, native endian. } + ,xplmType_IntArray = 16 + + { A variable block of data. } + ,xplmType_Data = 32 + + ); + PXPLMDataTypeID = ^XPLMDataTypeID; + + { + XPLMFindDataRef + + Given a c-style string that names the data ref, this routine looks up the + actual opaque XPLMDataRef that you use to read and write the data. The + string names for datarefs are published on the X-Plane SDK web site. + + This function returns NULL if the data ref cannot be found. + + NOTE: this function is relatively expensive; save the XPLMDataRef this + function returns for future use. Do not look up your data ref by string + every time you need to read or write it. + } + FUNCTION XPLMFindDataRef( + inDataRefName : XPLMString) : XPLMDataRef; + cdecl; external XPLM_DLL; + + { + XPLMCanWriteDataRef + + Given a data ref, this routine returns true if you can successfully set the + data, false otherwise. Some datarefs are read-only. + + NOTE: even if a dataref is marked writable, it may not act writable. This + can happen for datarefs that X-Plane writes to on every frame of + simulation. In some cases, the dataref is writable but you have to set a + separate "override" dataref to 1 to stop X-Plane from writing it. + } + FUNCTION XPLMCanWriteDataRef( + inDataRef : XPLMDataRef) : Integer; + cdecl; external XPLM_DLL; + + { + XPLMIsDataRefGood + + This function returns true if the passed in handle is a valid dataref that + is not orphaned. + + Note: there is normally no need to call this function; datarefs returned by + XPLMFindDataRef remain valid (but possibly orphaned) unless there is a + complete plugin reload (in which case your plugin is reloaded anyway). + Orphaned datarefs can be safely read and return 0. Therefore you never need + to call XPLMIsDataRefGood to 'check' the safety of a dataref. + (XPLMIsDatarefGood performs some slow checking of the handle validity, so + it has a perormance cost.) + } + FUNCTION XPLMIsDataRefGood( + inDataRef : XPLMDataRef) : Integer; + cdecl; external XPLM_DLL; + + { + XPLMGetDataRefTypes + + This routine returns the types of the data ref for accessor use. If a data + ref is available in multiple data types, the bit-wise OR of these types + will be returned. + } + FUNCTION XPLMGetDataRefTypes( + inDataRef : XPLMDataRef) : XPLMDataTypeID; + cdecl; external XPLM_DLL; + +{___________________________________________________________________________ + * DATA ACCESSORS + ___________________________________________________________________________} +{ + These routines read and write the data references. For each supported data + type there is a reader and a writer. + + If the data ref is orphaned or the plugin that provides it is disabled or + there is a type mismatch, the functions that read data will return 0 as a + default value or not modify the passed in memory. The plugins that write + data will not write under these circumstances or if the data ref is + read-only. + + NOTE: to keep the overhead of reading datarefs low, these routines do not + do full validation of a dataref; passing a junk value for a dataref can + result in crashing the sim. The get/set APIs do check for NULL. + + For array-style datarefs, you specify the number of items to read/write and + the offset into the array; the actual number of items read or written is + returned. This may be less to prevent an array-out-of-bounds error. +} + + + { + XPLMGetDatai + + Read an integer data ref and return its value. The return value is the + dataref value or 0 if the dataref is NULL or the plugin is disabled. + } + FUNCTION XPLMGetDatai( + inDataRef : XPLMDataRef) : Integer; + cdecl; external XPLM_DLL; + + { + XPLMSetDatai + + Write a new value to an integer data ref. This routine is a no-op if the + plugin publishing the dataref is disabled, the dataref is NULL, or the + dataref is not writable. + } + PROCEDURE XPLMSetDatai( + inDataRef : XPLMDataRef; + inValue : Integer); + cdecl; external XPLM_DLL; + + { + XPLMGetDataf + + Read a single precision floating point dataref and return its value. The + return value is the dataref value or 0.0 if the dataref is NULL or the + plugin is disabled. + } + FUNCTION XPLMGetDataf( + inDataRef : XPLMDataRef) : Single; + cdecl; external XPLM_DLL; + + { + XPLMSetDataf + + Write a new value to a single precision floating point data ref. This + routine is a no-op if the plugin publishing the dataref is disabled, the + dataref is NULL, or the dataref is not writable. + } + PROCEDURE XPLMSetDataf( + inDataRef : XPLMDataRef; + inValue : Single); + cdecl; external XPLM_DLL; + + { + XPLMGetDatad + + Read a double precision floating point dataref and return its value. The + return value is the dataref value or 0.0 if the dataref is NULL or the + plugin is disabled. + } + FUNCTION XPLMGetDatad( + inDataRef : XPLMDataRef) : Real; + cdecl; external XPLM_DLL; + + { + XPLMSetDatad + + Write a new value to a double precision floating point data ref. This + routine is a no-op if the plugin publishing the dataref is disabled, the + dataref is NULL, or the dataref is not writable. + } + PROCEDURE XPLMSetDatad( + inDataRef : XPLMDataRef; + inValue : Real); + cdecl; external XPLM_DLL; + + { + XPLMGetDatavi + + Read a part of an integer array dataref. If you pass NULL for outValues, + the routine will return the size of the array, ignoring inOffset and inMax. + + If outValues is not NULL, then up to inMax values are copied from the + dataref into outValues, starting at inOffset in the dataref. If inMax + + inOffset is larger than the size of the dataref, less than inMax values + will be copied. The number of values copied is returned. + + Note: the semantics of array datarefs are entirely implemented by the + plugin (or X-Plane) that provides the dataref, not the SDK itself; the + above description is how these datarefs are intended to work, but a rogue + plugin may have different behavior. + } + FUNCTION XPLMGetDatavi( + inDataRef : XPLMDataRef; + outValues : PInteger; { Can be nil } + inOffset : Integer; + inMax : Integer) : Integer; + cdecl; external XPLM_DLL; + + { + XPLMSetDatavi + + Write part or all of an integer array dataref. The values passed by + inValues are written into the dataref starting at inOffset. Up to inCount + values are written; however if the values would write "off the end" of the + dataref array, then fewer values are written. + + Note: the semantics of array datarefs are entirely implemented by the + plugin (or X-Plane) that provides the dataref, not the SDK itself; the + above description is how these datarefs are intended to work, but a rogue + plugin may have different behavior. + } + PROCEDURE XPLMSetDatavi( + inDataRef : XPLMDataRef; + inValues : PInteger; + inoffset : Integer; + inCount : Integer); + cdecl; external XPLM_DLL; + + { + XPLMGetDatavf + + Read a part of a single precision floating point array dataref. If you pass + NULL for outVaules, the routine will return the size of the array, ignoring + inOffset and inMax. + + If outValues is not NULL, then up to inMax values are copied from the + dataref into outValues, starting at inOffset in the dataref. If inMax + + inOffset is larger than the size of the dataref, less than inMax values + will be copied. The number of values copied is returned. + + Note: the semantics of array datarefs are entirely implemented by the + plugin (or X-Plane) that provides the dataref, not the SDK itself; the + above description is how these datarefs are intended to work, but a rogue + plugin may have different behavior. + } + FUNCTION XPLMGetDatavf( + inDataRef : XPLMDataRef; + outValues : PSingle; { Can be nil } + inOffset : Integer; + inMax : Integer) : Integer; + cdecl; external XPLM_DLL; + + { + XPLMSetDatavf + + Write part or all of a single precision floating point array dataref. The + values passed by inValues are written into the dataref starting at + inOffset. Up to inCount values are written; however if the values would + write "off the end" of the dataref array, then fewer values are written. + + Note: the semantics of array datarefs are entirely implemented by the + plugin (or X-Plane) that provides the dataref, not the SDK itself; the + above description is how these datarefs are intended to work, but a rogue + plugin may have different behavior. + } + PROCEDURE XPLMSetDatavf( + inDataRef : XPLMDataRef; + inValues : PSingle; + inoffset : Integer; + inCount : Integer); + cdecl; external XPLM_DLL; + + { + XPLMGetDatab + + Read a part of a byte array dataref. If you pass NULL for outVaules, the + routine will return the size of the array, ignoring inOffset and inMax. + + If outValues is not NULL, then up to inMax values are copied from the + dataref into outValues, starting at inOffset in the dataref. If inMax + + inOffset is larger than the size of the dataref, less than inMax values + will be copied. The number of values copied is returned. + + Note: the semantics of array datarefs are entirely implemented by the + plugin (or X-Plane) that provides the dataref, not the SDK itself; the + above description is how these datarefs are intended to work, but a rogue + plugin may have different behavior. + } + FUNCTION XPLMGetDatab( + inDataRef : XPLMDataRef; + outValue : pointer; { Can be nil } + inOffset : Integer; + inMaxBytes : Integer) : Integer; + cdecl; external XPLM_DLL; + + { + XPLMSetDatab + + Write part or all of a byte array dataref. The values passed by inValues + are written into the dataref starting at inOffset. Up to inCount values are + written; however if the values would write "off the end" of the dataref + array, then fewer values are written. + + Note: the semantics of array datarefs are entirely implemented by the + plugin (or X-Plane) that provides the dataref, not the SDK itself; the + above description is how these datarefs are intended to work, but a rogue + plugin may have different behavior. + } + PROCEDURE XPLMSetDatab( + inDataRef : XPLMDataRef; + inValue : pointer; + inOffset : Integer; + inLength : Integer); + cdecl; external XPLM_DLL; + +{___________________________________________________________________________ + * PUBLISHING YOUR PLUGIN'S DATA + ___________________________________________________________________________} +{ + These functions allow you to create data references that other plug-ins and + X-Plane can access via the above data access APIs. Data references + published by other plugins operate the same as ones published by X-Plane in + all manners except that your data reference will not be available to other + plugins if/when your plugin is disabled. + + You share data by registering data provider callback functions. When a + plug-in requests your data, these callbacks are then called. You provide + one callback to return the value when a plugin 'reads' it and another to + change the value when a plugin 'writes' it. + + Important: you must pick a prefix for your datarefs other than "sim/" - + this prefix is reserved for X-Plane. The X-Plane SDK website contains a + registry where authors can select a unique first word for dataref names, to + prevent dataref collisions between plugins. +} + + + { + XPLMGetDatai_f + + Data provider function pointers. + + These define the function pointers you provide to get or set data. Note + that you are passed a generic pointer for each one. This is the same + pointer you pass in your register routine; you can use it to locate plugin + variables, etc. + + The semantics of your callbacks are the same as the dataref accessor above + - basically routines like XPLMGetDatai are just pass-throughs from a caller + to your plugin. Be particularly mindful in implementing array dataref + read-write accessors; you are responsible for avoiding overruns, supporting + offset read/writes, and handling a read with a NULL buffer. + } +TYPE + XPLMGetDatai_f = FUNCTION( + inRefcon : pointer) : Integer; cdecl; + + { + XPLMSetDatai_f + } + XPLMSetDatai_f = PROCEDURE( + inRefcon : pointer; + inValue : Integer); cdecl; + + { + XPLMGetDataf_f + } + XPLMGetDataf_f = FUNCTION( + inRefcon : pointer) : Single; cdecl; + + { + XPLMSetDataf_f + } + XPLMSetDataf_f = PROCEDURE( + inRefcon : pointer; + inValue : Single); cdecl; + + { + XPLMGetDatad_f + } + XPLMGetDatad_f = FUNCTION( + inRefcon : pointer) : Real; cdecl; + + { + XPLMSetDatad_f + } + XPLMSetDatad_f = PROCEDURE( + inRefcon : pointer; + inValue : Real); cdecl; + + { + XPLMGetDatavi_f + } + XPLMGetDatavi_f = FUNCTION( + inRefcon : pointer; + outValues : PInteger; { Can be nil } + inOffset : Integer; + inMax : Integer) : Integer; cdecl; + + { + XPLMSetDatavi_f + } + XPLMSetDatavi_f = PROCEDURE( + inRefcon : pointer; + inValues : PInteger; + inOffset : Integer; + inCount : Integer); cdecl; + + { + XPLMGetDatavf_f + } + XPLMGetDatavf_f = FUNCTION( + inRefcon : pointer; + outValues : PSingle; { Can be nil } + inOffset : Integer; + inMax : Integer) : Integer; cdecl; + + { + XPLMSetDatavf_f + } + XPLMSetDatavf_f = PROCEDURE( + inRefcon : pointer; + inValues : PSingle; + inOffset : Integer; + inCount : Integer); cdecl; + + { + XPLMGetDatab_f + } + XPLMGetDatab_f = FUNCTION( + inRefcon : pointer; + outValue : pointer; { Can be nil } + inOffset : Integer; + inMaxLength : Integer) : Integer; cdecl; + + { + XPLMSetDatab_f + } + XPLMSetDatab_f = PROCEDURE( + inRefcon : pointer; + inValue : pointer; + inOffset : Integer; + inLength : Integer); cdecl; + + { + XPLMRegisterDataAccessor + + This routine creates a new item of data that can be read and written. Pass + in the data's full name for searching, the type(s) of the data for + accessing, and whether the data can be written to. For each data type you + support, pass in a read accessor function and a write accessor function if + necessary. Pass NULL for data types you do not support or write accessors + if you are read-only. + + You are returned a data ref for the new item of data created. You can use + this data ref to unregister your data later or read or write from it. + } + FUNCTION XPLMRegisterDataAccessor( + inDataName : XPLMString; + inDataType : XPLMDataTypeID; + inIsWritable : Integer; + inReadInt : XPLMGetDatai_f; + inWriteInt : XPLMSetDatai_f; + inReadFloat : XPLMGetDataf_f; + inWriteFloat : XPLMSetDataf_f; + inReadDouble : XPLMGetDatad_f; + inWriteDouble : XPLMSetDatad_f; + inReadIntArray : XPLMGetDatavi_f; + inWriteIntArray : XPLMSetDatavi_f; + inReadFloatArray : XPLMGetDatavf_f; + inWriteFloatArray : XPLMSetDatavf_f; + inReadData : XPLMGetDatab_f; + inWriteData : XPLMSetDatab_f; + inReadRefcon : pointer; + inWriteRefcon : pointer) : XPLMDataRef; + cdecl; external XPLM_DLL; + + { + XPLMUnregisterDataAccessor + + Use this routine to unregister any data accessors you may have registered. + You unregister a data ref by the XPLMDataRef you get back from + registration. Once you unregister a data ref, your function pointer will + not be called anymore. + } + PROCEDURE XPLMUnregisterDataAccessor( + inDataRef : XPLMDataRef); + cdecl; external XPLM_DLL; + +{___________________________________________________________________________ + * SHARING DATA BETWEEN MULTIPLE PLUGINS + ___________________________________________________________________________} +{ + The data reference registration APIs from the previous section allow a + plugin to publish data in a one-owner manner; the plugin that publishes the + data reference owns the real memory that the data ref uses. This is + satisfactory for most cases, but there are also cases where plugnis need to + share actual data. + + With a shared data reference, no one plugin owns the actual memory for the + data reference; the plugin SDK allocates that for you. When the first + plugin asks to 'share' the data, the memory is allocated. When the data is + changed, every plugin that is sharing the data is notified. + + Shared data references differ from the 'owned' data references from the + previous section in a few ways: + + * With shared data references, any plugin can create the data reference; + with owned plugins one plugin must create the data reference and others + subscribe. (This can be a problem if you don't know which set of plugins + will be present). + + * With shared data references, every plugin that is sharing the data is + notified when the data is changed. With owned data references, only the + one owner is notified when the data is changed. + + * With shared data references, you cannot access the physical memory of the + data reference; you must use the XPLMGet... and XPLMSet... APIs. With an + owned data reference, the one owning data reference can manipulate the + data reference's memory in any way it sees fit. + + Shared data references solve two problems: if you need to have a data + reference used by several plugins but do not know which plugins will be + installed, or if all plugins sharing data need to be notified when that + data is changed, use shared data references. +} + + + { + XPLMDataChanged_f + + An XPLMDataChanged_f is a callback that the XPLM calls whenever any other + plug-in modifies shared data. A refcon you provide is passed back to help + identify which data is being changed. In response, you may want to call one + of the XPLMGetDataxxx routines to find the new value of the data. + } +TYPE + XPLMDataChanged_f = PROCEDURE( + inRefcon : pointer); cdecl; + + { + XPLMShareData + + This routine connects a plug-in to shared data, creating the shared data if + necessary. inDataName is a standard path for the data ref, and inDataType + specifies the type. This function will create the data if it does not + exist. If the data already exists but the type does not match, an error is + returned, so it is important that plug-in authors collaborate to establish + public standards for shared data. + + If a notificationFunc is passed in and is not NULL, that notification + function will be called whenever the data is modified. The notification + refcon will be passed to it. This allows your plug-in to know which shared + data was changed if multiple shared data are handled by one callback, or if + the plug-in does not use global variables. + + A one is returned for successfully creating or finding the shared data; a + zero if the data already exists but is of the wrong type. + } + FUNCTION XPLMShareData( + inDataName : XPLMString; + inDataType : XPLMDataTypeID; + inNotificationFunc : XPLMDataChanged_f; + inNotificationRefcon: pointer) : Integer; + cdecl; external XPLM_DLL; + + { + XPLMUnshareData + + This routine removes your notification function for shared data. Call it + when done with the data to stop receiving change notifications. Arguments + must match XPLMShareData. The actual memory will not necessarily be freed, + since other plug-ins could be using it. + } + FUNCTION XPLMUnshareData( + inDataName : XPLMString; + inDataType : XPLMDataTypeID; + inNotificationFunc : XPLMDataChanged_f; + inNotificationRefcon: pointer) : Integer; + cdecl; external XPLM_DLL; + + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/SDKold/Delphi/XPLM/XPLMDefs.pas b/XPLPro_Plugin_Source/SDK/SDKold/Delphi/XPLM/XPLMDefs.pas new file mode 100644 index 0000000..b614085 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDKold/Delphi/XPLM/XPLMDefs.pas @@ -0,0 +1,438 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPLMDefs; +INTERFACE +{ + This file is contains the cross-platform and basic definitions for the + X-Plane SDK. + + The preprocessor macros APL and IBM must be defined to specify the + compilation target; define APL to 1 and IBM 0 to compile on Macintosh and + APL to 0 and IBM to 1 for Windows. You must specify these macro definitions + before including XPLMDefs.h or any other XPLM headers. You can do this + using the -D command line option or a preprocessor header. +} + + {$A4} +{$IFDEF LINUX} + {$DEFINE KYLIX} +{$ENDIF} +TYPE +{$IFNDEF DELPHI} +{$IFNDEF KYLIX} + Pchar = ^char; + Ppchar = ^Pchar; + Psingle = ^single; + Pinteger = ^integer; +{$ENDIF} +{$ENDIF} + Preal = ^real; + Plongint = ^longint; +{___________________________________________________________________________ + * DLL Definitions + ___________________________________________________________________________} +{ + These definitions control the importing and exporting of functions within + the DLL. + + You can prefix your five required callbacks with the PLUGIN_API macro to + declare them as exported C functions. The XPLM_API macro identifies + functions that are provided to you via the plugin SDK. (Link against + XPLM.lib to use these functions.) +} + + + +{___________________________________________________________________________ + * GLOBAL DEFINITIONS + ___________________________________________________________________________} +{ + These definitions are used in all parts of the SDK. +} + + +TYPE + { + XPLMPluginID + + Each plug-in is identified by a unique integer ID. This ID can be used to + disable or enable a plug-in, or discover what plug-in is 'running' at the + time. A plug-in ID is unique within the currently running instance of + X-Plane unless plug-ins are reloaded. Plug-ins may receive a different + unique ID each time they are loaded. This includes the unloading and + reloading of plugins that are part of the user's aircraft. + + For persistent identification of plug-ins, use XPLMFindPluginBySignature in + XPLMUtiltiies.h + + -1 indicates no plug-in. + } + XPLMPluginID = Integer; + PXPLMPluginID = ^XPLMPluginID; + +CONST + { No plugin. } + XPLM_NO_PLUGIN_ID = (-1); + + { X-Plane itself } + XPLM_PLUGIN_XPLANE = (0); + + { The current XPLM revision is 4.00 (400). } + kXPLM_Version = (400); + + { + XPLMKeyFlags + + These bitfields define modifier keys in a platform independent way. When a + key is pressed, a series of messages are sent to your plugin. The down + flag is set in the first of these messages, and the up flag in the last. + While the key is held down, messages are sent with neither to indicate that + the key is being held down as a repeated character. + + The control flag is mapped to the control flag on Macintosh and PC. + Generally X-Plane uses the control key and not the command key on + Macintosh, providing a consistent interface across platforms that does not + necessarily match the Macintosh user interface guidelines. There is not + yet a way for plugins to access the Macintosh control keys without using + #ifdefed code. + } +TYPE + XPLMKeyFlags = ( + { The shift key is down } + xplm_ShiftFlag = 1 + + { The option or alt key is down } + ,xplm_OptionAltFlag = 2 + + { The control key is down* } + ,xplm_ControlFlag = 4 + + { The key is being pressed down } + ,xplm_DownFlag = 8 + + { The key is being released } + ,xplm_UpFlag = 16 + + ); + PXPLMKeyFlags = ^XPLMKeyFlags; + +{___________________________________________________________________________ + * ASCII CONTROL KEY CODES + ___________________________________________________________________________} +{ + These definitions define how various control keys are mapped to ASCII key + codes. Not all key presses generate an ASCII value, so plugin code should + be prepared to see null characters come from the keyboard...this usually + represents a key stroke that has no equivalent ASCII, like a page-down + press. Use virtual key codes to find these key strokes. + + ASCII key codes take into account modifier keys; shift keys will affect + capitals and punctuation; control key combinations may have no vaild ASCII + and produce NULL. To detect control-key combinations, use virtual key + codes, not ASCII keys. +} + + +CONST + XPLM_KEY_RETURN = 13; + + XPLM_KEY_ESCAPE = 27; + + XPLM_KEY_TAB = 9; + + XPLM_KEY_DELETE = 8; + + XPLM_KEY_LEFT = 28; + + XPLM_KEY_RIGHT = 29; + + XPLM_KEY_UP = 30; + + XPLM_KEY_DOWN = 31; + + XPLM_KEY_0 = 48; + + XPLM_KEY_1 = 49; + + XPLM_KEY_2 = 50; + + XPLM_KEY_3 = 51; + + XPLM_KEY_4 = 52; + + XPLM_KEY_5 = 53; + + XPLM_KEY_6 = 54; + + XPLM_KEY_7 = 55; + + XPLM_KEY_8 = 56; + + XPLM_KEY_9 = 57; + + XPLM_KEY_DECIMAL = 46; + +{___________________________________________________________________________ + * VIRTUAL KEY CODES + ___________________________________________________________________________} +{ + These are cross-platform defines for every distinct keyboard press on the + computer. Every physical key on the keyboard has a virtual key code. So + the "two" key on the top row of the main keyboard has a different code from + the "two" key on the numeric key pad. But the 'w' and 'W' character are + indistinguishable by virtual key code because they are the same physical + key (one with and one without the shift key). + + Use virtual key codes to detect keystrokes that do not have ASCII + equivalents, allow the user to map the numeric keypad separately from the + main keyboard, and detect control key and other modifier-key combinations + that generate ASCII control key sequences (many of which are not available + directly via character keys in the SDK). + + To assign virtual key codes we started with the Microsoft set but made some + additions and changes. A few differences: + + 1. Modifier keys are not available as virtual key codes. You cannot get + distinct modifier press and release messages. Please do not try to use + modifier keys as regular keys; doing so will almost certainly interfere + with users' abilities to use the native X-Plane key bindings. + 2. Some keys that do not exist on both Mac and PC keyboards are removed. + 3. Do not assume that the values of these keystrokes are interchangeable + with MS v-keys. +} + + +CONST + XPLM_VK_BACK = $08; + + XPLM_VK_TAB = $09; + + XPLM_VK_CLEAR = $0C; + + XPLM_VK_RETURN = $0D; + + XPLM_VK_ESCAPE = $1B; + + XPLM_VK_SPACE = $20; + + XPLM_VK_PRIOR = $21; + + XPLM_VK_NEXT = $22; + + XPLM_VK_END = $23; + + XPLM_VK_HOME = $24; + + XPLM_VK_LEFT = $25; + + XPLM_VK_UP = $26; + + XPLM_VK_RIGHT = $27; + + XPLM_VK_DOWN = $28; + + XPLM_VK_SELECT = $29; + + XPLM_VK_PRINT = $2A; + + XPLM_VK_EXECUTE = $2B; + + XPLM_VK_SNAPSHOT = $2C; + + XPLM_VK_INSERT = $2D; + + XPLM_VK_DELETE = $2E; + + XPLM_VK_HELP = $2F; + + { XPLM_VK_0 thru XPLM_VK_9 are the same as ASCII '0' thru '9' (0x30 - 0x39) } + XPLM_VK_0 = $30; + + XPLM_VK_1 = $31; + + XPLM_VK_2 = $32; + + XPLM_VK_3 = $33; + + XPLM_VK_4 = $34; + + XPLM_VK_5 = $35; + + XPLM_VK_6 = $36; + + XPLM_VK_7 = $37; + + XPLM_VK_8 = $38; + + XPLM_VK_9 = $39; + + { XPLM_VK_A thru XPLM_VK_Z are the same as ASCII 'A' thru 'Z' (0x41 - 0x5A) } + XPLM_VK_A = $41; + + XPLM_VK_B = $42; + + XPLM_VK_C = $43; + + XPLM_VK_D = $44; + + XPLM_VK_E = $45; + + XPLM_VK_F = $46; + + XPLM_VK_G = $47; + + XPLM_VK_H = $48; + + XPLM_VK_I = $49; + + XPLM_VK_J = $4A; + + XPLM_VK_K = $4B; + + XPLM_VK_L = $4C; + + XPLM_VK_M = $4D; + + XPLM_VK_N = $4E; + + XPLM_VK_O = $4F; + + XPLM_VK_P = $50; + + XPLM_VK_Q = $51; + + XPLM_VK_R = $52; + + XPLM_VK_S = $53; + + XPLM_VK_T = $54; + + XPLM_VK_U = $55; + + XPLM_VK_V = $56; + + XPLM_VK_W = $57; + + XPLM_VK_X = $58; + + XPLM_VK_Y = $59; + + XPLM_VK_Z = $5A; + + XPLM_VK_NUMPAD0 = $60; + + XPLM_VK_NUMPAD1 = $61; + + XPLM_VK_NUMPAD2 = $62; + + XPLM_VK_NUMPAD3 = $63; + + XPLM_VK_NUMPAD4 = $64; + + XPLM_VK_NUMPAD5 = $65; + + XPLM_VK_NUMPAD6 = $66; + + XPLM_VK_NUMPAD7 = $67; + + XPLM_VK_NUMPAD8 = $68; + + XPLM_VK_NUMPAD9 = $69; + + XPLM_VK_MULTIPLY = $6A; + + XPLM_VK_ADD = $6B; + + XPLM_VK_SEPARATOR = $6C; + + XPLM_VK_SUBTRACT = $6D; + + XPLM_VK_DECIMAL = $6E; + + XPLM_VK_DIVIDE = $6F; + + XPLM_VK_F1 = $70; + + XPLM_VK_F2 = $71; + + XPLM_VK_F3 = $72; + + XPLM_VK_F4 = $73; + + XPLM_VK_F5 = $74; + + XPLM_VK_F6 = $75; + + XPLM_VK_F7 = $76; + + XPLM_VK_F8 = $77; + + XPLM_VK_F9 = $78; + + XPLM_VK_F10 = $79; + + XPLM_VK_F11 = $7A; + + XPLM_VK_F12 = $7B; + + XPLM_VK_F13 = $7C; + + XPLM_VK_F14 = $7D; + + XPLM_VK_F15 = $7E; + + XPLM_VK_F16 = $7F; + + XPLM_VK_F17 = $80; + + XPLM_VK_F18 = $81; + + XPLM_VK_F19 = $82; + + XPLM_VK_F20 = $83; + + XPLM_VK_F21 = $84; + + XPLM_VK_F22 = $85; + + XPLM_VK_F23 = $86; + + XPLM_VK_F24 = $87; + + { The following definitions are extended and are not based on the Microsoft } + { key set. } + XPLM_VK_EQUAL = $B0; + + XPLM_VK_MINUS = $B1; + + XPLM_VK_RBRACE = $B2; + + XPLM_VK_LBRACE = $B3; + + XPLM_VK_QUOTE = $B4; + + XPLM_VK_SEMICOLON = $B5; + + XPLM_VK_BACKSLASH = $B6; + + XPLM_VK_COMMA = $B7; + + XPLM_VK_SLASH = $B8; + + XPLM_VK_PERIOD = $B9; + + XPLM_VK_BACKQUOTE = $BA; + + XPLM_VK_ENTER = $BB; + + XPLM_VK_NUMPAD_ENT = $BC; + + XPLM_VK_NUMPAD_EQ = $BD; + + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/SDKold/Delphi/XPLM/XPLMDisplay.pas b/XPLPro_Plugin_Source/SDK/SDKold/Delphi/XPLM/XPLMDisplay.pas new file mode 100644 index 0000000..ee4242c --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDKold/Delphi/XPLM/XPLMDisplay.pas @@ -0,0 +1,1630 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPLMDisplay; +INTERFACE +{ + This API provides the basic hooks to draw in X-Plane and create user + interface. All X-Plane drawing is done in OpenGL. The X-Plane plug-in + manager takes care of properly setting up the OpenGL context and matrices. + You do not decide when in your code's execution to draw; X-Plane tells you + (via callbacks) when it is ready to have your plugin draw. + + X-Plane's drawing strategy is straightforward: every "frame" the screen is + rendered by drawing the 3-D scene (dome, ground, objects, airplanes, etc.) + and then drawing the cockpit on top of it. Alpha blending is used to + overlay the cockpit over the world (and the gauges over the panel, etc.). + X-Plane user interface elements (including windows like the map, the main + menu, etc.) are then drawn on top of the cockpit. + + There are two ways you can draw: directly and in a window. + + Direct drawing (deprecated!---more on that below) involves drawing to the + screen before or after X-Plane finishes a phase of drawing. When you draw + directly, you can specify whether X-Plane is to complete this phase or not. + This allows you to do three things: draw before X-Plane does (under it), + draw after X-Plane does (over it), or draw instead of X-Plane. + + To draw directly, you register a callback and specify which phase you want + to intercept. The plug-in manager will call you over and over to draw that + phase. + + Direct drawing allows you to override scenery, panels, or anything. Note + that you cannot assume that you are the only plug-in drawing at this phase. + + Direct drawing is deprecated; at some point in the X-Plane 11 run, it will + likely become unsupported entirely as X-Plane transitions from OpenGL to + modern graphics API backends (e.g., Vulkan, Metal, etc.). In the long term, + plugins should use the XPLMInstance API for drawing 3-D objects---this will + be much more efficient than general 3-D OpenGL drawing, and it will + actually be supported by the new graphics backends. We do not yet know what + the post-transition API for generic 3-D drawing will look like (if it + exists at all). + + In contrast to direct drawing, window drawing provides a higher level + functionality. With window drawing, you create a 2-D window that takes up a + portion of the screen. Window drawing is always two dimensional. Window + drawing is front-to-back controlled; you can specify that you want your + window to be brought on top, and other plug-ins may put their window on top + of you. Window drawing also allows you to sign up for key presses and + receive mouse clicks. + + Drawing into the screen of an avionics device, like a GPS or a Primary + Flight Display, is a way to extend or replace X-Plane's avionics. Most + screens can be displayed both in a 3d cockpit or + 2d panel, and also in separate popup windows. By installing drawing + callbacks for a certain avionics device, you can change or extend the + appearance of that device regardless whether it's installed in a 3d + cockpit or used in a separate display for home cockpits because you leave + the window managing to X-Plane. + + There are three ways to get keystrokes: + + 1. If you create a window, the window can take keyboard focus. It will + then receive all keystrokes. If no window has focus, X-Plane receives + keystrokes. Use this to implement typing in dialog boxes, etc. Only + one window may have focus at a time; your window will be notified if it + loses focus. + 2. If you need low level access to the keystroke stream, install a key + sniffer. Key sniffers can be installed above everything or right in + front of the sim. + 3. If you would like to associate key strokes with commands/functions in + your plug-in, you should simply register a command (via + XPLMCreateCommand()) and allow users to bind whatever key they choose to + that command. Another (now deprecated) method of doing so is to use a + hot key---a key-specific callback. Hotkeys are sent based on virtual + key strokes, so any key may be distinctly mapped with any modifiers. + Hot keys can be remapped by other plug-ins. As a plug-in, you don't + have to worry about what your hot key ends up mapped to; other plug-ins + may provide a UI for remapping keystrokes. So hotkeys allow a user to + resolve conflicts and customize keystrokes. +} + +USES + XPLMDefs; + {$A4} +{___________________________________________________________________________ + * DRAWING CALLBACKS + ___________________________________________________________________________} +{ + Basic drawing callbacks, for low level intercepting of X-Plane's render + loop. The purpose of drawing callbacks is to provide targeted additions or + replacements to X-Plane's graphics environment (for example, to add extra + custom objects, or replace drawing of the AI aircraft). Do not assume that + the drawing callbacks will be called in the order implied by the + enumerations. Also do not assume that each drawing phase ends before + another begins; they may be nested. + + Note that all APIs in this section are deprecated, and will likely be + removed during the X-Plane 11 run as part of the transition to + Vulkan/Metal/etc. See the XPLMInstance API for future-proof drawing of 3-D + objects. +} + + + { + XPLMDrawingPhase + + This constant indicates which part of drawing we are in. Drawing is done + from the back to the front. We get a callback before or after each item. + Metaphases provide access to the beginning and end of the 3d (scene) and + 2d (cockpit) drawing in a manner that is independent of new phases added + via X-Plane implementation. + + **NOTE**: As of XPLM302 the legacy 3D drawing phases (xplm_Phase_FirstScene + to xplm_Phase_LastScene) are deprecated. When running under X-Plane 11.50 + with the modern Vulkan or Metal backend, X-Plane will no longer call + these drawing phases. There is a new drawing phase, xplm_Phase_Modern3D, + which is supported under OpenGL and Vulkan which is called out roughly + where the old before xplm_Phase_Airplanes phase was for blending. This + phase is *NOT* supported under Metal and comes with potentially + substantial performance overhead. Please do *NOT* opt into this phase if + you don't do any actual drawing that requires the depth buffer in some + way! + + **WARNING**: As X-Plane's scenery evolves, some drawing phases may cease to + exist and new ones may be invented. If you need a particularly specific + use of these codes, consult Austin and/or be prepared to revise your code + as X-Plane evolves. + } +TYPE + XPLMDrawingPhase = ( +{$IFDEF XPLM_DEPRECATED} + { Deprecated as of XPLM302. This is the earliest point at which you can draw } + { in 3-d. } + xplm_Phase_FirstScene = 0 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated as of XPLM302. Drawing of land and water. } + ,xplm_Phase_Terrain = 5 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated as of XPLM302. Drawing runways and other airport detail. } + ,xplm_Phase_Airports = 10 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated as of XPLM302. Drawing roads, trails, trains, etc. } + ,xplm_Phase_Vectors = 15 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated as of XPLM302. 3-d objects (houses, smokestacks, etc. } + ,xplm_Phase_Objects = 20 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated as of XPLM302. External views of airplanes, both yours and the } + { AI aircraft. } + ,xplm_Phase_Airplanes = 25 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated as of XPLM302. This is the last point at which you can draw in } + { 3-d. } + ,xplm_Phase_LastScene = 30 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM302} + { A chance to do modern 3D drawing. } + ,xplm_Phase_Modern3D = 31 +{$ENDIF XPLM302} + + { This is the first phase where you can draw in 2-d. } + ,xplm_Phase_FirstCockpit = 35 + + { The non-moving parts of the aircraft panel. } + ,xplm_Phase_Panel = 40 + + { The moving parts of the aircraft panel. } + ,xplm_Phase_Gauges = 45 + + { Floating windows from plugins. } + ,xplm_Phase_Window = 50 + + { The last chance to draw in 2d. } + ,xplm_Phase_LastCockpit = 55 + +{$IFDEF XPLM200} + { Removed as of XPLM300; Use the full-blown XPLMMap API instead. } + ,xplm_Phase_LocalMap3D = 100 +{$ENDIF XPLM200} + +{$IFDEF XPLM200} + { Removed as of XPLM300; Use the full-blown XPLMMap API instead. } + ,xplm_Phase_LocalMap2D = 101 +{$ENDIF XPLM200} + +{$IFDEF XPLM200} + { Removed as of XPLM300; Use the full-blown XPLMMap API instead. } + ,xplm_Phase_LocalMapProfile = 102 +{$ENDIF XPLM200} + + ); + PXPLMDrawingPhase = ^XPLMDrawingPhase; + + { + XPLMDrawCallback_f + + This is the prototype for a low level drawing callback. You are passed in + the phase and whether it is before or after. If you are before the phase, + return 1 to let X-Plane draw or 0 to suppress X-Plane drawing. If you are + after the phase the return value is ignored. + + Refcon is a unique value that you specify when registering the callback, + allowing you to slip a pointer to your own data to the callback. + + Upon entry the OpenGL context will be correctly set up for you and OpenGL + will be in 'local' coordinates for 3d drawing and panel coordinates for 2d + drawing. The OpenGL state (texturing, etc.) will be unknown. + } + XPLMDrawCallback_f = FUNCTION( + inPhase : XPLMDrawingPhase; + inIsBefore : Integer; + inRefcon : pointer) : Integer; cdecl; + + { + XPLMRegisterDrawCallback + + This routine registers a low level drawing callback. Pass in the phase you + want to be called for and whether you want to be called before or after. + This routine returns 1 if the registration was successful, or 0 if the + phase does not exist in this version of X-Plane. You may register a + callback multiple times for the same or different phases as long as the + refcon is unique each time. + + Note that this function will likely be removed during the X-Plane 11 run as + part of the transition to Vulkan/Metal/etc. See the XPLMInstance API for + future-proof drawing of 3-D objects. + } + FUNCTION XPLMRegisterDrawCallback( + inCallback : XPLMDrawCallback_f; + inPhase : XPLMDrawingPhase; + inWantsBefore : Integer; + inRefcon : pointer) : Integer; + cdecl; external XPLM_DLL; + + { + XPLMUnregisterDrawCallback + + This routine unregisters a draw callback. You must unregister a callback + for each time you register a callback if you have registered it multiple + times with different refcons. The routine returns 1 if it can find the + callback to unregister, 0 otherwise. + + Note that this function will likely be removed during the X-Plane 11 run as + part of the transition to Vulkan/Metal/etc. See the XPLMInstance API for + future-proof drawing of 3-D objects. + } + FUNCTION XPLMUnregisterDrawCallback( + inCallback : XPLMDrawCallback_f; + inPhase : XPLMDrawingPhase; + inWantsBefore : Integer; + inRefcon : pointer) : Integer; + cdecl; external XPLM_DLL; + +{$IFDEF XPLM400} +{___________________________________________________________________________ + * AVIONICS API + ___________________________________________________________________________} +{ + Drawing callbacks for before and after X-Plane draws the instrument screen + can be registered for every cockpit device. If the user plane does not + have the device installed, your callback will not be called! Use the + return value to enable or disable X-Plane's drawing. By drawing into the + framebuffer of the avionics device, your modifications will be visible + regardless whether the device's screen is in a 3d cockpit or a popup + window. +} + + + { + XPLMDeviceID + + This constant indicates the device we want to override or enhance. We can + get a callback before or after each item. + } +TYPE + XPLMDeviceID = ( + { GNS430, pilot side. } + xplm_device_GNS430_1 = 0 + + { GNS430, copilot side. } + ,xplm_device_GNS430_2 = 1 + + { GNS530, pilot side. } + ,xplm_device_GNS530_1 = 2 + + { GNS530, copilot side. } + ,xplm_device_GNS530_2 = 3 + + { generic airliner CDU, pilot side. } + ,xplm_device_CDU739_1 = 4 + + { generic airliner CDU, copilot side. } + ,xplm_device_CDU739_2 = 5 + + { G1000 Primary Flight Display, pilot side. } + ,xplm_device_G1000_PFD_1 = 6 + + { G1000 Multifunction Display. } + ,xplm_device_G1000_MFD = 7 + + { G1000 Primary Flight Display, copilot side. } + ,xplm_device_G1000_PFD_2 = 8 + + { Primus CDU, pilot side. } + ,xplm_device_CDU815_1 = 9 + + { Primus CDU, copilot side. } + ,xplm_device_CDU815_2 = 10 + + { Primus Primary Flight Display, pilot side. } + ,xplm_device_Primus_PFD_1 = 11 + + { Primus Primary Flight Display, copilot side. } + ,xplm_device_Primus_PFD_2 = 12 + + { Primus Multifunction Display, pilot side. } + ,xplm_device_Primus_MFD_1 = 13 + + { Primus Multifunction Display, copilot side. } + ,xplm_device_Primus_MFD_2 = 14 + + { Primus Multifunction Display, central. } + ,xplm_device_Primus_MFD_3 = 15 + + { Primus Radio Management Unit, pilot side. } + ,xplm_device_Primus_RMU_1 = 16 + + { Primus Radio Management Unit, copilot side. } + ,xplm_device_Primus_RMU_2 = 17 + + ); + PXPLMDeviceID = ^XPLMDeviceID; + + { + XPLMAvionicsCallback_f + + This is the prototype for your drawing callback. You are passed in the + device you are enhancing/replacing, and whether it is before or after + X-Plane drawing. If you are before X-Plane, return 1 to let X-Plane draw or + 0 to suppress X-Plane drawing. If you are after the phase the return value + is ignored. + + Refcon is a unique value that you specify when registering the callback, + allowing you to slip a pointer to your own data to the callback. + + Upon entry the OpenGL context will be correctly set up for you and OpenGL + will be in panel coordinates for 2d drawing. The OpenGL state (texturing, + etc.) will be unknown. + } + XPLMAvionicsCallback_f = FUNCTION( + inDeviceID : XPLMDeviceID; + inIsBefore : Integer; + inRefcon : pointer) : Integer; cdecl; + + { + XPLMAvionicsID + + This is an opaque identifier for an avionics display that you enhance or + replace. When you register your callbacks (via + XPLMRegisterAvionicsCallbacksEx()), you will specify callbacks to handle + drawing, and get back such a handle. + } + XPLMAvionicsID = pointer; + PXPLMAvionicsID = ^XPLMAvionicsID; + + { + XPLMCustomizeAvionics_t + + The XPLMCustomizeAvionics_t structure defines all of the parameters used to + replace or enhance avionics for using XPLMRegisterAvionicsCallbacksEx(). + The structure will be expanded in future SDK APIs to include more features. + Always set the structSize member to the size of your struct in bytes! + } + XPLMCustomizeAvionics_t = RECORD + { Used to inform XPLMRegisterAvionicsCallbacksEx() of the SDK version you } + { compiled against; should always be set to sizeof(XPLMCustomizeAvionics_t) } + structSize : Integer; + { Which avionics device you want your drawing applied to. } + deviceId : XPLMDeviceID; + { The draw callback to be called before X-Plane draws. } + drawCallbackBefore : XPLMAvionicsCallback_f; + { The draw callback to be called after X-Plane has drawn. } + drawCallbackAfter : XPLMAvionicsCallback_f; + { A reference which will be passed into each of your draw callbacks. Use this} + { to pass information to yourself as needed. } + refcon : pointer; + END; + PXPLMCustomizeAvionics_t = ^XPLMCustomizeAvionics_t; + + { + XPLMRegisterAvionicsCallbacksEx + + This routine registers your callbacks for a device. This returns a handle. + If the returned handle is NULL, there was a problem interpreting your + input, most likely the struct size was wrong for your SDK version. If the + returned handle is not NULL, your callbacks will be called according to + schedule as long as your plugin is not deactivated, or unloaded, or your + call XPLMUnregisterAvionicsCallbacks(). + } + FUNCTION XPLMRegisterAvionicsCallbacksEx( + inParams : PXPLMCustomizeAvionics_t) : XPLMAvionicsID; + cdecl; external XPLM_DLL; + + { + XPLMUnregisterAvionicsCallbacks + + This routine unregisters your callbacks for a device. They will no longer + be called. + } + PROCEDURE XPLMUnregisterAvionicsCallbacks( + inAvionicsId : XPLMAvionicsID); + cdecl; external XPLM_DLL; + +{$ENDIF XPLM400} +{___________________________________________________________________________ + * WINDOW API + ___________________________________________________________________________} +{ + The window API provides a high-level abstraction for drawing with UI + interaction. + + Windows may operate in one of two modes: legacy (for plugins compiled + against old versions of the XPLM, as well as windows created via the + deprecated XPLMCreateWindow() function, rather than XPLMCreateWindowEx()), + or modern (for windows compiled against the XPLM300 or newer API, and + created via XPLMCreateWindowEx()). + + Modern windows have access to new X-Plane 11 windowing features, like + support for new positioning modes (including being "popped out" into their + own first-class window in the operating system). They can also optionally + be decorated in the style of X-Plane 11 windows (like the map). + + Modern windows operate in "boxel" units. A boxel ("box of pixels") is a + unit of virtual pixels which, depending on X-Plane's scaling, may + correspond to an arbitrary NxN "box" of real pixels on screen. Because + X-Plane handles this scaling automatically, you can effectively treat the + units as though you were simply drawing in pixels, and know that when + X-Plane is running with 150% or 200% scaling, your drawing will be + automatically scaled (and likewise all mouse coordinates, screen bounds, + etc. will also be auto-scaled). + + In contrast, legacy windows draw in true screen pixels, and thus tend to + look quite small when X-Plane is operating in a scaled mode. + + Legacy windows have their origin in the lower left of the main X-Plane + window. In contrast, since modern windows are not constrained to the main + window, they have their origin in the lower left of the entire global + desktop space, and the lower left of the main X-Plane window is not + guaranteed to be (0, 0). In both cases, x increases as you move left, and y + increases as you move up. +} + + +TYPE + { + XPLMWindowID + + This is an opaque identifier for a window. You use it to control your + window. When you create a window (via either XPLMCreateWindow() or + XPLMCreateWindowEx()), you will specify callbacks to handle drawing, mouse + interaction, etc. + } + XPLMWindowID = pointer; + PXPLMWindowID = ^XPLMWindowID; + + { + XPLMDrawWindow_f + + A callback to handle 2-D drawing of your window. You are passed in your + window and its refcon. Draw the window. You can use other XPLM functions + from this header to find the current dimensions of your window, etc. When + this callback is called, the OpenGL context will be set properly for 2-D + window drawing. + + **Note**: Because you are drawing your window over a background, you can + make a translucent window easily by simply not filling in your entire + window's bounds. + } + XPLMDrawWindow_f = PROCEDURE( + inWindowID : XPLMWindowID; + inRefcon : pointer); cdecl; + + { + XPLMHandleKey_f + + This function is called when a key is pressed or keyboard focus is taken + away from your window. If losingFocus is 1, you are losing the keyboard + focus, otherwise a key was pressed and inKey contains its character. + + The window ID passed in will be your window for key presses, or the other + window taking focus when losing focus. Note that in the modern plugin + system, often focus is taken by the window manager itself; for this resaon, + the window ID may be zero when losing focus, and you should not write code + that depends onit. + + The refcon passed in will be the one from registration, for both key + presses and losing focus. + + Warning: this API declares virtual keys as a signed character; however the + VKEY #define macros in XPLMDefs.h define the vkeys using unsigned values + (that is 0x80 instead of -0x80). So you may need to cast the incoming vkey + to an unsigned char to get correct comparisons in C. + } + XPLMHandleKey_f = PROCEDURE( + inWindowID : XPLMWindowID; + inKey : XPLMChar; + inFlags : XPLMKeyFlags; + inVirtualKey : XPLMChar; + inRefcon : pointer; + losingFocus : Integer); cdecl; + + { + XPLMMouseStatus + + When the mouse is clicked, your mouse click routine is called repeatedly. + It is first called with the mouse down message. It is then called zero or + more times with the mouse-drag message, and finally it is called once with + the mouse up message. All of these messages will be directed to the same + window; you are guaranteed to not receive a drag or mouse-up event without + first receiving the corresponding mouse-down. + } + XPLMMouseStatus = ( + xplm_MouseDown = 1 + + ,xplm_MouseDrag = 2 + + ,xplm_MouseUp = 3 + + ); + PXPLMMouseStatus = ^XPLMMouseStatus; + + { + XPLMHandleMouseClick_f + + You receive this call for one of three events: + + - when the user clicks the mouse button down + - (optionally) when the user drags the mouse after a down-click, but before + the up-click + - when the user releases the down-clicked mouse button. + + You receive the x and y of the click, your window, and a refcon. Return 1 + to consume the click, or 0 to pass it through. + + WARNING: passing clicks through windows (as of this writing) causes mouse + tracking problems in X-Plane; do not use this feature! + + The units for x and y values match the units used in your window. Thus, for + "modern" windows (those created via XPLMCreateWindowEx() and compiled + against the XPLM300 library), the units are boxels, while legacy windows + will get pixels. Legacy windows have their origin in the lower left of the + main X-Plane window, while modern windows have their origin in the lower + left of the global desktop space. In both cases, x increases as you move + right, and y increases as you move up. + } + XPLMHandleMouseClick_f = FUNCTION( + inWindowID : XPLMWindowID; + x : Integer; + y : Integer; + inMouse : XPLMMouseStatus; + inRefcon : pointer) : Integer; cdecl; + +{$IFDEF XPLM200} + { + XPLMCursorStatus + + XPLMCursorStatus describes how you would like X-Plane to manage the cursor. + See XPLMHandleCursor_f for more info. + } +TYPE + XPLMCursorStatus = ( + { X-Plane manages the cursor normally, plugin does not affect the cusrsor. } + xplm_CursorDefault = 0 + + { X-Plane hides the cursor. } + ,xplm_CursorHidden = 1 + + { X-Plane shows the cursor as the default arrow. } + ,xplm_CursorArrow = 2 + + { X-Plane shows the cursor but lets you select an OS cursor. } + ,xplm_CursorCustom = 3 + + ); + PXPLMCursorStatus = ^XPLMCursorStatus; +{$ENDIF XPLM200} + +{$IFDEF XPLM200} + { + XPLMHandleCursor_f + + The SDK calls your cursor status callback when the mouse is over your + plugin window. Return a cursor status code to indicate how you would like + X-Plane to manage the cursor. If you return xplm_CursorDefault, the SDK + will try lower-Z-order plugin windows, then let the sim manage the cursor. + + Note: you should never show or hide the cursor yourself---these APIs are + typically reference-counted and thus cannot safely and predictably be used + by the SDK. Instead return one of xplm_CursorHidden to hide the cursor or + xplm_CursorArrow/xplm_CursorCustom to show the cursor. + + If you want to implement a custom cursor by drawing a cursor in OpenGL, use + xplm_CursorHidden to hide the OS cursor and draw the cursor using a 2-d + drawing callback (after xplm_Phase_Window is probably a good choice, but + see deprecation warnings on the drawing APIs!). If you want to use a + custom OS-based cursor, use xplm_CursorCustom to ask X-Plane to show the + cursor but not affect its image. You can then use an OS specific call like + SetThemeCursor (Mac) or SetCursor/LoadCursor (Windows). + + The units for x and y values match the units used in your window. Thus, for + "modern" windows (those created via XPLMCreateWindowEx() and compiled + against the XPLM300 library), the units are boxels, while legacy windows + will get pixels. Legacy windows have their origin in the lower left of the + main X-Plane window, while modern windows have their origin in the lower + left of the global desktop space. In both cases, x increases as you move + right, and y increases as you move up. + } + XPLMHandleCursor_f = FUNCTION( + inWindowID : XPLMWindowID; + x : Integer; + y : Integer; + inRefcon : pointer) : XPLMCursorStatus; cdecl; +{$ENDIF XPLM200} + +{$IFDEF XPLM200} + { + XPLMHandleMouseWheel_f + + The SDK calls your mouse wheel callback when one of the mouse wheels is + scrolled within your window. Return 1 to consume the mouse wheel movement + or 0 to pass them on to a lower window. (If your window appears opaque to + the user, you should consume mouse wheel scrolling even if it does + nothing.) The number of "clicks" indicates how far the wheel was turned + since the last callback. The wheel is 0 for the vertical axis or 1 for the + horizontal axis (for OS/mouse combinations that support this). + + The units for x and y values match the units used in your window. Thus, for + "modern" windows (those created via XPLMCreateWindowEx() and compiled + against the XPLM300 library), the units are boxels, while legacy windows + will get pixels. Legacy windows have their origin in the lower left of the + main X-Plane window, while modern windows have their origin in the lower + left of the global desktop space. In both cases, x increases as you move + right, and y increases as you move up. + } + XPLMHandleMouseWheel_f = FUNCTION( + inWindowID : XPLMWindowID; + x : Integer; + y : Integer; + wheel : Integer; + clicks : Integer; + inRefcon : pointer) : Integer; cdecl; +{$ENDIF XPLM200} + +{$IFDEF XPLM300} + { + XPLMWindowLayer + + XPLMWindowLayer describes where in the ordering of windows X-Plane should + place a particular window. Windows in higher layers cover windows in lower + layers. So, a given window might be at the top of its particular layer, but + it might still be obscured by a window in a higher layer. (This happens + frequently when floating windows, like X-Plane's map, are covered by a + modal alert.) + + Your window's layer can only be specified when you create the window (in + the XPLMCreateWindow_t you pass to XPLMCreateWindowEx()). For this reason, + layering only applies to windows created with new X-Plane 11 GUI features. + (Windows created using the older XPLMCreateWindow(), or windows compiled + against a pre-XPLM300 version of the SDK will simply be placed in the + flight overlay window layer.) + } +TYPE + XPLMWindowLayer = ( + { The lowest layer, used for HUD-like displays while flying. } + xplm_WindowLayerFlightOverlay = 0 + + { Windows that "float" over the sim, like the X-Plane 11 map does. If you are} + { not sure which layer to create your window in, choose floating. } + ,xplm_WindowLayerFloatingWindows = 1 + + { An interruptive modal that covers the sim with a transparent black overlay } + { to draw the user's focus to the alert } + ,xplm_WindowLayerModal = 2 + + { "Growl"-style notifications that are visible in a corner of the screen, } + { even over modals } + ,xplm_WindowLayerGrowlNotifications = 3 + + ); + PXPLMWindowLayer = ^XPLMWindowLayer; +{$ENDIF XPLM300} + +{$IFDEF XPLM301} + { + XPLMWindowDecoration + + XPLMWindowDecoration describes how "modern" windows will be displayed. This + impacts both how X-Plane draws your window as well as certain mouse + handlers. + + Your window's decoration can only be specified when you create the window + (in the XPLMCreateWindow_t you pass to XPLMCreateWindowEx()). + } +TYPE + XPLMWindowDecoration = ( + { X-Plane will draw no decoration for your window, and apply no automatic } + { click handlers. The window will not stop click from passing through its } + { bounds. This is suitable for "windows" which request, say, the full screen } + { bounds, then only draw in a small portion of the available area. } + xplm_WindowDecorationNone = 0 + + { The default decoration for "native" windows, like the map. Provides a solid} + { background, as well as click handlers for resizing and dragging the window.} + ,xplm_WindowDecorationRoundRectangle = 1 + + { X-Plane will draw no decoration for your window, nor will it provide resize} + { handlers for your window edges, but it will stop clicks from passing } + { through your windows bounds. } + ,xplm_WindowDecorationSelfDecorated = 2 + + { Like self-decorated, but with resizing; X-Plane will draw no decoration for} + { your window, but it will stop clicks from passing through your windows } + { bounds, and provide automatic mouse handlers for resizing. } + ,xplm_WindowDecorationSelfDecoratedResizable = 3 + + ); + PXPLMWindowDecoration = ^XPLMWindowDecoration; +{$ENDIF XPLM301} + +{$IFDEF XPLM200} + { + XPLMCreateWindow_t + + The XPMCreateWindow_t structure defines all of the parameters used to + create a modern window using XPLMCreateWindowEx(). The structure will be + expanded in future SDK APIs to include more features. Always set the + structSize member to the size of your struct in bytes! + + All windows created by this function in the XPLM300 version of the API are + created with the new X-Plane 11 GUI features. This means your plugin will + get to "know" about the existence of X-Plane windows other than the main + window. All drawing and mouse callbacks for your window will occur in + "boxels," giving your windows automatic support for high-DPI scaling in + X-Plane. In addition, your windows can opt-in to decoration with the + X-Plane 11 window styling, and you can use the + XPLMSetWindowPositioningMode() API to make your window "popped out" into a + first-class operating system window. + + Note that this requires dealing with your window's bounds in "global + desktop" positioning units, rather than the traditional panel coordinate + system. In global desktop coordinates, the main X-Plane window may not have + its origin at coordinate (0, 0), and your own window may have negative + coordinates. Assuming you don't implicitly assume (0, 0) as your origin, + the only API change you should need is to start using + XPLMGetMouseLocationGlobal() rather than XPLMGetMouseLocation(), and + XPLMGetScreenBoundsGlobal() instead of XPLMGetScreenSize(). + + If you ask to be decorated as a floating window, you'll get the blue window + control bar and blue backing that you see in X-Plane 11's normal "floating" + windows (like the map). + } +TYPE + XPLMCreateWindow_t = RECORD + { Used to inform XPLMCreateWindowEx() of the SDK version you compiled } + { against; should always be set to sizeof(XPLMCreateWindow_t) } + structSize : Integer; + { Left bound, in global desktop boxels } + left : Integer; + { Top bound, in global desktop boxels } + top : Integer; + { Right bound, in global desktop boxels } + right : Integer; + { Bottom bound, in global desktop boxels } + bottom : Integer; + visible : Integer; + drawWindowFunc : XPLMDrawWindow_f; + { A callback to handle the user left-clicking within your window (or NULL to } + { ignore left clicks) } + handleMouseClickFunc : XPLMHandleMouseClick_f; + handleKeyFunc : XPLMHandleKey_f; + handleCursorFunc : XPLMHandleCursor_f; + handleMouseWheelFunc : XPLMHandleMouseWheel_f; + { A reference which will be passed into each of your window callbacks. Use } + { this to pass information to yourself as needed. } + refcon : pointer; +{$IFDEF XPLM301} + { Specifies the type of X-Plane 11-style "wrapper" you want around your } + { window, if any } + decorateAsFloatingWindow : XPLMWindowDecoration; +{$ENDIF XPLM301} +{$IFDEF XPLM300} + layer : XPLMWindowLayer; +{$ENDIF XPLM300} +{$IFDEF XPLM300} + { A callback to handle the user right-clicking within your window (or NULL to} + { ignore right clicks) } + handleRightClickFunc : XPLMHandleMouseClick_f; +{$ENDIF XPLM300} + END; + PXPLMCreateWindow_t = ^XPLMCreateWindow_t; +{$ENDIF XPLM200} + +{$IFDEF XPLM200} + { + XPLMCreateWindowEx + + This routine creates a new "modern" window. You pass in an + XPLMCreateWindow_t structure with all of the fields set in. You must set + the structSize of the structure to the size of the actual structure you + used. Also, you must provide functions for every callback---you may not + leave them null! (If you do not support the cursor or mouse wheel, use + functions that return the default values.) + } + FUNCTION XPLMCreateWindowEx( + inParams : PXPLMCreateWindow_t) : XPLMWindowID; + cdecl; external XPLM_DLL; +{$ENDIF XPLM200} + + { + XPLMCreateWindow + + Deprecated as of XPLM300. + + This routine creates a new legacy window. Unlike modern windows (created + via XPLMCreateWindowEx()), legacy windows do not have access to X-Plane 11 + features like automatic scaling for high-DPI screens, native window styles, + or support for being "popped out" into first-class operating system + windows. + + Pass in the dimensions and offsets to the window's bottom left corner from + the bottom left of the screen. You can specify whether the window is + initially visible or not. Also, you pass in three callbacks to run the + window and a refcon. This function returns a window ID you can use to + refer to the new window. + + NOTE: Legacy windows do not have "frames"; you are responsible for drawing + the background and frame of the window. Higher level libraries have + routines which make this easy. + } + FUNCTION XPLMCreateWindow( + inLeft : Integer; + inTop : Integer; + inRight : Integer; + inBottom : Integer; + inIsVisible : Integer; + inDrawCallback : XPLMDrawWindow_f; + inKeyCallback : XPLMHandleKey_f; + inMouseCallback : XPLMHandleMouseClick_f; + inRefcon : pointer) : XPLMWindowID; + cdecl; external XPLM_DLL; + + { + XPLMDestroyWindow + + This routine destroys a window. The window's callbacks are not called + after this call. Keyboard focus is removed from the window before + destroying it. + } + PROCEDURE XPLMDestroyWindow( + inWindowID : XPLMWindowID); + cdecl; external XPLM_DLL; + + { + XPLMGetScreenSize + + This routine returns the size of the main X-Plane OpenGL window in pixels. + This number can be used to get a rough idea of the amount of detail the + user will be able to see when drawing in 3-d. + } + PROCEDURE XPLMGetScreenSize( + outWidth : PInteger; { Can be nil } + outHeight : PInteger); { Can be nil } + cdecl; external XPLM_DLL; + +{$IFDEF XPLM300} + { + XPLMGetScreenBoundsGlobal + + This routine returns the bounds of the "global" X-Plane desktop, in boxels. + Unlike the non-global version XPLMGetScreenSize(), this is multi-monitor + aware. There are three primary consequences of multimonitor awareness. + + First, if the user is running X-Plane in full-screen on two or more + monitors (typically configured using one full-screen window per monitor), + the global desktop will be sized to include all X-Plane windows. + + Second, the origin of the screen coordinates is not guaranteed to be (0, + 0). Suppose the user has two displays side-by-side, both running at 1080p. + Suppose further that they've configured their OS to make the left display + their "primary" monitor, and that X-Plane is running in full-screen on + their right monitor only. In this case, the global desktop bounds would be + the rectangle from (1920, 0) to (3840, 1080). If the user later asked + X-Plane to draw on their primary monitor as well, the bounds would change + to (0, 0) to (3840, 1080). + + Finally, if the usable area of the virtual desktop is not a perfect + rectangle (for instance, because the monitors have different resolutions or + because one monitor is configured in the operating system to be above and + to the right of the other), the global desktop will include any wasted + space. Thus, if you have two 1080p monitors, and monitor 2 is configured to + have its bottom left touch monitor 1's upper right, your global desktop + area would be the rectangle from (0, 0) to (3840, 2160). + + Note that popped-out windows (windows drawn in their own operating system + windows, rather than "floating" within X-Plane) are not included in these + bounds. + } + PROCEDURE XPLMGetScreenBoundsGlobal( + outLeft : PInteger; { Can be nil } + outTop : PInteger; { Can be nil } + outRight : PInteger; { Can be nil } + outBottom : PInteger); { Can be nil } + cdecl; external XPLM_DLL; +{$ENDIF XPLM300} + +{$IFDEF XPLM300} + { + XPLMReceiveMonitorBoundsGlobal_f + + This function is informed of the global bounds (in boxels) of a particular + monitor within the X-Plane global desktop space. Note that X-Plane must be + running in full screen on a monitor in order for that monitor to be passed + to you in this callback. + } +TYPE + XPLMReceiveMonitorBoundsGlobal_f = PROCEDURE( + inMonitorIndex : Integer; + inLeftBx : Integer; + inTopBx : Integer; + inRightBx : Integer; + inBottomBx : Integer; + inRefcon : pointer); cdecl; +{$ENDIF XPLM300} + +{$IFDEF XPLM300} + { + XPLMGetAllMonitorBoundsGlobal + + This routine immediately calls you back with the bounds (in boxels) of each + full-screen X-Plane window within the X-Plane global desktop space. Note + that if a monitor is *not* covered by an X-Plane window, you cannot get its + bounds this way. Likewise, monitors with only an X-Plane window (not in + full-screen mode) will not be included. + + If X-Plane is running in full-screen and your monitors are of the same size + and configured contiguously in the OS, then the combined global bounds of + all full-screen monitors will match the total global desktop bounds, as + returned by XPLMGetScreenBoundsGlobal(). (Of course, if X-Plane is running + in windowed mode, this will not be the case. Likewise, if you have + differently sized monitors, the global desktop space will include wasted + space.) + + Note that this function's monitor indices match those provided by + XPLMGetAllMonitorBoundsOS(), but the coordinates are different (since the + X-Plane global desktop may not match the operating system's global desktop, + and one X-Plane boxel may be larger than one pixel due to 150% or 200% + scaling). + } + PROCEDURE XPLMGetAllMonitorBoundsGlobal( + inMonitorBoundsCallback: XPLMReceiveMonitorBoundsGlobal_f; + inRefcon : pointer); + cdecl; external XPLM_DLL; +{$ENDIF XPLM300} + +{$IFDEF XPLM300} + { + XPLMReceiveMonitorBoundsOS_f + + This function is informed of the global bounds (in pixels) of a particular + monitor within the operating system's global desktop space. Note that a + monitor index being passed to you here does not indicate that X-Plane is + running in full screen on this monitor, or even that any X-Plane windows + exist on this monitor. + } +TYPE + XPLMReceiveMonitorBoundsOS_f = PROCEDURE( + inMonitorIndex : Integer; + inLeftPx : Integer; + inTopPx : Integer; + inRightPx : Integer; + inBottomPx : Integer; + inRefcon : pointer); cdecl; +{$ENDIF XPLM300} + +{$IFDEF XPLM300} + { + XPLMGetAllMonitorBoundsOS + + This routine immediately calls you back with the bounds (in pixels) of each + monitor within the operating system's global desktop space. Note that + unlike XPLMGetAllMonitorBoundsGlobal(), this may include monitors that have + no X-Plane window on them. + + Note that this function's monitor indices match those provided by + XPLMGetAllMonitorBoundsGlobal(), but the coordinates are different (since + the X-Plane global desktop may not match the operating system's global + desktop, and one X-Plane boxel may be larger than one pixel). + } + PROCEDURE XPLMGetAllMonitorBoundsOS( + inMonitorBoundsCallback: XPLMReceiveMonitorBoundsOS_f; + inRefcon : pointer); + cdecl; external XPLM_DLL; +{$ENDIF XPLM300} + + { + XPLMGetMouseLocation + + Deprecated in XPLM300. Modern windows should use + XPLMGetMouseLocationGlobal() instead. + + This routine returns the current mouse location in pixels relative to the + main X-Plane window. The bottom left corner of the main window is (0, 0). + Pass NULL to not receive info about either parameter. + + Because this function gives the mouse position relative to the main X-Plane + window (rather than in global bounds), this function should only be used by + legacy windows. Modern windows should instead get the mouse position in + global desktop coordinates using XPLMGetMouseLocationGlobal(). + + Note that unlike XPLMGetMouseLocationGlobal(), if the mouse goes outside + the user's main monitor (for instance, to a pop out window or a secondary + monitor), this function will not reflect it. + } + PROCEDURE XPLMGetMouseLocation( + outX : PInteger; { Can be nil } + outY : PInteger); { Can be nil } + cdecl; external XPLM_DLL; + +{$IFDEF XPLM300} + { + XPLMGetMouseLocationGlobal + + Returns the current mouse location in global desktop boxels. Unlike + XPLMGetMouseLocation(), the bottom left of the main X-Plane window is not + guaranteed to be (0, 0)---instead, the origin is the lower left of the + entire global desktop space. In addition, this routine gives the real mouse + location when the mouse goes to X-Plane windows other than the primary + display. Thus, it can be used with both pop-out windows and secondary + monitors. + + This is the mouse location function to use with modern windows (i.e., those + created by XPLMCreateWindowEx()). + + Pass NULL to not receive info about either parameter. + } + PROCEDURE XPLMGetMouseLocationGlobal( + outX : PInteger; { Can be nil } + outY : PInteger); { Can be nil } + cdecl; external XPLM_DLL; +{$ENDIF XPLM300} + + { + XPLMGetWindowGeometry + + This routine returns the position and size of a window. The units and + coordinate system vary depending on the type of window you have. + + If this is a legacy window (one compiled against a pre-XPLM300 version of + the SDK, or an XPLM300 window that was not created using + XPLMCreateWindowEx()), the units are pixels relative to the main X-Plane + display. + + If, on the other hand, this is a new X-Plane 11-style window (compiled + against the XPLM300 SDK and created using XPLMCreateWindowEx()), the units + are global desktop boxels. + + Pass NULL to not receive any paramter. + } + PROCEDURE XPLMGetWindowGeometry( + inWindowID : XPLMWindowID; + outLeft : PInteger; { Can be nil } + outTop : PInteger; { Can be nil } + outRight : PInteger; { Can be nil } + outBottom : PInteger); { Can be nil } + cdecl; external XPLM_DLL; + + { + XPLMSetWindowGeometry + + This routine allows you to set the position and size of a window. + + The units and coordinate system match those of XPLMGetWindowGeometry(). + That is, modern windows use global desktop boxel coordinates, while legacy + windows use pixels relative to the main X-Plane display. + + Note that this only applies to "floating" windows (that is, windows that + are drawn within the X-Plane simulation windows, rather than being "popped + out" into their own first-class operating system windows). To set the + position of windows whose positioning mode is xplm_WindowPopOut, you'll + need to instead use XPLMSetWindowGeometryOS(). + } + PROCEDURE XPLMSetWindowGeometry( + inWindowID : XPLMWindowID; + inLeft : Integer; + inTop : Integer; + inRight : Integer; + inBottom : Integer); + cdecl; external XPLM_DLL; + +{$IFDEF XPLM300} + { + XPLMGetWindowGeometryOS + + This routine returns the position and size of a "popped out" window (i.e., + a window whose positioning mode is xplm_WindowPopOut), in operating system + pixels. Pass NULL to not receive any parameter. + } + PROCEDURE XPLMGetWindowGeometryOS( + inWindowID : XPLMWindowID; + outLeft : PInteger; { Can be nil } + outTop : PInteger; { Can be nil } + outRight : PInteger; { Can be nil } + outBottom : PInteger); { Can be nil } + cdecl; external XPLM_DLL; +{$ENDIF XPLM300} + +{$IFDEF XPLM300} + { + XPLMSetWindowGeometryOS + + This routine allows you to set the position and size, in operating system + pixel coordinates, of a popped out window (that is, a window whose + positioning mode is xplm_WindowPopOut, which exists outside the X-Plane + simulation window, in its own first-class operating system window). + + Note that you are responsible for ensuring both that your window is popped + out (using XPLMWindowIsPoppedOut()) and that a monitor really exists at the + OS coordinates you provide (using XPLMGetAllMonitorBoundsOS()). + } + PROCEDURE XPLMSetWindowGeometryOS( + inWindowID : XPLMWindowID; + inLeft : Integer; + inTop : Integer; + inRight : Integer; + inBottom : Integer); + cdecl; external XPLM_DLL; +{$ENDIF XPLM300} + +{$IFDEF XPLM301} + { + XPLMGetWindowGeometryVR + + Returns the width and height, in boxels, of a window in VR. Note that you + are responsible for ensuring your window is in VR (using + XPLMWindowIsInVR()). + } + PROCEDURE XPLMGetWindowGeometryVR( + inWindowID : XPLMWindowID; + outWidthBoxels : PInteger; { Can be nil } + outHeightBoxels : PInteger); { Can be nil } + cdecl; external XPLM_DLL; +{$ENDIF XPLM301} + +{$IFDEF XPLM301} + { + XPLMSetWindowGeometryVR + + This routine allows you to set the size, in boxels, of a window in VR (that + is, a window whose positioning mode is xplm_WindowVR). + + Note that you are responsible for ensuring your window is in VR (using + XPLMWindowIsInVR()). + } + PROCEDURE XPLMSetWindowGeometryVR( + inWindowID : XPLMWindowID; + widthBoxels : Integer; + heightBoxels : Integer); + cdecl; external XPLM_DLL; +{$ENDIF XPLM301} + + { + XPLMGetWindowIsVisible + + Returns true (1) if the specified window is visible. + } + FUNCTION XPLMGetWindowIsVisible( + inWindowID : XPLMWindowID) : Integer; + cdecl; external XPLM_DLL; + + { + XPLMSetWindowIsVisible + + This routine shows or hides a window. + } + PROCEDURE XPLMSetWindowIsVisible( + inWindowID : XPLMWindowID; + inIsVisible : Integer); + cdecl; external XPLM_DLL; + +{$IFDEF XPLM300} + { + XPLMWindowIsPoppedOut + + True if this window has been popped out (making it a first-class window in + the operating system), which in turn is true if and only if you have set + the window's positioning mode to xplm_WindowPopOut. + + Only applies to modern windows. (Windows created using the deprecated + XPLMCreateWindow(), or windows compiled against a pre-XPLM300 version of + the SDK cannot be popped out.) + } + FUNCTION XPLMWindowIsPoppedOut( + inWindowID : XPLMWindowID) : Integer; + cdecl; external XPLM_DLL; +{$ENDIF XPLM300} + +{$IFDEF XPLM301} + { + XPLMWindowIsInVR + + True if this window has been moved to the virtual reality (VR) headset, + which in turn is true if and only if you have set the window's positioning + mode to xplm_WindowVR. + + Only applies to modern windows. (Windows created using the deprecated + XPLMCreateWindow(), or windows compiled against a pre-XPLM301 version of + the SDK cannot be moved to VR.) + } + FUNCTION XPLMWindowIsInVR( + inWindowID : XPLMWindowID) : Integer; + cdecl; external XPLM_DLL; +{$ENDIF XPLM301} + +{$IFDEF XPLM300} + { + XPLMSetWindowGravity + + A window's "gravity" controls how the window shifts as the whole X-Plane + window resizes. A gravity of 1 means the window maintains its positioning + relative to the right or top edges, 0 the left/bottom, and 0.5 keeps it + centered. + + Default gravity is (0, 1, 0, 1), meaning your window will maintain its + position relative to the top left and will not change size as its + containing window grows. + + If you wanted, say, a window that sticks to the top of the screen (with a + constant height), but which grows to take the full width of the window, you + would pass (0, 1, 1, 1). Because your left and right edges would maintain + their positioning relative to their respective edges of the screen, the + whole width of your window would change with the X-Plane window. + + Only applies to modern windows. (Windows created using the deprecated + XPLMCreateWindow(), or windows compiled against a pre-XPLM300 version of + the SDK will simply get the default gravity.) + } + PROCEDURE XPLMSetWindowGravity( + inWindowID : XPLMWindowID; + inLeftGravity : Single; + inTopGravity : Single; + inRightGravity : Single; + inBottomGravity : Single); + cdecl; external XPLM_DLL; +{$ENDIF XPLM300} + +{$IFDEF XPLM300} + { + XPLMSetWindowResizingLimits + + Sets the minimum and maximum size of the client rectangle of the given + window. (That is, it does not include any window styling that you might + have asked X-Plane to apply on your behalf.) All resizing operations are + constrained to these sizes. + + Only applies to modern windows. (Windows created using the deprecated + XPLMCreateWindow(), or windows compiled against a pre-XPLM300 version of + the SDK will have no minimum or maximum size.) + } + PROCEDURE XPLMSetWindowResizingLimits( + inWindowID : XPLMWindowID; + inMinWidthBoxels : Integer; + inMinHeightBoxels : Integer; + inMaxWidthBoxels : Integer; + inMaxHeightBoxels : Integer); + cdecl; external XPLM_DLL; +{$ENDIF XPLM300} + +{$IFDEF XPLM300} + { + XPLMWindowPositioningMode + + XPLMWindowPositionMode describes how X-Plane will position your window on + the user's screen. X-Plane will maintain this positioning mode even as the + user resizes their window or adds/removes full-screen monitors. + + Positioning mode can only be set for "modern" windows (that is, windows + created using XPLMCreateWindowEx() and compiled against the XPLM300 SDK). + Windows created using the deprecated XPLMCreateWindow(), or windows + compiled against a pre-XPLM300 version of the SDK will simply get the + "free" positioning mode. + } +TYPE + XPLMWindowPositioningMode = ( + { The default positioning mode. Set the window geometry and its future } + { position will be determined by its window gravity, resizing limits, and } + { user interactions. } + xplm_WindowPositionFree = 0 + + { Keep the window centered on the monitor you specify } + ,xplm_WindowCenterOnMonitor = 1 + + { Keep the window full screen on the monitor you specify } + ,xplm_WindowFullScreenOnMonitor = 2 + + { Like gui_window_full_screen_on_monitor, but stretches over *all* monitors } + { and popout windows. This is an obscure one... unless you have a very good } + { reason to need it, you probably don't! } + ,xplm_WindowFullScreenOnAllMonitors = 3 + + { A first-class window in the operating system, completely separate from the } + { X-Plane window(s) } + ,xplm_WindowPopOut = 4 + +{$IFDEF XPLM301} + { A floating window visible on the VR headset } + ,xplm_WindowVR = 5 +{$ENDIF XPLM301} + + ); + PXPLMWindowPositioningMode = ^XPLMWindowPositioningMode; +{$ENDIF XPLM300} + +{$IFDEF XPLM300} + { + XPLMSetWindowPositioningMode + + Sets the policy for how X-Plane will position your window. + + Some positioning modes apply to a particular monitor. For those modes, you + can pass a negative monitor index to position the window on the main + X-Plane monitor (the screen with the X-Plane menu bar at the top). Or, if + you have a specific monitor you want to position your window on, you can + pass a real monitor index as received from, e.g., + XPLMGetAllMonitorBoundsOS(). + + Only applies to modern windows. (Windows created using the deprecated + XPLMCreateWindow(), or windows compiled against a pre-XPLM300 version of + the SDK will always use xplm_WindowPositionFree.) + } + PROCEDURE XPLMSetWindowPositioningMode( + inWindowID : XPLMWindowID; + inPositioningMode : XPLMWindowPositioningMode; + inMonitorIndex : Integer); + cdecl; external XPLM_DLL; +{$ENDIF XPLM300} + +{$IFDEF XPLM300} + { + XPLMSetWindowTitle + + Sets the name for a window. This only applies to windows that opted-in to + styling as an X-Plane 11 floating window (i.e., with styling mode + xplm_WindowDecorationRoundRectangle) when they were created using + XPLMCreateWindowEx(). + } + PROCEDURE XPLMSetWindowTitle( + inWindowID : XPLMWindowID; + inWindowTitle : XPLMString); + cdecl; external XPLM_DLL; +{$ENDIF XPLM300} + + { + XPLMGetWindowRefCon + + Returns a window's reference constant, the unique value you can use for + your own purposes. + } + FUNCTION XPLMGetWindowRefCon( + inWindowID : XPLMWindowID) : pointer; + cdecl; external XPLM_DLL; + + { + XPLMSetWindowRefCon + + Sets a window's reference constant. Use this to pass data to yourself in + the callbacks. + } + PROCEDURE XPLMSetWindowRefCon( + inWindowID : XPLMWindowID; + inRefcon : pointer); + cdecl; external XPLM_DLL; + + { + XPLMTakeKeyboardFocus + + This routine gives a specific window keyboard focus. Keystrokes will be + sent to that window. Pass a window ID of 0 to remove keyboard focus from + any plugin-created windows and instead pass keyboard strokes directly to + X-Plane. + } + PROCEDURE XPLMTakeKeyboardFocus( + inWindow : XPLMWindowID); + cdecl; external XPLM_DLL; + + { + XPLMHasKeyboardFocus + + Returns true (1) if the indicated window has keyboard focus. Pass a window + ID of 0 to see if no plugin window has focus, and all keystrokes will go + directly to X-Plane. + } + FUNCTION XPLMHasKeyboardFocus( + inWindow : XPLMWindowID) : Integer; + cdecl; external XPLM_DLL; + + { + XPLMBringWindowToFront + + This routine brings the window to the front of the Z-order for its layer. + Windows are brought to the front automatically when they are created. + Beyond that, you should make sure you are front before handling mouse + clicks. + + Note that this only brings your window to the front of its layer + (XPLMWindowLayer). Thus, if you have a window in the floating window layer + (xplm_WindowLayerFloatingWindows), but there is a modal window (in layer + xplm_WindowLayerModal) above you, you would still not be the true frontmost + window after calling this. (After all, the window layers are strictly + ordered, and no window in a lower layer can ever be above any window in a + higher one.) + } + PROCEDURE XPLMBringWindowToFront( + inWindow : XPLMWindowID); + cdecl; external XPLM_DLL; + + { + XPLMIsWindowInFront + + This routine returns true if the window you passed in is the frontmost + visible window in its layer (XPLMWindowLayer). + + Thus, if you have a window at the front of the floating window layer + (xplm_WindowLayerFloatingWindows), this will return true even if there is a + modal window (in layer xplm_WindowLayerModal) above you. (Not to worry, + though: in such a case, X-Plane will not pass clicks or keyboard input down + to your layer until the window above stops "eating" the input.) + + Note that legacy windows are always placed in layer + xplm_WindowLayerFlightOverlay, while modern-style windows default to + xplm_WindowLayerFloatingWindows. This means it's perfectly consistent to + have two different plugin-created windows (one legacy, one modern) *both* + be in the front (of their different layers!) at the same time. + } + FUNCTION XPLMIsWindowInFront( + inWindow : XPLMWindowID) : Integer; + cdecl; external XPLM_DLL; + +{___________________________________________________________________________ + * KEY SNIFFERS + ___________________________________________________________________________} +{ + Low-level keyboard handlers. Allows for intercepting keystrokes outside the + normal rules of the user interface. +} + + + { + XPLMKeySniffer_f + + This is the prototype for a low level key-sniffing function. Window-based + UI _should not use this_! The windowing system provides high-level + mediated keyboard access, via the callbacks you attach to your + XPLMCreateWindow_t. By comparison, the key sniffer provides low level + keyboard access. + + Key sniffers are provided to allow libraries to provide non-windowed user + interaction. For example, the MUI library uses a key sniffer to do pop-up + text entry. + + Return 1 to pass the key on to the next sniffer, the window manager, + X-Plane, or whomever is down stream. Return 0 to consume the key. + + Warning: this API declares virtual keys as a signed character; however the + VKEY #define macros in XPLMDefs.h define the vkeys using unsigned values + (that is 0x80 instead of -0x80). So you may need to cast the incoming vkey + to an unsigned char to get correct comparisons in C. + } +TYPE + XPLMKeySniffer_f = FUNCTION( + inChar : XPLMChar; + inFlags : XPLMKeyFlags; + inVirtualKey : XPLMChar; + inRefcon : pointer) : Integer; cdecl; + + { + XPLMRegisterKeySniffer + + This routine registers a key sniffing callback. You specify whether you + want to sniff before the window system, or only sniff keys the window + system does not consume. You should ALMOST ALWAYS sniff non-control keys + after the window system. When the window system consumes a key, it is + because the user has "focused" a window. Consuming the key or taking + action based on the key will produce very weird results. Returns + 1 if successful. + } + FUNCTION XPLMRegisterKeySniffer( + inCallback : XPLMKeySniffer_f; + inBeforeWindows : Integer; + inRefcon : pointer) : Integer; + cdecl; external XPLM_DLL; + + { + XPLMUnregisterKeySniffer + + This routine unregisters a key sniffer. You must unregister a key sniffer + for every time you register one with the exact same signature. Returns 1 + if successful. + } + FUNCTION XPLMUnregisterKeySniffer( + inCallback : XPLMKeySniffer_f; + inBeforeWindows : Integer; + inRefcon : pointer) : Integer; + cdecl; external XPLM_DLL; + +{___________________________________________________________________________ + * HOT KEYS + ___________________________________________________________________________} +{ + Keystrokes that can be managed by others. These are lower-level than window + keyboard handlers (i.e., callbacks you attach to your XPLMCreateWindow_t), + but higher level than key sniffers. +} + + + { + XPLMHotKey_f + + Your hot key callback simply takes a pointer of your choosing. + } +TYPE + XPLMHotKey_f = PROCEDURE( + inRefcon : pointer); cdecl; + + { + XPLMHotKeyID + + An opaque ID used to identify a hot key. + } + XPLMHotKeyID = pointer; + PXPLMHotKeyID = ^XPLMHotKeyID; + + { + XPLMRegisterHotKey + + This routine registers a hot key. You specify your preferred key stroke + virtual key/flag combination, a description of what your callback does (so + other plug-ins can describe the plug-in to the user for remapping) and a + callback function and opaque pointer to pass in). A new hot key ID is + returned. During execution, the actual key associated with your hot key + may change, but you are insulated from this. + } + FUNCTION XPLMRegisterHotKey( + inVirtualKey : XPLMChar; + inFlags : XPLMKeyFlags; + inDescription : XPLMString; + inCallback : XPLMHotKey_f; + inRefcon : pointer) : XPLMHotKeyID; + cdecl; external XPLM_DLL; + + { + XPLMUnregisterHotKey + + Unregisters a hot key. You can only unregister your own hot keys. + } + PROCEDURE XPLMUnregisterHotKey( + inHotKey : XPLMHotKeyID); + cdecl; external XPLM_DLL; + + { + XPLMCountHotKeys + + Returns the number of current hot keys. + } + FUNCTION XPLMCountHotKeys: Integer; + cdecl; external XPLM_DLL; + + { + XPLMGetNthHotKey + + Returns a hot key by index, for iteration on all hot keys. + } + FUNCTION XPLMGetNthHotKey( + inIndex : Integer) : XPLMHotKeyID; + cdecl; external XPLM_DLL; + + { + XPLMGetHotKeyInfo + + Returns information about the hot key. Return NULL for any parameter you + don't want info about. The description should be at least 512 chars long. + } + PROCEDURE XPLMGetHotKeyInfo( + inHotKey : XPLMHotKeyID; + outVirtualKey : XPLMString; { Can be nil } + outFlags : PXPLMKeyFlags; { Can be nil } + outDescription : XPLMString; { Can be nil } + outPlugin : PXPLMPluginID); { Can be nil } + cdecl; external XPLM_DLL; + + { + XPLMSetHotKeyCombination + + Remaps a hot key's keystrokes. You may remap another plugin's keystrokes. + } + PROCEDURE XPLMSetHotKeyCombination( + inHotKey : XPLMHotKeyID; + inVirtualKey : XPLMChar; + inFlags : XPLMKeyFlags); + cdecl; external XPLM_DLL; + + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/SDKold/Delphi/XPLM/XPLMGraphics.pas b/XPLPro_Plugin_Source/SDK/SDKold/Delphi/XPLM/XPLMGraphics.pas new file mode 100644 index 0000000..20ff61a --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDKold/Delphi/XPLM/XPLMGraphics.pas @@ -0,0 +1,424 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPLMGraphics; +INTERFACE +{ + A few notes on coordinate systems: + + X-Plane uses three kinds of coordinates. Global coordinates are specified + as latitude, longitude and elevation. This coordinate system never changes + but is not very precise. + + OpenGL (or 'local') coordinates are cartesian and shift with the plane. + They offer more precision and are used for 3-d OpenGL drawing. The X axis + is aligned east-west with positive X meaning east. The Y axis is aligned + straight up and down at the point 0,0,0 (but since the earth is round it is + not truly straight up and down at other points). The Z axis is aligned + north-south at 0, 0, 0 with positive Z pointing south (but since the earth + is round it isn't exactly north-south as you move east or west of 0, 0, 0). + One unit is one meter and the point 0,0,0 is on the surface of the earth at + sea level for some latitude and longitude picked by the sim such that the + user's aircraft is reasonably nearby. + + 2-d Panel coordinates are 2d, with the X axis horizontal and the Y axis + vertical. The point 0,0 is the bottom left and 1024,768 is the upper + right of the screen. This is true no matter what resolution the user's + monitor is in; when running in higher resolution, graphics will be + scaled. + + Use X-Plane's routines to convert between global and local coordinates. Do + not attempt to do this conversion yourself; the precise 'roundness' of + X-Plane's physics model may not match your own, and (to make things + weirder) the user can potentially customize the physics of the current + planet. +} + +USES + XPLMDefs; + {$A4} +{___________________________________________________________________________ + * X-PLANE GRAPHICS + ___________________________________________________________________________} +{ + These routines allow you to use OpenGL with X-Plane. +} + + + { + XPLMTextureID + + XPLM Texture IDs name well-known textures in the sim for you to use. This + allows you to recycle textures from X-Plane, saving VRAM. + + *Warning*: do not use these enums. The only remaining use they have is to + access the legacy compatibility v10 UI texture; if you need this, get it + via the Widgets library. + } +TYPE + XPLMTextureID = ( + { The bitmap that contains window outlines, button outlines, fonts, etc. } + xplm_Tex_GeneralInterface = 0 + +{$IFDEF XPLM_DEPRECATED} + { The exterior paint for the user's aircraft (daytime). } + ,xplm_Tex_AircraftPaint = 1 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { The exterior light map for the user's aircraft. } + ,xplm_Tex_AircraftLiteMap = 2 +{$ENDIF XPLM_DEPRECATED} + + ); + PXPLMTextureID = ^XPLMTextureID; + + { + XPLMSetGraphicsState + + XPLMSetGraphicsState changes OpenGL's fixed function pipeline state. You + are not responsible for restoring any state that is accessed via + XPLMSetGraphicsState, but you are responsible for not accessing this state + directly. + + - inEnableFog - enables or disables fog, equivalent to: glEnable(GL_FOG); + - inNumberTexUnits - enables or disables a number of multitexturing units. + If the number is 0, 2d texturing is disabled entirely, as in + glDisable(GL_TEXTURE_2D); Otherwise, 2d texturing is enabled, and a + number of multitexturing units are enabled sequentially, starting with + unit 0, e.g. glActiveTextureARB(GL_TEXTURE0_ARB); glEnable + (GL_TEXTURE_2D); + - inEnableLighting - enables or disables OpenGL lighting, e.g. + glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); + - inEnableAlphaTesting - enables or disables the alpha test per pixel, e.g. + glEnable(GL_ALPHA_TEST); + - inEnableAlphaBlending - enables or disables alpha blending per pixel, + e.g. glEnable(GL_BLEND); + - inEnableDepthTesting - enables per pixel depth testing, as in + glEnable(GL_DEPTH_TEST); + - inEnableDepthWriting - enables writing back of depth information to the + depth bufffer, as in glDepthMask(GL_TRUE); + + The purpose of this function is to change OpenGL state while keeping + X-Plane aware of the state changes; this keeps X-Plane from getting + surprised by OGL state changes, and prevents X-Plane and plug-ins from + having to set all state before all draws; XPLMSetGraphicsState internally + skips calls to change state that is already properly enabled. + + X-Plane does not have a 'default' OGL state for plug-ins with respect to + the above state vector; plug-ins should totally set OGL state using this + API before drawing. Use XPLMSetGraphicsState instead of any of the above + OpenGL calls. + + WARNING: Any routine that performs drawing (e.g. XPLMDrawString or widget + code) may change X-Plane's state. Always set state before drawing after + unknown code has executed. + + *Deprecation Warnings*: X-Plane's lighting and fog environemnt is + significantly more complex than the fixed function pipeline can express; + do not assume that lighting and fog state is a good approximation for 3-d + drawing. Prefer to use XPLMInstancing to draw objects. All calls to + XPLMSetGraphicsState should have no fog or lighting. + } + PROCEDURE XPLMSetGraphicsState( + inEnableFog : Integer; + inNumberTexUnits : Integer; + inEnableLighting : Integer; + inEnableAlphaTesting: Integer; + inEnableAlphaBlending: Integer; + inEnableDepthTesting: Integer; + inEnableDepthWriting: Integer); + cdecl; external XPLM_DLL; + + { + XPLMBindTexture2d + + XPLMBindTexture2d changes what texture is bound to the 2d texturing + target. This routine caches the current 2d texture across all texturing + units in the sim and plug-ins, preventing extraneous binding. For + example, consider several plug-ins running in series; if they all use the + 'general interface' bitmap to do UI, calling this function will skip the + rebinding of the general interface texture on all but the first plug-in, + which can provide better frame rate son some graphics cards. + + inTextureID is the ID of the texture object to bind; inTextureUnit is a + zero-based texture unit (e.g. 0 for the first one), up to a maximum of 4 + units. (This number may increase in future versions of X-Plane.) + + Use this routine instead of glBindTexture(GL_TEXTURE_2D, ....); + } + PROCEDURE XPLMBindTexture2d( + inTextureNum : Integer; + inTextureUnit : Integer); + cdecl; external XPLM_DLL; + + { + XPLMGenerateTextureNumbers + + Use this routine instead of glGenTextures to generate new texture object + IDs. This routine historically ensured that plugins don't use texure IDs + that X-Plane is reserving for its own use. + } + PROCEDURE XPLMGenerateTextureNumbers( + outTextureIDs : PInteger; + inCount : Integer); + cdecl; external XPLM_DLL; + +{$IFDEF XPLM_DEPRECATED} + { + XPLMGetTexture + + XPLMGetTexture returns the OpenGL texture ID of an X-Plane texture based on + a generic identifying code. For example, you can get the texture for + X-Plane's UI bitmaps. + } + FUNCTION XPLMGetTexture( + inTexture : XPLMTextureID) : Integer; + cdecl; external XPLM_DLL; +{$ENDIF XPLM_DEPRECATED} + + { + XPLMWorldToLocal + + This routine translates coordinates from latitude, longitude, and altitude + to local scene coordinates. Latitude and longitude are in decimal degrees, + and altitude is in meters MSL (mean sea level). The XYZ coordinates are in + meters in the local OpenGL coordinate system. + } + PROCEDURE XPLMWorldToLocal( + inLatitude : Real; + inLongitude : Real; + inAltitude : Real; + outX : PReal; + outY : PReal; + outZ : PReal); + cdecl; external XPLM_DLL; + + { + XPLMLocalToWorld + + This routine translates a local coordinate triplet back into latitude, + longitude, and altitude. Latitude and longitude are in decimal degrees, + and altitude is in meters MSL (mean sea level). The XYZ coordinates are in + meters in the local OpenGL coordinate system. + + NOTE: world coordinates are less precise than local coordinates; you should + try to avoid round tripping from local to world and back. + } + PROCEDURE XPLMLocalToWorld( + inX : Real; + inY : Real; + inZ : Real; + outLatitude : PReal; + outLongitude : PReal; + outAltitude : PReal); + cdecl; external XPLM_DLL; + + { + XPLMDrawTranslucentDarkBox + + This routine draws a translucent dark box, partially obscuring parts of the + screen but making text easy to read. This is the same graphics primitive + used by X-Plane to show text files and ATC info. + } + PROCEDURE XPLMDrawTranslucentDarkBox( + inLeft : Integer; + inTop : Integer; + inRight : Integer; + inBottom : Integer); + cdecl; external XPLM_DLL; + +{___________________________________________________________________________ + * X-PLANE TEXT + ___________________________________________________________________________} + + { + XPLMFontID + + X-Plane features some fixed-character fonts. Each font may have its own + metrics. + + WARNING: Some of these fonts are no longer supported or may have changed + geometries. For maximum copmatibility, see the comments below. + + Note: X-Plane 7 supports proportional-spaced fonts. Since no measuring + routine is available yet, the SDK will normally draw using a fixed-width + font. You can use a dataref to enable proportional font drawing on XP7 if + you want to. + } +TYPE + XPLMFontID = ( + { Mono-spaced font for user interface. Available in all versions of the SDK.} + xplmFont_Basic = 0 + +{$IFDEF XPLM_DEPRECATED} + { Deprecated, do not use. } + ,xplmFont_Menus = 1 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated, do not use. } + ,xplmFont_Metal = 2 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated, do not use. } + ,xplmFont_Led = 3 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated, do not use. } + ,xplmFont_LedWide = 4 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated, do not use. } + ,xplmFont_PanelHUD = 5 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated, do not use. } + ,xplmFont_PanelEFIS = 6 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated, do not use. } + ,xplmFont_PanelGPS = 7 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated, do not use. } + ,xplmFont_RadiosGA = 8 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated, do not use. } + ,xplmFont_RadiosBC = 9 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated, do not use. } + ,xplmFont_RadiosHM = 10 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated, do not use. } + ,xplmFont_RadiosGANarrow = 11 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated, do not use. } + ,xplmFont_RadiosBCNarrow = 12 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated, do not use. } + ,xplmFont_RadiosHMNarrow = 13 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated, do not use. } + ,xplmFont_Timer = 14 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated, do not use. } + ,xplmFont_FullRound = 15 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated, do not use. } + ,xplmFont_SmallRound = 16 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { Deprecated, do not use. } + ,xplmFont_Menus_Localized = 17 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM200} + { Proportional UI font. } + ,xplmFont_Proportional = 18 +{$ENDIF XPLM200} + + ); + PXPLMFontID = ^XPLMFontID; + + { + XPLMDrawString + + This routine draws a NULL termianted string in a given font. Pass in the + lower left pixel that the character is to be drawn onto. Also pass the + character and font ID. This function returns the x offset plus the width of + all drawn characters. The color to draw in is specified as a pointer to an + array of three floating point colors, representing RGB intensities from 0.0 + to 1.0. + } + PROCEDURE XPLMDrawString( + inColorRGB : PSingle; + inXOffset : Integer; + inYOffset : Integer; + inChar : XPLMString; + inWordWrapWidth : PInteger; { Can be nil } + inFontID : XPLMFontID); + cdecl; external XPLM_DLL; + + { + XPLMDrawNumber + + This routine draws a number similar to the digit editing fields in + PlaneMaker and data output display in X-Plane. Pass in a color, a + position, a floating point value, and formatting info. Specify how many + integer and how many decimal digits to show and whether to show a sign, as + well as a character set. This routine returns the xOffset plus width of the + string drawn. + } + PROCEDURE XPLMDrawNumber( + inColorRGB : PSingle; + inXOffset : Integer; + inYOffset : Integer; + inValue : Real; + inDigits : Integer; + inDecimals : Integer; + inShowSign : Integer; + inFontID : XPLMFontID); + cdecl; external XPLM_DLL; + + { + XPLMGetFontDimensions + + This routine returns the width and height of a character in a given font. + It also tells you if the font only supports numeric digits. Pass NULL if + you don't need a given field. Note that for a proportional font the width + will be an arbitrary, hopefully average width. + } + PROCEDURE XPLMGetFontDimensions( + inFontID : XPLMFontID; + outCharWidth : PInteger; { Can be nil } + outCharHeight : PInteger; { Can be nil } + outDigitsOnly : PInteger); { Can be nil } + cdecl; external XPLM_DLL; + +{$IFDEF XPLM200} + { + XPLMMeasureString + + This routine returns the width in pixels of a string using a given font. + The string is passed as a pointer plus length (and does not need to be null + terminated); this is used to allow for measuring substrings. The return + value is floating point; it is possible that future font drawing may allow + for fractional pixels. + } + FUNCTION XPLMMeasureString( + inFontID : XPLMFontID; + inChar : XPLMString; + inNumChars : Integer) : Single; + cdecl; external XPLM_DLL; +{$ENDIF XPLM200} + + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/SDKold/Delphi/XPLM/XPLMInstance.pas b/XPLPro_Plugin_Source/SDK/SDKold/Delphi/XPLM/XPLMInstance.pas new file mode 100644 index 0000000..a38d2bb --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDKold/Delphi/XPLM/XPLMInstance.pas @@ -0,0 +1,125 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPLMInstance; +INTERFACE +{ + This API provides instanced drawing of X-Plane objects (.obj files). In + contrast to old drawing APIs, which required you to draw your own objects + per-frame, the instancing API allows you to simply register an OBJ for + drawing, then move or manipulate it later (as needed). + + This provides one tremendous benefit: it keeps all dataref operations for + your object in one place. Because datarefs are main thread only, allowing + dataref access anywhere is a serious performance bottleneck for the + simulator---the whole simulator has to pause and wait for each dataref + access. This performance penalty will only grow worse as X-Plane moves + toward an ever more heavily multithreaded engine. + + The instancing API allows X-Plane to isolate all dataref manipulations for + all plugin object drawing to one place, potentially providing huge + performance gains. + + Here's how it works: + + When an instance is created, it provides a list of all datarefs you want to + manipulate in for the OBJ in the future. This list of datarefs replaces the + ad-hoc collections of dataref objects previously used by art assets. Then, + per-frame, you can manipulate the instance by passing in a "block" of + packed floats representing the current values of the datarefs for your + instance. (Note that the ordering of this set of packed floats must exactly + match the ordering of the datarefs when you created your instance.) +} + +USES + XPLMDefs, XPLMScenery; + {$A4} +{___________________________________________________________________________ + * Instance Creation and Destruction + ___________________________________________________________________________} +{ + Registers and unregisters instances. +} + + +TYPE + { + XPLMInstanceRef + + An opaque handle to an instance. + } + XPLMInstanceRef = pointer; + PXPLMInstanceRef = ^XPLMInstanceRef; + + { + XPLMCreateInstance + + XPLMCreateInstance creates a new instance, managed by your plug-in, and + returns a handle to the instance. A few important requirements: + + * The object passed in must be fully loaded and returned from the XPLM + before you can create your instance; you cannot pass a null obj ref, nor + can you change the ref later. + + * If you use any custom datarefs in your object, they must be registered + before the object is loaded. This is true even if their data will be + provided via the instance dataref list. + + * The instance dataref array must be a valid ptr to an array of at least + one item that is null terminated. That is, if you do not want any + datarefs, you must passa ptr to an array with a null item. You cannot + pass null for this. + } + FUNCTION XPLMCreateInstance( + obj : XPLMObjectRef; + datarefs : PXPLMString) : XPLMInstanceRef; + cdecl; external XPLM_DLL; + + { + XPLMDestroyInstance + + XPLMDestroyInstance destroys and deallocates your instance; once called, + you are still responsible for releasing the OBJ ref. + + Tip: you can release your OBJ ref after you call XPLMCreateInstance as long + as you never use it again; the instance will maintain its own reference to + the OBJ and the object OBJ be deallocated when the instance is destroyed. + } + PROCEDURE XPLMDestroyInstance( + instance : XPLMInstanceRef); + cdecl; external XPLM_DLL; + +{___________________________________________________________________________ + * Instance Manipulation + ___________________________________________________________________________} + + { + XPLMInstanceSetPosition + + Updates both the position of the instance and all datarefs you registered + for it. Call this from a flight loop callback or UI callback. + + __DO NOT__ call XPLMInstanceSetPosition from a drawing callback; the whole + point of instancing is that you do not need any drawing callbacks. Setting + instance data from a drawing callback may have undefined consequences, and + the drawing callback hurts FPS unnecessarily. + + The memory pointed to by the data pointer must be large enough to hold one + float for every data ref you have registered, and must contain valid + floating point data. + + BUG: before X-Plane 11.50, if you have no dataref registered, you must + still pass a valid pointer for data and not null. + } + PROCEDURE XPLMInstanceSetPosition( + instance : XPLMInstanceRef; + new_position : PXPLMDrawInfo_t; + data : PSingle); + cdecl; external XPLM_DLL; + + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/SDKold/Delphi/XPLM/XPLMMap.pas b/XPLPro_Plugin_Source/SDK/SDKold/Delphi/XPLM/XPLMMap.pas new file mode 100644 index 0000000..ea00ee0 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDKold/Delphi/XPLM/XPLMMap.pas @@ -0,0 +1,608 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPLMMap; +INTERFACE +{ + This API allows you to create new layers within X-Plane maps. Your layers + can draw arbitrary OpenGL, but they conveniently also have access to + X-Plane's built-in icon and label drawing functions. + + As of X-Plane 11, map drawing happens in three stages: + + 1. backgrounds and "fill," + 2. icons, and + 3. labels. + + Thus, all background drawing gets layered beneath all icons, which likewise + get layered beneath all labels. Within each stage, the map obeys a + consistent layer ordering, such that "fill" layers (layers that cover a + large amount of map area, like the terrain and clouds) appear beneath + "markings" layers (like airport icons). This ensures that layers with fine + details don't get obscured by layers with larger details. + + The XPLM map API reflects both aspects of this draw layering: you can + register a layer as providing either markings or fill, and X-Plane will + draw your fill layers beneath your markings layers (regardless of + registration order). Likewise, you are guaranteed that your layer's icons + (added from within an icon callback) will go above your layer's OpenGL + drawing, and your labels will go above your icons. + + The XPLM guarantees that all plugin-created fill layers go on top of all + native X-Plane fill layers, and all plugin-created markings layers go on + top of all X-Plane markings layers (with the exception of the aircraft + icons). It also guarantees that the draw order of your own plugin's layers + will be consistent. But, for layers created by different plugins, the only + guarantee is that we will draw all of one plugin's layers of each type + (fill, then markings), then all of the others'; we don't guarantee which + plugin's fill and markings layers go on top of the other's. + + As of X-Plane 11, maps use true cartographic projections for their drawing, + and different maps may use different projections. For that reason, all + drawing calls include an opaque handle for the projection you should use to + do the drawing. Any time you would draw at a particular latitude/longitude, + you'll need to ask the projection to translate that position into "map + coordinates." (Note that the projection is guaranteed not to change between + calls to your prepare-cache hook, so if you cache your map coordinates + ahead of time, there's no need to re-project them when you actually draw.) + + In addition to mapping normal latitude/longitude locations into map + coordinates, the projection APIs also let you know the current heading for + north. (Since X-Plane 11 maps can rotate to match the heading of the user's + aircraft, it's not safe to assume that north is at zero degrees rotation.) +} + +USES + XPLMDefs; + {$A4} +{$IFDEF XPLM300} +{___________________________________________________________________________ + * DRAWING CALLBACKS + ___________________________________________________________________________} +{ + When you create a new map layer (using XPLMCreateMapLayer), you can provide + any or all of these callbacks. They allow you to insert your own OpenGL + drawing, text labels, and icons into the X-Plane map at the appropriate + places, allowing your layer to behave as similarly to X-Plane's built-in + layers as possible. +} + + +TYPE + { + XPLMMapLayerID + + This is an opaque handle for a plugin-created map layer. Pass it to the map + drawing APIs from an appropriate callback to draw in the layer you created. + } + XPLMMapLayerID = pointer; + PXPLMMapLayerID = ^XPLMMapLayerID; + + { + XPLMMapProjectionID + + This is an opaque handle for a map projection. Pass it to the projection + APIs to translate between map coordinates and latitude/longitudes. + } + XPLMMapProjectionID = pointer; + PXPLMMapProjectionID = ^XPLMMapProjectionID; + + { + XPLMMapStyle + + Indicates the visual style being drawn by the map. In X-Plane, the user can + choose between a number of map types, and different map types may have use + a different visual representation for the same elements (for instance, the + visual style of the terrain layer changes drastically between the VFR and + IFR layers), or certain layers may be disabled entirely in some map types + (e.g., localizers are only visible in the IFR low-enroute style). + } + XPLMMapStyle = ( + xplm_MapStyle_VFR_Sectional = 0 + + ,xplm_MapStyle_IFR_LowEnroute = 1 + + ,xplm_MapStyle_IFR_HighEnroute = 2 + + ); + PXPLMMapStyle = ^XPLMMapStyle; + + { + XPLMMapDrawingCallback_f + + This is the OpenGL map drawing callback for plugin-created map layers. You + can perform arbitrary OpenGL drawing from this callback, with one + exception: changes to the Z-buffer are not permitted, and will result in + map drawing errors. + + All drawing done from within this callback appears beneath all built-in + X-Plane icons and labels, but above the built-in "fill" layers (layers + providing major details, like terrain and water). Note, however, that the + relative ordering between the drawing callbacks of different plugins is not + guaranteed. + } + XPLMMapDrawingCallback_f = PROCEDURE( + inLayer : XPLMMapLayerID; + inMapBoundsLeftTopRightBottom: PSingle; + zoomRatio : Single; + mapUnitsPerUserInterfaceUnit: Single; + mapStyle : XPLMMapStyle; + projection : XPLMMapProjectionID; + inRefcon : pointer); cdecl; + + { + XPLMMapIconDrawingCallback_f + + This is the icon drawing callback that enables plugin-created map layers to + draw icons using X-Plane's built-in icon drawing functionality. You can + request an arbitrary number of PNG icons to be drawn via + XPLMDrawMapIconFromSheet() from within this callback, but you may not + perform any OpenGL drawing here. + + Icons enqueued by this function will appear above all OpenGL drawing + (performed by your optional XPLMMapDrawingCallback_f), and above all + built-in X-Plane map icons of the same layer type ("fill" or "markings," as + determined by the XPLMMapLayerType in your XPLMCreateMapLayer_t). Note, + however, that the relative ordering between the drawing callbacks of + different plugins is not guaranteed. + } + XPLMMapIconDrawingCallback_f = PROCEDURE( + inLayer : XPLMMapLayerID; + inMapBoundsLeftTopRightBottom: PSingle; + zoomRatio : Single; + mapUnitsPerUserInterfaceUnit: Single; + mapStyle : XPLMMapStyle; + projection : XPLMMapProjectionID; + inRefcon : pointer); cdecl; + + { + XPLMMapLabelDrawingCallback_f + + This is the label drawing callback that enables plugin-created map layers + to draw text labels using X-Plane's built-in labeling functionality. You + can request an arbitrary number of text labels to be drawn via + XPLMDrawMapLabel() from within this callback, but you may not perform any + OpenGL drawing here. + + Labels enqueued by this function will appear above all OpenGL drawing + (performed by your optional XPLMMapDrawingCallback_f), and above all + built-in map icons and labels of the same layer type ("fill" or "markings," + as determined by the XPLMMapLayerType in your XPLMCreateMapLayer_t). Note, + however, that the relative ordering between the drawing callbacks of + different plugins is not guaranteed. + } + XPLMMapLabelDrawingCallback_f = PROCEDURE( + inLayer : XPLMMapLayerID; + inMapBoundsLeftTopRightBottom: PSingle; + zoomRatio : Single; + mapUnitsPerUserInterfaceUnit: Single; + mapStyle : XPLMMapStyle; + projection : XPLMMapProjectionID; + inRefcon : pointer); cdecl; + +{$ENDIF XPLM300} +{$IFDEF XPLM300} +{___________________________________________________________________________ + * LAYER MANAGEMENT CALLBACKS + ___________________________________________________________________________} +{ + These are various "bookkeeping" callbacks that your map layer can receive + (if you provide the callback in your XPLMCreateMapLayer_t). They allow you + to manage the lifecycle of your layer, as well as cache any + computationally-intensive preparation you might need for drawing. +} + + + { + XPLMMapPrepareCacheCallback_f + + A callback used to allow you to cache whatever information your layer needs + to draw in the current map area. + + This is called each time the map's total bounds change. This is typically + triggered by new DSFs being loaded, such that X-Plane discards old, + now-distant DSFs and pulls in new ones. At that point, the available bounds + of the map also change to match the new DSF area. + + By caching just the information you need to draw in this area, your future + draw calls can be made faster, since you'll be able to simply "splat" your + precomputed information each frame. + + We guarantee that the map projection will not change between successive + prepare cache calls, nor will any draw call give you bounds outside these + total map bounds. So, if you cache the projected map coordinates of all the + items you might want to draw in the total map area, you can be guaranteed + that no draw call will be asked to do any new work. + } +TYPE + XPLMMapPrepareCacheCallback_f = PROCEDURE( + inLayer : XPLMMapLayerID; + inTotalMapBoundsLeftTopRightBottom: PSingle; + projection : XPLMMapProjectionID; + inRefcon : pointer); cdecl; + + { + XPLMMapWillBeDeletedCallback_f + + Called just before your map layer gets deleted. Because SDK-created map + layers have the same lifetime as the X-Plane map that contains them, if the + map gets unloaded from memory, your layer will too. + } + XPLMMapWillBeDeletedCallback_f = PROCEDURE( + inLayer : XPLMMapLayerID; + inRefcon : pointer); cdecl; + +{$ENDIF XPLM300} +{$IFDEF XPLM300} +{___________________________________________________________________________ + * MAP LAYER CREATION AND DESTRUCTION + ___________________________________________________________________________} +{ + Enables the creation of new map layers. Layers are created for a particular + instance of the X-Plane map. For instance, if you want your layer to appear + in both the normal map interface and the Instructor Operator Station (IOS), + you would need two separate calls to XPLMCreateMapLayer(), with two + different values for your XPLMCreateMapLayer_t::layer_name. + + Your layer's lifetime will be determined by the lifetime of the map it is + created in. If the map is destroyed (on the X-Plane side), your layer will + be too, and you'll receive a callback to your + XPLMMapWillBeDeletedCallback_f. +} + + + { + XPLMMapLayerType + + Indicates the type of map layer you are creating. Fill layers will always + be drawn beneath markings layers. + } +TYPE + XPLMMapLayerType = ( + { A layer that draws "fill" graphics, like weather patterns, terrain, etc. } + { Fill layers frequently cover a large portion of the visible map area. } + xplm_MapLayer_Fill = 0 + + { A layer that provides markings for particular map features, like NAVAIDs, } + { airports, etc. Even dense markings layers cover a small portion of the } + { total map area. } + ,xplm_MapLayer_Markings = 1 + + ); + PXPLMMapLayerType = ^XPLMMapLayerType; + +CONST + { Globally unique identifier for X-Plane's Map window, used as the } + { mapToCreateLayerIn parameter in XPLMCreateMapLayer_t } + XPLM_MAP_USER_INTERFACE = "XPLM_MAP_USER_INTERFACE"; + + { Globally unique identifier for X-Plane's Instructor Operator Station } + { window, used as the mapToCreateLayerIn parameter in XPLMCreateMapLayer_t } + XPLM_MAP_IOS = "XPLM_MAP_IOS"; + + { + XPLMCreateMapLayer_t + + This structure defines all of the parameters used to create a map layer + using XPLMCreateMapLayer. The structure will be expanded in future SDK APIs + to include more features. Always set the structSize member to the size of + your struct in bytes! + + Each layer must be associated with exactly one map instance in X-Plane. + That map, and that map alone, will call your callbacks. Likewise, when that + map is deleted, your layer will be as well. + } +TYPE + XPLMCreateMapLayer_t = RECORD + { Used to inform XPLMCreateMapLayer() of the SDK version you compiled } + { against; should always be set to sizeof(XPLMCreateMapLayer_t) } + structSize : Integer; + { Globally unique string identifying the map you want this layer to appear } + { in. As of XPLM300, this is limited to one of XPLM_MAP_USER_INTERFACE or } + { XPLM_MAP_IOS } + mapToCreateLayerIn : XPLMString; + { The type of layer you are creating, used to determine draw order (all } + { plugin-created markings layers are drawn above all plugin-created fill } + { layers) } + layerType : XPLMMapLayerType; + { Optional callback to inform you this layer is being deleted (due to its } + { owning map being destroyed) } + willBeDeletedCallback : XPLMMapWillBeDeletedCallback_f; + { Optional callback you want to use to prepare your draw cache when the map } + { bounds change (set to NULL if you don't want this callback) } + prepCacheCallback : XPLMMapPrepareCacheCallback_f; + { Optional callback you want to use for arbitrary OpenGL drawing, which goes } + { beneath all icons in the map's layering system (set to NULL if you don't } + { want this callback) } + drawCallback : XPLMMapDrawingCallback_f; + { Optional callback you want to use for drawing icons, which go above all } + { built-in X-Plane icons (except the aircraft) in the map's layering system } + { (set to NULL if you don't want this callback) } + iconCallback : XPLMMapIconDrawingCallback_f; + { Optional callback you want to use for drawing map labels, which go above } + { all built-in X-Plane icons and labels (except those of aircraft) in the } + { map's layering system (set to NULL if you don't want this callback) } + labelCallback : XPLMMapLabelDrawingCallback_f; + { True if you want a checkbox to be created in the map UI to toggle this } + { layer on and off; false if the layer should simply always be enabled } + showUiToggle : Integer; + { Short label to use for this layer in the user interface } + layerName : XPLMString; + { A reference to arbitrary data that will be passed to your callbacks } + refcon : pointer; + END; + PXPLMCreateMapLayer_t = ^XPLMCreateMapLayer_t; + + { + XPLMCreateMapLayer + + This routine creates a new map layer. You pass in an XPLMCreateMapLayer_t + structure with all of the fields set in. You must set the structSize of + the structure to the size of the actual structure you used. + + Returns NULL if the layer creation failed. This happens most frequently + because the map you specified in your + XPLMCreateMapLayer_t::mapToCreateLayerIn field doesn't exist (that is, if + XPLMMapExists() returns 0 for the specified map). You can use + XPLMRegisterMapCreationHook() to get a notification each time a new map is + opened in X-Plane, at which time you can create layers in it. + } + FUNCTION XPLMCreateMapLayer( + inParams : PXPLMCreateMapLayer_t) : XPLMMapLayerID; + cdecl; external XPLM_DLL; + + { + XPLMDestroyMapLayer + + Destroys a map layer you created (calling your + XPLMMapWillBeDeletedCallback_f if applicable). Returns true if a deletion + took place. + } + FUNCTION XPLMDestroyMapLayer( + inLayer : XPLMMapLayerID) : Integer; + cdecl; external XPLM_DLL; + + { + XPLMMapCreatedCallback_f + + A callback to notify your plugin that a new map has been created in + X-Plane. This is the best time to add a custom map layer using + XPLMCreateMapLayer(). + + No OpenGL drawing is permitted within this callback. + } +TYPE + XPLMMapCreatedCallback_f = PROCEDURE( + mapIdentifier : XPLMString; + refcon : pointer); cdecl; + + { + XPLMRegisterMapCreationHook + + Registers your callback to receive a notification each time a new map is + constructed in X-Plane. This callback is the best time to add your custom + map layer using XPLMCreateMapLayer(). + + Note that you will not be notified about any maps that already exist---you + can use XPLMMapExists() to check for maps that were created previously. + } + PROCEDURE XPLMRegisterMapCreationHook( + callback : XPLMMapCreatedCallback_f; + refcon : pointer); + cdecl; external XPLM_DLL; + + { + XPLMMapExists + + Returns 1 if the map with the specified identifier already exists in + X-Plane. In that case, you can safely call XPLMCreateMapLayer() specifying + that your layer should be added to that map. + } + FUNCTION XPLMMapExists( + mapIdentifier : XPLMString) : Integer; + cdecl; external XPLM_DLL; + +{$ENDIF XPLM300} +{$IFDEF XPLM300} +{___________________________________________________________________________ + * MAP DRAWING + ___________________________________________________________________________} +{ + These APIs are only valid from within a map drawing callback (one of + XPLMIconDrawingCallback_t or XPLMMapLabelDrawingCallback_f). Your drawing + callbacks are registered when you create a new map layer as part of your + XPLMCreateMapLayer_t. The functions here hook into X-Plane's built-in map + drawing functionality for icons and labels, so that you get a consistent + style with the rest of the X-Plane map. + + Note that the X-Plane 11 map introduces a strict ordering: layers of type + xplm_MapLayer_Fill get drawn beneath all xplm_MapLayer_Markings layers. + Likewise, all OpenGL drawing (performed in your layer's + XPLMMapDrawingCallback_f) will appear beneath any icons and labels you + draw. +} + + + { + XPLMMapOrientation + + Indicates whether a map element should be match its rotation to the map + itself, or to the user interface. For instance, the map itself may be + rotated such that "up" matches the user's aircraft, but you may want to + draw a text label such that it is always rotated zero degrees relative to + the user's perspective. In that case, you would have it draw with UI + orientation. + } +TYPE + XPLMMapOrientation = ( + { Orient such that a 0 degree rotation matches the map's north } + xplm_MapOrientation_Map = 0 + + { Orient such that a 0 degree rotation is "up" relative to the user interface} + ,xplm_MapOrientation_UI = 1 + + ); + PXPLMMapOrientation = ^XPLMMapOrientation; + + { + XPLMDrawMapIconFromSheet + + Enables plugin-created map layers to draw PNG icons using X-Plane's + built-in icon drawing functionality. Only valid from within an + XPLMIconDrawingCallback_t (but you can request an arbitrary number of icons + to be drawn from within your callback). + + X-Plane will automatically manage the memory for your texture so that it + only has to be loaded from disk once as long as you continue drawing it + per-frame. (When you stop drawing it, the memory may purged in a "garbage + collection" pass, require a load from disk in the future.) + + Instead of having X-Plane draw a full PNG, this method allows you to use UV + coordinates to request a portion of the image to be drawn. This allows you + to use a single texture load (of an icon sheet, for example) to draw many + icons. Doing so is much more efficient than drawing a dozen different small + PNGs. + + The UV coordinates used here treat the texture you load as being comprised + of a number of identically sized "cells." You specify the width and height + in cells (ds and dt, respectively), as well as the coordinates within the + cell grid for the sub-image you'd like to draw. + + Note that you can use different ds and dt values in subsequent calls with + the same texture sheet. This enables you to use icons of different sizes in + the same sheet if you arrange them properly in the PNG. + + This function is only valid from within an XPLMIconDrawingCallback_t (but + you can request an arbitrary number of icons to be drawn from within your + callback). + } + PROCEDURE XPLMDrawMapIconFromSheet( + layer : XPLMMapLayerID; + inPngPath : XPLMString; + s : Integer; + t : Integer; + ds : Integer; + dt : Integer; + mapX : Single; + mapY : Single; + orientation : XPLMMapOrientation; + rotationDegrees : Single; + mapWidth : Single); + cdecl; external XPLM_DLL; + + { + XPLMDrawMapLabel + + Enables plugin-created map layers to draw text labels using X-Plane's + built-in labeling functionality. Only valid from within an + XPLMMapLabelDrawingCallback_f (but you can request an arbitrary number of + text labels to be drawn from within your callback). + } + PROCEDURE XPLMDrawMapLabel( + layer : XPLMMapLayerID; + inText : XPLMString; + mapX : Single; + mapY : Single; + orientation : XPLMMapOrientation; + rotationDegrees : Single); + cdecl; external XPLM_DLL; + +{$ENDIF XPLM300} +{$IFDEF XPLM300} +{___________________________________________________________________________ + * MAP PROJECTIONS + ___________________________________________________________________________} +{ + As of X-Plane 11, the map draws using true cartographic projections, and + different maps may use different projections. Thus, to draw at a particular + latitude and longitude, you must first transform your real-world + coordinates into map coordinates. + + The map projection is also responsible for giving you the current scale of + the map. That is, the projection can tell you how many map units correspond + to 1 meter at a given point. + + Finally, the map projection can give you the current rotation of the map. + Since X-Plane 11 maps can rotate to match the heading of the aircraft, the + map's rotation can potentially change every frame. +} + + + { + XPLMMapProject + + Projects a latitude/longitude into map coordinates. This is the inverse of + XPLMMapUnproject(). + + Only valid from within a map layer callback (one of + XPLMMapPrepareCacheCallback_f, XPLMMapDrawingCallback_f, + XPLMMapIconDrawingCallback_f, or XPLMMapLabelDrawingCallback_f.) + } + PROCEDURE XPLMMapProject( + projection : XPLMMapProjectionID; + latitude : Real; + longitude : Real; + outX : PSingle; + outY : PSingle); + cdecl; external XPLM_DLL; + + { + XPLMMapUnproject + + Transforms map coordinates back into a latitude and longitude. This is the + inverse of XPLMMapProject(). + + Only valid from within a map layer callback (one of + XPLMMapPrepareCacheCallback_f, XPLMMapDrawingCallback_f, + XPLMMapIconDrawingCallback_f, or XPLMMapLabelDrawingCallback_f.) + } + PROCEDURE XPLMMapUnproject( + projection : XPLMMapProjectionID; + mapX : Single; + mapY : Single; + outLatitude : PReal; + outLongitude : PReal); + cdecl; external XPLM_DLL; + + { + XPLMMapScaleMeter + + Returns the number of map units that correspond to a distance of one meter + at a given set of map coordinates. + + Only valid from within a map layer callback (one of + XPLMMapPrepareCacheCallback_f, XPLMMapDrawingCallback_f, + XPLMMapIconDrawingCallback_f, or XPLMMapLabelDrawingCallback_f.) + } + FUNCTION XPLMMapScaleMeter( + projection : XPLMMapProjectionID; + mapX : Single; + mapY : Single) : Single; + cdecl; external XPLM_DLL; + + { + XPLMMapGetNorthHeading + + Returns the heading (in degrees clockwise) from the positive Y axis in the + cartesian mapping coordinate system to true north at the point passed in. + You can use it as a clockwise rotational offset to align icons and other + 2-d drawing with true north on the map, compensating for rotations in the + map due to projection. + + Only valid from within a map layer callback (one of + XPLMMapPrepareCacheCallback_f, XPLMMapDrawingCallback_f, + XPLMMapIconDrawingCallback_f, or XPLMMapLabelDrawingCallback_f.) + } + FUNCTION XPLMMapGetNorthHeading( + projection : XPLMMapProjectionID; + mapX : Single; + mapY : Single) : Single; + cdecl; external XPLM_DLL; + +{$ENDIF XPLM300} + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/SDKold/Delphi/XPLM/XPLMMenus.pas b/XPLPro_Plugin_Source/SDK/SDKold/Delphi/XPLM/XPLMMenus.pas new file mode 100644 index 0000000..754a434 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDKold/Delphi/XPLM/XPLMMenus.pas @@ -0,0 +1,277 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPLMMenus; +INTERFACE +{ + Plug-ins can create menus in the menu bar of X-Plane. This is done by + creating a menu and then creating items. Menus are referred to by an + opaque ID. Items are referred to by (zero-based) index number. + + Menus are "sandboxed" between plugins---no plugin can access the menus of + any other plugin. Furthermore, all menu indices are relative to your + plugin's menus only; if your plugin creates two sub-menus in the Plugins + menu at different times, it doesn't matter how many other plugins also + create sub-menus of Plugins in the intervening time: your sub-menus will be + given menu indices 0 and 1. (The SDK does some work in the back-end to + filter out menus that are irrelevant to your plugin in order to deliver + this consistency for each plugin.) + + When you create a menu item, you specify how we should handle clicks on + that menu item. You can either have the XPLM trigger a callback (the + XPLMMenuHandler_f associated with the menu that contains the item), or you + can simply have a command be triggered (with no associated call to your + menu handler). The advantage of the latter method is that X-Plane will + display any keyboard shortcuts associated with the command. (In contrast, + there are no keyboard shortcuts associated with menu handler callbacks with + specific parameters.) + + Menu text in X-Plane is UTF8; X-Plane's character set covers latin, greek + and cyrillic characters, Katakana, as well as some Japanese symbols. Some + APIs have a inDeprecatedAndIgnored parameter that used to select a + character set; since X-Plane 9 all localization is done via UTF-8 only. +} + +USES + XPLMDefs, XPLMUtilities; + {$A4} +{___________________________________________________________________________ + * XPLM MENUS + ___________________________________________________________________________} + + { + XPLMMenuCheck + + These enumerations define the various 'check' states for an X-Plane menu. + 'checking' in X-Plane actually appears as a light which may or may not be + lit. So there are three possible states. + } +TYPE + XPLMMenuCheck = ( + { there is no symbol to the left of the menu item. } + xplm_Menu_NoCheck = 0 + + { the menu has a mark next to it that is unmarked (not lit). } + ,xplm_Menu_Unchecked = 1 + + { the menu has a mark next to it that is checked (lit). } + ,xplm_Menu_Checked = 2 + + ); + PXPLMMenuCheck = ^XPLMMenuCheck; + + { + XPLMMenuID + + This is a unique ID for each menu you create. + } + XPLMMenuID = pointer; + PXPLMMenuID = ^XPLMMenuID; + + { + XPLMMenuHandler_f + + A menu handler function takes two reference pointers, one for the menu + (specified when the menu was created) and one for the item (specified when + the item was created). + } + XPLMMenuHandler_f = PROCEDURE( + inMenuRef : pointer; + inItemRef : pointer); cdecl; + + { + XPLMFindPluginsMenu + + This function returns the ID of the plug-ins menu, which is created for you + at startup. + } + FUNCTION XPLMFindPluginsMenu: XPLMMenuID; + cdecl; external XPLM_DLL; + +{$IFDEF XPLM300} + { + XPLMFindAircraftMenu + + This function returns the ID of the menu for the currently-loaded aircraft, + used for showing aircraft-specific commands. + + The aircraft menu is created by X-Plane at startup, but it remains hidden + until it is populated via XPLMAppendMenuItem() or + XPLMAppendMenuItemWithCommand(). + + Only plugins loaded with the user's current aircraft are allowed to access + the aircraft menu. For all other plugins, this will return NULL, and any + attempts to add menu items to it will fail. + } + FUNCTION XPLMFindAircraftMenu: XPLMMenuID; + cdecl; external XPLM_DLL; +{$ENDIF XPLM300} + + { + XPLMCreateMenu + + This function creates a new menu and returns its ID. It returns NULL if + the menu cannot be created. Pass in a parent menu ID and an item index to + create a submenu, or NULL for the parent menu to put the menu in the menu + bar. The menu's name is only used if the menu is in the menubar. You also + pass a handler function and a menu reference value. Pass NULL for the + handler if you do not need callbacks from the menu (for example, if it only + contains submenus). + + Important: you must pass a valid, non-empty menu title even if the menu is + a submenu where the title is not visible. + } + FUNCTION XPLMCreateMenu( + inName : XPLMString; + inParentMenu : XPLMMenuID; + inParentItem : Integer; + inHandler : XPLMMenuHandler_f; + inMenuRef : pointer) : XPLMMenuID; + cdecl; external XPLM_DLL; + + { + XPLMDestroyMenu + + This function destroys a menu that you have created. Use this to remove a + submenu if necessary. (Normally this function will not be necessary.) + } + PROCEDURE XPLMDestroyMenu( + inMenuID : XPLMMenuID); + cdecl; external XPLM_DLL; + + { + XPLMClearAllMenuItems + + This function removes all menu items from a menu, allowing you to rebuild + it. Use this function if you need to change the number of items on a menu. + } + PROCEDURE XPLMClearAllMenuItems( + inMenuID : XPLMMenuID); + cdecl; external XPLM_DLL; + + { + XPLMAppendMenuItem + + This routine appends a new menu item to the bottom of a menu and returns + its index. Pass in the menu to add the item to, the items name, and a void + * ref for this item. + + Returns a negative index if the append failed (due to an invalid parent + menu argument). + + Note that all menu indices returned are relative to your plugin's menus + only; if your plugin creates two sub-menus in the Plugins menu at different + times, it doesn't matter how many other plugins also create sub-menus of + Plugins in the intervening time: your sub-menus will be given menu indices + 0 and 1. (The SDK does some work in the back-end to filter out menus that + are irrelevant to your plugin in order to deliver this consistency for each + plugin.) + } + FUNCTION XPLMAppendMenuItem( + inMenu : XPLMMenuID; + inItemName : XPLMString; + inItemRef : pointer; + inDeprecatedAndIgnored: Integer) : Integer; + cdecl; external XPLM_DLL; + +{$IFDEF XPLM300} + { + XPLMAppendMenuItemWithCommand + + Like XPLMAppendMenuItem(), but instead of the new menu item triggering the + XPLMMenuHandler_f of the containiner menu, it will simply execute the + command you pass in. Using a command for your menu item allows the user to + bind a keyboard shortcut to the command and see that shortcut represented + in the menu. + + Returns a negative index if the append failed (due to an invalid parent + menu argument). + + Like XPLMAppendMenuItem(), all menu indices are relative to your plugin's + menus only. + } + FUNCTION XPLMAppendMenuItemWithCommand( + inMenu : XPLMMenuID; + inItemName : XPLMString; + inCommandToExecute : XPLMCommandRef) : Integer; + cdecl; external XPLM_DLL; +{$ENDIF XPLM300} + + { + XPLMAppendMenuSeparator + + This routine adds a separator to the end of a menu. + + Returns a negative index if the append failed (due to an invalid parent + menu argument). + } + PROCEDURE XPLMAppendMenuSeparator( + inMenu : XPLMMenuID); + cdecl; external XPLM_DLL; + + { + XPLMSetMenuItemName + + This routine changes the name of an existing menu item. Pass in the menu + ID and the index of the menu item. + } + PROCEDURE XPLMSetMenuItemName( + inMenu : XPLMMenuID; + inIndex : Integer; + inItemName : XPLMString; + inDeprecatedAndIgnored: Integer); + cdecl; external XPLM_DLL; + + { + XPLMCheckMenuItem + + Set whether a menu item is checked. Pass in the menu ID and item index. + } + PROCEDURE XPLMCheckMenuItem( + inMenu : XPLMMenuID; + index : Integer; + inCheck : XPLMMenuCheck); + cdecl; external XPLM_DLL; + + { + XPLMCheckMenuItemState + + This routine returns whether a menu item is checked or not. A menu item's + check mark may be on or off, or a menu may not have an icon at all. + } + PROCEDURE XPLMCheckMenuItemState( + inMenu : XPLMMenuID; + index : Integer; + outCheck : PXPLMMenuCheck); + cdecl; external XPLM_DLL; + + { + XPLMEnableMenuItem + + Sets whether this menu item is enabled. Items start out enabled. + } + PROCEDURE XPLMEnableMenuItem( + inMenu : XPLMMenuID; + index : Integer; + enabled : Integer); + cdecl; external XPLM_DLL; + +{$IFDEF XPLM210} + { + XPLMRemoveMenuItem + + Removes one item from a menu. Note that all menu items below are moved up + one; your plugin must track the change in index numbers. + } + PROCEDURE XPLMRemoveMenuItem( + inMenu : XPLMMenuID; + inIndex : Integer); + cdecl; external XPLM_DLL; +{$ENDIF XPLM210} + + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/SDKold/Delphi/XPLM/XPLMNavigation.pas b/XPLPro_Plugin_Source/SDK/SDKold/Delphi/XPLM/XPLMNavigation.pas new file mode 100644 index 0000000..044b99b --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDKold/Delphi/XPLM/XPLMNavigation.pas @@ -0,0 +1,350 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPLMNavigation; +INTERFACE +{ + The XPLM Navigation APIs give you some access to the navigation databases + inside X-Plane. X-Plane stores all navigation information in RAM, so by + using these APIs you can gain access to most information without having to + go to disk or parse the files yourself. + + You can also use this API to program the FMS. You must use the navigation + APIs to find the nav-aids you want to program into the FMS, since the FMS + is powered internally by X-Plane's navigation database. +} + +USES + XPLMDefs; + {$A4} +{___________________________________________________________________________ + * NAVIGATION DATABASE ACCESS + ___________________________________________________________________________} + + { + XPLMNavType + + These enumerations define the different types of navaids. They are each + defined with a separate bit so that they may be bit-wise added together to + form sets of nav-aid types. + + NOTE: xplm_Nav_LatLon is a specific lat-lon coordinate entered into the + FMS. It will not exist in the database, and cannot be programmed into the + FMS. Querying the FMS for navaids will return it. Use + XPLMSetFMSEntryLatLon to set a lat/lon waypoint. + } +TYPE + XPLMNavType = ( + xplm_Nav_Unknown = 0 + + ,xplm_Nav_Airport = 1 + + ,xplm_Nav_NDB = 2 + + ,xplm_Nav_VOR = 4 + + ,xplm_Nav_ILS = 8 + + ,xplm_Nav_Localizer = 16 + + ,xplm_Nav_GlideSlope = 32 + + ,xplm_Nav_OuterMarker = 64 + + ,xplm_Nav_MiddleMarker = 128 + + ,xplm_Nav_InnerMarker = 256 + + ,xplm_Nav_Fix = 512 + + ,xplm_Nav_DME = 1024 + + ,xplm_Nav_LatLon = 2048 + + ); + PXPLMNavType = ^XPLMNavType; + + { + XPLMNavRef + + XPLMNavRef is an iterator into the navigation database. The navigation + database is essentially an array, but it is not necessarily densely + populated. The only assumption you can safely make is that like-typed + nav-aids are grouped together. + + Use XPLMNavRef to refer to a nav-aid. + + XPLM_NAV_NOT_FOUND is returned by functions that return an XPLMNavRef when + the iterator must be invalid. + } + XPLMNavRef = Integer; + PXPLMNavRef = ^XPLMNavRef; + +CONST + XPLM_NAV_NOT_FOUND = -1; + + { + XPLMGetFirstNavAid + + This returns the very first navaid in the database. Use this to traverse + the entire database. Returns XPLM_NAV_NOT_FOUND if the nav database is + empty. + } + FUNCTION XPLMGetFirstNavAid: XPLMNavRef; + cdecl; external XPLM_DLL; + + { + XPLMGetNextNavAid + + Given a valid nav aid ref, this routine returns the next navaid. It + returns XPLM_NAV_NOT_FOUND if the nav aid passed in was invalid or if the + navaid passed in was the last one in the database. Use this routine to + iterate across all like-typed navaids or the entire database. + } + FUNCTION XPLMGetNextNavAid( + inNavAidRef : XPLMNavRef) : XPLMNavRef; + cdecl; external XPLM_DLL; + + { + XPLMFindFirstNavAidOfType + + This routine returns the ref of the first navaid of the given type in the + database or XPLM_NAV_NOT_FOUND if there are no navaids of that type in the + database. You must pass exactly one nav aid type to this routine. + } + FUNCTION XPLMFindFirstNavAidOfType( + inType : XPLMNavType) : XPLMNavRef; + cdecl; external XPLM_DLL; + + { + XPLMFindLastNavAidOfType + + This routine returns the ref of the last navaid of the given type in the + database or XPLM_NAV_NOT_FOUND if there are no navaids of that type in the + database. You must pass exactly one nav aid type to this routine. + } + FUNCTION XPLMFindLastNavAidOfType( + inType : XPLMNavType) : XPLMNavRef; + cdecl; external XPLM_DLL; + + { + XPLMFindNavAid + + This routine provides a number of searching capabilities for the nav + database. XPLMFindNavAid will search through every nav aid whose type is + within inType (multiple types may be added together) and return any + nav-aids found based on the following rules: + + * If inLat and inLon are not NULL, the navaid nearest to that lat/lon will + be returned, otherwise the last navaid found will be returned. + + * If inFrequency is not NULL, then any navaids considered must match this + frequency. Note that this will screen out radio beacons that do not have + frequency data published (like inner markers) but not fixes and airports. + + * If inNameFragment is not NULL, only navaids that contain the fragment in + their name will be returned. + + * If inIDFragment is not NULL, only navaids that contain the fragment in + their IDs will be returned. + + This routine provides a simple way to do a number of useful searches: + * Find the nearest navaid on this frequency. + * Find the nearest airport. + * Find the VOR whose ID is "KBOS". + * Find the nearest airport whose name contains "Chicago". + } + FUNCTION XPLMFindNavAid( + inNameFragment : XPLMString; { Can be nil } + inIDFragment : XPLMString; { Can be nil } + inLat : PSingle; { Can be nil } + inLon : PSingle; { Can be nil } + inFrequency : PInteger; { Can be nil } + inType : XPLMNavType) : XPLMNavRef; + cdecl; external XPLM_DLL; + + { + XPLMGetNavAidInfo + + This routine returns information about a navaid. Any non-null field is + filled out with information if it is available. + + Frequencies are in the nav.dat convention as described in the X-Plane nav + database FAQ: NDB frequencies are exact, all others are multiplied by 100. + + The buffer for IDs should be at least 6 chars and the buffer for names + should be at least 41 chars, but since these values are likely to go up, I + recommend passing at least 32 chars for IDs and 256 chars for names when + possible. + + The outReg parameter tells if the navaid is within the local "region" of + loaded DSFs. (This information may not be particularly useful to plugins.) + The parameter is a single byte value 1 for true or 0 for false, not a C + string. + } + PROCEDURE XPLMGetNavAidInfo( + inRef : XPLMNavRef; + outType : PXPLMNavType; { Can be nil } + outLatitude : PSingle; { Can be nil } + outLongitude : PSingle; { Can be nil } + outHeight : PSingle; { Can be nil } + outFrequency : PInteger; { Can be nil } + outHeading : PSingle; { Can be nil } + outID : XPLMString; { Can be nil } + outName : XPLMString; { Can be nil } + outReg : XPLMString); { Can be nil } + cdecl; external XPLM_DLL; + +{___________________________________________________________________________ + * FLIGHT MANAGEMENT COMPUTER + ___________________________________________________________________________} +{ + Note: the FMS works based on an array of entries. Indices into the array + are zero-based. Each entry is a nav-aid plus an altitude. The FMS tracks + the currently displayed entry and the entry that it is flying to. + + The FMS must be programmed with contiguous entries, so clearing an entry at + the end shortens the effective flight plan. There is a max of 100 + waypoints in the flight plan. +} + + + { + XPLMCountFMSEntries + + This routine returns the number of entries in the FMS. + } + FUNCTION XPLMCountFMSEntries: Integer; + cdecl; external XPLM_DLL; + + { + XPLMGetDisplayedFMSEntry + + This routine returns the index of the entry the pilot is viewing. + } + FUNCTION XPLMGetDisplayedFMSEntry: Integer; + cdecl; external XPLM_DLL; + + { + XPLMGetDestinationFMSEntry + + This routine returns the index of the entry the FMS is flying to. + } + FUNCTION XPLMGetDestinationFMSEntry: Integer; + cdecl; external XPLM_DLL; + + { + XPLMSetDisplayedFMSEntry + + This routine changes which entry the FMS is showing to the index specified. + } + PROCEDURE XPLMSetDisplayedFMSEntry( + inIndex : Integer); + cdecl; external XPLM_DLL; + + { + XPLMSetDestinationFMSEntry + + This routine changes which entry the FMS is flying the aircraft toward. + } + PROCEDURE XPLMSetDestinationFMSEntry( + inIndex : Integer); + cdecl; external XPLM_DLL; + + { + XPLMGetFMSEntryInfo + + This routine returns information about a given FMS entry. If the entry is + an airport or navaid, a reference to a nav entry can be returned allowing + you to find additional information (such as a frequency, ILS heading, name, + etc.). Note that this reference can be XPLM_NAV_NOT_FOUND until the + information has been looked up asynchronously, so after flightplan changes, + it might take up to a second for this field to become populated. The other + information is available immediately. For a lat/lon entry, the lat/lon is + returned by this routine but the navaid cannot be looked up (and the + reference will be XPLM_NAV_NOT_FOUND). FMS name entry buffers should be at + least 256 chars in length. + + WARNING: Due to a bug in X-Plane prior to 11.31, the navaid reference will + not be set to XPLM_NAV_NOT_FOUND while no data is available, and instead + just remain the value of the variable that you passed the pointer to. + Therefore, always initialize the variable to XPLM_NAV_NOT_FOUND before + passing the pointer to this function. + } + PROCEDURE XPLMGetFMSEntryInfo( + inIndex : Integer; + outType : PXPLMNavType; { Can be nil } + outID : XPLMString; { Can be nil } + outRef : PXPLMNavRef; { Can be nil } + outAltitude : PInteger; { Can be nil } + outLat : PSingle; { Can be nil } + outLon : PSingle); { Can be nil } + cdecl; external XPLM_DLL; + + { + XPLMSetFMSEntryInfo + + This routine changes an entry in the FMS to have the destination navaid + passed in and the altitude specified. Use this only for airports, fixes, + and radio-beacon navaids. Currently of radio beacons, the FMS can only + support VORs and NDBs. Use the routines below to clear or fly to a lat/lon. + } + PROCEDURE XPLMSetFMSEntryInfo( + inIndex : Integer; + inRef : XPLMNavRef; + inAltitude : Integer); + cdecl; external XPLM_DLL; + + { + XPLMSetFMSEntryLatLon + + This routine changes the entry in the FMS to a lat/lon entry with the given + coordinates. + } + PROCEDURE XPLMSetFMSEntryLatLon( + inIndex : Integer; + inLat : Single; + inLon : Single; + inAltitude : Integer); + cdecl; external XPLM_DLL; + + { + XPLMClearFMSEntry + + This routine clears the given entry, potentially shortening the flight + plan. + } + PROCEDURE XPLMClearFMSEntry( + inIndex : Integer); + cdecl; external XPLM_DLL; + +{___________________________________________________________________________ + * GPS RECEIVER + ___________________________________________________________________________} +{ + These APIs let you read data from the GPS unit. +} + + { + XPLMGetGPSDestinationType + + This routine returns the type of the currently selected GPS destination, + one of fix, airport, VOR or NDB. + } + FUNCTION XPLMGetGPSDestinationType: XPLMNavType; + cdecl; external XPLM_DLL; + + { + XPLMGetGPSDestination + + This routine returns the current GPS destination. + } + FUNCTION XPLMGetGPSDestination: XPLMNavRef; + cdecl; external XPLM_DLL; + + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/SDKold/Delphi/XPLM/XPLMPlanes.pas b/XPLPro_Plugin_Source/SDK/SDKold/Delphi/XPLM/XPLMPlanes.pas new file mode 100644 index 0000000..3801f0a --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDKold/Delphi/XPLM/XPLMPlanes.pas @@ -0,0 +1,278 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPLMPlanes; +INTERFACE +{ + The XPLMPlanes APIs allow you to control the various aircraft in X-Plane, + both the user's and the sim's. + + *Note*: unlike almost all other APIs in the SDK, aircraft paths are _full_ + file system paths for historical reasons. You'll need to prefix all + relative paths with the X-Plane path as accessed via XPLMGetSystemPath. +} + +USES + XPLMDefs; + {$A4} +{___________________________________________________________________________ + * USER AIRCRAFT ACCESS + ___________________________________________________________________________} + + { + XPLMSetUsersAircraft + + This routine changes the user's aircraft. Note that this will reinitialize + the user to be on the nearest airport's first runway. Pass in a full path + (hard drive and everything including the .acf extension) to the .acf file. + } + PROCEDURE XPLMSetUsersAircraft( + inAircraftPath : XPLMString); + cdecl; external XPLM_DLL; + { + XPLMPlaceUserAtAirport + + This routine places the user at a given airport. Specify the airport by + its X-Plane airport ID (e.g. 'KBOS'). + } + PROCEDURE XPLMPlaceUserAtAirport( + inAirportCode : XPLMString); + cdecl; external XPLM_DLL; +{$IFDEF XPLM300} + { + XPLMPlaceUserAtLocation + + Places the user at a specific location after performing any necessary + scenery loads. + + As with in-air starts initiated from the X-Plane user interface, the + aircraft will always start with its engines running, regardless of the + user's preferences (i.e., regardless of what the dataref + `sim/operation/prefs/startup_running` says). + } + PROCEDURE XPLMPlaceUserAtLocation( + latitudeDegrees : Real; + longitudeDegrees : Real; + elevationMetersMSL : Single; + headingDegreesTrue : Single; + speedMetersPerSecond: Single); + cdecl; external XPLM_DLL; +{$ENDIF XPLM300} +{___________________________________________________________________________ + * GLOBAL AIRCRAFT ACCESS + ___________________________________________________________________________} + +CONST + { The user's aircraft is always index 0. } + XPLM_USER_AIRCRAFT = 0; +{$IFDEF XPLM_DEPRECATED} + { + XPLMPlaneDrawState_t + + This structure contains additional plane parameter info to be passed to + draw plane. Make sure to fill in the size of the structure field with + sizeof(XPLMDrawPlaneState_t) so that the XPLM can tell how many fields you + knew about when compiling your plugin (since more fields may be added + later). + + Most of these fields are ratios from 0 to 1 for control input. X-Plane + calculates what the actual controls look like based on the .acf file for + that airplane. Note for the yoke inputs, this is what the pilot of the + plane has commanded (post artificial stability system if there were one) + and affects aelerons, rudder, etc. It is not necessarily related to the + actual position of the plane! + } +TYPE + XPLMPlaneDrawState_t = RECORD + { The size of the draw state struct. } + structSize : Integer; + { A ratio from [0..1] describing how far the landing gear is extended. } + gearPosition : Single; + { Ratio of flap deployment, 0 = up, 1 = full deploy. } + flapRatio : Single; + { Ratio of spoiler deployment, 0 = none, 1 = full deploy. } + spoilerRatio : Single; + { Ratio of speed brake deployment, 0 = none, 1 = full deploy. } + speedBrakeRatio : Single; + { Ratio of slat deployment, 0 = none, 1 = full deploy. } + slatRatio : Single; + { Wing sweep ratio, 0 = forward, 1 = swept. } + wingSweep : Single; + { Thrust power, 0 = none, 1 = full fwd, -1 = full reverse. } + thrust : Single; + { Total pitch input for this plane. } + yokePitch : Single; + { Total Heading input for this plane. } + yokeHeading : Single; + { Total Roll input for this plane. } + yokeRoll : Single; + END; + PXPLMPlaneDrawState_t = ^XPLMPlaneDrawState_t; +{$ENDIF XPLM_DEPRECATED} + { + XPLMCountAircraft + + This function returns the number of aircraft X-Plane is capable of having, + as well as the number of aircraft that are currently active. These numbers + count the user's aircraft. It can also return the plugin that is currently + controlling aircraft. In X-Plane 7, this routine reflects the number of + aircraft the user has enabled in the rendering options window. + } + PROCEDURE XPLMCountAircraft( + outTotalAircraft : PInteger; + outActiveAircraft : PInteger; + outController : PXPLMPluginID); + cdecl; external XPLM_DLL; + { + XPLMGetNthAircraftModel + + This function returns the aircraft model for the Nth aircraft. Indices are + zero based, with zero being the user's aircraft. The file name should be + at least 256 chars in length; the path should be at least 512 chars in + length. + } + PROCEDURE XPLMGetNthAircraftModel( + inIndex : Integer; + outFileName : XPLMString; + outPath : XPLMString); + cdecl; external XPLM_DLL; +{___________________________________________________________________________ + * EXCLUSIVE AIRCRAFT ACCESS + ___________________________________________________________________________} +{ + The following routines require exclusive access to the airplane APIs. Only + one plugin may have this access at a time. +} + + + { + XPLMPlanesAvailable_f + + Your airplanes available callback is called when another plugin gives up + access to the multiplayer planes. Use this to wait for access to + multiplayer. + } +TYPE + XPLMPlanesAvailable_f = PROCEDURE( + inRefcon : pointer); cdecl; + + { + XPLMAcquirePlanes + + XPLMAcquirePlanes grants your plugin exclusive access to the aircraft. It + returns 1 if you gain access, 0 if you do not. + + inAircraft - pass in an array of pointers to strings specifying the planes + you want loaded. For any plane index you do not want loaded, pass a + 0-length string. Other strings should be full paths with the .acf + extension. NULL terminates this array, or pass NULL if there are no planes + you want loaded. + + If you pass in a callback and do not receive access to the planes your + callback will be called when the airplanes are available. If you do receive + airplane access, your callback will not be called. + } + FUNCTION XPLMAcquirePlanes( + inAircraft : PXPLMString; { Can be nil } + inCallback : XPLMPlanesAvailable_f; + inRefcon : pointer) : Integer; + cdecl; external XPLM_DLL; + + { + XPLMReleasePlanes + + Call this function to release access to the planes. Note that if you are + disabled, access to planes is released for you and you must reacquire it. + } + PROCEDURE XPLMReleasePlanes; + cdecl; external XPLM_DLL; + + { + XPLMSetActiveAircraftCount + + This routine sets the number of active planes. If you pass in a number + higher than the total number of planes availables, only the total number of + planes available is actually used. + } + PROCEDURE XPLMSetActiveAircraftCount( + inCount : Integer); + cdecl; external XPLM_DLL; + + { + XPLMSetAircraftModel + + This routine loads an aircraft model. It may only be called if you have + exclusive access to the airplane APIs. Pass in the path of the model with + the .acf extension. The index is zero based, but you may not pass in 0 + (use XPLMSetUsersAircraft to load the user's aircracft). + } + PROCEDURE XPLMSetAircraftModel( + inIndex : Integer; + inAircraftPath : XPLMString); + cdecl; external XPLM_DLL; + + { + XPLMDisableAIForPlane + + This routine turns off X-Plane's AI for a given plane. The plane will + continue to draw and be a real plane in X-Plane, but will not move itself. + } + PROCEDURE XPLMDisableAIForPlane( + inPlaneIndex : Integer); + cdecl; external XPLM_DLL; + +{$IFDEF XPLM_DEPRECATED} + { + XPLMDrawAircraft + + WARNING: Aircraft drawing via this API is deprecated and will not work in + future versions of X-Plane. Use XPLMInstance for 3-d drawing of custom + aircraft models. + + This routine draws an aircraft. It can only be called from a 3-d drawing + callback. Pass in the position of the plane in OpenGL local coordinates + and the orientation of the plane. A 1 for full drawing indicates that the + whole plane must be drawn; a 0 indicates you only need the nav lights + drawn. (This saves rendering time when planes are far away.) + } + PROCEDURE XPLMDrawAircraft( + inPlaneIndex : Integer; + inX : Single; + inY : Single; + inZ : Single; + inPitch : Single; + inRoll : Single; + inYaw : Single; + inFullDraw : Integer; + inDrawStateInfo : PXPLMPlaneDrawState_t); + cdecl; external XPLM_DLL; +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + { + XPLMReinitUsersPlane + + WARNING: DO NOT USE. Use XPLMPlaceUserAtAirport or + XPLMPlaceUserAtLocation. + + This function recomputes the derived flight model data from the aircraft + structure in memory. If you have used the data access layer to modify the + aircraft structure, use this routine to resynchronize X-Plane; since + X-Plane works at least partly from derived values, the sim will not behave + properly until this is called. + + WARNING: this routine does not necessarily place the airplane at the + airport; use XPLMSetUsersAircraft to be compatible. This routine is + provided to do special experimentation with flight models without resetting + flight. + } + PROCEDURE XPLMReinitUsersPlane; + cdecl; external XPLM_DLL; +{$ENDIF XPLM_DEPRECATED} + + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/SDKold/Delphi/XPLM/XPLMPlugin.pas b/XPLPro_Plugin_Source/SDK/SDKold/Delphi/XPLM/XPLMPlugin.pas new file mode 100644 index 0000000..83fbb73 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDKold/Delphi/XPLM/XPLMPlugin.pas @@ -0,0 +1,413 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPLMPlugin; +INTERFACE +{ + These APIs provide facilities to find and work with other plugins and + manage other plugins. +} + +USES + XPLMDefs; + {$A4} +{___________________________________________________________________________ + * FINDING PLUGINS + ___________________________________________________________________________} +{ + These APIs allow you to find another plugin or yourself, or iterate across + all plugins. For example, if you wrote an FMS plugin that needed to talk + to an autopilot plugin, you could use these APIs to locate the autopilot + plugin. +} + + + { + XPLMGetMyID + + This routine returns the plugin ID of the calling plug-in. Call this to + get your own ID. + } + FUNCTION XPLMGetMyID: XPLMPluginID; + cdecl; external XPLM_DLL; + + { + XPLMCountPlugins + + This routine returns the total number of plug-ins that are loaded, both + disabled and enabled. + } + FUNCTION XPLMCountPlugins: Integer; + cdecl; external XPLM_DLL; + + { + XPLMGetNthPlugin + + This routine returns the ID of a plug-in by index. Index is 0 based from 0 + to XPLMCountPlugins-1, inclusive. Plugins may be returned in any arbitrary + order. + } + FUNCTION XPLMGetNthPlugin( + inIndex : Integer) : XPLMPluginID; + cdecl; external XPLM_DLL; + + { + XPLMFindPluginByPath + + This routine returns the plug-in ID of the plug-in whose file exists at the + passed in absolute file system path. XPLM_NO_PLUGIN_ID is returned if the + path does not point to a currently loaded plug-in. + } + FUNCTION XPLMFindPluginByPath( + inPath : XPLMString) : XPLMPluginID; + cdecl; external XPLM_DLL; + + { + XPLMFindPluginBySignature + + This routine returns the plug-in ID of the plug-in whose signature matches + what is passed in or XPLM_NO_PLUGIN_ID if no running plug-in has this + signature. Signatures are the best way to identify another plug-in as they + are independent of the file system path of a plug-in or the human-readable + plug-in name, and should be unique for all plug-ins. Use this routine to + locate another plugin that your plugin interoperates with + } + FUNCTION XPLMFindPluginBySignature( + inSignature : XPLMString) : XPLMPluginID; + cdecl; external XPLM_DLL; + + { + XPLMGetPluginInfo + + This routine returns information about a plug-in. Each parameter should be + a pointer to a buffer of at least + 256 characters, or NULL to not receive the information. + + outName - the human-readable name of the plug-in. outFilePath - the + absolute file path to the file that contains this plug-in. outSignature - a + unique string that identifies this plug-in. outDescription - a + human-readable description of this plug-in. + } + PROCEDURE XPLMGetPluginInfo( + inPlugin : XPLMPluginID; + outName : XPLMString; { Can be nil } + outFilePath : XPLMString; { Can be nil } + outSignature : XPLMString; { Can be nil } + outDescription : XPLMString); { Can be nil } + cdecl; external XPLM_DLL; + +{___________________________________________________________________________ + * ENABLING/DISABLING PLUG-INS + ___________________________________________________________________________} +{ + These routines are used to work with plug-ins and manage them. Most + plugins will not need to use these APIs. +} + + + { + XPLMIsPluginEnabled + + Returns whether the specified plug-in is enabled for running. + } + FUNCTION XPLMIsPluginEnabled( + inPluginID : XPLMPluginID) : Integer; + cdecl; external XPLM_DLL; + + { + XPLMEnablePlugin + + This routine enables a plug-in if it is not already enabled. It returns 1 + if the plugin was enabled or successfully enables itself, 0 if it does not. + Plugins may fail to enable (for example, if resources cannot be acquired) + by returning 0 from their XPluginEnable callback. + } + FUNCTION XPLMEnablePlugin( + inPluginID : XPLMPluginID) : Integer; + cdecl; external XPLM_DLL; + + { + XPLMDisablePlugin + + This routine disableds an enabled plug-in. + } + PROCEDURE XPLMDisablePlugin( + inPluginID : XPLMPluginID); + cdecl; external XPLM_DLL; + + { + XPLMReloadPlugins + + This routine reloads all plug-ins. Once this routine is called and you + return from the callback you were within (e.g. a menu select callback) you + will receive your XPluginDisable and XPluginStop callbacks and your DLL + will be unloaded, then the start process happens as if the sim was starting + up. + } + PROCEDURE XPLMReloadPlugins; + cdecl; external XPLM_DLL; + +{___________________________________________________________________________ + * INTERPLUGIN MESSAGING + ___________________________________________________________________________} +{ + Plugin messages are defined as 32-bit integers. Messages below 0x00FFFFFF + are reserved for X-Plane and the plugin SDK. + + Messages come with a pointer parameter; the meaning of this pointer depends + on the message itself. In some messages, the pointer parameter contains an + actual typed pointer to data that can be inspected in the plugin; in these + cases the documentation will state that the parameter "points to" + information. + + in other cases, the value of the pointer is actually an integral number + stuffed into the pointer's storage. In these second cases, the pointer + parameter needs to be cast, not dereferenced. In these caess, the + documentation will state that the parameter "contains" a value, which will + always be an integral type. + + Some messages don't use the pointer parameter - in this case your plugin + should ignore it. + + Messages have two conceptual uses: notifications and commands. Commands + are sent from one plugin to another to induce behavior; notifications are + sent from one plugin to all others for informational purposes. It is + important that commands and notifications not have the same values because + this could cause a notification sent by one plugin to accidentally induce a + command in another. + + By convention, plugin-defined notifications should have the high bit set + (e.g. be greater or equal to unsigned 0x8000000) while commands should have + this bit be cleared. + + The following messages are sent to your plugin by X-Plane. +} + + +CONST + { This message is sent to your plugin whenever the user's plane crashes. The } + { parameter is ignored. } + XPLM_MSG_PLANE_CRASHED = 101; + + { This message is sent to your plugin whenever a new plane is loaded. The } + { parameter contains the index number of the plane being loaded; 0 indicates } + { the user's plane. } + XPLM_MSG_PLANE_LOADED = 102; + + { This messages is sent whenever the user's plane is positioned at a new } + { airport. The parameter is ignored. } + XPLM_MSG_AIRPORT_LOADED = 103; + + { This message is sent whenever new scenery is loaded. Use datarefs to } + { determine the new scenery files that were loaded. The parameter is ignored.} + XPLM_MSG_SCENERY_LOADED = 104; + + { This message is sent whenever the user adjusts the number of X-Plane } + { aircraft models. You must use XPLMCountPlanes to find out how many planes } + { are now available. This message will only be sent in XP7 and higher } + { because in XP6 the number of aircraft is not user-adjustable. The parameter} + { is ignored. } + XPLM_MSG_AIRPLANE_COUNT_CHANGED = 105; + +{$IFDEF XPLM200} +CONST + { This message is sent to your plugin whenever a plane is unloaded. The } + { parameter contains the index number of the plane being unloaded; 0 } + { indicates the user's plane. The parameter is of type int, passed as the } + { value of the pointer. (That is: the parameter is an int, not a pointer to } + { an int.) } + XPLM_MSG_PLANE_UNLOADED = 106; +{$ENDIF XPLM200} + +{$IFDEF XPLM210} +CONST + { This message is sent to your plugin right before X-Plane writes its } + { preferences file. You can use this for two purposes: to write your own } + { preferences, and to modify any datarefs to influence preferences output. } + { For example, if your plugin temporarily modifies saved preferences, you can} + { put them back to their default values here to avoid having the tweaks be } + { persisted if your plugin is not loaded on the next invocation of X-Plane. } + { The parameter is ignored. } + XPLM_MSG_WILL_WRITE_PREFS = 107; +{$ENDIF XPLM210} + +{$IFDEF XPLM210} + { This message is sent to your plugin right after a livery is loaded for an } + { airplane. You can use this to check the new livery (via datarefs) and } + { react accordingly. The parameter contains the index number of the aircraft} + { whose livery is changing. } + XPLM_MSG_LIVERY_LOADED = 108; +{$ENDIF XPLM210} + +{$IFDEF XPLM301} +CONST + { Sent to your plugin right before X-Plane enters virtual reality mode (at } + { which time any windows that are not positioned in VR mode will no longer be} + { visible to the user). The parameter is unused and should be ignored. } + XPLM_MSG_ENTERED_VR = 109; +{$ENDIF XPLM301} + +{$IFDEF XPLM301} + { Sent to your plugin right before X-Plane leaves virtual reality mode (at } + { which time you may want to clean up windows that are positioned in VR } + { mode). The parameter is unused and should be ignored. } + XPLM_MSG_EXITING_VR = 110; +{$ENDIF XPLM301} + +{$IFDEF XPLM303} +CONST + { Sent to your plugin if another plugin wants to take over AI planes. If you } + { are a synthetic traffic provider, that probably means a plugin for an } + { online network has connected and wants to supply aircraft flown by real } + { humans and you should cease to provide synthetic traffic. If however you } + { are providing online traffic from real humans, you probably don't want to } + { disconnect, in which case you just ignore this message. The sender is the } + { plugin ID of the plugin asking for control of the planes now. You can use } + { it to find out who is requesting and whether you should yield to them. } + { Synthetic traffic providers should always yield to online networks. The } + { parameter is unused and should be ignored. } + XPLM_MSG_RELEASE_PLANES = 111; +{$ENDIF XPLM303} + + { + XPLMSendMessageToPlugin + + This function sends a message to another plug-in or X-Plane. Pass + XPLM_NO_PLUGIN_ID to broadcast to all plug-ins. Only enabled plug-ins with + a message receive function receive the message. + } + PROCEDURE XPLMSendMessageToPlugin( + inPlugin : XPLMPluginID; + inMessage : Integer; + inParam : pointer); + cdecl; external XPLM_DLL; + +{$IFDEF XPLM200} +{___________________________________________________________________________ + * Plugin Features API + ___________________________________________________________________________} +{ + The plugin features API allows your plugin to "sign up" for additional + capabilities and plugin system features that are normally disabled for + backward compatibility. This allows advanced plugins to "opt-in" to new + behavior. + + Each feature is defined by a permanent string name. The feature string + names will vary with the particular installation of X-Plane, so plugins + should not expect a feature to be guaranteed present. + + XPLM_WANTS_REFLECTIONS + ---------------------- + + Available in the SDK 2.0 and later for X-Plane 9, enabling this capability + causes your plugin to receive drawing hook callbacks when X-Plane builds + its off-screen reflection and shadow rendering passes. Plugins should + enable this and examine the dataref sim/graphics/view/plane_render_type to + determine whether the drawing callback is for a reflection, shadow + calculation, or the main screen. Rendering can be simlified or omitted for + reflections, and non-solid drawing should be skipped for shadow + calculations. + + **Note**: direct drawing via draw callbacks is not recommended; use the + XPLMInstance API to create object models instead. + + XPLM_USE_NATIVE_PATHS + --------------------- + + available in the SDK 2.1 and later for X-Plane 10, this modifies the plugin + system to use Unix-style paths on all operating systems. With this enabled: + + * OS X paths will match the native OS X Unix. + * Windows will use forward slashes but preserve C:\ or another drive letter + when using complete file paths. + * Linux uses its native file system path scheme. + + Without this enabled: + + * OS X will use CFM file paths separated by a colon. + * Windows will use back-slashes and conventional DOS paths. + * Linux uses its native file system path scheme. + + All plugins should enable this feature on OS X to access the native file + system. + + XPLM_USE_NATIVE_WIDGET_WINDOWS + ------------------------------ + + Available in the SDK 3.0.2 SDK, this capability tells the widgets library + to use new, modern X-Plane backed XPLMDisplay windows to anchor all widget + trees. Without it, widgets will always use legacy windows. + + Plugins should enable this to allow their widget hierarchies to respond to + the user's UI size settings and to map widget-based windwos to a VR HMD. + + Before enabling this, make sure any custom widget code in your plugin is + prepared to cope with the UI coordinate system not being th same as the + OpenGL window coordinate system. +} + + + { + XPLMFeatureEnumerator_f + + You pass an XPLMFeatureEnumerator_f to get a list of all features supported + by a given version running version of X-Plane. This routine is called once + for each feature. + } +TYPE + XPLMFeatureEnumerator_f = PROCEDURE( + inFeature : XPLMString; + inRef : pointer); cdecl; + + { + XPLMHasFeature + + This returns 1 if the given installation of X-Plane supports a feature, or + 0 if it does not. + } + FUNCTION XPLMHasFeature( + inFeature : XPLMString) : Integer; + cdecl; external XPLM_DLL; + + { + XPLMIsFeatureEnabled + + This returns 1 if a feature is currently enabled for your plugin, or 0 if + it is not enabled. It is an error to call this routine with an unsupported + feature. + } + FUNCTION XPLMIsFeatureEnabled( + inFeature : XPLMString) : Integer; + cdecl; external XPLM_DLL; + + { + XPLMEnableFeature + + This routine enables or disables a feature for your plugin. This will + change the running behavior of X-Plane and your plugin in some way, + depending on the feature. + } + PROCEDURE XPLMEnableFeature( + inFeature : XPLMString; + inEnable : Integer); + cdecl; external XPLM_DLL; + + { + XPLMEnumerateFeatures + + This routine calls your enumerator callback once for each feature that this + running version of X-Plane supports. Use this routine to determine all of + the features that X-Plane can support. + } + PROCEDURE XPLMEnumerateFeatures( + inEnumerator : XPLMFeatureEnumerator_f; + inRef : pointer); + cdecl; external XPLM_DLL; + +{$ENDIF XPLM200} + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/SDKold/Delphi/XPLM/XPLMProcessing.pas b/XPLPro_Plugin_Source/SDK/SDKold/Delphi/XPLM/XPLMProcessing.pas new file mode 100644 index 0000000..e09b6e5 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDKold/Delphi/XPLM/XPLMProcessing.pas @@ -0,0 +1,254 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPLMProcessing; +INTERFACE +{ + This API allows you to get regular callbacks during the flight loop, the + part of X-Plane where the plane's position calculates the physics of + flight, etc. Use these APIs to accomplish periodic tasks like logging data + and performing I/O. + + You can receive a callback either just before or just after the per-frame + physics calculations happen - you can use post-FM callbacks to "patch" the + flight model after it has run. + + If the user has set the number of flight model iterations per frame greater + than one your plugin will _not_ see this; these integrations run on the + sub-section of the flight model where iterations improve responsiveness + (e.g. physical integration, not simple systems tracking) and are thus + opaque to plugins. + + Flight loop scheduling, when scheduled by time, is scheduled by a "first + callback after the deadline" schedule, e.g. your callbacks will always be + slightly late to ensure that we don't run faster than your deadline. + + WARNING: Do NOT use these callbacks to draw! You cannot draw during flight + loop callbacks. Use the drawing callbacks (see XPLMDisplay for more info) + for graphics. (One exception: you can use a post-flight loop callback to + update your own off-screen FBOs.) +} + +USES + XPLMDefs; + {$A4} +{___________________________________________________________________________ + * FLIGHT LOOP CALLBACKS + ___________________________________________________________________________} + +{$IFDEF XPLM210} + { + XPLMFlightLoopPhaseType + + You can register a flight loop callback to run either before or after the + flight model is integrated by X-Plane. + } +TYPE + XPLMFlightLoopPhaseType = ( + { Your callback runs before X-Plane integrates the flight model. } + xplm_FlightLoop_Phase_BeforeFlightModel = 0 + + { Your callback runs after X-Plane integrates the flight model. } + ,xplm_FlightLoop_Phase_AfterFlightModel = 1 + + ); + PXPLMFlightLoopPhaseType = ^XPLMFlightLoopPhaseType; +{$ENDIF XPLM210} + +{$IFDEF XPLM210} + { + XPLMFlightLoopID + + This is an opaque identifier for a flight loop callback. You can use this + identifier to easily track and remove your callbacks, or to use the new + flight loop APIs. + } + XPLMFlightLoopID = pointer; + PXPLMFlightLoopID = ^XPLMFlightLoopID; +{$ENDIF XPLM210} + + { + XPLMFlightLoop_f + + This is your flight loop callback. Each time the flight loop is iterated + through, you receive this call at the end. + + Flight loop callbacks receive a number of input timing parameters. These + input timing parameters are not particularly useful; you may need to track + your own timing data (e.g. by reading datarefs). The input parameters are: + + - inElapsedSinceLastCall: the wall time since your last callback. + - inElapsedTimeSinceLastFlightLoop: the wall time since any flight loop was + dispatched. + - inCounter: a monotonically increasing counter, bumped once per flight + loop dispatch from the sim. + - inRefcon: your own ptr constant from when you regitered yor callback. + + Your return value controls when you will next be called. + + - Return 0 to stop receiving callbacks. + - Pass a positive number to specify how many seconds until the next + callback. (You will be called at or after this time, not before.) + - Pass a negative number to specify how many loops must go by until you + are called. For example, -1.0 means call me the very next loop. + + Try to run your flight loop as infrequently as is practical, and suspend it + (using return value 0) when you do not need it; lots of flight loop + callbacks that do nothing lowers X-Plane's frame rate. + + Your callback will NOT be unregistered if you return 0; it will merely be + inactive. + } +TYPE + XPLMFlightLoop_f = FUNCTION( + inElapsedSinceLastCall: Single; + inElapsedTimeSinceLastFlightLoop: Single; + inCounter : Integer; + inRefcon : pointer) : Single; cdecl; + +{$IFDEF XPLM210} + { + XPLMCreateFlightLoop_t + + XPLMCreateFlightLoop_t contains the parameters to create a new flight loop + callback. The strsucture can be expanded in future SDKs - always set + structSize to the size of your structure in bytes. + } +TYPE + XPLMCreateFlightLoop_t = RECORD + structSize : Integer; + phase : XPLMFlightLoopPhaseType; + callbackFunc : XPLMFlightLoop_f; + refcon : pointer; + END; + PXPLMCreateFlightLoop_t = ^XPLMCreateFlightLoop_t; +{$ENDIF XPLM210} + + { + XPLMGetElapsedTime + + This routine returns the elapsed time since the sim started up in decimal + seconds. This is a wall timer; it keeps counting upward even if the sim is + pasued. + + __WARNING__: XPLMGetElapsedTime is not a very good timer! It lacks + precision in both its data type and its source. Do not attempt to use it + for timing critical applications like network multiplayer. + } + FUNCTION XPLMGetElapsedTime: Single; + cdecl; external XPLM_DLL; + + { + XPLMGetCycleNumber + + This routine returns a counter starting at zero for each sim cycle + computed/video frame rendered. + } + FUNCTION XPLMGetCycleNumber: Integer; + cdecl; external XPLM_DLL; + + { + XPLMRegisterFlightLoopCallback + + This routine registers your flight loop callback. Pass in a pointer to a + flight loop function and a refcon. inInterval defines when you will be + called. Pass in a positive number to specify seconds from registration time + to the next callback. Pass in a negative number to indicate when you will + be called (e.g. pass -1 to be called at the next cylcle). Pass 0 to not be + called; your callback will be inactive. + + (This legacy function only installs pre-flight-loop callbacks; use + XPLMCreateFlightLoop for more control.) + } + PROCEDURE XPLMRegisterFlightLoopCallback( + inFlightLoop : XPLMFlightLoop_f; + inInterval : Single; + inRefcon : pointer); + cdecl; external XPLM_DLL; + + { + XPLMUnregisterFlightLoopCallback + + This routine unregisters your flight loop callback. Do NOT call it from + your flight loop callback. Once your flight loop callback is unregistered, + it will not be called again. + + Only use this on flight loops registered via + XPLMRegisterFlightLoopCallback. + } + PROCEDURE XPLMUnregisterFlightLoopCallback( + inFlightLoop : XPLMFlightLoop_f; + inRefcon : pointer); + cdecl; external XPLM_DLL; + + { + XPLMSetFlightLoopCallbackInterval + + This routine sets when a callback will be called. Do NOT call it from your + callback; use the return value of the callback to change your callback + interval from inside your callback. + + inInterval is formatted the same way as in XPLMRegisterFlightLoopCallback; + positive for seconds, negative for cycles, and 0 for deactivating the + callback. If inRelativeToNow is 1, times are from the time of this call; + otherwise they are from the time the callback was last called (or the time + it was registered if it has never been called. + } + PROCEDURE XPLMSetFlightLoopCallbackInterval( + inFlightLoop : XPLMFlightLoop_f; + inInterval : Single; + inRelativeToNow : Integer; + inRefcon : pointer); + cdecl; external XPLM_DLL; + +{$IFDEF XPLM210} + { + XPLMCreateFlightLoop + + This routine creates a flight loop callback and returns its ID. The flight + loop callback is created using the input param struct, and is inited to be + unscheduled. + } + FUNCTION XPLMCreateFlightLoop( + inParams : PXPLMCreateFlightLoop_t) : XPLMFlightLoopID; + cdecl; external XPLM_DLL; +{$ENDIF XPLM210} + +{$IFDEF XPLM210} + { + XPLMDestroyFlightLoop + + This routine destroys a flight loop callback by ID. Only call it on flight + loops created with the newer XPLMCreateFlightLoop API. + } + PROCEDURE XPLMDestroyFlightLoop( + inFlightLoopID : XPLMFlightLoopID); + cdecl; external XPLM_DLL; +{$ENDIF XPLM210} + +{$IFDEF XPLM210} + { + XPLMScheduleFlightLoop + + This routine schedules a flight loop callback for future execution. If + inInterval is negative, it is run in a certain number of frames based on + the absolute value of the input. If the interval is positive, it is a + duration in seconds. + + If inRelativeToNow is true, ties are interpretted relative to the time this + routine is called; otherwise they are relative to the last call time or the + time the flight loop was registered (if never called). + } + PROCEDURE XPLMScheduleFlightLoop( + inFlightLoopID : XPLMFlightLoopID; + inInterval : Single; + inRelativeToNow : Integer); + cdecl; external XPLM_DLL; +{$ENDIF XPLM210} + + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/SDKold/Delphi/XPLM/XPLMScenery.pas b/XPLPro_Plugin_Source/SDK/SDKold/Delphi/XPLM/XPLMScenery.pas new file mode 100644 index 0000000..a585830 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDKold/Delphi/XPLM/XPLMScenery.pas @@ -0,0 +1,434 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPLMScenery; +INTERFACE +{ + This package contains APIs to interact with X-Plane's scenery system. +} + +USES + XPLMDefs; + {$A4} +{$IFDEF XPLM200} +{___________________________________________________________________________ + * Terrain Y-Testing + ___________________________________________________________________________} +{ + The Y-testing API allows you to locate the physical scenery mesh. This + would be used to place dynamic graphics on top of the ground in a plausible + way or do physics interactions. + + The Y-test API works via probe objects, which are allocated by your plugin + and used to query terrain. Probe objects exist both to capture which + algorithm you have requested (see probe types) and also to cache query + information. + + Performance Guidelines + ---------------------- + + It is generally faster to use the same probe for nearby points and + different probes for different points. Try not to allocate more than + "hundreds" of probes at most. Share probes if you need more. Generally, + probing operations are expensive, and should be avoided via caching when + possible. + + Y testing returns a location on the terrain, a normal vectory, and a + velocity vector. The normal vector tells you the slope of the terrain at + that point. The velocity vector tells you if that terrain is moving (and is + in meters/second). For example, if your Y test hits the aircraft carrier + deck, this tells you the velocity of that point on the deck. + + Note: the Y-testing API is limited to probing the loaded scenery area, + which is approximately 300x300 km in X-Plane 9. Probes outside this area + will return the height of a 0 MSL sphere. +} + + + { + XPLMProbeType + + XPLMProbeType defines the type of terrain probe - each probe has a + different algorithm. (Only one type of probe is provided right now, but + future APIs will expose more flexible or poewrful or useful probes. + } +TYPE + XPLMProbeType = ( + { The Y probe gives you the location of the tallest physical scenery along } + { the Y axis going through the queried point. } + xplm_ProbeY = 0 + + ); + PXPLMProbeType = ^XPLMProbeType; + + { + XPLMProbeResult + + Probe results - possible results from a probe query. + } + XPLMProbeResult = ( + { The probe hit terrain and returned valid values. } + xplm_ProbeHitTerrain = 0 + + { An error in the API call. Either the probe struct size is bad, or the } + { probe is invalid or the type is mismatched for the specific query call. } + ,xplm_ProbeError = 1 + + { The probe call succeeded but there is no terrain under this point (perhaps } + { it is off the side of the planet?) } + ,xplm_ProbeMissed = 2 + + ); + PXPLMProbeResult = ^XPLMProbeResult; + + { + XPLMProbeRef + + An XPLMProbeRef is an opaque handle to a probe, used for querying the + terrain. + } + XPLMProbeRef = pointer; + PXPLMProbeRef = ^XPLMProbeRef; + + { + XPLMProbeInfo_t + + XPLMProbeInfo_t contains the results of a probe call. Make sure to set + structSize to the size of the struct before using it. + } + XPLMProbeInfo_t = RECORD + { Size of structure in bytes - always set this before calling the XPLM. } + structSize : Integer; + { Resulting X location of the terrain point we hit, in local OpenGL } + { coordinates. } + locationX : Single; + { Resulting Y location of the terrain point we hit, in local OpenGL } + { coordinates. } + locationY : Single; + { Resulting Z location of the terrain point we hit, in local OpenGL } + { coordinates. } + locationZ : Single; + { X component of the normal vector to the terrain we found. } + normalX : Single; + { Y component of the normal vector to the terrain we found. } + normalY : Single; + { Z component of the normal vector to the terrain we found. } + normalZ : Single; + { X component of the velocity vector of the terrain we found. } + velocityX : Single; + { Y component of the velocity vector of the terrain we found. } + velocityY : Single; + { Z component of the velocity vector of the terrain we found. } + velocityZ : Single; + { Tells if the surface we hit is water (otherwise it is land). } + is_wet : Integer; + END; + PXPLMProbeInfo_t = ^XPLMProbeInfo_t; + + { + XPLMCreateProbe + + Creates a new probe object of a given type and returns. + } + FUNCTION XPLMCreateProbe( + inProbeType : XPLMProbeType) : XPLMProbeRef; + cdecl; external XPLM_DLL; + + { + XPLMDestroyProbe + + Deallocates an existing probe object. + } + PROCEDURE XPLMDestroyProbe( + inProbe : XPLMProbeRef); + cdecl; external XPLM_DLL; + + { + XPLMProbeTerrainXYZ + + Probes the terrain. Pass in the XYZ coordinate of the probe point, a probe + object, and an XPLMProbeInfo_t struct that has its structSize member set + properly. Other fields are filled in if we hit terrain, and a probe result + is returned. + } + FUNCTION XPLMProbeTerrainXYZ( + inProbe : XPLMProbeRef; + inX : Single; + inY : Single; + inZ : Single; + outInfo : PXPLMProbeInfo_t) : XPLMProbeResult; + cdecl; external XPLM_DLL; + +{$ENDIF XPLM200} +{$IFDEF XPLM300} +{___________________________________________________________________________ + * Magnetic Variation + ___________________________________________________________________________} +{ + Use the magnetic variation (more properly, the "magnetic declination") API + to find the offset of magnetic north from true north at a given latitude + and longitude within the simulator. + + In the real world, the Earth's magnetic field is irregular, such that true + north (the direction along a meridian toward the north pole) does not + necessarily match what a magnetic compass shows as north. + + Using this API ensures that you present the same offsets to users as + X-Plane's built-in instruments. +} + + + { + XPLMGetMagneticVariation + + Returns X-Plane's simulated magnetic variation (declination) at the + indication latitude and longitude. + } + FUNCTION XPLMGetMagneticVariation( + latitude : Real; + longitude : Real) : Single; + cdecl; external XPLM_DLL; + + { + XPLMDegTrueToDegMagnetic + + Converts a heading in degrees relative to true north into a value relative + to magnetic north at the user's current location. + } + FUNCTION XPLMDegTrueToDegMagnetic( + headingDegreesTrue : Single) : Single; + cdecl; external XPLM_DLL; + + { + XPLMDegMagneticToDegTrue + + Converts a heading in degrees relative to magnetic north at the user's + current location into a value relative to true north. + } + FUNCTION XPLMDegMagneticToDegTrue( + headingDegreesMagnetic: Single) : Single; + cdecl; external XPLM_DLL; + +{$ENDIF XPLM300} +{___________________________________________________________________________ + * Object Drawing + ___________________________________________________________________________} +{ + The object drawing routines let you load and draw X-Plane OBJ files. + Objects are loaded by file path and managed via an opaque handle. X-Plane + naturally reference counts objects, so it is important that you balance + every successful call to XPLMLoadObject with a call to XPLMUnloadObject! +} + + +{$IFDEF XPLM200} +TYPE + { + XPLMObjectRef + + An XPLMObjectRef is a opaque handle to an .obj file that has been loaded + into memory. + } + XPLMObjectRef = pointer; + PXPLMObjectRef = ^XPLMObjectRef; +{$ENDIF XPLM200} + +{$IFDEF XPLM200} + { + XPLMDrawInfo_t + + The XPLMDrawInfo_t structure contains positioning info for one object that + is to be drawn. Be sure to set structSize to the size of the structure for + future expansion. + } + XPLMDrawInfo_t = RECORD + { Set this to the size of this structure! } + structSize : Integer; + { X location of the object in local coordinates. } + x : Single; + { Y location of the object in local coordinates. } + y : Single; + { Z location of the object in local coordinates. } + z : Single; + { Pitch in degres to rotate the object, positive is up. } + pitch : Single; + { Heading in local coordinates to rotate the object, clockwise. } + heading : Single; + { Roll to rotate the object. } + roll : Single; + END; + PXPLMDrawInfo_t = ^XPLMDrawInfo_t; +{$ENDIF XPLM200} + +{$IFDEF XPLM210} + { + XPLMObjectLoaded_f + + You provide this callback when loading an object asynchronously; it will be + called once the object is loaded. Your refcon is passed back. The object + ref passed in is the newly loaded object (ready for use) or NULL if an + error occured. + + If your plugin is disabled, this callback will be delivered as soon as the + plugin is re-enabled. If your plugin is unloaded before this callback is + ever called, the SDK will release the object handle for you. + } +TYPE + XPLMObjectLoaded_f = PROCEDURE( + inObject : XPLMObjectRef; + inRefcon : pointer); cdecl; +{$ENDIF XPLM210} + +{$IFDEF XPLM200} + { + XPLMLoadObject + + This routine loads an OBJ file and returns a handle to it. If X-Plane has + already loaded the object, the handle to the existing object is returned. + Do not assume you will get the same handle back twice, but do make sure to + call unload once for every load to avoid "leaking" objects. The object will + be purged from memory when no plugins and no scenery are using it. + + The path for the object must be relative to the X-System base folder. If + the path is in the root of the X-System folder you may need to prepend ./ + to it; loading objects in the root of the X-System folder is STRONGLY + discouraged - your plugin should not dump art resources in the root folder! + + XPLMLoadObject will return NULL if the object cannot be loaded (either + because it is not found or the file is misformatted). This routine will + load any object that can be used in the X-Plane scenery system. + + It is important that the datarefs an object uses for animation already be + loaded before you load the object. For this reason it may be necessary to + defer object loading until the sim has fully started. + } + FUNCTION XPLMLoadObject( + inPath : XPLMString) : XPLMObjectRef; + cdecl; external XPLM_DLL; +{$ENDIF XPLM200} + +{$IFDEF XPLM210} + { + XPLMLoadObjectAsync + + This routine loads an object asynchronously; control is returned to you + immediately while X-Plane loads the object. The sim will not stop flying + while the object loads. For large objects, it may be several seconds before + the load finishes. + + You provide a callback function that is called once the load has completed. + Note that if the object cannot be loaded, you will not find out until the + callback function is called with a NULL object handle. + + There is no way to cancel an asynchronous object load; you must wait for + the load to complete and then release the object if it is no longer + desired. + } + PROCEDURE XPLMLoadObjectAsync( + inPath : XPLMString; + inCallback : XPLMObjectLoaded_f; + inRefcon : pointer); + cdecl; external XPLM_DLL; +{$ENDIF XPLM210} + +{$IFDEF XPLM_DEPRECATED} + { + XPLMDrawObjects + + __Deprecation Warning__: use XPLMInstancing to draw 3-d objects by creating + instances, rather than these APIs from draw callbacks. + + XPLMDrawObjects draws an object from an OBJ file one or more times. You + pass in the object and an array of XPLMDrawInfo_t structs, one for each + place you would like the object to be drawn. + + X-Plane will attempt to cull the objects based on LOD and visibility, and + will pick the appropriate LOD. + + Lighting is a boolean; pass 1 to show the night version of object with + night-only lights lit up. Pass 0 to show the daytime version of the object. + + earth_relative controls the coordinate system. If this is 1, the rotations + you specify are applied to the object after its coordinate system is + transformed from local to earth-relative coordinates -- that is, an object + with no rotations will point toward true north and the Y axis will be up + against gravity. If this is 0, the object is drawn with your rotations from + local coordanates -- that is, an object with no rotations is drawn pointing + down the -Z axis and the Y axis of the object matches the local coordinate + Y axis. + } + PROCEDURE XPLMDrawObjects( + inObject : XPLMObjectRef; + inCount : Integer; + inLocations : PXPLMDrawInfo_t; + lighting : Integer; + earth_relative : Integer); + cdecl; external XPLM_DLL; +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM200} + { + XPLMUnloadObject + + This routine marks an object as no longer being used by your plugin. + Objects are reference counted: once no plugins are using an object, it is + purged from memory. Make sure to call XPLMUnloadObject once for each + successful call to XPLMLoadObject. + } + PROCEDURE XPLMUnloadObject( + inObject : XPLMObjectRef); + cdecl; external XPLM_DLL; +{$ENDIF XPLM200} + +{$IFDEF XPLM200} +{___________________________________________________________________________ + * Library Access + ___________________________________________________________________________} +{ + The library access routines allow you to locate scenery objects via the + X-Plane library system. Right now library access is only provided for + objects, allowing plugin-drawn objects to be extended using the library + system. +} + + + { + XPLMLibraryEnumerator_f + + An XPLMLibraryEnumerator_f is a callback you provide that is called once + for each library element that is located. The returned paths will be + relative to the X-System folder. + } +TYPE + XPLMLibraryEnumerator_f = PROCEDURE( + inFilePath : XPLMString; + inRef : pointer); cdecl; + + { + XPLMLookupObjects + + This routine looks up a virtual path in the library system and returns all + matching elements. You provide a callback - one virtual path may match many + objects in the library. XPLMLookupObjects returns the number of objects + found. + + The latitude and longitude parameters specify the location the object will + be used. The library system allows for scenery packages to only provide + objects to certain local locations. Only objects that are allowed at the + latitude/longitude you provide will be returned. + } + FUNCTION XPLMLookupObjects( + inPath : XPLMString; + inLatitude : Single; + inLongitude : Single; + enumerator : XPLMLibraryEnumerator_f; + ref : pointer) : Integer; + cdecl; external XPLM_DLL; + +{$ENDIF XPLM200} + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/SDKold/Delphi/XPLM/XPLMUtilities.pas b/XPLPro_Plugin_Source/SDK/SDKold/Delphi/XPLM/XPLMUtilities.pas new file mode 100644 index 0000000..121e28b --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDKold/Delphi/XPLM/XPLMUtilities.pas @@ -0,0 +1,951 @@ +{ + Copyright 2005-2012 Sandy Barbour and Ben Supnik All rights reserved. See + license.txt for usage. X-Plane SDK Version: 2.1.1 +} + +UNIT XPLMUtilities; +INTERFACE + +USES + XPLMDefs; + {$A4} +{___________________________________________________________________________ + * FILE UTILITIES + ___________________________________________________________________________} +{ + The XPLMUtilities file APIs provide some basic file and path functions for + use with X-Plane. + + Directory Separators + -------------------- + + The XPLM has two modes it can work in: + + * X-Plane native paths: all paths are UTF8 strings, using the unix forward + slash (/) as the directory separating character. In native path mode, + you use the same path format for all three operating systems. + + * Legacy OS paths: the directroy separator is \ for Windows, : for OS X, + and / for Linux; OS paths are encoded in MacRoman for OS X using legacy + HFS conventions, use the application code page for multi-byte encoding + on Unix using DOS path conventions, and use UTF-8 for Linux. + + While legacy OS paths are the default, we strongly encourage you to opt in + to native paths using the XPLMEnableFeature API. + + * All OS X plugins should enable native paths all of the time; if you do + not do this, you will have to convert all paths back from HFS to Unix + (and deal with MacRoman) - code written using native paths and the C + file APIs "just works" on OS X. + + * For Linux plugins, there is no difference between the two encodings. + + * Windows plugins will need to convert the UTF8 file paths to UTF16 for + use with the "wide" APIs. While it might seem tempting to stick with + legacy OS paths (and just use the "ANSI" Windows APIs), X-Plane is fully + unicode-capable, and will often be installed in paths where the user's + directories have no ACP encoding. + + Full and Relative Paths + ----------------------- + + Some of these APIs use full paths, but others use paths relative to the + user's X-Plane installation. This is documented on a per-API basis. +} + + +{$IFDEF XPLM200} + { + XPLMDataFileType + + These enums define types of data files you can load or unload using the + SDK. + } +TYPE + XPLMDataFileType = ( + { A situation (.sit) file, which starts off a flight in a given } + { configuration. } + xplm_DataFile_Situation = 1 + + { A situation movie (.smo) file, which replays a past flight. } + ,xplm_DataFile_ReplayMovie = 2 + + ); + PXPLMDataFileType = ^XPLMDataFileType; +{$ENDIF XPLM200} + + { + XPLMGetSystemPath + + This function returns the full path to the X-System folder. Note that this + is a directory path, so it ends in a trailing : or /. + + The buffer you pass should be at least 512 characters long. The path is + returned using the current native or OS path conventions. + } + PROCEDURE XPLMGetSystemPath( + outSystemPath : XPLMString); + cdecl; external XPLM_DLL; + + { + XPLMGetPrefsPath + + This routine returns a full path to a file that is within X-Plane's + preferences directory. (You should remove the file name back to the last + directory separator to get the preferences directory using + XPLMExtractFileAndPath.) + + The buffer you pass should be at least 512 characters long. The path is + returned using the current native or OS path conventions. + } + PROCEDURE XPLMGetPrefsPath( + outPrefsPath : XPLMString); + cdecl; external XPLM_DLL; + + { + XPLMGetDirectorySeparator + + This routine returns a string with one char and a null terminator that is + the directory separator for the current platform. This allows you to write + code that concatinates directory paths without having to #ifdef for + platform. The character returned will reflect the current file path mode. + } + FUNCTION XPLMGetDirectorySeparator: XPLMString; + cdecl; external XPLM_DLL; + + { + XPLMExtractFileAndPath + + Given a full path to a file, this routine separates the path from the file. + If the path is a partial directory (e.g. ends in : or \) the trailing + directory separator is removed. This routine works in-place; a pointer to + the file part of the buffer is returned; the original buffer still starts + with the path and is null terminated with no trailing separator. + } + FUNCTION XPLMExtractFileAndPath( + inFullPath : XPLMString) : XPLMString; + cdecl; external XPLM_DLL; + + { + XPLMGetDirectoryContents + + This routine returns a list of files in a directory (specified by a full + path, no trailing : or \). The output is returned as a list of NULL + terminated strings. An index array (if specified) is filled with pointers + into the strings. The last file is indicated by a zero-length string (and + NULL in the indices). This routine will return 1 if you had capacity for + all files or 0 if you did not. You can also skip a given number of files. + + * inDirectoryPath - a null terminated C string containing the full path to + the directory with no trailing directory char. + + * inFirstReturn - the zero-based index of the first file in the directory + to return. (Usually zero to fetch all in one pass.) + + * outFileNames - a buffer to receive a series of sequential null + terminated C-string file names. A zero-length C string will be appended + to the very end. + + * inFileNameBufSize - the size of the file name buffer in bytes. + + * outIndices - a pointer to an array of character pointers that will + become an index into the directory. The last file will be followed by a + NULL value. Pass NULL if you do not want indexing information. + + * inIndexCount - the max size of the index in entries. + + * outTotalFiles - if not NULL, this is filled in with the number of files + in the directory. + + * outReturnedFiles - if not NULL, the number of files returned by this + iteration. + + Return value: 1 if all info could be returned, 0 if there was a buffer + overrun. + + WARNING: Before X-Plane 7 this routine did not properly iterate through + directories. If X-Plane + 6 compatibility is needed, use your own code to iterate directories. + } + FUNCTION XPLMGetDirectoryContents( + inDirectoryPath : XPLMString; + inFirstReturn : Integer; + outFileNames : XPLMString; + inFileNameBufSize : Integer; + outIndices : PXPLMString; { Can be nil } + inIndexCount : Integer; + outTotalFiles : PInteger; { Can be nil } + outReturnedFiles : PInteger) : Integer; { Can be nil } + cdecl; external XPLM_DLL; + +{$IFDEF XPLM200} + { + XPLMLoadDataFile + + Loads a data file of a given type. Paths must be relative to the X-System + folder. To clear the replay, pass a NULL file name (this is only valid with + replay movies, not sit files). + } + FUNCTION XPLMLoadDataFile( + inFileType : XPLMDataFileType; + inFilePath : XPLMString) : Integer; { Can be nil } + cdecl; external XPLM_DLL; +{$ENDIF XPLM200} + +{$IFDEF XPLM200} + { + XPLMSaveDataFile + + Saves the current situation or replay; paths are relative to the X-System + folder. + } + FUNCTION XPLMSaveDataFile( + inFileType : XPLMDataFileType; + inFilePath : XPLMString) : Integer; + cdecl; external XPLM_DLL; +{$ENDIF XPLM200} + +{___________________________________________________________________________ + * X-PLANE MISC + ___________________________________________________________________________} + + { + XPLMHostApplicationID + + While the plug-in SDK is only accessible to plugins running inside X-Plane, + the original authors considered extending the API to other applications + that shared basic infrastructure with X-Plane. These enumerations are + hold-overs from that original roadmap; all values other than X-Plane are + deprecated. Your plugin should never need this enumeration. + } +TYPE + XPLMHostApplicationID = ( + xplm_Host_Unknown = 0 + + ,xplm_Host_XPlane = 1 + +{$IFDEF XPLM_DEPRECATED} + ,xplm_Host_PlaneMaker = 2 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + ,xplm_Host_WorldMaker = 3 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + ,xplm_Host_Briefer = 4 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + ,xplm_Host_PartMaker = 5 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + ,xplm_Host_YoungsMod = 6 +{$ENDIF XPLM_DEPRECATED} + +{$IFDEF XPLM_DEPRECATED} + ,xplm_Host_XAuto = 7 +{$ENDIF XPLM_DEPRECATED} + + ); + PXPLMHostApplicationID = ^XPLMHostApplicationID; + + { + XPLMLanguageCode + + These enums define what language the sim is running in. These enumerations + do not imply that the sim can or does run in all of these languages; they + simply provide a known encoding in the event that a given sim version is + localized to a certain language. + } + XPLMLanguageCode = ( + xplm_Language_Unknown = 0 + + ,xplm_Language_English = 1 + + ,xplm_Language_French = 2 + + ,xplm_Language_German = 3 + + ,xplm_Language_Italian = 4 + + ,xplm_Language_Spanish = 5 + + ,xplm_Language_Korean = 6 + +{$IFDEF XPLM200} + ,xplm_Language_Russian = 7 +{$ENDIF XPLM200} + +{$IFDEF XPLM200} + ,xplm_Language_Greek = 8 +{$ENDIF XPLM200} + +{$IFDEF XPLM200} + ,xplm_Language_Japanese = 9 +{$ENDIF XPLM200} + +{$IFDEF XPLM300} + ,xplm_Language_Chinese = 10 +{$ENDIF XPLM300} + + ); + PXPLMLanguageCode = ^XPLMLanguageCode; + +{$IFDEF XPLM200} + { + XPLMError_f + + An XPLM error callback is a function that you provide to receive debugging + information from the plugin SDK. See XPLMSetErrorCallback for more + information. NOTE: for the sake of debugging, your error callback will be + called even if your plugin is not enabled, allowing you to receive debug + info in your XPluginStart and XPluginStop callbacks. To avoid causing logic + errors in the management code, do not call any other plugin routines from + your error callback - it is only meant for catching errors in the + debugging. + } +TYPE + XPLMError_f = PROCEDURE( + inMessage : XPLMString); cdecl; +{$ENDIF XPLM200} + +{$IFDEF XPLM_DEPRECATED} + { + XPLMInitialized + + Deprecated: This function returns 1 if X-Plane has properly initialized the + plug-in system. If this routine returns 0, many XPLM functions will not + work. + + NOTE: because plugins are always called from within the XPLM, there is no + need to check for initialization; it will always return 1. This routine is + deprecated - you do not need to check it before continuing within your + plugin. + } + FUNCTION XPLMInitialized: Integer; + cdecl; external XPLM_DLL; +{$ENDIF XPLM_DEPRECATED} + + { + XPLMGetVersions + + This routine returns the revision of both X-Plane and the XPLM DLL. All + versions are three-digit decimal numbers (e.g. 606 for version 6.06 of + X-Plane); the current revision of the XPLM is 200 (2.00). This routine also + returns the host ID of the app running us. + + The most common use of this routine is to special-case around X-Plane + version-specific behavior. + } + PROCEDURE XPLMGetVersions( + outXPlaneVersion : PInteger; + outXPLMVersion : PInteger; + outHostID : PXPLMHostApplicationID); + cdecl; external XPLM_DLL; + + { + XPLMGetLanguage + + This routine returns the langauge the sim is running in. + } + FUNCTION XPLMGetLanguage: XPLMLanguageCode; + cdecl; external XPLM_DLL; + +{$IFDEF XPLM200} + { + XPLMFindSymbol + + This routine will attempt to find the symbol passed in the inString + parameter. If the symbol is found a pointer the function is returned, + othewise the function will return NULL. + + You can use XPLMFindSymbol to utilize newer SDK API features without + requiring newer versions of the SDK (and X-Plane) as your minimum X-Plane + version as follows: + + * Define the XPLMnnn macro to the minimum required XPLM version you will + ship with (e.g. XPLM210 for X-Plane 10 compatibility). + + * Use XPLMGetVersions and XPLMFindSymbol to detect that the host sim is + new enough to use new functions and resolve function pointers. + + * Conditionally use the new functions if and only if XPLMFindSymbol only + returns a non- NULL pointer. + + Warning: you should always check the XPLM API version as well as the + results of XPLMFindSymbol to determine if funtionality is safe to use. + + To use functionality via XPLMFindSymbol you will need to copy your own + definitions of the X-Plane API prototypes and cast the returned pointer to + the correct type. + } + FUNCTION XPLMFindSymbol( + inString : XPLMString) : pointer; + cdecl; external XPLM_DLL; +{$ENDIF XPLM200} + +{$IFDEF XPLM200} + { + XPLMSetErrorCallback + + XPLMSetErrorCallback installs an error-reporting callback for your plugin. + Normally the plugin system performs minimum diagnostics to maximize + performance. When you install an error callback, you will receive calls due + to certain plugin errors, such as passing bad parameters or incorrect data. + + Important: the error callback determines *programming* errors, e.g. bad API + parameters. Every error that is returned by the error callback represents a + mistake in your plugin that you should fix. Error callbacks are not used to + report expected run-time problems (e.g. disk I/O errors). + + The intention is for you to install the error callback during debug + sections and put a break-point inside your callback. This will cause you to + break into the debugger from within the SDK at the point in your plugin + where you made an illegal call. + + Installing an error callback may activate error checking code that would + not normally run, and this may adversely affect performance, so do not + leave error callbacks installed in shipping plugins. Since the only useful + response to an error is to change code, error callbacks are not useful "in + the field". + } + PROCEDURE XPLMSetErrorCallback( + inCallback : XPLMError_f); + cdecl; external XPLM_DLL; +{$ENDIF XPLM200} + + { + XPLMDebugString + + This routine outputs a C-style string to the Log.txt file. The file is + immediately flushed so you will not lose data. (This does cause a + performance penalty.) + + Please do *not* leave routine diagnostic logging enabled in your shipping + plugin. The X-Plane Log file is shared by X-Plane and every plugin in the + system, and plugins that (when functioning normally) print verbose log + output make it difficult for developers to find error conditions from other + parts of the system. + } + PROCEDURE XPLMDebugString( + inString : XPLMString); + cdecl; external XPLM_DLL; + + { + XPLMSpeakString + + This function displays the string in a translucent overlay over the current + display and also speaks the string if text-to-speech is enabled. The string + is spoken asynchronously, this function returns immediately. This function + may not speak or print depending on user preferences. + } + PROCEDURE XPLMSpeakString( + inString : XPLMString); + cdecl; external XPLM_DLL; + + { + XPLMGetVirtualKeyDescription + + Given a virtual key code (as defined in XPLMDefs.h) this routine returns a + human-readable string describing the character. This routine is provided + for showing users what keyboard mappings they have set up. The string may + read 'unknown' or be a blank or NULL string if the virtual key is unknown. + } + FUNCTION XPLMGetVirtualKeyDescription( + inVirtualKey : XPLMChar) : XPLMString; + cdecl; external XPLM_DLL; + + { + XPLMReloadScenery + + XPLMReloadScenery reloads the current set of scenery. You can use this + function in two typical ways: simply call it to reload the scenery, picking + up any new installed scenery, .env files, etc. from disk. Or, change the + lat/ref and lon/ref data refs and then call this function to shift the + scenery environment. This routine is equivalent to picking "reload + scenery" from the developer menu. + } + PROCEDURE XPLMReloadScenery; + cdecl; external XPLM_DLL; + +{$IFDEF XPLM200} +{___________________________________________________________________________ + * X-PLANE COMMAND MANAGEMENT + ___________________________________________________________________________} +{ + The command management APIs let plugins interact with the command-system in + X-Plane, the abstraction behind keyboard presses and joystick buttons. This + API lets you create new commands and modify the behavior (or get + notification) of existing ones. + + X-Plane Command Phases + ---------------------- + + X-Plane commands are not instantaneous; they operate over a duration. + (Think of a joystick button press - you can press, hold down, and then + release the joystick button; X-Plane commands model this entire process.) + + An X-Plane command consists of three phases: a beginning, continuous + repetition, and an ending. The command may be repeated zero times in its + duration, followed by one command ending. Command begin and end messges are + balanced, but a command may be bound to more than one event source (e.g. a + keyboard key and a joystick button), in which case you may receive a second + begin during before any end). + + When you issue commands in the plugin system, you *must* balance every call + to XPLMCommandBegin with a call to XPLMCommandEnd with the same command + reference. + + Command Behavior Modification + ----------------------------- + + You can register a callback to handle a command either before or after + X-Plane does; if you receive the command before X-Plane you have the option + to either let X-Plane handle the command or hide the command from X-Plane. + This lets plugins both augment commands and replace them. + + If you register for an existing command, be sure that you are *consistent* + in letting X-Plane handle or not handle the command; you are responsible + for passing a *balanced* number of begin and end messages to X-Plane. (E.g. + it is not legal to pass all the begin messages to X-Plane but hide all the + end messages). +} + + + { + XPLMCommandPhase + + The phases of a command. + } +TYPE + XPLMCommandPhase = ( + { The command is being started. } + xplm_CommandBegin = 0 + + { The command is continuing to execute. } + ,xplm_CommandContinue = 1 + + { The command has ended. } + ,xplm_CommandEnd = 2 + + ); + PXPLMCommandPhase = ^XPLMCommandPhase; + + { + XPLMCommandRef + + A command ref is an opaque identifier for an X-Plane command. Command + references stay the same for the life of your plugin but not between + executions of X-Plane. Command refs are used to execute commands, create + commands, and create callbacks for particular commands. + + Note that a command is not "owned" by a particular plugin. Since many + plugins may participate in a command's execution, the command does not go + away if the plugin that created it is unloaded. + } + XPLMCommandRef = pointer; + PXPLMCommandRef = ^XPLMCommandRef; + + { + XPLMCommandCallback_f + + A command callback is a function in your plugin that is called when a + command is pressed. Your callback receives the command reference for the + particular command, the phase of the command that is executing, and a + reference pointer that you specify when registering the callback. + + Your command handler should return 1 to let processing of the command + continue to other plugins and X-Plane, or 0 to halt processing, potentially + bypassing X-Plane code. + } + XPLMCommandCallback_f = FUNCTION( + inCommand : XPLMCommandRef; + inPhase : XPLMCommandPhase; + inRefcon : pointer) : Integer; cdecl; + + { + XPLMFindCommand + + XPLMFindCommand looks up a command by name, and returns its command + reference or NULL if the command does not exist. + } + FUNCTION XPLMFindCommand( + inName : XPLMString) : XPLMCommandRef; + cdecl; external XPLM_DLL; + + { + XPLMCommandBegin + + XPLMCommandBegin starts the execution of a command, specified by its + command reference. The command is "held down" until XPLMCommandEnd is + called. You must balance each XPLMCommandBegin call with an XPLMCommandEnd + call. + } + PROCEDURE XPLMCommandBegin( + inCommand : XPLMCommandRef); + cdecl; external XPLM_DLL; + + { + XPLMCommandEnd + + XPLMCommandEnd ends the execution of a given command that was started with + XPLMCommandBegin. You must not issue XPLMCommandEnd for a command you did + not begin. + } + PROCEDURE XPLMCommandEnd( + inCommand : XPLMCommandRef); + cdecl; external XPLM_DLL; + + { + XPLMCommandOnce + + This executes a given command momentarily, that is, the command begins and + ends immediately. This is the equivalent of calling XPLMCommandBegin() and + XPLMCommandEnd() back ot back. + } + PROCEDURE XPLMCommandOnce( + inCommand : XPLMCommandRef); + cdecl; external XPLM_DLL; + + { + XPLMCreateCommand + + XPLMCreateCommand creates a new command for a given string. If the command + already exists, the existing command reference is returned. The description + may appear in user interface contexts, such as the joystick configuration + screen. + } + FUNCTION XPLMCreateCommand( + inName : XPLMString; + inDescription : XPLMString) : XPLMCommandRef; + cdecl; external XPLM_DLL; + + { + XPLMRegisterCommandHandler + + XPLMRegisterCommandHandler registers a callback to be called when a command + is executed. You provide a callback with a reference pointer. + + If inBefore is true, your command handler callback will be executed before + X-Plane executes the command, and returning 0 from your callback will + disable X-Plane's processing of the command. If inBefore is false, your + callback will run after X-Plane. (You can register a single callback both + before and after a command.) + } + PROCEDURE XPLMRegisterCommandHandler( + inComand : XPLMCommandRef; + inHandler : XPLMCommandCallback_f; + inBefore : Integer; + inRefcon : pointer); + cdecl; external XPLM_DLL; + + { + XPLMUnregisterCommandHandler + + XPLMUnregisterCommandHandler removes a command callback registered with + XPLMRegisterCommandHandler. + } + PROCEDURE XPLMUnregisterCommandHandler( + inComand : XPLMCommandRef; + inHandler : XPLMCommandCallback_f; + inBefore : Integer; + inRefcon : pointer); + cdecl; external XPLM_DLL; + +{$ENDIF XPLM200} +{$IFDEF XPLM_DEPRECATED} +{___________________________________________________________________________ + * X-PLANE USER INTERACTION + ___________________________________________________________________________} +{ + WARNING: The legacy user interaction API is deprecated; while it was the + only way to run commands in X-Plane 6,7 and 8, it is obsolete, and was + replaced by the command system API in X-Plane 9. You should not use this + API; replace any of the calls below with XPLMCommand invocations based on + persistent command strings. The documentation that follows is for historic + reference only. + + The legacy user interaction APIs let you simulate commands the user can do + with a joystick, keyboard etc. Note that it is generally safer for future + compatibility to use one of these commands than to manipulate the + underlying sim data. +} + + + { + XPLMCommandKeyID + + These enums represent all the keystrokes available within X-Plane. They can + be sent to X-Plane directly. For example, you can reverse thrust using + these enumerations. + } +TYPE + XPLMCommandKeyID = ( + xplm_key_pause=0, + xplm_key_revthrust, + xplm_key_jettison, + xplm_key_brakesreg, + xplm_key_brakesmax, + xplm_key_gear, + xplm_key_timedn, + xplm_key_timeup, + xplm_key_fadec, + xplm_key_otto_dis, + xplm_key_otto_atr, + xplm_key_otto_asi, + xplm_key_otto_hdg, + xplm_key_otto_gps, + xplm_key_otto_lev, + xplm_key_otto_hnav, + xplm_key_otto_alt, + xplm_key_otto_vvi, + xplm_key_otto_vnav, + xplm_key_otto_nav1, + xplm_key_otto_nav2, + xplm_key_targ_dn, + xplm_key_targ_up, + xplm_key_hdgdn, + xplm_key_hdgup, + xplm_key_barodn, + xplm_key_baroup, + xplm_key_obs1dn, + xplm_key_obs1up, + xplm_key_obs2dn, + xplm_key_obs2up, + xplm_key_com1_1, + xplm_key_com1_2, + xplm_key_com1_3, + xplm_key_com1_4, + xplm_key_nav1_1, + xplm_key_nav1_2, + xplm_key_nav1_3, + xplm_key_nav1_4, + xplm_key_com2_1, + xplm_key_com2_2, + xplm_key_com2_3, + xplm_key_com2_4, + xplm_key_nav2_1, + xplm_key_nav2_2, + xplm_key_nav2_3, + xplm_key_nav2_4, + xplm_key_adf_1, + xplm_key_adf_2, + xplm_key_adf_3, + xplm_key_adf_4, + xplm_key_adf_5, + xplm_key_adf_6, + xplm_key_transpon_1, + xplm_key_transpon_2, + xplm_key_transpon_3, + xplm_key_transpon_4, + xplm_key_transpon_5, + xplm_key_transpon_6, + xplm_key_transpon_7, + xplm_key_transpon_8, + xplm_key_flapsup, + xplm_key_flapsdn, + xplm_key_cheatoff, + xplm_key_cheaton, + xplm_key_sbrkoff, + xplm_key_sbrkon, + xplm_key_ailtrimL, + xplm_key_ailtrimR, + xplm_key_rudtrimL, + xplm_key_rudtrimR, + xplm_key_elvtrimD, + xplm_key_elvtrimU, + xplm_key_forward, + xplm_key_down, + xplm_key_left, + xplm_key_right, + xplm_key_back, + xplm_key_tower, + xplm_key_runway, + xplm_key_chase, + xplm_key_free1, + xplm_key_free2, + xplm_key_spot, + xplm_key_fullscrn1, + xplm_key_fullscrn2, + xplm_key_tanspan, + xplm_key_smoke, + xplm_key_map, + xplm_key_zoomin, + xplm_key_zoomout, + xplm_key_cycledump, + xplm_key_replay, + xplm_key_tranID, + xplm_key_max + ); + PXPLMCommandKeyID = ^XPLMCommandKeyID; + + { + XPLMCommandButtonID + + These are enumerations for all of the things you can do with a joystick + button in X-Plane. They currently match the buttons menu in the equipment + setup dialog, but these enums will be stable even if they change in + X-Plane. + } + XPLMCommandButtonID = ( + xplm_joy_nothing=0, + xplm_joy_start_all, + xplm_joy_start_0, + xplm_joy_start_1, + xplm_joy_start_2, + xplm_joy_start_3, + xplm_joy_start_4, + xplm_joy_start_5, + xplm_joy_start_6, + xplm_joy_start_7, + xplm_joy_throt_up, + xplm_joy_throt_dn, + xplm_joy_prop_up, + xplm_joy_prop_dn, + xplm_joy_mixt_up, + xplm_joy_mixt_dn, + xplm_joy_carb_tog, + xplm_joy_carb_on, + xplm_joy_carb_off, + xplm_joy_trev, + xplm_joy_trm_up, + xplm_joy_trm_dn, + xplm_joy_rot_trm_up, + xplm_joy_rot_trm_dn, + xplm_joy_rud_lft, + xplm_joy_rud_cntr, + xplm_joy_rud_rgt, + xplm_joy_ail_lft, + xplm_joy_ail_cntr, + xplm_joy_ail_rgt, + xplm_joy_B_rud_lft, + xplm_joy_B_rud_rgt, + xplm_joy_look_up, + xplm_joy_look_dn, + xplm_joy_look_lft, + xplm_joy_look_rgt, + xplm_joy_glance_l, + xplm_joy_glance_r, + xplm_joy_v_fnh, + xplm_joy_v_fwh, + xplm_joy_v_tra, + xplm_joy_v_twr, + xplm_joy_v_run, + xplm_joy_v_cha, + xplm_joy_v_fr1, + xplm_joy_v_fr2, + xplm_joy_v_spo, + xplm_joy_flapsup, + xplm_joy_flapsdn, + xplm_joy_vctswpfwd, + xplm_joy_vctswpaft, + xplm_joy_gear_tog, + xplm_joy_gear_up, + xplm_joy_gear_down, + xplm_joy_lft_brake, + xplm_joy_rgt_brake, + xplm_joy_brakesREG, + xplm_joy_brakesMAX, + xplm_joy_speedbrake, + xplm_joy_ott_dis, + xplm_joy_ott_atr, + xplm_joy_ott_asi, + xplm_joy_ott_hdg, + xplm_joy_ott_alt, + xplm_joy_ott_vvi, + xplm_joy_tim_start, + xplm_joy_tim_reset, + xplm_joy_ecam_up, + xplm_joy_ecam_dn, + xplm_joy_fadec, + xplm_joy_yaw_damp, + xplm_joy_art_stab, + xplm_joy_chute, + xplm_joy_JATO, + xplm_joy_arrest, + xplm_joy_jettison, + xplm_joy_fuel_dump, + xplm_joy_puffsmoke, + xplm_joy_prerotate, + xplm_joy_UL_prerot, + xplm_joy_UL_collec, + xplm_joy_TOGA, + xplm_joy_shutdown, + xplm_joy_con_atc, + xplm_joy_fail_now, + xplm_joy_pause, + xplm_joy_rock_up, + xplm_joy_rock_dn, + xplm_joy_rock_lft, + xplm_joy_rock_rgt, + xplm_joy_rock_for, + xplm_joy_rock_aft, + xplm_joy_idle_hilo, + xplm_joy_lanlights, + xplm_joy_max + ); + PXPLMCommandButtonID = ^XPLMCommandButtonID; + + { + XPLMSimulateKeyPress + + This function simulates a key being pressed for X-Plane. The keystroke goes + directly to X-Plane; it is never sent to any plug-ins. However, since this + is a raw key stroke it may be mapped by the keys file or enter text into a + field. + + Deprecated: use XPLMCommandOnce + } + PROCEDURE XPLMSimulateKeyPress( + inKeyType : Integer; + inKey : Integer); + cdecl; external XPLM_DLL; + + { + XPLMCommandKeyStroke + + This routine simulates a command-key stroke. However, the keys are done by + function, not by actual letter, so this function works even if the user has + remapped their keyboard. Examples of things you might do with this include + pausing the simulator. + + Deprecated: use XPLMCommandOnce + } + PROCEDURE XPLMCommandKeyStroke( + inKey : XPLMCommandKeyID); + cdecl; external XPLM_DLL; + + { + XPLMCommandButtonPress + + This function simulates any of the actions that might be taken by pressing + a joystick button. However, this lets you call the command directly rather + than have to know which button is mapped where. Important: you must release + each button you press. The APIs are separate so that you can 'hold down' a + button for a fixed amount of time. + + Deprecated: use XPLMCommandBegin. + } + PROCEDURE XPLMCommandButtonPress( + inButton : XPLMCommandButtonID); + cdecl; external XPLM_DLL; + + { + XPLMCommandButtonRelease + + This function simulates any of the actions that might be taken by pressing + a joystick button. See XPLMCommandButtonPress. + + Deprecated: use XPLMCommandEnd. + } + PROCEDURE XPLMCommandButtonRelease( + inButton : XPLMCommandButtonID); + cdecl; external XPLM_DLL; + +{$ENDIF XPLM_DEPRECATED} + +IMPLEMENTATION + +END. diff --git a/XPLPro_Plugin_Source/SDK/SDKold/Libraries/Mac/XPLM.framework/XPLM b/XPLPro_Plugin_Source/SDK/SDKold/Libraries/Mac/XPLM.framework/XPLM new file mode 100644 index 0000000..99a7a72 Binary files /dev/null and b/XPLPro_Plugin_Source/SDK/SDKold/Libraries/Mac/XPLM.framework/XPLM differ diff --git a/XPLPro_Plugin_Source/SDK/SDKold/Libraries/Mac/XPWidgets.framework/XPWidgets b/XPLPro_Plugin_Source/SDK/SDKold/Libraries/Mac/XPWidgets.framework/XPWidgets new file mode 100644 index 0000000..16944be Binary files /dev/null and b/XPLPro_Plugin_Source/SDK/SDKold/Libraries/Mac/XPWidgets.framework/XPWidgets differ diff --git a/XPLPro_Plugin_Source/SDK/SDKold/README.txt b/XPLPro_Plugin_Source/SDK/SDKold/README.txt new file mode 100644 index 0000000..e7090b5 --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDKold/README.txt @@ -0,0 +1,222 @@ +------------------------------------------------------------------------------- + THE X-PLANE PLUGIN SDK +------------------------------------------------------------------------------- + +This download contains the files necessary to build plugins for X-Plane. The +X-Plane plugin website is: + +http://https://developer.x-plane.com/sdk/ + +The website contains full documentation on the SDK including tech notes, sample +plugins, sample code, contact information, and links to the latest versions of +this SDK. + +------------------------------------------------------------------------------- + SDK FILES +------------------------------------------------------------------------------- + +license.txt Copyright information for this download. +README.txt This document +CHeaders Header files for compiling C/C++ plugins +Delphi Interfaces for compiling Pascal plugins +Libraries Import libraries for linking on Windows + and frameworks for linking on Mac. + +Note: there are no import/link-time libraries for Linux; on Linux, plugins +simply leave SDK symbols undefined and they are discovered at runtime. The +SDK website explains this process in more detail. + +------------------------------------------------------------------------------- + RELEASE NOTES +------------------------------------------------------------------------------- + +This section contains per-release notes for the history of the X-Plane SDK. + +X-PLane SDK Release 4.0.0 beta 1 9/18/2022 + +The 4.0.0 SDK adds support for ARM64 Macs. The 4.0 SDK is supported by X-Plane +12. The new SDK adds support for drawing hooks that draw directly to the G1000 +and other avionic cockpit devices. + +X-Plane SDK Release 3.0.2 4/29/2020 + +The SDK 3.0.2 adds the modern 3-d drawing callback for interoperability with +Metal and Vulkan, and deprecates most older drawing callbacks. + +X-Plane SDK Release 3.0.1 3/5/2018 + +The SDK 3.0.1 API adds new messages and APIs to support VR. + +X-Plane SDK Release 3.0.0 11/2/7/2017 + +The SDK 3.0 API supports new features and new packaging for plugins. The 3.0 +SDK requires X-Plane 11.0 or newer. New features include: + + - Display APIs to match X-Plane 11's UI. + - New map APIs. Legacy 2-d map draw callbacks are deprecated. + - Aircraft-plugins get their own menu + - Aircraft placement by lat-lon-elevation. + - Magnetic variation queries + - Chinese language support + - New instancing API + +The 3.0 SDK supports a new plugin packaging schema: + + //.xpl + +where ABI is one of mac_x64, win_x64 or lin_x64. The new schema is preferred, +so you can pack a version of your plugin that requires 3.0 with this scheme +and include a legacy 2.x plugin using hte old scheme for X-Plane 10 +compatibility. + +Please use the new scheme where possible - having a unique file name for each +DLL makes crash reports easier to read and triage. + +The 3.0 SDK drops support for 32-bit plugins; if you need to ship a 32-bit +plugin for 32-bit X-Plane 10, shipping using two schemes and two binaries may +be the best option. + +X-Plane SDK Release 2.1.3 11/14/13 + +Fixed XPC Wrappers to use int and intptr_t instead of long. This fixes +crashes for plugins on 64-bit Windows. + +X-Plane SDK Release 2.1.2 RC2 1/15/13 + +Removed headers from frameworks, as they don't work; updated README. + +X-Plane SDK Release 2.1.2 RC1 1/12/13 + +The 2.1.2 SDK adds frameworks for the XPLM and XPWidgets; Mac developers +can link directly against these frameworks and avoid unresolved symbols +and flat namespace problems. The frameworks produce plugins that will +work on X-Plane 8, 9, and 10 depending on the plugin CPU architecture, +minimum system SDK, and XPLM API revision number. + +X-Plane SDK Release 2.1.1 RC1 10/29/12 + +The 2.1.1 update to the SDK provides 64-bit build materials. + +X-Plane SDK Release 2.1.0 RC1 3/31/12 + +This is the first release of the version 2.1 X-Plane SDK. This version of the +SDK exposes new APIs. + +This API also replaces all references to "long" with int or intptr_t, +depending on whether the integer needs to be wide enough to hold coerced +pointers. Most of the time, int is used; the notable exception is the widgets +library where params and properties can contain pointers to user data. + +This change is not an ABI change - compiled plugins will work unmodified. +However for some compilers, you may need to replace long with int or intptr_t +in your code. + +X-Plane SDK Release 2.0.1 RC1 7/21/10 + +This release adds symbol visibility macros for GCC 4 on Linux and corrects a few +function documentation comments. + +X-Plane SDK Release 2.0 RC1 7/11/08 + +This release includes a corrected XPLM.lib for windows with exports for some of +the new 2.0 APIs. + +X-Plane SDK Release 2.0 Beta 2 4/23/08 + +This release includes new APIs for reading and writing data files and drawing +hooks for the local map screen, as well as some minor tweaks: + +- Sim version is 2.0 in the headers. +- unload plane msg marked as 2.0 only. +- New enumerations for additional languages. +- Function level docs improved. + +X-Plane SDK Release 2.0 Beta 1 1/19/08 + +This is the first release of the version 2.0 X-Plane SDK. CFM support has +been removed, and the license has been simplified, reflecting that it only has +to cover the SDK include/import lib files and not the sample code or examples. + +X-Plane SDK Release 1.0.2 1/5/05 + +The headers of the SDK are modified to support Kylix. No changes for Mac, +Windows, or C users. Headers now have SDK version numbers. + +X-Plane SDK Release 1.0.1 12/29/04 + +The headers of this SDK are modified to support Linux complication. No changes +for Mac and Windows users. + +X-Plane SDK Release Candidate 1 + +Only one slight change in the enums: the enum xpProperty_SubWindowHasCloseBoxes +in XPStandardWidgets.h has been changed to xpProperty_MainWindowHasCloseBoxes. +Its value has not been changed, so you will need to search-and-replace your code +when using this version of the SDK, but already-compiled plugins will experience +no different operation. + +The documentation has been revised for all headers to revise changes made to the +SDK over the course of beta. + +X-Plane SDK Beta 5 + +This version of the SDK features a number of enumeration changes to reflect the +X-Plane interface more correctly. This became crucial when X-Plane 7's new user +interface was released. With X-Plane in release candidates hopefully beta 5 of +the SDK could be the last one. Please see: + +www.xsquawkbox.net/xpsdk/newui.html + +For a comprehensive description of all the enumeration changes. For most +plugins (no developers reported using the deprecated enumerations), a simple +search and replace should suffice. Plugins compiled against the beta 4 SDK that +do not use now-unsupported graphics will continue to work correctly. + +X-Plane SDK Beta 4 + +This release corrects two problems with the Pascal headers: function pointer +types are now declared cdecl (since this is how the SDK calls them), and the +import library for the widget callbacks is now XPWIDGETS.DLL as it should be. + +X-Plane SDK Beta 3 + +This release finally features full documentation and a stable widgets API, as +well as a few other minor bug fixes. + +Starting with beta 3, the DLLs necessary to run plugins ship with X-Plane 660. +The SDK will work with X-Plane 660 RC3 and later. The XPWidgets DLL now lives +in the Resources/plugins folder. + +Starting with beta 3, extra plugins, documentation, sample code, and sample +projects are now featured directly on the web in the new X-Plane SDK library. +They are not included in the SDK zip file; the zip file only contains headers +and lib files for the SDK. + +X-Plane SDK Beta 2 + +You must recompile your plugin for the beta 2 plugin SDK! Plugins compiled +against the beta 1 SDK will not work with X-Plane 660 or the new XPLM.DLL. + +A huge number of data refs have been added. Unfortunately the documentation +is thin. Use the data ref tester plugin to view the data refs in real time +and find what you need. + +The data ref APIs have also changed to allow for arrays of integers as well +as floats. Some sim variables are now arrays that were previously many +individual items. + +A new drawing phase is available for replacing aircraft graphics. The +texturing APIs in XPLMGraphics have been revised. The most notable change is +that you cannot use the SDK to load your textures. (This functionality was +broken and never worked in beta 1.) See the x-plane-dev list for sample code +on how to load your own bitmaps. + +X-Plane can reload plugins on the fly. Use the Plugin Enabler plugin to reload +your plugin. On the Mac you can throw the old DLL in the trash and put a new +one in its place to reload a new version of the plugin. On the PC, an alert +comes up; while this alert is up you can swap your plugins' DLL. This allows +you to recompile your plugin without rebooting the sim. + +Delphi Pascal interfaces and sample code are in the SDK. Thanks to Billy +Verreynne for his hard work on this. + diff --git a/XPLPro_Plugin_Source/SDK/SDKold/license.txt b/XPLPro_Plugin_Source/SDK/SDKold/license.txt new file mode 100644 index 0000000..8b9cbfc --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/SDKold/license.txt @@ -0,0 +1,27 @@ +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. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/XPLPro_Plugin_Source/SDK/license.txt b/XPLPro_Plugin_Source/SDK/license.txt new file mode 100644 index 0000000..8b9cbfc --- /dev/null +++ b/XPLPro_Plugin_Source/SDK/license.txt @@ -0,0 +1,27 @@ +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. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/XPLPro_Plugin_Source/SerialClass.cpp b/XPLPro_Plugin_Source/SerialClass.cpp new file mode 100644 index 0000000..7ecc9ee --- /dev/null +++ b/XPLPro_Plugin_Source/SerialClass.cpp @@ -0,0 +1,168 @@ +#include "SerialClass.h" +#include "XPLProCommon.h" + +#include + +extern FILE* errlog; // Used for logging problems + +serialClass::serialClass() +{ + + +} + +serialClass::~serialClass() +{ + shutDown(); + +} + +int serialClass::begin(int portNumber) +{ + //We're not yet connected + this->connected = false; + this->status; + + //Form the Raw device name + + + sprintf_s(portName, 20, "\\\\.\\COM%u", portNumber); + + //Try to connect to the given port throuh CreateFile + this->hSerial = CreateFileA(portName, + GENERIC_READ | GENERIC_WRITE, + 0, + NULL, + OPEN_EXISTING, + 0, //FILE_FLAG_OVERLAPPED, + NULL); + + //Check if the connection was successfull + if (this->hSerial == INVALID_HANDLE_VALUE) + { + return -1; + } + else + { + //If connected we try to set the comm parameters + DCB dcbSerialParams = { 0 }; + + //Try to get the current + if (!GetCommState(this->hSerial, &dcbSerialParams)) + { + //If impossible, show an error + //printf("failed to get current serial parameters!"); + } + else + { + //Define serial connection parameters for the arduino board + dcbSerialParams.BaudRate = XPL_BAUDRATE; + dcbSerialParams.ByteSize = 8; + dcbSerialParams.StopBits = ONESTOPBIT; + dcbSerialParams.Parity = NOPARITY; + //Setting the DTR to Control_Enable ensures that the Arduino is properly + //reset upon establishing a connection + dcbSerialParams.fDtrControl = DTR_CONTROL_ENABLE; + + //Set the parameters and check for their proper application + if (!SetCommState(hSerial, &dcbSerialParams)) + { + // printf("ALERT: Could not set Serial Port parameters"); + } + else + { + //If everything went fine we're connected + this->connected = true; + //Flush any remaining characters in the buffers + PurgeComm(this->hSerial, PURGE_RXCLEAR | PURGE_TXCLEAR); + //We wait 2s as the arduino board will be resetting + Sleep(ARDUINO_WAIT_TIME); + fprintf(errlog, "Serial: port \"%s\" opened successfully.\n", portName); + return portNumber; + } + } + } + return -1; // general error code +} + +int serialClass::shutDown(void) +{ + //Check if we are connected before trying to disconnect + if (this->connected) + { + //We're no longer connected + this->connected = false; + //Close the serial handler + CloseHandle(this->hSerial); + fprintf(errlog, "...Closing port %s\n", portName); + + } + return 0; +} + + + +int serialClass::readData(char* buffer, size_t nbChar) +{ + //Number of bytes we'll have read + DWORD bytesRead; + //Number of bytes we'll really ask to read + size_t toRead; + + //Use the ClearCommError function to get status info on the Serial port + ClearCommError(this->hSerial, &this->errors, &this->status); + + //Check if there is something to read + if (this->status.cbInQue > 0) + { + //If there is we check if there is enough data to read the required number + //of characters, if not we'll read only the available characters to prevent + //locking of the application. + if (this->status.cbInQue > nbChar) + { + toRead = nbChar; + } + else + { + toRead = this->status.cbInQue; + } + + //Try to read the require number of chars, and return the number of read bytes on success + if (ReadFile(this->hSerial, buffer, toRead, &bytesRead, NULL)) + { + return bytesRead; + } + + } + + //If nothing has been read, or that an error was detected return 0 + return 0; + +} + + +bool serialClass::writeData(const char* buffer, size_t nbChar) +{ + DWORD bytesSend; + + //Try to write the buffer on the Serial port + if (!WriteFile(this->hSerial, (void*)buffer, nbChar, &bytesSend, 0)) + { + //In case it doesnt work get comm error and return false + ClearCommError(this->hSerial, &this->errors, &this->status); + + return false; + } + else + { + // FlushFileBuffers(this->hSerial); + return true; + } +} + +bool serialClass::IsConnected(void) +{ + //Simply return the connection status + return this->connected; +} + diff --git a/XPLPro_Plugin_Source/SimData.vcxproj b/XPLPro_Plugin_Source/SimData.vcxproj new file mode 100644 index 0000000..edae193 --- /dev/null +++ b/XPLPro_Plugin_Source/SimData.vcxproj @@ -0,0 +1,303 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + 10.0 + {A5C93EF2-9EEF-4A23-99ED-B1AC1F167F69} + XPLProPlugin + + + + DynamicLibrary + false + MultiByte + v142 + + + DynamicLibrary + false + MultiByte + v142 + + + DynamicLibrary + false + MultiByte + v142 + + + DynamicLibrary + false + MultiByte + v142 + + + + + + + + + + + + + + + + + + + + + + + ..\..\..\..\..\..\X-Plane 12\Resources\plugins\XPLPro\64\ + .\Release\64\ + false + .xpl + false + win + + + false + .xpl + false + win + ..\..\X-Plane 10\Resources\plugins\XPLCore\32 + .\release\32\ + + + ..\..\X-Plane 10\Resources\plugins\XPLDirect\64\ + .\Debug\64\ + false + .xpl + false + win + + + false + .xpl + false + win + + + + MultiThreadedDLL + AnySuitable + true + true + MaxSpeed + true + Level3 + SDK\CHeaders\XPLM;SDK\CHeaders\Widgets;%(AdditionalIncludeDirectories) + WINVER=0x0601;_WIN32_WINNT=0x0601;_WIN32_WINDOWS=0x0601;WIN32;NDEBUG;_WINDOWS;_USRDLL;SIMDATA_EXPORTS;IBM=1;XPLM100=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + .\Release\64\ + .\Release\64\SimData.pch + + + .\Release\64\ + .\Release\64\ + Default + true + Speed + true + false + + + true + WINVER=0x0601;_WIN32_WINNT=0x0601;_WIN32_WINDOWS=0x0601;NDEBUG;%(PreprocessorDefinitions) + .\Release\SimData.tlb + true + + + 0x0809 + WINVER=0x0601;_WIN32_WINNT=0x0601;_WIN32_WINDOWS=0x0601;NDEBUG;%(PreprocessorDefinitions) + + + true + .\Release\SimData.bsc + + + true + true + Console + .\Release\64\SimData.lib + SDK\Libraries\Win;%(AdditionalLibraryDirectories) + Opengl32.lib;odbc32.lib;odbccp32.lib;XPLM_64.lib;XPWidgets_64.lib;libconfig.lib;%(AdditionalDependencies) + + + + + MultiThreadedDLL + AnySuitable + true + true + MaxSpeed + true + Level3 + SDK\CHeaders\XPLM;SDK\CHeaders\Widgets;%(AdditionalIncludeDirectories) + WINVER=0x0601;_WIN32_WINNT=0x0601;_WIN32_WINDOWS=0x0601;WIN32;NDEBUG;_WINDOWS;_USRDLL;SIMDATA_EXPORTS;IBM=1;XPLM100=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + .\Release\64\ + .\Release\64\SimData.pch + + + .\Release\64\ + .\Release\64\ + Default + true + Speed + true + + + true + WINVER=0x0601;_WIN32_WINNT=0x0601;_WIN32_WINDOWS=0x0601;NDEBUG;%(PreprocessorDefinitions) + .\Release\SimData.tlb + true + + + 0x0809 + WINVER=0x0601;_WIN32_WINNT=0x0601;_WIN32_WINDOWS=0x0601;NDEBUG;%(PreprocessorDefinitions) + + + true + .\Release\SimData.bsc + + + true + true + Console + .\Release\64\SimData.lib + SDK\Libraries\Win;%(AdditionalLibraryDirectories) + Opengl32.lib;odbc32.lib;odbccp32.lib;XPLM_64.lib;XPWidgets_64.lib;%(AdditionalDependencies) + + + + + MultiThreadedDebugDLL + Default + false + Disabled + true + OldStyle + SDK\CHeaders\XPLM;SDK\CHeaders\Widgets;%(AdditionalIncludeDirectories) + WINVER=0x0601;_WIN32_WINNT=0x0601;_WIN32_WINDOWS=0x0601;WIN32;_DEBUG;_WINDOWS;_USRDLL;SIMDATA_EXPORTS;IBM=1;XPLM100=1;%(PreprocessorDefinitions) + .\Debug\64\ + .\Debug\64\SimData.pch + + + .\Debug\64\ + .\Debug\64\ + EnableFastChecks + Default + Level3 + + + true + WINVER=0x0601;_WIN32_WINNT=0x0601;_WIN32_WINDOWS=0x0601;_DEBUG;%(PreprocessorDefinitions) + .\Debug\SimData.tlb + true + + + 0x0809 + WINVER=0x0601;_WIN32_WINNT=0x0601;_WIN32_WINDOWS=0x0601;_DEBUG;%(PreprocessorDefinitions) + + + true + .\Debug\SimData.bsc + + + true + true + true + Console + .\Debug\64\SimData.lib + SDK\Libraries\Win;%(AdditionalLibraryDirectories) + Opengl32.lib;odbc32.lib;odbccp32.lib;XPLM_64.lib;XPWidgets_64.lib;%(AdditionalDependencies) + + + + + MultiThreadedDebugDLL + Default + false + Disabled + true + OldStyle + SDK\CHeaders\XPLM;SDK\CHeaders\Widgets;%(AdditionalIncludeDirectories) + WINVER=0x0601;_WIN32_WINNT=0x0601;_WIN32_WINDOWS=0x0601;WIN32;_DEBUG;_WINDOWS;_USRDLL;SIMDATA_EXPORTS;IBM=1;XPLM100=1;%(PreprocessorDefinitions) + .\Debug\64\ + .\Debug\64\SimData.pch + + + .\Debug\64\ + .\Debug\64\ + EnableFastChecks + Default + Level3 + + + true + WINVER=0x0601;_WIN32_WINNT=0x0601;_WIN32_WINDOWS=0x0601;_DEBUG;%(PreprocessorDefinitions) + .\Debug\SimData.tlb + true + + + 0x0809 + WINVER=0x0601;_WIN32_WINNT=0x0601;_WIN32_WINDOWS=0x0601;_DEBUG;%(PreprocessorDefinitions) + + + true + .\Debug\SimData.bsc + + + true + true + true + Console + .\Debug\64\SimData.lib + SDK\Libraries\Win;%(AdditionalLibraryDirectories) + Opengl32.lib;odbc32.lib;odbccp32.lib;XPLM_64.lib;XPWidgets_64.lib;%(AdditionalDependencies) + + + + + + + + false + false + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/XPLPro_Plugin_Source/StatusWindow.cpp b/XPLPro_Plugin_Source/StatusWindow.cpp new file mode 100644 index 0000000..1fbf38e --- /dev/null +++ b/XPLPro_Plugin_Source/StatusWindow.cpp @@ -0,0 +1,176 @@ + +#include +#include +#include + + + +#define XPLM200 + +#include "XPLProCommon.h" +#include "XPLMPlugin.h" +#include "XPLMDataAccess.h" +#include "XPLMDisplay.h" +#include "XPLMGraphics.h" +#include "XPLMMenus.h" + +#include "XPWidgets.h" +#include "XPStandardWidgets.h" + +#include "XPLMUtilities.h" +#include "XPLMProcessing.h" + +#include "XPLMCamera.h" +#include "XPUIGraphics.h" +#include "XPWidgetUtils.h" + + +#include "serialclass.h" +#include "Config.h" + +#include "XPLProPlugin.h" + +#include "DataTransfer.h" +#include "StatusWindow.h" + +XPLMWindowID statusWindow = NULL; + +extern CommandBinding myCommands[XPL_MAXCOMMANDS_PC]; +extern DataRefBinding myBindings[XPL_MAXDATAREFS_PC]; + + +extern long int packetsSent; +extern long int packetsReceived; +extern int validPorts; + +extern long cycleCount; +extern float elapsedTime; + +extern int cmdHandleCounter; +extern int refHandleCounter; + +int lastCmdAction = -1; +int lastRefSent = -1; +int lastRefElementSent = 0; +int lastRefReceived = -1; +int lastRefElementReceived = 0; + + +void statusWindowCreate() +{ + statusWindow = XPLMCreateWindow( + 50, 600, 800, 200, /* Area of the window. */ + 1, /* Start visible. */ + statusDrawWindowCallback, /* Callbacks */ + statusHandleKeyCallback, + statusHandleMouseClickCallback, + NULL); /* Refcon - not used. */ +} + +/**************************************************************************************/ +/* MyDrawWindowCallback -- Called by xplane while window is active */ +/**************************************************************************************/ +void statusDrawWindowCallback( + XPLMWindowID inWindowID, + void* inRefcon) +{ + int left, top, right, bottom; + float color[] = { 1.0, 1.0, 1.0 }; /* RGB White */ + char tstring[800]; + + /* First we get the location of the window passed in to us. */ + XPLMGetWindowGeometry(inWindowID, &left, &top, &right, &bottom); + + /* We now use an XPLMGraphics routine to draw a translucent dark + * rectangle that is our window's shape. */ + XPLMDrawTranslucentDarkBox(left, top, right, bottom); + + /* Finally we draw the text into the window, also using XPLMGraphics + * routines. The NULL indicates no word wrapping. */ + XPLMDrawString(color, left + 5, top - 20, "Curiosity Workshop XPLPro Arduino Interface. Updates and Examples: www.patreon.com/curiosityworkshop", NULL, xplmFont_Basic); + + + sprintf(tstring, "Distribution Build: %u. Click this window when complete", XPL_VERSION); + XPLMDrawString(color, left + 5, top - 35, tstring, NULL, xplmFont_Basic); + + + sprintf(tstring, "Devices Detected: %i, Registered DataRefs: %i, Registered Commands: %i, tx: %i, rx: %i", validPorts, refHandleCounter, cmdHandleCounter, packetsSent, packetsReceived); + XPLMDrawString(color, left + 5, top - 55, tstring, NULL, xplmFont_Basic); + sprintf(tstring, "Elapsed time since start: %i, cycles: %i, average time between cycles: %3.2f", (int)elapsedTime, cycleCount, elapsedTime / cycleCount); + XPLMDrawString(color, left + 5, top - 70, tstring, NULL, xplmFont_Basic); + + if (lastRefReceived >= 0) + { + //sprintf(tstring, "Last ref received: %i, %s\n", lastRefReceived, myBindings[lastRefReceived].xplaneDataRefName); + + if (myBindings[lastRefReceived].xplaneDataRefTypeID & xplmType_Int) sprintf(tstring, "Last Dataref Received: %s, %i", myBindings[lastRefReceived].xplaneDataRefName, myBindings[lastRefReceived].currentReceivedl[lastRefElementReceived]); + if (myBindings[lastRefReceived].xplaneDataRefTypeID & xplmType_Float) sprintf(tstring, "Last Dataref Received: %s, %f", myBindings[lastRefReceived].xplaneDataRefName, myBindings[lastRefReceived].currentReceivedf[lastRefElementReceived]); + if (myBindings[lastRefReceived].xplaneDataRefTypeID & xplmType_Double) sprintf(tstring, "Last Dataref Received: %s, %i", myBindings[lastRefReceived].xplaneDataRefName, myBindings[lastRefReceived].currentReceivedl[lastRefElementReceived]); + if (myBindings[lastRefReceived].xplaneDataRefTypeID & xplmType_IntArray) sprintf(tstring, "Last Dataref Received: %s, Element: %i, %i", myBindings[lastRefReceived].xplaneDataRefName, lastRefElementReceived, myBindings[lastRefReceived].currentReceivedl[lastRefElementReceived]); + if (myBindings[lastRefReceived].xplaneDataRefTypeID & xplmType_FloatArray) sprintf(tstring, "Last Dataref Received: %s, Element: %i, %f", myBindings[lastRefReceived].xplaneDataRefName, lastRefElementReceived, myBindings[lastRefReceived].currentReceivedf[lastRefElementReceived]); + // if (myBindings[lastRefReceived].xplaneDataRefTypeID & xplmType_Data) sprintf(tstring, "Last Dataref Action: %s, %s", myBindings[lastRefReceived].xplaneDataRefName, myBindings[lastRefReceived].xplaneCurrentReceiveds); + XPLMDrawString(color, left + 5, top - 90, tstring, NULL, xplmFont_Basic); + + } + + if (lastRefSent >= 0) + { + //sprintf(tstring, "Last ref sent: %i, %s\n", lastRefReceived, myBindings[lastRefReceived].xplaneDataRefName); + + if (myBindings[lastRefSent].xplaneDataRefTypeID & xplmType_Int) sprintf(tstring, "Last Dataref Sent: %s, %i", myBindings[lastRefSent].xplaneDataRefName, myBindings[lastRefSent].currentSentl[lastRefElementSent]); + if (myBindings[lastRefSent].xplaneDataRefTypeID & xplmType_Float) sprintf(tstring, "Last Dataref Sent: %s, %f", myBindings[lastRefSent].xplaneDataRefName, myBindings[lastRefSent].currentSentf[lastRefElementSent]); + if (myBindings[lastRefSent].xplaneDataRefTypeID & xplmType_Double) sprintf(tstring, "Last Dataref Sent: %s, %i", myBindings[lastRefSent].xplaneDataRefName, myBindings[lastRefSent].currentSentl[lastRefElementSent]); + if (myBindings[lastRefSent].xplaneDataRefTypeID & xplmType_IntArray) sprintf(tstring, "Last Dataref Sent: %s, Element: %i, %i", myBindings[lastRefSent].xplaneDataRefName, lastRefElementSent, myBindings[lastRefSent].currentSentl[lastRefElementSent]); + if (myBindings[lastRefSent].xplaneDataRefTypeID & xplmType_FloatArray) sprintf(tstring, "Last Dataref Sent: %s, Element: %i, %f", myBindings[lastRefSent].xplaneDataRefName, lastRefElementSent, myBindings[lastRefSent].currentSentf[lastRefElementSent]); + if (myBindings[lastRefSent].xplaneDataRefTypeID & xplmType_Data) sprintf(tstring, "Last Dataref Sent: %s, %s", myBindings[lastRefSent].xplaneDataRefName, myBindings[lastRefSent].currentSents[lastRefElementSent]); + XPLMDrawString(color, left + 5, top - 105, tstring, NULL, xplmFont_Basic); + + } + + if (lastCmdAction >= 0) + { + sprintf(tstring, "Last Command Action: %s, accumulator: %i", myCommands[lastCmdAction].xplaneCommandName, myCommands[lastCmdAction].accumulator); + XPLMDrawString(color, left + 5, top - 120, tstring, NULL, xplmFont_Basic); + } + + + +} + +int statusWindowActive(void) +{ + if (!statusWindow) return 0; + else return 1; +} + + +/**************************************************************************************/ +/* MyHandleMouseClickCallback -- Called by xplane while status window is active */ +/**************************************************************************************/ +int statusHandleMouseClickCallback( + XPLMWindowID inWindowID, + int x, + int y, + XPLMMouseStatus inMouse, + void* inRefcon) +{ + + XPLMDestroyWindow(statusWindow); + statusWindow = NULL; + + return 1; +} + +/**************************************************************************************/ +/* MyHandleKeyCallback -- Called by xplane while status window is active */ +/**************************************************************************************/ +void statusHandleKeyCallback( + XPLMWindowID inWindowID, + char inKey, + XPLMKeyFlags inFlags, + char inVirtualKey, + void* inRefcon, + int losingFocus) +{ +} + diff --git a/XPLPro_Plugin_Source/StatusWindow.h b/XPLPro_Plugin_Source/StatusWindow.h new file mode 100644 index 0000000..e8b0ee5 --- /dev/null +++ b/XPLPro_Plugin_Source/StatusWindow.h @@ -0,0 +1,16 @@ +#pragma once + + + +void statusWindowCreate(void); +int statusWindowActive(void); + +void statusDrawWindowCallback( XPLMWindowID, void*); +int statusHandleMouseClickCallback(XPLMWindowID, int , int , XPLMMouseStatus , void*); +void statusHandleKeyCallback( + XPLMWindowID inWindowID, + char inKey, + XPLMKeyFlags inFlags, + char inVirtualKey, + void* inRefcon, + int losingFocus); \ No newline at end of file diff --git a/XPLPro_Plugin_Source/XPLDevice.cpp b/XPLPro_Plugin_Source/XPLDevice.cpp new file mode 100644 index 0000000..d02a584 --- /dev/null +++ b/XPLPro_Plugin_Source/XPLDevice.cpp @@ -0,0 +1,678 @@ + +#define XPLM200 + +#include "XPLMPlugin.h" +#include "XPLMDataAccess.h" +#include "XPLMDisplay.h" +#include "XPLMGraphics.h" +#include "XPLMMenus.h" + +#include "XPWidgets.h" +#include "XPStandardWidgets.h" + +#include "XPLMUtilities.h" +#include "XPLMProcessing.h" + +#include "XPLMCamera.h" +#include "XPUIGraphics.h" +#include "abbreviations.h" +#include "XPWidgetUtils.h" + +#include "DataTransfer.h" +#include "XPLDevice.h" + +extern long int packetsSent; +extern long int packetsReceived; +extern FILE* serialLogFile; // for serial data log +extern FILE* errlog; // Used for logging problems +extern abbreviations gAbbreviations; +extern float elapsedTime; + +extern int refHandleCounter; +extern int cmdHandleCounter; + +extern CommandBinding myCommands[XPL_MAXCOMMANDS_PC]; +extern DataRefBinding myBindings[XPL_MAXDATAREFS_PC]; + +extern int lastRefReceived; +extern int lastRefSent; +extern int lastCmdAction; +extern int lastRefElementSent; +extern int lastRefElementReceived; + +XPLDevice::XPLDevice(int inReference) +{ + bufferPosition = 0; + readBuffer[0] = '\0'; + lastDebugMessageReceived[0] = '\0'; + RefsLoaded = 0; + lastSendTime = 0; + _referenceID = inReference; + + _active = 0; + _flightLoopPause = 0; + + minTimeBetweenFrames = XPL_MILLIS_BETWEEN_FRAMES_DEFAULT; + +} + +XPLDevice::~XPLDevice() +{ + //if (Port) delete Port; + +} + +int XPLDevice::isActive(void) +{ + + return _active; + +} + +void XPLDevice::setActive(int flag) +{ + _active = flag; + +} + + +void XPLDevice::processSerial(void) +{ + do + { + while (port->readData(&readBuffer[bufferPosition], 1)) + { + readBuffer[bufferPosition + 1] = '\0'; + //fprintf(errlog, "Buffer currently: %s\r\n", readBuffer); + + + if (readBuffer[0] != XPL_PACKETHEADER) + { + readBuffer[0] = '\0'; + bufferPosition = -1; + } + + + if (readBuffer[0] == XPL_PACKETHEADER + && readBuffer[bufferPosition] == XPL_PACKETTRAILER) + + { + + _processPacket(); + readBuffer[0] = '\0'; + bufferPosition = -1; + } + + + if (strlen(readBuffer) >= XPLMAX_PACKETSIZE) + { + readBuffer[0] = '\0'; // packet size exceeded / bad packet + bufferPosition = -1; + } + + + bufferPosition++; + readBuffer[bufferPosition] = '\0'; + } + + } while (_flightLoopPause); + +} + + + +void XPLDevice::_processPacket(void) +{ + + char writeBuffer[XPLMAX_PACKETSIZE]; + char speechBuf[XPLMAX_PACKETSIZE]; + + int bindingNumber; + long int rate; + float precision; + int element; + + packetsReceived++; + + + if (!port) return; + +// fprintf(errlog, "_processPacket: %s \r\n", readBuffer); + + if (serialLogFile) fprintf(serialLogFile, "et: %5.0f rx port: %s length: %3.3i buffer: %s\n", elapsedTime, port->portName, (int)strlen(readBuffer), readBuffer); + + + readBuffer[bufferPosition+1] = 0; // terminate the string just in case + + + switch (readBuffer[1]) + { + + case XPLREQUEST_REGISTERDATAREF: + { + + _parseString(myBindings[refHandleCounter].xplaneDataRefName, readBuffer,2, 80 ); + //_parseInt(&myBindings[refHandleCounter].RWMode, readBuffer, 3); + + fprintf(errlog, "\n Device %s is requesting handle for dataref: \"%s\"...", deviceName, myBindings[refHandleCounter].xplaneDataRefName); + + myBindings[refHandleCounter].xplaneDataRefHandle = XPLMFindDataRef(myBindings[refHandleCounter].xplaneDataRefName); + if (myBindings[refHandleCounter].xplaneDataRefHandle == NULL) // if not found, try searching the abbreviations file before giving up + { + gAbbreviations.convertString(myBindings[refHandleCounter].xplaneDataRefName); + myBindings[refHandleCounter].xplaneDataRefHandle = XPLMFindDataRef(myBindings[refHandleCounter].xplaneDataRefName); + } + + if (myBindings[refHandleCounter].xplaneDataRefHandle != NULL) + { + fprintf(errlog, "I found that DataRef!\n"); + + myBindings[refHandleCounter].bindingActive = 1; + myBindings[refHandleCounter].deviceIndex = _referenceID; + //myBindings[refHandleCounter].xplaneDataRefArrayOffset = atoi(arrayReference); + //myBindings[refHandleCounter].divider = atof(dividerString); + //myBindings[refHandleCounter].RWMode = readBuffer[2] - '0'; + //fprintf(errlog, "RWMode %c was saved as int %i\r\n", strippedPacket[1], myBindings[refHandleCounter].RWMode); + myBindings[refHandleCounter].xplaneDataRefTypeID = XPLMGetDataRefTypes(myBindings[refHandleCounter].xplaneDataRefHandle); + + sprintf_s(writeBuffer, XPLMAX_PACKETSIZE, ",%i", refHandleCounter); + + _writePacket(XPLRESPONSE_DATAREF, writeBuffer); + + fprintf(errlog, " I responded with %3.3i as a handle using this packet: %s\n", refHandleCounter, writeBuffer); + if (myBindings[refHandleCounter].xplaneDataRefTypeID & xplmType_Int) fprintf(errlog, " This dataref returns that it is of type: int\n"); + if (myBindings[refHandleCounter].xplaneDataRefTypeID & xplmType_Float) fprintf(errlog, " This dataref returns that it is of type: float\n"); + if (myBindings[refHandleCounter].xplaneDataRefTypeID & xplmType_Double) fprintf(errlog, " This dataref returns that it is of type: double\n"); + if (myBindings[refHandleCounter].xplaneDataRefTypeID & xplmType_FloatArray) fprintf(errlog, " This dataref returns that it is of type: floatArray\n"); + if (myBindings[refHandleCounter].xplaneDataRefTypeID & xplmType_IntArray) fprintf(errlog, " This dataref returns that it is of type: intArray\n"); + if (myBindings[refHandleCounter].xplaneDataRefTypeID & xplmType_Data) + { + fprintf(errlog, " This dataref returns that it is of type: data ***Currently supported only for data sent from xplane (read only)***\n"); + myBindings[refHandleCounter].currentSents[0] = (char*)malloc(XPLMAX_PACKETSIZE - 5); + } + + + refHandleCounter++; + } + else + { + sprintf_s(writeBuffer, XPLMAX_PACKETSIZE, ",-02,\"%s\"", myBindings[refHandleCounter].xplaneDataRefName); + _writePacket(XPLRESPONSE_DATAREF, writeBuffer); + myBindings[refHandleCounter].bindingActive = 0; + fprintf(errlog, " requested DataRef not found, sorry. \n I sent back data frame: %s\n", writeBuffer); + refHandleCounter++; // to avoid timeout + } + + + break; + } + + case XPLREQUEST_UPDATES: + + + _parseInt(&bindingNumber, readBuffer, 2); + _parseInt(&rate, readBuffer, 3); + _parseFloat(&precision, readBuffer, 4); + + myBindings[bindingNumber].readFlag[0] = 1; + myBindings[bindingNumber].updateRate = rate; + myBindings[bindingNumber].precision = precision; + fprintf(errlog, " Device requested that %s dataref be updated at rate: %i and precision %f\n", myBindings[bindingNumber].xplaneDataRefName, rate, precision); + + break; + + case XPLREQUEST_UPDATESARRAY: + + + _parseInt(&bindingNumber, readBuffer, 2); + _parseInt(&rate, readBuffer, 3); + _parseFloat(&precision, readBuffer, 4); + _parseInt(&element, readBuffer, 5); + + myBindings[bindingNumber].readFlag[element] = 1; + myBindings[bindingNumber].updateRate = rate; + myBindings[bindingNumber].precision = precision; + fprintf(errlog, " Device requested that %s dataref element %i be updated at rate: %i and precision %f\n", myBindings[bindingNumber].xplaneDataRefName, element, rate, precision); + + break; + + case XPLREQUEST_SCALING: + _parseInt(&bindingNumber, readBuffer, 2); + _parseInt(&myBindings[bindingNumber].scaleFromLow, readBuffer, 3); + _parseInt(&myBindings[bindingNumber].scaleFromHigh, readBuffer, 4); + _parseInt(&myBindings[bindingNumber].scaleToLow, readBuffer, 5); + _parseInt(&myBindings[bindingNumber].scaleToHigh, readBuffer, 6); + myBindings[bindingNumber].scaleFlag = 1; + + break; + + case XPLREQUEST_REGISTERCOMMAND: + { + + _parseString(myCommands[cmdHandleCounter].xplaneCommandName, readBuffer, 2, 80); + + fprintf(errlog, " Device %s is requesting command: %s...", deviceName, myCommands[cmdHandleCounter].xplaneCommandName); + + myCommands[cmdHandleCounter].xplaneCommandHandle = XPLMFindCommand(myCommands[cmdHandleCounter].xplaneCommandName); + if (myCommands[cmdHandleCounter].xplaneCommandHandle == NULL) // if not found, try searching the abbreviations file before giving up + { + gAbbreviations.convertString(myCommands[cmdHandleCounter].xplaneCommandName); + myCommands[cmdHandleCounter].xplaneCommandHandle = XPLMFindCommand(myCommands[cmdHandleCounter].xplaneCommandName); + } + + + + if (myCommands[cmdHandleCounter].xplaneCommandHandle != NULL) + { + fprintf(errlog, "I found that Command!\n"); + + myCommands[cmdHandleCounter].bindingActive = 1; + myCommands[cmdHandleCounter].deviceIndex = _referenceID; + + sprintf_s(writeBuffer, XPLMAX_PACKETSIZE, ",%i", cmdHandleCounter); + + _writePacket(XPLRESPONSE_COMMAND, writeBuffer); + + //if (!myXPLDevices[port].Port->WriteData(writeBuffer, strlen(writeBuffer))) + // fprintf(errlog, " Problem occurred sending handle to the device, sorry.\n"); + //else + { + fprintf(errlog, " I responded with %3.3i as a handle using this packet: %s\n", cmdHandleCounter, writeBuffer); + } + + cmdHandleCounter++; + } + else + + { + sprintf_s(writeBuffer, XPLMAX_PACKETSIZE, ",-02,\"%s\"", &readBuffer[2]); + _writePacket(XPLRESPONSE_COMMAND, writeBuffer); + myCommands[cmdHandleCounter].bindingActive = 0; + fprintf(errlog, " requested Command not found, sorry. \n I sent back data frame: %s\n", writeBuffer); + cmdHandleCounter++; + } + + + break; + } + + case XPLCMD_DATAREFUPDATEINT: + case XPLCMD_DATAREFUPDATEFLOAT: + case XPLCMD_DATAREFUPDATEFLOATARRAY: + case XPLCMD_DATAREFUPDATEINTARRAY: + { + + float tempFloat; + int tempInt; + int tempElement; + + // fprintf(errlog, "Device is sending dataRef update with packet: %s \r\n", strippedPacket); + + _parseInt(&bindingNumber, readBuffer, 2); + + if (bindingNumber < 0 && bindingNumber > refHandleCounter) break; + + lastRefReceived = bindingNumber; // for the status window + + if (myBindings[bindingNumber].xplaneDataRefTypeID & xplmType_Int) + { + _parseInt(&tempInt, readBuffer, 3); + if (myBindings[bindingNumber].scaleFlag) tempInt = mapInt(tempInt, myBindings[bindingNumber].scaleFromLow, + myBindings[bindingNumber].scaleFromHigh, + myBindings[bindingNumber].scaleToLow, + myBindings[bindingNumber].scaleToHigh); + + XPLMSetDatai(myBindings[bindingNumber].xplaneDataRefHandle, tempInt); + myBindings[bindingNumber].currentReceivedl[0] = tempInt; + myBindings[bindingNumber].currentSentl[0] = tempInt; + } + + if (myBindings[bindingNumber].xplaneDataRefTypeID & xplmType_Float) + { + + _parseFloat(&tempFloat, readBuffer, 3); + if (myBindings[bindingNumber].scaleFlag) tempFloat = mapFloat(tempFloat, myBindings[bindingNumber].scaleFromLow, + myBindings[bindingNumber].scaleFromHigh, + myBindings[bindingNumber].scaleToLow, + myBindings[bindingNumber].scaleToHigh); + + + XPLMSetDataf(myBindings[bindingNumber].xplaneDataRefHandle, tempFloat); + myBindings[bindingNumber].currentReceivedf[0] = tempFloat; + myBindings[bindingNumber].currentSentf[0] = tempFloat; + } + + if (myBindings[bindingNumber].xplaneDataRefTypeID & xplmType_Double) + { + _parseFloat(&tempFloat, readBuffer, 3); + if (myBindings[bindingNumber].scaleFlag) tempFloat = mapFloat(tempFloat, myBindings[bindingNumber].scaleFromLow, + myBindings[bindingNumber].scaleFromHigh, + myBindings[bindingNumber].scaleToLow, + myBindings[bindingNumber].scaleToHigh); + XPLMSetDatad(myBindings[bindingNumber].xplaneDataRefHandle, tempFloat); + myBindings[bindingNumber].currentReceivedf[0] = tempFloat; + myBindings[bindingNumber].currentSentf[0] = tempFloat; + + } + + + if (myBindings[bindingNumber].xplaneDataRefTypeID & xplmType_IntArray) + { + _parseInt(&tempInt, readBuffer, 3); + _parseInt(&tempElement, readBuffer, 4);// need error checking here + + if (myBindings[bindingNumber].scaleFlag) tempInt = mapInt(tempInt, myBindings[bindingNumber].scaleFromLow, + myBindings[bindingNumber].scaleFromHigh, + myBindings[bindingNumber].scaleToLow, + myBindings[bindingNumber].scaleToHigh); + + XPLMSetDatavi(myBindings[bindingNumber].xplaneDataRefHandle, &tempInt, tempElement, 1); + myBindings[bindingNumber].currentReceivedl[tempElement] = tempInt; + myBindings[bindingNumber].currentSentl[tempElement] = tempInt; + myBindings[bindingNumber].currentElementSent[tempElement] = tempElement; + + } + + if (myBindings[bindingNumber].xplaneDataRefTypeID & xplmType_FloatArray) // process for datarefs of type float (array) + { + _parseFloat(&tempFloat, readBuffer, 3); + _parseInt(&tempElement, readBuffer, 4); // need error checking here + + if (myBindings[bindingNumber].scaleFlag) tempFloat = mapFloat(tempFloat, myBindings[bindingNumber].scaleFromLow, + myBindings[bindingNumber].scaleFromHigh, + myBindings[bindingNumber].scaleToLow, + myBindings[bindingNumber].scaleToHigh); + + XPLMSetDatavf(myBindings[bindingNumber].xplaneDataRefHandle, &tempFloat, tempElement, 1); + myBindings[bindingNumber].currentReceivedf[tempElement] = tempFloat; + myBindings[bindingNumber].currentSentf[tempElement] = tempFloat; + lastRefElementSent = tempElement; + } + + + break; + + } + + case XPLCMD_COMMANDSTART: + case XPLCMD_COMMANDEND: + case XPLCMD_COMMANDTRIGGER: + { + + + int commandNumber; + int triggerCount; + + _parseInt(&commandNumber, readBuffer, 2); + _parseInt(&triggerCount, readBuffer, 3); + + fprintf(errlog, "Command received for myCommands[%i]. cmdHandleCounter = %i. triggerCount: %i. readBuffer: %s\n", commandNumber, cmdHandleCounter, triggerCount, readBuffer); + + + if (commandNumber < 0 || commandNumber >= cmdHandleCounter) break; + + lastCmdAction = commandNumber; + + if (readBuffer[1] == XPLCMD_COMMANDTRIGGER) + { + + + // fprintf(errlog, "Device is sending Command %i %i times \n", commandNumber, triggerCount); + myCommands[commandNumber].accumulator += triggerCount-1; + + XPLMCommandOnce(myCommands[commandNumber].xplaneCommandHandle); + + + + + break; + } + + if (readBuffer[1] == XPLCMD_COMMANDSTART) + { + // fprintf(errlog, "Device is sending Command Start to derived commandNumber: %i\n", commandNumber); + XPLMCommandBegin(myCommands[commandNumber].xplaneCommandHandle); + } + + if (readBuffer[1] == XPLCMD_COMMANDEND) + { + // fprintf(errlog, "Device is sending Command End to derived commandNumber: %i\n", commandNumber); + //fprintf(errlog, "Device is sending Command End with packet: %s \n", strippedPacket); + XPLMCommandEnd(myCommands[commandNumber].xplaneCommandHandle); + } + + break; + } + + + case XPLCMD_PRINTDEBUG: + { + _parseString(lastDebugMessageReceived, readBuffer, 2, 80); + fprintf(errlog, "Device \"%s\" sent debug message: \"%s\"\n", deviceName, lastDebugMessageReceived); + + break; + } + + case XPLCMD_SPEAK: + { + _parseString(speechBuf, readBuffer, 2, 80); + XPLMSpeakString(&readBuffer[2]); + break; + } + + case XPLRESPONSE_NAME: + { + + _parseString(deviceName, readBuffer, 2, 80); + setActive(1); + + break; + } + + + case XPLCMD_FLIGHTLOOPPAUSE: + { + _flightLoopPause = 1; + break; + } + + case XPLCMD_FLIGHTLOOPRESUME: + { + _flightLoopPause = 0; + break; + } + + case XPLREQUEST_NOREQUESTS: + { + //RefsLoaded = 1; + //fprintf(errlog, " Device \"%s\" says it has no more dataRefs or commands to register!\n\n", deviceName); + break; + } + + case XPLCMD_RESET: + { + reloadDevices(); + break; + } + + default: + { + fprintf(errlog, "invalid command received\n"); + break; + } + + } +} + +int XPLDevice::_parseString(char *outBuffer, char *inBuffer, int parameter, int maxSize) // todo: Confirm 0 length strings ("") dont cause issues +{ + int cBeg; + int pos = 0; + int len; + + for (int i = 1; i < parameter; i++) + { + + while (inBuffer[pos] != ',' && inBuffer[pos] != NULL ) pos++; + pos++; + + } + + while (inBuffer[pos] != '\"' && inBuffer[pos] != NULL) pos++; + cBeg = ++pos; + + while (inBuffer[pos] != '\"' && inBuffer[pos] != NULL) pos++; + len = pos - cBeg; + if (len > maxSize) len = maxSize; + + + strncpy(outBuffer, (char*)&inBuffer[cBeg], len); + outBuffer[len] = 0; + //fprintf(errlog, "_parseString, pos: %i, cBeg: %i, deviceName: %s\n", pos, cBeg, target); + + return 0; +} + +int XPLDevice::_parseInt(int *outTarget, char *inBuffer, int parameter) +{ + int cBeg; + int pos = 0; + + for (int i = 1; i < parameter; i++) + { + + while (inBuffer[pos] != ',' && inBuffer[pos] != NULL) pos++; + pos++; + + } + cBeg = pos; + + while (inBuffer[pos] != ',' && inBuffer[pos] != NULL && inBuffer[pos] != XPL_PACKETTRAILER) pos++; + + char holdChar = inBuffer[pos]; + inBuffer[pos] = 0; + *outTarget = atoi((char*)&inBuffer[cBeg]); + +// fprintf(errlog, "outTarget: %i cBeg: %i pos: %i string: %s\n", *outTarget, cBeg, pos, (char*)&inBuffer[cBeg]); + + inBuffer[pos] = holdChar; + + + + return 0; + +} +int XPLDevice::_parseInt(long int* outTarget, char* inBuffer, int parameter) +{ + int cBeg; + int pos = 0; + + for (int i = 1; i < parameter; i++) + { + + while (inBuffer[pos] != ',' && inBuffer[pos] != NULL) pos++; + pos++; + + } + cBeg = pos; + + while (inBuffer[pos] != ',' && inBuffer[pos] != NULL && inBuffer[pos] != XPL_PACKETTRAILER) pos++; + + char holdChar = inBuffer[pos]; + inBuffer[pos] = 0; + *outTarget = atol((char*)&inBuffer[cBeg]); + + // fprintf(errlog, "outTarget: %i cBeg: %i pos: %i string: %s\n", *outTarget, cBeg, pos, (char*)&inBuffer[cBeg]); + + inBuffer[pos] = holdChar; + + + + return 0; + +} + +int XPLDevice::_parseFloat(float* outTarget, char* inBuffer, int parameter) +{ + int cBeg; + int pos = 0; + + for (int i = 1; i < parameter; i++) + { + + while (inBuffer[pos] != ',' && inBuffer[pos] != NULL) pos++; + pos++; + + } + cBeg = pos; + + while (inBuffer[pos] != ',' && inBuffer[pos] != NULL && inBuffer[pos] != XPL_PACKETTRAILER) pos++; + + char holdChar = inBuffer[pos]; + inBuffer[pos] = 0; + *outTarget = atof((char*)&inBuffer[cBeg]); + + // fprintf(errlog, "outTarget: %i cBeg: %i pos: %i string: %s\n", *outTarget, cBeg, pos, (char*)&inBuffer[cBeg]); + + inBuffer[pos] = holdChar; + + + + return 0; + +} + +int XPLDevice::_writePacket(char cmd, char* packet) +{ + //return 0; + char writeBuffer[XPLMAX_PACKETSIZE]; + snprintf(writeBuffer, XPLMAX_PACKETSIZE, "%c%c%s%c", XPL_PACKETHEADER, cmd, packet, XPL_PACKETTRAILER); + + + if (serialLogFile) fprintf(serialLogFile, "et: %5.0f tx port: %s length: %3.3zi packet: %s\n", elapsedTime, port->portName, strlen(writeBuffer), writeBuffer); + + + + if (!port->writeData(writeBuffer, strlen(writeBuffer))) + { + fprintf(errlog, "Problem occurred during write: %s.\n", writeBuffer); + return 0; + } + + packetsSent++; + + return 1; +} + + +int XPLDevice::_writePacketN(char cmd, char* packet, int packetSize) +{ + //return 0; + char writeBuffer[XPLMAX_PACKETSIZE]; + snprintf(writeBuffer, XPLMAX_PACKETSIZE, "%c%c,", XPL_PACKETHEADER, cmd); + memcpy((void*)&writeBuffer[3], packet, packetSize); + writeBuffer[packetSize + 2] = XPL_PACKETTRAILER; + writeBuffer[packetSize + 3] = 0; // terminate with null + + if (serialLogFile) + { + fprintf(serialLogFile, "et: %5.0f tx port: %s length: %3.3i packet: ",elapsedTime, port->portName, packetSize + 3); + for (int i = 0; i < packetSize + 3; i++) + { + if (isprint(writeBuffer[i])) fprintf(serialLogFile, "%c", writeBuffer[i]); + else fprintf(serialLogFile, "~"); + } + fprintf(serialLogFile, "\n"); + + } + + if (!port->writeData(writeBuffer, packetSize + 6)) + { + fprintf(errlog, "Problem occurred during write: %s.\n", writeBuffer); + return 0; + } + + packetsSent++; + + return 1; +} diff --git a/XPLPro_Plugin_Source/XPLDevice.h b/XPLPro_Plugin_Source/XPLDevice.h new file mode 100644 index 0000000..e94f498 --- /dev/null +++ b/XPLPro_Plugin_Source/XPLDevice.h @@ -0,0 +1,57 @@ +#pragma once +#include "SerialClass.h" +#include "XPLProCommon.h" + +class XPLDevice +{ +public: + + XPLDevice(int inReference); + ~XPLDevice(); + int _writePacket(char cmd, char* packet); + int _writePacketN(char cmd, char* packet, int packetSize); +// char* getDeviceName(void); +// int getDeviceType(void); +// char* getLastDebugMessageReceived(void); + int isActive(void); // returns true if device has communicated its name + void setActive(int activeFlag); + void processSerial(void); + + char readBuffer[XPLMAX_PACKETSIZE]; + + char lastDebugMessageReceived[80]; // what was last sent by the device as a debug string + float lastSendTime; // last time data update occurred + +// int deviceType; // XPLDirect = 1 XPLWizard = 2 + int boardType; // Type of arduino device, if XPLWizard + int RefsLoaded; // true if device has sent all dataref bindings it wants + char deviceName[80]; // name of device as returned from device + //char boardName[80]; // name of board type, implemented for XPLWizard Devices + + float minTimeBetweenFrames; // only implemented for dataref updates. + int bufferPosition; + + serialClass* port; // handle to open com port + + + +private: + + void _processPacket(void); + + int _parseString(char* outBuffer, char* inBuffer, int parameter, int maxSize); + int _parseInt(int* outTarget, char* inBuffer, int parameter); + int _parseInt(long int* outTarget, char* inBuffer, int parameter); + int _parseFloat(float* outTarget, char* inBuffer, int parameter); + + int _active; // true if device responds + int _referenceID; // possibly temporary to id ourselves exterally + + int _flightLoopPause; // while initializing datarefs and commands this can be true to stop flight loop cycle. Downside is, if it never becomes false... + + + + + + +}; diff --git a/XPLPro_Plugin_Source/XPLPro.sln b/XPLPro_Plugin_Source/XPLPro.sln new file mode 100644 index 0000000..5c063b9 --- /dev/null +++ b/XPLPro_Plugin_Source/XPLPro.sln @@ -0,0 +1,48 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30413.136 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "XPLProPlugin", "SimData.vcxproj", "{A5C93EF2-9EEF-4A23-99ED-B1AC1F167F69}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{36FDB778-95B3-4BB8-A122-80744B2DAA88}" + ProjectSection(SolutionItems) = preProject + ..\..\..\..\..\..\X-Plane 12\Resources\plugins\XPLPro\abbreviations.txt = ..\..\..\..\..\..\X-Plane 12\Resources\plugins\XPLPro\abbreviations.txt + ..\..\..\..\..\..\X-Plane 12\Log.txt = ..\..\..\..\..\..\X-Plane 12\Log.txt + ..\..\My Arduino Sketchbook\libraries\XPLPro\readme.txt = ..\..\My Arduino Sketchbook\libraries\XPLPro\readme.txt + ..\..\..\..\..\..\X-Plane 12\Resources\plugins\XPLPro\XPLPro.cfg = ..\..\..\..\..\..\X-Plane 12\Resources\plugins\XPLPro\XPLPro.cfg + ..\..\My Arduino Sketchbook\libraries\XPLPro\XPLPro.cpp = ..\..\My Arduino Sketchbook\libraries\XPLPro\XPLPro.cpp + ..\..\My Arduino Sketchbook\libraries\XPLPro\XPLPro.h = ..\..\My Arduino Sketchbook\libraries\XPLPro\XPLPro.h + ..\..\..\..\..\..\X-Plane 12\XPLProError.log = ..\..\..\..\..\..\X-Plane 12\XPLProError.log + ..\..\..\..\..\..\X-Plane 12\XPLProSerial.log = ..\..\..\..\..\..\X-Plane 12\XPLProSerial.log + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A5C93EF2-9EEF-4A23-99ED-B1AC1F167F69}.Debug|Win32.ActiveCfg = Release|x64 + {A5C93EF2-9EEF-4A23-99ED-B1AC1F167F69}.Debug|Win32.Build.0 = Release|x64 + {A5C93EF2-9EEF-4A23-99ED-B1AC1F167F69}.Debug|x64.ActiveCfg = Debug|x64 + {A5C93EF2-9EEF-4A23-99ED-B1AC1F167F69}.Debug|x64.Build.0 = Debug|x64 + {A5C93EF2-9EEF-4A23-99ED-B1AC1F167F69}.Debug|x86.ActiveCfg = Debug|Win32 + {A5C93EF2-9EEF-4A23-99ED-B1AC1F167F69}.Release|Win32.ActiveCfg = Release|x64 + {A5C93EF2-9EEF-4A23-99ED-B1AC1F167F69}.Release|Win32.Build.0 = Release|x64 + {A5C93EF2-9EEF-4A23-99ED-B1AC1F167F69}.Release|x64.ActiveCfg = Release|x64 + {A5C93EF2-9EEF-4A23-99ED-B1AC1F167F69}.Release|x64.Build.0 = Release|x64 + {A5C93EF2-9EEF-4A23-99ED-B1AC1F167F69}.Release|x86.ActiveCfg = Release|Win32 + {A5C93EF2-9EEF-4A23-99ED-B1AC1F167F69}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {751D5454-9CC8-4E22-98C6-9E3A1680E01F} + EndGlobalSection +EndGlobal diff --git a/XPLPro_Plugin_Source/XPLProCommon.h b/XPLPro_Plugin_Source/XPLProCommon.h new file mode 100644 index 0000000..75938ae --- /dev/null +++ b/XPLPro_Plugin_Source/XPLProCommon.h @@ -0,0 +1,70 @@ + + +#pragma once + +#define CFG_FILE "Resources\\plugins\\XPLPro\\XPLPro.cfg" +#define CFG_ABBREVIATIONS_FILE "Resources\\plugins\\XPLPro\\abbreviations.txt" + +#define ARDUINO_WAIT_TIME 2000 + +#define XPL_BAUDRATE 115200 +#define XPL_MILLIS_BETWEEN_FRAMES_DEFAULT 0 // for data sends +#define XPL_RETURN_TIME .05 // request next visit every .05 seconds or - for cycles +#define XPL_PACKETHEADER '[' // +#define XPL_PACKETTRAILER ']' + +#define XPL_MAXDATAREFS_PC 1000 +#define XPL_MAXCOMMANDS_PC 1000 + +#define XPLDEVICES_MAXDEVICES 30 + +#define XPLMAX_PACKETSIZE 200 +#define XPLMAX_ELEMENTS 10 +#define XPL_TIMEOUT_SECONDS 3 + +#define XPLRESPONSE_NAME 'n' +#define XPLRESPONSE_DATAREF 'D' // %3.3i%s dataref handle, dataref name +#define XPLRESPONSE_COMMAND 'C' // %3.3i%s command handle, command name +#define XPLRESPONSE_VERSION 'v' // %3.3i%u customer build ID, version +#define XPLCMD_PRINTDEBUG 'g' +#define XPLCMD_RESET 'z' +#define XPLCMD_SPEAK 's' +#define XPLCMD_SENDNAME 'N' +#define XPLCMD_FLIGHTLOOPPAUSE 'p' // stop flight loop while we register +#define XPLCMD_FLIGHTLOOPRESUME 'q' // +#define XPLREQUEST_REGISTERDATAREF 'b' // dataref name +#define XPLREQUEST_REGISTERCOMMAND 'm' // name of the command to register +#define XPLREQUEST_NOREQUESTS 'c' // nothing to request +#define XPLREQUEST_REFRESH 'd' // the plugin will call this once xplane is loaded in order to get fresh updates from arduino handles that write +#define XPLREQUEST_UPDATES 'r' // arduino is asking the plugin to update the specified dataref with rate and divider parameters +#define XPLREQUEST_UPDATESARRAY 't' +#define XPLREQUEST_SCALING 'u' // arduino requests the plugin apply scaling to the dataref values +#define XPLREQUEST_DATAREFVALUE 'e' + +#define XPLCMD_DATAREFUPDATEINT '1' +#define XPLCMD_DATAREFUPDATEFLOAT '2' +#define XPLCMD_DATAREFUPDATEINTARRAY '3' +#define XPLCMD_DATAREFUPDATEFLOATARRAY '4' +#define XPLCMD_DATAREFUPDATESTRING '9' + +#define XPLCMD_SENDREQUEST 'Q' + +#define XPLCMD_COMMANDSTART 'i' +#define XPLCMD_COMMANDEND 'j' +#define XPLCMD_COMMANDTRIGGER 'k' // command handle, number of triggers +#define XPLCMD_SENDVERSION 'v' // get current build version from arduino device + + +#define XPL_EXITING 'X' // xplane is closing + +#define XPLTYPE_XPLPRO 1 + + +#define XPL_READ 1 +#define XPL_WRITE 2 +#define XPL_READWRITE 3 + +#define XPL_DATATYPE_INT 1 +#define XPL_DATATYPE_FLOAT 2 +#define XPL_DATATYPE_STRING 3 + diff --git a/XPLPro_Plugin_Source/XPLProPlugin.cpp b/XPLPro_Plugin_Source/XPLProPlugin.cpp new file mode 100644 index 0000000..cab1c3c --- /dev/null +++ b/XPLPro_Plugin_Source/XPLProPlugin.cpp @@ -0,0 +1,363 @@ +/* + + + XPLPro - plugin for serial interface to Arduino + Created by Curiosity Workshop -- Michael Gerlicher, September 2020. + + +*/ + + + + +#include + + + +#define XPLM200 +#include "XPLProCommon.h" +#include "XPLMPlugin.h" +#include "XPLMDataAccess.h" +#include "XPLMDisplay.h" +#include "XPLMGraphics.h" +#include "XPLMMenus.h" + +#include "XPWidgets.h" +#include "XPStandardWidgets.h" + +#include "XPLMUtilities.h" +#include "XPLMProcessing.h" + +#include "XPLMCamera.h" +#include "XPUIGraphics.h" +#include "XPWidgetUtils.h" + + +#include "StatusWindow.h" + +#include "abbreviations.h" + +//#include "serialclass.h" + +#include "DataTransfer.h" +#include "Config.h" + +#include "XPLProPlugin.h" + +FILE* serialLogFile; // for serial data log +FILE* errlog; // Used for logging problems + +Config *XPLConfig; + +abbreviations gAbbreviations; + + +extern long int packetsSent; +extern long int packetsReceived; +extern int validPorts; + +long cycleCount = 0l; +float elapsedTime = 0; +int logSerial = false; + +int gClicked = 0; +XPLMMenuID myMenu; +int disengageMenuItemIndex; +int logSerialMenuItemIndex; + + + +XPLMCommandRef ResetCommand = NULL; + + + + + +PLUGIN_API int XPluginStart( + char * outName, + char * outSig, + char * outDesc) +{ + + int mySubMenuItem; + + char outFilePath[256]; + + + fopen_s(&errlog, "XPLProError.log", "w"); + if (!errlog) + { + XPLMDebugString("XPLPro: Unable to open error log file XPLCoreError.log\n"); + return 0; + } + setbuf(errlog, NULL); + +// Provide our plugin's profile to the plugin system. + strcpy(outName, "XPLPro"); + strcpy(outSig, "xplpro.arduino.cw"); + strcpy(outDesc, "Direct communications with Arduino infrastructure"); + + + fprintf(errlog, "Curiosity Workshop XPLPro interface version %u copyright 2007-2023. \n", XPL_VERSION ); + + fprintf(errlog, "To report problems, download updates and examples, suggest enhancements or get technical support:\r\n"); + fprintf(errlog, " discord: https://discord.gg/gzXetjEST4\n"); + fprintf(errlog, " patreon: www.patreon.com/curiosityworkshop\n"); + fprintf(errlog, " YouTube: youtube.com/channel/UCISdHdJIundC-OSVAEPzQIQ \n\n"); + + fprintf(errlog, "XPLPro interface Error log file begins now.\r\n"); + + XPLMGetPluginInfo( XPLMGetMyID(), NULL, outFilePath, NULL, NULL); + fprintf(errlog, "Plugin Path: %s\r\n", outFilePath); + + // first load configuration stuff + XPLConfig = new Config(CFG_FILE); + logSerial = XPLConfig->getSerialLogFlag(); + + if (logSerial) fprintf(errlog, "Serial logging enabled.\r\n"); else fprintf(errlog, "Serial logging disabled.\r\n"); + + + gAbbreviations.begin(); + + + + XPLMDebugString("XPLPro: Initializing Plug-in\n"); + + + + /* First we put a new menu item into the plugin menu. + * This menu item will contain a submenu for us. */ + mySubMenuItem = XPLMAppendMenuItem( + XPLMFindPluginsMenu(), /* Put in plugins menu */ + "XPLPro", /* Item Title */ + 0, /* Item Ref */ + 1); /* Force English */ + + /* Now create a submenu attached to our menu item. */ + myMenu = XPLMCreateMenu( + "XPLDirectB", + XPLMFindPluginsMenu(), + mySubMenuItem, /* Menu Item to attach to. */ + MyMenuHandlerCallback, /* The handler */ + 0); /* Handler Ref */ + + /* Append a few menu items to our submenu. */ + + XPLMAppendMenuItem(myMenu, "Status",(void *) "Status", 1); + disengageMenuItemIndex = XPLMAppendMenuItem(myMenu, "Engage Devices", (void *) "Engage Devices", 1); + logSerialMenuItemIndex = XPLMAppendMenuItem(myMenu, "Log Serial Data", (void*) "Log Serial Data", 1); + XPLMAppendMenuSeparator(myMenu); + + + if (logSerial) XPLMCheckMenuItem(myMenu, logSerialMenuItemIndex, xplm_Menu_Checked); + else XPLMCheckMenuItem(myMenu, logSerialMenuItemIndex, xplm_Menu_Unchecked); + + + XPLMRegisterFlightLoopCallback( // Setup timed processing + MyFlightLoopCallback, // Callback + -2.0, // Interval + NULL); // refcon not used. + + + ResetCommand = XPLMCreateCommand("XPLPro/ResetDevices", "Disengage / re-engage XPLPro Devices"); + XPLMRegisterCommandHandler(ResetCommand, // in Command name + ResetCommandHandler, // in Handler + 1, // Receive input before plugin windows. + (void*)0); // inRefcon. + + + if (logSerial) + { + fopen_s(&serialLogFile, "XPLProSerial.log", "w"); + if (serialLogFile) fprintf(serialLogFile, "Serial logger. Unprintable characters are represented by '~'\n"); + } + + XPLMDebugString("XPLPro: Plugin initialization complete.\n"); + + + + return 1; +} + + +// XPluginStop + +PLUGIN_API void XPluginStop(void) +{ +// cmpSelect.saveConfiguration(); +// cmpLEDEdit.saveConfiguration(); + + + disengageDevices(); + if (errlog) fprintf(errlog, "Ending plugin, cycle count: %u Packets transmitted: %u, Packets Received: %u\n", cycleCount, packetsSent, packetsReceived); + if (errlog) fclose(errlog); + + + if (serialLogFile) fclose(serialLogFile); + + +} + + +// XPluginDisable Handler. We do nothing in this plugin +PLUGIN_API void XPluginDisable(void) +{ +} + +//XpluginEnable handler. We do nothing in this plugin. +PLUGIN_API int XPluginEnable(void) +{ + return 1; +} + +// XPluginRecieveMessage Handler +PLUGIN_API void XPluginReceiveMessage( + XPLMPluginID inFromWho, + int inMessage, + void* inParam) +{ + char pluginName[256]; + + XPLMGetPluginInfo(inFromWho, pluginName, NULL, NULL, NULL); + + if (inMessage == XPLM_MSG_PLANE_UNLOADED) + { + fprintf(errlog, "%s says that the current plane was unloaded. I will disengage devices. \n", pluginName); + disengageDevices(); + XPLMSetMenuItemName(myMenu, disengageMenuItemIndex, "Engage Devices", 0); + + } + if (inMessage == 108) // 108 is supposed to = XPLM_MSG_LIVERY_LOADED + //if (inMessage == XPLM_MSG_PLANE_LOADED) + { + fprintf(errlog, "%s says that a plane was loaded. I will attempt to engage XPL/Direct devices. \n", pluginName); + engageDevices(); + if (validPorts) XPLMSetMenuItemName(myMenu, disengageMenuItemIndex, "Disengage Devices", 0); + } + +// fprintf(errlog, "Xplane sent me a message from: %s, message: %i\n", pluginName, inMessage); +} + + +/**************************************************************************************/ +/* MyMenuHandlerCallback-- Handle users request for calibration */ +/**************************************************************************************/ +void MyMenuHandlerCallback( + void* inMenuRef, + void* inItemRef) +{ + +// fprintf(errlog, "User selected inMenuRef: %i, inItemRef: %i\n", (int)(int *)inMenuRef, (int)(int *)inItemRef); + + + // Handle request for status window + if (!strcmp((const char*)inItemRef, "Status")) // menu 0, item 1, "Status" + { + if (!statusWindowActive() ) statusWindowCreate(); + } + + // Handle request for arduino device engagement/disengagement + if (!strcmp((const char*)inItemRef, "Engage Devices")) // menu 0, item 2, "disengage / re-engage" + { + if (validPorts) + { + fprintf(errlog, "User requested to disengage devices. \n"); + disengageDevices(); + + XPLMSetMenuItemName(myMenu, disengageMenuItemIndex, "Engage Devices", 0); + + } + else + { + fprintf(errlog, "User requested to re-engage devices. \n"); + + disengageDevices(); // just to make sure we are cleared + engageDevices(); + if (validPorts) XPLMSetMenuItemName(myMenu, disengageMenuItemIndex, "Disengage Devices", 0); + } + + } + + + // Handle request toggle for serial logging + if (!strcmp((const char*)inItemRef, "Log Serial Data")) // menu 0, item 1, "Log Serial Data" + { + if (logSerial) + { + fclose(serialLogFile); + logSerial = false; + XPLMCheckMenuItem(myMenu, logSerialMenuItemIndex, xplm_Menu_Unchecked); + XPLConfig->setSerialLogFlag(0); + } + else + { + fopen_s(&serialLogFile, "XPLProSerial.log", "w"); + + if (serialLogFile) + { + fprintf(serialLogFile, "Serial logger. Unprintable characters are represented by '~'\n"); + logSerial = true; + XPLMCheckMenuItem(myMenu, logSerialMenuItemIndex, xplm_Menu_Checked); + XPLConfig->setSerialLogFlag(1); + } + + } + } + +} + + + + +/**************************************************************************************/ +/* MyFlightLoopCallback -- Called by xplane every few flight loops */ +/**************************************************************************************/ +float MyFlightLoopCallback( + float inElapsedSinceLastCall, + float inElapsedTimeSinceLastFlightLoop, + int inCounter, + void* inRefcon) +{ + //return XPLDIRECT_RETURN_TIME; + //fprintf(errlog, "Time: %f \n", inElapsedSinceLastCall); + elapsedTime += inElapsedSinceLastCall; + + _processSerial(); + _updateDataRefs(0); + _updateCommands(); + + cycleCount++; + return (float)XPL_RETURN_TIME; +} + + + + +int widgetMessageDispatcher(XPWidgetMessage inMessage, XPWidgetID inWidget, intptr_t inParam1, intptr_t inParam2) +{ + // need to add for each dialog for now + + return 0; // always return 0 if we don't know what to do with the message + +} + +int ResetCommandHandler(XPLMCommandRef inCommand, + XPLMCommandPhase inPhase, + void* inRefcon) +{ + // Use this structure to have the command executed on button up only. + if (inPhase == xplm_CommandEnd) + { + + fprintf(errlog, "XPLPro/ResetDevices command received, I am complying. \n"); + + disengageDevices(); // just to make sure we are cleared + engageDevices(); + if (validPorts) XPLMSetMenuItemName(myMenu, disengageMenuItemIndex, "Disengage Devices", 0); + } + + // Return 1 to pass the command to plugin windows and X-Plane. + // Returning 0 disables further processing by X-Plane. + // In this case we might return 0 or 1 because X-Plane does not duplicate our command. + return 0; +} \ No newline at end of file diff --git a/XPLPro_Plugin_Source/XPLProPlugin.h b/XPLPro_Plugin_Source/XPLProPlugin.h new file mode 100644 index 0000000..9650a83 --- /dev/null +++ b/XPLPro_Plugin_Source/XPLProPlugin.h @@ -0,0 +1,17 @@ + +#pragma once + +#define XPL_VERSION 2302091 +#define XPLM200 + + + +float MyFlightLoopCallback(float inElapsedSinceLastCall, float inElapsedTimeSinceLastFlightLoop, int inCounter, void* inRefcon); + +static void MyMenuHandlerCallback( + void* inMenuRef, + void* inItemRef); + +int ResetCommandHandler(XPLMCommandRef inCommand, + XPLMCommandPhase inPhase, + void* inRefcon); diff --git a/XPLPro_Plugin_Source/abbreviations.cpp b/XPLPro_Plugin_Source/abbreviations.cpp new file mode 100644 index 0000000..4dad91f --- /dev/null +++ b/XPLPro_Plugin_Source/abbreviations.cpp @@ -0,0 +1,89 @@ + +#include +#include + +#include "XPLProCommon.h" +#include "abbreviations.h" + + +extern FILE* errlog; + +abbreviations::abbreviations() +{ + + + +} + + + +abbreviations::~abbreviations() +{ + + if (_abbFile) + { + fclose(_abbFile); + fprintf(errlog, "Abbreviation file closed.\n"); + } + + + +} + +int abbreviations::begin() +{ + + _abbFile = fopen(CFG_ABBREVIATIONS_FILE, "r"); + if (_abbFile) + { + fprintf(errlog, "Abbreviation file opened successfully. \n"); + return 1; + } + + fprintf(errlog, "** I was unable to open abbreviation.txt! This is not critical. \n"); + return -1; +} + +int abbreviations::convertString(char* inString) +{ + char inBuffer[200]; + char *retBuffer; + size_t inLength; + size_t startPos; + size_t endPos; + + if (!_abbFile) return -1; + + inLength = strlen(inString); + +//fprintf(errlog, "searching abbreviation file for: %s\n", inString); + rewind(_abbFile); + do + { + retBuffer = fgets(inBuffer, 200, _abbFile); + if (!strncmp(inBuffer, inString, inLength)) + { + if (inBuffer[inLength] != ' ' && inBuffer[inLength] != '=') continue; + + fprintf(errlog, "\n Abbreviations: converting: %s to: ", inString); + + startPos = inLength+1; + while ((!isgraph(inBuffer[startPos]) || inBuffer[startPos] == '=') && startPos < 100) startPos++; + endPos = startPos; + while (isgraph(inBuffer[endPos]) && endPos < 200) endPos++; + +//fprintf(errlog, "startpos: %i endpos: %i \n", startPos, endPos); + + strncpy(inString, &inBuffer[startPos], endPos - startPos); // dirty but it works + + fprintf(errlog, "%s... ", inString); + return 1; + + } +//fprintf(errlog, inBuffer); + + + } while (retBuffer != NULL); + + return -1; +} \ No newline at end of file diff --git a/XPLPro_Plugin_Source/abbreviations.h b/XPLPro_Plugin_Source/abbreviations.h new file mode 100644 index 0000000..90272a6 --- /dev/null +++ b/XPLPro_Plugin_Source/abbreviations.h @@ -0,0 +1,18 @@ +#pragma once +#include + +class abbreviations +{ + +public: + abbreviations(); + ~abbreviations(); + int begin(void); + int convertString(char* inString); + +private: + + FILE* _abbFile; + +}; + diff --git a/XPLPro_Plugin_Source/libconfig.h b/XPLPro_Plugin_Source/libconfig.h new file mode 100644 index 0000000..5e4eea3 --- /dev/null +++ b/XPLPro_Plugin_Source/libconfig.h @@ -0,0 +1,355 @@ +/* ---------------------------------------------------------------------------- + libconfig - A library for processing structured configuration files + Copyright (C) 2005-2018 Mark A Lindner + + This file is part of libconfig. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License + as published by the Free Software Foundation; either version 2.1 of + the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, see + . + ---------------------------------------------------------------------------- +*/ + +#ifndef __libconfig_h +#define __libconfig_h + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) +#if defined(LIBCONFIG_STATIC) +#define LIBCONFIG_API +#elif defined(LIBCONFIG_EXPORTS) +#define LIBCONFIG_API __declspec(dllexport) +#else /* ! LIBCONFIG_EXPORTS */ +#define LIBCONFIG_API __declspec(dllimport) +#endif /* LIBCONFIG_STATIC */ +#else /* ! WIN32 */ +#define LIBCONFIG_API +#endif /* WIN32 */ + +#define LIBCONFIG_VER_MAJOR 1 +#define LIBCONFIG_VER_MINOR 7 +#define LIBCONFIG_VER_REVISION 0 + +#include + +#define CONFIG_TYPE_NONE 0 +#define CONFIG_TYPE_GROUP 1 +#define CONFIG_TYPE_INT 2 +#define CONFIG_TYPE_INT64 3 +#define CONFIG_TYPE_FLOAT 4 +#define CONFIG_TYPE_STRING 5 +#define CONFIG_TYPE_BOOL 6 +#define CONFIG_TYPE_ARRAY 7 +#define CONFIG_TYPE_LIST 8 + +#define CONFIG_FORMAT_DEFAULT 0 +#define CONFIG_FORMAT_HEX 1 + +#define CONFIG_OPTION_AUTOCONVERT 0x01 +#define CONFIG_OPTION_SEMICOLON_SEPARATORS 0x02 +#define CONFIG_OPTION_COLON_ASSIGNMENT_FOR_GROUPS 0x04 +#define CONFIG_OPTION_COLON_ASSIGNMENT_FOR_NON_GROUPS 0x08 +#define CONFIG_OPTION_OPEN_BRACE_ON_SEPARATE_LINE 0x10 +#define CONFIG_OPTION_ALLOW_SCIENTIFIC_NOTATION 0x20 +#define CONFIG_OPTION_FSYNC 0x40 +#define CONFIG_OPTION_ALLOW_OVERRIDES 0x80 + +#define CONFIG_TRUE (1) +#define CONFIG_FALSE (0) + +typedef union config_value_t +{ + int ival; + long long llval; + double fval; + char *sval; + struct config_list_t *list; +} config_value_t; + +typedef struct config_setting_t +{ + char *name; + short type; + short format; + config_value_t value; + struct config_setting_t *parent; + struct config_t *config; + void *hook; + unsigned int line; + const char *file; +} config_setting_t; + +typedef enum +{ + CONFIG_ERR_NONE = 0, + CONFIG_ERR_FILE_IO = 1, + CONFIG_ERR_PARSE = 2 +} config_error_t; + +typedef struct config_list_t +{ + unsigned int length; + config_setting_t **elements; +} config_list_t; + +typedef const char ** (*config_include_fn_t)(struct config_t *, + const char *, + const char *, + const char **); + +typedef struct config_t +{ + config_setting_t *root; + void (*destructor)(void *); + int options; + unsigned short tab_width; + unsigned short float_precision; + unsigned short default_format; + const char *include_dir; + config_include_fn_t include_fn; + const char *error_text; + const char *error_file; + int error_line; + config_error_t error_type; + const char **filenames; + void *hook; +} config_t; + +extern LIBCONFIG_API int config_read(config_t *config, FILE *stream); +extern LIBCONFIG_API void config_write(const config_t *config, FILE *stream); + +extern LIBCONFIG_API void config_set_default_format(config_t *config, + short format); + +extern LIBCONFIG_API void config_set_options(config_t *config, int options); +extern LIBCONFIG_API int config_get_options(const config_t *config); + +extern LIBCONFIG_API void config_set_option(config_t *config, int option, + int flag); +extern LIBCONFIG_API int config_get_option(const config_t *config, int option); + +extern LIBCONFIG_API int config_read_string(config_t *config, const char *str); + +extern LIBCONFIG_API int config_read_file(config_t *config, + const char *filename); +extern LIBCONFIG_API int config_write_file(config_t *config, + const char *filename); + +extern LIBCONFIG_API void config_set_destructor(config_t *config, + void (*destructor)(void *)); +extern LIBCONFIG_API void config_set_include_dir(config_t *config, + const char *include_dir); +extern LIBCONFIG_API void config_set_include_func(config_t *config, + config_include_fn_t func); + +extern LIBCONFIG_API void config_set_float_precision(config_t *config, + unsigned short digits); +extern LIBCONFIG_API unsigned short config_get_float_precision( + const config_t *config); + +extern LIBCONFIG_API void config_set_tab_width(config_t *config, + unsigned short width); +extern LIBCONFIG_API unsigned short config_get_tab_width( + const config_t *config); + +extern LIBCONFIG_API void config_set_hook(config_t *config, void *hook); + +#define config_get_hook(C) ((C)->hook) + +extern LIBCONFIG_API void config_init(config_t *config); +extern LIBCONFIG_API void config_destroy(config_t *config); +extern LIBCONFIG_API void config_clear(config_t *config); + +extern LIBCONFIG_API int config_setting_get_int( + const config_setting_t *setting); +extern LIBCONFIG_API long long config_setting_get_int64( + const config_setting_t *setting); +extern LIBCONFIG_API double config_setting_get_float( + const config_setting_t *setting); +extern LIBCONFIG_API int config_setting_get_bool( + const config_setting_t *setting); +extern LIBCONFIG_API const char *config_setting_get_string( + const config_setting_t *setting); + +extern LIBCONFIG_API int config_setting_lookup_int( + const config_setting_t *setting, const char *name, int *value); +extern LIBCONFIG_API int config_setting_lookup_int64( + const config_setting_t *setting, const char *name, long long *value); +extern LIBCONFIG_API int config_setting_lookup_float( + const config_setting_t *setting, const char *name, double *value); +extern LIBCONFIG_API int config_setting_lookup_bool( + const config_setting_t *setting, const char *name, int *value); +extern LIBCONFIG_API int config_setting_lookup_string( + const config_setting_t *setting, const char *name, const char **value); + +extern LIBCONFIG_API int config_setting_set_int(config_setting_t *setting, + int value); +extern LIBCONFIG_API int config_setting_set_int64(config_setting_t *setting, + long long value); +extern LIBCONFIG_API int config_setting_set_float(config_setting_t *setting, + double value); +extern LIBCONFIG_API int config_setting_set_bool(config_setting_t *setting, + int value); +extern LIBCONFIG_API int config_setting_set_string(config_setting_t *setting, + const char *value); + +extern LIBCONFIG_API int config_setting_set_format(config_setting_t *setting, + short format); +extern LIBCONFIG_API short config_setting_get_format( + const config_setting_t *setting); + +extern LIBCONFIG_API int config_setting_get_int_elem( + const config_setting_t *setting, int idx); +extern LIBCONFIG_API long long config_setting_get_int64_elem( + const config_setting_t *setting, int idx); +extern LIBCONFIG_API double config_setting_get_float_elem( + const config_setting_t *setting, int idx); +extern LIBCONFIG_API int config_setting_get_bool_elem( + const config_setting_t *setting, int idx); +extern LIBCONFIG_API const char *config_setting_get_string_elem( + const config_setting_t *setting, int idx); + +extern LIBCONFIG_API config_setting_t *config_setting_set_int_elem( + config_setting_t *setting, int idx, int value); +extern LIBCONFIG_API config_setting_t *config_setting_set_int64_elem( + config_setting_t *setting, int idx, long long value); +extern LIBCONFIG_API config_setting_t *config_setting_set_float_elem( + config_setting_t *setting, int idx, double value); +extern LIBCONFIG_API config_setting_t *config_setting_set_bool_elem( + config_setting_t *setting, int idx, int value); +extern LIBCONFIG_API config_setting_t *config_setting_set_string_elem( + config_setting_t *setting, int idx, const char *value); + +extern LIBCONFIG_API const char **config_default_include_func( + config_t *config, const char *include_dir, const char *path, + const char **error); + +extern LIBCONFIG_API int config_setting_is_scalar( + const config_setting_t *setting); + +extern LIBCONFIG_API int config_setting_is_aggregate( + const config_setting_t *setting); + +#define /* const char * */ config_get_include_dir(/* const config_t * */ C) \ + ((C)->include_dir) + +#define /* void */ config_set_auto_convert(/* config_t * */ C, F) \ + config_set_option((C), CONFIG_OPTION_AUTOCONVERT, (F)) +#define /* int */ config_get_auto_convert(/* const config_t * */ C) \ + config_get_option((C), CONFIG_OPTION_AUTOCONVERT) + +#define /* int */ config_setting_type(/* const config_setting_t * */ S) \ + ((S)->type) + +#define /* int */ config_setting_is_group(/* const config_setting_t * */ S) \ + ((S)->type == CONFIG_TYPE_GROUP) +#define /* int */ config_setting_is_array(/* const config_setting_t * */ S) \ + ((S)->type == CONFIG_TYPE_ARRAY) +#define /* int */ config_setting_is_list(/* const config_setting_t * */ S) \ + ((S)->type == CONFIG_TYPE_LIST) + +#define /* int */ config_setting_is_number(/* const config_setting_t * */ S) \ + (((S)->type == CONFIG_TYPE_INT) \ + || ((S)->type == CONFIG_TYPE_INT64) \ + || ((S)->type == CONFIG_TYPE_FLOAT)) + +#define /* const char * */ config_setting_name( \ + /* const config_setting_t * */ S) \ + ((S)->name) + +#define /* config_setting_t * */ config_setting_parent( \ + /* const config_setting_t * */ S) \ + ((S)->parent) + +#define /* int */ config_setting_is_root( \ + /* const config_setting_t * */ S) \ + ((S)->parent ? CONFIG_FALSE : CONFIG_TRUE) + +extern LIBCONFIG_API int config_setting_index(const config_setting_t *setting); + +extern LIBCONFIG_API int config_setting_length( + const config_setting_t *setting); +extern LIBCONFIG_API config_setting_t *config_setting_get_elem( + const config_setting_t *setting, unsigned int idx); + +extern LIBCONFIG_API config_setting_t *config_setting_get_member( + const config_setting_t *setting, const char *name); + +extern LIBCONFIG_API config_setting_t *config_setting_add( + config_setting_t *parent, const char *name, int type); +extern LIBCONFIG_API int config_setting_remove(config_setting_t *parent, + const char *name); +extern LIBCONFIG_API int config_setting_remove_elem(config_setting_t *parent, + unsigned int idx); +extern LIBCONFIG_API void config_setting_set_hook(config_setting_t *setting, + void *hook); + +#define config_setting_get_hook(S) ((S)->hook) + +extern LIBCONFIG_API config_setting_t *config_lookup(const config_t *config, + const char *path); +extern LIBCONFIG_API config_setting_t *config_setting_lookup( + config_setting_t *setting, const char *path); + +extern LIBCONFIG_API int config_lookup_int(const config_t *config, + const char *path, int *value); +extern LIBCONFIG_API int config_lookup_int64(const config_t *config, + const char *path, + long long *value); +extern LIBCONFIG_API int config_lookup_float(const config_t *config, + const char *path, double *value); +extern LIBCONFIG_API int config_lookup_bool(const config_t *config, + const char *path, int *value); +extern LIBCONFIG_API int config_lookup_string(const config_t *config, + const char *path, + const char **value); + +#define /* config_setting_t * */ config_root_setting( \ + /* const config_t * */ C) \ + ((C)->root) + +#define /* void */ config_set_default_format(/* config_t * */ C, \ + /* short */ F) \ + (C)->default_format = (F) + +#define /* short */ config_get_default_format(/* config_t * */ C) \ + ((C)->default_format) + +#define /* unsigned short */ config_setting_source_line( \ + /* const config_setting_t * */ S) \ + ((S)->line) + +#define /* const char */ config_setting_source_file( \ + /* const config_setting_t * */ S) \ + ((S)->file) + +#define /* const char * */ config_error_text(/* const config_t * */ C) \ + ((C)->error_text) + +#define /* const char * */ config_error_file(/* const config_t * */ C) \ + ((C)->error_file) + +#define /* int */ config_error_line(/* const config_t * */ C) \ + ((C)->error_line) + +#define /* config_error_t */ config_error_type(/* const config_t * */ C) \ + ((C)->error_type) + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __libconfig_h */ diff --git a/XPLPro_Plugin_Source/libconfig.lib b/XPLPro_Plugin_Source/libconfig.lib new file mode 100644 index 0000000..841786e Binary files /dev/null and b/XPLPro_Plugin_Source/libconfig.lib differ diff --git a/XPLPro_Plugin_Source/monitorwindow.h b/XPLPro_Plugin_Source/monitorwindow.h new file mode 100644 index 0000000..cc217f7 --- /dev/null +++ b/XPLPro_Plugin_Source/monitorwindow.h @@ -0,0 +1,11 @@ +#pragma once +#ifndef MONITORWINDOW_H_INCLUDED +#define MONITORWINDOW_H_INCLUDED + + + +PLUGIN_API int MonitorWindowStart(void); +void CreateTestWidgets(int , int , int , int ); + +#endif + diff --git a/XPLPro_Plugin_Source/serialclass.h b/XPLPro_Plugin_Source/serialclass.h new file mode 100644 index 0000000..25260ed --- /dev/null +++ b/XPLPro_Plugin_Source/serialclass.h @@ -0,0 +1,50 @@ +#pragma once + +#define XPL_MAX_SERIALPORTS + +#include +#include +#include + +class serialClass +{ +private: + //Serial comm handler + HANDLE hSerial = NULL; + //Connection status + bool connected = false; + //Get various information about the connection + COMSTAT status; + //Keep track of last error + DWORD errors; + + + + +public: + //Initialize Serial communication with the given COM port + serialClass(); + //Close the connection + ~serialClass(); + + int begin(int portNumber); + int shutDown(void); + int findAvailablePort(void); + + + //Read data in a buffer, if nbChar is greater than the + //maximum number of bytes available, it will return only the + //bytes available. The function return -1 when nothing could + //be read, the number of bytes actually read. + int readData(char* buffer, size_t nbChar); + //Writes data from a buffer through the Serial connection + //return true on success. + bool writeData(const char* buffer, size_t nbChar); + //Check if we are actually connected + bool IsConnected(void); + + char portName[20]; // port name + int valid; + +}; +