Some InputEvents don't work when sent via execute_calculator_code()

To reproduce:

  1. Spawn the Cessna CJ4 in MSFS2024 and get inside the cockpit
  2. Send 0 (>B:ELECTRICAL_SWITCH_BATTERY_MASTER_Set) using execute_calculator_code() in a WASM module*

Result: The main battery switch in the plane moves to the on position but none of the avionics light up
Expected result: The avionics light up

Triggering the same event via the developer mode behaviors dialog works fine. Triggering the event via its hash (6437187992459564835) and the SetInputEvent() API works fine as well. It’s only when it is sent via execute_calculator_code() that it doesn’t. None of the variants of the event (MASTER_BATTERY_ON, for example) work correctly via the execute API either.

In general, I’ve found nearly all input events work fine when sent via the execute API. This specific event, in addition to NAVCOM_AUDIO_COM1_TRANSMIT, seem to not work and I have no idea why.

* The easiest way to do this without writing code is to install MobiFlight and configure a Microsoft Flight Simulator input using the RPN mentioned in step 2.

From what I understand, B variables are only available in WASM gauge code, not standalone. I’ve never been able to do anything with B vars from a standalone WASM module, so I’m surprised to hear that any of them work at all.

Can you give me an example of a working one I can try with? It would be interesting to check. Is it only the _Set variants that work?

So far I’ve implemented the SimConnect Input Events functions, which does work fine for setting and reading, besides the awkwardness of the process.

As of the 2024 release they just magically started working. I’ve been able to call all of them including all of the variants just like I’ve always dreamed and they work great… Except this specific one.

No changes made at all to the WASM code that mobiflight installs. It just started working in 2024.

2 Likes

Wow… :exploding_head: I hadn’t tried since March or maybe earlier. Wonder what changed… nothing in release notes, right?

I maintain another “remote access” WASM module for calc. and vars access, so this is good news indeed (especially since I don’t need to change anything on that end :slight_smile: ).

Thanks,
-Max

Correct, nothing in the release notes. One of our users tried it in a fit of rage after 2024 came out and they were struggling to reverse engineer the underlying RPN. It worked, and our minds were blown.

I’ve successfully used input events as Bvars in RPN to map everything in the CJ4… except the ones mentioned above.

Weird… Just tried it and it worked. Value of 0 sets the switch up, to “ON”, 1 to the middle “OFF” and 2 to bottom “EMER”. I’m in the CJ4 cockpit, everything else is cold and dark. Sim v1.1.9.0

Before that I was trying to toggle exterior bits during the walkaround but none of those events seemed to work via execute_calculator_code() but did via SimConnect_SetInputEvent().

:person_shrugging:

EDIT: Oh… the switch moves but it doesn’t actually turn on the battery. Using the WT_CJ4_BATTERY_SWITCH_POS L var does the same thing. NVM…

Exactly what I see. The switch moves but it doesn’t actually turn on the battery.

This is fantastic news! I just tested it, and it works. I’m curious if there will be an official documentation update stating that this usage is supported, or if an official representative could confirm it. That way, I can migrate my old code to the 2024 version.