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 TWINE_KEYBOARD_H
23 #define TWINE_KEYBOARD_H
24 
25 #include "common/events.h"
26 #include "common/keyboard.h"
27 #include "common/scummsys.h"
28 #include "common/util.h"
29 #include "common/rect.h"
30 
31 namespace TwinE {
32 
33 class TwinEEngine;
34 
35 extern const char *mainKeyMapId;
36 extern const char *uiKeyMapId;
37 extern const char *cutsceneKeyMapId;
38 extern const char *holomapKeyMapId;
39 
40 enum TwinEActionType {
41  Pause,
42  DebugGridCameraPressUp,
43  DebugGridCameraPressDown,
44  DebugGridCameraPressLeft,
45  DebugGridCameraPressRight,
46  QuickBehaviourNormal,
47  QuickBehaviourAthletic,
48  QuickBehaviourAggressive,
49  QuickBehaviourDiscreet,
50  ChangeBehaviourNormal,
51  ChangeBehaviourAthletic,
52  ChangeBehaviourAggressive,
53  ChangeBehaviourDiscreet,
54  ExecuteBehaviourAction,
55  BehaviourMenu,
56  OptionsMenu,
57  RecenterScreenOnTwinsen,
58  UseSelectedObject,
59  ThrowMagicBall,
60  MoveForward,
61  MoveBackward,
62  TurnRight,
63  TurnLeft,
64  UseProtoPack,
65  OpenHolomap,
66  InventoryMenu,
67  SpecialAction,
68  SceneryZoom,
69  Escape,
70 
71  UIEnter,
72  UIAbort,
73  UILeft,
74  UIRight,
75  UIUp,
76  UIDown,
77  UINextPage,
78 
79  CutsceneAbort,
80 
81  HolomapAbort,
82  HolomapLeft,
83  HolomapRight,
84  HolomapUp,
85  HolomapDown,
86  HolomapNext,
87  HolomapPrev,
88 
89  Max
90 };
91 
95 class ScopedKeyMap {
96 private:
97  TwinEEngine* _engine;
98  bool _changed;
99  Common::String _keymap;
100 public:
101  ScopedKeyMap(TwinEEngine* engine, const char *id);
102  ~ScopedKeyMap();
103 };
104 
105 class Input {
106 private:
107  TwinEEngine *_engine;
108  Common::String _currentKeyMap;
109 
110  uint8 _actionStates[TwinEActionType::Max]{false};
111  Common::Point _lastMousePos;
112 public:
113  Input(TwinEEngine *engine);
114 
119  void enableKeyMap(const char *id);
120  bool enableAdditionalKeyMap(const char *id, bool enable);
121 
122  const Common::String currentKeyMap() const;
123 
131  bool isActionActive(TwinEActionType actionType, bool onlyFirstTime = true) const;
132 
133  void resetLastHoveredMousePosition();
134  bool isMouseHovering(const Common::Rect &rect, bool onlyIfMoved = true);
135 
140  bool toggleActionIfActive(TwinEActionType actionType);
141  void resetActionStates();
142 
143  bool toggleAbortAction();
144 
145  bool isQuickBehaviourActionActive() const;
146  bool isMoveOrTurnActionActive() const;
147  bool isHeroActionActive() const;
148  bool resetHeroActions();
149 
154  Common::Point getMousePositions() const;
155 
159  void readKeys();
160  void processCustomEngineEventStart(const Common::Event& event);
161  void processCustomEngineEventEnd(const Common::Event& event);
162 };
163 
164 inline const Common::String Input::currentKeyMap() const {
165  return _currentKeyMap;
166 }
167 
168 } // namespace TwinE
169 
170 #endif
Definition: str.h:59
Definition: input.h:105
Definition: rect.h:144
Definition: events.h:199
Activates the given key map id that is registered in the meta engine.
Definition: input.h:95
Definition: rect.h:45
Definition: twine.h:207
Definition: achievements_tables.h:27