diff options
author | Stephen Kennedy | 2008-08-15 17:53:18 +0000 |
---|---|---|
committer | Stephen Kennedy | 2008-08-15 17:53:18 +0000 |
commit | 6ef83243029b1dc61746f736f9af24f3ea8c90f1 (patch) | |
tree | f353c8768d8b7dfcd993983b81e7dd23e655f22c | |
parent | 6f09c4f10ebe16200f3bd40e21defaa733cf712e (diff) | |
download | scummvm-rg350-6ef83243029b1dc61746f736f9af24f3ea8c90f1.tar.gz scummvm-rg350-6ef83243029b1dc61746f736f9af24f3ea8c90f1.tar.bz2 scummvm-rg350-6ef83243029b1dc61746f736f9af24f3ea8c90f1.zip |
* Added Virtual Keyboard descriptions for all keycodes
* Tweaking of key delivery queue
svn-id: r33907
-rw-r--r-- | backends/vkeybd/keycode-descriptions.h | 331 | ||||
-rw-r--r-- | backends/vkeybd/virtual-keyboard-gui.cpp | 2 | ||||
-rw-r--r-- | backends/vkeybd/virtual-keyboard.cpp | 79 | ||||
-rw-r--r-- | backends/vkeybd/virtual-keyboard.h | 8 | ||||
-rw-r--r-- | dists/msvc8/scummvm.vcproj | 4 |
5 files changed, 398 insertions, 26 deletions
diff --git a/backends/vkeybd/keycode-descriptions.h b/backends/vkeybd/keycode-descriptions.h new file mode 100644 index 0000000000..e31cc562be --- /dev/null +++ b/backends/vkeybd/keycode-descriptions.h @@ -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", + "€", + "Undo" +}; +static const int keycodeDescTableSize = 322; + +#endif diff --git a/backends/vkeybd/virtual-keyboard-gui.cpp b/backends/vkeybd/virtual-keyboard-gui.cpp index 87db58d06d..5ffcee9a20 100644 --- a/backends/vkeybd/virtual-keyboard-gui.cpp +++ b/backends/vkeybd/virtual-keyboard-gui.cpp @@ -317,6 +317,8 @@ void VirtualKeyboardGUI::animateCaret() { void VirtualKeyboardGUI::updateDisplay() { if (!_displayEnabled) return; + _refreshDisplay = false; + // calculate the text to display uint cursorPos = _kbd->_keyQueue.getInsertIndex(); String wholeText = _kbd->_keyQueue.getString(); diff --git a/backends/vkeybd/virtual-keyboard.cpp b/backends/vkeybd/virtual-keyboard.cpp index ba41cc4686..f0c565acc3 100644 --- a/backends/vkeybd/virtual-keyboard.cpp +++ b/backends/vkeybd/virtual-keyboard.cpp @@ -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 @@ VirtualKeyboard::VirtualKeyboard() : _currentMode(0) { _parser = new VirtualKeyboardParser(this); _kbdGUI = new VirtualKeyboardGUI(this); _submitKeys = _loaded = false; + + printf("\t\"%c\",\n",255); } VirtualKeyboard::~VirtualKeyboard() { @@ -231,44 +237,62 @@ VirtualKeyboard::KeyPressQueue::KeyPressQueue() { _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 @@ void VirtualKeyboard::KeyPressQueue::deleteKey() { it--; _strPos -= it->strLen; while((it->strLen)-- > 0) - _str.deleteChar(_strPos); + _keysStr.deleteChar(_strPos); _keys.erase(it); } @@ -308,7 +332,7 @@ KeyState VirtualKeyboard::KeyPressQueue::pop() { _strPos -= kp.strLen; while (kp.strLen-- > 0) - _str.deleteChar(0); + _keysStr.deleteChar(0); return kp.key; } @@ -316,9 +340,9 @@ KeyState VirtualKeyboard::KeyPressQueue::pop() { 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 @@ bool VirtualKeyboard::KeyPressQueue::empty() 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() { diff --git a/backends/vkeybd/virtual-keyboard.h b/backends/vkeybd/virtual-keyboard.h index 71f718a9b2..b7034270e8 100644 --- a/backends/vkeybd/virtual-keyboard.h +++ b/backends/vkeybd/virtual-keyboard.h @@ -118,10 +118,12 @@ protected: bool hasStringChanged(); private: - byte _keyFlags; + byte _flags; + String _flagsStr; + List<VirtualKeyPress> _keys; - String _str; + String _keysStr; bool _strChanged; @@ -129,6 +131,8 @@ protected: uint _strPos; }; + + public: VirtualKeyboard(); virtual ~VirtualKeyboard(); diff --git a/dists/msvc8/scummvm.vcproj b/dists/msvc8/scummvm.vcproj index e9395c9039..fb25400d79 100644 --- a/dists/msvc8/scummvm.vcproj +++ b/dists/msvc8/scummvm.vcproj @@ -1045,6 +1045,10 @@ > </File> <File + RelativePath="..\..\backends\vkeybd\keycode-descriptions.h" + > + </File> + <File RelativePath="..\..\backends\vkeybd\polygon.cpp" > </File> |