diff options
author | Stephen Kennedy | 2008-07-31 10:54:13 +0000 |
---|---|---|
committer | Stephen Kennedy | 2008-07-31 10:54:13 +0000 |
commit | ad6563a57a17db297394503aa608106ac87f1a35 (patch) | |
tree | 21b24aef3601a2661f8c1c58d5bb712179a12b49 /backends | |
parent | 8345c1b687c1c5ee7a4d3f57dda53bf888d25576 (diff) | |
download | scummvm-rg350-ad6563a57a17db297394503aa608106ac87f1a35.tar.gz scummvm-rg350-ad6563a57a17db297394503aa608106ac87f1a35.tar.bz2 scummvm-rg350-ad6563a57a17db297394503aa608106ac87f1a35.zip |
Bug fixes to get new keyboard pack working
svn-id: r33465
Diffstat (limited to 'backends')
-rw-r--r-- | backends/common/virtual-keyboard-parser.cpp | 18 | ||||
-rw-r--r-- | backends/common/virtual-keyboard.cpp | 51 | ||||
-rw-r--r-- | backends/common/virtual-keyboard.h | 11 |
3 files changed, 55 insertions, 25 deletions
diff --git a/backends/common/virtual-keyboard-parser.cpp b/backends/common/virtual-keyboard-parser.cpp index 416c539acd..375b062219 100644 --- a/backends/common/virtual-keyboard-parser.cpp +++ b/backends/common/virtual-keyboard-parser.cpp @@ -300,13 +300,15 @@ bool VirtualKeyboardParser::parserCallback_Layout() { } _mode->bitmapName = layoutNode->values["bitmap"]; - - 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()); + if (!_mode->image) { + 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()); + } if (layoutNode->values.contains("transparent_color")) { int r, g, b; @@ -347,9 +349,9 @@ bool VirtualKeyboardParser::parserCallback_Area() { 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") { diff --git a/backends/common/virtual-keyboard.cpp b/backends/common/virtual-keyboard.cpp index 45a0a47568..60c0de2356 100644 --- a/backends/common/virtual-keyboard.cpp +++ b/backends/common/virtual-keyboard.cpp @@ -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 @@ void VirtualKeyboard::reset() { _hAlignment = kAlignCentre; _vAlignment = kAlignBottom; _keyQueue.clear(); - _keyDown = 0; - _keyFlags = 0; _loaded = false; _kbdGUI->reset(); } @@ -134,21 +132,16 @@ void VirtualKeyboard::processAreaClick(const Common::String& area) { 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 @@ VirtualKeyboard::KeyPressQueue::KeyPressQueue() { _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 @@ void VirtualKeyboard::KeyPressQueue::insertKey(KeyState key) { ; } + 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 @@ void VirtualKeyboard::KeyPressQueue::insertKey(KeyState key) { 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 @@ void VirtualKeyboard::KeyPressQueue::clear() { _keyPos = _keys.end(); _str.clear(); _strPos = 0; + _keyFlags = 0; } bool VirtualKeyboard::KeyPressQueue::empty() @@ -315,9 +325,22 @@ bool VirtualKeyboard::KeyPressQueue::empty() 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 diff --git a/backends/common/virtual-keyboard.h b/backends/common/virtual-keyboard.h index 9aef84f421..09ae427a48 100644 --- a/backends/common/virtual-keyboard.h +++ b/backends/common/virtual-keyboard.h @@ -112,6 +112,8 @@ protected: class KeyPressQueue { public: KeyPressQueue(); + void toggleFlags(byte fl); + void clearFlags(); void insertKey(KeyState key); void deleteKey(); void moveLeft(); @@ -119,12 +121,17 @@ protected: 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 @@ protected: // TODO : clean up all this stuff friend class VirtualKeyboardGUI; VirtualKeyboardGUI *_kbdGUI; - byte _keyFlags; KeyPressQueue _keyQueue; - KeyState *_keyDown; friend class VirtualKeyboardParser; VirtualKeyboardParser *_parser; |