SkillAgentSearch skills...

WASimCommander

WASM Module and developer API for remote access to the Microsoft Flight Simulator 2020 & 2024 "Gauge API" functions.

Install / Use

/learn @mpaperno/WASimCommander

README

GitHub release (latest by date including pre-releases) GPLv3 License LGPGv3 License API Documentation Discord

WASimCommander

<div align="center"> <img src="https://github.com/mpaperno/WASimCommander/wiki/images/logo/WASim-Logo_640x160.png" style="width: auto;" /> </div>

Remote access to the Microsoft Flight Simulator 2020 & 2024 "Gauge API."

A WASM module-based Server and a full Client API combination.

This project is geared towards other MSFS developers/coders who need a convenient way to remotely access parts of the Simulator which are normally inaccessible via SimConnect, such as some variable types and 'H' events, and running RPN "calculator code" directly on the sim.

The Client API can be utilized natively from C++, or via .NET managed assembly from C#, Python, or other languages.

The system also provides direct access to functions from within the Simulator environment and in many cases could be used as a simpler alternative to SimConnect for basic functionality like reading/setting Simulation Variables or triggering Key Events. SimConnect is still used as the network "transport" layer, but this usage is abstracted into, essentially, an implementation detail.

Motivation

One of the motivations for this project was seeing multiple MSFS tool authors and casual hackers creating their own WASM modules and protocols just to support their own product or need. There is nothing wrong with this, of course, but for the Sim user it can be a disadvantage on several levels. They may end up running multiple versions of modules which all do essentially the same thing, and it may be confusing which WASM module they need to support which tool, just to name two obvious issues. For the developer, programming the WASM modules comes with its own quirks, too, not to mention the time involved. And regardless of the supposed isolated environment a WASM module is supposed to run in, it's still very easy to take down the whole Simulator with some errant code... ;-)

Since MS/Asobo have been, ahem, "slow" to add further remote access features to SimConnect (or come up with some other method), this project is an attempt at establishing a "standard" or "common" way of doing so. At the least I hope it motivates some kind of standards adoption.

On a more practical note, I am using it with the MSFS Touch Portal Plugin which I'm currently maintaining.


Features

Remote Capabilities

  • Execute Calculator Code:
    • With or without a returned result; Result returned as numeric and string types.
    • Formatted results from format_calculator_string() using RPN String Formatting
  • Get Variable: Return value result from any type of variable accessible to a standalone WASM module (basically everything but Gauge and Instrument types, but also including Token vars).
    • With optional Unit specifier for variable types which support it.
  • Set Variable: Set the value of any settable variable type, with optional Unit specifier for variable types which support it.
  • Create Variable: Create (and get/set) a new Local variable if it doesn't already exist.
  • List Local Variables: Get a list of all available 'L' variables with their names and current IDs.
  • Lookup: Return a numeric ID for a SimVar/Local/Token variable, Unit, or Key Event name.
  • Subscribe to Calculator Code and Get Variable results:
    • Get "push" notifications whenever result values change; Change monitoring can be configured at any rate down to the millisecond (~25ms minimum). Can also be configured to use the "delta epsilon" feature of SimConnect (to ignore insignificant changes in value) or, conversely, to always send updates even when values do not change.
    • Optionally perform manual ("polled") updates of subscriptions at any interval of your choice.
    • Any calculator code saved in subscriptions is pre-compiled to a more efficient byte code representation before being passed to the respective calculator functions. This significantly improves performance for recurring calculations.
  • Register Named Events:
    • Save recurring "set events," like activating controls using calculator code, for more efficient and simpler re-use. Saved calculator code is pre-compiled to a more efficient byte code representation before being passed to the calculator function. This significantly improves performance for recurring events.
    • Registered events can be executed "natively" via WASim API by simply sending a short command with the saved event ID.
    • Saved events can also be named and executed via standard SimConnect commands SimConnect_MapClientEventToSimEvent(id, "event_name") and SimConnect_TransmitClientEvent(id).
    • Event names can be completely custom (including a . (period) as per SimConnect convention), or derive from the connected Client's name (to ensure uniqueness).
  • Send Simulator "Key Events" directly by ID or name (instead of going through the SimConnect mapping process or executing calculator code). Much more efficient than the other methods.
    • New in v1.1.0: Send Key Events with up to 5 values (like the new SimConnect_TransmitClientEvent_EX1()).
    • New in v1.3.0: Send Custom Key Events (the ones with a "." in the name that are defined by particular models) by name or ID with up to 5 values.
  • Remote Logging: Log messages (errors, warnings, debug, etc) can optionally be sent to the Client, with specific minimum level (eg. only warnings and errors).
  • Ping the Server to check that the WASM module is installed and running before trying to connect or use its features.

Core Components

  • WASM module-based Server supports multiple simultaneous, independent client connections.
  • Full-featured Client implementation available as a C++ library and a C#/.NET assembly.
  • Well-defined message API for communication between Server module and any client implementation.
  • Uses standard SimConnect messages for the base network "transport" layer.
  • All data allocations are on client side, so SimConnect limits in WASM module are bypassed (can in theory support unlimited clients).
  • No wasted data allocations, each data/variable subscription is stored independently avoiding complications with offsets or data overflows.
  • Minimum possible impact on MSFS in terms of memory and CPU usage; practically zero effect for Sim user when no clients are connected (Server is idle).
  • Server periodically checks that a client is still connected by sending "heartbeat" ping requests and enforcing a timeout if no response is received.
  • Extensive logging at configurable levels (debug/info/warning/etc) to multiple destinations (file/console/remote) for both Server and Client.
    • Uses an efficient lazy logging implementation which doesn't evaluate any arguments if the log message will be discarded anyway (eg. a DEBUG level message when minimum logging level is INFO).
    • Logging levels can be set at startup via config files and changed at runtime for each facility (including remotely on the server).
  • Includes a SimConnect request/exception tracking feature for detailed diagnostics.
  • Extensive documentation for core API and all Client library features.
  • Efficiency and runtime safety are core requirements.

Desktop GUI

  • Includes a full-featured desktop application which demonstrates/tests all available features of the API.
  • Fully usable as a standalone application which saves preferences, imports/exports lists of data subscriptions/registered events, and other friendly features.
  • Very useful for "exploring" the simulator in general, like checking variable values, testing effects of key events and RPN calculator code.
  • Can be used with the MSFS/SimConnect Touch Portal Plugin for import/export of custom variable request definitions.
<p> &nbsp; </p> <div align="center"> <a href="https://github.com/mpaperno/WASimCommander/wiki/images/gui/wasimui-dark-new-v1005.png"><img src="https://github.com/mpaperno/WASimCommander/wiki/images/gui/wasimui-dark-new-v1005.png" style="width: 65%;" /></a> </div> <p> &nbsp; </p>

Downloads and Updates

Over in the Releases there are 3 packages provided. (The actual file names have version numbers appended.)

  • WASimCommander_SDK - All header files, pre-built static and dynamic libs, packaged WASM module, pre-build GUI, reference documentation, and other tools/examples.
  • WASimModule - Just the WASM module component, ready to be dropped into a MSFS Community folder.
  • WASimUI - Just the GUI application, which is very handy in combination with the WASM module for exploring the system.

Watch -> Custom -> Releases this repo (button at top) or subscribe to the ATOM feed for release notifications.

Update announcements are also posted on my Discord server's WASimCommander release announcement channel.

The SDK and updates are published on Flightsim.to where one could "s

View on GitHub
GitHub Stars62
CategoryDevelopment
Updated20d ago
Forks13

Languages

C++

Security Score

85/100

Audited on Mar 10, 2026

No findings