Advanced Solutions for Flight Simulation
Sending Events to Mindstar Avionics |
||||
Looking for receiving events instead? Click Here. | ||||
Overview In order for external hardware to control Mindstar avionics, all our products are capable of receiving custom events sent through SimConnect, FSUIPC, or even the keyboard. This event mechanism allows hardware knobs and buttons to notify the Mindstar software that a particular hardware item has been pressed or rotated. Our software can then act on that event accordingly. This page will explain the C++ code necessary for you to send these events to our software through SimConnect. For this example, we will use the Mindstar G1000 gauge that works in FSX, FSX:Steam, and Prepar3D versions 1-3. (Version 4 compatability is coming in mid-2020). Details about the event mechanism are explained on our page about the G1000.INI. There are many controls on the G1000 that can be maniuplated in this way, but for this example, we will use the DIRECT-TO and the CLEAR buttons on the G1000 PFD. Buttons used in this example Relationship to G1000.INI The events numbers you send to the Mindstar G1000 are determined by lines that appear in the [KEYBOARD] section of our G1000.INI file. That section lists all the available things the Mindstar G1000 can be told to do. |
||||
|
||||
Let's look at a highly simplified subsection of a G1000.INI below. It is you, or your end user, who defines what hex event numbers are listed in this file. If a hex number is entered after the '=' sign on any of these lines, then the Mindstar G1000 will listen for that event number to be broadcast by your program through SimConnect. If Mindstar software receives any of these events, it will act on that particular item by simulating the press of a knob or button accordingly. The events are just hex numbers, as shown in red below: [KEYBOARD] PFD_DIRECT_TO=0x11000 PFD_CLR=0x11005 C++ Code Example and Explanations To send any of these events via SimConnect, you must write a C++ program that knows how to broadcast them. This example uses only 2 of the numerous SimConnect function calls to accomplish this:
SimConnect_MapClientEventToSimEvent
Your Event Enumeration You start by coding an enumeration in your C++ program with entries that represent each of the individual events you want to send to SimConnect. If you send events to other vendors' software in addition to Mindstar, you must incorporate all the events ID's into this single enumeration.
static enum MY_SIMCONNECT_EVENT_IDS {
Connecting Your Enumeration to the Hex Event Numbers - Event Mapping SimConnect does not let you directly transmit the hex event numbers. Instead, SimConnect makes you send one of your own enumeration IDs that have been previously matched up with one of the actual hex event numbers. This matching, where you create a correllation between your enumeration items and the actual hex numbers is called "mapping" a client event to a sim event. Each of your enumeration items are a client
event The correllation ("mapping") between each hex event number and its corresponding item in your enumeration is accomplished during program initialization with a single function call for each event, as shown below:
Be very careful to format the hex event number into the string exactly as shown. The string must contain a single pound sign # (or hashtag, depending on your age), followed by 0x and the 5 hex digits. Don't add any more characters to that string or else SimConnect will not interpret it as a hex number.
Firing (Transmitting) the Events When you are ready to tell the G1000 that one of these buttons has been pushed, you do this by telling SimConnect to fire the event. But you do this by referencing your enumeration item. The code below will fire the event for the PFD's Direct-To button, assuming the event number was specified in the G1000.INI, and mapped to your enumeration when your program initialized itself.
SIMCONNECT_OBJECT_ID objectID = SIMCONNECT_OBJECT_ID_USER;
// direct the event to the user-aircraft
Additional References The SimConnect SDK is well-documented online on the Microsoft and Lockheed-Martin websites, or in the Help file delivered with the FSX or Prepar3D SDKs. Our gauges are currently being modified to support Prepar3D V4, but until those modifications are complete, you must use either FSX, or Prepar3D versions 1 thru 3. The SimConnect SDK functions used in these examples are practically the same in all those versions of the sim. Here are some useful links to the Lockheed-Martin website that show more information about the functions used in our examples on this page.
General SimConnect SDK Overview |