Events API not working

Version: 1.1.9.0

Frequency: Consistently

Severity: High

Context: WASM Module

**Bug description: Calling Events API gives ERR_ILLEGAL_C_IMPORT in the developer console output *

WASM: ERR_VALIDATION_ERROR (-4095 / fffff001)
WASM: Error ERR_ILLEGAL_C_IMPORT: env:fsEventsRegisterKeyEventHandler is not a whitelisted C import, nor a valid webassembly import.
WASM: Error ERR_ILLEGAL_C_IMPORT: env:fsEventsUnregisterKeyEventHandler is not a whitelisted C import, nor a valid webassembly import.

**Repro steps:Try to use the Events API in a WASM module
@EPellissier

@StevenPearce833,

I have asked my team to look into this, I’ll get back to you on this asap.

Best regards,

Eric / Asobo

1 Like

@StevenPearce833

We couldn’t reproduce the bug on our end using 1.1.9 and the SDK Sample “WasmAircraft” (variation “Vars and Events”) which uses those functions.
Can you check if this sample works fine on your end?

Best regards,

Eric / Asobo

@StevenPearce833

Could you please specify if you are working on a gauge module, a standalone module or an airport module?

Best regards,

Eric / Asobo

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) {};```

@StevenPearce833

The issue has been identified and fixed on our end - we will let you know as soon as it is available in a released build.

Best regards,

Eric / Asobo

1 Like