PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

How do I keep the device turned on?

I thought I'd start another topic from my previous post because this one tackles keeping the device turned on rather than just the backlight. There seems to be no generic way to keep the backlight turned on on most devices so I guess I'll just stick to turning on the device.

How do you keep the device always turned on using GapiApplication? I saw the code below from a mailing list but how do I implement it using GapiApplication?

keybd_event( VK_F24, 0, KEYEVENTF_KEYUP | KEYEVENTF_SILENT, 0 );

How do I convert that to use the KeyUp event in GapiApp?

Any inputs will be greatly appreciated!

Erick :)
I guess you could try to post the event you suggested every 100th frame or so.. It might work.. You don't have to catch the key event either...
Johan wrote:I guess you could try to post the event you suggested every 100th frame or so.. It might work.. You don't have to catch the key event either...

That is what I do and it works correcly. At least I haven't come across a device that it didn't work on.

However, I include it as an option. I expect some people wouldn't want to see their batteries drained because they forget to close a game while they left their device alone.

--Eric
Hi Eric,

Would you mind posting how did you integrate it? I don't have the slightest idea how do I do that using GapiApplication?

Many thanks!

Erick :)
Hi Erick!

Pretty simple. I added these lines at the top of the ProcessNextFrame function:

FrameCount++;
if(FrameCount == 300)
{
keybd_event( VK_F24, 0, KEYEVENTF_KEYUP, 0 );
FrameCount = 0;
}

Pretty simple. I saw no side-effect on speed at all. FrameCount is a DWORD. I send the event at 300 frames interval basically because I lock my app at 15 FPS, which means that the event is sent at around 20 seconds interval.

There are plenty of ways to do it, but this is the easiest to understand and it works well in what I'm doing.

Note that I didn't use the "silent" flag mentionned in other posts. I think this flag is obsolete on recent versions of Windows (not sure). Anyway, it's a more realistic key simulation without the flag, me think.

I hope this helps.

--Eric
Oh is that it? Thanks a lot!

This feature is really important for my game and I'm going to make it as an option too so the user won't drain their batteries when they leave the game running on their device.

You've earned a space on my credits list! Thanks Eric!

Erick :)
egarayblas wrote:You've earned a space on my credits list!

Wow, how great is that! Thanks!!

--Eric
hmm... so Erick -eSoft and Eric -efrontier are two UNIQUE person! Sorry about this post coz I got confuse reading your posts guys... Cheers :-)
denthorq wrote:
hmm... so Erick -eSoft and Eric -efrontier are two UNIQUE person! Sorry about this post coz I got confuse reading your posts guys... Cheers :-)


Indeed!

And people have quite a bit of problem with the spelling of my name too! ;)
Hmp... hmmmmm... sorry about that. Efortier... Did I get it right?
Anonymous wrote:
Hmp... hmmmmm... sorry about that. Efortier... Did I get it right?


Yep, two different people denthorq. :) I haven't worked yet with efortier but I get the feeling its going to be soon. ;)
You have no need to fool the screen to turn backlight on, you can use GetFromRegistry() to get the default backlight value setting and use SetToRegistry() to set new value into registry ( try to set about 3 hours = 36*36*3*1000)
so when you quit the game , just set em' back as the default value you got from the first function :)
Kethy::

What's the registry entry for that, and is it valid across all ppc devices?
Wow! That seems like a very good solution if it works across all devices. Would you mind posting the registry entry for configuring the backlight? Thanks!
The key is:

HKEY_CURRENT_USER\ControlPanel\Backlight

There's plenty of interesting, exotic settings in there too ;)

--Eric

PS: In the "Owner" key of my iPaq it says "Peter G. White". Who the hell is that??
Yeah , try these functions to do so
Code:

LONG RegOpenKeyEx(HKEY hKey,LPCWSTR lpSubKey,
DWORD ulOptions,REGSAM samDesired,
PHKEY phkResult );

- RegOpenKeyEx() to open registry
Code:

LONG RegQueryValueEx(HKEY hKey,LPCWSTR lpValueName,
LPDWORD lpReserved,LPDWORD lpType,
LPBYTE lpData,LPDWORD lpcbData );

- get your needed specified value (lpValueName)
from the registry,use phkResult from Open as hKey in Query

Code:

LONG RegSetValueEx(HKEY hKey,LPCWSTR lpValueName,
DWORD Reserved,DWORD dwType,
const BYTE *lpData,DWORD cbData );


In this case "lpSubKey" should be "ControlPanel\\Backlight"
What happens if someone ends your game before it can set the reg key back? I dont think its a good idea to set something that could be perminent.
Something like you remove battery instead of quitting game? Yeah that will be permanently set to registry, but if you need to get the last value back, you have to go to "setting"->"power management"
and set the time back...

I know this's not a good idea to do, but its just an Idea :) and it worked very well :)