• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

FSXA [Compiled OK]Converting a 32 bit C++ gauge to P3Dv4

Kekelekou

Resource contributor
Messages
226
Country
france
Hello there,

Hello there !

Following the release of the Damage Mod for Flight1’s BN-2 Islander, I have been asked if the mod (designed for FSXA) was available for P3Dv4. The XML gauges should work OK, Doug’s fuel, config and sound gauges already exist for P3Dv4, so it all falls down to my two C++ gauges intercepting the throttle or pitch lever positions.
Is there a way to recompile the source code so that the gauges work in P3Dv4? I suppose so, but I am struggling to find a tutorial here or over the wide web.

Have a nice day
 

DragonflightDesign

Resource contributor
Messages
1,088
Country
northernireland
https://www.fsdeveloper.com/forum/resources/fsx-p3d-and-cfs3-gauge-creation-tutorial-rev-36.206/

There's a section on setting up Visual Studio for compiling 64-bit gauges. In your gauges you will need to change the gauge callback header from UINT32 to UINT_PTR e.g.
Code:
void FSAPI aircraft_config_update(PGAUGEHDR pgauge, int service_id, UINT_PTR extra_data)
The other approach to this is to use an #ifdef e.g.
Code:
#ifdef _64BIT
    #include "p3dv4_gauges.h"
    #define PUSERDATA UINT_PTR
    #include "simconnect\64\SimConnect.h"
#else
    #include "fsxgauges_sp2.h"
    #define PUSERDATA UINT32
    #include "simconnect\fsx\SimConnect.h"
#endif
and change the gauge callback header to
Code:
void FSAPI aircraft_config_update(PGAUGEHDR pgauge, int service_id, PUSERDATA extra_data)
 
Last edited:

Kekelekou

Resource contributor
Messages
226
Country
france
Two additional questions :
- Is compiling a FSX SDK based gauge with a 64bits setting (and your proposed header change) enough to have it work in P3Dv4, or do I need to install the P3Dv4 SDK and compile from it ?
- Is the header change the only "code" modification required?
 

ddawson

Resource contributor
Messages
862
Country
canada
Two additional questions :
- Is compiling a FSX SDK based gauge with a 64bits setting (and your proposed header change) enough to have it work in P3Dv4, or do I need to install the P3Dv4 SDK and compile from it ?
- Is the header change the only "code" modification required?

You will need to use the P3Dv4 version of gauges.h
Also, if you are using SimConnect in the gauge, make sure you use the version of simconnect.h and simconnect.lib that are included with the P3Dv4 SDK.
 

DragonflightDesign

Resource contributor
Messages
1,088
Country
northernireland
To add to Doug's response - see also the #ifdef statement I posted in my initial reply - this switches between FSX and P3D and the required gauges and simconnect header files. You may need to add paths to the #ifdef statement depending on your setup.
 

Kekelekou

Resource contributor
Messages
226
Country
france
Hi,

Still so much to learn I am afraid.
I have set VS2017 and my project as per stated in Dai’s tutorial, and have gone the UINT_PTR way.
I have updated the inc and lib paths in the project settings to the P3Dv4 inc and lib folders.
I have added the v4 gauges.h and simconnect.h to the project.
I have added SimConnect.lib to the linker’s command line.
But all I am getting is 8 lnk2001 errors : unresolevd external symbol. They are all related to SimConnect « functions » eg simconnect_SetNotificationGroupPriority.

Is there another obvious item rookie-me has forgotten to set right?

PS: I have installed P3Dv4’s SDK, but I don’t have the sim. Is it of any importance?
 

JB3DG

Resource contributor
Messages
1,325
Country
southafrica
You need to use separate SimConnect.h and lib files for x64. Also, v4 uses separate release and debug libs. I would keep the lib out of the linker's command line and use #pragma comment linking instead.

Here is what I use in most of my projects:

C++:
#ifdef _M_X64
#include "lx64\\SimConnect.h"
#ifdef _DEBUG
#pragma comment(lib, "lx64\\SimConnectDebug.lib")
#else
#pragma comment(lib, "lx64\\SimConnect.lib")
#endif
#else
#include "SimConnect.h"
#pragma comment(lib, "SimConnect.lib")
#endif
 

DragonflightDesign

Resource contributor
Messages
1,088
Country
northernireland
Never thought about using #pragma commenting! :) I do have an #ifdef _DEBUG switching statement in my code but never thought to post it with the original example. My bad - I should have done.

And... I've said it before, but thanks for the original #ifdef _64BIT statement. You have no idea how much grief that has saved me!
 

Kekelekou

Resource contributor
Messages
226
Country
france
Case closed! (at least as long as the compilation is concerned).
I just had to delete 32-bit gauges.h and simconnect.h/.lib files inside the project folder, so that the x64 ones could be used for compiling.
Programming is such a blast! :laughing:
 
Messages
917
Country
indonesia
even you solved compiling with deleting 32-bit gauge.h and paste x64 gauge.h, you did long way though.
I did what JB3DG did, and I just need select x64 or x32 on solution platform just like flip my hand, then compile.
 
Top