ScummVM API documentation
event.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 SCI_EVENT_H
23#define SCI_EVENT_H
24
25#include "common/list.h"
26#include "common/rect.h"
27
28namespace Sci {
29
30enum SciEventType {
31 kSciEventNone = 0,
32 kSciEventMousePress = 1,
33 kSciEventMouseRelease = 1 << 1,
34 kSciEventMouse = kSciEventMousePress | kSciEventMouseRelease,
35 kSciEventKeyDown = 1 << 2,
36 kSciEventKeyUp = 1 << 3,
37 kSciEventKey = kSciEventKeyDown | kSciEventKeyUp,
38 kSciEventDirection16 = 1 << 6, // SCI16
39 kSciEventSaid = 1 << 7,
40#ifdef ENABLE_SCI32
41 kSciEventDirection32 = 1 << 4, // SCI32
42 kSciEventHotRectangle = 1 << 10,
43#endif
44 kSciEventQuit = 1 << 11,
45 kSciEventPeek = 1 << 15,
46
47 kSciEventAny = ~kSciEventPeek
48};
49
50inline SciEventType operator|(const SciEventType a, const SciEventType b) {
51 return static_cast<SciEventType>((int)a | (int)b);
52}
53
54inline SciEventType &operator|=(SciEventType &a, const SciEventType b) {
55 return a = static_cast<SciEventType>((int)a | (int)b);
56}
57
58enum SciKeyCode {
59 kSciKeyEtx = 3,
60 kSciKeyBackspace = 8,
61 kSciKeyTab = '\t',
62 kSciKeyEnter = 13,
63 kSciKeyEsc = 27,
64 kSciKeyShiftTab = 15 << 8,
65
66 kSciKeyHome = 71 << 8, // numpad 7
67 kSciKeyUp = 72 << 8, // numpad 8
68 kSciKeyPageUp = 73 << 8, // numpad 9
69 kSciKeyLeft = 75 << 8, // numpad 4
70 kSciKeyCenter = 76 << 8, // numpad 5
71 kSciKeyRight = 77 << 8, // numpad 6
72 kSciKeyEnd = 79 << 8, // numpad 1
73 kSciKeyDown = 80 << 8, // numpad 2
74 kSciKeyPageDown = 81 << 8, // numpad 3
75 kSciKeyInsert = 82 << 8, // numpad 0
76 kSciKeyDelete = 83 << 8, // numpad .
77
78 kSciKeyF1 = 59 << 8,
79 kSciKeyF2 = 60 << 8,
80 kSciKeyF3 = 61 << 8,
81 kSciKeyF4 = 62 << 8,
82 kSciKeyF5 = 63 << 8,
83 kSciKeyF6 = 64 << 8,
84 kSciKeyF7 = 65 << 8,
85 kSciKeyF8 = 66 << 8,
86 kSciKeyF9 = 67 << 8,
87 kSciKeyF10 = 68 << 8,
88
89 kSciKeyShiftF1 = 84 << 8,
90 kSciKeyShiftF2 = 85 << 8,
91 kSciKeyShiftF3 = 86 << 8,
92 kSciKeyShiftF4 = 87 << 8,
93 kSciKeyShiftF5 = 88 << 8,
94 kSciKeyShiftF6 = 89 << 8,
95 kSciKeyShiftF7 = 90 << 8,
96 kSciKeyShiftF8 = 91 << 8,
97 kSciKeyShiftF9 = 92 << 8,
98 kSciKeyShiftF10 = 93 << 8
99};
100
101enum SciKeyModifiers {
102 kSciKeyModNone = 0,
103 kSciKeyModRShift = 1,
104 kSciKeyModLShift = 1 << 1,
105 kSciKeyModShift = kSciKeyModRShift | kSciKeyModLShift,
106 kSciKeyModCtrl = 1 << 2,
107 kSciKeyModAlt = 1 << 3,
108 kSciKeyModScrLock = 1 << 4,
109 kSciKeyModNumLock = 1 << 5,
110 kSciKeyModCapsLock = 1 << 6,
111 kSciKeyModInsert = 1 << 7,
112 kSciKeyModNonSticky = kSciKeyModRShift | kSciKeyModLShift | kSciKeyModCtrl | kSciKeyModAlt,
113 kSciKeyModAll = ~kSciKeyModNone
114};
115
116inline SciKeyModifiers &operator|=(SciKeyModifiers &a, SciKeyModifiers b) {
117 return a = static_cast<SciKeyModifiers>((int)a | (int)b);
118}
119
120struct SciEvent {
121 SciEventType type;
122 SciKeyModifiers modifiers;
128 uint16 character;
129
135
136#ifdef ENABLE_SCI32
141 Common::Point mousePosSci;
142
147 int16 hotRectangleIndex;
148#endif
149};
150
152public:
153 EventManager(bool fontIsExtended);
155
156 void updateScreen();
157 SciEvent getSciEvent(SciEventType mask);
158 void flushEvents();
159
160private:
161 SciEvent getScummVMEvent();
162
163 const bool _fontIsExtended;
165#ifdef ENABLE_SCI32
166public:
167 void setHotRectanglesActive(const bool active);
168 void setHotRectangles(const Common::Array<Common::Rect> &rects);
169 void checkHotRectangles(const Common::Point &mousePosition);
170
171private:
172 bool _hotRectanglesActive;
174 int16 _activeRectIndex;
175#endif
176};
177
178} // End of namespace Sci
179
180#endif
Definition: list.h:44
Definition: event.h:151
Definition: console.h:28
Definition: rect.h:144
Definition: event.h:120
uint16 character
Definition: event.h:128
Common::Point mousePos
Definition: event.h:134