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