plane icon Welcome to Microsoft Flight Simulator’s SDK Q&A Platform!

You have questions regarding the SDK? DevMode Tools? SimConnect? You would like to submit an idea for future improvements, seek help or exchange knowledge? You’re in the right place.

Please take a moment to read the platform’s guidelines before you get started!

question

MobiFlight avatar image
MobiFlight asked FlyingRaccoon answered

SimConnect_AddToClientDataDefinition - incorrect example code

Hi team,

when I implemented the MobiFlight WASM module I saw that the example code for this particular method is not correct.

Link:

https://docs.flightsimulator.com/html/index.htm#t=Programming_Tools%2FSimConnect%2FAPI_Reference%2FEvents_And_Data%2FSimConnect_AddToClientDataDefinition.htm

Example code:

static enum EVENT_ID {
    EVENT_MY_EVENT
    EVENT_DME
    };
hr = SimConnect_MapClientEventToSimEvent(hSimConnect, EVENT_MY_EVENT, "Custom.Event");
SimConnect_TransmitClientEvent(hSimConnect, 0, EVENT_MY_EVENT, 0, SIMCONNECT_GROUP_PRIORITY_HIGHEST, SIMCONNECT_EVENT_FLAG_GROUPID_IS_PRIORITY);
      
hr = SimConnect_MapClientEventToSimEvent(hSimConnect, EVENT_DME, "DME_SELECT");
SimConnect_TransmitClientEvent(hSimConnect, 0, EVENT_DME, 2, SIMCONNECT_GROUP_PRIORITY_DEFAULT, SIMCONNECT_EVENT_FLAG_GROUPID_IS_PRIORITY); 

The code clearly doesn't use the documented method

HRESULT SimConnect_AddToClientDataDefinition(
    HANDLE  hSimConnect,
    SIMCONNECT_CLIENT_DATA_DEFINITION_ID  DefineID,
    DWORD  dwOffset,
    DWORD  dwSizeOrType,
    float  fEpsilon = 0,
    DWORD  DatumID = SIMCONNECT_UNUSED
    );

As a general feedback, the entire group of methods related to Events and Custom Data Definitions is really hard to understand and it took me forever to figure it out.

simconnectdocumentation
10 |10000 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 4.8 MiB each and 23.8 MiB total.

1 Answer

· Write an Answer
FlyingRaccoon avatar image
FlyingRaccoon answered

Hello,

Obviously a mistake. Our tech writer will fix that, thanks for reporting it.

The SDK is providing very simple examples on how to use events and read/write custom data.

We are open to suggestions on how to improve it.
What piece of information do you think is missing to make it easier to understand?

Regards,
Sylvain

10 |10000 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 4.8 MiB each and 23.8 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 5 attachments (including images) can be used with a maximum of 4.8 MiB each and 23.8 MiB total.