aboutsummaryrefslogtreecommitdiff
path: root/backends/wince/CEActions.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'backends/wince/CEActions.cpp')
-rw-r--r--backends/wince/CEActions.cpp182
1 files changed, 33 insertions, 149 deletions
diff --git a/backends/wince/CEActions.cpp b/backends/wince/CEActions.cpp
index 7770cd278c..a10b056775 100644
--- a/backends/wince/CEActions.cpp
+++ b/backends/wince/CEActions.cpp
@@ -19,10 +19,10 @@
*
*/
-
#include "stdafx.h"
#include "CEActions.h"
-#include "KeysBuffer.h"
+#include "CEActionsPocket.h"
+#include "CEActionsSmartphone.h"
#include "gui/message.h"
@@ -30,135 +30,36 @@
#include "common/config-manager.h"
-const String actionNames[] = {
- "none",
- "Pause",
- "Save",
- "Quit",
- "Skip",
- "Hide",
- "Keyboard",
- "Sound",
- "Right click",
- "Cursor",
- "Free look"
-};
CEActions* CEActions::Instance() {
return _instance;
}
-String CEActions::actionName(ActionType action) {
- return actionNames[action];
-}
-
-int CEActions::size() {
- return ACTION_LAST - 1;
-}
-
-CEActions::CEActions(OSystem_WINCE3 *mainSystem, GameDetector &detector) :
- _mainSystem(mainSystem), _mapping_active(false), _right_click_needed(false),
- _hide_toolbar_needed(false)
+CEActions::CEActions(GameDetector &detector) :
+ _detector(&detector), _mapping_active(false), _initialized(false)
{
- int i;
- 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);
- bool is_queen = (detector._targetName == "queen");
- bool is_sky = (detector._targetName == "sky");
-
- for (i=0; i<ACTION_LAST; i++)
- _action_mapping[i] = 0;
-
- // See if a right click mapping could be needed
- if (is_sword1 || is_sword2 || is_sky || is_queen || detector._targetName == "comi" ||
- detector._targetName == "samnmax")
- _right_click_needed = true;
-
- // See if a "hide toolbar" mapping could be needed
- if (is_sword1 || is_sword2 || is_queen)
- _hide_toolbar_needed = true;
-
- // Initialize keys for different actions
- // Pause
- _key_action[ACTION_PAUSE].setAscii(VK_SPACE);
- _action_enabled[ACTION_PAUSE] = true;
- // Save
- if (is_simon)
- _action_enabled[ACTION_SAVE] = false;
- else
- if (is_queen) {
- _action_enabled[ACTION_SAVE] = true;
- _key_action[ACTION_SAVE].setAscii(282); // F1 key
- }
- else
- if (is_sky) {
- _action_enabled[ACTION_SAVE] = true;
- _key_action[ACTION_SAVE].setAscii(63);
- }
- else {
- _action_enabled[ACTION_SAVE] = true;
- _key_action[ACTION_SAVE].setAscii(319); // F5 key
- }
- // Quit
- _action_enabled[ACTION_QUIT] = true;
- // Skip
- _action_enabled[ACTION_SKIP] = true;
- if (is_simon || is_sky || is_sword2 || is_queen || is_sword1)
- _key_action[ACTION_SKIP].setAscii(VK_ESCAPE);
- else
- _key_action[ACTION_SKIP].setAscii(Scumm::KEY_ALL_SKIP);
- // Hide
- _action_enabled[ACTION_HIDE] = true;
- // Keyboard
- _action_enabled[ACTION_KEYBOARD] = true;
- // Sound
- _action_enabled[ACTION_SOUND] = true;
- // RightClick
- _action_enabled[ACTION_RIGHTCLICK] = true;
- // Cursor
- _action_enabled[ACTION_CURSOR] = true;
- // Freelook
- _action_enabled[ACTION_FREELOOK] = true;
}
CEActions::~CEActions() {
}
-void CEActions::init(OSystem_WINCE3 *mainSystem, GameDetector &detector) {
- _instance = new CEActions(mainSystem, detector);
+void CEActions::init(GameDetector &detector) {
+ if (!CEDevice::hasSmartphoneResolution())
+ CEActionsPocket::init(detector);
+#ifdef WIN32_PLATFORM_WFSP
+ else
+ CEActionsSmartphone::init(detector);
+#endif
}
-bool CEActions::perform(ActionType action) {
- switch (action) {
- case ACTION_PAUSE:
- case ACTION_SAVE:
- case ACTION_SKIP:
- KeysBuffer::Instance()->simulate(&_key_action[action]);
- return true;
- case ACTION_KEYBOARD:
- _mainSystem->swap_panel();
- return true;
- case ACTION_HIDE:
- _mainSystem->swap_panel_visibility();
- return true;
- case ACTION_SOUND:
- _mainSystem->swap_sound_master();
- return true;
- case ACTION_RIGHTCLICK:
- _mainSystem->add_right_click();
- return true;
- case ACTION_CURSOR:
- _mainSystem->swap_mouse_visibility();
- return true;
- case ACTION_QUIT:
- GUI::MessageDialog alert("Do you want to quit ?", "Yes", "No");
- if (alert.runModal() == 1)
- _mainSystem->quit();
- return true;
- }
- return false;
+void CEActions::initInstance(OSystem_WINCE3 *mainSystem) {
+ _mainSystem = mainSystem;
+ _instance->_initialized = true;
+}
+
+bool CEActions::initialized() {
+ return _initialized;
}
bool CEActions::isActive(ActionType action) {
@@ -180,13 +81,9 @@ bool CEActions::mappingActive() {
bool CEActions::performMapped(unsigned int keyCode, bool pushed) {
int i;
- for (i=0; i<ACTION_LAST; i++) {
- if (_action_mapping[i] == keyCode) {
- if (pushed)
- return perform((ActionType)(i + 1));
- else
- return true;
- }
+ for (i=0; i<size(); i++) {
+ if (_action_mapping[i] == keyCode)
+ return perform((ActionType)i, pushed);
}
return false;
@@ -194,14 +91,14 @@ bool CEActions::performMapped(unsigned int keyCode, bool pushed) {
bool CEActions::loadMapping() {
const char *tempo;
- int version;
+ int current_version;
int i;
- version = ConfMan.getInt("CE_mapping_version");
- if (version != ACTIONS_VERSION)
+ current_version = ConfMan.getInt("action_mapping_version", domain());
+ if (current_version != version())
return false;
- tempo = ConfMan.get("CE_mapping").c_str();
+ tempo = ConfMan.get("action_mapping", domain()).c_str();
if (tempo && strlen(tempo)) {
- for (i=0; i<ACTION_LAST; i++) {
+ for (i=0; i<size(); i++) {
char x[6];
int j;
memset(x, 0, sizeof(x));
@@ -219,45 +116,32 @@ bool CEActions::saveMapping() {
char tempo[200];
int i;
tempo[0] = '\0';
- ConfMan.set("CE_mapping_version", ACTIONS_VERSION);
- for (i=0; i<ACTION_LAST; i++) {
+ ConfMan.set("action_mapping_version", version(), domain());
+ for (i=0; i<size(); i++) {
char x[4];
sprintf(x, "%.4x ", _action_mapping[i]);
strcat(tempo, x);
}
- ConfMan.set("CE_mapping", tempo);
+ ConfMan.set("action_mapping", tempo, domain());
ConfMan.flushToDisk();
return true;
}
unsigned int CEActions::getMapping(ActionType action) {
- return _action_mapping[action - 1];
+ return _action_mapping[action];
}
void CEActions::setMapping(ActionType action, unsigned int keyCode) {
int i;
- for (i=0; i<ACTION_LAST; i++) {
+ for (i=0; i<size(); i++) {
if (_action_mapping[i] == keyCode)
_action_mapping[i] = 0;
}
- _action_mapping[action - 1] = keyCode;
+ _action_mapping[action] = keyCode;
}
-bool CEActions::needsRightClickMapping() {
- if (!_right_click_needed)
- return false;
- else
- return (_action_mapping[ACTION_RIGHTCLICK] == 0);
-}
-
-bool CEActions::needsHideToolbarMapping() {
- if (!_hide_toolbar_needed)
- return false;
- else
- return (_action_mapping[ACTION_HIDE] == 0);
-}
-CEActions *CEActions::_instance = NULL;
+CEActions *CEActions::_instance = NULL; \ No newline at end of file