aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/wince
diff options
context:
space:
mode:
authorDavid Corrales2007-05-26 20:23:24 +0000
committerDavid Corrales2007-05-26 20:23:24 +0000
commit3646c968c9578c2a94d65ebd5fb06ec835f8c51d (patch)
tree8b57b339ebb31a1d7a67f1678aa5dc5c7759070a /backends/platform/wince
parentd1f56d93f934150f4b579c2e90564e2bf035f113 (diff)
parentac45c5b33d834acbc9718f89be76e49d403a4d2c (diff)
downloadscummvm-rg350-3646c968c9578c2a94d65ebd5fb06ec835f8c51d.tar.gz
scummvm-rg350-3646c968c9578c2a94d65ebd5fb06ec835f8c51d.tar.bz2
scummvm-rg350-3646c968c9578c2a94d65ebd5fb06ec835f8c51d.zip
Merged the fs branch with trunk. r26472:26948
svn-id: r26949
Diffstat (limited to 'backends/platform/wince')
-rw-r--r--backends/platform/wince/CEActionsPocket.cpp43
-rw-r--r--backends/platform/wince/CEActionsPocket.h49
-rw-r--r--backends/platform/wince/CEActionsSmartphone.cpp42
-rw-r--r--backends/platform/wince/CEActionsSmartphone.h42
-rw-r--r--backends/platform/wince/CEDevice.cpp224
-rw-r--r--backends/platform/wince/CEDevice.h9
-rw-r--r--backends/platform/wince/CEKeysDialog.cpp126
-rw-r--r--backends/platform/wince/CEKeysDialog.h46
-rw-r--r--backends/platform/wince/CEScaler.cpp64
-rw-r--r--backends/platform/wince/CEgui/ItemAction.cpp5
-rw-r--r--backends/platform/wince/Makefile12
-rw-r--r--backends/platform/wince/wince-sdl.cpp402
-rw-r--r--backends/platform/wince/wince-sdl.h2
13 files changed, 451 insertions, 615 deletions
diff --git a/backends/platform/wince/CEActionsPocket.cpp b/backends/platform/wince/CEActionsPocket.cpp
index 73d8dfe334..6cddf62695 100644
--- a/backends/platform/wince/CEActionsPocket.cpp
+++ b/backends/platform/wince/CEActionsPocket.cpp
@@ -1,5 +1,5 @@
/* ScummVM - Scumm Interpreter
- * Copyright (C) 2001-2006 The ScummVM project
+ * Copyright (C) 2001-2007 The ScummVM project
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -24,13 +24,9 @@
#include "common/stdafx.h"
#include "CEActionsPocket.h"
#include "EventsBuffer.h"
-
#include "gui/message.h"
-
#include "scumm/scumm.h"
-
#include "common/config-manager.h"
-
#include "gui/KeysDialog.h"
#ifdef _WIN32_WCE
@@ -42,20 +38,20 @@ const String pocketActionNames[] = {
"Save",
"Quit",
"Skip",
- "Hide",
- "Keyboard",
- "Sound",
+ "Hide Toolbar",
+ "Show Keyboard",
+ "Sound on/off",
"Right click",
- "Cursor",
+ "Show/Hide Cursor",
"Free look",
"Zoom up",
"Zoom down",
"FT Cheat",
"Bind Keys",
- "Up",
- "Down",
- "Left",
- "Right",
+ "Cursor Up",
+ "Cursor Down",
+ "Cursor Left",
+ "Cursor Right",
"Left Click",
};
@@ -100,11 +96,11 @@ GUI::Actions()
_action_enabled[POCKET_ACTION_DOWN] = true;
_action_enabled[POCKET_ACTION_LEFT] = true;
_action_enabled[POCKET_ACTION_RIGHT] = true;
- _action_mapping[POCKET_ACTION_LEFTCLICK] = VK_RETURN;
- _action_mapping[POCKET_ACTION_UP] = 0x111;
- _action_mapping[POCKET_ACTION_DOWN] = 0x112;
- _action_mapping[POCKET_ACTION_LEFT] = 0x114;
- _action_mapping[POCKET_ACTION_RIGHT] = 0x113;
+ _action_mapping[POCKET_ACTION_LEFTCLICK] = SDLK_RETURN;
+ _action_mapping[POCKET_ACTION_UP] = SDLK_UP;
+ _action_mapping[POCKET_ACTION_DOWN] = SDLK_DOWN;
+ _action_mapping[POCKET_ACTION_LEFT] = SDLK_LEFT;
+ _action_mapping[POCKET_ACTION_RIGHT] = SDLK_RIGHT;
}
void CEActionsPocket::initInstanceMain(OSystem *mainSystem) {
@@ -184,7 +180,7 @@ void CEActionsPocket::initInstanceGame() {
// Freelook
_action_enabled[POCKET_ACTION_FREELOOK] = true;
// Zoom
- if (is_sword1 || is_sword2 || is_comi) {
+ if (is_sword1 || is_sword2 || is_comi || is_touche) {
_zoom_needed = true;
_action_enabled[POCKET_ACTION_ZOOM_UP] = true;
_action_enabled[POCKET_ACTION_ZOOM_DOWN] = true;
@@ -244,9 +240,9 @@ bool CEActionsPocket::perform(GUI::ActionType action, bool pushed) {
case POCKET_ACTION_CURSOR:
_CESystem->swap_mouse_visibility();
return true;
- case POCKET_ACTION_FREELOOK:
- _CESystem->swap_freeLook();
- return true;
+ case POCKET_ACTION_FREELOOK:
+ _CESystem->swap_freeLook();
+ return true;
case POCKET_ACTION_ZOOM_UP:
_CESystem->swap_zoom_up();
return true;
@@ -270,7 +266,7 @@ bool CEActionsPocket::perform(GUI::ActionType action, bool pushed) {
return true;
case POCKET_ACTION_QUIT:
{
- GUI::MessageDialog alert("Do you want to quit ?", "Yes", "No");
+ GUI::MessageDialog alert(" Are you sure you want to quit ? ", "Yes", "No");
if (alert.runModal() == GUI::kMessageOK)
_mainSystem->quit();
return true;
@@ -309,4 +305,3 @@ bool CEActionsPocket::needsZoomMapping() {
else
return (_action_mapping[POCKET_ACTION_ZOOM_UP] == 0 || _action_mapping[POCKET_ACTION_ZOOM_DOWN] == 0);
}
-
diff --git a/backends/platform/wince/CEActionsPocket.h b/backends/platform/wince/CEActionsPocket.h
index f3d8f482cb..d20829f3f6 100644
--- a/backends/platform/wince/CEActionsPocket.h
+++ b/backends/platform/wince/CEActionsPocket.h
@@ -1,5 +1,5 @@
/* ScummVM - Scumm Interpreter
- * Copyright (C) 2001-2006 The ScummVM project
+ * Copyright (C) 2001-2007 The ScummVM project
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -26,37 +26,34 @@
#include "common/stdafx.h"
#include "common/scummsys.h"
#include "common/system.h"
-
-
#include "wince-sdl.h"
#include "gui/Key.h"
-
#include "gui/Actions.h"
-#define POCKET_ACTION_VERSION 4
+#define POCKET_ACTION_VERSION 5
enum pocketActionType {
- POCKET_ACTION_PAUSE = 0,
- POCKET_ACTION_SAVE,
- POCKET_ACTION_QUIT,
- POCKET_ACTION_SKIP,
- POCKET_ACTION_HIDE,
- POCKET_ACTION_KEYBOARD,
- POCKET_ACTION_SOUND,
- POCKET_ACTION_RIGHTCLICK,
- POCKET_ACTION_CURSOR,
- POCKET_ACTION_FREELOOK,
- POCKET_ACTION_ZOOM_UP,
- POCKET_ACTION_ZOOM_DOWN,
- POCKET_ACTION_FT_CHEAT,
- POCKET_ACTION_BINDKEYS,
- POCKET_ACTION_UP,
- POCKET_ACTION_DOWN,
- POCKET_ACTION_LEFT,
- POCKET_ACTION_RIGHT,
- POCKET_ACTION_LEFTCLICK,
-
- POCKET_ACTION_LAST
+ POCKET_ACTION_PAUSE = 0,
+ POCKET_ACTION_SAVE,
+ POCKET_ACTION_QUIT,
+ POCKET_ACTION_SKIP,
+ POCKET_ACTION_HIDE,
+ POCKET_ACTION_KEYBOARD,
+ POCKET_ACTION_SOUND,
+ POCKET_ACTION_RIGHTCLICK,
+ POCKET_ACTION_CURSOR,
+ POCKET_ACTION_FREELOOK,
+ POCKET_ACTION_ZOOM_UP,
+ POCKET_ACTION_ZOOM_DOWN,
+ POCKET_ACTION_FT_CHEAT,
+ POCKET_ACTION_BINDKEYS,
+ POCKET_ACTION_UP,
+ POCKET_ACTION_DOWN,
+ POCKET_ACTION_LEFT,
+ POCKET_ACTION_RIGHT,
+ POCKET_ACTION_LEFTCLICK,
+
+ POCKET_ACTION_LAST
};
class CEActionsPocket : public GUI::Actions {
diff --git a/backends/platform/wince/CEActionsSmartphone.cpp b/backends/platform/wince/CEActionsSmartphone.cpp
index 8d9b18b46c..1d53b01dc4 100644
--- a/backends/platform/wince/CEActionsSmartphone.cpp
+++ b/backends/platform/wince/CEActionsSmartphone.cpp
@@ -1,5 +1,5 @@
/* ScummVM - Scumm Interpreter
- * Copyright (C) 2001-2006 The ScummVM project
+ * Copyright (C) 2001-2007 The ScummVM project
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -20,25 +20,15 @@
*
*/
-//#define SIMU_SMARTPHONE 1
-
-//#ifdef WIN32_PLATFORM_WFSP
-
#include "common/stdafx.h"
#include "CEActionsSmartphone.h"
#include "EventsBuffer.h"
-
#include "gui/message.h"
-
#include "scumm/scumm.h"
-
#include "common/config-manager.h"
-
#include "gui/KeysDialog.h"
-#ifdef _WIN32_WCE
#define KEY_ALL_SKIP 3457
-#endif
const String smartphoneActionNames[] = {
"Up",
@@ -53,14 +43,11 @@ const String smartphoneActionNames[] = {
"FT Cheat",
"Bind Keys",
"Keyboard",
- "Rotate"
+ "Rotate",
+ "Quit"
};
-#ifdef SIMU_SMARTPHONE
-const int ACTIONS_SMARTPHONE_DEFAULT[] = { 0x111, 0x112, 0x114, 0x113, 0x11a, 0x11b, VK_LWIN, VK_ESCAPE, VK_F8, 0, VK_RETURN, 0, 0 };
-#else
-const int ACTIONS_SMARTPHONE_DEFAULT[] = { '4', '6', '8', '2', 0x11a, 0x11b, '0', VK_ESCAPE, '9', 0, VK_RETURN, 0, 0 };
-#endif
+const int ACTIONS_SMARTPHONE_DEFAULT[] = { SDLK_UP, SDLK_DOWN, SDLK_LEFT, SDLK_RIGHT, SDLK_F1, SDLK_F2, SDLK_F3, SDLK_ESCAPE, SDLK_9, SDLK_8, SDLK_F4, SDLK_RETURN, SDLK_5, SDLK_0 };
void CEActionsSmartphone::init() {
_instance = new CEActionsSmartphone();
@@ -98,22 +85,18 @@ void CEActionsSmartphone::initInstanceMain(OSystem *mainSystem) {
_CESystem = static_cast<OSystem_WINCE3*>(mainSystem);
GUI_Actions::initInstanceMain(mainSystem);
- // Mouse Up
+
+ // These actions are always on
_action_enabled[SMARTPHONE_ACTION_UP] = true;
- // Mouse Down
_action_enabled[SMARTPHONE_ACTION_DOWN] = true;
- // Mouse Left
_action_enabled[SMARTPHONE_ACTION_LEFT] = true;
- // Mouse Right
_action_enabled[SMARTPHONE_ACTION_RIGHT] = true;
- // Left Click
_action_enabled[SMARTPHONE_ACTION_LEFTCLICK] = true;
- // Right Click
_action_enabled[SMARTPHONE_ACTION_RIGHTCLICK] = true;
- // Show virtual keyboard
_action_enabled[SMARTPHONE_ACTION_KEYBOARD] = true;
- // Rotate display
_action_enabled[SMARTPHONE_ACTION_ROTATE] = true;
+ _action_enabled[SMARTPHONE_ACTION_QUIT] = true;
+ _action_enabled[SMARTPHONE_ACTION_BINDKEYS] = true;
}
void CEActionsSmartphone::initInstanceGame() {
@@ -239,9 +222,14 @@ bool CEActionsSmartphone::perform(GUI::ActionType action, bool pushed) {
case SMARTPHONE_ACTION_ROTATE:
_CESystem->smartphone_rotate_display();
return true;
+ case SMARTPHONE_ACTION_QUIT:
+ {
+ GUI::MessageDialog alert(" Are you sure you want to quit ? ", "Yes", "No");
+ if (alert.runModal() == GUI::kMessageOK)
+ _mainSystem->quit();
+ return true;
+ }
}
return false;
}
-
-//#endif
diff --git a/backends/platform/wince/CEActionsSmartphone.h b/backends/platform/wince/CEActionsSmartphone.h
index b100680d9d..3ba57f1239 100644
--- a/backends/platform/wince/CEActionsSmartphone.h
+++ b/backends/platform/wince/CEActionsSmartphone.h
@@ -1,5 +1,5 @@
/* ScummVM - Scumm Interpreter
- * Copyright (C) 2001-2006 The ScummVM project
+ * Copyright (C) 2001-2007 The ScummVM project
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -23,36 +23,32 @@
#ifndef CEACTIONSSMARTPHONE
#define CEACTIONSSMARTPHONE
-//#ifdef WIN32_PLATFORM_WFSP
-
#include "common/stdafx.h"
#include "common/scummsys.h"
#include "common/system.h"
-
-
#include "wince-sdl.h"
#include "gui/Key.h"
-
#include "gui/Actions.h"
-#define SMARTPHONE_ACTION_VERSION 4
+#define SMARTPHONE_ACTION_VERSION 5
enum smartphoneActionType {
- SMARTPHONE_ACTION_UP = 0,
- SMARTPHONE_ACTION_DOWN,
- SMARTPHONE_ACTION_LEFT,
- SMARTPHONE_ACTION_RIGHT,
- SMARTPHONE_ACTION_LEFTCLICK,
- SMARTPHONE_ACTION_RIGHTCLICK,
- SMARTPHONE_ACTION_SAVE,
- SMARTPHONE_ACTION_SKIP,
- SMARTPHONE_ACTION_ZONE,
- SMARTPHONE_ACTION_FT_CHEAT,
- SMARTPHONE_ACTION_BINDKEYS,
- SMARTPHONE_ACTION_KEYBOARD,
- SMARTPHONE_ACTION_ROTATE,
-
- SMARTPHONE_ACTION_LAST
+ SMARTPHONE_ACTION_UP = 0,
+ SMARTPHONE_ACTION_DOWN,
+ SMARTPHONE_ACTION_LEFT,
+ SMARTPHONE_ACTION_RIGHT,
+ SMARTPHONE_ACTION_LEFTCLICK,
+ SMARTPHONE_ACTION_RIGHTCLICK,
+ SMARTPHONE_ACTION_SAVE,
+ SMARTPHONE_ACTION_SKIP,
+ SMARTPHONE_ACTION_ZONE,
+ SMARTPHONE_ACTION_FT_CHEAT,
+ SMARTPHONE_ACTION_BINDKEYS,
+ SMARTPHONE_ACTION_KEYBOARD,
+ SMARTPHONE_ACTION_ROTATE,
+ SMARTPHONE_ACTION_QUIT,
+
+ SMARTPHONE_ACTION_LAST
};
@@ -78,5 +74,3 @@ class CEActionsSmartphone : public GUI::Actions {
};
#endif
-
-//#endif
diff --git a/backends/platform/wince/CEDevice.cpp b/backends/platform/wince/CEDevice.cpp
index 495ba1b274..5a60c76bfe 100644
--- a/backends/platform/wince/CEDevice.cpp
+++ b/backends/platform/wince/CEDevice.cpp
@@ -1,5 +1,5 @@
/* ScummVM - Scumm Interpreter
- * Copyright (C) 2001-2006 The ScummVM project
+ * Copyright (C) 2001-2007 The ScummVM project
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -20,9 +20,6 @@
*
*/
-//#define SIMU_SMARTPHONE 1
-//#define SIMU_SMARTPHONE_2005 1
-
#include "common/stdafx.h"
#include "CEDevice.h"
@@ -30,52 +27,63 @@
#include "wince-sdl.h"
-#define KEY_CALENDAR 0xc1
-#define KEY_CONTACTS 0xc2
-#define KEY_INBOX 0xc3
-#define KEY_TASK 0xc4
-
-//#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",
- "Soft 1", "Soft 2", "Power", "Volume Up" ,"Volume Down", "Record", "None",
- 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
-};
-*/
-
-// 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;
+static DWORD REG_bat = 0, REG_ac = 0, REG_disp = 0, bat_timeout = 0;
#ifdef __GNUC__
extern "C" void WINAPI SystemIdleTimerReset(void);
-#define SPI_GETPLATFORMTYPE 257
+#define SPI_GETPLATFORMTYPE 257
+#define SPI_SETBATTERYIDLETIMEOUT 251
+#define SPI_GETBATTERYIDLETIMEOUT 252
#endif
-
#define TIMER_TRIGGER 9000
-//#endif
+DWORD CEDevice::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;
+}
+
+void CEDevice::backlight_xchg() {
+ HANDLE h;
+
+ REG_bat = reg_access(TEXT("ControlPanel\\BackLight"), TEXT("BatteryTimeout"), REG_bat);
+ REG_ac = reg_access(TEXT("ControlPanel\\BackLight"), TEXT("ACTimeout"), REG_ac);
+ REG_disp = reg_access(TEXT("ControlPanel\\Power"), TEXT("Display"), REG_disp);
+
+ h = CreateEvent(NULL, FALSE, FALSE, TEXT("BackLightChangeEvent"));
+ if (h)
+ {
+ SetEvent(h);
+ CloseHandle(h);
+ }
+}
-// Power management code borrowed from MoDaCo & Betaplayer. Thanks !
void CEDevice::init() {
+ // 2003+ power management code borrowed from MoDaCo & Betaplayer. Thanks !
HINSTANCE dll = LoadLibrary(TEXT("aygshell.dll"));
if (dll) {
*(FARPROC*)&_SHIdleTimerReset = GetProcAddress(dll, MAKEINTRESOURCE(2006));
@@ -89,12 +97,20 @@ void CEDevice::init() {
if (_SetPowerRequirement)
_hPowerManagement = _SetPowerRequirement((PVOID) TEXT("BKL1:"), 0, 1, (PVOID) NULL, 0);
_lastTime = GetTickCount();
+
+ // older devices
+ REG_bat = REG_ac = REG_disp = 2 * 60 * 60 * 1000; // 2hrs should do it
+ backlight_xchg();
+ SystemParametersInfo(SPI_GETBATTERYIDLETIMEOUT, 0, (void *) &bat_timeout, 0);
+ SystemParametersInfo(SPI_SETBATTERYIDLETIMEOUT, 60 * 60 * 2, NULL, SPIF_SENDCHANGE);
}
void CEDevice::end() {
- if (_ReleasePowerRequirement && _hPowerManagement) {
+ if (_ReleasePowerRequirement && _hPowerManagement)
_ReleasePowerRequirement(_hPowerManagement);
- }
+
+ backlight_xchg();
+ SystemParametersInfo(SPI_SETBATTERYIDLETIMEOUT, bat_timeout, NULL, SPIF_SENDCHANGE);
}
void CEDevice::wakeUp() {
@@ -107,97 +123,97 @@ void CEDevice::wakeUp() {
}
}
+bool CEDevice::hasSquareQVGAResolution() {
+ return (OSystem_WINCE3::getScreenWidth() == 240 && OSystem_WINCE3::getScreenHeight() == 240);
+}
+
bool CEDevice::hasPocketPCResolution() {
-#ifdef SIMU_SMARTPHONE
-#ifndef SIMU_SMARTPHONE_2005
- return false;
-#else
- return true;
-#endif
-#else
if (OSystem_WINCE3::isOzone() && hasWideResolution())
return true;
- return (OSystem_WINCE3::getScreenWidth() < 320 && OSystem_WINCE3::getScreenWidth() >= 240);
-#endif
+ return (OSystem_WINCE3::getScreenWidth() <= 320 && OSystem_WINCE3::getScreenWidth() >= 240);
}
bool CEDevice::hasDesktopResolution() {
-#ifdef SIMU_SMARTPHONE
- return false;
-#else
if (OSystem_WINCE3::isOzone() && hasWideResolution())
return true;
- return (OSystem_WINCE3::getScreenWidth() >= 320);
-#endif
+ return (OSystem_WINCE3::getScreenWidth() > 320);
}
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
-#ifndef SIMU_SMARTPHONE_2005
- return true;
-#else
- return false;
-#endif
-#else
return (OSystem_WINCE3::getScreenWidth() < 240);
-#endif
}
bool CEDevice::isSmartphone() {
-#ifdef SIMU_SMARTPHONE
- return true;
-#else
TCHAR platformType[100];
BOOL result = SystemParametersInfo(SPI_GETPLATFORMTYPE, sizeof(platformType), platformType, 0);
if (!result && GetLastError() == ERROR_ACCESS_DENIED)
return true;
return (_wcsnicmp(platformType, TEXT("SmartPhone"), 10) == 0);
-#endif
}
Common::String CEDevice::getKeyName(unsigned int keyCode) {
- char key_name[10];
-
- if (!keyCode)
- return "No key";
-
- if (keyCode == KEY_CALENDAR)
- return "Button Calendar";
- if (keyCode == KEY_CONTACTS)
- return "Button Contacts";
- if (keyCode == KEY_INBOX)
- return "Button Inbox";
- if (keyCode == KEY_TASK)
- return "Button Tasks";
- if (keyCode == SDLK_F1)
- return "F1 (hard 1)";
- if (keyCode == SDLK_F2)
- return "F2 (hard 2)";
- if (keyCode == SDLK_F3)
- return "F3 (hard 3)";
- if (keyCode == SDLK_F4)
- return "F4 (hard 4)";
-
-//#ifdef WIN32_PLATFORM_WFSP
- if (hasSmartphoneResolution()) {
- int i = 0;
- while (SMARTPHONE_KEYS_MAPPING[i]) {
- if (keyCode == SMARTPHONE_KEYS_MAPPING[i])
- return SMARTPHONE_KEYS_NAME[i];
- i++;
- }
+ 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);
}
-//#endif
-
- sprintf(key_name, "Key %.4x", keyCode);
- return key_name;
}
-
diff --git a/backends/platform/wince/CEDevice.h b/backends/platform/wince/CEDevice.h
index 1165377caa..4dd86f1619 100644
--- a/backends/platform/wince/CEDevice.h
+++ b/backends/platform/wince/CEDevice.h
@@ -1,5 +1,5 @@
/* ScummVM - Scumm Interpreter
- * Copyright (C) 2001-2006 The ScummVM project
+ * Copyright (C) 2001-2007 The ScummVM project
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -28,19 +28,22 @@
#include "common/system.h"
#include "common/str.h"
-//#include <gx.h>
-
class CEDevice {
public:
static void init();
static void end();
static void wakeUp();
static bool hasPocketPCResolution();
+ static bool hasSquareQVGAResolution();
static bool hasDesktopResolution();
static bool hasWideResolution();
static bool hasSmartphoneResolution();
static bool isSmartphone();
static Common::String getKeyName(unsigned int keyCode);
+
+ private:
+ static DWORD reg_access(TCHAR *key, TCHAR *val, DWORD data);
+ static void backlight_xchg();
};
#endif
diff --git a/backends/platform/wince/CEKeysDialog.cpp b/backends/platform/wince/CEKeysDialog.cpp
deleted file mode 100644
index 249f1f6fcd..0000000000
--- a/backends/platform/wince/CEKeysDialog.cpp
+++ /dev/null
@@ -1,126 +0,0 @@
-/* ScummVM - Scumm Interpreter
- * Copyright (C) 2001-2006 The ScummVM project
- *
- * 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
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#include "common/stdafx.h"
-#include "CEKeysDialog.h"
-#include "CEDevice.h"
-#include "gui/Actions.h"
-
-using GUI::ListWidget;
-using GUI::kListNumberingZero;
-using GUI::WIDGET_CLEARBG;
-using GUI::kListSelectionChangedCmd;
-using GUI::kCloseCmd;
-using GUI::StaticTextWidget;
-using GUI::kTextAlignCenter;
-using GUI::CommandSender;
-using GUI::Actions;
-
-enum {
- kMapCmd = 'map ',
- kOKCmd = 'ok '
-};
-
-
-CEKeysDialog::CEKeysDialog(const Common::String &title)
- : GUI::Dialog(30, 20, 260, 160) {
- addButton(this, 160, 20, "Map", kMapCmd, 'M'); // Map
- addButton(this, 160, 40, "OK", kOKCmd, 'O'); // OK
- addButton(this, 160, 60, "Cancel", kCloseCmd, 'C'); // Cancel
-
- _actionTitle = new StaticTextWidget(this, 10, 120, 240, 16, title, kTextAlignCenter);
- _keyMapping = new StaticTextWidget(this, 10, 140, 240, 16, "", kTextAlignCenter);
-
- _actionTitle->setFlags(WIDGET_CLEARBG);
- _keyMapping->setFlags(WIDGET_CLEARBG);
-
- _actionsList = new ListWidget(this, "Actions List");
- _actionsList->setNumberingMode(kListNumberingZero);
-
- // Get actions names
- Common::StringList l;
-
- for (int i = 0; i < GUI_Actions::Instance()->size(); i++)
- l.push_back(GUI_Actions::Instance()->actionName((GUI::ActionType)i));
-
- _actionsList->setList(l);
-
- _actionSelected = -1;
- GUI_Actions::Instance()->beginMapping(false);
-}
-
-void CEKeysDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
- switch(cmd) {
-
- case kListSelectionChangedCmd:
- if (_actionsList->getSelected() >= 0) {
- char selection[100];
-
- sprintf(selection, "Associated key : %s", CEDevice::getKeyName(GUI_Actions::Instance()->getMapping((GUI::ActionType)(_actionsList->getSelected()))).c_str());
- _keyMapping->setLabel(selection);
- _keyMapping->draw();
- }
- break;
- case kMapCmd:
- if (_actionsList->getSelected() < 0) {
- _actionTitle->setLabel("Please select an action");
- }
- else {
- char selection[100];
-
- _actionSelected = _actionsList->getSelected();
- sprintf(selection, "Associated key : %s", CEDevice::getKeyName(GUI_Actions::Instance()->getMapping((GUI::ActionType)_actionSelected)).c_str());
- _actionTitle->setLabel("Press the key to associate");
- _keyMapping->setLabel(selection);
- _keyMapping->draw();
- GUI_Actions::Instance()->beginMapping(true);
- _actionsList->setEnabled(false);
- }
- _actionTitle->draw();
- break;
- case kOKCmd:
- GUI_Actions::Instance()->saveMapping();
- close();
- break;
- case kCloseCmd:
- GUI_Actions::Instance()->loadMapping();
- close();
- break;
- }
-}
-
-void CEKeysDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) {
- if (modifiers == 0xff && GUI_Actions::Instance()->mappingActive()) {
- // GAPI key was selected
- char selection[100];
-
- GUI_Actions::Instance()->setMapping((GUI::ActionType)_actionSelected, ascii);
-
- sprintf(selection, "Associated key : %s", CEDevice::getKeyName(GUI_Actions::Instance()->getMapping((GUI::ActionType)_actionSelected)).c_str());
- _actionTitle->setLabel("Choose an action to map");
- _keyMapping->setLabel(selection);
- _keyMapping->draw();
- _actionSelected = -1;
- _actionsList->setEnabled(true);
- GUI_Actions::Instance()->beginMapping(false);
- }
-}
diff --git a/backends/platform/wince/CEKeysDialog.h b/backends/platform/wince/CEKeysDialog.h
deleted file mode 100644
index 37566bf431..0000000000
--- a/backends/platform/wince/CEKeysDialog.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/* ScummVM - Scumm Interpreter
- * Copyright (C) 2001-2006 The ScummVM project
- *
- * 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
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#ifndef CEKEYSDIALOG
-#define CEKEYSDIALOG
-
-#include "gui/newgui.h"
-#include "gui/dialog.h"
-#include "gui/ListWidget.h"
-#include "common/str.h"
-
-class CEKeysDialog : public GUI::Dialog {
-public:
- CEKeysDialog(const Common::String &title = "Choose an action to map");
-
- virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data);
- virtual void handleKeyDown(uint16 ascii, int keycode, int modifiers);
-
-protected:
-
- GUI::ListWidget *_actionsList;
- GUI::StaticTextWidget *_actionTitle;
- GUI::StaticTextWidget *_keyMapping;
- int _actionSelected;
-};
-
-#endif
diff --git a/backends/platform/wince/CEScaler.cpp b/backends/platform/wince/CEScaler.cpp
index dac46b801a..85151dafe5 100644
--- a/backends/platform/wince/CEScaler.cpp
+++ b/backends/platform/wince/CEScaler.cpp
@@ -1,5 +1,5 @@
/* ScummVM - Scumm Interpreter
- * Copyright (C) 2001-2006 The ScummVM project
+ * Copyright (C) 2001-2007 The ScummVM project
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -89,42 +89,39 @@ void PocketPCLandscapeAspect(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr
unsigned int p2;
uint16 * inbuf;
uint16 * outbuf;
- inbuf=(uint16 *)srcPtr;
- outbuf=(uint16 *)dstPtr;
+ inbuf = (uint16 *)srcPtr;
+ outbuf = (uint16 *)dstPtr;
uint16 srcPitch16 = (uint16)(srcPitch / sizeof(uint16));
uint16 dstPitch16 = (uint16)(dstPitch / sizeof(uint16));
- for (i=0; i<((height)/6); i++) {
- for (j=0; j<width; j++) {
- p1=*((uint16*)inbuf+j);
- inbuf+=srcPitch16;
- *((uint16*)outbuf+j)=p1;
- outbuf+=dstPitch16;
- p2=*((uint16*)inbuf+j);
- inbuf+=srcPitch16;
- *((uint16*)outbuf+j)=MAKEPIXEL(P20(RB(p1))+P80(RB(p2)),P20(G(p1))+P80(G(p2)));
- outbuf+=dstPitch16;
- p1=p2;
- p2=*((uint16*)inbuf+j);
- inbuf+=srcPitch16;
- *((uint16*)outbuf+j)=MAKEPIXEL(P40(RB(p1))+P60(RB(p2)),P40(G(p1))+P60(G(p2)));
- outbuf+=dstPitch16;
- p1=p2;
- p2=*((uint16*)inbuf+j);
- inbuf+=srcPitch16;
- *((uint16*)outbuf+j)=MAKEPIXEL(P60(RB(p1))+P40(RB(p2)),P60(G(p1))+P40(G(p2)));
- outbuf+=dstPitch16;
- p1=p2;
- p2=*((uint16*)inbuf+j);
- *((uint16*)outbuf+j)=MAKEPIXEL(P80(RB(p1))+P20(RB(p2)),P80(G(p1))+P20(G(p2)));
- outbuf+=dstPitch16;
- *((uint16*)outbuf+j)=p2;
- inbuf=inbuf-srcPitch16*4;
- outbuf=outbuf-dstPitch16*5;
+ for (i = 0; i < height/5; i++) {
+ for (j=0; j < width; j++) {
+ p1 = *((uint16*)inbuf+j); inbuf += srcPitch16;
+ *((uint16*)outbuf+j) = p1; outbuf += dstPitch16;
+
+ p2 = *((uint16*)inbuf+j); inbuf += srcPitch16;
+ *((uint16*)outbuf+j) = MAKEPIXEL(P20(RB(p1))+P80(RB(p2)),P20(G(p1))+P80(G(p2))); outbuf += dstPitch16;
+
+ p1 = p2;
+ p2 = *((uint16*)inbuf+j); inbuf += srcPitch16;
+ *((uint16*)outbuf+j) = MAKEPIXEL(P40(RB(p1))+P60(RB(p2)),P40(G(p1))+P60(G(p2))); outbuf += dstPitch16;
+
+ p1 = p2;
+ p2 = *((uint16*)inbuf+j); inbuf += srcPitch16;
+ *((uint16*)outbuf+j) = MAKEPIXEL(P60(RB(p1))+P40(RB(p2)),P60(G(p1))+P40(G(p2))); outbuf += dstPitch16;
+
+ p1 = p2;
+ p2 = *((uint16*)inbuf+j);
+ *((uint16*)outbuf+j) = MAKEPIXEL(P80(RB(p1))+P20(RB(p2)),P80(G(p1))+P20(G(p2))); outbuf += dstPitch16;
+
+ *((uint16*)outbuf+j) = p2;
+
+ inbuf = inbuf - srcPitch16*4;
+ outbuf = outbuf - dstPitch16*5;
}
- inbuf=inbuf+srcPitch16*5;
- outbuf=outbuf+dstPitch16*6;
+ inbuf = inbuf + srcPitch16*5;
+ outbuf = outbuf + dstPitch16*6;
}
}
@@ -190,7 +187,6 @@ void PocketPCHalfZoom(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint3
}
}
-//#ifdef WIN32_PLATFORM_WFSP
void SmartphoneLandscape(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) {
uint8 *work;
int i;
@@ -221,5 +217,3 @@ void SmartphoneLandscape(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, ui
}
}
}
-//#endif
-
diff --git a/backends/platform/wince/CEgui/ItemAction.cpp b/backends/platform/wince/CEgui/ItemAction.cpp
index 9bc9db65bb..7010d85ec0 100644
--- a/backends/platform/wince/CEgui/ItemAction.cpp
+++ b/backends/platform/wince/CEgui/ItemAction.cpp
@@ -1,5 +1,5 @@
/* ScummVM - Scumm Interpreter
- * Copyright (C) 2001-2006 The ScummVM project
+ * Copyright (C) 2001-2007 The ScummVM project
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -39,7 +39,8 @@ namespace CEGUI {
bool ItemAction::action(int x, int y, bool pushed) {
if (checkInside(x, y) && _visible && pushed) {
- GUI::Actions::Instance()->perform(_action);
+ GUI::Actions::Instance()->perform(_action, true);
+ GUI::Actions::Instance()->perform(_action, false);
return true;
}
else
diff --git a/backends/platform/wince/Makefile b/backends/platform/wince/Makefile
index 1d08073b1d..44c4b597cf 100644
--- a/backends/platform/wince/Makefile
+++ b/backends/platform/wince/Makefile
@@ -3,6 +3,7 @@
# $URL$
# $Id$
+wince_gcc_root = /cygdrive/e/wince-gcc-root/
srcdir = ../../..
VPATH = $(srcdir)
@@ -10,7 +11,7 @@ VPATH = $(srcdir)
#DISABLE_SKY = 1
#DISABLE_QUEEN = 1
#DISABLE_GOB = 1
-#DISABLE_LURE = 1
+DISABLE_LURE = 1
#DISABLE_CINE = 1
#DISABLE_SAGA = 1
#DISABLE_KYRA = 1
@@ -20,8 +21,9 @@ VPATH = $(srcdir)
#DISABLE_SWORD2 = 1
#DISABLE_TOUCHE = 1
DISABLE_PARALLACTION = 1
+DISABLE_CRUISE = 1
-DISABLE_HQ_SCALERS = 1
+#DISABLE_HQ_SCALERS = 1
CXX = arm-wince-pe-g++
LD = arm-wince-pe-g++
@@ -41,20 +43,20 @@ DEFINES += -D__stdcall= -Dcdecl= -D__cdecl__= -D__cdecl= -Wno-multichar
#DEFINES += -DDEBUG -DUSE_WINDBG -g
DEFINES += -O2
-INCLUDES := -I$(srcdir) -I. -I$(srcdir)/engines -Imissing/gcc -Ilibs/include -Ilibs/include/sdl -ICEgui -ICEkeys -I/cygdrive/e/wince-gcc-root/include
+INCLUDES := -I$(srcdir) -I. -I$(srcdir)/engines -Imissing/gcc -Ilibs/include -Ilibs/include/sdl -ICEgui -ICEkeys -I$(wince_gcc_root)/include
CFLAGS :=
CXXFLAGS := $(CFLAGS)
-LDFLAGS := -Llibs/lib -L/cygdrive/e/wince-gcc-root/lib
+LDFLAGS := -Llibs/lib -L$(wince_gcc_root)/lib
LIBS := -lSDL -lzlib -lmad -lmpeg2 -ltremorce --entry WinMainCRTStartup
TARGET = scummvm.exe
OBJS :=
MODULE_DIRS += .
-OBJS += CEActionsPocket.o CEDevice.o CEKeysDialog.o CEScaler.o \
+OBJS += CEActionsPocket.o CEDevice.o CEScaler.o \
CEActionsSmartphone.o CELauncherDialog.o wince-sdl.o
OBJS += CEgui/GUIElement.o CEgui/Panel.o CEgui/SDL_ImageResource.o \
CEgui/ItemAction.o CEgui/PanelItem.o CEgui/Toolbar.o \
diff --git a/backends/platform/wince/wince-sdl.cpp b/backends/platform/wince/wince-sdl.cpp
index f567b64b36..48eca8164e 100644
--- a/backends/platform/wince/wince-sdl.cpp
+++ b/backends/platform/wince/wince-sdl.cpp
@@ -1,5 +1,5 @@
/* ScummVM - Scumm Interpreter
- * Copyright (C) 2001-2006 The ScummVM project
+ * Copyright (C) 2001-2007 The ScummVM project
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -20,6 +20,8 @@
*
*/
+// NOTE: formatted for tabstop=4
+
#include "common/stdafx.h"
#include "backends/platform/wince/wince-sdl.h"
@@ -83,10 +85,11 @@ using namespace CEGUI;
#define NAME_ITEM_ORIENTATION "Orientation"
#define NAME_ITEM_BINDKEYS "Bindkeys"
-// Given to the true main, needed for backend adaptation
-
-static FILE *stdout_file;
-static FILE *stderr_file;
+// stdin/err redirection
+#define STDOUT_FNAME "\\scummvm_stdout.txt"
+#define STDERR_FNAME "\\scummvm_stderr.txt"
+static FILE *stdout_file = NULL, *stderr_file = NULL;
+static char stdout_fname[MAX_PATH], stderr_fname[MAX_PATH];
// Static member inits
typedef void (*SoundProc)(void *param, byte *buf, int len);
@@ -124,8 +127,6 @@ static const OSystem::GraphicsMode s_supportedGraphicsModesHigh[] = {
{0, 0, 0}
};
-#define STDOUT_FNAME "\\scummvm_stdout.txt"
-#define STDERR_FNAME "\\scummvm_stderr.txt"
// ********************************************************************************************
@@ -134,6 +135,13 @@ bool isSmartphone() {
return _hasSmartphoneResolution;
}
+const TCHAR *ASCIItoUnicode(const char *str) {
+ static TCHAR ustr[MAX_PATH]; // size good enough
+
+ MultiByteToWideChar(CP_ACP, 0, str, strlen(str) + 1, ustr, sizeof(ustr) / sizeof(TCHAR));
+ return ustr;
+}
+
// MAIN
#ifndef __GNUC__
int handleException(EXCEPTION_POINTERS *exceptionPointers) {
@@ -153,7 +161,7 @@ OSystem *OSystem_WINCE3_create() {
}
int SDL_main(int argc, char **argv) {
-
+ FILE *newfp = NULL;
#ifdef __GNUC__
// Due to incomplete crt0.o implementation, we go through the constructor function
// list provided by the linker and init all of them
@@ -170,32 +178,35 @@ int SDL_main(int argc, char **argv) {
CEDevice::init();
OSystem_WINCE3::initScreenInfos();
- /* Avoid print problems - this file will be put in RAM anyway */
+ /* Redirect standard input and standard output */
+ strcpy(stdout_fname, getcwd(NULL, MAX_PATH));
+ strcpy(stderr_fname, getcwd(NULL, MAX_PATH));
+ strcat(stdout_fname, STDOUT_FNAME);
+ strcat(stderr_fname, STDERR_FNAME);
#ifndef __GNUC__
- stdout_file = fopen(STDOUT_FNAME, "w");
- stderr_file = fopen(STDERR_FNAME, "w");
+ stdout_file = fopen(stdout_fname, "w");
+ stderr_file = fopen(stderr_fname, "w");
#else
- /* Redirect standard input and standard output */
- FILE *newfp = _wfreopen(TEXT(STDOUT_FNAME), TEXT("w"), stdout);
+ stdout_file = newfp = _wfreopen(ASCIItoUnicode(stdout_fname), TEXT("w"), stdout);
if (newfp == NULL) {
#if !defined(stdout)
- stdout = fopen(STDOUT_FNAME, "w");
+ stdout = fopen(stdout_fname, "w");
stdout_file = stdout;
#else
- newfp = fopen(STDOUT_FNAME, "w");
+ newfp = fopen(stdout_fname, "w");
if (newfp) {
*stdout = *newfp;
stdout_file = stdout;
}
#endif
}
- newfp = _wfreopen(TEXT(STDERR_FNAME), TEXT("w"), stderr);
+ stderr_file = newfp = _wfreopen(ASCIItoUnicode(stderr_fname), TEXT("w"), stderr);
if (newfp == NULL) {
#if !defined(stderr)
- stderr = fopen(STDERR_FNAME, "w");
+ stderr = fopen(stderr_fname, "w");
stderr_file = stderr;
#else
- newfp = fopen(STDERR_FNAME, "w");
+ newfp = fopen(stderr_fname, "w");
if (newfp) {
*stderr = *newfp;
stderr_file = stderr;
@@ -214,7 +225,6 @@ int SDL_main(int argc, char **argv) {
// Invoke the actual ScummVM main entry point:
res = scummvm_main(argc, argv);
- //res = scummvm_main(0, NULL);
g_system->quit(); // TODO: Consider removing / replacing this!
#if !defined(DEBUG) && !defined(__GNUC__)
}
@@ -258,7 +268,10 @@ void OSystem_WINCE3::initBackend()
// Initialize global key mapping
GUI::Actions::init();
GUI_Actions::Instance()->initInstanceMain(this);
- GUI_Actions::Instance()->loadMapping();
+ if (!GUI_Actions::Instance()->loadMapping()) { // error during loading means not present/wrong version
+ warning("Setting default action mappings.");
+ GUI_Actions::Instance()->saveMapping(); // write defaults
+ }
loadDeviceConfiguration();
@@ -306,7 +319,7 @@ OSystem_WINCE3::OSystem_WINCE3() : OSystem_SDL(),
_panelVisible(true), _panelStateForced(false), _forceHideMouse(false),
_freeLook(false), _forcePanelInvisible(false), _toolbarHighDrawn(false), _zoomUp(false), _zoomDown(false),
_scalersChanged(false), _monkeyKeyboard(false), _lastKeyPressed(0), _tapTime(0),
- _saveToolbarState(false), _saveActiveToolbar(NAME_MAIN_PANEL), _rbutton(false),
+ _saveToolbarState(false), _saveActiveToolbar(NAME_MAIN_PANEL), _rbutton(false), _hasfocus(true),
_usesEmulatedMouse(false), _mouseBackupOld(NULL), _mouseBackupToolbar(NULL), _mouseBackupDim(0)
{
_isSmartphone = CEDevice::isSmartphone();
@@ -320,10 +333,13 @@ OSystem_WINCE3::OSystem_WINCE3() : OSystem_SDL(),
create_toolbar();
_mixer = 0;
+ _screen = NULL;
}
void OSystem_WINCE3::swap_panel_visibility() {
//if (!_forcePanelInvisible && !_panelStateForced) {
+ if (_zoomDown || _zoomUp) return;
+
if (_panelVisible) {
if (_toolbarHandler.activeName() == NAME_PANEL_KEYBOARD)
_panelVisible = !_panelVisible;
@@ -335,6 +351,7 @@ void OSystem_WINCE3::swap_panel_visibility() {
_panelVisible = !_panelVisible;
}
_toolbarHandler.setVisible(_panelVisible);
+ _toolbarHighDrawn = false;
if (_screenHeight > 240)
addDirtyRect(0, 400, 640, 80);
@@ -376,7 +393,10 @@ void OSystem_WINCE3::swap_smartphone_keyboard() {
_toolbarHandler.setActive(NAME_PANEL_KEYBOARD);
_panelVisible = !_panelVisible;
_toolbarHandler.setVisible(_panelVisible);
- addDirtyRect(0, 0, 320, 40);
+ if (_screenHeight > 240)
+ addDirtyRect(0, 0, 640, 80);
+ else
+ addDirtyRect(0, 0, 320, 40);
internUpdateScreen();
}
@@ -417,6 +437,7 @@ void OSystem_WINCE3::swap_zoom_up() {
_scaleFactorYd = 2;
_scalerProc = PocketPCHalf;
_zoomUp = false;
+ _zoomDown = false;
}
else
{
@@ -430,9 +451,8 @@ void OSystem_WINCE3::swap_zoom_up() {
_scaleFactorYd = 1;
_scalerProc = PocketPCHalfZoom;
}
- else
- _zoomDown = false;
-
+
+ _zoomDown = false;
_zoomUp = true;
}
// redraw whole screen
@@ -448,6 +468,7 @@ void OSystem_WINCE3::swap_zoom_down() {
_scaleFactorYd = 2;
_scalerProc = PocketPCHalf;
_zoomDown = false;
+ _zoomUp = false;
}
else
{
@@ -461,9 +482,8 @@ void OSystem_WINCE3::swap_zoom_down() {
_scaleFactorYd = 1;
_scalerProc = PocketPCHalfZoom;
}
- else
- _zoomUp = false;
+ _zoomUp = false;
_zoomDown = true;
}
// redraw whole screen
@@ -641,7 +661,7 @@ bool OSystem_WINCE3::setSoundCallback(SoundProc proc, void *param) {
return false;
}
else
- warning("Sound opened OK, mixing at %d Hz", _sampleRate);
+ debug(1, "Sound opened OK, mixing at %d Hz", _sampleRate);
SDL_PauseAudio(0);
return true;
}
@@ -851,18 +871,16 @@ void OSystem_WINCE3::update_game_settings() {
panel->add(NAME_ITEM_BINDKEYS, new ItemAction(ITEM_BINDKEYS, POCKET_ACTION_BINDKEYS));
// portrait/landscape - screen dependent
// FIXME : will still display the portrait/landscape icon when using a scaler (but will be disabled)
- if (_screenWidth <= 320 && (isOzone() || !CEDevice::hasDesktopResolution())) {
- if (ConfMan.hasKey("landscape"))
- if (ConfMan.get("landscape")[0] > 57) {
- _newOrientation = _orientationLandscape = ConfMan.getBool("landscape");
- //ConfMan.removeKey("landscape", "");
- ConfMan.setInt("landscape", _orientationLandscape);
- } else
- _newOrientation = _orientationLandscape = ConfMan.getInt("landscape");
- else
- _newOrientation = _orientationLandscape = 0;
- panel->add(NAME_ITEM_ORIENTATION, new ItemSwitch(ITEM_VIEW_LANDSCAPE, ITEM_VIEW_PORTRAIT, &_newOrientation, 2));
- }
+ if (ConfMan.hasKey("landscape"))
+ if (ConfMan.get("landscape")[0] > 57) {
+ _newOrientation = _orientationLandscape = ConfMan.getBool("landscape");
+ //ConfMan.removeKey("landscape", "");
+ ConfMan.setInt("landscape", _orientationLandscape);
+ } else
+ _newOrientation = _orientationLandscape = ConfMan.getInt("landscape");
+ else
+ _newOrientation = _orientationLandscape = 0;
+ panel->add(NAME_ITEM_ORIENTATION, new ItemSwitch(ITEM_VIEW_LANDSCAPE, ITEM_VIEW_PORTRAIT, &_newOrientation, 2));
_toolbarHandler.add(NAME_MAIN_PANEL, *panel);
_toolbarHandler.setActive(NAME_MAIN_PANEL);
_toolbarHandler.setVisible(true);
@@ -920,6 +938,9 @@ void OSystem_WINCE3::initSize(uint w, uint h) {
if (w == 320 && h == 200 && !_hasSmartphoneResolution)
h = 240; // use the extra 40 pixels height for the toolbar
+ if (h == 400) // touche engine fixup
+ h += 80;
+
if (!_hasSmartphoneResolution)
if (h == 240)
_toolbarHandler.setOffset(200);
@@ -961,15 +982,15 @@ bool OSystem_WINCE3::update_scalers() {
_adjustAspectRatio = false;
if (CEDevice::hasPocketPCResolution()) {
- if (!_orientationLandscape && (_screenWidth == 320 || !_screenWidth)) {
+ if ( (!_orientationLandscape && (_screenWidth == 320 || !_screenWidth))
+ || CEDevice::hasSquareQVGAResolution() ) {
_scaleFactorXm = 3;
_scaleFactorXd = 4;
_scaleFactorYm = 1;
_scaleFactorYd = 1;
_scalerProc = PocketPCPortrait;
_modeFlags = 0;
- }
- if ( _orientationLandscape && (_screenWidth == 320 || !_screenWidth)) {
+ } else if ( _orientationLandscape && (_screenWidth == 320 || !_screenWidth)) {
Common::String gameid(ConfMan.get("gameid")); // consider removing this check and start honoring the _adjustAspectRatio flag
if (!_panelVisible && !_hasSmartphoneResolution && !_overlayVisible && !(strncmp(gameid.c_str(), "zak", 3) == 0)) {
_scaleFactorXm = 1;
@@ -987,16 +1008,14 @@ bool OSystem_WINCE3::update_scalers() {
_scalerProc = Normal1x;
_modeFlags = 0;
}
- }
- if (_screenWidth == 640 && !(isOzone() && (getScreenWidth() >= 640 || getScreenHeight() >= 640))) {
+ } else if (_screenWidth == 640 && !(isOzone() && (getScreenWidth() >= 640 || getScreenHeight() >= 640))) {
_scaleFactorXm = 1;
_scaleFactorXd = 2;
_scaleFactorYm = 1;
_scaleFactorYd = 2;
_scalerProc = PocketPCHalf;
_modeFlags = 0;
- }
- if (_screenWidth == 640 && (isOzone() && (getScreenWidth() >= 640 || getScreenHeight() >= 640))) {
+ } else if (_screenWidth == 640 && (isOzone() && (getScreenWidth() >= 640 || getScreenHeight() >= 640))) {
_scaleFactorXm = 1;
_scaleFactorXd = 1;
_scaleFactorYm = 1;
@@ -1007,6 +1026,7 @@ bool OSystem_WINCE3::update_scalers() {
return true;
}
+
if (CEDevice::hasSmartphoneResolution()) {
if (_screenWidth > 320)
error("Game resolution not supported on Smartphone");
@@ -1174,49 +1194,44 @@ void OSystem_WINCE3::loadGFXMode() {
// Create the surface that contains the 8 bit game data
_screen = SDL_CreateRGBSurface(SDL_SWSURFACE, _screenWidth, _screenHeight, 8, 0, 0, 0, 0);
if (_screen == NULL)
- error("_screen failed");
+ error("_screen failed (%s)", SDL_GetError());
// Create the surface that contains the scaled graphics in 16 bit mode
-
// Always use full screen mode to have a "clean screen"
- displayWidth = _screenWidth * _scaleFactorXm / _scaleFactorXd;
- displayHeight = _screenHeight * _scaleFactorYm / _scaleFactorYd;
- if (_screenHeight == 400) // touche engine fixup
- displayHeight += 80 * _scaleFactorYm / _scaleFactorYd;
+ if (!_adjustAspectRatio) {
+ displayWidth = _screenWidth * _scaleFactorXm / _scaleFactorXd;
+ displayHeight = _screenHeight * _scaleFactorYm / _scaleFactorYd;
+ } else {
+ displayWidth = _screenWidth;
+ displayHeight = _screenHeight;
+ }
- // FIXME
- if (displayWidth <= GetSystemMetrics(SM_CXSCREEN)) { // no rotation
- displayWidth = GetSystemMetrics(SM_CXSCREEN);
- displayHeight = GetSystemMetrics(SM_CYSCREEN);
- } else if (displayHeight > GetSystemMetrics(SM_CXSCREEN)) // rotating, clip height
- displayHeight = GetSystemMetrics(SM_CXSCREEN);
-
- if (_orientationLandscape == 2) flags |= SDL_FLIPVIDEO;
+ switch (_orientationLandscape) {
+ case 1:
+ flags |= SDL_LANDSCVIDEO;
+ break;
+ case 2:
+ flags |= SDL_INVLNDVIDEO;
+ break;
+ default:
+ flags |= SDL_PORTRTVIDEO;
+ }
_hwscreen = SDL_SetVideoMode(displayWidth, displayHeight, 16, flags);
if (_hwscreen == NULL) {
- // DON'T use error(), as this tries to bring up the debug
- // console, which WON'T WORK now that _hwscreen is hosed.
-
- // FIXME: We should be able to continue the game without
- // shutting down or bringing up the debug console, but at
- // this point we've already screwed up all our member vars.
- // We need to find a way to call SDL_VideoModeOK *before*
- // that happens and revert to all the old settings if we
- // can't pull off the switch to the new settings.
- //
- // Fingolfin says: the "easy" way to do that is not to modify
- // the member vars before we are sure everything is fine. Think
- // of "transactions, commit, rollback" style... we use local vars
- // in place of the member vars, do everything etc. etc.. In case
- // of a failure, rollback is trivial. Only if everything worked fine
- // do we "commit" the changed values to the member vars.
- warning("SDL_SetVideoMode says we can't switch to that mode");
+ warning("SDL_SetVideoMode says we can't switch to that mode (%s)", SDL_GetError());
quit();
}
- // Create the surface used for the graphics in 16 bit before scaling, and also the overlay
+ // see what orientation sdl finally accepted
+ if (_hwscreen->flags & SDL_PORTRTVIDEO)
+ _orientationLandscape = _newOrientation = 0;
+ else if (_hwscreen->flags & SDL_LANDSCVIDEO)
+ _orientationLandscape = _newOrientation = 1;
+ else
+ _orientationLandscape = _newOrientation = 2;
+ // Create the surface used for the graphics in 16 bit before scaling, and also the overlay
// Distinguish 555 and 565 mode
if (_hwscreen->format->Rmask == 0x7C00)
InitScalers(555);
@@ -1228,38 +1243,39 @@ void OSystem_WINCE3::loadGFXMode() {
_tmpscreen = SDL_CreateRGBSurface(SDL_SWSURFACE, _screenWidth + 3, _screenHeight + 3, 16, _hwscreen->format->Rmask, _hwscreen->format->Gmask, _hwscreen->format->Bmask, _hwscreen->format->Amask);
if (_tmpscreen == NULL)
- error("_tmpscreen creation failed");
+ error("_tmpscreen creation failed (%s)", SDL_GetError());
// Overlay
if (CEDevice::hasDesktopResolution()) {
_overlayscreen = SDL_CreateRGBSurface(SDL_SWSURFACE, _overlayWidth * _scaleFactorXm / _scaleFactorXd, _overlayHeight * _scaleFactorYm / _scaleFactorYd, 16, 0, 0, 0, 0);
if (_overlayscreen == NULL)
- error("_overlayscreen failed");
+ error("_overlayscreen failed (%s)", SDL_GetError());
_tmpscreen2 = SDL_CreateRGBSurface(SDL_SWSURFACE, _overlayWidth * _scaleFactorXm / _scaleFactorXd + 3, _overlayHeight * _scaleFactorYm / _scaleFactorYd + 3, 16, 0, 0, 0, 0);
if (_tmpscreen2 == NULL)
- error("_tmpscreen2 failed");
+ error("_tmpscreen2 failed (%s)", SDL_GetError());
} else {
_overlayscreen = SDL_CreateRGBSurface(SDL_SWSURFACE, _overlayWidth, _overlayHeight, 16, 0, 0, 0, 0);
if (_overlayscreen == NULL)
- error("_overlayscreen failed");
+ error("_overlayscreen failed (%s)", SDL_GetError());
_tmpscreen2 = SDL_CreateRGBSurface(SDL_SWSURFACE, _overlayWidth + 3, _overlayHeight + 3, 16, 0, 0, 0, 0);
if (_tmpscreen2 == NULL)
- error("_tmpscreen2 failed");
+ error("_tmpscreen2 failed (%s)", SDL_GetError());
}
// Toolbar
- uint16 *toolbar_screen = (uint16 *)calloc(320 * 40, sizeof(uint16));
+ _toolbarHighDrawn = false;
+ uint16 *toolbar_screen = (uint16 *)calloc(320 * 40, sizeof(uint16)); // *not* leaking memory here
_toolbarLow = SDL_CreateRGBSurfaceFrom(toolbar_screen, 320, 40, 16, 320 * 2, _hwscreen->format->Rmask, _hwscreen->format->Gmask, _hwscreen->format->Bmask, _hwscreen->format->Amask);
if (_toolbarLow == NULL)
- error("_toolbarLow failed");
+ error("_toolbarLow failed (%s)", SDL_GetError());
if (_screenHeight > 240) {
uint16 *toolbar_screen = (uint16 *)calloc(640 * 80, sizeof(uint16));
_toolbarHigh = SDL_CreateRGBSurfaceFrom(toolbar_screen, 640, 80, 16, 640 * 2, _hwscreen->format->Rmask, _hwscreen->format->Gmask, _hwscreen->format->Bmask, _hwscreen->format->Amask);
if (_toolbarHigh == NULL)
- error("_toolbarHigh failed");
+ error("_toolbarHigh failed (%s)", SDL_GetError());
} else
_toolbarHigh = NULL;
@@ -1330,11 +1346,12 @@ void OSystem_WINCE3::hotswapGFXMode() {
SDL_FreeSurface(old_overlayscreen);
SDL_FreeSurface(old_tmpscreen2);
- // Blit everything to the screen
+ // Blit everything back to the screen
+ _toolbarHighDrawn = false;
internUpdateScreen();
- // Make sure that an Common::EVENT_SCREEN_CHANGED gets sent later
- _modeChanged = true;
+ // Make sure that a Common::EVENT_SCREEN_CHANGED gets sent later -> FIXME this crashes when no game has been loaded.
+// _modeChanged = true;
}
void OSystem_WINCE3::update_keyboard() {
@@ -1355,8 +1372,17 @@ void OSystem_WINCE3::update_keyboard() {
void OSystem_WINCE3::internUpdateScreen() {
SDL_Surface *srcSurf, *origSurf;
static bool old_overlayVisible = false;
+ int numRectsOut = 0;
+ int16 routx, routy, routw, routh;
+
assert(_hwscreen != NULL);
+ // bail if the application is minimized, be nice to OS
+ if (!_hasfocus) {
+ Sleep(20);
+ return;
+ }
+
update_keyboard();
// If the shake position changed, fill the dirty area with blackness
@@ -1415,7 +1441,7 @@ void OSystem_WINCE3::internUpdateScreen() {
// Only draw anything if necessary
if (_numDirtyRects > 0) {
- SDL_Rect *r;
+ SDL_Rect *r, *rout;
SDL_Rect dst;
uint32 srcPitch, dstPitch;
SDL_Rect *last_rect = _dirtyRectList + _numDirtyRects;
@@ -1424,8 +1450,9 @@ void OSystem_WINCE3::internUpdateScreen() {
for (r = _dirtyRectList; r != last_rect; ++r) {
dst = *r;
- dst.x++; // Shift rect by one since 2xSai needs to acces the data around
+ dst.x++; // Shift rect by one since 2xSai needs to access the data around
dst.y++; // any pixel to scale it, and we want to avoid mem access crashes.
+ // NOTE: This is also known as BLACK MAGIC, copied from the sdl backend
if (SDL_BlitSurface(origSurf, r, srcSurf, &dst) != 0)
error("SDL_BlitSurface failed: %s", SDL_GetError());
}
@@ -1436,67 +1463,53 @@ void OSystem_WINCE3::internUpdateScreen() {
srcPitch = srcSurf->pitch;
dstPitch = _hwscreen->pitch;
- for (r = _dirtyRectList; r != last_rect; ++r) {
- register int dst_y = r->y + _currentShakePos;
- register int dst_h = 0;
-
- // Check if the toolbar is overwritten
- if (!_forceFull && toolbarVisible && r->y + r->h >= toolbarOffset)
- _toolbarHandler.forceRedraw();
-
- if (dst_y < _screenHeight) {
- dst_h = r->h;
- if (dst_h > _screenHeight - dst_y)
- dst_h = _screenHeight - dst_y;
-
- dst_y *= _scaleFactorYm;
- dst_y /= _scaleFactorYd;
-
- if (_adjustAspectRatio)
- dst_h = real2Aspect(dst_h);
-
- // clip inside platform screen (landscape,bottom only)
- if (_orientationLandscape && !_zoomDown && dst_y+dst_h > _screenHeight)
- dst_h = _screenHeight - dst_y;
-
- if (!_zoomDown)
- _scalerProc((byte *)srcSurf->pixels + (r->x * 2 + 2) + (r->y + 1) * srcPitch, srcPitch,
- (byte *)_hwscreen->pixels + (r->x * 2 * _scaleFactorXm / _scaleFactorXd) + dst_y * dstPitch, dstPitch, r->w, dst_h);
- else {
- _scalerProc((byte *)srcSurf->pixels + (r->x * 2 + 2) + (r->y + 1) * srcPitch, srcPitch,
- (byte *)_hwscreen->pixels + (r->x * 2 * _scaleFactorXm / _scaleFactorXd) + (dst_y - 240) * dstPitch, dstPitch, r->w, dst_h);
+ for (r = _dirtyRectList, rout = _dirtyRectOut; r != last_rect; ++r) {
+ // transform
+ routx = r->x * _scaleFactorXm / _scaleFactorXd; // locate position in scaled screen
+ routy = (r->y + _currentShakePos) * _scaleFactorYm / _scaleFactorYd; // adjust for shake offset
+ routw = r->w * _scaleFactorXm / _scaleFactorXd;
+ routh = r->h * _scaleFactorYm / _scaleFactorYd;
+
+ // clipping destination rectangle inside device screen (more strict, also more tricky but more stable)
+ // note that all current scalers do not make dst rect exceed left/right, unless chosen badly (FIXME)
+ if (_zoomDown) routy -= 240; // adjust for zoom position
+ if (routy + routh < 0) continue;
+ if (routy < 0) {
+ routh += routy;
+ routy = 0;
+ }
+ if (_orientationLandscape) {
+ if (routy > _platformScreenWidth) continue;
+ if (routy + routh > _platformScreenWidth) {
+ routh = _platformScreenWidth - routy;
+ r->h = routh * _scaleFactorYd / _scaleFactorYm;
+ }
+ } else {
+ if (routy > _platformScreenHeight) continue;
+ if (routy + routh > _platformScreenHeight) {
+ routh = _platformScreenHeight - routy;
+ r->h = routh * _scaleFactorYd / _scaleFactorYm;
}
-
}
- r->x = r->x * _scaleFactorXm / _scaleFactorXd;
- if (!_zoomDown)
- r->y = dst_y;
- else
- r->y = dst_y - 240;
- r->w = r->w * _scaleFactorXm / _scaleFactorXd;
- if (!_adjustAspectRatio)
- r->h = dst_h * _scaleFactorYm / _scaleFactorYd;
- else
- r->h = dst_h;
+ // check if the toolbar is overwritten
+ if (toolbarVisible && r->y + r->h >= toolbarOffset)
+ _toolbarHandler.forceRedraw();
+
+ // blit it (with added voodoo from the sdl backend, shifting the source rect again)
+ _scalerProc( (byte *)srcSurf->pixels + (r->x * 2 + 2)+ (r->y + 1) * srcPitch, srcPitch,
+ (byte *)_hwscreen->pixels + routx * 2 + routy * dstPitch, dstPitch,
+ r->w, r->h);
+
+ // add this rect to output
+ rout->x = routx; rout->y = routy;
+ rout->w = routw; rout->h = routh;
+ numRectsOut++;
+ rout++;
+
}
SDL_UnlockSurface(srcSurf);
SDL_UnlockSurface(_hwscreen);
-
- // Readjust the dirty rect list in case we are doing a full update.
- // This is necessary if shaking is active.
- if (_forceFull) {
- _dirtyRectList[0].y = 0;
- _dirtyRectList[0].h = (_adjustAspectRatio ? 240 : (_zoomUp || _zoomDown ? _screenHeight / 2 : _screenHeight)) * _scaleFactorYm / _scaleFactorYd;
- if (_orientationLandscape)
- {
- if (_dirtyRectList[0].h > _platformScreenWidth)
- _dirtyRectList[0].h = _platformScreenWidth; // clip
- } else {
- if (_dirtyRectList[0].h > _platformScreenHeight)
- _dirtyRectList[0].h = _platformScreenHeight; // clip
- }
- }
}
// Add the toolbar if needed
SDL_Rect toolbar_rect[1];
@@ -1515,8 +1528,6 @@ void OSystem_WINCE3::internUpdateScreen() {
SDL_UnlockSurface(_toolbarLow);
_toolbarHighDrawn = true;
}
- else
- _toolbarHighDrawn = false;
toolbar_rect[0].w *= 2;
toolbar_rect[0].h *= 2;
toolbarSurface = _toolbarHigh;
@@ -1548,8 +1559,8 @@ void OSystem_WINCE3::internUpdateScreen() {
}
// Finally, blit all our changes to the screen
- if (_numDirtyRects > 0)
- SDL_UpdateRects(_hwscreen, _numDirtyRects, _dirtyRectList);
+ if (numRectsOut > 0)
+ SDL_UpdateRects(_hwscreen, numRectsOut, _dirtyRectOut);
_numDirtyRects = 0;
_forceFull = false;
@@ -1563,30 +1574,6 @@ bool OSystem_WINCE3::saveScreenshot(const char *filename) {
return true;
}
-// FIXME
-// Reuse static or proper mapping
-
-static int mapKeyCE(SDLKey key, SDLMod mod, Uint16 unicode)
-{
- if (GUI::Actions::Instance()->mappingActive())
- return key;
-
- if (key >= SDLK_F1 && key <= SDLK_F9) {
- return key - SDLK_F1 + 315;
- } else if (key >= SDLK_KP0 && key <= SDLK_KP9) {
- return key - SDLK_KP0 + '0';
- } else if (key >= SDLK_UP && key <= SDLK_PAGEDOWN) {
- return key;
- } else if (unicode) {
- return unicode;
- } else if (key >= 'a' && key <= 'z' && mod & KMOD_SHIFT) {
- return key & ~0x20;
- } else if (key >= SDLK_NUMLOCK && key <= SDLK_EURO) {
- return 0;
- }
- return key;
-}
-
void OSystem_WINCE3::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) {
assert (_transactionMode == kTransactionNone);
@@ -2048,9 +2035,7 @@ void OSystem_WINCE3::addDirtyRect(int x, int y, int w, int h, bool mouseRect) {
else
h = 240 - y;
}
- }
- else
- if (_zoomDown) {
+ } else if (_zoomDown) {
if (y + h >= 240) {
if (y < 240) {
h = 240 - y;
@@ -2065,8 +2050,24 @@ void OSystem_WINCE3::addDirtyRect(int x, int y, int w, int h, bool mouseRect) {
OSystem_SDL::addDirtyRect(x, y, w, h, false);
}
-// FIXME
-// See if some SDL mapping can be useful for HPCs
+static int mapKeyCE(SDLKey key, SDLMod mod, Uint16 unicode)
+{
+ if (GUI::Actions::Instance()->mappingActive())
+ return key;
+
+ if (key >= SDLK_KP0 && key <= SDLK_KP9) {
+ return key - SDLK_KP0 + '0';
+ } else if (key >= SDLK_UP && key <= SDLK_PAGEDOWN) {
+ return key;
+ } else if (unicode) {
+ return unicode;
+ } else if (key >= 'a' && key <= 'z' && mod & KMOD_SHIFT) {
+ return key & ~0x20;
+ } else if (key >= SDLK_NUMLOCK && key <= SDLK_EURO) {
+ return 0;
+ }
+ return key;
+}
bool OSystem_WINCE3::pollEvent(Common::Event &event) {
SDL_Event ev;
@@ -2096,6 +2097,7 @@ bool OSystem_WINCE3::pollEvent(Common::Event &event) {
switch(ev.type) {
case SDL_KEYDOWN:
// KMOD_RESERVED is used if the key has been injected by an external buffer
+ debug(1, "Key down %X %s", ev.key.keysym.sym, SDL_GetKeyName((SDLKey)ev.key.keysym.sym));
if (ev.key.keysym.mod != KMOD_RESERVED) {
keyEvent = true;
_lastKeyPressed = ev.key.keysym.sym;
@@ -2117,6 +2119,7 @@ bool OSystem_WINCE3::pollEvent(Common::Event &event) {
case SDL_KEYUP:
// KMOD_RESERVED is used if the key has been injected by an external buffer
+ debug(1, "Key up %X %s", ev.key.keysym.sym, SDL_GetKeyName((SDLKey)ev.key.keysym.sym));
if (ev.key.keysym.mod != KMOD_RESERVED) {
keyEvent = true;
_lastKeyPressed = 0;
@@ -2181,12 +2184,13 @@ bool OSystem_WINCE3::pollEvent(Common::Event &event) {
if (_toolbarHandler.action(temp_event.mouse.x, temp_event.mouse.y, true)) {
if (!_toolbarHandler.drawn())
+ _toolbarHighDrawn = false;
internUpdateScreen();
- if (_newOrientation != _orientationLandscape && _mode == GFX_NORMAL) {
+ if (_newOrientation != _orientationLandscape){
_orientationLandscape = _newOrientation;
+ _toolbarHighDrawn = false;
ConfMan.setInt("landscape", _orientationLandscape);
ConfMan.flushToDisk();
- setGraphicsMode(GFX_NORMAL);
hotswapGFXMode();
}
} else {
@@ -2213,6 +2217,7 @@ bool OSystem_WINCE3::pollEvent(Common::Event &event) {
if (_toolbarHandler.action(temp_event.mouse.x, temp_event.mouse.y, false)) {
if (!_toolbarHandler.drawn())
+ _toolbarHighDrawn = false;
internUpdateScreen();
} else {
if (!_freeLook)
@@ -2228,18 +2233,29 @@ bool OSystem_WINCE3::pollEvent(Common::Event &event) {
case SDL_QUIT:
event.type = Common::EVENT_QUIT;
return true;
+
+ case SDL_ACTIVEEVENT:
+ if (ev.active.state & SDL_APPMOUSEFOCUS)
+ debug(1, "%s mouse focus.", ev.active.gain ? "Got" : "Lost");
+ if (ev.active.state & SDL_APPINPUTFOCUS)
+ debug(1, "%s input focus.", ev.active.gain ? "Got" : "Lost");
+ if (ev.active.state & SDL_APPACTIVE)
+ debug(1, "%s total focus.", ev.active.gain ? "Got" : "Lost");
+ if (ev.active.state & SDL_APPINPUTFOCUS) {
+ _hasfocus = ev.active.gain;
+ SDL_PauseAudio(!_hasfocus);
+ _forceFull |= _hasfocus;
+ }
+ break;
}
}
- // Simulate repeated key for Smartphones
-
- if (!keyEvent)
- if (_lastKeyPressed)
- if (currentTime > _keyRepeatTime + _keyRepeatTrigger) {
- _keyRepeatTime = currentTime;
- _keyRepeat++;
- GUI_Actions::Instance()->performMapped(_lastKeyPressed, true);
- }
+ // Simulate repeated key for backend
+ if (!keyEvent && _lastKeyPressed && currentTime > _keyRepeatTime + _keyRepeatTrigger) {
+ _keyRepeatTime = currentTime;
+ _keyRepeat++;
+ GUI_Actions::Instance()->performMapped(_lastKeyPressed, true);
+ }
return false;
}
@@ -2248,8 +2264,8 @@ void OSystem_WINCE3::quit() {
fclose(stdout_file);
fclose(stderr_file);
if (gDebugLevel <= 0) {
- DeleteFile(TEXT("\\scummvm_stdout.txt"));
- DeleteFile(TEXT("\\scummvm_stderr.txt"));
+ DeleteFile(ASCIItoUnicode(stdout_fname));
+ DeleteFile(ASCIItoUnicode(stderr_fname));
}
CEDevice::end();
OSystem_SDL::quit();
diff --git a/backends/platform/wince/wince-sdl.h b/backends/platform/wince/wince-sdl.h
index 7d797e5959..6f7cb7a0c1 100644
--- a/backends/platform/wince/wince-sdl.h
+++ b/backends/platform/wince/wince-sdl.h
@@ -206,7 +206,9 @@ private:
int _scaleFactorXd; // scaler X /
int _scaleFactorYm; // scaler Y *
int _scaleFactorYd; // scaler Y /
+ SDL_Rect _dirtyRectOut[NUM_DIRTY_RECT];
bool _scalersChanged;
+ bool _hasfocus; // scummvm has the top window
static int _platformScreenWidth;
static int _platformScreenHeight;