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 
30 namespace Common {
31 class Keymap;
32 typedef class Array<Keymap *> KeymapArray;
33 }
34 
35 namespace Nancy {
36 
37 namespace State {
38 class State;
39 }
40 
41 struct 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 
57  kLeftMouseButton = kLeftMouseButtonDown | kLeftMouseButtonHeld | kLeftMouseButtonUp,
58  kRightMouseButton = kRightMouseButtonDown | kRightMouseButtonHeld | kRightMouseButtonUp
59  };
60 
61  Common::Point mousePos;
62  uint16 input;
63  Common::Array<Common::KeyState> otherKbdInput;
64 
65  void eatMouseInput() { mousePos.x = -1; input &= ~(kLeftMouseButton | kRightMouseButton); }
66 };
67 
68 // This class handles collecting events and translating them to a NancyInput object,
69 // which can then be pulled by interested classes through getInput()
70 class InputManager {
71  friend class NancyConsole;
72 
73 enum NancyAction {
74  kNancyActionMoveUp,
75  kNancyActionMoveDown,
76  kNancyActionMoveLeft,
77  kNancyActionMoveRight,
78  kNancyActionMoveFast,
79  kNancyActionLeftClick,
80  kNancyActionRightClick,
81  kNancyActionOpenMainMenu,
82  kNancyActionShowRaycastMap
83 };
84 
85 public:
86  InputManager() :
87  _inputs(0),
88  _mouseEnabled(true),
89  _inputBeginState(NancyState::kNone) {}
90 
91  void processEvents();
92 
93  NancyInput getInput() const;
94  void forceCleanInput();
95  void setMouseInputEnabled(bool enabled) { _mouseEnabled = enabled; }
96  void setKeymapEnabled(Common::String keymapName, bool enabled);
97  void setVKEnabled(bool enabled);
98 
99  static void initKeymaps(Common::KeymapArray &keymaps, const char *target);
100 
101  static const char *_mazeKeymapID;
102 
103 private:
104  uint16 _inputs;
105  Common::Array<Common::KeyState> _otherKbdInput;
106  bool _mouseEnabled;
107  NancyState::NancyState _inputBeginState;
108 };
109 
110 } // End of namespace Nancy
111 
112 #endif // NANCY_INPUT_H
Definition: str.h:59
Definition: input.h:41
Definition: input.h:70
Definition: algorithm.h:29
Definition: rect.h:45
int16 x
Definition: rect.h:46
Definition: console.h:36
Definition: actionmanager.h:32