1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

SOUND_TOGGLE - knowing status of sounds ON/OFF?

Discussion in 'Sound' started by B21, 9/9/08.

  1. B21

    B21

    Joined:
    3/12/07
    Messages:
    149
    Country:
    unitedkingdom
    With some great help on this site I have my gauge able to recognise when the SOUND_TOGGLE event is happening - on each event I then toggle my own variable between 1 and 0 and use that to enable/disable some sounds (using my own DLL). So my gauge responds to the 'q' key correctly.

    I'm missing something though - how can I be sure I'm *always* toggling in the right direction? It seems the process is vulnerable to getting out of step (i.e. can you not fundamentally tell whether SOUND_TOGGLE is toggling the sound to ON, or to OFF?). It would be a damn sight easier if I was just reading a variable SOUND_STATUS instead of trying to create that myself.

    Did I miss something?

    Thanks
    B21
  2. Simon853

    Simon853

    Joined:
    15/1/07
    Messages:
    516
    You need to use the SimConnect function SimConnect_SubscribeToSystemEvent and subscribe to the Sound event. Everytime the user presses Q (or the matching menu option) an event will be generated and the specific state of the sound system is given.

    You also need to turn your sounds off in dialogs. So subscribe to the Dialog mode event also.

    Si
  3. B21

    B21

    Joined:
    3/12/07
    Messages:
    149
    Country:
    unitedkingdom
    Thanks Si - I've done a fair bit of simconnect programming and see the SimConnect_SubscribeToSystemEvent(..) call you're describing with the event "Sound": "Requests a notification when the master sound switch is changed. This request will also return the current state of the master sound switch immediately. A flag is returned in the dwData parameter, 0 if the switch is off". The provision of the actual *state* of the sound master switch is a significant addition in the simconnect api vs. the gauge.

    B21
  4. Simon853

    Simon853

    Joined:
    15/1/07
    Messages:
    516
    Don't forget that you can actually use SimConnect in a C gauge.

    If you're predominantly using XML gauges then you can export variables from your C to be visible in your XML gauges by:

    Code:
    void SetLVar32(SINT32 val,char *str)
    {
    	sprintf(VarCommandString,"%d (>L:%s)",val,str);
    	execute_calculator_code((PCSTRINGZ)VarCommandString,NULL,NULL,NULL);
    }
    
    where the string is the variable name of your choice and val is the value, i.e.

    SetLVar64("MySoundState,bool",sound);

    Will result in a variable called L:MySoundState,bool being available in XML and set to whatever the sound parameter is.

    Si

Share This Page