aboutsummaryrefslogtreecommitdiff
path: root/backends/wince
diff options
context:
space:
mode:
authorNicolas Bacca2004-12-20 23:52:16 +0000
committerNicolas Bacca2004-12-20 23:52:16 +0000
commit347815cdaee6f7207bb40692aa8727952496ff58 (patch)
tree736d02ff7469dae64f471985982f01066ab59519 /backends/wince
parent54d0384b0e213396ca93760112d3251b60fa6ae8 (diff)
downloadscummvm-rg350-347815cdaee6f7207bb40692aa8727952496ff58.tar.gz
scummvm-rg350-347815cdaee6f7207bb40692aa8727952496ff58.tar.bz2
scummvm-rg350-347815cdaee6f7207bb40692aa8727952496ff58.zip
Re-add Smartphone support (sorry for the year lag :p)
svn-id: r16215
Diffstat (limited to 'backends/wince')
-rw-r--r--backends/wince/CEActions.cpp12
-rw-r--r--backends/wince/CEActions.h3
-rw-r--r--backends/wince/CEActionsPocket.cpp9
-rw-r--r--backends/wince/CEActionsPocket.h4
-rw-r--r--backends/wince/CEActionsSmartphone.cpp54
-rw-r--r--backends/wince/CEActionsSmartphone.h8
-rw-r--r--backends/wince/CEDevice.cpp75
-rw-r--r--backends/wince/CEDevice.h9
-rw-r--r--backends/wince/CEScaler.cpp4
-rw-r--r--backends/wince/CEScaler.h4
10 files changed, 136 insertions, 46 deletions
diff --git a/backends/wince/CEActions.cpp b/backends/wince/CEActions.cpp
index a10b056775..078e0f75a1 100644
--- a/backends/wince/CEActions.cpp
+++ b/backends/wince/CEActions.cpp
@@ -47,17 +47,21 @@ CEActions::~CEActions() {
void CEActions::init(GameDetector &detector) {
if (!CEDevice::hasSmartphoneResolution())
CEActionsPocket::init(detector);
-#ifdef WIN32_PLATFORM_WFSP
+//#ifdef WIN32_PLATFORM_WFSP
else
CEActionsSmartphone::init(detector);
-#endif
+//#endif
}
-void CEActions::initInstance(OSystem_WINCE3 *mainSystem) {
+void CEActions::initInstanceMain(OSystem_WINCE3 *mainSystem) {
_mainSystem = mainSystem;
+}
+
+void CEActions::initInstanceGame() {
_instance->_initialized = true;
}
+
bool CEActions::initialized() {
return _initialized;
}
@@ -82,7 +86,7 @@ bool CEActions::performMapped(unsigned int keyCode, bool pushed) {
int i;
for (i=0; i<size(); i++) {
- if (_action_mapping[i] == keyCode)
+ if (_action_mapping[i] == keyCode && _action_enabled[i])
return perform((ActionType)i, pushed);
}
diff --git a/backends/wince/CEActions.h b/backends/wince/CEActions.h
index 128af42766..be07e558ac 100644
--- a/backends/wince/CEActions.h
+++ b/backends/wince/CEActions.h
@@ -41,7 +41,8 @@ class CEActions {
public:
static CEActions* Instance();
static void init(GameDetector &detector);
- virtual void initInstance(OSystem_WINCE3 *mainSystem);
+ virtual void initInstanceMain(OSystem_WINCE3 *mainSystem);
+ virtual void initInstanceGame();
bool initialized();
// Actions
diff --git a/backends/wince/CEActionsPocket.cpp b/backends/wince/CEActionsPocket.cpp
index f382cff80f..06bfc24452 100644
--- a/backends/wince/CEActionsPocket.cpp
+++ b/backends/wince/CEActionsPocket.cpp
@@ -82,7 +82,12 @@ CEActionsPocket::CEActionsPocket(GameDetector &detector) :
}
-void CEActionsPocket::initInstance(OSystem_WINCE3 *mainSystem) {
+void CEActionsPocket::initInstanceMain(OSystem_WINCE3 *mainSystem) {
+ // Nothing generic to do for Pocket PC
+ CEActions::initInstanceMain(mainSystem);
+}
+
+void CEActionsPocket::initInstanceGame() {
bool is_simon = (strncmp(_detector->_targetName.c_str(), "simon", 5) == 0);
bool is_sword1 = (_detector->_targetName == "sword1");
bool is_sword2 = (strcmp(_detector->_targetName.c_str(), "sword2") == 0);
@@ -90,7 +95,7 @@ void CEActionsPocket::initInstance(OSystem_WINCE3 *mainSystem) {
bool is_sky = (_detector->_targetName == "sky");
bool is_comi = (strncmp(_detector->_targetName.c_str(), "comi", 4) == 0);
- CEActions::initInstance(mainSystem);
+ CEActions::initInstanceGame();
// See if a right click mapping could be needed
if (is_sword1 || is_sword2 || is_sky || is_queen || is_comi ||
diff --git a/backends/wince/CEActionsPocket.h b/backends/wince/CEActionsPocket.h
index 348aba5553..f23937895b 100644
--- a/backends/wince/CEActionsPocket.h
+++ b/backends/wince/CEActionsPocket.h
@@ -58,8 +58,10 @@ class CEActionsPocket : public CEActions {
bool perform(ActionType action, bool pushed = true);
String actionName(ActionType action);
int size();
+
static void init(GameDetector &detector);
- void initInstance(OSystem_WINCE3 *mainSystem);
+ void initInstanceMain(OSystem_WINCE3 *mainSystem);
+ void initInstanceGame();
// Action domain
String domain();
diff --git a/backends/wince/CEActionsSmartphone.cpp b/backends/wince/CEActionsSmartphone.cpp
index bf5e584412..1dfd7af190 100644
--- a/backends/wince/CEActionsSmartphone.cpp
+++ b/backends/wince/CEActionsSmartphone.cpp
@@ -19,12 +19,13 @@
*
*/
+//#define SIMU_SMARTPHONE 1
-#ifdef WIN32_PLATFORM_WFSP
+//#ifdef WIN32_PLATFORM_WFSP
#include "stdafx.h"
-#include "CEActionsPocket.h"
-#include "KeysBuffer.h"
+#include "CEActionsSmartphone.h"
+#include "EventsBuffer.h"
#include "gui/message.h"
@@ -44,6 +45,12 @@ const String smartphoneActionNames[] = {
"Zone"
};
+#ifdef SIMU_SMARTPHONE
+const int ACTIONS_SMARTPHONE_DEFAULT[] = { 0x111, 0x112, 0x114, 0x113, 0x11a, 0x11b, VK_LWIN, VK_ESCAPE, VK_F8 };
+#else
+const int ACTIONS_SMARTPHONE_DEFAULT[] = { '4', '6', '8', '2', 0x11a, 0x11b, '0', VK_ESCAPE, VK_F10 };
+#endif
+
void CEActionsSmartphone::init(GameDetector &detector) {
_instance = new CEActionsSmartphone(detector);
}
@@ -71,25 +78,15 @@ CEActionsSmartphone::CEActionsSmartphone(GameDetector &detector) :
int i;
for (i=0; i<SMARTPHONE_ACTION_LAST; i++) {
- _action_mapping[i] = 0;
+ _action_mapping[i] = ACTIONS_SMARTPHONE_DEFAULT[i];
_action_enabled[i] = false;
}
}
-void CEActionsSmartphone::initInstance(OSystem_WINCE3 *mainSystem) {
-{
- int i;
- bool is_simon = (strncmp(_detector->_targetName.c_str(), "simon", 5) == 0);
- bool is_sky = (_detector->_targetName == "sky");
-
- CEActions::initInstance(mainSystem);
-
- // See if a right click mapping could be needed
- if (is_sky || _detector->_targetName == "samnmax")
- _right_click_needed = true;
-
- // Initialize keys for different actions
+void CEActionsSmartphone::initInstanceMain(OSystem_WINCE3 *mainSystem) {
+ CEActions::initInstanceMain(mainSystem);
+
// Mouse Up
_action_enabled[SMARTPHONE_ACTION_UP] = true;
// Mouse Down
@@ -101,7 +98,21 @@ void CEActionsSmartphone::initInstance(OSystem_WINCE3 *mainSystem) {
// Left Click
_action_enabled[SMARTPHONE_ACTION_LEFTCLICK] = true;
// Right Click
- _action_enabled[ACTION_RIGHTCLICK] = true;
+ _action_enabled[SMARTPHONE_ACTION_RIGHTCLICK] = true;
+}
+
+void CEActionsSmartphone::initInstanceGame() {
+ bool is_simon = (strncmp(_detector->_targetName.c_str(), "simon", 5) == 0);
+ bool is_sky = (_detector->_targetName == "sky");
+ bool is_queen = (_detector->_targetName == "queen");
+
+ CEActions::initInstanceGame();
+
+ // See if a right click mapping could be needed
+ if (is_sky || _detector->_targetName == "samnmax")
+ _right_click_needed = true;
+
+ // Initialize keys for different actions
// Save
if (is_simon)
_action_enabled[SMARTPHONE_ACTION_SAVE] = false;
@@ -133,10 +144,9 @@ void CEActionsSmartphone::initInstance(OSystem_WINCE3 *mainSystem) {
CEActionsSmartphone::~CEActionsSmartphone() {
}
-bool CEActionsSmartphone::perform(ActionType action, bool pushed = true) {
+bool CEActionsSmartphone::perform(ActionType action, bool pushed) {
if (!pushed) {
- _mainSystem->clear_key_repeat();
- return true;
+ return false;
}
switch (action) {
@@ -170,4 +180,4 @@ bool CEActionsSmartphone::perform(ActionType action, bool pushed = true) {
return false;
}
-#endif
+//#endif
diff --git a/backends/wince/CEActionsSmartphone.h b/backends/wince/CEActionsSmartphone.h
index bbb9d244dc..d780121cca 100644
--- a/backends/wince/CEActionsSmartphone.h
+++ b/backends/wince/CEActionsSmartphone.h
@@ -22,7 +22,7 @@
#ifndef CEACTIONSSMARTPHONE
#define CEACTIONSSMARTPHONE
-#ifdef WIN32_PLATFORM_WFSP
+//#ifdef WIN32_PLATFORM_WFSP
#include "common/stdafx.h"
#include "common/scummsys.h"
@@ -59,7 +59,8 @@ class CEActionsSmartphone : public CEActions {
String actionName(ActionType action);
int size();
static void init(GameDetector &detector);
- void initInstance(OSystem_WINCE3 *mainSystem);
+ void initInstanceMain(OSystem_WINCE3 *mainSystem);
+ void initInstanceGame();
// Action domain
String domain();
@@ -68,8 +69,9 @@ class CEActionsSmartphone : public CEActions {
~CEActionsSmartphone();
private:
CEActionsSmartphone(GameDetector &detector);
+ bool _right_click_needed;
};
#endif
-#endif \ No newline at end of file
+//#endif \ No newline at end of file
diff --git a/backends/wince/CEDevice.cpp b/backends/wince/CEDevice.cpp
index 0ef165f6f2..05389de03e 100644
--- a/backends/wince/CEDevice.cpp
+++ b/backends/wince/CEDevice.cpp
@@ -31,7 +31,7 @@
#define KEY_INBOX 0xc3
#define KEY_TASK 0xc4
-#ifdef WIN32_PLATFORM_WFSP
+//#ifdef WIN32_PLATFORM_WFSP
const char* SMARTPHONE_KEYS_NAME[] = {
"1", "2", "3","4", "5", "6", "7", "8", "9", "*", "0", "#",
"Home", "Back", "Up", "Down", "Left", "Right", "Action", "Hang up", "Call",
@@ -39,32 +39,99 @@ const char* SMARTPHONE_KEYS_NAME[] = {
0
};
+// Old mapping from the previous (non SDL) version. To be forgotten.
+/*
const int SMARTPHONE_KEYS_MAPPING[] = {
'1', '2', '3', '4', '5', '6', '7', '8', '9', VK_F8, '0', VK_F9,
VK_LWIN, VK_ESCAPE, VK_UP, VK_DOWN, VK_LEFT, VK_RIGHT, VK_RETURN, VK_F4, VK_F3,
VK_F1, VK_F2, VK_F18, VK_F6, VK_F7, VK_F10, 0xff, 0
};
-#endif
+*/
+
+// FIXME : Home and Record are not mapped
+const int SMARTPHONE_KEYS_MAPPING[] = {
+ '1', '2', '3', '4', '5', '6', '7', '8', '9', VK_F9, '0', VK_F10,
+ 0xFF, VK_ESCAPE, 0x113, 0x114, 0x111, 0x112, VK_RETURN, 0x11D, 0x11C,
+ 0x11A, 0x11B, 0x11D, 0x11F, 0x120, 0xFF, 0
+};
+
+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;
+
+#define TIMER_TRIGGER 9000
+
+//#endif
+
+// 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)
+ _hPowerManagement = _SetPowerRequirement(TEXT("BKL1:"), 0, 1, NULL, 0);
+ _lastTime = GetTickCount();
+}
+
+void CEDevice::end() {
+ if (_ReleasePowerRequirement && _hPowerManagement) {
+ _ReleasePowerRequirement(_hPowerManagement);
+ }
+}
+void CEDevice::wakeUp() {
+ DWORD currentTime = GetTickCount();
+ if (currentTime > _lastTime + TIMER_TRIGGER) {
+ _lastTime = currentTime;
+ SystemIdleTimerReset();
+ if (_SHIdleTimerReset)
+ _SHIdleTimerReset();
+ }
+}
bool CEDevice::hasPocketPCResolution() {
+#ifdef SIMU_SMARTPHONE
+ return false;
+#else
if (OSystem_WINCE3::isOzone() && hasWideResolution())
return true;
return (OSystem_WINCE3::getScreenWidth() < 320 && OSystem_WINCE3::getScreenWidth() >= 240);
+#endif
}
bool CEDevice::hasDesktopResolution() {
+#ifdef SIMU_SMARTPHONE
+ return false;
+#else
if (OSystem_WINCE3::isOzone() && hasWideResolution())
return true;
return (OSystem_WINCE3::getScreenWidth() >= 320);
+#endif
}
bool CEDevice::hasWideResolution() {
+#ifdef SIMU_SMARTPHONE
+ return false;
+#else
return (OSystem_WINCE3::getScreenWidth() >= 640 || OSystem_WINCE3::getScreenHeight() >= 640);
+#endif
}
bool CEDevice::hasSmartphoneResolution() {
+#ifdef SIMU_SMARTPHONE
+ return true;
+#else
return (OSystem_WINCE3::getScreenWidth() < 240);
+#endif
}
Common::String CEDevice::getKeyName(unsigned int keyCode) {
@@ -90,7 +157,7 @@ Common::String CEDevice::getKeyName(unsigned int keyCode) {
if (keyCode == SDLK_F4)
return "F4 (hard 4)";
-#ifdef WIN32_PLATFORM_WFSP
+//#ifdef WIN32_PLATFORM_WFSP
if (hasSmartphoneResolution()) {
int i = 0;
while (SMARTPHONE_KEYS_MAPPING[i]) {
@@ -99,7 +166,7 @@ Common::String CEDevice::getKeyName(unsigned int keyCode) {
i++;
}
}
-#endif
+//#endif
sprintf(key_name, "Key %.4x", keyCode);
return key_name;
diff --git a/backends/wince/CEDevice.h b/backends/wince/CEDevice.h
index b8b0dd3f8f..d32b19d7d1 100644
--- a/backends/wince/CEDevice.h
+++ b/backends/wince/CEDevice.h
@@ -31,15 +31,14 @@
class CEDevice {
public:
+ static void init();
+ static void end();
+ static void wakeUp();
static bool hasPocketPCResolution();
static bool hasDesktopResolution();
static bool hasWideResolution();
static bool hasSmartphoneResolution();
- static Common::String getKeyName(unsigned int keyCode);
- private:
- typedef int (*tGXVoidFunction)(void);
- typedef struct GXKeyList (*tGXGetDefaultKeys)(int);
-
+ static Common::String getKeyName(unsigned int keyCode);
};
#endif
diff --git a/backends/wince/CEScaler.cpp b/backends/wince/CEScaler.cpp
index 189abe0134..e1cda2fd1b 100644
--- a/backends/wince/CEScaler.cpp
+++ b/backends/wince/CEScaler.cpp
@@ -120,7 +120,7 @@ void PocketPCHalfZoom(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint3
}
}
-#ifdef WIN32_PLATFORM_WFSP
+//#ifdef WIN32_PLATFORM_WFSP
void SmartphoneLandscape(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) {
uint8 *work;
int i;
@@ -151,5 +151,5 @@ void SmartphoneLandscape(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, ui
}
}
}
-#endif
+//#endif
diff --git a/backends/wince/CEScaler.h b/backends/wince/CEScaler.h
index df6d2364ce..0b41fa3fc5 100644
--- a/backends/wince/CEScaler.h
+++ b/backends/wince/CEScaler.h
@@ -31,9 +31,9 @@
DECLARE_SCALER(PocketPCPortrait);
DECLARE_SCALER(PocketPCHalf);
DECLARE_SCALER(PocketPCHalfZoom);
-#ifdef WIN32_PLATFORM_WFSP
+//#ifdef WIN32_PLATFORM_WFSP
DECLARE_SCALER(SmartphoneLandscape);
-#endif
+//#endif
void initCEScaler(void);