TITANIC: Implement keyboard event handling

This commit is contained in:
Paul Gilbert 2016-03-31 23:40:30 -04:00
parent 18fabbb2d4
commit 43f183c207
3 changed files with 17 additions and 0 deletions

View File

@ -187,6 +187,9 @@ void Events::keyDown(Common::KeyState keyState) {
_vm->_debugger->attach();
_vm->_debugger->onFrame();
}
if (_vm->_window->_inputAllowed)
_vm->_window->_gameManager->_inputTranslator.keyDown(keyState);
}
void Events::keyUp(Common::KeyState keyState) {

View File

@ -94,4 +94,16 @@ void CInputTranslator::rightButtonDoubleClick(int special, const Point &pt) {
_inputHandler->handleMessage(msg);
}
void CInputTranslator::keyDown(const Common::KeyState &keyState) {
if (keyState.keycode >= Common::KEYCODE_F1 && keyState.keycode <= Common::KEYCODE_F5) {
CVirtualKeyCharMsg msg(keyState);
_inputHandler->handleMessage(msg);
}
if (keyState.ascii >= 32 && keyState.ascii <= 127) {
CKeyCharMsg msg(keyState.ascii);
_inputHandler->handleMessage(msg);
}
}
} // End of namespace Titanic

View File

@ -23,6 +23,7 @@
#ifndef TITANIC_INPUT_TRANSLATOR_H
#define TITANIC_INPUT_TRANSLATOR_H
#include "common/keyboard.h"
#include "titanic/messages/mouse_messages.h"
namespace Titanic {
@ -50,6 +51,7 @@ public:
void rightButtonDown(int special, const Point &pt);
void rightButtonUp(int special, const Point &pt);
void rightButtonDoubleClick(int special, const Point &pt);
void keyDown(const Common::KeyState &keyState);
};
} // End of namespace Titanic