From: Kostas N. <kn...@us...> - 2005-12-27 22:22:35
|
Update of /cvsroot/stella/stella/src/wince In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21863 Modified Files: PocketStella.cpp Log Message: backlight always on in emulator Index: PocketStella.cpp =================================================================== RCS file: /cvsroot/stella/stella/src/wince/PocketStella.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PocketStella.cpp 24 Oct 2005 18:10:17 -0000 1.3 --- PocketStella.cpp 27 Dec 2005 22:22:27 -0000 1.4 *************** *** 42,45 **** --- 42,48 ---- HWND hWnd; uInt16 rotkeystate = 0; + int paddlespeed; + + DWORD REG_bat, REG_ac, REG_disp; *************** *** 64,75 **** } - - void CleanUp(void) - { - if(theOSystem) delete theOSystem; - GXCloseDisplay(); - GXCloseInput(); - } - LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) { --- 67,70 ---- *************** *** 125,128 **** --- 120,129 ---- 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; *************** *** 130,133 **** --- 131,137 ---- case WM_KILLFOCUS: case WM_HIBERNATE: + if (theOSystem) + if (!theOSystem->eventHandler().doPause()) + theOSystem->eventHandler().handleEvent(Event::Pause, theOSystem->eventHandler().state()); GXSuspend(); return 0; *************** *** 143,146 **** --- 147,201 ---- } + static DWORD reg_access(TCHAR *key, TCHAR *val, DWORD data) + { + HKEY regkey; + DWORD tmpval, cbdata; + + if (RegOpenKeyEx(HKEY_CURRENT_USER, key, 0, 0, ®key) != 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 ) { *************** *** 153,156 **** --- 208,215 ---- 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 *************** *** 198,201 **** --- 257,262 ---- theOSystem->createSound(); + paddlespeed = theSettings.getInt("wce_smartphone_paddlespeed"); + string romfile = ((string) getcwd()) + ((string) "\\") + theSettings.getString("GameFilename"); if (!FilesystemNode::fileExists(romfile)) |