OpenTTD Source: src/video/cocoa/cocoa_keys.h Source File

OpenTTD Source 14.0-beta3

cocoa_keys.h
Go to the documentation of this file.
1 /*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6 */
7
10 #ifndef COCOA_KEYS_H
11 #define COCOA_KEYS_H
12
13 /* From SDL_QuartzKeys.h
14 * These are the Macintosh key scancode constants -- from Inside Macintosh */
15
16 #define QZ_ESCAPE 0x35
17 #define QZ_F1 0x7A
18 #define QZ_F2 0x78
19 #define QZ_F3 0x63
20 #define QZ_F4 0x76
21 #define QZ_F5 0x60
22 #define QZ_F6 0x61
23 #define QZ_F7 0x62
24 #define QZ_F8 0x64
25 #define QZ_F9 0x65
26 #define QZ_F10 0x6D
27 #define QZ_F11 0x67
28 #define QZ_F12 0x6F
29 #define QZ_PRINT 0x69
30 #define QZ_SCROLLOCK 0x6B
31 #define QZ_PAUSE 0x71
32 #define QZ_POWER 0x7F
33 #define QZ_BACKQUOTE 0x0A
34 #define QZ_BACKQUOTE2 0x32
35 #define QZ_1 0x12
36 #define QZ_2 0x13
37 #define QZ_3 0x14
38 #define QZ_4 0x15
39 #define QZ_5 0x17
40 #define QZ_6 0x16
41 #define QZ_7 0x1A
42 #define QZ_8 0x1C
43 #define QZ_9 0x19
44 #define QZ_0 0x1D
45 #define QZ_MINUS 0x1B
46 #define QZ_EQUALS 0x18
47 #define QZ_BACKSPACE 0x33
48 #define QZ_INSERT 0x72
49 #define QZ_HOME 0x73
50 #define QZ_PAGEUP 0x74
51 #define QZ_NUMLOCK 0x47
52 #define QZ_KP_EQUALS 0x51
53 #define QZ_KP_DIVIDE 0x4B
54 #define QZ_KP_MULTIPLY 0x43
55 #define QZ_TAB 0x30
56 #define QZ_q 0x0C
57 #define QZ_w 0x0D
58 #define QZ_e 0x0E
59 #define QZ_r 0x0F
60 #define QZ_t 0x11
61 #define QZ_y 0x10
62 #define QZ_u 0x20
63 #define QZ_i 0x22
64 #define QZ_o 0x1F
65 #define QZ_p 0x23
66 #define QZ_LEFTBRACKET 0x21
67 #define QZ_RIGHTBRACKET 0x1E
68 #define QZ_BACKSLASH 0x2A
69 #define QZ_DELETE 0x75
70 #define QZ_END 0x77
71 #define QZ_PAGEDOWN 0x79
72 #define QZ_KP7 0x59
73 #define QZ_KP8 0x5B
74 #define QZ_KP9 0x5C
75 #define QZ_KP_MINUS 0x4E
76 #define QZ_CAPSLOCK 0x39
77 #define QZ_a 0x00
78 #define QZ_s 0x01
79 #define QZ_d 0x02
80 #define QZ_f 0x03
81 #define QZ_g 0x05
82 #define QZ_h 0x04
83 #define QZ_j 0x26
84 #define QZ_k 0x28
85 #define QZ_l 0x25
86 #define QZ_SEMICOLON 0x29
87 #define QZ_QUOTE 0x27
88 #define QZ_RETURN 0x24
89 #define QZ_KP4 0x56
90 #define QZ_KP5 0x57
91 #define QZ_KP6 0x58
92 #define QZ_KP_PLUS 0x45
93 #define QZ_LSHIFT 0x38
94 #define QZ_z 0x06
95 #define QZ_x 0x07
96 #define QZ_c 0x08
97 #define QZ_v 0x09
98 #define QZ_b 0x0B
99 #define QZ_n 0x2D
100 #define QZ_m 0x2E
101 #define QZ_COMMA 0x2B
102 #define QZ_PERIOD 0x2F
103 #define QZ_SLASH 0x2C
104 #if 1 /* Panther now defines right side keys */
105 #define QZ_RSHIFT 0x3C
106 #endif
107 #define QZ_UP 0x7E
108 #define QZ_KP1 0x53
109 #define QZ_KP2 0x54
110 #define QZ_KP3 0x55
111 #define QZ_KP_ENTER 0x4C
112 #define QZ_LCTRL 0x3B
113 #define QZ_LALT 0x3A
114 #define QZ_LMETA 0x37
115 #define QZ_SPACE 0x31
116 #if 1 /* Panther now defines right side keys */
117 #define QZ_RMETA 0x36
118 #define QZ_RALT 0x3D
119 #define QZ_RCTRL 0x3E
120 #endif
121 #define QZ_LEFT 0x7B
122 #define QZ_DOWN 0x7D
123 #define QZ_RIGHT 0x7C
124 #define QZ_KP0 0x52
125 #define QZ_KP_PERIOD 0x41
126
127 /* Weird, these keys are on my iBook under MacOS X */
128 #define QZ_IBOOK_ENTER 0x34
129 #define QZ_IBOOK_LEFT 0x3B
130 #define QZ_IBOOK_RIGHT 0x3C
131 #define QZ_IBOOK_DOWN 0x3D
132 #define QZ_IBOOK_UP 0x3E
133
134
135 struct CocoaVkMapping {
136 unsigned short vk_from;
137 byte map_to;
138 };
139
140 #define AS(x, z) {x, z}
141
142 static const CocoaVkMapping _vk_mapping[] = {
143 AS(QZ_BACKQUOTE, WKC_BACKQUOTE), // key left of '1'
144 AS(QZ_BACKQUOTE2, WKC_BACKQUOTE), // some keyboards have it on another scancode
145
146 /* Pageup stuff + up/down */
147 AS(QZ_PAGEUP, WKC_PAGEUP),
148 AS(QZ_PAGEDOWN, WKC_PAGEDOWN),
149
150 AS(QZ_UP, WKC_UP),
151 AS(QZ_DOWN, WKC_DOWN),
152 AS(QZ_LEFT, WKC_LEFT),
153 AS(QZ_RIGHT, WKC_RIGHT),
154
155 AS(QZ_HOME, WKC_HOME),
156 AS(QZ_END, WKC_END),
157
158 AS(QZ_INSERT, WKC_INSERT),
159 AS(QZ_DELETE, WKC_DELETE),
160
161 /* Letters. QZ_[a-z] is not in numerical order so we can't use AM(...) */
162 AS(QZ_a, 'A'),
163 AS(QZ_b, 'B'),
164 AS(QZ_c, 'C'),
165 AS(QZ_d, 'D'),
166 AS(QZ_e, 'E'),
167 AS(QZ_f, 'F'),
168 AS(QZ_g, 'G'),
169 AS(QZ_h, 'H'),
170 AS(QZ_i, 'I'),
171 AS(QZ_j, 'J'),
172 AS(QZ_k, 'K'),
173 AS(QZ_l, 'L'),
174 AS(QZ_m, 'M'),
175 AS(QZ_n, 'N'),
176 AS(QZ_o, 'O'),
177 AS(QZ_p, 'P'),
178 AS(QZ_q, 'Q'),
179 AS(QZ_r, 'R'),
180 AS(QZ_s, 'S'),
181 AS(QZ_t, 'T'),
182 AS(QZ_u, 'U'),
183 AS(QZ_v, 'V'),
184 AS(QZ_w, 'W'),
185 AS(QZ_x, 'X'),
186 AS(QZ_y, 'Y'),
187 AS(QZ_z, 'Z'),
188 /* Same thing for digits */
189 AS(QZ_0, '0'),
190 AS(QZ_1, '1'),
191 AS(QZ_2, '2'),
192 AS(QZ_3, '3'),
193 AS(QZ_4, '4'),
194 AS(QZ_5, '5'),
195 AS(QZ_6, '6'),
196 AS(QZ_7, '7'),
197 AS(QZ_8, '8'),
198 AS(QZ_9, '9'),
199
200 AS(QZ_ESCAPE, WKC_ESC),
201 AS(QZ_PAUSE, WKC_PAUSE),
202 AS(QZ_BACKSPACE, WKC_BACKSPACE),
203
204 AS(QZ_SPACE, WKC_SPACE),
205 AS(QZ_RETURN, WKC_RETURN),
206 AS(QZ_TAB, WKC_TAB),
207
208 /* Function keys */
209 AS(QZ_F1, WKC_F1),
210 AS(QZ_F2, WKC_F2),
211 AS(QZ_F3, WKC_F3),
212 AS(QZ_F4, WKC_F4),
213 AS(QZ_F5, WKC_F5),
214 AS(QZ_F6, WKC_F6),
215 AS(QZ_F7, WKC_F7),
216 AS(QZ_F8, WKC_F8),
217 AS(QZ_F9, WKC_F9),
218 AS(QZ_F10, WKC_F10),
219 AS(QZ_F11, WKC_F11),
220 AS(QZ_F12, WKC_F12),
221
222 /* Numeric part */
223 AS(QZ_KP0, '0'),
224 AS(QZ_KP1, '1'),
225 AS(QZ_KP2, '2'),
226 AS(QZ_KP3, '3'),
227 AS(QZ_KP4, '4'),
228 AS(QZ_KP5, '5'),
229 AS(QZ_KP6, '6'),
230 AS(QZ_KP7, '7'),
231 AS(QZ_KP8, '8'),
232 AS(QZ_KP9, '9'),
233 AS(QZ_KP_DIVIDE, WKC_NUM_DIV),
234 AS(QZ_KP_MULTIPLY, WKC_NUM_MUL),
235 AS(QZ_KP_MINUS, WKC_NUM_MINUS),
236 AS(QZ_KP_PLUS, WKC_NUM_PLUS),
237 AS(QZ_KP_ENTER, WKC_NUM_ENTER),
238 AS(QZ_KP_PERIOD, WKC_NUM_DECIMAL),
239
240 /* Other non-letter keys */
241 AS(QZ_SLASH, WKC_SLASH),
242 AS(QZ_SEMICOLON, WKC_SEMICOLON),
243 AS(QZ_EQUALS, WKC_EQUALS),
244 AS(QZ_LEFTBRACKET, WKC_L_BRACKET),
245 AS(QZ_BACKSLASH, WKC_BACKSLASH),
246 AS(QZ_RIGHTBRACKET, WKC_R_BRACKET),
247
248 AS(QZ_QUOTE, WKC_SINGLEQUOTE),
249 AS(QZ_COMMA, WKC_COMMA),
250 AS(QZ_MINUS, WKC_MINUS),
251 AS(QZ_PERIOD, WKC_PERIOD)
252 };
253
254 #undef AS
255
256 #endif
WKC_SINGLEQUOTE
@ WKC_SINGLEQUOTE
' Single quote
Definition: gfx_type.h:101
WKC_SLASH
@ WKC_SLASH
/ Forward slash
Definition: gfx_type.h:95
WKC_BACKSLASH
@ WKC_BACKSLASH
\ Backslash
Definition: gfx_type.h:99
CocoaVkMapping
Definition: cocoa_keys.h:135
WKC_L_BRACKET
@ WKC_L_BRACKET
[ Left square bracket
Definition: gfx_type.h:98
AS
#define AS(ap_name, size_x, size_y, min_year, max_year, catchment, noise, maint_cost, ttdpatch_type, class_id, name, preview)
AirportSpec definition for airports with at least one depot.
Definition: airport_defaults.h:393
WKC_EQUALS
@ WKC_EQUALS
= Equals
Definition: gfx_type.h:97
WKC_R_BRACKET
@ WKC_R_BRACKET
] Right square bracket
Definition: gfx_type.h:100
WKC_PERIOD
@ WKC_PERIOD
. Period
Definition: gfx_type.h:103
WKC_COMMA
@ WKC_COMMA
, Comma
Definition: gfx_type.h:102
WKC_SEMICOLON
@ WKC_SEMICOLON
; Semicolon
Definition: gfx_type.h:96
WKC_MINUS
@ WKC_MINUS
Definition: gfx_type.h:104