Jump to content
Sign in to follow this  
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

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


Ed Wilson

Mindstar Aviation
My Playland - I69

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

Lefteris Kalamaras - Founder

www.flightsimlabs.com

 

sig_fsldeveloper.jpg

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...