Would the same effect be achieved by sending a mouse wheel event with delta of 0?tepples wrote:Then send something innocent like the down arrow or the spacebar or the X key, as that's what players would already be pressing when playing an NES game with a keyboard.
In any case, Windows Vista didn't exist 8 years ago, and your product requires it or newer.
Important screensaver tip for Windows emulator authors
Moderator: Moderators
- cpow
- NESICIDE developer
- Posts: 1097
- Joined: Mon Oct 13, 2008 7:55 pm
- Location: Minneapolis, MN
- Contact:
Re: Important screensaver tip for Windows emulator authors
Re: Important screensaver tip for Windows emulator authors
I just tested that and it does appear to work as well. Good call!cpow wrote:Would the same effect be achieved by sending a mouse wheel event with delta of 0?
get nemulator
http://nemulator.com
http://nemulator.com
- cpow
- NESICIDE developer
- Posts: 1097
- Joined: Mon Oct 13, 2008 7:55 pm
- Location: Minneapolis, MN
- Contact:
Re: Important screensaver tip for Windows emulator authors
Nice! I knew I still had a few good ideas in me.James wrote:I just tested that and it does appear to work as well. Good call!cpow wrote:Would the same effect be achieved by sending a mouse wheel event with delta of 0?
Re: An important tip for Windows emulator authors
You're right -- thanks, I've updated my post on Steam. I believe this also means the Nestopia code is wrong too (lacking & 0xfff0), but the updated unofficial version in git has it fixed.Quietust wrote:There's actually two minor flaws in the sample code you posted on the Steam forums:
1. wParam needs to be ANDed with 0xFFF0 first.MSDN wrote:In WM_SYSCOMMAND messages, the four low-order bits of the wParam parameter are used internally by the system. To obtain the correct result when testing the value of wParam, an application must combine the value 0xFFF0 with the wParam value by using the bitwise AND operator.
Re: Important screensaver tip for Windows emulator authors
SDL2 has functions for disabling the screensaver, but does anyone know how it does it? Hopefully, it's the way mentioned in this thread and not by changing the power profile.
Re: Important screensaver tip for Windows emulator authors
Drag wrote:SDL2 has functions for disabling the screensaver, but does anyone know how it does it?
Code: Select all
case WM_SYSCOMMAND:
{
/* Don't start the screensaver or blank the monitor in fullscreen apps */
if ((wParam & 0xFFF0) == SC_SCREENSAVE ||
(wParam & 0xFFF0) == SC_MONITORPOWER) {
if (SDL_GetVideoDevice()->suspend_screensaver) {
return (0);
}
}
}
break;
get nemulator
http://nemulator.com
http://nemulator.com
Re: Important screensaver tip for Windows emulator authors
Ah, excellent. Thanks for digging that up. It's only after this post that I remember that SDL is open source and I could've looked it up myself. D'oh!
Re: Important screensaver tip for Windows emulator authors
Who still use screensavers anyway?
- rainwarrior
- Posts: 8732
- Joined: Sun Jan 22, 2012 12:03 pm
- Location: Canada
- Contact:
Re: Important screensaver tip for Windows emulator authors
It's not just for screen savers anymore, darkhog, that's just what we call it now. It's about a timer on inactive input, and lots of computers are set to turn the monitor off or go to sleep after a certain time.
Re: Important screensaver tip for Windows emulator authors
Aren't these things like a mouse wheel movement of 0 just hacks, i.e. they will break at some point in the future? It's a sad situation that the OS would suspend a system even though a USB HID was generating input.
Re: Important screensaver tip for Windows emulator authors
Expanding on what rainwarrior wrote: The effort formerly put into screensavers has forked into two areas.
Screensaver as art: The display hacks common in the screensaver era appear to have folded into the demoscene.
Screensaver as blanking: With CRTs and plasma planels giving way to LCDs that have less of a burn-in problem, and with an increased focus on conserving electric power, it's not quite as necessary to waste computing cycles on rendering visual effects. But it's still common to have the system blank the screen when a terminal has become idle, lock the input devices, and possibly show a simple moving image to show that the computer is still in use. This improves security, as eavesdroppers have less of a chance to read sensitive information from the screen. It also gracefully leads into lower-power states: in monitor power save, the graphics processor cuts off the signal and the monitor turns off, and in suspend, everything but the DRAM refresh and the keyboard controller turns off.
Screensaver as art: The display hacks common in the screensaver era appear to have folded into the demoscene.
Screensaver as blanking: With CRTs and plasma planels giving way to LCDs that have less of a burn-in problem, and with an increased focus on conserving electric power, it's not quite as necessary to waste computing cycles on rendering visual effects. But it's still common to have the system blank the screen when a terminal has become idle, lock the input devices, and possibly show a simple moving image to show that the computer is still in use. This improves security, as eavesdroppers have less of a chance to read sensitive information from the screen. It also gracefully leads into lower-power states: in monitor power save, the graphics processor cuts off the signal and the monitor turns off, and in suspend, everything but the DRAM refresh and the keyboard controller turns off.
- colinvella
- Posts: 74
- Joined: Sun Jun 05, 2016 1:41 pm
Windows Forms implementation in C#
The only change needed to adapt it for your implementation is the condition:
(edited - constant for invalid handle value added)if (gameState == GameState.Running)
Code: Select all
/// <summary>
/// Windows message handler
/// </summary>
/// <param name="message">Windows message to process</param>
protected override void WndProc(ref Message message)
{
// check if screen saver message dispatched
if (message.Msg == WM_SYSCOMMAND && (int)message.WParam == SC_SCREENSAVE)
{
// if game is running, suppress screen saver request
if (gameState == GameState.Running)
{
message.Result = INVALID_HANDLE_VALUE;
return;
}
}
// fall back to default message processor
base.WndProc(ref message);
}
// window message processing
private static readonly int SC_SCREENSAVE = 0xF140;
private static readonly int WM_SYSCOMMAND = 0x0112;
private static readonly IntPtr INVALID_HANDLE_VALUE = (IntPtr)(-1);
Last edited by colinvella on Sun Jul 03, 2016 2:59 pm, edited 1 time in total.
Tile IDE and tile engine for XNA: http://tide.codeplex.com/
Fancy Fish Mod - Minecraft Mod: http://fancyfishmod.weebly.com/
Fancy Fish Mod - Minecraft Mod: http://fancyfishmod.weebly.com/
Re: Important screensaver tip for Windows emulator authors
Hardcoding the NULL Pointer to -1 instead of just using NULL? I've seen it all, as long as that isn't how Microsoft tells you how to do it.
- colinvella
- Posts: 74
- Joined: Sun Jun 05, 2016 1:41 pm
Re: Important screensaver tip for Windows emulator authors
Apparently it's the managed code equivalent of the Win32 C++ constant INVALID_HANDLE_VALUE. It serves a different purpose than NULL.3gengames wrote:Hardcoding the NULL Pointer to -1 instead of just using NULL? I've seen it all, as long as that isn't how Microsoft tells you how to do it.
Tile IDE and tile engine for XNA: http://tide.codeplex.com/
Fancy Fish Mod - Minecraft Mod: http://fancyfishmod.weebly.com/
Fancy Fish Mod - Minecraft Mod: http://fancyfishmod.weebly.com/
Re: Important screensaver tip for Windows emulator authors
I should note there's also a "newer" way to to this (Windows 7 and up only; older Windows releases need to use the methodology already described) through Windows' Power Management API. Specifically I'm referring to PowerCreateRequest() and PowerSetRequest() for the PowerRequestDisplayRequired RequestType.
The reason I mention this is that use of this API to inhibit display blanking/power-down/sleep allows a user to do powercfg.exe -requests from the CLI and see which applications and/or drivers are inhibiting said condition.
The reason I mention this is that use of this API to inhibit display blanking/power-down/sleep allows a user to do powercfg.exe -requests from the CLI and see which applications and/or drivers are inhibiting said condition.