2004-01-26 08:20:26 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
2007-04-28 17:27:08 +00:00
|
|
|
* Copyright (C) 2001-2007 The ScummVM project
|
2004-01-26 08:20:26 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2004-01-26 08:20:26 +00:00
|
|
|
*
|
2006-02-11 12:47:47 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2004-01-26 08:20:26 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2005-06-24 15:23:51 +00:00
|
|
|
#include "common/stdafx.h"
|
2004-01-26 08:20:26 +00:00
|
|
|
#include "CEDevice.h"
|
|
|
|
|
2004-05-09 14:53:05 +00:00
|
|
|
#include <SDL.h>
|
2004-01-26 08:20:26 +00:00
|
|
|
|
2004-05-30 13:24:51 +00:00
|
|
|
#include "wince-sdl.h"
|
|
|
|
|
2004-12-20 23:52:16 +00:00
|
|
|
static void (WINAPI* _SHIdleTimerReset)(void) = NULL;
|
|
|
|
static HANDLE (WINAPI* _SetPowerRequirement)(PVOID,int,ULONG,PVOID,ULONG) = NULL;
|
|
|
|
static DWORD (WINAPI* _ReleasePowerRequirement)(HANDLE) = NULL;
|
|
|
|
static HANDLE _hPowerManagement = NULL;
|
|
|
|
static DWORD _lastTime = 0;
|
2006-10-08 18:15:18 +00:00
|
|
|
#ifdef __GNUC__
|
|
|
|
extern "C" void WINAPI SystemIdleTimerReset(void);
|
|
|
|
#define SPI_GETPLATFORMTYPE 257
|
|
|
|
#endif
|
|
|
|
|
2004-12-20 23:52:16 +00:00
|
|
|
|
|
|
|
#define TIMER_TRIGGER 9000
|
|
|
|
|
|
|
|
// Power management code borrowed from MoDaCo & Betaplayer. Thanks !
|
|
|
|
void CEDevice::init() {
|
|
|
|
HINSTANCE dll = LoadLibrary(TEXT("aygshell.dll"));
|
|
|
|
if (dll) {
|
|
|
|
*(FARPROC*)&_SHIdleTimerReset = GetProcAddress(dll, MAKEINTRESOURCE(2006));
|
|
|
|
}
|
|
|
|
dll = LoadLibrary(TEXT("coredll.dll"));
|
|
|
|
if (dll) {
|
|
|
|
*(FARPROC*)&_SetPowerRequirement = GetProcAddress(dll, TEXT("SetPowerRequirement"));
|
|
|
|
*(FARPROC*)&_ReleasePowerRequirement = GetProcAddress(dll, TEXT("ReleasePowerRequirement"));
|
|
|
|
|
|
|
|
}
|
|
|
|
if (_SetPowerRequirement)
|
2006-10-08 18:15:18 +00:00
|
|
|
_hPowerManagement = _SetPowerRequirement((PVOID) TEXT("BKL1:"), 0, 1, (PVOID) NULL, 0);
|
2004-12-20 23:52:16 +00:00
|
|
|
_lastTime = GetTickCount();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CEDevice::end() {
|
|
|
|
if (_ReleasePowerRequirement && _hPowerManagement) {
|
|
|
|
_ReleasePowerRequirement(_hPowerManagement);
|
|
|
|
}
|
|
|
|
}
|
2004-05-09 14:53:05 +00:00
|
|
|
|
2004-12-20 23:52:16 +00:00
|
|
|
void CEDevice::wakeUp() {
|
|
|
|
DWORD currentTime = GetTickCount();
|
|
|
|
if (currentTime > _lastTime + TIMER_TRIGGER) {
|
|
|
|
_lastTime = currentTime;
|
|
|
|
SystemIdleTimerReset();
|
|
|
|
if (_SHIdleTimerReset)
|
|
|
|
_SHIdleTimerReset();
|
|
|
|
}
|
|
|
|
}
|
2004-05-09 14:53:05 +00:00
|
|
|
|
2004-01-26 08:20:26 +00:00
|
|
|
bool CEDevice::hasPocketPCResolution() {
|
2004-05-30 13:24:51 +00:00
|
|
|
if (OSystem_WINCE3::isOzone() && hasWideResolution())
|
|
|
|
return true;
|
|
|
|
return (OSystem_WINCE3::getScreenWidth() < 320 && OSystem_WINCE3::getScreenWidth() >= 240);
|
2004-01-26 08:20:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CEDevice::hasDesktopResolution() {
|
2004-05-30 13:24:51 +00:00
|
|
|
if (OSystem_WINCE3::isOzone() && hasWideResolution())
|
|
|
|
return true;
|
|
|
|
return (OSystem_WINCE3::getScreenWidth() >= 320);
|
2004-01-26 08:20:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CEDevice::hasWideResolution() {
|
2004-05-30 13:24:51 +00:00
|
|
|
return (OSystem_WINCE3::getScreenWidth() >= 640 || OSystem_WINCE3::getScreenHeight() >= 640);
|
2004-01-26 08:20:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CEDevice::hasSmartphoneResolution() {
|
2004-05-30 13:24:51 +00:00
|
|
|
return (OSystem_WINCE3::getScreenWidth() < 240);
|
2004-01-26 08:20:26 +00:00
|
|
|
}
|
|
|
|
|
2005-10-16 22:37:17 +00:00
|
|
|
bool CEDevice::isSmartphone() {
|
|
|
|
TCHAR platformType[100];
|
|
|
|
BOOL result = SystemParametersInfo(SPI_GETPLATFORMTYPE, sizeof(platformType), platformType, 0);
|
|
|
|
if (!result && GetLastError() == ERROR_ACCESS_DENIED)
|
|
|
|
return true;
|
2006-10-08 18:15:18 +00:00
|
|
|
return (_wcsnicmp(platformType, TEXT("SmartPhone"), 10) == 0);
|
2005-10-16 22:37:17 +00:00
|
|
|
}
|
|
|
|
|
2004-01-26 08:20:26 +00:00
|
|
|
Common::String CEDevice::getKeyName(unsigned int keyCode) {
|
2007-04-28 17:27:08 +00:00
|
|
|
switch (keyCode) {
|
|
|
|
case SDLK_F1:
|
|
|
|
return "Softkey A";
|
|
|
|
case SDLK_F2:
|
|
|
|
return "Softkey B";
|
|
|
|
case SDLK_F3:
|
|
|
|
return "Talk";
|
|
|
|
case SDLK_F4:
|
|
|
|
return "End";
|
|
|
|
case SDLK_APP1:
|
|
|
|
return "Application 1";
|
|
|
|
case SDLK_APP2:
|
|
|
|
return "Application 2";
|
|
|
|
case SDLK_APP3:
|
|
|
|
return "Application 3";
|
|
|
|
case SDLK_APP4:
|
|
|
|
return "Application 4";
|
|
|
|
case SDLK_APP5:
|
|
|
|
return "Application 5";
|
|
|
|
case SDLK_APP6:
|
|
|
|
return "Application 6";
|
|
|
|
case SDLK_LSUPER:
|
|
|
|
return "Home";
|
|
|
|
case SDLK_ESCAPE:
|
|
|
|
return "Back";
|
|
|
|
case SDLK_UP:
|
|
|
|
return "Up";
|
|
|
|
case SDLK_DOWN:
|
|
|
|
return "Down";
|
|
|
|
case SDLK_LEFT:
|
|
|
|
return "Left";
|
|
|
|
case SDLK_RIGHT:
|
|
|
|
return "Right";
|
|
|
|
case SDLK_RETURN:
|
|
|
|
return "Action";
|
|
|
|
case SDLK_F10:
|
|
|
|
return "Record";
|
|
|
|
case SDLK_F6:
|
|
|
|
return "Volume Up";
|
|
|
|
case SDLK_F7:
|
|
|
|
return "Volume Down";
|
|
|
|
case SDLK_F17:
|
|
|
|
return "Flip";
|
|
|
|
case SDLK_F18:
|
|
|
|
return "Power";
|
|
|
|
case SDLK_F16:
|
|
|
|
return "Speaker";
|
|
|
|
case SDLK_F8:
|
|
|
|
return "Star";
|
|
|
|
case SDLK_F9:
|
|
|
|
return "Pound";
|
|
|
|
case SDLK_F11:
|
|
|
|
return "Symbol";
|
|
|
|
case SDLK_F19:
|
|
|
|
return "Red Key";
|
|
|
|
case 0:
|
|
|
|
return "None";
|
|
|
|
default:
|
|
|
|
return SDL_GetKeyName((SDLKey)keyCode);
|
2004-05-09 14:53:05 +00:00
|
|
|
}
|
2004-01-26 08:20:26 +00:00
|
|
|
}
|