Archived

This topic is now archived and is closed to further replies.

GCarty

Making Sound-gating Code Fsx-compatible

Recommended Posts

I have the following code in some FS9 gauge source code I was able to get from someone (and which I'd like to make work with FSX too). It determines whether or not the panel should play sound (it checks that FS sounds are enabled, that the aircraft is in an internal view, and that FS is not paused or in slew mode).It doesn't work in FSX because GLOBAL.DLL does not exist in that sim. How do I modify it to make it compatible with both sims?

case PANEL_SERVICE_CONNECT_TO_WINDOW:	RXPGLOBALHANDLE = GetModuleHandle("GLOBAL.DLL");	if ((RXPGLOBALHANDLE) != NULL) 	{		SimSound		= ((UINT32)(GetProcAddress(RXPGLOBALHANDLE,"Linkage")) + 0x0B20); // sound control		SimPauseOrSlew	= ((UINT32)(GetProcAddress(RXPGLOBALHANDLE,"Linkage")) + 0x0B24); // sound flag		SimView			= ((UINT32)(GetProcAddress(RXPGLOBALHANDLE,"Linkage")) + 0x0D48); // 2=tower or spot view	}	else	{		SimSound = 0;		SimPauseOrSlew = 0;		SimView = 0;	}	break;case PANEL_SERVICE_PRE_DRAW:	if ((* (unsigned char *) SimView) != 2 && 		(* (unsigned char *) SimSound) == 1 &&		(* (unsigned char *) SimPauseOrSlew) == 1)	{		SoundFlag = TRUE; //enable sounds	}	else	{		SoundFlag = FALSE;	}

By the way, I've already got a BOOL in the code called IsFSX, which does exactly what it says on the tin...

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

Now you know the reason for not using hacks. :)

Share this post


Link to post
Share on other sites

As I indicated in the original message, I didn't write this code. Does anyone have any ideas for how I can write code which fulfills the same purpose, and which works in both FS9 and FSX

Share this post


Link to post
Share on other sites
As I indicated in the original message, I didn't write this code. Does anyone have any ideas for how I can write code which fulfills the same purpose, and which works in both FS9 and FSX
The only solution I have found in FSX is to force the sound on (or off) on gauge load, and then to track occurrences of KEY_SOUND_ON, KEY_SOUND_OFF and KEY_SOUND_TOGGLE.Doug

Share this post


Link to post
Share on other sites
The only solution I have found in FSX is to force the sound on (or off) on gauge load, and then to track occurrences of KEY_SOUND_ON, KEY_SOUND_OFF and KEY_SOUND_TOGGLE.Doug
Why don't you all like SimConnect? It provides event notification for "Sound", for "View", for "Sim" and "Pause" modes... they do exactly what you want...

Share this post


Link to post
Share on other sites