ScummVM API documentation
events.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 ACCESS_EVENTS_H
23 #define ACCESS_EVENTS_H
24 
25 #include "common/scummsys.h"
26 #include "common/events.h"
27 #include "common/stack.h"
28 
29 namespace Access {
30 
31 enum CursorType {
32  // These names are for Amazon - Noctropolis uses a different order.
33  CURSOR_NONE = -1,
34  CURSOR_ARROW = 0,
35  CURSOR_CROSSHAIRS = 1,
36  CURSOR_2 = 2,
37  CURSOR_3 = 3,
38  CURSOR_LOOK = 4,
39  CURSOR_USE = 5,
40  CURSOR_TAKE = 6,
41  CURSOR_CLIMB = 7,
42  CURSOR_TALK = 8,
43  CURSOR_HELP = 9,
44  CURSOR_NOCT_EXIT = 9,
45  CURSOR_DARK_ANKH = 10,
46  CURSOR_INVENTORY = 99
47 };
48 
49 #define GAME_FRAME_RATE 100
50 #define GAME_FRAME_TIME (1000 / GAME_FRAME_RATE)
51 #define GAME_TIMER_TIME 15
52 
53 class AccessEngine;
54 
56 private:
57  AccessEngine *_vm;
58  uint32 _frameCounter;
59  uint32 _priorFrameTime;
60  uint32 _priorTimerTime;
61  Common::KeyCode _keyCode;
63 
64  Graphics::Surface _invCursor;
65  bool checkForNextFrameCounter();
66  bool checkForNextTimerUpdate();
67  void nextFrame();
68  void nextTimer();
69  void keyControl(Common::KeyCode keycode, bool isKeyDown);
70  void actionControl(Common::CustomEventType action, bool isKeyDown);
71 
72 public:
73  CursorType _cursorId;
74  CursorType _normalMouse;
75  bool _leftButton, _rightButton;
76  bool _middleButton;
77  bool _wheelUp, _wheelDown;
78  Common::Point _mousePos;
79  int _mouseCol, _mouseRow;
80  bool _cursorExitFlag;
81  int _vbCount;
82  bool _interfaceOff;
83 public:
88 
93 
97  uint32 getFrameCounter() const { return _frameCounter; }
98 
102  void forceSetCursor(CursorType cursorId);
103 
107  void setNormalCursor(CursorType cursorId);
108 
112  void setCursor(CursorType cursorId);
113 
118 
122  CursorType getCursor() const { return _cursorId; }
123 
127  void showCursor();
128 
132  void hideCursor();
133 
137  bool isCursorVisible();
138 
139  void pollEvents(bool skipTimers = false);
140 
141  void pollEventsAndWait();
142 
143  void zeroKeysActions();
144 
145  bool getAction(Common::CustomEventType &action);
146 
147  Common::CustomEventType peekAction() const { return _action; }
148 
149  Common::KeyCode peekKeyCode() const { return _keyCode; }
150 
151  bool isKeyActionPending() const;
152 
153  void delay(int time = 5);
154 
155  void delayUntilNextFrame();
156 
157  void debounceLeft();
158 
159  void debounceRight();
160 
161  void clearEvents();
162 
163  void waitKeyActionMouse();
164 
165  const Common::Point &getMousePos() const { return _mousePos; }
166 
167  Common::Point calcRawMouse();
168 
169  int checkMouseBox1(const Common::Array<Common::Rect> &rects);
170 
171  bool isKeyActionMousePressed();
172 
173  void centerMousePos();
174  void restrictMouse();
175 
176  static int16 clipMouseCenter(int16 mousePos, int16 length, int16 maxLength, int16 &warpMousePos);
177 
178  /* get ms delay before considering something a double-click */
179  uint32 getDoubleClickTime() const;
180 
181  uint32 getPriorFrameTime() const { return _priorFrameTime; }
182 };
183 
184 } // End of namespace Access
185 
186 #endif /* ACCESS_EVENTS_H */
Definition: managed_surface.h:51
void forceSetCursor(CursorType cursorId)
Definition: surface.h:67
Definition: events.h:55
Definition: access.h:141
uint32 getFrameCounter() const
Definition: events.h:97
Definition: rect.h:524
uint32 CustomEventType
Definition: events.h:204
EventsManager(AccessEngine *vm)
CursorType getCursor() const
Definition: events.h:122
void setCursor(CursorType cursorId)
void setNormalCursor(CursorType cursorId)
Definition: rect.h:144
Definition: access.h:62
void setCursorData(Graphics::ManagedSurface *src, const Common::Rect &r)