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

C Gauges Development

Messages
12
Country
brazil
I started programming gauges about 3 weeks, I'm Java developer and I've some ideas about C.

I downloaded sd2gau23.zip guide to learn about FS Gauges and at this file there are some C gauges codes. When I tried to compile, I saw that some file are missing:

- fssound.h
- eventid.h
- gauges.h

Where can I find these files? Can I use DEV-C++ to create Gauges?


Thank you and sorry my bad english
 
Last edited:
You don't need fssound.h because it's been stripped out of that document in recent editions. It's for supporting additional gauge triggered sounds using DirectSound. Just comment out anything related to fssound in those files.

gauges.h is replaced in that document with fsx_gauges_sp2.h as it includes some stuff MS appraently missed out of gauges.h included in the SDK, (located in \Microsoft Flight Simulator X SDK\SDK\SimObject Creation Kit\Panels and Gauges SDK\inc)

I don't know what eventid.h is. Sounds like it's probably their way of assigning event strings (listed in \Microsoft Flight Simulator X SDK\SDK\Core Utilities Kit\Variables\Event Ids.htm to #define labels.

I don't know what DEV-C++ is. I use Visual C++ Express 2008, which is free.

Si
 
The gauges.h file is part of the FS SDK. You will need to download and install the relevant SDK for the version for which you are developing, as the gauges.h file has additional content for FSX, SP1, SP2 and Acceleration.

As Si already mentioned though, Dai has merged his and Arne Bartel's "improvements and fixes" to the file Dai included in his mini-book. ;)

I'd suggest going here and reading the sticky threads I've posted: http://forums.flightsim.com/vbfs/forumdisplay.php?f=24
 
Last edited:
You don't need fssound.h because it's been stripped out of that document in recent editions. It's for supporting additional gauge triggered sounds using DirectSound. Just comment out anything related to fssound in those files.

gauges.h is replaced in that document with fsx_gauges_sp2.h as it includes some stuff MS appraently missed out of gauges.h included in the SDK, (located in \Microsoft Flight Simulator X SDK\SDK\SimObject Creation Kit\Panels and Gauges SDK\inc)

I don't know what eventid.h is. Sounds like it's probably their way of assigning event strings (listed in \Microsoft Flight Simulator X SDK\SDK\Core Utilities Kit\Variables\Event Ids.htm to #define labels.

I don't know what DEV-C++ is. I use Visual C++ Express 2008, which is free.

Si

I'm building gauges for FS2004, can I use fsxgauges_sp2.h ?

Thank you for the help and I'm downloading visual c++
 
I suggest you stick to the files relevant for your version of the sim. The FS2004 stuff is a subset of the fsx_gauges_sp2.h file, but you could just end up confusing yourself by trying to use features that FS2004 doesn't support. I suggest you try and get an earlier FS2004 specific version of Dai's .h file or download the MS SDK for FS2004.

Si
 
I Started studying gauges because I need to build one that controls windows mixer microphone volume (record settings), is it possible using XML gauges? Probably not.

What do you say?

Thanks in advance
 
XML has absolutely no sound control whatever, nor any form of file I/O.
 
Trying to compile the files, I got some errors:

bip.engine.c(6) : error C2065: 'GAUGE_NAME' : undeclared identifier

At this line: char engine_gauge_name[] = GAUGE_NAME;

But GAUGE_NAME is actually defined at Bip.c:

#define GAUGE_NAME "Engine\0"
#define GAUGEHDR_VAR_NAME gaugehdr_engine
#define GAUGE_W 100

#include "Bip.Engine.c"



After this error, I have lots of sintax errors too.

Did I forget to setup something? I'm confused :confused:


Thanks in advance
 
Try to exclude "Bip.Engine.c" from "Source files" in solution\workspace (and other file with gauge code ***.c, but NOT main gauge code file (in which defines entries for subgauges, in this case - Bip.c)).
 
Try to exclude "Bip.Engine.c" from "Source files" in solution\workspace (and other file with gauge code ***.c, but NOT main gauge code file (in which defines entries for subgauges, in this case - Bip.c)).


Thanks for the information LAVRIK, it works but I got another error... What can it be? Thanks!

------ Build started: Project: Gauge, Configuration: Debug Win32 ------
Compiling resources...
Microsoft (R) Windows (R) Resource Compiler Version 6.0.5724.0
Copyright (C) Microsoft Corporation. All rights reserved.
Linking...
Creating library C:\Documents and Settings\Thomas Couto\Desktop\Gauges Develop\Gauge\Gauge\Debug\Gauge.lib and object C:\Documents and Settings\Thomas Couto\Desktop\Gauges Develop\Gauge\Gauge\Debug\Gauge.exp
LIBCMTD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main


Bip.obj : error LNK2001: unresolved external symbol _engine_mouse_rect
C:\Documents and Settings\Thomas Couto\Desktop\Gauges Develop\Gauge\Gauge\Debug\Gauge.gau : fatal error LNK1120: 2 unresolved externals


Build log was saved at "file://c:\Documents and Settings\Thomas Couto\Desktop\Gauges Develop\Gauge\Gauge\Debug\BuildLog.htm"
Gauge - 3 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
 
For the first C gauge I made I took a working sample and just modified it. That way I knew my compiler was set up correctly and the project settings were ok. Rooting around trying to solve linker problems can be a nightmare when you first start.

The _engine_mouse_rect linker error should be easy enough to find. It's looking for the definition of something you've included in a function or macro call but not defined.

i.e. my guess is you have engine_mouse_rect defined in your GAUGE_HEADER_FSxxx macro, but you don't have a subsequent MOUSE_BEGIN section describing the actual mouse rect area.

The unresolved external _main I'm not sure about but it looks like your code is trying to either build an exe but there's no main (but then it says it's build .lib so I don't know..) or you have a reference to main() somewhere that you don't need.

Si
 
If you aren't going to use a mouse rectangle, simply put NULL in the parameter list of your header:

GAUGE_HEADER_FS700(GAUGE_W, VOR1_gauge_name, &VOR1_list, VOR1_mouse_rect, vor2_gaugecall, 0, 0, 0);

GAUGE_HEADER_FS700(GAUGE_W, VOR1_gauge_name, &VOR1_list,NULL, vor2_gaugecall, 0, 0, 0);
 
Thanks Si and n4gix.

Now I have only this error:

LIBCMTD.lib(crt0.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup


I have not a main() method at my C files.

My output file is: $(OutDir)\$(ProjectName).gau

At Configuration Type I have:

- MakeFile
- Application.exe
- .Dll
- Static library
- Utility

I tried between .exe (?!) and .dll but i got the same error above.

My config:

(c/c++)
At Runtime Library -> Multi-threaded Debug (/MTd)
Basic Runtime Checks -> Both (/RTC1, equiv. to /RTCsu)

(linker)
SubSystem -> Console (/SUBSYSTEM:CONSOLE)

At Advanced tab:
Entry point: I leaved it blank (it was 'main')
No Entry Point: YES /NoEntry
 
What I did when I couldn't get my files to link initially was to open up a working sample in a second copy of visual studio then open up the project properties for both side by side and compare every option one at a time until I found one a difference that might be causing it.

You could try adding libcmt to the list of ignored standard libraries. I find that library quite often gets in the way but I'm usually coding for cross-platform with Qt where it's not required (when not doing gauges.)

Si
 
What I did when I couldn't get my files to link initially was to open up a working sample in a second copy of visual studio then open up the project properties for both side by side and compare every option one at a time until I found one a difference that might be causing it.

You could try adding libcmt to the list of ignored standard libraries. I find that library quite often gets in the way but I'm usually coding for cross-platform with Qt where it's not required (when not doing gauges.)

Si

Everthing is working now Si, thank you VERY much.

:)
 
You cannot play sounds from C or XML gauges directly. There are essentially two ways of doing it. Firstly you can map the sound you want to one of the existing aircraft sound functions, like the "no smoking" or "seatbelts" noise in the sound.cfg. Then you simply trigger the event in your gauge to play it, as if the user had just pressed the respective key command. Secondly you can link in DirectSound and interface directly to the Windows DirectX sound system, but that is a lot more involved and you'll need to delve through the DirectX SDK to figure out how to do it. You can download that SDK from MS.

Edit: You can use that dll that's mentioned in Dai's document. But it's been removed from the latest version. If you search for an older one you may find it included but I'm not sure whether it was removed from the later versions because it doesn't work anymore. Alternatively, do a search for the dll sound gauge by Doug Dawson, which you can use for freeware products, or pay a fee for inclusion in payware.

Si
 
I use Gaugesound.dll myself. It was supplied with Easy Gauge when I bought the 'professional version' some years ago. It is based on the DirectSound SDK.
 
I keep all my gauge's sound files in a sub-folder under the default FS ..\sound folder, as shown below.

To play a sound once:

(GaugePlaySound)("sound\\ESDG\\click.wav","",0) ;

To loop a sound:

(GaugePlaySound)("sound\\ESDG\\Siren.wav","stop_siren",1) ;
(GaugeStopSound)("stop_siren") ;

To stop ALL sounds at once:

(TerminateSounds)();


Here is an example gauge showing how I coded a custom XML-to-C interface gauge.
Also shown are the inititialization and deinitialization requirements:

Code:
char ES_XMLSound_gauge_name[]  = GAUGE_NAME;
extern PELEMENT_HEADER   ES_XMLSound_list;
PELEMENT_STATIC_IMAGE bg_element =NULL;
extern MOUSERECT     ES_XMLSound_mouse_rect[];
GAUGE_CALLBACK     gaugecall;
GAUGE_HEADER_FS700(GAUGE_W, ES_XMLSound_gauge_name, &ES_XMLSound_list, NULL, gaugecall, 0, 0, 0);

	// Sound declarations
	typedef VOID (*TGaugePlaySound)(LPTSTR, LPTSTR,int);
	typedef VOID (*TGaugeStopSound)(LPTSTR);
	typedef VOID (*TTerminateSounds)();
	TGaugePlaySound GaugePlaySound;
	TGaugeStopSound GaugeStopSound;
	TTerminateSounds TerminateSounds;
	HMODULE MGaugeSound;

	#define GAUGE_CHARSET2           DEFAULT_CHARSET
	#define GAUGE_FONT_DEFAULT2          "Arial Bold"
	#define GAUGE_WEIGHT_DEFAULT2     FW_NORMAL

	int xml_click = 0;
	int xml_push = 0;
	int xml_ding = 0;
	int xml_lvalt = 0;
	int xml_time_expired = 0;

	ID xml_click_id;
	ID xml_push_id;
	ID xml_ding_id;
	ID xml_lvalt_id;
	ID xml_time_expired_id;

void FSAPI gaugecall(PGAUGEHDR pgauge, int service_id, UINT32 extra_data)
{
	switch(service_id)
	{
	case PANEL_SERVICE_PRE_INITIALIZE:
		bg_element = (PELEMENT_STATIC_IMAGE)pgauge->elements_list[0];
		if (MGaugeSound == NULL) {MGaugeSound = LoadLibrary("GaugeSound");}
		GaugePlaySound = (TGaugePlaySound)GetProcAddress(MGaugeSound,"GaugePlaySound");
		GaugeStopSound = (TGaugeStopSound)GetProcAddress(MGaugeSound,"GaugeStopSound");
		TerminateSounds = (TTerminateSounds)GetProcAddress(MGaugeSound,"TerminateSounds");

		register_named_variable ( "XMLClick" );
		register_named_variable ( "XMLPush" );
		register_named_variable ( "XMLDing" );
		register_named_variable ( "XMLLvAlt" );
		register_named_variable ( "XMLTimeExp" );
	break;

	case PANEL_SERVICE_PRE_KILL:
		MGaugeSound = GetModuleHandle("GaugeSound");
		if (MGaugeSound == NULL) {MGaugeSound = LoadLibrary("GaugeSound");}
		GaugePlaySound = (TGaugePlaySound)GetProcAddress(MGaugeSound,"GaugePlaySound");
		GaugeStopSound = (TGaugeStopSound)GetProcAddress(MGaugeSound,"GaugeStopSound");
		TerminateSounds = (TTerminateSounds)GetProcAddress(MGaugeSound,"TerminateSounds");
		(TerminateSounds)();
		FreeLibrary(MGaugeSound);
	break;

	case PANEL_SERVICE_PRE_UPDATE:
		MGaugeSound = GetModuleHandle("GaugeSound");
		if (MGaugeSound == NULL) {MGaugeSound = LoadLibrary("GaugeSound");}
		GaugePlaySound = (TGaugePlaySound)GetProcAddress(MGaugeSound,"GaugePlaySound");
		GaugeStopSound = (TGaugeStopSound)GetProcAddress(MGaugeSound,"GaugeStopSound");
		TerminateSounds = (TTerminateSounds)GetProcAddress(MGaugeSound,"TerminateSounds");

		xml_click_id = check_named_variable ( "XMLClick" ) ;
		xml_click = get_named_variable_value (xml_click_id);

		xml_push_id = check_named_variable ( "XMLPush" ) ;
		xml_push = get_named_variable_value (xml_push_id);

		xml_ding_id = check_named_variable ( "XMLDing" ) ;
		xml_ding = get_named_variable_value (xml_ding_id);

		xml_lvalt_id = check_named_variable ( "XMLLvAlt" ) ;
		xml_lvalt = get_named_variable_value (xml_lvalt_id);

		xml_time_expired_id = check_named_variable ( "XMLTimeExp" ) ;
		xml_time_expired = get_named_variable_value (xml_time_expired_id);

		if ( xml_click == 1 ) { (GaugePlaySound)("sound\\ESDG\\click.wav","",0) ; xml_click = 0 ; }
		if ( xml_push == 1 ) { (GaugePlaySound)("sound\\ESDG\\push.wav","",0) ; xml_push = 0 ; }
		if ( xml_ding == 1 ) { (GaugePlaySound)("sound\\ESDG\\ding.wav","",0) ; xml_ding = 0 ; }
		if ( xml_lvalt == 1 ) { (GaugePlaySound)("sound\\ESDG\\LEAVING_ALTITUDE.wav","",0) ; xml_lvalt = 0 ; }
		if ( xml_time_expired == 1) { (GaugePlaySound)("sound\\ESDG\\TIMER_EXPIRED.wav","",0) ; xml_time_expired = 0 ; }

		set_named_variable_value(xml_click_id, xml_click) ;
		set_named_variable_value(xml_push_id, xml_push) ;
		set_named_variable_value(xml_ding_id, xml_ding) ;
		set_named_variable_value(xml_lvalt_id, xml_lvalt) ;
		set_named_variable_value(xml_time_expired_id, xml_time_expired);
	break;
	}
}

FLOAT64 FSAPI callback4( PELEMENT_STRING pelement)
{
	float rwert=xml_ding;
	sprintf(pelement->string,"XMLDing = %.0f",rwert);
	return 0;
}

FLOAT64 FSAPI callback3( PELEMENT_STRING pelement)
{
	float rwert=xml_push;
	sprintf(pelement->string,"XMLPush = %.0f",rwert);
	return 0;
}

FLOAT64 FSAPI callback2( PELEMENT_STRING pelement)
{
	float rwert=xml_click;
	sprintf(pelement->string,"XMLClick = %.0f",rwert);
	return 0;
}

MAKE_STRING(String4,NULL,NULL,IMAGE_USE_ERASE | IMAGE_USE_TRANSPARENCY | BIT7,0,0,77,99,20,1000000,
			MODULE_VAR_NONE,
			MODULE_VAR_NONE,
			MODULE_VAR_NONE,
			RGB(8,8,8),
			RGB(0,0,0),
			RGB(0,0,0),
			GAUGE_FONT_DEFAULT2,
			GAUGE_WEIGHT_DEFAULT2,
			GAUGE_CHARSET2,
			0,0,
			NULL,
			callback4)
PELEMENT_HEADER ElementList2[] = 
{
	&String4.header,
	NULL
};

MAKE_STRING(String3,&ElementList2,NULL,IMAGE_USE_ERASE | IMAGE_USE_TRANSPARENCY | BIT7,0,1,44,99,20,1000000,
			MODULE_VAR_NONE,
			MODULE_VAR_NONE,
			MODULE_VAR_NONE,
			RGB(8,8,8),
			RGB(0,0,0),
			RGB(0,0,0),
			GAUGE_FONT_DEFAULT2,
			GAUGE_WEIGHT_DEFAULT2,
			GAUGE_CHARSET2,
			0,0,
			NULL,
			callback3)
PELEMENT_HEADER ElementList3[] = 
{
	&String3.header,
	NULL
};

MAKE_STRING(String2,&ElementList3,NULL,IMAGE_USE_ERASE | IMAGE_USE_TRANSPARENCY | BIT7,0,3,6,99,20,1000000,
			MODULE_VAR_NONE,
			MODULE_VAR_NONE,
			MODULE_VAR_NONE,
			RGB(8,8,8),
			RGB(0,0,0),
			RGB(0,0,0),
			GAUGE_FONT_DEFAULT2,
			GAUGE_WEIGHT_DEFAULT2,
			GAUGE_CHARSET2,
			0,0,
			NULL,
			callback2)
PELEMENT_HEADER ElementList4[] = 
{
	&String2.header,
	NULL
};

MAKE_STATIC(Static1,BMP_BACKGROUND,&ElementList4,NULL,IMAGE_USE_ERASE | IMAGE_USE_TRANSPARENCY | BIT7,0,0,0)

PELEMENT_HEADER ES_XMLSound_list = &Static1.header;

To play a sound from an XML script:

1 (>L:XMLClick,enum)
1 (>L:XMLDing,enum)
1 (>L:XMLPush,enum)
1 (>L:XMLLvAlt,enum)
1 (>L:XMLTimeExp,enum)
 
Last edited:
Back
Top