Bug fixes to get new keyboard pack working
svn-id: r33465
This commit is contained in:
parent
8345c1b687
commit
ad6563a57a
3 changed files with 55 additions and 25 deletions
|
@ -300,13 +300,15 @@ bool VirtualKeyboardParser::parserCallback_Layout() {
|
|||
}
|
||||
|
||||
_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());
|
||||
|
||||
_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") {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue