This is great and the first good outline of how to set up a SimConnect ClientData within a WASM that I have seen. I am also trying to send LVar values to my SimConnect client. The SimConnect_RequestClientData setup I think I can manage as long as I have the WASM set up correctly. I am very confused on the use of the SimConnect_CallDispatch and the FSAPI EventHandler and the role they play in a WASM module in regards to ClientData. I was able to bind keys to any LVar I could find using one of the below links but that communication only went one way for me (SimConnect Client to WASM). I need, for example, the FMC Zero key to send an event to my SimConnect client when I click it in the Sim.
I started with this post:
Demo: LVAR write access for any aircraft control
and using PMGD, P3D samples and this post:
Client Data area problems
managed to slap this together:
HANDLE hSimConnect;
HRESULT hr;
FLOAT64 testData = 321;
static enum DATA_DEFINE_ID {
DEFINITION_1 = 1,
};
extern "C" MSFS_CALLBACK void module_init(void)
{
hSimConnect = 0;
hr = SimConnect_Open(&hSimConnect, "Standalone Module", nullptr, 0, 0, 0);
if (hr == S_OK)
{
cout << "LVar Module Iniatialized" << endl;
hr = SimConnect_MapClientDataNameToID(hSimConnect, "(>H:AS01B_FMC_1_BTN_0)", 1);
hr = SimConnect_AddToClientDataDefinition(hSimConnect, DEFINITION_1, SIMCONNECT_CLIENTDATAOFFSET_AUTO, SIMCONNECT_CLIENTDATATYPE_FLOAT64, 0, 0);
hr = SimConnect_CreateClientData(hSimConnect, 1, 8, SIMCONNECT_CLIENT_DATA_REQUEST_FLAG_CHANGED);
hr = SimConnect_SetClientData(hSimConnect, 1, DEFINITION_1, 0, 0, sizeof(FLOAT64), &testData);
}
I think I understand how to structure it on the SimConnect_RequestClientData side of things if my WASM was correct. Any suggestions or links to examples I don’t know about would be greatly appreciated. Thanks!