It is currently Mon Nov 20, 2017 4:47 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 31 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
PostPosted: Thu Oct 03, 2013 1:57 pm 
Offline
NESICIDE developer
User avatar

Joined: Mon Oct 13, 2008 7:55 pm
Posts: 1049
Location: Minneapolis, MN
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.


Would the same effect be achieved by sending a mouse wheel event with delta of 0?


Top
 Profile  
 
PostPosted: Thu Oct 03, 2013 2:15 pm 
Offline
User avatar

Joined: Sat Jan 22, 2005 8:51 am
Posts: 427
Location: Chicago, IL
cpow wrote:
Would the same effect be achieved by sending a mouse wheel event with delta of 0?

I just tested that and it does appear to work as well. Good call!

_________________
get nemulator
http://nemulator.com


Top
 Profile  
 
PostPosted: Thu Oct 03, 2013 7:12 pm 
Offline
NESICIDE developer
User avatar

Joined: Mon Oct 13, 2008 7:55 pm
Posts: 1049
Location: Minneapolis, MN
James wrote:
cpow wrote:
Would the same effect be achieved by sending a mouse wheel event with delta of 0?

I just tested that and it does appear to work as well. Good call!

Nice! I knew I still had a few good ideas in me. :lol:


Top
 Profile  
 
PostPosted: Sun Oct 06, 2013 9:38 pm 
Offline
User avatar

Joined: Sun Sep 19, 2004 9:28 pm
Posts: 3192
Location: Mountain View, CA, USA
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.


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.


Top
 Profile  
 
PostPosted: Mon Oct 07, 2013 11:58 am 
Offline

Joined: Mon Sep 27, 2004 2:57 pm
Posts: 1248
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.


Top
 Profile  
 
PostPosted: Mon Oct 07, 2013 12:15 pm 
Offline
User avatar

Joined: Sat Jan 22, 2005 8:51 am
Posts: 427
Location: Chicago, IL
Drag wrote:
SDL2 has functions for disabling the screensaver, but does anyone know how it does it?

Code:
    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


Top
 Profile  
 
PostPosted: Mon Oct 07, 2013 11:40 pm 
Offline

Joined: Mon Sep 27, 2004 2:57 pm
Posts: 1248
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!


Top
 Profile  
 
PostPosted: Thu Nov 14, 2013 3:59 pm 
Offline

Joined: Tue Jun 28, 2011 2:39 pm
Posts: 152
Who still use screensavers anyway?


Top
 Profile  
 
PostPosted: Thu Nov 14, 2013 4:02 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5822
Location: Canada
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.


Top
 Profile  
 
PostPosted: Thu Nov 14, 2013 4:14 pm 
Offline
User avatar

Joined: Mon Sep 27, 2004 8:33 am
Posts: 3715
Location: Central Texas, USA
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.


Top
 Profile  
 
PostPosted: Thu Nov 14, 2013 4:21 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19233
Location: NE Indiana, USA (NTSC)
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.


Top
 Profile  
 
PostPosted: Fri Jul 01, 2016 7:00 am 
Offline
User avatar

Joined: Sun Jun 05, 2016 1:41 pm
Posts: 74
The only change needed to adapt it for your implementation is the condition:
Quote:
if (gameState == GameState.Running)


(edited - constant for invalid handle value added)

Code:
        /// <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);

_________________
Tile IDE and tile engine for XNA: http://tide.codeplex.com/
Fancy Fish Mod - Minecraft Mod: http://fancyfishmod.weebly.com/


Last edited by colinvella on Sun Jul 03, 2016 2:59 pm, edited 1 time in total.

Top
 Profile  
 
PostPosted: Fri Jul 01, 2016 12:23 pm 
Offline
Formerly 65024U

Joined: Sat Mar 27, 2010 12:57 pm
Posts: 2257
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.


Top
 Profile  
 
PostPosted: Fri Jul 01, 2016 12:53 pm 
Offline
User avatar

Joined: Sun Jun 05, 2016 1:41 pm
Posts: 74
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.


Apparently it's the managed code equivalent of the Win32 C++ constant INVALID_HANDLE_VALUE. It serves a different purpose than NULL.

_________________
Tile IDE and tile engine for XNA: http://tide.codeplex.com/
Fancy Fish Mod - Minecraft Mod: http://fancyfishmod.weebly.com/


Top
 Profile  
 
PostPosted: Fri Jul 01, 2016 1:55 pm 
Offline
User avatar

Joined: Sun Sep 19, 2004 9:28 pm
Posts: 3192
Location: Mountain View, CA, USA
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 31 posts ]  Go to page Previous  1, 2, 3  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: Bing [Bot] and 14 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group