ScummVM API documentation
input.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef NANCY_INPUT_H
23#define NANCY_INPUT_H
24
25#include "engines/nancy/commontypes.h"
26
27#include "common/rect.h"
28#include "common/keyboard.h"
29
30namespace Common {
31class Keymap;
32typedef class Array<Keymap *> KeymapArray;
33}
34
35namespace Nancy {
36
37namespace State {
38class State;
39}
40
41struct NancyInput {
42 enum InputType : uint16 {
43 kLeftMouseButtonDown = 1 << 0,
44 kLeftMouseButtonHeld = 1 << 1,
45 kLeftMouseButtonUp = 1 << 2,
46 kRightMouseButtonDown = 1 << 3,
47 kRightMouseButtonHeld = 1 << 4,
48 kRightMouseButtonUp = 1 << 5,
49 kMoveUp = 1 << 6,
50 kMoveDown = 1 << 7,
51 kMoveLeft = 1 << 8,
52 kMoveRight = 1 << 9,
53 kMoveFastModifier = 1 << 10,
54 kOpenMainMenu = 1 << 11,
55 kRaycastMap = 1 << 12,
56 kMouseWheelUp = 1 << 13,
57 kMouseWheelDown = 1 << 14,
58
59 kLeftMouseButton = kLeftMouseButtonDown | kLeftMouseButtonHeld | kLeftMouseButtonUp,
60 kRightMouseButton = kRightMouseButtonDown | kRightMouseButtonHeld | kRightMouseButtonUp,
61 kMouseWheel = kMouseWheelUp | kMouseWheelDown
62 };
63
64 Common::Point mousePos; // in game coordinates
65 Common::Point screenMousePos; // Nancy16: for what gets drawn at the screen's own resolution
66 uint16 input;
68
69 void eatMouseInput() { mousePos.x = -1; screenMousePos.x = -1; input &= ~(kLeftMouseButton | kRightMouseButton | kMouseWheel); }
70
71 // Consumes just the wheel input, leaving the mouse position and buttons alone,
72 // so a widget that scrolls can still keep updating its hover state
73 void eatMouseWheelInput() { input &= ~kMouseWheel; }
74};
75
76// This class handles collecting events and translating them to a NancyInput object,
77// which can then be pulled by interested classes through getInput()
79
80public:
81 enum NancyAction {
82 kNancyActionMoveUp,
83 kNancyActionMoveDown,
84 kNancyActionMoveLeft,
85 kNancyActionMoveRight,
86 kNancyActionMoveFast,
87 kNancyActionLeftClick,
88 kNancyActionRightClick,
89 kNancyActionOpenMainMenu,
90 kNancyActionShowRaycastMap
91 };
92
93 InputManager() :
94 _inputs(0),
95 _mouseEnabled(true),
96 _inputBeginState(NancyState::kNone) {}
97
98 void processEvents();
99
100 NancyInput getInput() const;
101 void forceCleanInput();
102 void setMouseInputEnabled(bool enabled) { _mouseEnabled = enabled; }
103 void setKeymapEnabled(Common::String keymapName, bool enabled);
104 void setVKEnabled(bool enabled);
105
106 static void initKeymaps(Common::KeymapArray &keymaps, const char *target);
107
108 static const char *_mazeKeymapID;
109
110private:
111 uint16 _inputs;
112 Common::Array<Common::KeyState> _otherKbdInput;
113 bool _mouseEnabled;
114 NancyState::NancyState _inputBeginState;
115};
116
117} // End of namespace Nancy
118
119#endif // NANCY_INPUT_H
Definition: str.h:59
Definition: input.h:78
Definition: algorithm.h:29
Definition: actionmanager.h:32
T x
Definition: rect.h:48
Definition: rect.h:144
Definition: input.h:41