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 M4_PLATFORM_EVENTS_H
23 #define M4_PLATFORM_EVENTS_H
24 
25 #include "common/queue.h"
26 #include "common/events.h"
27 #include "m4/m4_types.h"
28 
29 namespace M4 {
30 
31 enum MouseEvent {
32  _ME_no_event, // 0
33  _ME_move, // 1
34  _ME_L_click, // 2
35  _ME_L_hold, // 3
36  _ME_L_drag, // 4
37  _ME_L_release, // 5
38  _ME_R_click, // 6
39  _ME_R_hold, // 7
40  _ME_R_drag, // 8
41  _ME_R_release, // 9
42  _ME_both_click, // 10
43  _ME_both_hold, // 11
44  _ME_both_drag, // 12
45  _ME_both_release, // 13
46  _ME_doubleclick, // 14
47  _ME_doubleclick_hold, // 15
48  _ME_doubleclick_drag, // 16
49  _ME_doubleclick_release
50 };
51 
52 enum mausState {
53  _MS_no_event, // 0
54  _MS_L_clickDown, // 1
55  _MS_R_clickDown, // 2
56  _MS_both_clickDown, // 3
57  _MS_doubleclick_Down // 4
58 };
59 
60 struct MouseInfo {
61  uint16 Event = 0;
62  uint16 ButtonState = 0;
63  uint16 CursorColumn = 0; // x
64  uint16 CursorRow = 0; // y
65  uint16 HorizontalMickeyCount = 0;
66  uint16 VerticalMickeyCount = 0;
67 };
68 
69 struct Events : public MouseInfo {
70 private:
72  uint16 &_mouseX = CursorColumn;
73  uint16 &_mouseY = CursorRow;
74  uint16 _oldX = 0xffff;
75  uint16 _oldY = 0xffff;
76  mausState _mouse_state = _MS_no_event;
77  uint32 _mouseStateEvent = 0;
78  uint32 _dclickTime = 0;
79 
83  void pollEvents();
84 
88  void handleMouseEvent(const Common::Event &ev);
89 
93  void handleKeyboardEvent(const Common::Event &ev);
94 
98  inline bool is_mod_key(const Common::KeyState &ks) {
99  return ks.keycode == Common::KEYCODE_LCTRL || ks.keycode == Common::KEYCODE_RCTRL ||
100  ks.keycode == Common::KEYCODE_LALT || ks.keycode == Common::KEYCODE_RALT ||
101  ks.keycode == Common::KEYCODE_LSHIFT || ks.keycode == Common::KEYCODE_RSHIFT ||
102  ks.keycode == Common::KEYCODE_MODE;
103  }
104 
105 public:
106  Events();
107  ~Events();
108 
112  void process();
113 
117  MouseEvent mouse_get_event();
118 
122  bool util_kbd_check(int32 *parm1);
123 
124  void clearMouseStateEvent() {
125  _mouseStateEvent = 0;
126  }
127 
131  void delay(uint amount);
132 };
133 
134 extern Events *g_events;
135 
136 MouseEvent mouse_get_event();
137 bool util_kbd_check(int32 *parm1);
138 
139 } // namespace M4
140 
141 #endif
Definition: events.h:60
KeyCode keycode
Definition: keyboard.h:299
Definition: events.h:199
Definition: database.h:28
Definition: keyboard.h:294
Definition: events.h:69