Does the Aircraft Simulation Variable CABIN SEATBELTS ALERT SWITCH work in the A320Neo default aircraft. I use
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_6, “CABIN SEATBELTS ALERT SWITCH”, “Bool”) to setup, and, in the event received code,
hr = SimConnect_SetDataOnSimObject(hSimConnect, DEFINITION_6, SIMCONNECT_OBJECT_ID_USER, 0, 0, sizeof(sb), &sb);
where sb is defined as
struct structseatbelt
bool seatbelt;

structseatbelt sb;
.There is also
hr = SimConnect_MapInputEventToClientEvent(hSimConnect, INPUT_6, “i”, EVENT_6);
and related pieces of code.
Now, after starting the SimConnect based exe, getting Sim connection, then launching a flight, when I press “i” on KB, nothing happens, though my printfs confirm the event has been received, the SimConnectSetData(…) has been executed, hr returned has value “0”, the Seatbelt lights switch does not toggle.
A small issue is also the definition of the variable
CABIN SEATBELTS ALERT SWITCH True if the Seatbelts switch is on. Bool TYPE_BOOL
inconsistent with types enumeration!!
What is the real status of this variable, anything I have to change in the usage

Thank you

Anantha Krishnan

This is a common pitfall: the “Bool” here is to be understood as “unit” (as in “feet”, “kilogram”, “radians”, …) rather than as “type” (as in “float”, “int”, “double”, …).

In fact, the default type of every data defintion will be FLOAT64 (-> SIMCONNECT_DATATYPE_FLOAT64 - refer again to the exact function signature: SimConnect_AddToDataDefinition), and as you do not specify the type the default here is really 64bit, or in other words: you are trying to “squeeze” 64 bit into a 1bit “boolean” (.Net, C++) type here :wink: That does not work.

So you need to specify the type to be INT32 (which is really the “smallest amount of bits” you can request/send):


And define your struct member accordingly: choose a type with exactly 32bit of size (as I use C++ with the Qt toolkit that would be the type “qint32” for me, which is guaranteed to be 32bit on every platform)

Also, if you’re using structs with multiple members don’t forget to “pack” the struct (so no alignment “with gaps”, optimised for the corresponding CPU is done). In C++ that would e.g. be the pragma (compiler instruction/hint):

#pragma pack(push, 1)
struct MyStruct { … };
#pragma pack(pop)

In C# there is an equivalent compiler instruction (see the SDK documentation, specifically the chapter about “Managed Code”).

Hi Steeler,
Thanks for the response.
I modified the code as suggested, but not having any luck in getting the Seatbelt Switch to change when I press “i” on KB. System-A320Neo default in MSFS on Windows 10 latest on an ASUS TUF Gaming A15 laptop.

The code is in SetData.cpp and I am building the executable on a MSVS2019.

Sorry, I am pasting the code here, seems I cant attach the .cpp file.

// Copyright (c) Asobo Studio, All rights reserved.
// SimConnect Set Data Sample
// Description:
// When z is pressed, the user aircraft is moved
//MeMe23May2021-when “i” is pressed! z is already AP toggle
// to a new location

#include <windows.h>
#include <tchar.h>
#include <stdio.h>
#include <strsafe.h>
//MeMe25May2021-do we need below for bool
#include <stdbool.h>

#include “SimConnect.h”

int quit = 0;
HANDLE hSimConnect = NULL;

static enum GROUP_ID {

static enum INPUT_ID {

static enum EVENT_ID{

static enum DATA_DEFINE_ID {

static enum DATA_REQUEST_ID {

//MeMe24May2021-added struct
//MeMe1Jun2021-changed per Steeler Forum from bool seatbelt;Try int
struct structseatbelt
int seatbelt;

structseatbelt sb;

void CALLBACK MyDispatchProcSD(SIMCONNECT_RECV* pData, DWORD cbData, void *pContext)

    //MeMe24May2021-added from ThrottleControl sample!
            case REQUEST_6:
				// Read and set the initial seatbelt value
				structseatbelt *pS = (structseatbelt*)&pObjData->dwData;

				sb.seatbelt	= pS->seatbelt;
				printf("\nREQUEST_USERID received, seatbelt = %d", pS->seatbelt);

				// Now turn the input events on
			    hr = SimConnect_SetInputGroupState(hSimConnect, INPUT_6, SIMCONNECT_STATE_ON);


                //MeMe24May2021-added from throttlecontrol sample!!
                hr = SimConnect_RequestDataOnSimObject(hSimConnect, REQUEST_6, DEFINITION_6, SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_PERIOD_ONCE);

            case EVENT_6:
                /*MeMe23May2021-    SIMCONNECT_DATA_INITPOSITION Init;
                    Init.Altitude   = 5000.0;
                    Init.Latitude   = 47.64210;
                    Init.Longitude  = -122.13010;
                    Init.Pitch      =  0.0;
                    Init.Bank       = -1.0;
                    Init.Heading    = 180.0;
                    Init.OnGround   = 0;
                    Init.Airspeed	= 60;
                    hr = SimConnect_SetDataOnSimObject(hSimConnect, DEFINITION_6, SIMCONNECT_OBJECT_ID_USER, 0, 0, sizeof(Init), &Init );*/
					if (0 == sb.seatbelt) sb.seatbelt = 1;
						else sb.seatbelt = 0;
                    printf("\nValue seatbelt:%d\n", sb.seatbelt);
				    hr = SimConnect_SetDataOnSimObject(hSimConnect, DEFINITION_6, SIMCONNECT_OBJECT_ID_USER, NULL, 0, sizeof(sb), &sb);
                    printf("\nhr after EVENT_6 received and data sent=%d",hr);
                    printf("\nEVENT_6 received and data sent");
                    //MeMe1Jun2021-not needed?
                    //hr = SimConnect_SetInputGroupState(hSimConnect, INPUT_6, SIMCONNECT_STATE_ON);


        quit = 1;

        //MeMe23May2021-added \n at end!!?? printf("\nReceived:%d",pData->dwID);
        printf("\nReceived:%d\n", pData->dwID);


void testDataSet()
//MeMe24May2021-redundant sb.seatbelt = 1;

if (SUCCEEDED(SimConnect_Open(&hSimConnect, "Set Data", NULL, 0, 0, 0)))
    //MeMe23May2021-added \n at end!!?? printf("\nConnected to Flight Simulator!");   
    printf("\nConnected to Flight Simulator!\n");
    hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_6, "CABIN SEATBELTS ALERT SWITCH", "Bool", SIMCONNECT_DATATYPE_INT32);
    // Request a simulation start event
    hr = SimConnect_SubscribeToSystemEvent(hSimConnect, EVENT_SIM_START, "SimStart");

    // Create a custom event
    hr = SimConnect_MapClientEventToSimEvent(hSimConnect, EVENT_6, "My.i");

    // Link the custom event to some keyboard keys, and turn the input event off
    hr = SimConnect_MapInputEventToClientEvent(hSimConnect, INPUT_6, "i", EVENT_6);
    // Sign up for notifications for EVENT_6
    hr = SimConnect_AddClientEventToNotificationGroup(hSimConnect, GROUP_6, EVENT_6);
    //MeMe24May2021-added from throttle sample
    printf("\nPlease launch a flight");

    while( 0 == quit )
        SimConnect_CallDispatch(hSimConnect, MyDispatchProcSD, NULL);

    hr = SimConnect_Close(hSimConnect);


int __cdecl _tmain(int argc, _TCHAR* argv[])


return 0;


Can I trouble you to give me one more time a tip what is wrong, thenks a ton.

Anantha Krishnan

Hint: the forum software here actually allows you to wrap code into a corresponding “code” tag (with angular brackets around it), as in:

int somFunction(int someArgument) {
  return doSomething(someArgument);

So while I haven’t read all your code - it’s a bit too much and without indentation not easily readable - I would try a very simple application with nothing more than a main() function which:

  • Create a SimConnect connection
  • Define and register the required data structures
  • Set the “cabin seats” variable (possibly even based on some command line argument value: on or off)
  • Disconnect from SimConnect (which is always a nice thing to do when you know that you’re done ;))
  • Terminate (return from main)

Or in other words: take the whole “event handling” out of the equation for now - simplify your code to the bare minimum, in order to simply (and only) set the desired value.

And I would also recommend using the provided “Simvar Watcher” example application which comes with the SDK: it also allows you to set (and get) simulation variables! So make sure that the aircraft in question actually responds as expected to setting the “CABIN SEATBELT” variable. Otherwise you might be hunting ghosts…

The SimVarWatch tip was really useful.

As far as I can make out, the variable seems not to be actually implemented in the SimConnect module.

I can Try Set Value in SimVarWatcher for say Light Beacon/Light Landing,
But my CABIN ALERT SEATBELT… when I try to set using Bool units,value 0 or 1, it throws DATA_ERROR.

Still not clear what other values I can use, or is this still a TODO.

Thanks. Shall go to other things to see for now!

PJAnantha Krishnan

Aha? Then you were indeed “hunting a ghost” :wink: “DATA_ERROR” indicates that the corresponding simulation variable is not writeable (or it is expecting a STRING value instead of a FLOAT64 etc. - but I am pretty sure that this is not the case for CABIN ALERT SEATBELT).

Btw I just checked the API documentation:

SDK Documentation (

Assuming that you are really referring to CABIN SEATBELTS ALERT SWITCH (according to your code snippet above you do) that variable actually should be writeable. So why you are getting a “DATA ERROR” is beyond me (even if the actual aircraft would “ignore” that variable you should not get such an error).

Yes, no reason why CABIN SEATBELTS … var should give DATA_ERROR?
I have raised a Bug in Support, hope solution happens.
Thanks for the help.