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 
72 public:
73  enum NancyAction {
74  kNancyActionMoveUp,
75  kNancyActionMoveDown,
76  kNancyActionMoveLeft,
77  kNancyActionMoveRight,
78  kNancyActionMoveFast,
79  kNancyActionLeftClick,
80  kNancyActionRightClick,
81  kNancyActionOpenMainMenu,
82  kNancyActionShowRaycastMap
83  };
84 
85  InputManager() :
86  _inputs(0),
87  _mouseEnabled(true),
88  _inputBeginState(NancyState::kNone) {}
89 
90  void processEvents();
91 
92  NancyInput getInput() const;
93  void forceCleanInput();
94  void setMouseInputEnabled(bool enabled) { _mouseEnabled = enabled; }
95  void setKeymapEnabled(Common::String keymapName, bool enabled);
96  void setVKEnabled(bool enabled);
97 
98  static void initKeymaps(Common::KeymapArray &keymaps, const char *target);
99 
100  static const char *_mazeKeymapID;
101 
102 private:
103  uint16 _inputs;
104  Common::Array<Common::KeyState> _otherKbdInput;
105  bool _mouseEnabled;
106  NancyState::NancyState _inputBeginState;
107 };
108 
109 } // End of namespace Nancy
110 
111 #endif // NANCY_INPUT_H
Definition: str.h:59
Definition: input.h:41
Definition: input.h:70
Definition: algorithm.h:29
T x
Definition: rect.h:48
Definition: rect.h:144
Definition: actionmanager.h:32