[Scummvm-cvs-logs] scummvm master -> c2640ed33a1b9c28e58b04877b7c4bf7b5fff570

tsoliman tarek at bashasoliman.com
Sun Feb 12 20:32:05 CET 2012


This automated email contains information about 7 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
52da780fbc KEYMAPPER: Refactor HardwareKeySet generation
e52f75eaa4 MAEMO: Define HardwareKeySet
705761011d KEYMAPPER: Allow ports to define their own global keymap
8c245af35c MAEMO: Define platform global keymap
883f9ae073 COMMON: Add custom backend event
d90d4d10a0 MAEMO: Refactor toggle click mode
c2640ed33a MAEMO: Use custom event Click Mode keymap action


Commit: 52da780fbc10200b91d92e7cd04932b101c7539b
    https://github.com/scummvm/scummvm/commit/52da780fbc10200b91d92e7cd04932b101c7539b
Author: Tarek Soliman (tsoliman at scummvm.org)
Date: 2012-02-12T11:28:13-08:00

Commit Message:
KEYMAPPER: Refactor HardwareKeySet generation

Changed paths:
    backends/keymapper/hardware-key.h
    backends/platform/sdl/hardwarekeys.cpp
    backends/platform/sdl/sdl.h



diff --git a/backends/keymapper/hardware-key.h b/backends/keymapper/hardware-key.h
index 32df042..713b086 100644
--- a/backends/keymapper/hardware-key.h
+++ b/backends/keymapper/hardware-key.h
@@ -32,7 +32,6 @@
 
 namespace Common {
 
-
 #define HWKEY_ID_SIZE (30)
 
 /**
@@ -62,6 +61,27 @@ struct HardwareKey {
 	}
 };
 
+/**
+ * Entry in a static table of available non-modifier keys
+ */
+struct KeyTableEntry {
+	const char *hwId;
+	KeyCode keycode;
+	uint16 ascii;
+	const char *desc;
+	KeyType preferredAction;
+	bool shiftable;
+};
+
+/**
+ * Entry in a static table of available key modifiers
+ */
+struct ModifierTableEntry {
+	byte flag;
+	const char *id;
+	const char *desc;
+	bool shiftable;
+};
 
 /**
  * Simple class to encapsulate a device's set of HardwareKeys.
@@ -71,6 +91,17 @@ struct HardwareKey {
 class HardwareKeySet {
 public:
 
+	/**
+	 * Add hardware keys to the set out of key and modifier tables.
+	 * @param keys       table of available keys
+	 * @param modifiers  table of available modifiers
+	 */
+	HardwareKeySet(const KeyTableEntry keys[], const ModifierTableEntry modifiers[]) {
+		addHardwareKeys(keys, modifiers);
+	}
+
+	HardwareKeySet() { }
+
 	virtual ~HardwareKeySet() {
 		List<const HardwareKey*>::const_iterator it;
 
@@ -111,6 +142,38 @@ public:
 		return _keys.size();
 	}
 
+	/**
+	 * Add hardware keys to the set out of key and modifier tables.
+	 * @param keys       table of available keys
+	 * @param modifiers  table of available modifiers
+	 */
+	void addHardwareKeys(const KeyTableEntry keys[], const ModifierTableEntry modifiers[]) {
+		const KeyTableEntry *key;
+		const ModifierTableEntry *mod;
+		char fullKeyId[50];
+		char fullKeyDesc[100];
+		uint16 ascii;
+
+		for (mod = modifiers; mod->id; mod++) {
+			for (key = keys; key->hwId; key++) {
+				ascii = key->ascii;
+
+				if (mod->shiftable && key->shiftable) {
+					snprintf(fullKeyId, 50, "%s%c", mod->id, toupper(key->hwId[0]));
+					snprintf(fullKeyDesc, 100, "%s%c", mod->desc, toupper(key->desc[0]));
+					ascii = toupper(key->ascii);
+				} else if (mod->shiftable) {
+					snprintf(fullKeyId, 50, "S+%s%s", mod->id, key->hwId);
+					snprintf(fullKeyDesc, 100, "Shift+%s%s", mod->desc, key->desc);
+				} else {
+					snprintf(fullKeyId, 50, "%s%s", mod->id, key->hwId);
+					snprintf(fullKeyDesc, 100, "%s%s", mod->desc, key->desc);
+				}
+
+				addHardwareKey(new HardwareKey(fullKeyId, KeyState(key->keycode, ascii, mod->flag), fullKeyDesc, key->preferredAction ));
+			}
+		}
+	}
 
 private:
 
@@ -128,7 +191,6 @@ private:
 	List<const HardwareKey*> _keys;
 };
 
-
 } // End of namespace Common
 
 #endif // #ifdef ENABLE_KEYMAPPER
diff --git a/backends/platform/sdl/hardwarekeys.cpp b/backends/platform/sdl/hardwarekeys.cpp
index 9a33e357..3e93786 100644
--- a/backends/platform/sdl/hardwarekeys.cpp
+++ b/backends/platform/sdl/hardwarekeys.cpp
@@ -28,16 +28,7 @@
 
 using namespace Common;
 
-struct Key {
-	const char *hwId;
-	KeyCode keycode;
-	uint16 ascii;
-	const char *desc;
-	KeyType preferredAction;
-	bool shiftable;
-};
-
-static const Key keys[] = {
+static const KeyTableEntry sdlKeys[] = {
 	{"BACKSPACE", KEYCODE_BACKSPACE, ASCII_BACKSPACE, "Backspace", kActionKeyType, false},
 	{"TAB", KEYCODE_TAB, ASCII_TAB, "Tab", kActionKeyType, false},
 	{"CLEAR", KEYCODE_CLEAR, 0, "Clear", kActionKeyType, false},
@@ -173,14 +164,7 @@ static const Key keys[] = {
 	{0, KEYCODE_INVALID, 0, 0, kGenericKeyType, false}
 };
 
-struct Mod {
-	byte flag;
-	const char *id;
-	const char *desc;
-	bool shiftable;
-};
-
-static const Mod modifiers[] = {
+static const ModifierTableEntry sdlModifiers[] = {
 	{ 0, "", "", false },
 	{ KBD_CTRL, "C+", "Ctrl+", false },
 	{ KBD_ALT, "A+", "Alt+", false },
@@ -195,35 +179,7 @@ static const Mod modifiers[] = {
 
 Common::HardwareKeySet *OSystem_SDL::getHardwareKeySet() {
 #ifdef ENABLE_KEYMAPPER
-	HardwareKeySet *keySet = new HardwareKeySet();
-	const Key *key;
-	const Mod *mod;
-	char fullKeyId[50];
-	char fullKeyDesc[100];
-	uint16 ascii;
-
-	for (mod = modifiers; mod->id; mod++) {
-		for (key = keys; key->hwId; key++) {
-			ascii = key->ascii;
-
-			if (mod->shiftable && key->shiftable) {
-				snprintf(fullKeyId, 50, "%s%c", mod->id, toupper(key->hwId[0]));
-				snprintf(fullKeyDesc, 100, "%s%c", mod->desc, toupper(key->desc[0]));
-				ascii = toupper(key->ascii);
-			} else if (mod->shiftable) {
-				snprintf(fullKeyId, 50, "S+%s%s", mod->id, key->hwId);
-				snprintf(fullKeyDesc, 100, "Shift+%s%s", mod->desc, key->desc);
-			} else {
-				snprintf(fullKeyId, 50, "%s%s", mod->id, key->hwId);
-				snprintf(fullKeyDesc, 100, "%s%s", mod->desc, key->desc);
-			}
-
-			keySet->addHardwareKey(new HardwareKey(fullKeyId, KeyState(key->keycode, ascii, mod->flag), fullKeyDesc, key->preferredAction ));
-		}
-	}
-
-	return keySet;
-
+	return new HardwareKeySet(sdlKeys, sdlModifiers);
 #else
 	return 0;
 #endif
diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h
index 22d79db..6c84c5c 100644
--- a/backends/platform/sdl/sdl.h
+++ b/backends/platform/sdl/sdl.h
@@ -30,6 +30,11 @@
 #include "backends/events/sdl/sdl-events.h"
 #include "backends/log/log.h"
 
+namespace Common {
+struct KeyTableEntry;
+struct ModifierTableEntry;
+}
+
 /**
  * Base OSystem class for all SDL ports.
  */


Commit: e52f75eaa40b6a8f6f0db3a14a7dabf2e54506d3
    https://github.com/scummvm/scummvm/commit/e52f75eaa40b6a8f6f0db3a14a7dabf2e54506d3
Author: Tarek Soliman (tsoliman at scummvm.org)
Date: 2012-02-12T11:28:13-08:00

Commit Message:
MAEMO: Define HardwareKeySet

Changed paths:
  A backends/platform/maemo/maemo-keys.h
    backends/platform/maemo/maemo.cpp
    backends/platform/maemo/maemo.h



diff --git a/backends/platform/maemo/maemo-keys.h b/backends/platform/maemo/maemo-keys.h
new file mode 100644
index 0000000..6725b11
--- /dev/null
+++ b/backends/platform/maemo/maemo-keys.h
@@ -0,0 +1,144 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * 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.
+ *
+ */
+
+#if defined(MAEMO)
+#if defined(ENABLE_KEYMAPPER)
+
+#ifndef PLATFORM_SDL_MAEMO_KEYS_H
+#define PLATFORM_SDL_MAEMO_KEYS_H
+
+#include "common/keyboard.h"
+
+#include "backends/keymapper/hardware-key.h"
+
+namespace Common {
+
+static const ModifierTableEntry maemoModifiers[] = {
+	{ 0, "", "", false },
+	{ KBD_CTRL, "C+", "Ctrl+", false },
+	{ KBD_SHIFT, "", "", true },
+	{ KBD_SHIFT | KBD_CTRL, "S+C+", "Shift+Ctrl+", true },
+	{ 0, 0, 0, false }
+};
+
+static const KeyTableEntry maemoKeys[] = {
+	{"BACKSPACE", KEYCODE_BACKSPACE, ASCII_BACKSPACE, "Backspace", kActionKeyType, false},
+	{"TAB", KEYCODE_TAB, ASCII_TAB, "Tab", kActionKeyType, false},
+	{"CLEAR", KEYCODE_CLEAR, 0, "Clear", kActionKeyType, false},
+	{"RETURN", KEYCODE_RETURN, ASCII_RETURN, "MCenter", kActionKeyType, false},
+	{"ESCAPE", KEYCODE_ESCAPE, ASCII_ESCAPE, "Esc", kStartKeyType, false},
+	{"SPACE", KEYCODE_SPACE, ASCII_SPACE, "Space", kActionKeyType, false},
+	{"EXCLAIM", KEYCODE_EXCLAIM, '!', "!", kActionKeyType, false},
+	{"QUOTEDBL", KEYCODE_QUOTEDBL, '"', "\"", kActionKeyType, false},
+	{"HASH", KEYCODE_HASH, '#', "#", kActionKeyType, false},
+	{"DOLLAR", KEYCODE_DOLLAR, '$', "$", kActionKeyType, false},
+	{"AMPERSAND", KEYCODE_AMPERSAND, '&', "&", kActionKeyType, false},
+	{"QUOTE", KEYCODE_QUOTE, '\'', "'", kActionKeyType, false},
+	{"LEFTPAREN", KEYCODE_LEFTPAREN, '(', "(", kActionKeyType, false},
+	{"RIGHTPAREN", KEYCODE_RIGHTPAREN, ')', ")", kActionKeyType, false},
+	{"ASTERISK", KEYCODE_ASTERISK, '*', "*", kActionKeyType, false},
+	{"PLUS", KEYCODE_PLUS, '+', "+", kActionKeyType, false},
+	{"COMMA", KEYCODE_COMMA, ',', ",", kActionKeyType, false},
+	{"MINUS", KEYCODE_MINUS, '-', "-", kActionKeyType, false},
+	{"PERIOD", KEYCODE_PERIOD, '.', ".", kActionKeyType, false},
+	{"SLASH", KEYCODE_SLASH, '/', "/", kActionKeyType, false},
+	{"0", KEYCODE_0, '0', "0", kActionKeyType, false},
+	{"1", KEYCODE_1, '1', "1", kActionKeyType, false},
+	{"2", KEYCODE_2, '2', "2", kActionKeyType, false},
+	{"3", KEYCODE_3, '3', "3", kActionKeyType, false},
+	{"4", KEYCODE_4, '4', "4", kActionKeyType, false},
+	{"5", KEYCODE_5, '5', "5", kActionKeyType, false},
+	{"6", KEYCODE_6, '6', "6", kActionKeyType, false},
+	{"7", KEYCODE_7, '7', "7", kActionKeyType, false},
+	{"8", KEYCODE_8, '8', "8", kActionKeyType, false},
+	{"9", KEYCODE_9, '9', "9", kActionKeyType, false},
+	{"COLON", KEYCODE_COLON, ':', ":", kActionKeyType, false},
+	{"SEMICOLON", KEYCODE_SEMICOLON, ';', ";", kActionKeyType, false},
+	{"LESS", KEYCODE_LESS, '<', "<", kActionKeyType, false},
+	{"EQUALS", KEYCODE_EQUALS, '=', "=", kActionKeyType, false},
+	{"GREATER", KEYCODE_GREATER, '>', ">", kActionKeyType, false},
+	{"QUESTION", KEYCODE_QUESTION, '?', "?", kActionKeyType, false},
+	{"AT", KEYCODE_AT, '@', "@", kActionKeyType, false},
+
+	{"LEFTBRACKET", KEYCODE_LEFTBRACKET, '[', "[", kActionKeyType, false},
+	{"BACKSLASH", KEYCODE_BACKSLASH, '\\', "\\", kActionKeyType, false},
+	{"RIGHTBRACKET", KEYCODE_RIGHTBRACKET, ']', "]", kActionKeyType, false},
+	{"CARET", KEYCODE_CARET, '^', "^", kActionKeyType, false},
+	{"UNDERSCORE", KEYCODE_UNDERSCORE, '_', "_", kActionKeyType, false},
+	{"BACKQUOTE", KEYCODE_BACKQUOTE, '`', "`", kActionKeyType, false},
+	{"a", KEYCODE_a, 'a', "a", kActionKeyType, true},
+	{"b", KEYCODE_b, 'b', "b", kActionKeyType, true},
+	{"c", KEYCODE_c, 'c', "c", kActionKeyType, true},
+	{"d", KEYCODE_d, 'd', "d", kActionKeyType, true},
+	{"e", KEYCODE_e, 'e', "e", kActionKeyType, true},
+	{"f", KEYCODE_f, 'f', "f", kActionKeyType, true},
+	{"g", KEYCODE_g, 'g', "g", kActionKeyType, true},
+	{"h", KEYCODE_h, 'h', "h", kActionKeyType, true},
+	{"i", KEYCODE_i, 'i', "i", kActionKeyType, true},
+	{"j", KEYCODE_j, 'j', "j", kActionKeyType, true},
+	{"k", KEYCODE_k, 'k', "k", kActionKeyType, true},
+	{"l", KEYCODE_l, 'l', "l", kActionKeyType, true},
+	{"m", KEYCODE_m, 'm', "m", kActionKeyType, true},
+	{"n", KEYCODE_n, 'n', "n", kActionKeyType, true},
+	{"o", KEYCODE_o, 'o', "o", kActionKeyType, true},
+	{"p", KEYCODE_p, 'p', "p", kActionKeyType, true},
+	{"q", KEYCODE_q, 'q', "q", kActionKeyType, true},
+	{"r", KEYCODE_r, 'r', "r", kActionKeyType, true},
+	{"s", KEYCODE_s, 's', "s", kActionKeyType, true},
+	{"t", KEYCODE_t, 't', "t", kActionKeyType, true},
+	{"u", KEYCODE_u, 'u', "u", kActionKeyType, true},
+	{"v", KEYCODE_v, 'v', "v", kActionKeyType, true},
+	{"w", KEYCODE_w, 'w', "w", kActionKeyType, true},
+	{"x", KEYCODE_x, 'x', "x", kActionKeyType, true},
+	{"y", KEYCODE_y, 'y', "y", kActionKeyType, true},
+	{"z", KEYCODE_z, 'z', "z", kActionKeyType, true},
+	{"DELETE", KEYCODE_DELETE, 0, "Del", kActionKeyType, false},
+
+	{"KP_ENTER", KEYCODE_KP_ENTER, 0, "Enter", kActionKeyType, false},
+
+	// Arrows + Home/End pad
+	{"UP", KEYCODE_UP, 0, "Up", kDirUpKeyType, false},
+	{"DOWN", KEYCODE_DOWN, 0, "Down", kDirDownKeyType, false},
+	{"RIGHT", KEYCODE_RIGHT, 0, "Right", kDirRightKeyType, false},
+	{"LEFT", KEYCODE_LEFT, 0, "Left", kDirLeftKeyType, false},
+
+	// Function keys
+	{"F1", KEYCODE_F1, ASCII_F1, "F1", kActionKeyType, false},
+	{"F2", KEYCODE_F2, ASCII_F2, "F2", kActionKeyType, false},
+	{"F3", KEYCODE_F3, ASCII_F3, "F3", kActionKeyType, false},
+	{"F4", KEYCODE_F4, ASCII_F4, "Menu", kActionKeyType, false},
+	{"F5", KEYCODE_F5, ASCII_F5, "Home", kActionKeyType, false},
+	{"F6", KEYCODE_F6, ASCII_F6, "FullScreen", kActionKeyType, false},
+	{"F7", KEYCODE_F7, ASCII_F7, "Zoom+", kActionKeyType, false},
+	{"F8", KEYCODE_F8, ASCII_F8, "Zoom-", kActionKeyType, false},
+	{"F9", KEYCODE_F9, ASCII_F9, "F9", kActionKeyType, false},
+
+	{0, KEYCODE_INVALID, 0, 0, kGenericKeyType, false}
+};
+
+
+} // namespace Common
+
+#endif // ifndef PLATFORM_SDL_MAEMO_KEYS_H
+
+#endif // if defined(ENABLE_KEYMAPPER)
+#endif // if defined(MAEMO)
diff --git a/backends/platform/maemo/maemo.cpp b/backends/platform/maemo/maemo.cpp
index 454a136..24f5d38 100644
--- a/backends/platform/maemo/maemo.cpp
+++ b/backends/platform/maemo/maemo.cpp
@@ -28,6 +28,7 @@
 #include "common/config-manager.h"
 
 #include "backends/platform/maemo/maemo.h"
+#include "backends/platform/maemo/maemo-keys.h"
 #include "backends/events/maemosdl/maemosdl-events.h"
 #include "backends/graphics/maemosdl/maemosdl-graphics.h"
 #include "common/textconsole.h"
@@ -118,6 +119,16 @@ void OSystem_SDL_Maemo::setupIcon() {
 	// http://bugzilla.libsdl.org/show_bug.cgi?id=586
 }
 
+Common::HardwareKeySet *OSystem_SDL_Maemo::getHardwareKeySet() {
+#ifdef ENABLE_KEYMAPPER
+	return new Common::HardwareKeySet(Common::maemoKeys, Common::maemoModifiers);
+#else
+	return OSystem_POSIX::getHardwareKeySet();
+#endif
+}
+
 } //namespace Maemo
 
+
+
 #endif
diff --git a/backends/platform/maemo/maemo.h b/backends/platform/maemo/maemo.h
index 32b5247..44b84cd 100644
--- a/backends/platform/maemo/maemo.h
+++ b/backends/platform/maemo/maemo.h
@@ -39,6 +39,7 @@ public:
 	virtual void fatalError();
 	virtual void setWindowCaption(const char *caption);
 	virtual void setupIcon();
+	virtual Common::HardwareKeySet *getHardwareKeySet();
 
 	Model getModel() { return _model; }
 


Commit: 705761011d24f08eb56add90f6dfa605b36ac8ee
    https://github.com/scummvm/scummvm/commit/705761011d24f08eb56add90f6dfa605b36ac8ee
Author: Tarek Soliman (tsoliman at scummvm.org)
Date: 2012-02-12T11:28:13-08:00

Commit Message:
KEYMAPPER: Allow ports to define their own global keymap

Changed paths:
    backends/keymapper/keymapper.cpp
    base/main.cpp
    common/system.h



diff --git a/backends/keymapper/keymapper.cpp b/backends/keymapper/keymapper.cpp
index 6d9ae21..10cff94 100644
--- a/backends/keymapper/keymapper.cpp
+++ b/backends/keymapper/keymapper.cpp
@@ -145,6 +145,8 @@ Keymap *Keymapper::getKeymap(const String& name, bool *globalReturn) {
 
 bool Keymapper::pushKeymap(const String& name, bool transparent) {
 	bool global;
+
+	assert(!name.empty());
 	Keymap *newMap = getKeymap(name, &global);
 
 	if (!newMap) {
diff --git a/base/main.cpp b/base/main.cpp
index 9bf67a3..f3ff081 100644
--- a/base/main.cpp
+++ b/base/main.cpp
@@ -259,13 +259,11 @@ static void setupGraphics(OSystem &system) {
 }
 
 static void setupKeymapper(OSystem &system) {
-
 #ifdef ENABLE_KEYMAPPER
 	using namespace Common;
 
 	Keymapper *mapper = system.getEventManager()->getKeymapper();
-	Keymap *globalMap = new Keymap(kGlobalKeymapName);
-	Action *act;
+
 	HardwareKeySet *keySet;
 
 	keySet = system.getHardwareKeySet();
@@ -274,30 +272,39 @@ static void setupKeymapper(OSystem &system) {
 	mapper->registerHardwareKeySet(keySet);
 
 	// Now create the global keymap
-	act = new Action(globalMap, "MENU", _("Menu"), kGenericActionType, kSelectKeyType);
+	Keymap *primaryGlobalKeymap = new Keymap(kGlobalKeymapName);
+	Action *act;
+	act = new Action(primaryGlobalKeymap, "MENU", _("Menu"), kGenericActionType, kSelectKeyType);
 	act->addEvent(EVENT_MAINMENU);
 
-	act = new Action(globalMap, "SKCT", _("Skip"), kGenericActionType, kActionKeyType);
+	act = new Action(primaryGlobalKeymap, "SKCT", _("Skip"), kGenericActionType, kActionKeyType);
 	act->addKeyEvent(KeyState(KEYCODE_ESCAPE, ASCII_ESCAPE, 0));
 
-	act = new Action(globalMap, "PAUS", _("Pause"), kGenericActionType, kStartKeyType);
+	act = new Action(primaryGlobalKeymap, "PAUS", _("Pause"), kGenericActionType, kStartKeyType);
 	act->addKeyEvent(KeyState(KEYCODE_SPACE, ' ', 0));
 
-	act = new Action(globalMap, "SKLI", _("Skip line"), kGenericActionType, kActionKeyType);
+	act = new Action(primaryGlobalKeymap, "SKLI", _("Skip line"), kGenericActionType, kActionKeyType);
 	act->addKeyEvent(KeyState(KEYCODE_PERIOD, '.', 0));
 
-	act = new Action(globalMap, "VIRT", _("Display keyboard"), kVirtualKeyboardActionType);
+	act = new Action(primaryGlobalKeymap, "VIRT", _("Display keyboard"), kVirtualKeyboardActionType);
 	act->addKeyEvent(KeyState(KEYCODE_F7, ASCII_F7, 0));
 
-	act = new Action(globalMap, "REMP", _("Remap keys"), kKeyRemapActionType);
+	act = new Action(primaryGlobalKeymap, "REMP", _("Remap keys"), kKeyRemapActionType);
 	act->addKeyEvent(KeyState(KEYCODE_F8, ASCII_F8, 0));
 
-	act = new Action(globalMap, "FULS", _("Toggle FullScreen"), kKeyRemapActionType);
+	act = new Action(primaryGlobalKeymap, "FULS", _("Toggle FullScreen"), kKeyRemapActionType);
 	act->addKeyEvent(KeyState(KEYCODE_RETURN, ASCII_RETURN, KBD_ALT));
 
-	mapper->addGlobalKeymap(globalMap);
-
+	mapper->addGlobalKeymap(primaryGlobalKeymap);
 	mapper->pushKeymap(kGlobalKeymapName, true);
+
+	// Get the platform-specific global keymap (if it exists)
+	Keymap *platformGlobalKeymap = system.getGlobalKeymap();
+	if (platformGlobalKeymap) {
+		String platformGlobalKeymapName = platformGlobalKeymap->getName();
+		mapper->addGlobalKeymap(platformGlobalKeymap);
+		mapper->pushKeymap(platformGlobalKeymapName, true);
+	}
 #endif
 
 }
diff --git a/common/system.h b/common/system.h
index 413fe32..2a651bb 100644
--- a/common/system.h
+++ b/common/system.h
@@ -52,6 +52,7 @@ class TimerManager;
 class SeekableReadStream;
 class WriteStream;
 class HardwareKeySet;
+class Keymap;
 }
 
 class AudioCDManager;
@@ -941,6 +942,16 @@ public:
 	 */
 	virtual Common::HardwareKeySet *getHardwareKeySet() { return 0; }
 
+	/**
+	 * Return a platform-specific global keymap
+	 *
+	 * @return Keymap with actions appropriate for the platform
+	 *
+	 * The caller will use and delete the return object.
+	 *
+	 * See keymapper documentation for further reference.
+	 */
+	virtual Common::Keymap *getGlobalKeymap() { return 0; }
 	//@}
 
 


Commit: 8c245af35cc2ac3666b631be12e1f130bfbad503
    https://github.com/scummvm/scummvm/commit/8c245af35cc2ac3666b631be12e1f130bfbad503
Author: Tarek Soliman (tsoliman at scummvm.org)
Date: 2012-02-12T11:28:13-08:00

Commit Message:
MAEMO: Define platform global keymap

Changed paths:
    backends/platform/maemo/maemo.cpp
    backends/platform/maemo/maemo.h
    po/POTFILES



diff --git a/backends/platform/maemo/maemo.cpp b/backends/platform/maemo/maemo.cpp
index 24f5d38..eae18cc 100644
--- a/backends/platform/maemo/maemo.cpp
+++ b/backends/platform/maemo/maemo.cpp
@@ -31,7 +31,9 @@
 #include "backends/platform/maemo/maemo-keys.h"
 #include "backends/events/maemosdl/maemosdl-events.h"
 #include "backends/graphics/maemosdl/maemosdl-graphics.h"
+#include "backends/keymapper/keymapper.h"
 #include "common/textconsole.h"
+#include "common/translation.h"
 
 
 #include <SDL/SDL_syswm.h>
@@ -127,6 +129,31 @@ Common::HardwareKeySet *OSystem_SDL_Maemo::getHardwareKeySet() {
 #endif
 }
 
+Common::Keymap *OSystem_SDL_Maemo::getGlobalKeymap() {
+#ifdef ENABLE_KEYMAPPER
+	using namespace Common;
+	Keymap *globalMap = new Keymap("maemo");
+
+	Action *act;
+
+//	act = new Action(globalMap, "CLKM", _("Click Mode"), kKeyRemapActionType);
+//	act->addCustomEvent(CLICK_MODE);
+
+	act = new Action(globalMap, "LCLK", _("Left Click"), kKeyRemapActionType);
+	act->addLeftClickEvent();
+
+	act = new Action(globalMap, "MCLK", _("Middle Click"), kKeyRemapActionType);
+	act->addMiddleClickEvent();
+
+	act = new Action(globalMap, "RCLK", _("Right Click"), kKeyRemapActionType);
+	act->addRightClickEvent();
+
+	return globalMap;
+#else
+	return OSystem_POSIX::getGlobalKeymap();
+#endif
+}
+
 } //namespace Maemo
 
 
diff --git a/backends/platform/maemo/maemo.h b/backends/platform/maemo/maemo.h
index 44b84cd..e94c6c6 100644
--- a/backends/platform/maemo/maemo.h
+++ b/backends/platform/maemo/maemo.h
@@ -40,6 +40,7 @@ public:
 	virtual void setWindowCaption(const char *caption);
 	virtual void setupIcon();
 	virtual Common::HardwareKeySet *getHardwareKeySet();
+	virtual Common::Keymap *getGlobalKeymap();
 
 	Model getModel() { return _model; }
 
diff --git a/po/POTFILES b/po/POTFILES
index 9898958..33492c0 100644
--- a/po/POTFILES
+++ b/po/POTFILES
@@ -64,6 +64,7 @@ backends/keymapper/remap-dialog.cpp
 backends/midi/windows.cpp
 backends/platform/ds/arm9/source/dsoptions.cpp
 backends/platform/iphone/osys_events.cpp
+backends/platform/maemo/maemo.cpp
 backends/platform/sdl/macosx/appmenu_osx.mm
 backends/graphics/surfacesdl/surfacesdl-graphics.cpp
 backends/graphics/opengl/opengl-graphics.cpp


Commit: 883f9ae07338cd044604c7821a22485d9e1f5683
    https://github.com/scummvm/scummvm/commit/883f9ae07338cd044604c7821a22485d9e1f5683
Author: Tarek Soliman (tsoliman at scummvm.org)
Date: 2012-02-12T11:28:13-08:00

Commit Message:
COMMON: Add custom backend event

Changed paths:
    common/events.h



diff --git a/common/events.h b/common/events.h
index 673ccb6..04dfd39 100644
--- a/common/events.h
+++ b/common/events.h
@@ -72,9 +72,11 @@ enum EventType {
 	 * use events to ask for the save game dialog or to pause the engine.
 	 * An associated enumerated type can accomplish this.
 	 **/
-	EVENT_PREDICTIVE_DIALOG = 12
+	EVENT_PREDICTIVE_DIALOG = 12,
+	EVENT_CUSTOM_BACKEND = 13
 };
 
+typedef uint32 CustomEventType;
 /**
  * Data structure for an event. A pointer to an instance of Event
  * can be passed to pollEvent.
@@ -99,6 +101,8 @@ struct Event {
 	 */
 	Point mouse;
 
+	CustomEventType customType;
+
 	Event() : type(EVENT_INVALID), synthetic(false) {}
 };
 


Commit: d90d4d10a09e1bab04154aa81162aac9c994f23c
    https://github.com/scummvm/scummvm/commit/d90d4d10a09e1bab04154aa81162aac9c994f23c
Author: Tarek Soliman (tsoliman at scummvm.org)
Date: 2012-02-12T11:28:13-08:00

Commit Message:
MAEMO: Refactor toggle click mode

Changed paths:
    backends/events/maemosdl/maemosdl-events.cpp
    backends/events/maemosdl/maemosdl-events.h



diff --git a/backends/events/maemosdl/maemosdl-events.cpp b/backends/events/maemosdl/maemosdl-events.cpp
index 07af368..d7bda8c 100644
--- a/backends/events/maemosdl/maemosdl-events.cpp
+++ b/backends/events/maemosdl/maemosdl-events.cpp
@@ -124,9 +124,7 @@ bool MaemoSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) {
 					debug(9, "remapping to F7 up (virtual keyboard)");
 					return true;
 				} else {
-					_clickEnabled = !_clickEnabled;
-					((SurfaceSdlGraphicsManager*) _graphicsManager)->displayMessageOnOSD(
-					  _clickEnabled ? _("Clicking Enabled") : _("Clicking Disabled"));
+					toggleClickMode();
 					debug(9, "remapping to click toggle");
 					return true;
 				}
@@ -158,6 +156,14 @@ bool MaemoSdlEventSource::handleMouseButtonUp(SDL_Event &ev, Common::Event &even
 	return SdlEventSource::handleMouseButtonUp(ev, event);
 }
 
+bool MaemoSdlEventSource::toggleClickMode() {
+	_clickEnabled = !_clickEnabled;
+	((SurfaceSdlGraphicsManager*) _graphicsManager)->displayMessageOnOSD(
+	  _clickEnabled ? _("Clicking Enabled") : _("Clicking Disabled"));
+
+	return _clickEnabled;
+}
+
 } // namespace Maemo
 
 #endif // if defined(MAEMO)
diff --git a/backends/events/maemosdl/maemosdl-events.h b/backends/events/maemosdl/maemosdl-events.h
index 5c06c4b..f7b2bbf 100644
--- a/backends/events/maemosdl/maemosdl-events.h
+++ b/backends/events/maemosdl/maemosdl-events.h
@@ -37,6 +37,8 @@ namespace Maemo {
 class MaemoSdlEventSource : public SdlEventSource {
 public:
 	MaemoSdlEventSource();
+
+	bool toggleClickMode();
 protected:
 	virtual bool remapKey(SDL_Event &ev, Common::Event &event);
 	virtual bool handleMouseButtonDown(SDL_Event &ev, Common::Event &event);


Commit: c2640ed33a1b9c28e58b04877b7c4bf7b5fff570
    https://github.com/scummvm/scummvm/commit/c2640ed33a1b9c28e58b04877b7c4bf7b5fff570
Author: Tarek Soliman (tsoliman at scummvm.org)
Date: 2012-02-12T11:28:13-08:00

Commit Message:
MAEMO: Use custom event Click Mode keymap action

Changed paths:
    backends/events/maemosdl/maemosdl-events.cpp
    backends/events/maemosdl/maemosdl-events.h
    backends/platform/maemo/maemo-common.h
    backends/platform/maemo/maemo.cpp
    backends/platform/maemo/maemo.h



diff --git a/backends/events/maemosdl/maemosdl-events.cpp b/backends/events/maemosdl/maemosdl-events.cpp
index d7bda8c..acca1a3 100644
--- a/backends/events/maemosdl/maemosdl-events.cpp
+++ b/backends/events/maemosdl/maemosdl-events.cpp
@@ -164,6 +164,22 @@ bool MaemoSdlEventSource::toggleClickMode() {
 	return _clickEnabled;
 }
 
+MaemoSdlEventObserver::MaemoSdlEventObserver(MaemoSdlEventSource *eventSource) {
+	assert(_eventSource);
+	_eventSource = eventSource;
+}
+
+bool MaemoSdlEventObserver::notifyEvent(const Common::Event &event) {
+	if (event.type != Common::EVENT_CUSTOM_BACKEND)
+		return false;
+	if (event.customType == kEventClickMode) {
+		assert(_eventSource);
+		_eventSource->toggleClickMode();
+		return true;
+	}
+	return false;
+}
+
 } // namespace Maemo
 
 #endif // if defined(MAEMO)
diff --git a/backends/events/maemosdl/maemosdl-events.h b/backends/events/maemosdl/maemosdl-events.h
index f7b2bbf..f3f05fe 100644
--- a/backends/events/maemosdl/maemosdl-events.h
+++ b/backends/events/maemosdl/maemosdl-events.h
@@ -47,6 +47,15 @@ protected:
 	bool _clickEnabled;
 };
 
+class MaemoSdlEventObserver : public Common::EventObserver {
+public:
+	MaemoSdlEventObserver(MaemoSdlEventSource *eventSource);
+
+	virtual bool notifyEvent(const Common::Event &event);
+private:
+	MaemoSdlEventSource *_eventSource;
+};
+
 } // namespace Maemo
 
 #endif // include guard
diff --git a/backends/platform/maemo/maemo-common.h b/backends/platform/maemo/maemo-common.h
index 5f8645a..cd4bb3b 100644
--- a/backends/platform/maemo/maemo-common.h
+++ b/backends/platform/maemo/maemo-common.h
@@ -51,6 +51,11 @@ static const Model models[] = {
 	{0, kModelTypeInvalid, 0, true}
 };
 
+enum CustomEventType {
+	kEventClickMode = 1,
+	kEventInvalid = 0
+};
+
 } // namespace Maemo
 
 #endif // ifndef PLATFORM_SDL_MAEMO_COMMON_H
diff --git a/backends/platform/maemo/maemo.cpp b/backends/platform/maemo/maemo.cpp
index eae18cc..fe60bdc 100644
--- a/backends/platform/maemo/maemo.cpp
+++ b/backends/platform/maemo/maemo.cpp
@@ -46,6 +46,10 @@ OSystem_SDL_Maemo::OSystem_SDL_Maemo()
 	OSystem_POSIX() {
 }
 
+OSystem_SDL_Maemo::~OSystem_SDL_Maemo() {
+	delete _eventObserver;
+}
+
 void OSystem_SDL_Maemo::initBackend() {
 	// Create the events manager
 	if (_eventSource == 0)
@@ -54,12 +58,16 @@ void OSystem_SDL_Maemo::initBackend() {
 	if (_graphicsManager == 0)
 		_graphicsManager = new MaemoSdlGraphicsManager(_eventSource);
 
+	if (_eventObserver == 0)
+		_eventObserver = new MaemoSdlEventObserver((MaemoSdlEventSource *)_eventSource);
+
 	ConfMan.set("vkeybdpath", DATA_PATH);
 
 	_model = Model(detectModel());
 
 	// Call parent implementation of this method
 	OSystem_POSIX::initBackend();
+	initObserver();
 }
 
 void OSystem_SDL_Maemo::quit() {
@@ -136,8 +144,11 @@ Common::Keymap *OSystem_SDL_Maemo::getGlobalKeymap() {
 
 	Action *act;
 
-//	act = new Action(globalMap, "CLKM", _("Click Mode"), kKeyRemapActionType);
-//	act->addCustomEvent(CLICK_MODE);
+	act = new Action(globalMap, "CLKM", _("Click Mode"), kKeyRemapActionType);
+	Event evt = Event();
+	evt.type = EVENT_CUSTOM_BACKEND;
+	evt.customType = Maemo::kEventClickMode;
+	act->addEvent(evt);
 
 	act = new Action(globalMap, "LCLK", _("Left Click"), kKeyRemapActionType);
 	act->addLeftClickEvent();
@@ -154,8 +165,11 @@ Common::Keymap *OSystem_SDL_Maemo::getGlobalKeymap() {
 #endif
 }
 
-} //namespace Maemo
-
+void OSystem_SDL_Maemo::initObserver() {
+	assert(_eventManager);
+	_eventManager->getEventDispatcher()->registerObserver(_eventObserver, 10, false);
+}
 
+} //namespace Maemo
 
 #endif
diff --git a/backends/platform/maemo/maemo.h b/backends/platform/maemo/maemo.h
index e94c6c6..821f352 100644
--- a/backends/platform/maemo/maemo.h
+++ b/backends/platform/maemo/maemo.h
@@ -29,10 +29,12 @@
 #include "backends/platform/maemo/maemo-common.h"
 
 namespace Maemo {
+class MaemoSdlEventObserver;
 
 class OSystem_SDL_Maemo : public OSystem_POSIX {
 public:
 	OSystem_SDL_Maemo();
+	~OSystem_SDL_Maemo();
 
 	virtual void initBackend();
 	virtual void quit();
@@ -46,10 +48,11 @@ public:
 
 private:
 	virtual void setXWindowName(const char *caption);
+	void initObserver();
 
 	const Model detectModel();
 	Model _model;
-
+	MaemoSdlEventObserver *_eventObserver;
 };
 
 } // namespace Maemo






More information about the Scummvm-git-logs mailing list