diff options
| author | Stephen Kennedy | 2008-08-18 10:07:11 +0000 |
|---|---|---|
| committer | Stephen Kennedy | 2008-08-18 10:07:11 +0000 |
| commit | d92909203b56d9b3fa6c4989bdeb83dbed5b94d5 (patch) | |
| tree | 350de91c678c790dde49487804b02e1bb317f1d2 /backends/vkeybd | |
| parent | 63c4a61032bd97b478de9cbf82510f461d08f653 (diff) | |
| download | scummvm-rg350-d92909203b56d9b3fa6c4989bdeb83dbed5b94d5.tar.gz scummvm-rg350-d92909203b56d9b3fa6c4989bdeb83dbed5b94d5.tar.bz2 scummvm-rg350-d92909203b56d9b3fa6c4989bdeb83dbed5b94d5.zip | |
- proper init of virtual keyboard now implemented (involved added EventManager::init() which is called after screen has been initialised)
- changed HardwareKey / Action id field to an array of 4 chars instead of int32. Means that the keymap key/value pairs in config file are more readable.
svn-id: r33986
Diffstat (limited to 'backends/vkeybd')
| -rw-r--r-- | backends/vkeybd/virtual-keyboard-gui.cpp | 52 | ||||
| -rw-r--r-- | backends/vkeybd/virtual-keyboard-gui.h | 6 | ||||
| -rw-r--r-- | backends/vkeybd/virtual-keyboard.cpp | 8 |
3 files changed, 43 insertions, 23 deletions
diff --git a/backends/vkeybd/virtual-keyboard-gui.cpp b/backends/vkeybd/virtual-keyboard-gui.cpp index d46dc695f6..8f1ed6588c 100644 --- a/backends/vkeybd/virtual-keyboard-gui.cpp +++ b/backends/vkeybd/virtual-keyboard-gui.cpp @@ -39,6 +39,9 @@ VirtualKeyboardGUI::VirtualKeyboardGUI(VirtualKeyboard *kbd) _system = g_system; _lastScreenChanged = _system->getScreenChangeID(); + _screenW = _system->getOverlayWidth(); + _screenH = _system->getOverlayHeight(); + memset(_cursor, 0xFF, sizeof(_cursor)); } @@ -93,6 +96,11 @@ void VirtualKeyboardGUI::checkScreenChanged() { screenChanged(); } +void VirtualKeyboardGUI::initSize(int16 w, int16 h) { + _screenW = w; + _screenH = h; +} + void VirtualKeyboardGUI::run() { if (_firstRun) { _firstRun = false; @@ -103,7 +111,7 @@ void VirtualKeyboardGUI::run() { _system->showOverlay(); _system->clearOverlay(); } - _overlayBackup.create(_system->getOverlayWidth(), _system->getOverlayHeight(), sizeof(OverlayColor)); + _overlayBackup.create(_screenW, _screenH, sizeof(OverlayColor)); _system->grabOverlay((OverlayColor*)_overlayBackup.pixels, _overlayBackup.w); setupCursor(); @@ -136,32 +144,31 @@ void VirtualKeyboardGUI::reset() { void VirtualKeyboardGUI::moveToDefaultPosition() { - int16 scrW = _system->getOverlayWidth(), scrH = _system->getOverlayHeight(); int16 kbdW = _kbdBound.width(), kbdH = _kbdBound.height(); int16 x = 0, y = 0; - if (scrW != kbdW) { + if (_screenW != kbdW) { switch (_kbd->_hAlignment) { case VirtualKeyboard::kAlignLeft: x = 0; break; case VirtualKeyboard::kAlignCentre: - x = (scrW - kbdW) / 2; + x = (_screenW - kbdW) / 2; break; case VirtualKeyboard::kAlignRight: - x = scrW - kbdW; + x = _screenW - kbdW; break; } } - if (scrH != kbdH) { + if (_screenH != kbdH) { switch (_kbd->_vAlignment) { case VirtualKeyboard::kAlignTop: y = 0; break; case VirtualKeyboard::kAlignMiddle: - y = (scrH - kbdH) / 2; + y = (_screenH - kbdH) / 2; break; case VirtualKeyboard::kAlignBottom: - y = scrH - kbdH; + y = _screenH - kbdH; break; } } @@ -170,17 +177,17 @@ void VirtualKeyboardGUI::moveToDefaultPosition() void VirtualKeyboardGUI::move(int16 x, int16 y) { // add old position to dirty area - extendDirtyRect(_kbdBound); + if (_displaying) extendDirtyRect(_kbdBound); // snap to edge of screen if (ABS(x) < SNAP_WIDTH) x = 0; - int16 x2 = _system->getOverlayWidth() - _kbdBound.width(); + int16 x2 = _screenW - _kbdBound.width(); if (ABS(x - x2) < SNAP_WIDTH) x = x2; if (ABS(y) < SNAP_WIDTH) y = 0; - int16 y2 = _system->getOverlayHeight() - _kbdBound.height(); + int16 y2 = _screenH - _kbdBound.height(); if (ABS(y - y2) < SNAP_WIDTH) y = y2; @@ -188,19 +195,26 @@ void VirtualKeyboardGUI::move(int16 x, int16 y) { _dispY += y - _kbdBound.top; _kbdBound.moveTo(x, y); - // add new position to dirty area - extendDirtyRect(_kbdBound); - - redraw(); + if (_displaying) { + // add new position to dirty area + extendDirtyRect(_kbdBound); + redraw(); + } } void VirtualKeyboardGUI::screenChanged() { _lastScreenChanged = _system->getScreenChangeID(); - if (!_kbd->checkModeResolutions()) { - _displaying = false; - return; + int16 newScreenW = _system->getOverlayWidth(); + int16 newScreenH = _system->getOverlayHeight(); + if (_screenW != newScreenW || _screenH != newScreenH) { + _screenW = newScreenW; + _screenH = newScreenH; + if (!_kbd->checkModeResolutions()) { + _displaying = false; + return; + } + moveToDefaultPosition(); } - moveToDefaultPosition(); } diff --git a/backends/vkeybd/virtual-keyboard-gui.h b/backends/vkeybd/virtual-keyboard-gui.h index 8171f166f1..ae6385e30b 100644 --- a/backends/vkeybd/virtual-keyboard-gui.h +++ b/backends/vkeybd/virtual-keyboard-gui.h @@ -49,10 +49,12 @@ public: void reset(); void startDrag(int16 x, int16 y); void endDrag(); + void initSize(int16 w, int16 h); private: OSystem *_system; + VirtualKeyboard *_kbd; Rect _kbdBound; Graphics::Surface *_kbdSurface; @@ -72,9 +74,11 @@ private: uint _dispI; OverlayColor _dispForeColor, _dispBackColor; + int _lastScreenChanged; + int16 _screenW, _screenH; + bool _displaying; bool _firstRun; - int _lastScreenChanged; void setupDisplayArea(Rect& r, OverlayColor forecolor); void move(int16 x, int16 y); diff --git a/backends/vkeybd/virtual-keyboard.cpp b/backends/vkeybd/virtual-keyboard.cpp index 3a66c75091..fbf26b80b5 100644 --- a/backends/vkeybd/virtual-keyboard.cpp +++ b/backends/vkeybd/virtual-keyboard.cpp @@ -44,7 +44,6 @@ VirtualKeyboard::VirtualKeyboard() : _currentMode(0) { _kbdGUI = new VirtualKeyboardGUI(this); _submitKeys = _loaded = false; - printf("\t\"%c\",\n",255); } VirtualKeyboard::~VirtualKeyboard() { @@ -75,6 +74,9 @@ void VirtualKeyboard::reset() { } bool VirtualKeyboard::loadKeyboardPack(Common::String packName) { + + _kbdGUI->initSize(_system->getOverlayWidth(), _system->getOverlayHeight()); + FilesystemNode *vkDir = 0; if (ConfMan.hasKey("vkeybdpath")) { vkDir = new FilesystemNode(ConfMan.get("vkeybdpath")); @@ -138,7 +140,7 @@ bool VirtualKeyboard::checkModeResolutions() { _parser->setParseMode(kParseCheckResolutions); _loaded = _parser->parse(); - _kbdGUI->initMode(_currentMode); + if (_currentMode) _kbdGUI->initMode(_currentMode); return _loaded; } @@ -215,7 +217,7 @@ void VirtualKeyboard::handleMouseUp(int16 x, int16 y) { void VirtualKeyboard::show() { if (_loaded) _kbdGUI->checkScreenChanged(); if (!_loaded) { - warning("Virtual keyboard not loaded!"); + warning("Virtual keyboard not loaded"); return; } |
