Gamepad and Screensaver

BlitzMax Forums/BlitzMax Programming/Gamepad and Screensaver

Johnsprogram(Posted 2008) [#1]
When I play a game with my gamepad for awhile, the screensaver will pop-up. Unlike the keyboard or mouse, the gamepad's functions are ignored for resetting the timer to start the screensaver.

Is there a way I could prevent the screensaver from appearing when I use the gamepad or joystick?


Gabriel(Posted 2008) [#2]
Yes, you can prevent the screensaver from popping up. BlitzMax should probably have a way of doing this natively, but I don't think it does. You would need to write your own windows message handler, and look out for the WM_SYSCOMMAND message. When the WP data passed with a WM_SYSCOMMAND is SC_SCREENSAVER, that tells you that the system wants to run a screensaver. If your WNDProc Returns 0 when that happens, the screensaver is not allowed to start.

I'm not entirely sure what you need to do to get your own WndProc running with BlitzMax though. I do it, but I create my own window and don't use any Max2D stuff. That's the message though, so if someone can help you with setting up your own message handler, you'll know what to do with it.

EDIT: Oops, should have mentioned, this is Windows only. If you're developing on other platforms, the method used will be different.


Yan(Posted 2008) [#3]
Some old, and slightly freaky, code...


AFAIR, the GL graphics driver dumps the screen saver messages but the DX driver doesn't.


MGE(Posted 2008) [#4]
Thanks for the code Ian! But what does "AFAIR, the GL graphics driver dumps the screen saver messages but the DX driver doesn't. " this mean?


Yan(Posted 2008) [#5]
When you use GLMax2D the screen saver (and monitor power saving?) won't kick in, whereas it will when you use DXMax2D, as you have seen.

Horribly inconsistent, I know. ;o)


GfK(Posted 2008) [#6]
So... if I were to write a screensaver using DXMax2D, the screensaver would exponentially call itself unless I came up with some code to force it to not run more than one instance?

That's ghastly. Why does it do this?


Yan(Posted 2008) [#7]
I'm almost certain that an NT based OS won't start a screen saver once another is already running. Under Win98, this would happen, although it wouldn't be exponential as the system invokes the saver, not the saver itself.

I don't like the idea of the GL graphics driver silently dumping the screen saver messages and would prefer it to be, at the very least, optional. There may be times that you'd want a graphical app to be sitting in the background.

Ideally, there'd be built in commands to control this behaviour for GL *and* DX, possibly with the default being to suppress any screen saver and/or power saving.


I haven't got a clue what happens under Linux and OSX. :o/


GfK(Posted 2008) [#8]
I'm almost certain that an NT based OS won't start a screen saver once another is already running
Well, that being the case its not quite as catastrophic as I thought it was. But even so, one type of behaviour in DX and something different under GL is confusing at best. They should both be the same and I can't think of any logical reason why they aren't.

I haven't got a clue what happens under Linux and OSX. :o/
At this point in time, I don't much care. But I'm sure its something that needs looking at.


Yan(Posted 2008) [#9]
But even so, one type of behaviour in DX and something different under GL is confusing at best. They should both be the same and I can't think of any logical reason why they aren't.
Can't argue with that. :o)