From d79549964c23336dd609702defb9ac740ab971ff Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 3 Jun 2012 03:16:57 +0200 Subject: WINTERMUTE: Make the engine atleast register keypresses. --- engines/wintermute/Base/BGame.cpp | 12 ++++++------ engines/wintermute/Base/BObject.cpp | 2 +- engines/wintermute/Base/BObject.h | 5 ++--- engines/wintermute/PlatformSDL.cpp | 2 ++ engines/wintermute/UI/UIWindow.cpp | 6 ++---- engines/wintermute/UI/UIWindow.h | 3 ++- 6 files changed, 15 insertions(+), 15 deletions(-) (limited to 'engines/wintermute') diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 3a4e88a612..33bfc8956a 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -3793,22 +3793,22 @@ bool CBGame::HandleKeypress(Common::Event *event) { _keyboardState->ReadKey(event); // TODO -#if 0 + if (_focusedWindow) { if (!Game->_focusedWindow->HandleKeypress(event)) { - if (event->type != SDL_TEXTINPUT) { + /*if (event->type != SDL_TEXTINPUT) {*/ if (Game->_focusedWindow->CanHandleEvent("Keypress")) Game->_focusedWindow->ApplyEvent("Keypress"); else ApplyEvent("Keypress"); - } + /*}*/ } return true; - } else if (event->type != SDL_TEXTINPUT) { + } else /*if (event->type != SDL_TEXTINPUT)*/ { ApplyEvent("Keypress"); return true; - } else return true; -#endif + } //else return true; + return false; } diff --git a/engines/wintermute/Base/BObject.cpp b/engines/wintermute/Base/BObject.cpp index 046f31e4ac..9f34541087 100644 --- a/engines/wintermute/Base/BObject.cpp +++ b/engines/wintermute/Base/BObject.cpp @@ -960,7 +960,7 @@ HRESULT CBObject::HandleMouse(TMouseEvent Event, TMouseButton Button) { ////////////////////////////////////////////////////////////////////////// -bool CBObject::HandleKeypress(SDL_Event *event) { +bool CBObject::HandleKeypress(Common::Event *event) { return false; } diff --git a/engines/wintermute/Base/BObject.h b/engines/wintermute/Base/BObject.h index e2c3b25fd8..475325e8e2 100644 --- a/engines/wintermute/Base/BObject.h +++ b/engines/wintermute/Base/BObject.h @@ -32,8 +32,7 @@ #include "engines/wintermute/Base/BScriptHolder.h" #include "engines/wintermute/persistent.h" - -union SDL_Event; +#include "common/events.h" namespace WinterMute { @@ -82,7 +81,7 @@ public: virtual bool HandleMouseWheel(int Delta); virtual HRESULT HandleMouse(TMouseEvent Event, TMouseButton Button); - virtual bool HandleKeypress(SDL_Event *event); + virtual bool HandleKeypress(Common::Event *event); virtual int GetHeight(); HRESULT SetCursor(const char *Filename); HRESULT SetActiveCursor(const char *Filename); diff --git a/engines/wintermute/PlatformSDL.cpp b/engines/wintermute/PlatformSDL.cpp index 909ecb525e..934670a628 100644 --- a/engines/wintermute/PlatformSDL.cpp +++ b/engines/wintermute/PlatformSDL.cpp @@ -244,6 +244,8 @@ void CBPlatform::HandleEvent(Common::Event *event) { case Common::EVENT_MBUTTONUP: if (Game) Game->OnMouseMiddleUp(); break; + case Common::EVENT_KEYDOWN: + if (Game) Game->HandleKeypress(event); /*#ifdef __IPHONEOS__ { CBRenderSDL *renderer = static_cast(Game->_renderer); diff --git a/engines/wintermute/UI/UIWindow.cpp b/engines/wintermute/UI/UIWindow.cpp index d364b27740..53ce72fe4a 100644 --- a/engines/wintermute/UI/UIWindow.cpp +++ b/engines/wintermute/UI/UIWindow.cpp @@ -1100,16 +1100,14 @@ const char *CUIWindow::ScToString() { ////////////////////////////////////////////////////////////////////////// -bool CUIWindow::HandleKeypress(SDL_Event *event) { +bool CUIWindow::HandleKeypress(Common::Event *event) { //TODO -#if 0 - if (event->type == SDL_KEYDOWN && event->key.keysym.scancode == SDL_SCANCODE_TAB) { + if (event->type == Common::EVENT_KEYDOWN && event->kbd.keycode == Common::KEYCODE_TAB) { return SUCCEEDED(MoveFocus(!CBKeyboardState::IsShiftDown())); } else { if (_focusedWidget) return _focusedWidget->HandleKeypress(event); else return false; } -#endif return false; } diff --git a/engines/wintermute/UI/UIWindow.h b/engines/wintermute/UI/UIWindow.h index 510fc076b4..4bdef647a3 100644 --- a/engines/wintermute/UI/UIWindow.h +++ b/engines/wintermute/UI/UIWindow.h @@ -31,6 +31,7 @@ #include "UIObject.h" +#include "common/events.h" namespace WinterMute { @@ -69,7 +70,7 @@ public: virtual HRESULT Display(int OffsetX = 0, int OffsetY = 0); CUIWindow(CBGame *inGame); virtual ~CUIWindow(); - virtual bool HandleKeypress(SDL_Event *event); + virtual bool HandleKeypress(Common::Event *event); CBArray _widgets; TTextAlign _titleAlign; HRESULT LoadFile(const char *Filename); -- cgit v1.2.3