Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Screensaver when using gamepad

This thread is locked; no one can reply to it. rss feed Print
Screensaver when using gamepad
count
Member #5,401
January 2005

I'm currently writing a game whith gamepad support.
I played the game to test it using the gamepad.
After some minutes my screen turned off. I thought I had a major bug and my PC just turned off completely.
But then I noticed that the monitor has been set to powersafe mode and was turned off.
Because I didn't use the mouse or the keyboard the PC thought it was not used.
But I played all the time!

How can I prevent that the screensaver/power safe mode turns on, while my game is played with a gamepad.

This dosn't happen on commercial games, does it?

Thanks for your help!

DanielH
Member #934
January 2001
avatar

With Win32 look up on Microsoft

WM_SYSCOMMAND
SC_SCREENSAVE
SC_MONITORPOWER

//from 'allegro.c' getting value from 'allegro.cfg'
_screensaver_policy = get_config_int(uconvert_ascii("system", tmp1),
                                     uconvert_ascii("disable_screensaver", tmp2),
                                     FULLSCREEN_DISABLED);

// from 'wwnd.c'
      case WM_SYSCOMMAND:
         if (wparam == SC_MONITORPOWER || wparam == SC_SCREENSAVE) {
            if (_screensaver_policy == ALWAYS_DISABLED
                || (_screensaver_policy == FULLSCREEN_DISABLED
                    && gfx_driver && !gfx_driver->windowed))
            return 0;
         }
         break;

count
Member #5,401
January 2005

Thank you.
But to be honest I don't know what to do with this information/ how to implement it.
The Microsoft site didn't help me.
Sorry for being dumb :-X

Would be cool if you could explain a little bit more what this code is/does.

Thanks alot!

Go to: