diff options
author | D G Turner | 2012-10-31 23:51:42 +0000 |
---|---|---|
committer | D G Turner | 2012-11-11 23:14:17 +0000 |
commit | 0a709d955da76df038a87a792d1759e43d718591 (patch) | |
tree | 655a5585776ea580a37019cd0cfa5b1916bca462 | |
parent | 659a4b8b14a8379cb672b5953ac79f69a9ec5f48 (diff) | |
download | scummvm-rg350-0a709d955da76df038a87a792d1759e43d718591.tar.gz scummvm-rg350-0a709d955da76df038a87a792d1759e43d718591.tar.bz2 scummvm-rg350-0a709d955da76df038a87a792d1759e43d718591.zip |
TONY: Replace Input class internal buffers with Common standard.
The mouse position is now represented internally by Common::Point and
the keyDown buffer is an array of Common::Keycode values for depressed
keys.
-rw-r--r-- | engines/tony/input.cpp | 29 | ||||
-rw-r--r-- | engines/tony/input.h | 7 |
2 files changed, 22 insertions, 14 deletions
diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index 553a3f7a68..36a9082aa2 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -32,13 +32,8 @@ namespace Tony { RMInput::RMInput() { - // Setup mouse fields - _mousePos.set(0, 0); _leftClickMouse = _leftReleaseMouse = false; _rightClickMouse = _rightReleaseMouse = false; - - // Setup keyboard fields - Common::fill(&_keyDown[0], &_keyDown[350], 0); } void RMInput::poll() { @@ -52,7 +47,7 @@ void RMInput::poll() { case Common::EVENT_LBUTTONUP: case Common::EVENT_RBUTTONDOWN: case Common::EVENT_RBUTTONUP: - _mousePos.set(_event.mouse.x, _event.mouse.y); + _mousePos = _event.mouse; if (_event.type == Common::EVENT_LBUTTONDOWN) { _leftClickMouse = true; @@ -76,12 +71,17 @@ void RMInput::poll() { g_vm->_debugger->onFrame(); } else { // Flag the given key as being down - _keyDown[(int)_event.kbd.keycode] = true; + _keyDown.push_back(_event.kbd.keycode); } return; case Common::EVENT_KEYUP: - _keyDown[(int)_event.kbd.keycode] = false; + for (int i = 0; i < _keyDown.size(); i++) { + if (_keyDown[i] == _event.kbd.keycode) { + _keyDown.remove_at(i); + break; + } + } return; default: @@ -96,16 +96,21 @@ void RMInput::poll() { bool RMInput::getAsyncKeyState(Common::KeyCode kc) { // The act of testing for a particular key automatically clears the state, to prevent // the same key being registered in multiple different frames - bool result = _keyDown[(int)kc]; - _keyDown[(int)kc] = false; - return result; + for (int i = 0; i < _keyDown.size(); i++) { + if (_keyDown[i] == kc) { + _keyDown.remove_at(i); + return true; + } + } + return false; } /** * Reading of the mouse */ RMPoint RMInput::mousePos() { - return _mousePos; + RMPoint p(_mousePos.x, _mousePos.y); + return p; } /** diff --git a/engines/tony/input.h b/engines/tony/input.h index 1672747efc..274aa8c491 100644 --- a/engines/tony/input.h +++ b/engines/tony/input.h @@ -30,6 +30,9 @@ #define TONY_INPUT_H #include "common/events.h" +#include "common/rect.h" +#include "common/array.h" +#include "common/keyboard.h" #include "tony/utils.h" namespace Tony { @@ -39,11 +42,11 @@ private: Common::Event _event; // Mouse related fields - RMPoint _mousePos; + Common::Point _mousePos; bool _leftClickMouse, _leftReleaseMouse, _rightClickMouse, _rightReleaseMouse; // Keyboard related fields - bool _keyDown[350]; + Common::Array<Common::KeyCode> _keyDown; public: RMInput(); |