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

kenny-d at users.sourceforge.net kenny-d at users.sourceforge.net
Thu Jul 31 12:54:14 CEST 2008


Revision: 33465
          http://scummvm.svn.sourceforge.net/scummvm/?rev=33465&view=rev
Author:   kenny-d
Date:     2008-07-31 10:54:13 +0000 (Thu, 31 Jul 2008)

Log Message:
-----------
Bug fixes to get new keyboard pack working

Modified Paths:
--------------
    scummvm/branches/gsoc2008-vkeybd/backends/common/virtual-keyboard-parser.cpp
    scummvm/branches/gsoc2008-vkeybd/backends/common/virtual-keyboard.cpp
    scummvm/branches/gsoc2008-vkeybd/backends/common/virtual-keyboard.h

Modified: scummvm/branches/gsoc2008-vkeybd/backends/common/virtual-keyboard-parser.cpp
===================================================================
--- scummvm/branches/gsoc2008-vkeybd/backends/common/virtual-keyboard-parser.cpp	2008-07-31 10:52:29 UTC (rev 33464)
+++ scummvm/branches/gsoc2008-vkeybd/backends/common/virtual-keyboard-parser.cpp	2008-07-31 10:54:13 UTC (rev 33465)
@@ -300,13 +300,15 @@
 	}
 
 	_mode->bitmapName = layoutNode->values["bitmap"];
+	_mode->image = ImageMan.getSurface(_mode->bitmapName);
+	if (!_mode->image) {
+		if (!ImageMan.registerSurface(_mode->bitmapName, 0))
+			return parserError("Error loading bitmap '%s'", _mode->bitmapName.c_str());
 
-	if (!ImageMan.registerSurface(_mode->bitmapName, 0))
-		return parserError("Error loading bitmap '%s'", _mode->bitmapName.c_str());
-
-	_mode->image = ImageMan.getSurface(_mode->bitmapName);
-	if (!_mode->image)
-		return parserError("Error loading bitmap '%s'", _mode->bitmapName.c_str());
+		_mode->image = ImageMan.getSurface(_mode->bitmapName);
+		if (!_mode->image)
+			return parserError("Error loading bitmap '%s'", _mode->bitmapName.c_str());
+	}
 	
 	if (layoutNode->values.contains("transparent_color")) {
 		int r, g, b;
@@ -347,9 +349,9 @@
 	Common::String& target = areaNode->values["target"];
 	Common::String& coords = areaNode->values["coords"];
 
-	if (target == "preview_area") {
+	if (target == "display_area") {
 		if (shape != "rect")
-			return parserError("preview_area must be a rect area");
+			return parserError("display_area must be a rect area");
 		_mode->previewArea = new Common::Rect();
 		return parseRect(_mode->previewArea, coords);
 	} else if (shape == "rect") {

Modified: scummvm/branches/gsoc2008-vkeybd/backends/common/virtual-keyboard.cpp
===================================================================
--- scummvm/branches/gsoc2008-vkeybd/backends/common/virtual-keyboard.cpp	2008-07-31 10:52:29 UTC (rev 33464)
+++ scummvm/branches/gsoc2008-vkeybd/backends/common/virtual-keyboard.cpp	2008-07-31 10:54:13 UTC (rev 33465)
@@ -30,7 +30,7 @@
 
 namespace Common {
 
-VirtualKeyboard::VirtualKeyboard() : _currentMode(0), _keyDown(0) {
+VirtualKeyboard::VirtualKeyboard() : _currentMode(0) {
 	assert(g_system);
 	_system = g_system;
 
@@ -62,8 +62,6 @@
 	_hAlignment = kAlignCentre;
 	_vAlignment = kAlignBottom;
 	_keyQueue.clear();
-	_keyDown = 0;
-	_keyFlags = 0;
 	_loaded = false;
 	_kbdGUI->reset();
 }
@@ -134,21 +132,16 @@
 	switch (evt->type) {
 	case kEventKey: {
 		// add virtual keypress to queue
-		Common::KeyState key = *(Common::KeyState*)evt->data;
-		key.flags ^= _keyFlags;
-		if ((key.keycode >= Common::KEYCODE_a) && (key.keycode <= Common::KEYCODE_z))
-			key.ascii = (key.flags & Common::KBD_SHIFT) ? key.keycode - 32 : key.keycode;
-		_keyQueue.insertKey(key);
-		_keyFlags = 0;
+		_keyQueue.insertKey(*(Common::KeyState*)evt->data);
 		break;
 	}
 	case kEventModifier:
-		_keyFlags ^= *(byte*)(evt->data);
+		_keyQueue.toggleFlags(*(byte*)(evt->data));
 		break;
 	case kEventSwitchMode:
 		// switch to new mode
 		switchMode(*(Common::String *)evt->data);
-		_keyFlags = 0;
+		_keyQueue.clearFlags();
 		break;
 	case kEventClose:
 		// close virtual keyboard
@@ -224,7 +217,18 @@
 	_strPos = 0;
 }
 
+void VirtualKeyboard::KeyPressQueue::toggleFlags(byte fl) {
+	_keyFlags ^= fl;
+	_strChanged = true;
+}
+
+void VirtualKeyboard::KeyPressQueue::clearFlags() {
+	_keyFlags = 0;
+	_strChanged = true;
+}
+
 void VirtualKeyboard::KeyPressQueue::insertKey(KeyState key) {
+	_strChanged = true;
 	switch (key.keycode) {
 	case KEYCODE_LEFT:
 		moveLeft();
@@ -239,6 +243,11 @@
 		;
 	}
 
+	key.flags ^= _keyFlags;
+	if ((key.keycode >= Common::KEYCODE_a) && (key.keycode <= Common::KEYCODE_z))
+		key.ascii = (key.flags & Common::KBD_SHIFT) ? key.keycode - 32 : key.keycode;
+	clearFlags();
+
 	String keyStr;
 	if (key.keycode >= 32 && key.keycode <= 126) {
 		if (key.flags & KBD_CTRL)
@@ -259,7 +268,7 @@
 	kp.strLen = keyStr.size();
 	_keys.insert(_keyPos, kp);
 
-	printf("%s %d\n", _str.c_str(), kp.strLen);
+	
 }
 
 void VirtualKeyboard::KeyPressQueue::deleteKey() {
@@ -308,6 +317,7 @@
 	_keyPos = _keys.end();
 	_str.clear();
 	_strPos = 0;
+	_keyFlags = 0;
 }
 
 bool VirtualKeyboard::KeyPressQueue::empty()
@@ -315,9 +325,22 @@
 	return _keys.empty();
 }
 
-const String& VirtualKeyboard::KeyPressQueue::getString()
+String VirtualKeyboard::KeyPressQueue::getString()
 {
-	return _str;
+	String flags;
+	if (_keyFlags & KBD_CTRL)
+		flags += "Ctrl+";
+	if (_keyFlags & KBD_ALT)
+		flags += "Alt+";
+	if (_keyFlags & KBD_SHIFT)
+		flags += "Shift+";
+	return _str + flags;
 }
 
+bool VirtualKeyboard::KeyPressQueue::hasStringChanged() {
+	bool ret = _strChanged;
+	_strChanged = false;
+	return ret;
+}
+
 } // end of namespace Common

Modified: scummvm/branches/gsoc2008-vkeybd/backends/common/virtual-keyboard.h
===================================================================
--- scummvm/branches/gsoc2008-vkeybd/backends/common/virtual-keyboard.h	2008-07-31 10:52:29 UTC (rev 33464)
+++ scummvm/branches/gsoc2008-vkeybd/backends/common/virtual-keyboard.h	2008-07-31 10:54:13 UTC (rev 33465)
@@ -112,6 +112,8 @@
 	class KeyPressQueue {
 	public:
 		KeyPressQueue();
+		void toggleFlags(byte fl);
+		void clearFlags();
 		void insertKey(KeyState key);
 		void deleteKey();
 		void moveLeft();
@@ -119,12 +121,17 @@
 		KeyState pop();
 		void clear();
 		bool empty();
-		const String& getString();
+		String getString();
+		bool hasStringChanged();
 
 	private:
+		byte _keyFlags;
+
 		List<VirtualKeyPress> _keys;
 		String _str;
 
+		bool _strChanged;
+
 		List<VirtualKeyPress>::iterator _keyPos;
 		uint _strPos;
 	};
@@ -173,9 +180,7 @@
 	friend class VirtualKeyboardGUI;
 	VirtualKeyboardGUI	*_kbdGUI;
 
-	byte _keyFlags;
 	KeyPressQueue _keyQueue;
-	KeyState *_keyDown;
 	
 	friend class VirtualKeyboardParser;
 	VirtualKeyboardParser *_parser;


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