SimConnect send control-requests (events) to P3D airplane.

lvedin
Posts: 22
Joined: Wed Aug 01, 2018 6:58 am

SimConnect send control-requests (events) to P3D airplane.

Postby lvedin » Sun Sep 23, 2018 6:04 pm

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

lvedin
Posts: 22
Joined: Wed Aug 01, 2018 6:58 am

Re: SimConnect send control-requests (events) to P3D airplane.

Postby lvedin » Sun Sep 23, 2018 8:05 pm

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.

lvedin
Posts: 22
Joined: Wed Aug 01, 2018 6:58 am

Re: SimConnect send control-requests (events) to P3D airplane.

Postby lvedin » Sun Sep 23, 2018 8:55 pm

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"....

JB3DG
Posts: 286
Joined: Mon Jan 09, 2012 6:44 pm

Re: SimConnect send control-requests (events) to P3D airplane.

Postby JB3DG » Mon Sep 24, 2018 5:59 am

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

lvedin
Posts: 22
Joined: Wed Aug 01, 2018 6:58 am

Re: SimConnect send control-requests (events) to P3D airplane.

Postby lvedin » Tue Sep 25, 2018 6:44 pm

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.

obinder
Posts: 63
Joined: Sun Jun 08, 2014 9:43 am

Re: SimConnect send control-requests (events) to P3D airplane.

Postby obinder » Tue Sep 25, 2018 9:13 pm

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.
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

JB3DG
Posts: 286
Joined: Mon Jan 09, 2012 6:44 pm

Re: SimConnect send control-requests (events) to P3D airplane.

Postby JB3DG » Wed Sep 26, 2018 5:54 am

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


Return to “SimConnect Interface Questions”

Who is online

Users browsing this forum: No registered users and 12 guests