backlight always on in emulator

git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@928 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
knakos 2005-12-27 22:22:27 +00:00
parent c68dd1bddd
commit 5f95ed458f
1 changed files with 69 additions and 8 deletions

View File

@ -41,6 +41,9 @@ bool RequestRefresh = false;
OSystemWinCE* theOSystem = (OSystemWinCE*) NULL;
HWND hWnd;
uInt16 rotkeystate = 0;
int paddlespeed;
DWORD REG_bat, REG_ac, REG_disp;
void KeyCheck(void)
@ -63,14 +66,6 @@ void KeyCheck(void)
#endif
}
void CleanUp(void)
{
if(theOSystem) delete theOSystem;
GXCloseDisplay();
GXCloseInput();
}
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
static PAINTSTRUCT ps;
@ -124,11 +119,20 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
case WM_SETFOCUS:
case WM_ACTIVATE:
if (theOSystem)
{
if (theOSystem->eventHandler().doPause())
theOSystem->eventHandler().handleEvent(Event::Pause, theOSystem->eventHandler().state());
theOSystem->frameBuffer().refresh(false);
}
GXResume();
return 0;
case WM_KILLFOCUS:
case WM_HIBERNATE:
if (theOSystem)
if (!theOSystem->eventHandler().doPause())
theOSystem->eventHandler().handleEvent(Event::Pause, theOSystem->eventHandler().state());
GXSuspend();
return 0;
@ -142,6 +146,57 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
static DWORD reg_access(TCHAR *key, TCHAR *val, DWORD data)
{
HKEY regkey;
DWORD tmpval, cbdata;
if (RegOpenKeyEx(HKEY_CURRENT_USER, key, 0, 0, &regkey) != ERROR_SUCCESS)
return data;
cbdata = sizeof(DWORD);
if (RegQueryValueEx(regkey, val, NULL, NULL, (LPBYTE) &tmpval, &cbdata) != ERROR_SUCCESS)
{
RegCloseKey(regkey);
return data;
}
cbdata = sizeof(DWORD);
if (RegSetValueEx(regkey, val, 0, REG_DWORD, (LPBYTE) &data, cbdata) != ERROR_SUCCESS)
{
RegCloseKey(regkey);
return data;
}
RegCloseKey(regkey);
return tmpval;
}
static void backlight_xchg(void)
{
HANDLE h;
REG_bat = reg_access(_T("ControlPanel\\BackLight"), _T("BatteryTimeout"), REG_bat);
REG_ac = reg_access(_T("ControlPanel\\BackLight"), _T("ACTimeout"), REG_ac);
REG_disp = reg_access(_T("ControlPanel\\Power"), _T("Display"), REG_disp);
h = CreateEvent(NULL, FALSE, FALSE, _T("BackLightChangeEvent"));
if (h)
{
SetEvent(h);
CloseHandle(h);
}
}
void CleanUp(void)
{
if(theOSystem) delete theOSystem;
GXCloseDisplay();
GXCloseInput();
backlight_xchg();
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nShowCmd )
{
LPTSTR wndname = _T("PocketStella");
@ -153,6 +208,10 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLin
if (!hWnd) return 1;
SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
/* backlight */
REG_bat = REG_ac = REG_disp = 2 * 60 * 60 * 1000; /* 2hrs should do it */
backlight_xchg();
// pump the messages to get the window up
MSG msg;
while (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
@ -197,6 +256,8 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLin
}
theOSystem->createSound();
paddlespeed = theSettings.getInt("wce_smartphone_paddlespeed");
string romfile = ((string) getcwd()) + ((string) "\\") + theSettings.getString("GameFilename");
if (!FilesystemNode::fileExists(romfile))
theOSystem->createLauncher();