I have the SimConnect C++ project up end running, seams to work since SimConnect_Open() response is correct.
I want to control my PMDG 737 such as gear and flaps from my application. Is this possible, what is the basic way ?.. The samples does not give me good hints since purposes typical get notifications from P3D, I only want to send commands such as GEAR_UP to P3D.
Can I simply call a SimConnect function whenever I want, is it SimConnect_SetDataOnSimObject() ?
Or must I create my void CALLBACK MyDispatchProcSD(SIMCONNECT_RECV* pData, DWORD cbData, void *pContext) ?.. If so, can I make it regular called so I can send my airplane control-command-events such as GEAR_UP at any time.
The reason to control from my application, is I use analog lever to control the flaps, and each button has a 2:nd function etc handled by my application. I read my controls via Windows API.
A lot of thank's if I can solve this / Lennart Vedin
SimConnect send control-requests (events) to P3D airplane.
Re: SimConnect send control-requests (events) to P3D airplane.
Additional regarding my research:
I did look the sample ThrottleControl.cpp
It looks like it aim to control the throttle, but i do not understand how the function call shall really work.
struct structThrottleControl
{
double throttlePercent;
};
structThrottleControl tc;
hr = SimConnect_SetDataOnSimObject(hSimConnect, DEFINITION_THROTTLE, SIMCONNECT_OBJECT_ID_USER, 0, 0, sizeof(tc), &tc);
since DEFINITION_THROTTLE and REQUEST_THROTTLE are equal to zero (as the definition, and as my debug), there is nothing I see in the entire code that tell P3D that this is a throttle request.
I did look the sample ThrottleControl.cpp
It looks like it aim to control the throttle, but i do not understand how the function call shall really work.
struct structThrottleControl
{
double throttlePercent;
};
structThrottleControl tc;
hr = SimConnect_SetDataOnSimObject(hSimConnect, DEFINITION_THROTTLE, SIMCONNECT_OBJECT_ID_USER, 0, 0, sizeof(tc), &tc);
since DEFINITION_THROTTLE and REQUEST_THROTTLE are equal to zero (as the definition, and as my debug), there is nothing I see in the entire code that tell P3D that this is a throttle request.
Re: SimConnect send control-requests (events) to P3D airplane.
Hmm ! I suppose I shall use Simulation Variable as Text such as text-string: "GENERAL ENG THROTTLE LEVER POSITION:1".
I will try this for "FLAPS HANDLE INDEX" and "GEAR HANDLE POSITION"....
I will try this for "FLAPS HANDLE INDEX" and "GEAR HANDLE POSITION"....
Re: SimConnect send control-requests (events) to P3D airplane.
SetDataOnSimObject is used for setting Sim vars directly. You will want TransmitClientEvent to send events instead.
Jonathan Bleeker
Milviz systems dev
Formerly known as Naruto-kun
Milviz systems dev
Formerly known as Naruto-kun
Re: SimConnect send control-requests (events) to P3D airplane.
No it is my fault since I write about events. I cannot send events to take action in P3D, except to pass to other clients.
Re: SimConnect send control-requests (events) to P3D airplane.
Sure you can, and in some cases you have to because the simulator variable can't be set. Not the case in your example, but there are many of those variables that you can only read but not write to.
Before using them, you first have to establish the link between your structure, the enum value and the actual variable(s). That is what "SimConnect_AddToDataDefinition" is for. I suggest that you carefully re-read the examples.
Best regards
Oliver Binder
Lorby-SI
Re: SimConnect send control-requests (events) to P3D airplane.
You normally use SimConnect_MapClientEventToSimEvent for your key event definitions (along with the extra functions involved in this process) and use SimConnect_TransmitClientEvent to trigger that event. Use SimConnect_AddToDataDefinition for adding sim variables to definition groups that you will set with SimConnect_SetDataOnSimObject.
Jonathan Bleeker
Milviz systems dev
Formerly known as Naruto-kun
Milviz systems dev
Formerly known as Naruto-kun