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

kenny-d at users.sourceforge.net kenny-d at users.sourceforge.net
Fri Aug 15 19:53:19 CEST 2008


Revision: 33907
          http://scummvm.svn.sourceforge.net/scummvm/?rev=33907&view=rev
Author:   kenny-d
Date:     2008-08-15 17:53:18 +0000 (Fri, 15 Aug 2008)

Log Message:
-----------
* Added Virtual Keyboard descriptions for all keycodes
* Tweaking of key delivery queue

Modified Paths:
--------------
    scummvm/branches/gsoc2008-vkeybd/backends/vkeybd/virtual-keyboard-gui.cpp
    scummvm/branches/gsoc2008-vkeybd/backends/vkeybd/virtual-keyboard.cpp
    scummvm/branches/gsoc2008-vkeybd/backends/vkeybd/virtual-keyboard.h
    scummvm/branches/gsoc2008-vkeybd/dists/msvc8/scummvm.vcproj

Added Paths:
-----------
    scummvm/branches/gsoc2008-vkeybd/backends/vkeybd/keycode-descriptions.h

Added: scummvm/branches/gsoc2008-vkeybd/backends/vkeybd/keycode-descriptions.h
===================================================================
--- scummvm/branches/gsoc2008-vkeybd/backends/vkeybd/keycode-descriptions.h	                        (rev 0)
+++ scummvm/branches/gsoc2008-vkeybd/backends/vkeybd/keycode-descriptions.h	2008-08-15 17:53:18 UTC (rev 33907)
@@ -0,0 +1,331 @@
+#ifndef KEYCODE_DESCRIPTIONS
+#define KEYCODE_DESCRIPTIONS
+
+static const char *keycodeDescTable[] = {
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"Backspace",
+	"Tab",
+	"",
+	"",
+	"Clear",
+	"Return",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"Pause",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"Escape",
+	"",
+	"",
+	"",
+	"",
+	" ",
+	"!",
+	"\"",
+	"#",
+	"$",
+	"%",
+	"&",
+	"'",
+	"(",
+	")",
+	"*",
+	"+",
+	",",
+	"-",
+	".",
+	"/",
+	"0",
+	"1",
+	"2",
+	"3",
+	"4",
+	"5",
+	"6",
+	"7",
+	"8",
+	"9",
+	":",
+	";",
+	"<",
+	"=",
+	">",
+	"?",
+	"@",
+	"A",
+	"B",
+	"C",
+	"D",
+	"E",
+	"F",
+	"G",
+	"H",
+	"I",
+	"J",
+	"K",
+	"L",
+	"M",
+	"N",
+	"O",
+	"P",
+	"Q",
+	"R",
+	"S",
+	"T",
+	"U",
+	"V",
+	"W",
+	"X",
+	"Y",
+	"Z",
+	"[",
+	"\\",
+	"]",
+	"^",
+	"_",
+	"`",
+	"a",
+	"b",
+	"c",
+	"d",
+	"e",
+	"f",
+	"g",
+	"h",
+	"i",
+	"j",
+	"k",
+	"l",
+	"m",
+	"n",
+	"o",
+	"p",
+	"q",
+	"r",
+	"s",
+	"t",
+	"u",
+	"v",
+	"w",
+	"x",
+	"y",
+	"z",
+	"{",
+	"|",
+	"}",
+	"~",
+	"Delete",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"",
+	"0",
+	"1",
+	"2",
+	"3",
+	"4",
+	"5",
+	"6",
+	"7",
+	"8",
+	"9",
+	".",
+	"/",
+	"*",
+	"-",
+	"+",
+	"Enter",
+	"=",
+	"Up",
+	"Down",
+	"Right",
+	"Left",
+	"Ins",
+	"Home",
+	"End",
+	"Page Up",
+	"Page Down",
+	"F1",
+	"F2",
+	"F3",
+	"F4",
+	"F5",
+	"F6",
+	"F7",
+	"F8",
+	"F9",
+	"F10",
+	"F11",
+	"F12",
+	"F13",
+	"F14",
+	"F15",
+	"",
+	"",
+	"",
+	"Num Lock",
+	"Caps Lock",
+	"Scroll Lock",
+	"Shift",
+	"Shift",
+	"Ctrl",
+	"Ctrl",
+	"Alt",
+	"Alt",
+	"Meta",
+	"Meta",
+	"Super",
+	"Super",
+	"Mode",
+	"Compose",
+	"Help",
+	"Print",
+	"SysReq",
+	"Break",
+	"Menu",
+	"Power",
+	"\x80",
+	"Undo"
+};
+static const int keycodeDescTableSize = 322;
+
+#endif


Property changes on: scummvm/branches/gsoc2008-vkeybd/backends/vkeybd/keycode-descriptions.h
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:keywords
   + Date Rev Author URL Id
Added: svn:eol-style
   + native

Modified: scummvm/branches/gsoc2008-vkeybd/backends/vkeybd/virtual-keyboard-gui.cpp
===================================================================
--- scummvm/branches/gsoc2008-vkeybd/backends/vkeybd/virtual-keyboard-gui.cpp	2008-08-15 17:40:58 UTC (rev 33906)
+++ scummvm/branches/gsoc2008-vkeybd/backends/vkeybd/virtual-keyboard-gui.cpp	2008-08-15 17:53:18 UTC (rev 33907)
@@ -317,6 +317,8 @@
 void VirtualKeyboardGUI::updateDisplay() {
 	if (!_displayEnabled) return;
 
+	_refreshDisplay = false;
+
 	// calculate the text to display
 	uint cursorPos = _kbd->_keyQueue.getInsertIndex();
 	String wholeText = _kbd->_keyQueue.getString();

Modified: scummvm/branches/gsoc2008-vkeybd/backends/vkeybd/virtual-keyboard.cpp
===================================================================
--- scummvm/branches/gsoc2008-vkeybd/backends/vkeybd/virtual-keyboard.cpp	2008-08-15 17:40:58 UTC (rev 33906)
+++ scummvm/branches/gsoc2008-vkeybd/backends/vkeybd/virtual-keyboard.cpp	2008-08-15 17:53:18 UTC (rev 33907)
@@ -26,8 +26,12 @@
 #include "backends/vkeybd/virtual-keyboard.h"
 #include "backends/vkeybd/virtual-keyboard-gui.h"
 #include "backends/vkeybd/virtual-keyboard-parser.h"
+#include "backends/vkeybd/keycode-descriptions.h"
 #include "graphics/imageman.h"
 
+#define KEY_START_CHAR ('[')
+#define KEY_END_CHAR (']')
+
 namespace Common {
 
 VirtualKeyboard::VirtualKeyboard() : _currentMode(0) {
@@ -37,6 +41,8 @@
 	_parser = new VirtualKeyboardParser(this);
 	_kbdGUI = new VirtualKeyboardGUI(this);
 	_submitKeys = _loaded = false;
+
+		printf("\t\"%c\",\n",255);
 }
 
 VirtualKeyboard::~VirtualKeyboard() {
@@ -231,44 +237,62 @@
 	_keyPos = _keys.end();
 	_strPos = 0;
 	_strChanged = false;
-	_keyFlags = 0;
+	_flags = 0;
 }
 
 void VirtualKeyboard::KeyPressQueue::toggleFlags(byte fl) {
-	_keyFlags ^= fl;
+	_flags ^= fl;
+	_flagsStr.clear();
+	if (_flags) {
+		_flagsStr = KEY_START_CHAR;
+		if (_flags & KBD_CTRL)
+			_flagsStr += "Ctrl+";
+		if (_flags & KBD_ALT)
+			_flagsStr += "Alt+";
+		if (_flags & KBD_SHIFT)
+			_flagsStr += "Shift+";
+	}
 	_strChanged = true;
 }
 
 void VirtualKeyboard::KeyPressQueue::clearFlags() {
-	_keyFlags = 0;
+	_flags = 0;
+	_flagsStr.clear();
 	_strChanged = true;
 }
 
 void VirtualKeyboard::KeyPressQueue::insertKey(KeyState key) {
 	_strChanged = true;
-	key.flags ^= _keyFlags;
+	key.flags ^= _flags;
 	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)
-			keyStr += "Ctrl+";
-		if (key.flags & KBD_ALT)
-			keyStr += "Alt+";
+	if (key.flags & KBD_CTRL) keyStr += "Ctrl+";
+	if (key.flags & KBD_ALT) keyStr += "Alt+";
+
+	if (key.ascii >= 32 && key.ascii <= 255) {
 		if (key.flags & KBD_SHIFT && (key.ascii < 65 || key.ascii > 90))
 			keyStr += "Shift+";
 		keyStr += (char)key.ascii;
+	} else {
+		if (key.flags & KBD_SHIFT) keyStr += "Shift+";
+		if (key.keycode >= 0 && key.keycode < keycodeDescTableSize)
+			keyStr += keycodeDescTable[key.keycode];
 	}
 
+	if (keyStr.empty()) keyStr += "???";
+
+	_keysStr.insertChar(KEY_START_CHAR, _strPos++);
 	const char *k = keyStr.c_str();
 	while (char ch = *k++)
-		_str.insertChar(ch, _strPos++);
+		_keysStr.insertChar(ch, _strPos++);
+	_keysStr.insertChar(KEY_END_CHAR, _strPos++);
 
 	VirtualKeyPress kp;
 	kp.key = key;
-	kp.strLen = keyStr.size();
+	kp.strLen = keyStr.size() + 2;
 	_keys.insert(_keyPos, kp);
 }
 
@@ -279,7 +303,7 @@
 	it--;
 	_strPos -= it->strLen;
 	while((it->strLen)-- > 0)
-		_str.deleteChar(_strPos);
+		_keysStr.deleteChar(_strPos);
 	_keys.erase(it);
 }
 
@@ -308,7 +332,7 @@
 		_strPos -= kp.strLen;
 
 	while (kp.strLen-- > 0)
-		_str.deleteChar(0);
+		_keysStr.deleteChar(0);
 
 	return kp.key;
 }
@@ -316,9 +340,9 @@
 void VirtualKeyboard::KeyPressQueue::clear() {
 	_keys.clear();
 	_keyPos = _keys.end();
-	_str.clear();
+	_keysStr.clear();
 	_strPos = 0;
-	_keyFlags = 0;
+	_flags = 0;
 }
 
 bool VirtualKeyboard::KeyPressQueue::empty()
@@ -328,18 +352,25 @@
 
 String VirtualKeyboard::KeyPressQueue::getString()
 {
-	String flags;
-	if (_keyFlags & KBD_CTRL)
-		flags += "Ctrl+";
-	if (_keyFlags & KBD_ALT)
-		flags += "Alt+";
-	if (_keyFlags & KBD_SHIFT)
-		flags += "Shift+";
-	return _str + flags;
+	if (_keysStr.empty())
+		return _flagsStr;
+	if (_flagsStr.empty())
+		return _keysStr;
+	if (_strPos == _keysStr.size())
+		return _keysStr + _flagsStr;
+
+	uint len = _keysStr.size() + _flagsStr.size();
+	char *str = new char[len];
+	memcpy(str, _keysStr.c_str(), _strPos);
+	memcpy(str + _strPos, _flagsStr.c_str(), _flagsStr.size());
+	memcpy(str + _strPos + _flagsStr.size(), _keysStr.c_str() + _strPos, _keysStr.size() - _strPos);
+	String ret(str, len);
+	delete[] str;
+	return ret;
 }
 
 uint VirtualKeyboard::KeyPressQueue::getInsertIndex() {
-	return _strPos;
+	return _strPos + _flagsStr.size();
 }
 
 bool VirtualKeyboard::KeyPressQueue::hasStringChanged() {

Modified: scummvm/branches/gsoc2008-vkeybd/backends/vkeybd/virtual-keyboard.h
===================================================================
--- scummvm/branches/gsoc2008-vkeybd/backends/vkeybd/virtual-keyboard.h	2008-08-15 17:40:58 UTC (rev 33906)
+++ scummvm/branches/gsoc2008-vkeybd/backends/vkeybd/virtual-keyboard.h	2008-08-15 17:53:18 UTC (rev 33907)
@@ -118,10 +118,12 @@
 		bool hasStringChanged();
 
 	private:
-		byte _keyFlags;
+		byte _flags;
+		String _flagsStr;
 
+
 		List<VirtualKeyPress> _keys;
-		String _str;
+		String _keysStr;
 
 		bool _strChanged;
 
@@ -129,6 +131,8 @@
 		uint _strPos;
 	};
 
+
+
 public:
 	VirtualKeyboard();
 	virtual ~VirtualKeyboard();

Modified: scummvm/branches/gsoc2008-vkeybd/dists/msvc8/scummvm.vcproj
===================================================================
--- scummvm/branches/gsoc2008-vkeybd/dists/msvc8/scummvm.vcproj	2008-08-15 17:40:58 UTC (rev 33906)
+++ scummvm/branches/gsoc2008-vkeybd/dists/msvc8/scummvm.vcproj	2008-08-15 17:53:18 UTC (rev 33907)
@@ -1045,6 +1045,10 @@
 					>
 				</File>
 				<File
+					RelativePath="..\..\backends\vkeybd\keycode-descriptions.h"
+					>
+				</File>
+				<File
 					RelativePath="..\..\backends\vkeybd\polygon.cpp"
 					>
 				</File>


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