### XPLMGetScreenBoundsGlobal Source: https://developer.x-plane.com/sdk/XPLMDisplay Gets the boundaries of the global X-Plane desktop in boxels, considering multi-monitor setups. ```APIDOC ## XPLMGetScreenBoundsGlobal ### Description Returns the bounds of the “global” X-Plane desktop, in boxels. This is multi-monitor aware, unlike XPLMGetScreenSize(). It accounts for different monitor arrangements and resolutions, including potential wasted space. Popped-out windows are not included. ### Method `void` ### Endpoint `XPLMGetScreenBoundsGlobal(int * outLeft, int * outTop, int * outRight, int * outBottom)` ### Parameters #### Path Parameters - **outLeft** (int *) - Optional - Pointer to store the left bound in boxels. Can be NULL. - **outTop** (int *) - Optional - Pointer to store the top bound in boxels. Can be NULL. - **outRight** (int *) - Optional - Pointer to store the right bound in boxels. Can be NULL. - **outBottom** (int *) - Optional - Pointer to store the bottom bound in boxels. Can be NULL. ### Request Example ```json { "example": "int left, top, right, bottom; XPLMGetScreenBoundsGlobal(&left, &top, &right, &bottom);" } ``` ### Response #### Success Response (200) - **outLeft** (int) - The left coordinate of the global desktop in boxels. - **outTop** (int) - The top coordinate of the global desktop in boxels. - **outRight** (int) - The right coordinate of the global desktop in boxels. - **outBottom** (int) - The bottom coordinate of the global desktop in boxels. #### Response Example ```json { "example": "left = 0, top = 0, right = 3840, bottom = 1080" } ``` ``` -------------------------------- ### Command Execution API Source: https://developer.x-plane.com/sdk/XPLMUtilities APIs for starting and ending the execution of X-Plane commands. ```APIDOC ## XPLMCommandBegin ### Description XPLMCommandBegin initiates the execution of a command specified by its command reference. The command remains active (as if held down) until `XPLMCommandEnd` is called. Each call to `XPLMCommandBegin` must be balanced with a corresponding call to `XPLMCommandEnd`. ### Method `void XPLMCommandBegin(XPLMCommandRef inCommand)` ### Parameters #### Path Parameters - `inCommand` (XPLMCommandRef) - Required - The reference of the command to begin execution. ### Request Example ``` // Assuming 'myCommandRef' is a valid XPLMCommandRef obtained via XPLMFindCommand XPLMCommandBegin(myCommandRef); ``` ### Response This function does not return a value. ``` ```APIDOC ## XPLMCommandEnd ### Description XPLMCommandEnd terminates the execution of a command that was previously started with `XPLMCommandBegin`. It is crucial not to call `XPLMCommandEnd` for a command that was not initiated by `XPLMCommandBegin` from the same source. ### Method `void XPLMCommandEnd(XPLMCommandRef inCommand)` ### Parameters #### Path Parameters - `inCommand` (XPLMCommandRef) - Required - The reference of the command to end execution. ### Request Example ``` // Assuming 'myCommandRef' is a valid XPLMCommandRef and XPLMCommandBegin was called previously XPLMCommandEnd(myCommandRef); ``` ### Response This function does not return a value. ``` -------------------------------- ### Get X-Plane Screen Size (C) Source: https://developer.x-plane.com/sdk/XPLMDisplay The XPLMGetScreenSize routine returns the dimensions of the main X-Plane OpenGL window in pixels. This information can be useful for estimating the level of detail visible to the user in 3D. ```c XPLM_API void XPLMGetScreenSize( int * outWidth, /* Can be NULL */ int * outHeight); /* Can be NULL */ ``` -------------------------------- ### Get Plugin by Index - XPLMGetNthPlugin (C) Source: https://developer.x-plane.com/sdk/XPLMPlugin Fetches the plugin ID of a plugin based on its zero-based index. The order of plugins is arbitrary and may change between simulator sessions. Ensure to use XPLMCountPlugins to get the valid range for the index. ```c XPLM_API XPLMPluginID XPLMGetNthPlugin(int inIndex); ``` -------------------------------- ### Get Virtual Key Description - XPLMGetVirtualKeyDescription Source: https://developer.x-plane.com/sdk/XPLMUtilities Retrieves a human-readable string for a given virtual key code. Useful for displaying keyboard mappings to users. Returns 'unknown', blank, or NULL for unrecognized keys. ```c XPLM_API const char * XPLMGetVirtualKeyDescription( char inVirtualKey); ``` -------------------------------- ### Get Plugin Information - XPLMGetPluginInfo (C) Source: https://developer.x-plane.com/sdk/XPLMPlugin Retrieves detailed information about a specific plugin, including its name, file path, signature, and description. Each output parameter should be a pointer to a character buffer of at least 256 bytes, or NULL if the information is not needed. ```c XPLM_API void XPLMGetPluginInfo(XPLMPluginID inPlugin, char *outName, char *outFilePath, char *outSignature, char *outDescription); ``` -------------------------------- ### XPLMGetDatavi Source: https://developer.x-plane.com/sdk/XPLMGetDatavi Reads a portion of an integer array dataref. Can be used to get the array size or to retrieve a specific number of integer values starting from a given offset. ```APIDOC ## XPLMGetDatavi ### Description Reads a part of an integer array dataref. If `outValues` is NULL, the routine returns the size of the array. If `outValues` is not NULL, up to `inMax` values are copied from the dataref into `outValues`, starting at `inOffset`. ### Method XPLM_API ### Endpoint N/A (This is a function call, not a network endpoint) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None #### Function Parameters - **inDataRef** (XPLMDataRef) - A reference to the integer array dataref. - **outValues** (int *) - A pointer to an integer array where the values will be stored. Can be NULL to get the array size. - **inOffset** (int) - The starting offset within the dataref to begin reading. - **inMax** (int) - The maximum number of integer values to read. ### Request Example ```c // Example: Get the size of the dataref int arraySize = XPLMGetDatavi(myIntArrayRef, NULL, 0, 0); // Example: Read 10 values starting from offset 5 int values[10]; int numRead = XPLMGetDatavi(myIntArrayRef, values, 5, 10); ``` ### Response #### Success Response (int) Returns the number of values read if `outValues` is not NULL, or the total size of the array if `outValues` is NULL. #### Response Example ``` // If outValues was NULL, the return value is the size of the array, e.g., 100 // If outValues was not NULL, the return value is the number of elements copied, e.g., 10 ``` ``` -------------------------------- ### Begin Command Execution - XPLMCommandBegin Source: https://developer.x-plane.com/sdk/XPLMUtilities Initiates the execution of a command using its reference. The command remains active until XPLMCommandEnd is called. Requires a corresponding XPLMCommandEnd call to maintain balance. ```c XPLM_API void XPLMCommandBegin( XPLMCommandRef inCommand); ``` -------------------------------- ### Get Elapsed Time Since Sim Start (C) Source: https://developer.x-plane.com/sdk/XPLMProcessing Retrieves the total elapsed time since the X-Plane simulator started, measured in decimal seconds. This is a wall-clock timer that continues to count even when the simulation is paused. It is not recommended for timing critical applications due to potential precision limitations. ```c XPLM_API float XPLMGetElapsedTime(void); ``` -------------------------------- ### Retrieve Plugin Information using XPLMGetPluginInfo (C) Source: https://developer.x-plane.com/sdk/XPLMGetPluginInfo This C function retrieves detailed information about a specified plugin. It requires a valid XPLMPluginID and character buffers to store the plugin's name, file path, signature, and description. Buffers should be at least 256 characters, or NULL can be passed if the information is not needed. ```c 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 */ ``` -------------------------------- ### Get Elapsed Simulation Time Source: https://developer.x-plane.com/sdk/XPLMProcessing Retrieves the total elapsed time since the simulation started, measured in decimal seconds. This timer is a wall clock and continues to count even when the simulation is paused. ```APIDOC ## XPLMGetElapsedTime ### Description 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 paused. ### Signature ```c XPLM_API float XPLMGetElapsedTime(void); ``` ### Return Value - **float**: The elapsed time in seconds since the simulation started. **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. ``` -------------------------------- ### XPLMAvionicsScreenCallback_f Prototype Source: https://developer.x-plane.com/sdk/XPLMDisplay Prototype for drawing callbacks used with custom avionics devices' screens. Provides a reference context (`inRefcon`) for custom data. ```APIDOC ## XPLMAvionicsScreenCallback_f Prototype ### Description This is the prototype for drawing callbacks for custom devices' screens. The `inRefcon` parameter is a unique value specified during device creation, allowing you to pass a pointer to your own data to the callback. The OpenGL context is set up for 2D drawing in panel coordinates upon entry. You must call `glClear()` to erase screen contents if needed, as X-Plane does not clear the screen between calls. ### Function Signature ```c typedef void (* XPLMAvionicsScreenCallback_f)( void * inRefcon); ``` ### Parameters - **inRefcon** (void *) - A reference to user-defined data passed to the callback. ``` -------------------------------- ### Get Current Simulation Cycle Number (C) Source: https://developer.x-plane.com/sdk/XPLMProcessing Retrieves the current simulation cycle number, which increments for each computed sim cycle or rendered video frame, starting from zero. This counter can be useful for tracking the progress of simulation updates. ```c XPLM_API int XPLMGetCycleNumber(void); ``` -------------------------------- ### Window API Concepts Source: https://developer.x-plane.com/sdk/XPLMDisplay Explains the concepts behind the X-Plane Window API, including modern vs. legacy modes, boxel units, and coordinate system origins. ```APIDOC ## WINDOW API Concepts ### Description Provides an overview of the X-Plane Window API, detailing its modes, units, and coordinate systems. ### Modes * **Legacy Mode**: For older plugins and windows created with `XPLMCreateWindow()`. Uses screen pixels. * **Modern Mode**: For plugins using XPLM300+ and `XPLMCreateWindowEx()`. Supports new features like popped-out windows and uses boxel units. ### Units * **Boxel**: A "box of pixels" unit used in modern windows. X-Plane handles scaling automatically. * **Screen Pixels**: Used in legacy windows. Can appear small on scaled displays. ### Coordinate System * **Legacy Windows**: Origin at the lower-left of the main X-Plane window. X increases to the right, Y increases upwards. * **Modern Windows**: Origin at the lower-left of the global desktop space. The main X-Plane window's origin is not guaranteed to be (0,0). X increases to the right, Y increases upwards. ### XPLMWindowID * Type: `typedef void * XPLMWindowID;` * Description: An opaque identifier for a window, used to control window behavior like drawing and interaction. ### XPLMDrawWindow_f Callback * Type: `typedef void (* XPLMDrawWindow_f)(XPLMWindowID inWindowID, void *inRefcon);` * Description: A callback function for handling 2D drawing of a window. It receives the window ID and a reference constant. The OpenGL context is set for 2D drawing. Translucent windows can be created by not filling the entire window bounds. ``` -------------------------------- ### XPLMCreateWindow_t Structure Definition (C) Source: https://developer.x-plane.com/sdk/XPLMDisplay Defines the parameters for creating a modern window using XPLMCreateWindowEx(). Includes window bounds, visibility, drawing and input callbacks, and decoration options. The structSize member must be set to the size of the structure. ```c 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; // Specifies the type of X-Plane 11-style "wrapper" you want around your window, if any XPLMWindowDecoration decorateAsFloatingWindow; XPLMWindowLayer layer; // A callback to handle the user right-clicking within your window (or NULL to ignore right clicks) XPLMHandleMouseClick_f handleRightClickFunc; } XPLMCreateWindow_t; ``` -------------------------------- ### XPLMHasFeature Source: https://developer.x-plane.com/sdk/XPLMPlugin Checks if a specific feature is supported by the current X-Plane installation. ```APIDOC ## XPLMHasFeature ### Description Determines if a given feature is supported by the current X-Plane installation. ### Method GET ### Endpoint N/A (Function Call) ### Parameters #### Path Parameters - **inFeature** (const char *) - Required - The name of the feature to check. ### Response #### Success Response (int) - **return value** (int) - Returns 1 if the feature is supported, 0 otherwise. ### Request Example ```c if (XPLMHasFeature("MY_CUSTOM_FEATURE")) { // Feature is supported } ``` ### Response Example ```json { "returnValue": 1 } ``` ``` -------------------------------- ### XPUCreateWidgets Source: https://developer.x-plane.com/sdk/XPWidgetUtils Creates a series of widgets from an array of definitions. Allows for bulk widget creation and nested structures. ```APIDOC ## XPUCreateWidgets ### Description This function creates a series of widgets from a table (see `XPWidgetCreate_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. ### Method `void XPUCreateWidgets(const XPWidgetCreate_t *inWidgetDefs, int inCount, XPWidgetID inParamParent, XPWidgetID *ioWidgets)` ### Parameters - **inWidgetDefs** (const XPWidgetCreate_t *) - An array of widget creation definitions. - **inCount** (int) - The number of widget definitions in the array. - **inParamParent** (XPWidgetID) - The widget ID to use when `containerIndex` is `PARAM_PARENT`. - **ioWidgets** (XPWidgetID *) - An array to store the created widget IDs. ``` -------------------------------- ### GET /XPLMGetDirectorySeparator Source: https://developer.x-plane.com/sdk/XPLMUtilities Returns the directory separator character for the current platform. ```APIDOC ## GET /XPLMGetDirectorySeparator ### Description 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 concatenates directory paths without having to #ifdef for platform. The character returned will reflect the current file path mode. ### Method GET ### Endpoint /XPLMGetDirectorySeparator ### Parameters None ### Response #### Success Response (200) - **separator** (const char*) - A string containing the directory separator character (e.g., "/" or "). ### Response Example ``` "/" ``` ``` -------------------------------- ### XPLMCustomizeAvionics_t Structure Source: https://developer.x-plane.com/sdk/XPLMDisplay Defines parameters for replacing or enhancing built-in simulator avionics devices. Includes callbacks for drawing, mouse interaction, scrolling, cursor display, and keyboard input. ```APIDOC ## XPLMCustomizeAvionics_t Structure ### Description The `XPLMCustomizeAvionics_t` structure defines all of the parameters used to replace or enhance built-in simulator avionics devices using `XPLMRegisterAvionicsCallbacksEx()`. ### Fields - **structSize** (int) - Size of the struct in bytes. Must be set to `sizeof(XPLMCustomizeAvionics_t)`. - **deviceId** (XPLMDeviceID) - The built-in avionics device to which your drawing is applied. - **drawCallbackBefore** (XPLMAvionicsCallback_f) - Callback function called before X-Plane draws. - **drawCallbackAfter** (XPLMAvionicsCallback_f) - Callback function called after X-Plane draws. - **bezelClickCallback** (XPLMAvionicsMouse_f) - Mouse click callback for the device's bezel. - **bezelRightClickCallback** (XPLMAvionicsMouse_f) - Right mouse click callback for the device's bezel. - **bezelScrollCallback** (XPLMAvionicsMouseWheel_f) - Scroll wheel callback for the device's bezel. - **bezelCursorCallback** (XPLMAvionicsCursor_f) - Callback to determine the cursor over the device's bezel. - **screenTouchCallback** (XPLMAvionicsMouse_f) - Mouse click callback for the device's screen. - **screenRightTouchCallback** (XPLMAvionicsMouse_f) - Right mouse click callback for the device's screen. - **screenScrollCallback** (XPLMAvionicsMouseWheel_f) - Scroll wheel callback for the device's screen. - **screenCursorCallback** (XPLMAvionicsCursor_f) - Callback to determine the cursor over the device's screen. - **keyboardCallback** (XPLMAvionicsKeyboard_f) - Keyboard callback for the device's popup. - **refcon** (void *) - Reference passed into draw callbacks for custom data. ``` -------------------------------- ### Install Error Callback for X-Plane Plugin (C) Source: https://developer.x-plane.com/sdk/XPLMSetErrorCallback The XPLMSetErrorCallback function installs a callback that is invoked when programming errors are detected within an X-Plane plugin. This function is crucial for debugging as it allows developers to set breakpoints within their error handling code. It is recommended to only use this in development environments as it can impact performance and is not useful for runtime error handling in production. ```c XPLM_API void XPLMSetErrorCallback( XPLMError_f inCallback); ``` -------------------------------- ### Create X-Plane Instance (C) Source: https://developer.x-plane.com/sdk/XPLMCreateInstance The XPLMCreateInstance function creates a new instance managed by a plugin. It requires a valid XPLMObjectRef and a null-terminated array of dataref names. The object must be loaded before creating an instance, and custom datarefs must be registered beforehand. ```c XPLM_API XPLMInstanceRef XPLMCreateInstance( XPLMObjectRef obj, const char ** datarefs); ``` -------------------------------- ### Define Avionics Brightness Callback (C) Source: https://developer.x-plane.com/sdk/XPLMAvionicsBrightness_f Prototype for callbacks that determine the screen brightness ratio for custom avionics devices in X-Plane. It takes rheostat value, ambient brightness, bus voltage ratio, and a reference constant as input, returning the desired screen brightness ratio (0-1). ```c typedef float (* XPLMAvionicsBrightness_f)( float inRheoValue, float inAmbiantBrightness, float inBusVoltsRatio, void * inRefcon); ``` -------------------------------- ### Execute Command Momentarily (XPLMCommandOnce) Source: https://developer.x-plane.com/sdk/XPLMUtilities The XPLMCommandOnce function executes a given command momentarily. This is equivalent to starting and immediately ending a command, simulating a single, instantaneous user action. It takes a command reference as input. ```c XPLM_API void XPLMCommandOnce( XPLMCommandRef inCommand); ``` -------------------------------- ### GET /XPLMGetPrefsPath Source: https://developer.x-plane.com/sdk/XPLMUtilities Retrieves a full path to a file within X-Plane's preferences directory. ```APIDOC ## GET /XPLMGetPrefsPath ### Description 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`). ### Method GET ### Endpoint /XPLMGetPrefsPath ### Parameters #### Query Parameters - **outPrefsPath** (char*) - Required - A buffer to store the preferences path. Must be at least 512 characters long. ### Response #### Success Response (200) - **outPrefsPath** (char*) - The full path within the X-Plane preferences directory. ### Response Example ``` "/Users/username/Library/Preferences/X-Plane/Output/preferences.prf" ``` ``` -------------------------------- ### Create Legacy X-Plane Window (XPLMCreateWindow) Source: https://developer.x-plane.com/sdk/XPLMCreateWindow This function creates a legacy window in X-Plane. It takes parameters for window dimensions, visibility, and callback functions for drawing, key input, and mouse clicks. It returns a window ID for future reference. Note that this function is deprecated and does not support modern X-Plane features like high-DPI scaling or native window styles. ```c 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); ``` -------------------------------- ### XPLMGetDatab Source: https://developer.x-plane.com/sdk/XPLMDataAccess Reads a portion of a byte array dataref. Can be used to get the size of the array or read bytes into a buffer. ```APIDOC ## XPLMGetDatab ### Description Reads a part of a byte array dataref. If `outValue` is NULL, returns the array size in bytes. Otherwise, copies up to `inMaxBytes` from the dataref into `outValue` starting at `inOffset`. ### Method Call ### Endpoint N/A (SDK Function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c XPLM_API int XPLMGetDatab(XPLMDataRef inDataRef, void *outValue, int inOffset, int inMaxBytes); ``` ### Response #### Success Response (int) - Returns the size of the array in bytes if `outValue` is NULL. - Returns the number of bytes copied if `outValue` is not NULL. #### Response Example ```c // Example of getting array size int arraySizeBytes = XPLMGetDatab(myByteArrayRef, NULL, 0, 0); // Example of reading bytes char buffer[20]; int bytesRead = XPLMGetDatab(myByteArrayRef, buffer, 0, 20); ``` ``` -------------------------------- ### Manage Window Z-Order (XPLMBringWindowToFront, XPLMIsWindowInFront) Source: https://developer.x-plane.com/sdk/XPLMDisplay XPLMBringWindowToFront raises a window to the top of its display layer. XPLMIsWindowInFront checks if a window is the foremost in its layer. It's important to note that these functions operate within specific layers (e.g., floating, modal) and do not guarantee being the absolute frontmost window if other layers are involved. ```c XPLM_API void XPLMBringWindowToFront(XPLMWindowID inWindow); XPLM_API int XPLMIsWindowInFront(XPLMWindowID inWindow); ``` -------------------------------- ### XPGetWidgetDescriptor Source: https://developer.x-plane.com/sdk/XPGetWidgetDescriptor Retrieves the descriptor string for a given widget. It can also be used to get the descriptor's length without retrieving the string itself. ```APIDOC ## XPGetWidgetDescriptor ### Description 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 Signature ```c WIDGET_API int XPGetWidgetDescriptor( XPWidgetID inWidget, char * outDescriptor, int inMaxDescLength); ``` ### Parameters #### Input Parameters - **inWidget** (XPWidgetID) - The ID of the widget whose descriptor is to be retrieved. - **outDescriptor** (char *) - A buffer to store the widget descriptor. If NULL, only the length is returned. - **inMaxDescLength** (int) - The maximum length of the buffer provided for `outDescriptor`. This includes space for the null terminator. ### Returns - **int**: The length of the actual descriptor string. If `outDescriptor` is NULL, this is the only return value. If the descriptor exceeds `inMaxDescLength`, the buffer will not be null-terminated. ``` -------------------------------- ### XPLMSetErrorCallback Source: https://developer.x-plane.com/sdk/XPLMSetErrorCallback Installs an error-reporting callback for the plugin. This callback is invoked for programming errors, such as invalid API parameters, and is intended for debugging purposes. ```APIDOC ## XPLMSetErrorCallback ### Description Installs an error-reporting callback for your plugin. When an error callback is installed, the plugin system will notify you of certain plugin errors, such as passing incorrect parameters or data. This function is intended for debugging to help identify and fix programming mistakes within your plugin. ### Method `void XPLMSetErrorCallback(XPLMError_f inCallback)` ### Endpoint N/A (This is a function call within the X-Plane SDK, not a web API endpoint) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c // Example of installing an error callback (conceptual) XPLMSetErrorCallback(myErrorCallbackFunction); ``` ### Response #### Success Response (void) This function does not return a value. #### Response Example N/A ``` -------------------------------- ### XPLMGetWindowGeometryVR Source: https://developer.x-plane.com/sdk/XPLMDisplay Returns the width and height, in boxels, of a window in VR. ```APIDOC ## XPLMGetWindowGeometryVR ### Description 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()). ### Method `void` ### Endpoint `XPLMGetWindowGeometryVR(XPLMWindowID inWindowID, int * outWidthBoxels, int * outHeightBoxels)` ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - **inWindowID** (XPLMWindowID) - The ID of the window to query. - **outWidthBoxels** (int *) - Pointer to store the width in boxels (can be NULL). - **outHeightBoxels** (int *) - Pointer to store the height in boxels (can be NULL). ### Request Example ```json { "inWindowID": "some_window_id" } ``` ### Response #### Success Response (200) - **outWidthBoxels** (int) - The width of the VR window in boxels. - **outHeightBoxels** (int) - The height of the VR window in boxels. #### Response Example ```json { "outWidthBoxels": 1024, "outHeightBoxels": 768 } ``` ``` -------------------------------- ### GET /XPLMGetSystemPath Source: https://developer.x-plane.com/sdk/XPLMUtilities Retrieves the full path to the X-System folder. The returned path may end with a directory separator character. ```APIDOC ## GET /XPLMGetSystemPath ### Description 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 / . ### Method GET ### Endpoint /XPLMGetSystemPath ### Parameters #### Query Parameters - **outSystemPath** (char*) - Required - A buffer to store the system path. Must be at least 512 characters long. ### Response #### Success Response (200) - **outSystemPath** (char*) - The full path to the X-System folder. ### Response Example ``` "/Applications/X-Plane 12/X-System/" ``` ``` -------------------------------- ### Get Flight Cycle Number Source: https://developer.x-plane.com/sdk/XPLMProcessing Retrieves the current flight cycle number, which increments for each computed simulation cycle or rendered video frame. ```APIDOC ## XPLMGetCycleNumber ### Description This routine returns a counter starting at zero for each sim cycle computed/video frame rendered. ### Signature ```c XPLM_API int XPLMGetCycleNumber(void); ``` ### Return Value - **int**: The current flight cycle number, starting from zero. ``` -------------------------------- ### Weather Update Management Source: https://developer.x-plane.com/sdk/XPLMWeather Functions to manage the start and end of batch weather updates, optimizing performance by informing the simulator of upcoming changes. ```APIDOC ## XPLMBeginWeatherUpdate ### Description Informs the simulator that you are starting a batch update of weather information. This can improve performance if you are providing multiple weather updates. ### Method `void` ### Endpoint N/A (Function call) ### Parameters None ### Request Example ```c XPLMBeginWeatherUpdate(); ``` ### Response N/A ## XPLMEndWeatherUpdate ### Description Informs the simulator that you are ending a batch update of weather information. It is mandatory to call this function after `XPLMBeginWeatherUpdate` before exiting the callback. ### Method `void` ### Endpoint N/A (Function call) ### Parameters - **isIncremental** (int) - Controls whether the update is incremental (applied to existing data) or replaces all previous data. - **updateImmediately** (int) - Determines if the weather changes should be applied instantly or with a slight delay to ensure smooth transitions. ### Request Example ```c XPLMEndWeatherUpdate(1, 0); // Incremental update, not immediate ``` ### Response N/A ``` -------------------------------- ### Avionics Screen Drawing Callback Prototype (C) Source: https://developer.x-plane.com/sdk/XPLMDisplay This is the prototype for callbacks used for drawing on custom avionics device screens. The 'inRefcon' parameter allows you to pass custom data. The OpenGL context is prepared for 2D drawing, but the state is unknown, and you must clear the screen using glClear() if necessary. ```c typedef void (* XPLMAvionicsScreenCallback_f)( void * inRefcon); ``` -------------------------------- ### XPLMSetErrorCallback API Source: https://developer.x-plane.com/sdk/XPLMUtilities Installs a callback function to receive notifications for specific plugin errors, such as invalid parameters. This is intended for debugging purposes. ```APIDOC ## XPLMSetErrorCallback ### Description Installs an error callback function that will be invoked when certain plugin errors occur, such as passing incorrect data or parameters. This is primarily intended for debugging to help identify programming mistakes. ### Method `void XPLMSetErrorCallback(XPLMError_f inCallback)` ### Endpoint N/A (This is a C API function) ### Parameters - **inCallback** (XPLMError_f) - A pointer to the callback function to be installed. This function should have the signature `void MyErrorCallback(XPLMErrorCode, const char *)`. ### Request Example N/A ### Response #### Success Response (void) Installs the provided error callback. #### Response Example ```c void MyErrorCallback(XPLMErrorCode inErrorCode, const char * inError) { // Handle the error, e.g., log it or break in debugger fprintf(stderr, "X-Plane Error: %d - %s\n", inErrorCode, inError); // asm { int 3 } // Uncomment to break in debugger } XPLMSetErrorCallback(MyErrorCallback); ``` ### Important Error callbacks report programming errors, not expected runtime problems. Installing an error callback may affect performance and should not be left in shipping plugins. The callback is typically used during development with a breakpoint set within it. ``` -------------------------------- ### XPLMGetAllMonitorBoundsGlobal Source: https://developer.x-plane.com/sdk/XPLMDisplay Invokes a callback with the global bounds of each full-screen X-Plane window. ```APIDOC ## XPLMGetAllMonitorBoundsGlobal ### Description Immediately calls a provided callback function with the bounds (in boxels) of each full-screen X-Plane window within the X-Plane global desktop space. Monitors not covered by an X-Plane window or windows not in full-screen mode are not included. Monitor indices match XPLMGetAllMonitorBoundsOS(), but coordinates may differ due to scaling. ### Method `void` ### Endpoint `XPLMGetAllMonitorBoundsGlobal(XPLMReceiveMonitorBoundsGlobal_f inMonitorBoundsCallback, void * inRefcon)` ### Parameters #### Path Parameters - **inMonitorBoundsCallback** (XPLMReceiveMonitorBoundsGlobal_f) - Required - The callback function to be invoked for each monitor's bounds. - **inRefcon** (void *) - Optional - A reference constant passed to the callback function. Can be NULL. ### Request Example ```json { "example": "void myCallback(int monitorIndex, int left, int top, int right, int bottom, void* refcon) { /* ... */ }\nXPLMGetAllMonitorBoundsGlobal(myCallback, NULL);" } ``` ### Response #### Success Response (200) This function does not return a value directly; it triggers the provided callback. #### Response Example ```json { "example": "The provided callback function (e.g., myCallback) will be executed for each full-screen monitor." } ``` ### Callback Definition #### XPLMReceiveMonitorBoundsGlobal_f ```c typedef void (* XPLMReceiveMonitorBoundsGlobal_f)( int inMonitorIndex, int inLeftBx, int inTopBx, int inRightBx, int inBottomBx, void * inRefcon); ``` ### Callback Parameters - **inMonitorIndex** (int) - The index of the monitor. - **inLeftBx** (int) - The left boundary of the monitor in boxels. - **inTopBx** (int) - The top boundary of the monitor in boxels. - **inRightBx** (int) - The right boundary of the monitor in boxels. - **inBottomBx** (int) - The bottom boundary of the monitor in boxels. - **inRefcon** (void *) - The reference constant passed to XPLMGetAllMonitorBoundsGlobal. ``` -------------------------------- ### Get Nth Hot Key (XPLMGetNthHotKey) Source: https://developer.x-plane.com/sdk/XPLMDisplay Retrieves the XPLMHotKeyID for a hot key at a specific index. This function is primarily used in conjunction with XPLMCountHotKeys to iterate over all registered hot keys. ```c XPLM_API XPLMHotKeyID XPLMGetNthHotKey( int inIndex); ``` -------------------------------- ### Manage Window Reference Constant (XPLMGetWindowRefCon, XPLMSetWindowRefCon) Source: https://developer.x-plane.com/sdk/XPLMDisplay These functions allow plugins to associate a unique reference constant (a void pointer) with an X-Plane window. XPLMGetWindowRefCon retrieves this constant, while XPLMSetWindowRefCon sets it. This is useful for passing custom data to window callback functions. ```c void *XPLMGetWindowRefCon(XPLMWindowID inWindowID); XPLM_API void XPLMSetWindowRefCon(XPLMWindowID inWindowID, void *inRefcon); ``` -------------------------------- ### Append Menu Item with Command (XPLM) Source: https://developer.x-plane.com/sdk/XPLMAppendMenuItemWithCommand Appends a menu item to an existing menu that, when selected, executes a specified XPLMCommandRef. This is useful for associating keyboard shortcuts with menu actions. The function returns an error code if the operation fails. Menu indices are local to the plugin. ```c XPLM_API int XPLMAppendMenuItemWithCommand( XPLMMenuID inMenu, const char * inItemName, XPLMCommandRef inCommandToExecute); ``` -------------------------------- ### End Command Execution - XPLMCommandEnd Source: https://developer.x-plane.com/sdk/XPLMUtilities Terminates the execution of a command that was previously started with XPLMCommandBegin. It is crucial not to call this for commands that were not initiated by the current plugin. ```c XPLM_API void XPLMCommandEnd( XPLMCommandRef inCommand); ``` -------------------------------- ### Create a New Command (XPLMCreateCommand) Source: https://developer.x-plane.com/sdk/XPLMUtilities XPLMCreateCommand creates a new command identified by a string name and an optional description. If a command with the same name already exists, its existing reference is returned. The description can be used in user interfaces like the joystick configuration screen. It returns a command reference. ```c XPLM_API XPLMCommandRef XPLMCreateCommand( const char * inName, const char * inDescription); ``` -------------------------------- ### XPLMSetDatavi Function Source: https://developer.x-plane.com/sdk/XPLMSetDatavi This function allows you to write integer values into an X-Plane dataref that is structured as an array. You can specify the starting offset and the number of values to write. ```APIDOC ## XPLMSetDatavi ### Description 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 past 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. ### Method `void` (This is a function call, not an HTTP request) ### Endpoint N/A (SDK Function) ### Parameters #### Function Parameters - **inDataRef** (XPLMDataRef) - The reference to the integer array dataref to modify. - **inValues** (int *) - A pointer to an array of integer values to write. - **inOffset** (int) - The starting index within the dataref array where writing should begin. - **inCount** (int) - The maximum number of integer values to write from `inValues`. ### Request Example ```c // Assuming you have a valid XPLMDataRef for an integer array dataref XPLMDataRef myIntArrayRef = XPLMFindDataRef("my.integer.array.dataref"); if (myIntArrayRef) { int valuesToWrite[] = {10, 20, 30, 40, 50}; int offset = 2; int count = 3; XPLMSetDatavi(myIntArrayRef, valuesToWrite, offset, count); // This will write {30, 40, 50} into the dataref starting at index 2. } ``` ### Response This function does not return a value (void). Success is indicated by the dataref being updated as expected. Error handling is typically managed by checking if the dataref reference is valid before calling the function and by understanding potential dataref provider behavior. ``` -------------------------------- ### Get FMOD Studio System Handle - C/C++ Source: https://developer.x-plane.com/sdk/XPLMGetFMODStudio Retrieves a handle to the FMOD Studio system, enabling operations like loading audio and accessing the underlying core system. This is crucial for advanced audio management within X-Plane. ```c XPLM_API FMOD_STUDIO_SYSTEM* XPLMGetFMODStudio(void); ``` -------------------------------- ### Get Parent Widget (C) Source: https://developer.x-plane.com/sdk/XPWidgets Returns the widget ID of the parent of a given widget. If the widget has no parent (e.g., it's a root widget), it returns 0. ```c WIDGET_API XPWidgetID XPGetParentWidget( XPWidgetID inWidget); ``` -------------------------------- ### XPLM Double Data Access Functions Source: https://developer.x-plane.com/sdk/XPLMDataAccess Defines function pointer types for getting and setting double-precision floating-point data. Useful for high-precision numerical data. ```c typedef double (* XPLMGetDatad_f)( void * inRefcon); typedef void (* XPLMSetDatad_f)( void * inRefcon, double inValue); ``` -------------------------------- ### Enable a Plugin - XPLMEnablePlugin (C) Source: https://developer.x-plane.com/sdk/XPLMPlugin Attempts to enable a specified plugin. It returns 1 if the plugin is successfully enabled or was already enabled. A return value of 0 indicates that the plugin failed to enable, possibly due to resource issues or errors within its XPluginEnable callback. ```c XPLM_API int XPLMEnablePlugin(XPLMPluginID inPluginID); ``` -------------------------------- ### XPLMGetDatavf Source: https://developer.x-plane.com/sdk/XPLMGetDatavf Reads a portion of a single-precision floating-point array dataref. This function can be used to get the size of the array or to read specific elements into an output buffer. ```APIDOC ## XPLMGetDatavf ### Description Reads a part of a single precision floating point 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. ### Method `XPLM_API` (Function Declaration) ### Parameters #### Arguments - **inDataRef** (XPLMDataRef) - A reference to the dataref to read from. - **outValues** (float *) - A pointer to a float array where the values will be stored. Can be NULL to get the array size. - **inOffset** (int) - The starting offset in the dataref array from which to read. - **inMax** (int) - The maximum number of values to read. ### Return Value - `int`: If `outValues` is NULL, returns the total size of the array. Otherwise, returns the number of values copied. ### Notes 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. ``` -------------------------------- ### XPLMAvionicsBezelCallback_f Prototype for Avionics Bezel Drawing Source: https://developer.x-plane.com/sdk/XPLMAvionicsBezelCallback_f This C callback prototype is used for drawing custom avionics bezels. It receives ambient light color (RGB) for tinting and a reference constant for custom data. The OpenGL context is set for 2D drawing in panel coordinates, but the OpenGL state is not guaranteed. ```c typedef void (* XPLMAvionicsBezelCallback_f)( float inAmbiantR, float inAmbiantG, float inAmbiantB, void * inRefcon); ``` -------------------------------- ### Show Widget (C) Source: https://developer.x-plane.com/sdk/XPWidgets Makes a widget visible. However, the widget will only be visible to the user if it is part of a rooted widget hierarchy and all its parent widgets are also visible. ```c WIDGET_API void XPShowWidget( XPWidgetID inWidget); ``` -------------------------------- ### Get Widget Geometry (XPGetWidgetGeometry) Source: https://developer.x-plane.com/sdk/XPWidgets Retrieves the bounding box coordinates (left, top, right, bottom) of a widget in global coordinates. NULL can be passed for parameters that are not of interest. ```c 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 */ /* This routine returns the bounding box of a widget in global coordinates. Pass NULL for any parameter you are not interested in. */ ```