I’m trying to create bindings to SimConnect using Dart FFI as an exercise to learn. I was able to create bindings on most functions, but I’m having problems actually getting the data coming from the sim.
On the docs, it says that I will receive a SIMCONNECT_RECV_SIMOBJECT_DATA struct after calling the SimConnect_RequestDataOnSimObject\Type function.
I’m really confused about how the data is converted into the actual data. Because if I just retrieve the dwData member, it is just an integer that looks something like this: 1256468312. Then, I see that dwData cast with a struct and that’s where the conversion happens.
Can somebody explain to me what exactly dwData is? On the docs, it says is an array, but is defined as DWORD? Is there another way of converting the data without casting it into a struct?
the dwData member constitutes a pointer to the data. The int just makes it universally usable. So 1256468312 in your example is the address of where you find your data. Thats why the dwData member has to be cast into a pointer of the type of the data definition that you used for the SimConnect_RequestDataOnSimObjectType() call.
To be more precise: it is not the ints value itself that matters, but the address to the int that is cast to the pointer that fits the definition of the request.
But to be honest: in the end I don’t care too much, how it is done, as long as it does what it is supposed to do. And it has been like that since the inception of SimConnect back in FSX days.