aboutsummaryrefslogtreecommitdiff
path: root/engines/illusions/input.h
diff options
context:
space:
mode:
authorjohndoe1232014-12-11 14:14:52 +0100
committerEugene Sandulenko2018-07-20 06:43:33 +0000
commit36ec0fafdb186ad55a0d6c08e38b96ef84fa60a8 (patch)
tree60c9d7eb972d42f7e6cdaf5d6cb169906f4e1c28 /engines/illusions/input.h
parenta078073e88c094c23e4eb51e5fb85e2cecc3ae9a (diff)
downloadscummvm-rg350-36ec0fafdb186ad55a0d6c08e38b96ef84fa60a8.tar.gz
scummvm-rg350-36ec0fafdb186ad55a0d6c08e38b96ef84fa60a8.tar.bz2
scummvm-rg350-36ec0fafdb186ad55a0d6c08e38b96ef84fa60a8.zip
ILLUSIONS: Refactor the input system
Diffstat (limited to 'engines/illusions/input.h')
-rw-r--r--engines/illusions/input.h62
1 files changed, 47 insertions, 15 deletions
diff --git a/engines/illusions/input.h b/engines/illusions/input.h
index f3c9654d37..f203a64046 100644
--- a/engines/illusions/input.h
+++ b/engines/illusions/input.h
@@ -31,43 +31,75 @@
namespace Illusions {
enum {
- MOUSE_NONE = 0,
- MOUSE_BUTTON0 = 1,
- MOUSE_BUTTON1 = 2
+ MOUSE_NONE = 0,
+ MOUSE_LEFT_BUTTON = 1,
+ MOUSE_RIGHT_BUTTON = 2
+};
+
+enum {
+ kEventLeftClick = 0,
+ kEventRightClick = 1,
+ kEventInventory = 2,
+ kEventAbort = 3,
+ kEventSkip = 4,
+ kEventF1 = 5,
+ kEventUp = 6,
+ kEventDown = 7,
+ kEventMax
};
struct KeyMapping {
Common::KeyCode _key;
int _mouseButton;
- uint _bitMask;
bool _down;
};
+class KeyMap : public Common::Array<KeyMapping> {
+public:
+ void addKey(Common::KeyCode key);
+ void addMouseButton(int mouseButton);
+protected:
+ void add(Common::KeyCode key, int mouseButton);
+};
+
+class InputEvent {
+public:
+ InputEvent& setBitMask(uint bitMask);
+ InputEvent& addKey(Common::KeyCode key);
+ InputEvent& addMouseButton(int mouseButton);
+ byte handle(Common::KeyCode key, int mouseButton, bool down);
+ uint getBitMask() const { return _bitMask; }
+protected:
+ uint _bitMask;
+ KeyMap _keyMap;
+};
+
class Input {
public:
Input();
void processEvent(Common::Event event);
- bool pollButton(uint buttons);
- bool lookButtonStates(uint buttons);
- bool lookNewButtons(uint buttons);
- void setButtonState(uint buttons);
- void discardButtons(uint buttons);
- void activateButton(uint buttons);
- void deactivateButton(uint buttons);
+ bool pollEvent(uint evt);
+ void discardEvent(uint evt);
+ void discardAllEvents();
+ void activateButton(uint bitMask);
+ void deactivateButton(uint bitMask);
Common::Point getCursorPosition();
void setCursorPosition(Common::Point mousePos);
Common::Point getCursorDelta();
+ InputEvent& setInputEvent(uint evt, uint bitMask);
protected:
- typedef Common::Array<KeyMapping> KeyMap;
uint _buttonStates, _newButtons, _buttonsDown;
uint _enabledButtons;
uint _newKeys;
Common::Point _cursorPos, _prevCursorPos;
- KeyMap _keyMap;
- void initKeys();
- void addKeyMapping(Common::KeyCode key, int mouseButton, uint bitMask);
+ InputEvent _inputEvents[kEventMax];
void handleKey(Common::KeyCode key, int mouseButton, bool down);
void handleMouseButton(int mouseButton, bool down);
+ bool pollButton(uint bitMask);
+ void discardButtons(uint bitMask);
+ bool lookButtonStates(uint bitMask);
+ bool lookNewButtons(uint bitMask);
+ void setButtonState(uint bitMask);
};
} // End of namespace Illusions