MSFS2020 Using the Custom Input Code Box - MobiFlight/MobiFlight-Connector GitHub Wiki

Custom Input Code Box

Beginning with Mobiflight version 8.2.0.7 (Beta), a new Action Type was introduced in the Inputs Config Wizard: "Custom Input". This feature provides a code box where the user is free to define whatever code he wishes to run in the simulator. This is a very powerful tool that allows us to basically specify any valid RPN code for input execution, in combination with config references and preconditions.

UPDATE: With the integration of Hubhop and Mobiflight (version 9.2 or newer), the Custom Input box has completely replaced the old way in which MSFS2020 events were handled. Mobiflight Connector no longer uses the events.txt, or msfs2020_eventids.cip files to organize the event names and related code. The selected event code is now placed in the Custom Input box, where the user is free to modify it, if he needs to.

The events are updated directly from Hubhop (in Extras - MSFS2020 - Download latest events) and follow the same organization: Vendor, Airplane, System. They are presented in easy to navigate drop down live menus for each category and there is also a text filter to customize the event search as needed.

image

In this input config example, an analog potentiometer is used as input device. Please note the use of the "@" as a placeholder for the pot reading. The analog position of the pot is read and adjusted to a range of 0-16383, and then sent to a K: event to set the position of the airplane spoilers. The same value pot reading is converted to percent and stored in a user L: variable that can then be displayed as an output.

Notes on the feature

  • The input event trigger can be a button, an encoder, or the new analog type (pots)
  • Instead of calling an event name in events.txt, the code in the box is sent directly for execution
  • No event name is needed
  • The code size limit was increased to a maximum of 1024 characters as of MF 9.0.0.3
  • The code can have line feeds to improve readability.
  • Config references can be included using their respective placeholders
  • Opens the possibility to send parameters to SET type events, e.g. @ (>K:SPOILERS_SET)
  • All the code entered in the Custom Input box is stored in the Mobiflight mcc file
  • Mobiflight will replace the placeholders @, #, ! with their respective config reference values, but keep in mind the code itself is sent to be executed by the MSFS2020 simulator.
  • All code needs to comply with RPN syntax rules

Limitations

You cannot use "ncalc" type expression syntax in the code field. This won't work

$+1 (>K:HEADING_BUG_SET)

But you can use RPN to get around this

$ 1 + (>K:HEADING_BUG_SET)

Benefits of using the Custom Input Code Box

The implications can be significant for users that may want to test new events or code.

  • Writing and testing code in events.user.txt can still be done and works as before, but it is not necessary anymore.
  • The code in Custom Input is managed by Mobiflight and sent for execution in MSFS2020 in real time, whenever the input device is used.
  • Neither the simulator, nor the MF WASM module need to store the code prior to it being executed.
  • This feature can be a time saver, as testing of new code with the Custom Input box DOES NOT require you to restart the simulator.

Mobiflight gets its events from Hubhop, an online database of all MSFS2020 events compiled by the MobiFlight community can be found at the HubHop website.