A standalone module. I will grab the aircraft sample and check in a few hrs. Here is the failing module:
#include <MSFS\MSFS_WindowsTypes.h>
#include <MSFS\MSFS_Events.h>
#include <MSFS\Types\MSFS_EventsEnum.h>
#include <SimConnect.h>
#include "Module.h"
HANDLE g_hSimConnect;
void EventHandler(FsEventId id, FsVarParamArray* params, void* userParams)
{
switch (id)
{
case KEY_TAXI_LIGHTS_ON:
SimConnect_FlightSave(g_hSimConnect, "sltest\n", NULL, NULL, 0);
break;
case KEY_TAXI_LIGHTS_OFF:
SimConnect_FlightLoad(g_hSimConnect, "sltest\n");
break;
default:
fprintf(stderr, "inputs event: %d\n", id);
break;
}
}
extern "C" MSFS_CALLBACK void module_init(void)
{
fsEventsRegisterKeyEventHandler(EventHandler, 0);
g_hSimConnect = 0;
HRESULT hr = SimConnect_Open(&g_hSimConnect, "Standalone Module", NULL, 0, 0, 0);
if (hr != S_OK)
{
fprintf(stderr, "Could not open SimConnect connection.\n");
return;
}
}
extern "C" MSFS_CALLBACK void module_deinit(void)
{
if (!g_hSimConnect)
return;
HRESULT hr = SimConnect_Close(g_hSimConnect);
if (hr != S_OK)
{
fprintf(stderr, "Could not close SimConnect connection.\n");
return;
}
fsEventsUnregisterKeyEventHandler(EventHandler, 0);
}
void CALLBACK MyDispatchProc(SIMCONNECT_RECV* pData, DWORD cbData, void* pContext) {};```