Monday, April 1, 2024

Learning to use SimConnect: Part Three - System Events

In my first post about SimConnect, I showed how to create a simple C# console app that connected to the SimConnect server running within Microsoft Flight Simulator 2020, using the managed SimConnect library. In the second post, I showed how to receive messages from the simulator using events defined by the SimConnect object, namely OnRecvOpen and OnRecvQuit.

In this post, we'll get into another way of getting information from the simulator, system events. In later posts, I'll hopefully be able to dive into two-way communication, using client events and simulator variables.

Friday, March 1, 2024

Learning to use SimConnect: Part Two - SimConnect Messages

 In my first post about SimConnect, I showed how to create a simple C# console app that connected to the SimConnect server running within Microsoft Flight Simulator 2020, using the managed SimConnect library. Now let's talk about how to actually interact with the simulator in a (somewhat) useful fashion.

I have a GitHub repository with all the code from this series in it, tagged at each stage. If you want to start out with the code as it was at the end of the first post, use the tag "03-add-a-pause".

SimConnect client/server communication is primarily through a set of defined data structures called messages. Clients receive these messages periodically from the server and either ignore the message, or take action, based on the kind of message received. In this model, the simulation engine itself is a client of the SimConnect server, so in order to control the simulation, we send messages from our client to the server, which the simulation engine then receives as a client. To start with, let's look at how we can receive messages from SimConnect.

Saturday, February 17, 2024

Learning to use SimConnect

Over the past year or so, I've really gotten into playing Microsoft Flight Simulator 2020. I'm an MS Flight Sim fan from way back; I still have version 4 - on a single floppy! - from 1991 out in my garage. I've been a plane nut even longer than that, ever since my dad got his private certificate back in the 70s. I hadn't used MSFS since the 98 version, but I got a small bonus at work and decided to give it a try again. I've since spent probably too much money buying a bunch of the Logitech flight sim controls to go with it. 

More recently, I've been working with an Arduino kit to see about making my own controls - the Logitech multi-panel's trim control is not that great, so I'm trying to see if I can come up with something better. In order to do that, I need to use the SimConnect SDK to communicate with MSFS 2020. I haven't gotten very far with it, but I'm going to share some of the stuff that I have learned so far, since one of the obstacles has been having to piece together how to do things from the documentation, plus various forum posts I've found through Google. Maybe having all this stuff in one place will be helpful to someone else.