PDK Panel Service

flyboy7798
Posts: 37
Joined: Thu Jul 20, 2017 7:15 pm

PDK Panel Service

Postby flyboy7798 » Wed Mar 11, 2020 1:38 pm

Is there an example of how to get an instance of a panel service object via the PDK? I've looked over the examples and all I seem to find is where it's used to register and unregister a key event handler but not much else. I would like to do something like this via the PDK:

Code: Select all

IPanelCCallback* pIPanelCCallback; IAircraftCCallback* pIAircraftCCallback; IGaugeCCallback* pIGaugeCCallback;

Code: Select all

pIPanelCCallback = panel_get_registered_c_callback("VRSTP_Util"); if (pIPanelCCallback) pIAircraftCCallback = panel_get_aircraft_c_callback("VRSTP_Util"); if (pIAircraftCCallback) pIGaugeCCallback = pIAircraftCCallback->CreateGaugeCCallback();
The purpose of getting a gauge callback is to get and set Cvars. Currently, the DLL that this would potentially reside in is one that uses module_init and module_deinit. I see in the examples where DLLstart and DLLstop are used. I would like to know if this is possible and where would the best place to declare and use these pointers. Thanks in advance for your answer.

User avatar
Prepar3DGuy
Posts: 7
Joined: Thu Nov 23, 2017 7:22 pm

Re: PDK Panel Service

Postby Prepar3DGuy » Wed Mar 11, 2020 8:01 pm

To get pointer to the panel service (IPanelSystemV400) you can QueryService on the pointer to IPdk that was passed to your module_init entry point function.

Code: Select all

void FSAPI module_init(__in __notnull P3D::IPdk* pPdk) { CComPtr<P3D::IPanelSystemV400> spPanelSystem; pPdk->QueryService(P3D::SID_PanelSystem, P3D::IID_IPanelSystemV400, (void**)&spPanelSystem); CComPtr<IPanelCCallback> spPanelCallback = spPanelSystem->PanelGetRegisteredCCallback("VRSTP_Util"); // Do something useful }
The better way to request PDK services are via P3D:PdkServices helper http://www.prepar3d.com/SDKv4/sdk/pdk_a ... k_services

Code: Select all

void FSAPI module_init(__in __notnull P3D::IPdk* pPdk) { P3D::PdkServices::Init(pPdk); CComPtr<IPanelCCallback> spPanelCallback = P3D::PdkServices::GetPanelSystem()->PanelGetRegisteredCCallback("VRSTP_Util"); // Do something useful }
Oh, just look at the Custom_Nav_Draw example.
But you can't do this

Code: Select all

spPanelCallback->CreateAircraftCCallback(What_ID)
because it's Prepar3D only role to call this method with some magic Container_ID.
By the way you can get pointer to the aircraft callback instance if it exists via

Code: Select all

P3D::PdkServices::GetPanelSystem()->PanelGetAircraftCCallback("VRSTP_Util");
Check that it not NULL (Prepar3D have not created this instance yet),

User avatar
Prepar3DGuy
Posts: 7
Joined: Thu Nov 23, 2017 7:22 pm

Re: PDK Panel Service

Postby Prepar3DGuy » Wed Mar 11, 2020 8:35 pm

If your module_init doesn't receive pointer to IPdk, use query_pdk from gauge.h as alternative.

User avatar
Prepar3DGuy
Posts: 7
Joined: Thu Nov 23, 2017 7:22 pm

Re: PDK Panel Service

Postby Prepar3DGuy » Wed Mar 11, 2020 9:16 pm

The purpose of getting a gauge callback is to get and set Cvars.
Why not to simply use ExecuteCalculatorCode method from PanelSystemV400
Look at this forum thread.

flyboy7798
Posts: 37
Joined: Thu Jul 20, 2017 7:15 pm

Re: PDK Panel Service

Postby flyboy7798 » Thu Mar 12, 2020 7:07 pm

Thank you, I will take a look. It's much appreciated.


Return to “Software Development Kit (SDK) Questions”

Who is online

Users browsing this forum: No registered users and 20 guests