[Scummvm-cvs-logs] SF.net SVN: scummvm:[33986] scummvm/branches/gsoc2008-vkeybd

kenny-d at users.sourceforge.net kenny-d at users.sourceforge.net
Mon Aug 18 12:07:14 CEST 2008


Revision: 33986
          http://scummvm.svn.sourceforge.net/scummvm/?rev=33986&view=rev
Author:   kenny-d
Date:     2008-08-18 10:07:11 +0000 (Mon, 18 Aug 2008)

Log Message:
-----------
- proper init of virtual keyboard now implemented (involved added EventManager::init() which is called after screen has been initialised)
- changed HardwareKey / Action id field to an array of 4 chars instead of int32. Means that the keymap key/value pairs in config file are more readable.

Modified Paths:
--------------
    scummvm/branches/gsoc2008-vkeybd/backends/events/default/default-events.cpp
    scummvm/branches/gsoc2008-vkeybd/backends/events/default/default-events.h
    scummvm/branches/gsoc2008-vkeybd/backends/keymapper/action.cpp
    scummvm/branches/gsoc2008-vkeybd/backends/keymapper/action.h
    scummvm/branches/gsoc2008-vkeybd/backends/keymapper/hardware-key.h
    scummvm/branches/gsoc2008-vkeybd/backends/keymapper/keymap.cpp
    scummvm/branches/gsoc2008-vkeybd/backends/keymapper/keymap.h
    scummvm/branches/gsoc2008-vkeybd/backends/platform/sdl/events.cpp
    scummvm/branches/gsoc2008-vkeybd/backends/vkeybd/virtual-keyboard-gui.cpp
    scummvm/branches/gsoc2008-vkeybd/backends/vkeybd/virtual-keyboard-gui.h
    scummvm/branches/gsoc2008-vkeybd/backends/vkeybd/virtual-keyboard.cpp
    scummvm/branches/gsoc2008-vkeybd/base/main.cpp
    scummvm/branches/gsoc2008-vkeybd/common/events.h

Modified: scummvm/branches/gsoc2008-vkeybd/backends/events/default/default-events.cpp
===================================================================
--- scummvm/branches/gsoc2008-vkeybd/backends/events/default/default-events.cpp	2008-08-18 07:12:05 UTC (rev 33985)
+++ scummvm/branches/gsoc2008-vkeybd/backends/events/default/default-events.cpp	2008-08-18 10:07:11 UTC (rev 33986)
@@ -199,6 +199,8 @@
 	_vk = new Common::VirtualKeyboard();
 	_keymapper = new Common::Keymapper(this);
 	_remap = false;
+
+	//init();
 }
 
 DefaultEventManager::~DefaultEventManager() {
@@ -259,6 +261,14 @@
 	_boss->deleteMutex(_recorderMutex);
 }
 
+void DefaultEventManager::init() {
+	if (ConfMan.hasKey("vkeybd_pack_name")) {
+		_vk->loadKeyboardPack(ConfMan.get("vkeybd_pack_name"));
+	} else {
+		_vk->loadKeyboardPack("vkeybd");
+	}
+}
+
 bool DefaultEventManager::playback(Common::Event &event) {
 
 	if (!_hasPlaybackEvent) {
@@ -418,22 +428,15 @@
 			_keyRepeatTime = time + kKeyRepeatInitialDelay;
 #endif
 
-			// HACK to show/hide keyboard (keyboard is not shown if gui is active)
 			if (event.kbd.keycode == Common::KEYCODE_F6 && event.kbd.flags == 0) {
 				if (_vk->isDisplaying()) {
 					_vk->close(true);
 				} else {
-					static bool enabled = true;
-					if (enabled && _vk->isLoaded() == false) {
-						enabled = _vk->loadKeyboardPack("vkeybd");
-					}
-					if (enabled) {
-						bool isPaused = (g_engine) ? g_engine->isPaused() : true;
-						if (!isPaused) g_engine->pauseEngine(true);
-						_vk->show();
-						if (!isPaused) g_engine->pauseEngine(false);
-						result = false;
-					}
+					bool isPaused = (g_engine) ? g_engine->isPaused() : true;
+					if (!isPaused) g_engine->pauseEngine(true);
+					_vk->show();
+					if (!isPaused) g_engine->pauseEngine(false);
+					result = false;
 				}
 			} else if (event.kbd.keycode == Common::KEYCODE_F7 && event.kbd.flags == 0) {
 				if (!_remap) {

Modified: scummvm/branches/gsoc2008-vkeybd/backends/events/default/default-events.h
===================================================================
--- scummvm/branches/gsoc2008-vkeybd/backends/events/default/default-events.h	2008-08-18 07:12:05 UTC (rev 33985)
+++ scummvm/branches/gsoc2008-vkeybd/backends/events/default/default-events.h	2008-08-18 10:07:11 UTC (rev 33986)
@@ -122,6 +122,7 @@
 	DefaultEventManager(OSystem *boss);
 	~DefaultEventManager();
 
+	virtual void init();
 	virtual bool pollEvent(Common::Event &event);
 	virtual void pushEvent(const Common::Event &event);
 	virtual void registerRandomSource(Common::RandomSource &rnd, const char *name);

Modified: scummvm/branches/gsoc2008-vkeybd/backends/keymapper/action.cpp
===================================================================
--- scummvm/branches/gsoc2008-vkeybd/backends/keymapper/action.cpp	2008-08-18 07:12:05 UTC (rev 33985)
+++ scummvm/branches/gsoc2008-vkeybd/backends/keymapper/action.cpp	2008-08-18 10:07:11 UTC (rev 33986)
@@ -28,11 +28,15 @@
 
 namespace Common {
 
-Action::Action(Keymap *boss, int32 i,	String des, ActionCategory cat, 
+Action::Action(Keymap *boss, const char *i,	String des, ActionCategory cat, 
 			   ActionType typ, int pri, int grp, int flg)
-	: _boss(boss), id(i), description(des), category(cat), type(typ), 
+	: _boss(boss), description(des), category(cat), type(typ), 
 	priority(pri), group(grp), flags(flg), _hwKey(0) {
+	assert(i);
 	assert(_boss);
+
+	strncpy(id, i, ACTION_ID_SIZE);
+
 	_boss->addAction(this);
 }
 

Modified: scummvm/branches/gsoc2008-vkeybd/backends/keymapper/action.h
===================================================================
--- scummvm/branches/gsoc2008-vkeybd/backends/keymapper/action.h	2008-08-18 07:12:05 UTC (rev 33985)
+++ scummvm/branches/gsoc2008-vkeybd/backends/keymapper/action.h	2008-08-18 10:07:11 UTC (rev 33986)
@@ -68,9 +68,11 @@
 	kActionCategoryMax
 };
 
+#define ACTION_ID_SIZE (4)
+
 struct Action {
 	/** unique id used for saving/loading to config */
-	int32 id;
+	char id[ACTION_ID_SIZE];
 	/** Human readable description */
 	String description;
 
@@ -88,7 +90,7 @@
 	Keymap *_boss;
 
 public:
-	Action(Keymap *boss, int32 id,	String des = "", 
+	Action(Keymap *boss, const char *id, String des = "", 
 		   ActionCategory cat = kGenericActionCategory,
 		   ActionType typ = kGenericActionType,
 		   int pri = 0, int grp = 0, int flg = 0 );

Modified: scummvm/branches/gsoc2008-vkeybd/backends/keymapper/hardware-key.h
===================================================================
--- scummvm/branches/gsoc2008-vkeybd/backends/keymapper/hardware-key.h	2008-08-18 07:12:05 UTC (rev 33985)
+++ scummvm/branches/gsoc2008-vkeybd/backends/keymapper/hardware-key.h	2008-08-18 10:07:11 UTC (rev 33986)
@@ -30,12 +30,14 @@
 
 namespace Common {
 
+#define HWKEY_ID_SIZE (4)
+
 /**
 * Describes an available hardware key 
 */
 struct HardwareKey {
 	/** unique id used for saving/loading to config */
-	int32 id;
+	char id[HWKEY_ID_SIZE];
 	/** Human readable description */
 	String description; 
 	/** 
@@ -48,15 +50,12 @@
 	ActionType preferredType;
 	int16 group;
 
-	HardwareKey(int32 i, KeyState ks = KeyState(), String des = "",
+	HardwareKey(const char *i, KeyState ks = KeyState(), String des = "",
 				ActionCategory cat = kGenericActionCategory,
-				ActionType ty = kGenericActionType,	int gr = 0) {
-		id = i;
-		key = ks;
-		description = des;
-		preferredCategory = cat;
-		preferredType = ty;
-		group = gr;
+				ActionType ty = kGenericActionType,	int gr = 0)
+		: key(ks), description(des), preferredCategory(cat), preferredType(ty), group(gr) {
+		assert(i);
+		strncpy(id, i, HWKEY_ID_SIZE);
 	}
 };
 
@@ -82,10 +81,10 @@
 		++_count;
 	}
 
-	const HardwareKey *findHardwareKey(int32 id) const {
+	const HardwareKey *findHardwareKey(const char *id) const {
 		List<const HardwareKey*>::iterator it;
 		for (it = _keys.begin(); it != _keys.end(); it++) {
-			if ((*it)->id == id)
+			if (strncmp((*it)->id, id, HWKEY_ID_SIZE) == 0)
 				return (*it);
 		}
 		return 0;

Modified: scummvm/branches/gsoc2008-vkeybd/backends/keymapper/keymap.cpp
===================================================================
--- scummvm/branches/gsoc2008-vkeybd/backends/keymapper/keymap.cpp	2008-08-18 07:12:05 UTC (rev 33985)
+++ scummvm/branches/gsoc2008-vkeybd/backends/keymapper/keymap.cpp	2008-08-18 10:07:11 UTC (rev 33986)
@@ -26,6 +26,8 @@
 #include "backends/keymapper/keymap.h"
 #include "backends/keymapper/hardware-key.h"
 
+#define KEYMAP_KEY_PREFIX "keymap_"
+
 namespace Common {
 
 Keymap::Keymap(const Keymap& km) : _actions(km._actions), _keymap(), _configDomain(0) {
@@ -68,23 +70,23 @@
 	}
 }
 
-Action *Keymap::getAction(int32 id) {
+Action *Keymap::getAction(const char *id) {
 	return findAction(id);
 }
 
-Action *Keymap::findAction(int32 id) {
+Action *Keymap::findAction(const char *id) {
 	List<Action*>::iterator it;
 	for (it = _actions.begin(); it != _actions.end(); it++) {
-		if ((*it)->id == id)
+		if (strncmp((*it)->id, id, ACTION_ID_SIZE) == 0)
 			return *it;
 	}
 	return 0;
 }
 
-const Action *Keymap::findAction(int32 id) const {
+const Action *Keymap::findAction(const char *id) const {
 	List<Action*>::const_iterator it;
 	for (it = _actions.begin(); it != _actions.end(); it++) {
-		if ((*it)->id == id)
+		if (strncmp((*it)->id, id, ACTION_ID_SIZE) == 0)
 			return *it;
 	}
 	return 0;
@@ -106,37 +108,25 @@
 void Keymap::loadMappings(const HardwareKeySet *hwKeys) {
 	if (!_configDomain) return;
 	ConfigManager::Domain::iterator it;	
-	String prefix = "km_" + _name + "_";
+	String prefix = KEYMAP_KEY_PREFIX + _name + "_";
 	for (it = _configDomain->begin(); it != _configDomain->end(); it++) {
 		const String& key = it->_key;
 		if (!key.hasPrefix(prefix.c_str()))
 			continue;
 
 		// parse Action ID
-		const char *actionIdStart = key.c_str() + prefix.size();
-		char *err;
-		int32 actionId = (int32) strtol(actionIdStart, &err, 0);
-		if (err == actionIdStart) {
-			warning("'%s' is not a valid Action ID", err);
-			continue;
-		}
+		const char *actionId = key.c_str() + prefix.size();
 		Action *ua = getAction(actionId);
 		if (!ua) {
-			warning("'%s' keymap does not contain Action with ID %d", 
-				_name.c_str(), (int)actionId);
+			warning("'%s' keymap does not contain Action with ID %s", 
+				_name.c_str(), actionId);
 			_configDomain->erase(key);
 			continue;
 		}
 
-		// parse HardwareKey ID
-		int32 hwKeyId = (int32) strtol(it->_value.c_str(), &err, 0);
-		if (err == it->_value.c_str()) {
-			warning("'%s' is not a valid HardwareKey ID", err);
-			continue;
-		}
-		const HardwareKey *hwKey = hwKeys->findHardwareKey(hwKeyId);
+		const HardwareKey *hwKey = hwKeys->findHardwareKey(it->_value.c_str());
 		if (!hwKey) {
-			warning("HardwareKey with ID %d not known", (int)hwKeyId);
+			warning("HardwareKey with ID %s not known", it->_value.c_str());
 			_configDomain->erase(key);
 			continue;
 		}
@@ -148,16 +138,17 @@
 void Keymap::saveMappings() {
 	if (!_configDomain) return;
 	List<Action*>::const_iterator it;
-	char buf[12];
-	String prefix = "km_" + _name + "_";
+	String prefix = KEYMAP_KEY_PREFIX + _name + "_";
 	for (it = _actions.begin(); it != _actions.end(); it++) {
-		sprintf(buf, "%d", (*it)->id);
-		String key = prefix + buf;
-		if ((*it)->getMappedKey())
-			sprintf(buf, "%d", (*it)->getMappedKey()->id);
-		else
-			strcpy(buf, "");
-		_configDomain->setVal(key, buf);
+		uint actIdLen = strnlen((*it)->id, ACTION_ID_SIZE);
+		String actId((*it)->id, (*it)->id + actIdLen);
+		if ((*it)->getMappedKey()) {
+			uint hwIdLen = strnlen((*it)->getMappedKey()->id, HWKEY_ID_SIZE);
+			String hwId((*it)->getMappedKey()->id, (*it)->getMappedKey()->id + hwIdLen);
+			_configDomain->setVal(prefix + actId, hwId);
+		} else {
+			_configDomain->setVal(prefix + actId, "");
+		}
 	}
 }
 

Modified: scummvm/branches/gsoc2008-vkeybd/backends/keymapper/keymap.h
===================================================================
--- scummvm/branches/gsoc2008-vkeybd/backends/keymapper/keymap.h	2008-08-18 07:12:05 UTC (rev 33985)
+++ scummvm/branches/gsoc2008-vkeybd/backends/keymapper/keymap.h	2008-08-18 10:07:11 UTC (rev 33986)
@@ -61,7 +61,7 @@
 	 * @param id id of Action to retrieve
 	 * @return Pointer to the Action or 0 if not found
 	 */
-	Action *getAction(int32 id);
+	Action *getAction(const char *id);
 
 	/**
 	 * Get the list of all the Actions contained in this Keymap
@@ -124,8 +124,8 @@
 	*/
 	void unregisterMapping(Action *action);
 
-	Action *findAction(int32 id);
-	const Action *findAction(int32 id) const;
+	Action *findAction(const char *id);
+	const Action *findAction(const char *id) const;
 
 	void internalMapKey(Action *action, HardwareKey *hwKey);
 

Modified: scummvm/branches/gsoc2008-vkeybd/backends/platform/sdl/events.cpp
===================================================================
--- scummvm/branches/gsoc2008-vkeybd/backends/platform/sdl/events.cpp	2008-08-18 07:12:05 UTC (rev 33985)
+++ scummvm/branches/gsoc2008-vkeybd/backends/platform/sdl/events.cpp	2008-08-18 10:07:11 UTC (rev 33986)
@@ -526,10 +526,10 @@
 	Keymapper *mapper = getEventManager()->getKeymapper();
 
 	HardwareKeySet *keySet = new HardwareKeySet();
-	keySet->addHardwareKey(new HardwareKey( 'a', KeyState(KEYCODE_a), "a" ));
-	keySet->addHardwareKey(new HardwareKey( 's', KeyState(KEYCODE_s), "s" ));
-	keySet->addHardwareKey(new HardwareKey( 'd', KeyState(KEYCODE_d), "d" ));
-	keySet->addHardwareKey(new HardwareKey( 'f', KeyState(KEYCODE_f), "f" ));
+	keySet->addHardwareKey(new HardwareKey( "a", KeyState(KEYCODE_a), "a" ));
+	keySet->addHardwareKey(new HardwareKey( "s", KeyState(KEYCODE_s), "s" ));
+	keySet->addHardwareKey(new HardwareKey( "d", KeyState(KEYCODE_d), "d" ));
+	keySet->addHardwareKey(new HardwareKey( "f", KeyState(KEYCODE_f), "f" ));
 	mapper->registerHardwareKeySet(keySet);
 
 	Keymap *global = new Keymap("global");
@@ -542,25 +542,25 @@
 		evt.kbd = KeyState(kc, asc, flags); \
 		act->events.push_back(evt);
 
-	act = new Action(global, 'MENU', "Menu", kGenericActionCategory, kMenuAction);
+	act = new Action(global, "MENU", "Menu", kGenericActionCategory, kMenuAction);
 	ADD_KEYDOWN_EVENT(KEYCODE_F5, ASCII_F5, 0)
 	
-	act = new Action(global, 'SKCT', "Skip");
+	act = new Action(global, "SKCT", "Skip");
 	ADD_KEYDOWN_EVENT(KEYCODE_ESCAPE, ASCII_ESCAPE, 0);
 
-	act = new Action(global, 'PAUS', "Pause");
+	act = new Action(global, "PAUS", "Pause");
 	ADD_KEYDOWN_EVENT(KEYCODE_SPACE, ' ', 0)
 	
-	act = new Action(global, 'SKLI', "Skip line");
+	act = new Action(global, "SKLI", "Skip line");
 	ADD_KEYDOWN_EVENT(Common::KEYCODE_PERIOD, '.', 0);
 
-	act = new Action(specific, 'JUMP', "Jump");
+	act = new Action(specific, "JUMP", "Jump");
 	ADD_KEYDOWN_EVENT(KEYCODE_j, 'j', 0);
 	
-	act = new Action(specific, 'DUCK', "Duck");
+	act = new Action(specific, "DUCK", "Duck");
 	ADD_KEYDOWN_EVENT(KEYCODE_d, 'd', 0);
 
-	act = new Action(specific, 'RUN_', "Run");
+	act = new Action(specific, "RUN_", "Run");
 	ADD_KEYDOWN_EVENT(KEYCODE_r, 'r', 0);
 
 	#undef ADD_KEYDOWN_EVENT

Modified: scummvm/branches/gsoc2008-vkeybd/backends/vkeybd/virtual-keyboard-gui.cpp
===================================================================
--- scummvm/branches/gsoc2008-vkeybd/backends/vkeybd/virtual-keyboard-gui.cpp	2008-08-18 07:12:05 UTC (rev 33985)
+++ scummvm/branches/gsoc2008-vkeybd/backends/vkeybd/virtual-keyboard-gui.cpp	2008-08-18 10:07:11 UTC (rev 33986)
@@ -39,6 +39,9 @@
 	_system = g_system;
 	
 	_lastScreenChanged = _system->getScreenChangeID();
+	_screenW = _system->getOverlayWidth();
+	_screenH = _system->getOverlayHeight();
+
 	
 	memset(_cursor, 0xFF, sizeof(_cursor));
 }
@@ -93,6 +96,11 @@
 		screenChanged(); 
 }
 
+void VirtualKeyboardGUI::initSize(int16 w, int16 h) {
+	_screenW = w;
+	_screenH = h;
+}
+
 void VirtualKeyboardGUI::run() {
 	if (_firstRun) {
 		_firstRun = false;
@@ -103,7 +111,7 @@
 		_system->showOverlay();
 		_system->clearOverlay();
 	}
-	_overlayBackup.create(_system->getOverlayWidth(), _system->getOverlayHeight(), sizeof(OverlayColor));
+	_overlayBackup.create(_screenW, _screenH, sizeof(OverlayColor));
 	_system->grabOverlay((OverlayColor*)_overlayBackup.pixels, _overlayBackup.w);
 
 	setupCursor();
@@ -136,32 +144,31 @@
 
 void VirtualKeyboardGUI::moveToDefaultPosition()
 {
-	int16 scrW = _system->getOverlayWidth(), scrH = _system->getOverlayHeight(); 
 	int16 kbdW = _kbdBound.width(), kbdH = _kbdBound.height();
 	int16 x = 0, y = 0;
-	if (scrW != kbdW) {
+	if (_screenW != kbdW) {
 		switch (_kbd->_hAlignment) {
 		case VirtualKeyboard::kAlignLeft:
 			x = 0;
 			break;
 		case VirtualKeyboard::kAlignCentre:
-			x = (scrW - kbdW) / 2;
+			x = (_screenW - kbdW) / 2;
 			break;
 		case VirtualKeyboard::kAlignRight:
-			x = scrW - kbdW;
+			x = _screenW - kbdW;
 			break;
 		}
 	}
-	if (scrH != kbdH) {
+	if (_screenH != kbdH) {
 		switch (_kbd->_vAlignment) {
 		case VirtualKeyboard::kAlignTop:
 			y = 0;
 			break;
 		case VirtualKeyboard::kAlignMiddle:
-			y = (scrH - kbdH) / 2;
+			y = (_screenH - kbdH) / 2;
 			break;
 		case VirtualKeyboard::kAlignBottom:
-			y = scrH - kbdH;
+			y = _screenH - kbdH;
 			break;
 		}
 	}
@@ -170,17 +177,17 @@
 
 void VirtualKeyboardGUI::move(int16 x, int16 y) {
 	// add old position to dirty area
-	extendDirtyRect(_kbdBound);
+	if (_displaying) extendDirtyRect(_kbdBound);
 
 	// snap to edge of screen
 	if (ABS(x) < SNAP_WIDTH)
 		x = 0;
-	int16 x2 = _system->getOverlayWidth() - _kbdBound.width();
+	int16 x2 = _screenW - _kbdBound.width();
 	if (ABS(x - x2) < SNAP_WIDTH)
 		x = x2;
 	if (ABS(y) < SNAP_WIDTH)
 		y = 0;
-	int16 y2 = _system->getOverlayHeight() - _kbdBound.height();
+	int16 y2 = _screenH - _kbdBound.height();
 	if (ABS(y - y2) < SNAP_WIDTH)
 		y = y2;
 
@@ -188,19 +195,26 @@
 	_dispY += y - _kbdBound.top;
 	_kbdBound.moveTo(x, y);
 
-	// add new position to dirty area
-	extendDirtyRect(_kbdBound);
-
-	redraw();
+	if (_displaying) {
+		// add new position to dirty area
+		extendDirtyRect(_kbdBound);
+		redraw();
+	}
 }
 
 void VirtualKeyboardGUI::screenChanged() {
 	_lastScreenChanged = _system->getScreenChangeID();
-	if (!_kbd->checkModeResolutions()) {
-		_displaying = false;
-		return;
+	int16 newScreenW = _system->getOverlayWidth();
+	int16 newScreenH = _system->getOverlayHeight();
+	if (_screenW != newScreenW || _screenH != newScreenH) {
+		_screenW = newScreenW;
+		_screenH = newScreenH;
+		if (!_kbd->checkModeResolutions()) {
+			_displaying = false;
+			return;
+		}
+		moveToDefaultPosition();
 	}
-	moveToDefaultPosition();
 }
 
 

Modified: scummvm/branches/gsoc2008-vkeybd/backends/vkeybd/virtual-keyboard-gui.h
===================================================================
--- scummvm/branches/gsoc2008-vkeybd/backends/vkeybd/virtual-keyboard-gui.h	2008-08-18 07:12:05 UTC (rev 33985)
+++ scummvm/branches/gsoc2008-vkeybd/backends/vkeybd/virtual-keyboard-gui.h	2008-08-18 10:07:11 UTC (rev 33986)
@@ -49,10 +49,12 @@
 	void reset();
 	void startDrag(int16 x, int16 y);
 	void endDrag();
+	void initSize(int16 w, int16 h);
 
 private:
 
 	OSystem *_system;
+
 	VirtualKeyboard *_kbd;
 	Rect _kbdBound;
 	Graphics::Surface *_kbdSurface;
@@ -72,9 +74,11 @@
 	uint _dispI;
 	OverlayColor _dispForeColor, _dispBackColor;
 
+	int _lastScreenChanged;
+	int16 _screenW, _screenH;
+
 	bool _displaying;
 	bool _firstRun;
-	int _lastScreenChanged;
 
 	void setupDisplayArea(Rect& r, OverlayColor forecolor);
 	void move(int16 x, int16 y);

Modified: scummvm/branches/gsoc2008-vkeybd/backends/vkeybd/virtual-keyboard.cpp
===================================================================
--- scummvm/branches/gsoc2008-vkeybd/backends/vkeybd/virtual-keyboard.cpp	2008-08-18 07:12:05 UTC (rev 33985)
+++ scummvm/branches/gsoc2008-vkeybd/backends/vkeybd/virtual-keyboard.cpp	2008-08-18 10:07:11 UTC (rev 33986)
@@ -44,7 +44,6 @@
 	_kbdGUI = new VirtualKeyboardGUI(this);
 	_submitKeys = _loaded = false;
 
-		printf("\t\"%c\",\n",255);
 }
 
 VirtualKeyboard::~VirtualKeyboard() {
@@ -75,6 +74,9 @@
 }
 
 bool VirtualKeyboard::loadKeyboardPack(Common::String packName) {
+
+	_kbdGUI->initSize(_system->getOverlayWidth(), _system->getOverlayHeight());
+
 	FilesystemNode *vkDir = 0;
 	if (ConfMan.hasKey("vkeybdpath")) {
 		vkDir = new FilesystemNode(ConfMan.get("vkeybdpath"));
@@ -138,7 +140,7 @@
 {
 	_parser->setParseMode(kParseCheckResolutions);
 	_loaded = _parser->parse();
-	_kbdGUI->initMode(_currentMode);
+	if (_currentMode) _kbdGUI->initMode(_currentMode);
 	return _loaded;
 }
 
@@ -215,7 +217,7 @@
 void VirtualKeyboard::show() {
 	if (_loaded) _kbdGUI->checkScreenChanged();
 	if (!_loaded) {
-		warning("Virtual keyboard not loaded!");
+		warning("Virtual keyboard not loaded");
 		return;
 	}
 

Modified: scummvm/branches/gsoc2008-vkeybd/base/main.cpp
===================================================================
--- scummvm/branches/gsoc2008-vkeybd/base/main.cpp	2008-08-18 07:12:05 UTC (rev 33985)
+++ scummvm/branches/gsoc2008-vkeybd/base/main.cpp	2008-08-18 10:07:11 UTC (rev 33986)
@@ -38,6 +38,7 @@
 #include "base/version.h"
 
 #include "common/config-manager.h"
+#include "common/events.h"
 #include "common/file.h"
 #include "common/fs.h"
 #include "common/system.h"
@@ -54,20 +55,6 @@
 
 
 static bool launcherDialog(OSystem &system) {
-
-	system.beginGFXTransaction();
-		// Set the user specified graphics mode (if any).
-		system.setGraphicsMode(ConfMan.get("gfx_mode").c_str());
-
-		system.initSize(320, 200);
-	system.endGFXTransaction();
-
-	// Set initial window caption
-	system.setWindowCaption(gScummVMFullVersion);
-
-	// Clear the main screen
-	system.clearScreen();
-
 #if defined(_WIN32_WCE)
 	CELauncherDialog dlg;
 #elif defined(__DC__)
@@ -203,7 +190,22 @@
 	return 0;
 }
 
+static void setupGraphics(OSystem &system) {
+	system.beginGFXTransaction();
+		// Set the user specified graphics mode (if any).
+		system.setGraphicsMode(ConfMan.get("gfx_mode").c_str());
 
+		system.initSize(320, 200);
+	system.endGFXTransaction();
+
+	// Set initial window caption
+	system.setWindowCaption(gScummVMFullVersion);
+
+	// Clear the main screen
+	system.clearScreen();
+}
+
+
 extern "C" int scummvm_main(int argc, char *argv[]) {
 	Common::String specialDebug;
 	Common::String command;
@@ -259,6 +261,12 @@
 	// the command line params) was read.
 	system.initBackend();
 
+	setupGraphics(system);
+
+	// Init the event manager. As the virtual keyboard is loaded here, it must 
+	// take place after the backend is initiated and the screen has been setup
+	system.getEventManager()->init();
+
 	// Unless a game was specified, show the launcher dialog
 	if (0 == ConfMan.getActiveDomain()) {
 		launcherDialog(system);
@@ -303,7 +311,9 @@
 			// screen to draw on yet.
 			warning("Could not find any engine capable of running the selected game");
 		}
-
+		
+		// reset the graphics to default
+		setupGraphics(system);
 		launcherDialog(system);
 	}
 	PluginManager::instance().unloadPlugins();

Modified: scummvm/branches/gsoc2008-vkeybd/common/events.h
===================================================================
--- scummvm/branches/gsoc2008-vkeybd/common/events.h	2008-08-18 07:12:05 UTC (rev 33985)
+++ scummvm/branches/gsoc2008-vkeybd/common/events.h	2008-08-18 10:07:11 UTC (rev 33986)
@@ -136,7 +136,13 @@
 		RBUTTON = 1 << 1
 	};
 
+
 	/**
+	 * Initialise the event manager.
+	 * @note	called after graphics system has been set up
+	 */
+	virtual void init() {}
+	/**
 	 * Get the next event in the event queue.
 	 * @param event	point to an Event struct, which will be filled with the event data.
 	 * @return true if an event was retrieved.


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list