FSX How can I determine if sim is paused?

#2
I don't think there's a sim var you can read, but you can create a SimConnect client and request events and current state that way.

Si
 
#4
You need to subscribe to the "Pause" Event and, when you receive it, in the evt->dwdata there's a value which, is not zero, means you are paused and if it's zero, you are not.
 
#5
Monitor the elapsed_time variable. If it is not changing, you are paused or in a menu.
I found no "elapsed_time" named variable, but I found a token variable "ELAPSED_SECONDS". And it helps!
Thank you! :)


I don't think there's a sim var you can read, but you can create a SimConnect client and request events and current state that way.i
You need to subscribe to the "Pause" Event
Can I use Simconnect in my gauge without any restrictions?
 
#6
Can I use Simconnect in my gauge without any restrictions?
Reply With Quote
Yes. I can't think of any restrictions. It works the same in a gauge as it does in an in-process dll (which a gauge is anyway.)

Si
 

DragonflightDesign

Resource contributor
#7
Late to the party but.... this function works fine:-

Code:
//**************************************************
// Check for FS paused - simPaused=1
//********************************************************
double simPaused=0;
double getSimState(double state)
{
  static double checksecs=0;
  lookup_var(&elapsedsecs);
  if(checksecs!=(int)elapsedsecs.var_value.n)
  {
    simPaused=0;
    checksecs=(int)elapsedsecs.var_value.n;
  }
  else simPaused=1;

  return simPaused;
}
-Dai
 
#8
I still think the best approach is the Simconnect method, unless you need backward compatibility with FS9 as well.

The polling method results in your code being executed constantly to check if the sim is paused, while with Simconnect, it's a callback that will executed only when the events you are interested in, really happened.

Also, by checking the elapsed seconds variable, you will not know if the clock is not running because because the user has pressed the Pause key, or because he entered the GUI. Note that the Sim might into pause mode automatically (or not) when the menu is accessed, depending on the option "Pause on Task switch"...

Instead, with the Simconnect method, you will know the difference because, the "Pause" event means the user has really pressed the Pause key, but you also have the "SimStop" and "SimStart" event, which happen when openining/closing the GUI, even if the Sim hasn't been put in Pause mode explicitely so, you can, if you need, handle the difference.

And, last reason, by checking the seconds, it means if the user enters/exits from Pause mode rapidly enough (less then 1 second), there will be some lag in the response time, while the Simconnect code would be executed immediately and it would appear more responsive.

So, if it's ok for you to write FSX-only code, the Simconnect way is the better method for FSX.
 
Top