ScummVM API documentation
keyboard_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 QDENGINE_SYSTEM_INPUT_KEYBOARD_INPUT_H
23 #define QDENGINE_SYSTEM_INPUT_KEYBOARD_INPUT_H
24 
25 #include "common/keyboard.h"
26 
27 namespace QDEngine {
28 
29 #define VK_LBUTTON 0x01
30 #define VK_RBUTTON 0x02
31 #define VK_CANCEL 0x03
32 #define VK_MBUTTON 0x04 /* NOT contiguous with L & RBUTTON */
33 
34 #define VK_BACK 0x08
35 #define VK_TAB 0x09
36 
37 #define VK_CLEAR 0x0C
38 #define VK_RETURN 0x0D
39 
40 #define VK_SHIFT 0x10
41 #define VK_CONTROL 0x11
42 #define VK_MENU 0x12
43 #define VK_PAUSE 0x13
44 #define VK_CAPITAL 0x14
45 
46 
47 #define VK_ESCAPE 0x1B
48 
49 #define VK_SPACE 0x20
50 #define VK_PRIOR 0x21
51 #define VK_NEXT 0x22
52 #define VK_END 0x23
53 #define VK_HOME 0x24
54 #define VK_LEFT 0x25
55 #define VK_UP 0x26
56 #define VK_RIGHT 0x27
57 #define VK_DOWN 0x28
58 #define VK_SELECT 0x29
59 #define VK_PRINT 0x2A
60 #define VK_EXECUTE 0x2B
61 #define VK_SNAPSHOT 0x2C
62 #define VK_INSERT 0x2D
63 #define VK_DELETE 0x2E
64 #define VK_HELP 0x2F
65 
66 /* VK_0 thru VK_9 are the same as ASCII '0' thru '9' (0x30 - 0x39) */
67 /* VK_A thru VK_Z are the same as ASCII 'A' thru 'Z' (0x41 - 0x5A) */
68 
69 #define VK_LWIN 0x5B
70 #define VK_RWIN 0x5C
71 #define VK_APPS 0x5D
72 
73 #define VK_NUMPAD0 0x60
74 #define VK_NUMPAD1 0x61
75 #define VK_NUMPAD2 0x62
76 #define VK_NUMPAD3 0x63
77 #define VK_NUMPAD4 0x64
78 #define VK_NUMPAD5 0x65
79 #define VK_NUMPAD6 0x66
80 #define VK_NUMPAD7 0x67
81 #define VK_NUMPAD8 0x68
82 #define VK_NUMPAD9 0x69
83 #define VK_MULTIPLY 0x6A
84 #define VK_ADD 0x6B
85 #define VK_SEPARATOR 0x6C
86 #define VK_SUBTRACT 0x6D
87 #define VK_DECIMAL 0x6E
88 #define VK_DIVIDE 0x6F
89 #define VK_F1 0x70
90 #define VK_F2 0x71
91 #define VK_F3 0x72
92 #define VK_F4 0x73
93 #define VK_F5 0x74
94 #define VK_F6 0x75
95 #define VK_F7 0x76
96 #define VK_F8 0x77
97 #define VK_F9 0x78
98 #define VK_F10 0x79
99 #define VK_F11 0x7A
100 #define VK_F12 0x7B
101 #define VK_F13 0x7C
102 #define VK_F14 0x7D
103 #define VK_F15 0x7E
104 #define VK_F16 0x7F
105 #define VK_F17 0x80
106 #define VK_F18 0x81
107 #define VK_F19 0x82
108 #define VK_F20 0x83
109 #define VK_F21 0x84
110 #define VK_F22 0x85
111 #define VK_F23 0x86
112 #define VK_F24 0x87
113 
114 #define VK_NUMLOCK 0x90
115 #define VK_SCROLL 0x91
116 
117 /*
118  * VK_L* & VK_R* - left and right Alt, Ctrl and Shift virtual keys.
119  * Used only as parameters to GetAsyncKeyState() and GetKeyState().
120  * No other API or message will distinguish left and right keys in this way.
121  */
122 #define VK_LSHIFT 0xA0
123 #define VK_RSHIFT 0xA1
124 #define VK_LCONTROL 0xA2
125 #define VK_RCONTROL 0xA3
126 #define VK_LMENU 0xA4
127 #define VK_RMENU 0xA5
128 
129 #define VK_ATTN 0xF6
130 #define VK_CRSEL 0xF7
131 #define VK_EXSEL 0xF8
132 #define VK_EREOF 0xF9
133 #define VK_PLAY 0xFA
134 #define VK_ZOOM 0xFB
135 #define VK_NONAME 0xFC
136 #define VK_PA1 0xFD
137 #define VK_OEM_CLEAR 0xFE
138 
139 
140 // Some additional virtual keycodes...
141 #define VK_OEM_COMMA 0xBC
142 #define VK_OEM_PERIOD 0xBE
143 #define VK_OEM_SCROLL 0x91
144 #define VK_OEM_MINUS 0xBD
145 #define VK_OEM_5_ 0x0C
146 #define VK_OEM_PLUS 0xBB
147 #define VK_OEM_ALT 0x12
148 
149 #define VK_SLASH 0xBF
150 #define VK_BKSLASH 0x5C
151 #define VK_TILDE 0xC0
152 #define VK_LBR 0x5B
153 #define VK_RBR 0x5D
154 
155 
157 public:
159 
162  typedef bool (*event_handler_t)(Common::KeyCode key_vcode, bool event);
163 
166 
168  bool is_pressed(int vkey) const;
169 
172  event_handler_t old_h = _handler;
173  _handler = h;
174  return old_h;
175  }
176 
178  bool handle_event(Common::KeyCode vkey, bool event);
179 
181  static keyboardDispatcher *instance();
182 
183 private:
184 
186  event_handler_t _handler;
187 
189  bool _key_states[Common::KEYCODE_LAST];
190 };
191 
192 } // namespace QDEngine
193 
194 #endif // QDENGINE_SYSTEM_INPUT_KEYBOARD_INPUT_H
event_handler_t set_handler(event_handler_t h)
Устанавливает обработчик нажатий/отжатий кнопок.
Definition: keyboard_input.h:171
Definition: keyboard_input.h:156
bool is_pressed(int vkey) const
Возвращает true, если кнопка с кодом vkey в данный момент нажата.
bool(* event_handler_t)(Common::KeyCode key_vcode, bool event)
Обработчик нажатий/отжатий кнопок.
Definition: keyboard_input.h:162
static keyboardDispatcher * instance()
Возвращает диспетчер по-умолчанию.
Базовый класс для игровых ресурсов.
Definition: console.h:28
bool handle_event(Common::KeyCode vkey, bool event)
Обрабатывает нажатие (event == true) или отжатие (event == false) кнопки с кодом vkey.