SimConnect + WASM combined project using VS2019

Hello @TFEV1909,

@Dragonlaird mentioned this also in one of his posts.

That is also what I have been doing several times in my code (you find my source code on GitHub). Below I show some extract of the code.

First I create a few empty enums to be used for type conversion (I could have done it with one single enum, but I think that is in favor of the readability of the code to use different ones). And then I use this to typecast a variable.

// file: SimConnectHUB.cs

// Some enums for type conversions
private enum SIMCONNECT_DEFINITION_ID { }
private enum SIMCONNECT_REQUEST_ID { }
private enum EVENT_ID { }

...

// usage later somewhere in the code

_oSimConnect.RequestDataOnSimObject(
    (SIMCONNECT_REQUEST_ID)vInList.uRequestID,
    (SIMCONNECT_DEFINITION_ID)vInList.uDefineID,
    0,
    SIMCONNECT_PERIOD.NEVER,
    SIMCONNECT_DATA_REQUEST_FLAG.DEFAULT,
    0, 0, 0);
_oSimConnect.ClearDataDefinition((SIMCONNECT_DEFINITION_ID)vInList.uDefineID);

...

I’m not the expert on Events (yet :slight_smile:), but I guess you want to use the below function:

HRESULT SimConnect_MapClientEventToSimEvent(
    HANDLE  hSimConnect,
    SIMCONNECT_CLIENT_EVENT_ID  EventID,
    const char*  EventName
    );

If we look at the signature in C#:

public void MapClientEventToSimEvent(Enum EventID, string EventName);

Below is an example of how you could use this.

// you need some variable
UInt16 uDefineID;

// at runtime you can define the value
uDefineID = [next available DefineID, or whatever way to define a value...]

// and somewhere in your code you will "link" that DefineID with the Event - here we use the typecasting
_oSimConnect.MapClientEventToSimEvent((SIMCONNECT_DEFINITION_ID)uDefineID, "AXIS_THROTTLE1_SET");

I hope that this is the answer you needed?

1 Like