File: | _build/../src/keymap.cc |
Warning: | line 1022, column 24 Out of bound memory access (accessed memory precedes memory block) |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8; tab-width: 8 -*- */ | |||
2 | /* | |||
3 | * Copyright (C) 2002,2003 Red Hat, Inc. | |||
4 | * | |||
5 | * This library is free software; you can redistribute it and/or | |||
6 | * modify it under the terms of the GNU Lesser General Public | |||
7 | * License as published by the Free Software Foundation; either | |||
8 | * version 2.1 of the License, or (at your option) any later version. | |||
9 | * | |||
10 | * This library is distributed in the hope that it will be useful, | |||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
13 | * Lesser General Public License for more details. | |||
14 | * | |||
15 | * You should have received a copy of the GNU Lesser General Public | |||
16 | * License along with this library; if not, write to the Free Software | |||
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |||
18 | */ | |||
19 | ||||
20 | #include "config.h" | |||
21 | ||||
22 | #include <cassert> | |||
23 | ||||
24 | #include <stdlib.h> | |||
25 | #include <stdarg.h> | |||
26 | #include <string.h> | |||
27 | #include <glib.h> | |||
28 | #include <ctk/ctk.h> | |||
29 | #include "caps.hh" | |||
30 | #include "debug.h" | |||
31 | #include "keymap.h" | |||
32 | ||||
33 | #ifdef BTE_DEBUG | |||
34 | static void | |||
35 | _bte_keysym_print(guint keyval, | |||
36 | guint modifiers) | |||
37 | { | |||
38 | g_printerr("Mapping "); | |||
39 | if (modifiers & CDK_CONTROL_MASK) { | |||
40 | g_printerr("Control+"); | |||
41 | } | |||
42 | if (modifiers & BTE_ALT_MASKCDK_MOD1_MASK) { | |||
43 | g_printerr("Alt+"); | |||
44 | } | |||
45 | if (modifiers & BTE_NUMLOCK_MASKCDK_MOD2_MASK) { | |||
46 | g_printerr("NumLock+"); | |||
47 | } | |||
48 | if (modifiers & CDK_SHIFT_MASK) { | |||
49 | g_printerr("Shift+"); | |||
50 | } | |||
51 | g_printerr("%s" , cdk_keyval_name(keyval)); | |||
52 | } | |||
53 | #else | |||
54 | static void | |||
55 | _bte_keysym_print(guint keyval, | |||
56 | guint modifiers) | |||
57 | { | |||
58 | } | |||
59 | #endif | |||
60 | ||||
61 | enum _bte_cursor_mode { | |||
62 | cursor_default = 1u << 0, | |||
63 | cursor_app = 1u << 1 | |||
64 | }; | |||
65 | ||||
66 | enum _bte_keypad_mode { | |||
67 | keypad_default = 1u << 0, | |||
68 | keypad_app = 1u << 1 | |||
69 | }; | |||
70 | ||||
71 | #define cursor_all(cursor_default | cursor_app) (cursor_default | cursor_app) | |||
72 | #define keypad_all(keypad_default | keypad_app) (keypad_default | keypad_app) | |||
73 | ||||
74 | struct _bte_keymap_entry { | |||
75 | guint cursor_mode; | |||
76 | guint keypad_mode; | |||
77 | guint mod_mask; | |||
78 | const char normal[8]; | |||
79 | int8_t normal_length; | |||
80 | }; | |||
81 | ||||
82 | #define X_NULL"" "" | |||
83 | ||||
84 | enum _bte_modifier_encoding_method { | |||
85 | MODIFIER_ENCODING_NONE, | |||
86 | MODIFIER_ENCODING_SHORT, | |||
87 | MODIFIER_ENCODING_LONG, | |||
88 | }; | |||
89 | ||||
90 | static const struct _bte_keymap_entry _bte_keymap_CDK_space[] = { | |||
91 | /* Control+Alt+space = ESC+NUL */ | |||
92 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), CDK_CONTROL_MASK | BTE_ALT_MASKCDK_MOD1_MASK, _BTE_CAP_ESC"\033" "\0", 2}, | |||
93 | /* Alt+space = ESC+" " */ | |||
94 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), BTE_ALT_MASKCDK_MOD1_MASK, _BTE_CAP_ESC"\033" " ", 2}, | |||
95 | /* Control+space = NUL */ | |||
96 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), CDK_CONTROL_MASK, "\0", 1}, | |||
97 | /* Regular space. */ | |||
98 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, " ", 1}, | |||
99 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
100 | }; | |||
101 | ||||
102 | static const struct _bte_keymap_entry _bte_keymap_CDK_Tab[] = { | |||
103 | /* Shift+Tab = Back-Tab */ | |||
104 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), CDK_SHIFT_MASK, _BTE_CAP_CSI"\033" "[" "Z", -1}, | |||
105 | /* Alt+Tab = Esc+Tab */ | |||
106 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), BTE_ALT_MASKCDK_MOD1_MASK, _BTE_CAP_ESC"\033" "\t", -1}, | |||
107 | /* Regular tab. */ | |||
108 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, "\t", 1}, | |||
109 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
110 | }; | |||
111 | ||||
112 | static const struct _bte_keymap_entry _bte_keymap_CDK_Return[] = { | |||
113 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), BTE_ALT_MASKCDK_MOD1_MASK, _BTE_CAP_ESC"\033" "\r", 2}, | |||
114 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, "\r", 1}, | |||
115 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
116 | }; | |||
117 | ||||
118 | static const struct _bte_keymap_entry _bte_keymap_CDK_Escape[] = { | |||
119 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), BTE_ALT_MASKCDK_MOD1_MASK, _BTE_CAP_ESC"\033" _BTE_CAP_ESC"\033", 2}, | |||
120 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_ESC"\033", 1}, | |||
121 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
122 | }; | |||
123 | ||||
124 | static const struct _bte_keymap_entry _bte_keymap_CDK_Insert[] = { | |||
125 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_CSI"\033" "[" "2~", -1}, | |||
126 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
127 | }; | |||
128 | ||||
129 | static const struct _bte_keymap_entry _bte_keymap_CDK_ISO_Left_Tab[] = { | |||
130 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_CSI"\033" "[" "Z", -1}, | |||
131 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
132 | }; | |||
133 | ||||
134 | static const struct _bte_keymap_entry _bte_keymap_CDK_slash[] = { | |||
135 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), BTE_ALT_MASKCDK_MOD1_MASK, _BTE_CAP_ESC"\033" "/", 2}, | |||
136 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), CDK_CONTROL_MASK, "\037", 1}, | |||
137 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, "/", 1}, | |||
138 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
139 | }; | |||
140 | ||||
141 | static const struct _bte_keymap_entry _bte_keymap_CDK_question[] = { | |||
142 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), BTE_ALT_MASKCDK_MOD1_MASK, _BTE_CAP_ESC"\033" "?", 2}, | |||
143 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), CDK_CONTROL_MASK, "\177", 1}, | |||
144 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, "?", 1}, | |||
145 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
146 | }; | |||
147 | ||||
148 | /* Various numeric keys enter control characters. */ | |||
149 | static const struct _bte_keymap_entry _bte_keymap_CDK_2[] = { | |||
150 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), CDK_CONTROL_MASK, "\0", 1}, | |||
151 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
152 | }; | |||
153 | static const struct _bte_keymap_entry _bte_keymap_CDK_3[] = { | |||
154 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), CDK_CONTROL_MASK, "\033", 1}, | |||
155 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
156 | }; | |||
157 | static const struct _bte_keymap_entry _bte_keymap_CDK_4[] = { | |||
158 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), CDK_CONTROL_MASK, "\034", 1}, | |||
159 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
160 | }; | |||
161 | static const struct _bte_keymap_entry _bte_keymap_CDK_5[] = { | |||
162 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), CDK_CONTROL_MASK, "\035", 1}, | |||
163 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
164 | }; | |||
165 | static const struct _bte_keymap_entry _bte_keymap_CDK_6[] = { | |||
166 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), CDK_CONTROL_MASK, "\036", 1}, | |||
167 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
168 | }; | |||
169 | static const struct _bte_keymap_entry _bte_keymap_CDK_7[] = { | |||
170 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), CDK_CONTROL_MASK, "\037", 1}, | |||
171 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
172 | }; | |||
173 | static const struct _bte_keymap_entry _bte_keymap_CDK_8[] = { | |||
174 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), CDK_CONTROL_MASK, "\177", 1}, | |||
175 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
176 | }; | |||
177 | static const struct _bte_keymap_entry _bte_keymap_CDK_Minus[] = { | |||
178 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), CDK_CONTROL_MASK, "\037", 1}, | |||
179 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
180 | }; | |||
181 | ||||
182 | /* Keys (potentially) affected by the cursor key mode. */ | |||
183 | static const struct _bte_keymap_entry _bte_keymap_CDK_Home[] = { | |||
184 | {cursor_default, keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_CSI"\033" "[" "H", -1}, | |||
185 | {cursor_app, keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_SS3"\033" "O" "H", -1}, | |||
186 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
187 | }; | |||
188 | ||||
189 | static const struct _bte_keymap_entry _bte_keymap_CDK_End[] = { | |||
190 | {cursor_default, keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_CSI"\033" "[" "F", -1}, | |||
191 | {cursor_app, keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_SS3"\033" "O" "F", -1}, | |||
192 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
193 | }; | |||
194 | ||||
195 | static const struct _bte_keymap_entry _bte_keymap_CDK_Page_Up[] = { | |||
196 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_CSI"\033" "[" "5~", -1}, | |||
197 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
198 | }; | |||
199 | ||||
200 | static const struct _bte_keymap_entry _bte_keymap_CDK_Page_Down[] = { | |||
201 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_CSI"\033" "[" "6~", -1}, | |||
202 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
203 | }; | |||
204 | ||||
205 | static const struct _bte_keymap_entry _bte_keymap_CDK_Up[] = { | |||
206 | {cursor_default, keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_CSI"\033" "[" "A", -1}, | |||
207 | {cursor_app, keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_SS3"\033" "O" "A", -1}, | |||
208 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
209 | }; | |||
210 | ||||
211 | static const struct _bte_keymap_entry _bte_keymap_CDK_Down[] = { | |||
212 | {cursor_default, keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_CSI"\033" "[" "B", -1}, | |||
213 | {cursor_app, keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_SS3"\033" "O" "B", -1}, | |||
214 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
215 | }; | |||
216 | ||||
217 | static const struct _bte_keymap_entry _bte_keymap_CDK_Right[] = { | |||
218 | {cursor_default, keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_CSI"\033" "[" "C", -1}, | |||
219 | {cursor_app, keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_SS3"\033" "O" "C", -1}, | |||
220 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
221 | }; | |||
222 | ||||
223 | static const struct _bte_keymap_entry _bte_keymap_CDK_Left[] = { | |||
224 | {cursor_default, keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_CSI"\033" "[" "D", -1}, | |||
225 | {cursor_app, keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_SS3"\033" "O" "D", -1}, | |||
226 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
227 | }; | |||
228 | ||||
229 | /* Keys (potentially) affected by the keypad key mode. */ | |||
230 | static const struct _bte_keymap_entry _bte_keymap_CDK_KP_Space[] = { | |||
231 | {cursor_all(cursor_default | cursor_app), keypad_default, 0, " ", 1}, | |||
232 | {cursor_all(cursor_default | cursor_app), keypad_app, 0, _BTE_CAP_SS3"\033" "O" " ", -1}, | |||
233 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
234 | }; | |||
235 | ||||
236 | static const struct _bte_keymap_entry _bte_keymap_CDK_KP_Tab[] = { | |||
237 | {cursor_all(cursor_default | cursor_app), keypad_default, 0, "\t", 1}, | |||
238 | {cursor_all(cursor_default | cursor_app), keypad_app, 0, _BTE_CAP_SS3"\033" "O" "I", -1}, | |||
239 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
240 | }; | |||
241 | ||||
242 | static const struct _bte_keymap_entry _bte_keymap_CDK_KP_Enter[] = { | |||
243 | {cursor_all(cursor_default | cursor_app), keypad_app, BTE_NUMLOCK_MASKCDK_MOD2_MASK, "\r", 1}, | |||
244 | {cursor_all(cursor_default | cursor_app), keypad_app, 0, _BTE_CAP_SS3"\033" "O" "M", -1}, | |||
245 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, "\r", 1}, | |||
246 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
247 | }; | |||
248 | ||||
249 | static const struct _bte_keymap_entry _bte_keymap_CDK_KP_F1[] = { | |||
250 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_SS3"\033" "O" "P", -1}, | |||
251 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
252 | }; | |||
253 | ||||
254 | static const struct _bte_keymap_entry _bte_keymap_CDK_KP_F2[] = { | |||
255 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_SS3"\033" "O" "Q", -1}, | |||
256 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
257 | }; | |||
258 | ||||
259 | static const struct _bte_keymap_entry _bte_keymap_CDK_KP_F3[] = { | |||
260 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_SS3"\033" "O" "R", -1}, | |||
261 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
262 | }; | |||
263 | ||||
264 | static const struct _bte_keymap_entry _bte_keymap_CDK_KP_F4[] = { | |||
265 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_SS3"\033" "O" "S", -1}, | |||
266 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
267 | }; | |||
268 | ||||
269 | static const struct _bte_keymap_entry _bte_keymap_CDK_KP_Multiply[] = { | |||
270 | {cursor_all(cursor_default | cursor_app), keypad_default, 0, "*", 1}, | |||
271 | {cursor_all(cursor_default | cursor_app), keypad_app, BTE_NUMLOCK_MASKCDK_MOD2_MASK, "*", 1}, | |||
272 | {cursor_all(cursor_default | cursor_app), keypad_app, 0, _BTE_CAP_SS3"\033" "O" "j", -1}, | |||
273 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
274 | }; | |||
275 | ||||
276 | static const struct _bte_keymap_entry _bte_keymap_CDK_KP_Add[] = { | |||
277 | {cursor_all(cursor_default | cursor_app), keypad_default, 0, "+", 1}, | |||
278 | {cursor_all(cursor_default | cursor_app), keypad_app, BTE_NUMLOCK_MASKCDK_MOD2_MASK, "+", 1}, | |||
279 | {cursor_all(cursor_default | cursor_app), keypad_app, 0, _BTE_CAP_SS3"\033" "O" "k", -1}, | |||
280 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
281 | }; | |||
282 | ||||
283 | static const struct _bte_keymap_entry _bte_keymap_CDK_KP_Separator[] = { | |||
284 | {cursor_all(cursor_default | cursor_app), keypad_default, 0, ",", 1}, | |||
285 | {cursor_all(cursor_default | cursor_app), keypad_app, 0, _BTE_CAP_SS3"\033" "O" "l", -1}, | |||
286 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
287 | }; | |||
288 | ||||
289 | static const struct _bte_keymap_entry _bte_keymap_CDK_KP_Subtract[] = { | |||
290 | {cursor_all(cursor_default | cursor_app), keypad_default, 0, "-", 1}, | |||
291 | {cursor_all(cursor_default | cursor_app), keypad_app, BTE_NUMLOCK_MASKCDK_MOD2_MASK, "-", 1}, | |||
292 | {cursor_all(cursor_default | cursor_app), keypad_app, 0, _BTE_CAP_SS3"\033" "O" "m", -1}, | |||
293 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
294 | }; | |||
295 | ||||
296 | static const struct _bte_keymap_entry _bte_keymap_CDK_KP_Decimal_Delete[] = { | |||
297 | {cursor_all(cursor_default | cursor_app), keypad_default, 0, ".", 1}, | |||
298 | {cursor_all(cursor_default | cursor_app), keypad_app, 0, _BTE_CAP_SS3"\033" "O" "3~", -1}, | |||
299 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
300 | }; | |||
301 | ||||
302 | static const struct _bte_keymap_entry _bte_keymap_CDK_KP_Divide[] = { | |||
303 | {cursor_all(cursor_default | cursor_app), keypad_default, 0, "/", 1}, | |||
304 | {cursor_all(cursor_default | cursor_app), keypad_app, BTE_NUMLOCK_MASKCDK_MOD2_MASK, "/", 1}, | |||
305 | {cursor_all(cursor_default | cursor_app), keypad_app, 0, _BTE_CAP_SS3"\033" "O" "o", -1}, | |||
306 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
307 | }; | |||
308 | ||||
309 | /* CDK already separates keypad "0" from keypad "Insert", so the only time | |||
310 | * we'll see this key is when NumLock is on. */ | |||
311 | static const struct _bte_keymap_entry _bte_keymap_CDK_KP_0[] = { | |||
312 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, "0", 1}, | |||
313 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
314 | }; | |||
315 | ||||
316 | static const struct _bte_keymap_entry _bte_keymap_CDK_KP_1[] = { | |||
317 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, "1", 1}, | |||
318 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
319 | }; | |||
320 | ||||
321 | static const struct _bte_keymap_entry _bte_keymap_CDK_KP_2[] = { | |||
322 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, "2", 1}, | |||
323 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
324 | }; | |||
325 | ||||
326 | static const struct _bte_keymap_entry _bte_keymap_CDK_KP_3[] = { | |||
327 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, "3", 1}, | |||
328 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
329 | }; | |||
330 | ||||
331 | static const struct _bte_keymap_entry _bte_keymap_CDK_KP_4[] = { | |||
332 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, "4", 1}, | |||
333 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
334 | }; | |||
335 | ||||
336 | static const struct _bte_keymap_entry _bte_keymap_CDK_KP_5[] = { | |||
337 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, "5", 1}, | |||
338 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
339 | }; | |||
340 | ||||
341 | static const struct _bte_keymap_entry _bte_keymap_CDK_KP_6[] = { | |||
342 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, "6", 1}, | |||
343 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
344 | }; | |||
345 | ||||
346 | static const struct _bte_keymap_entry _bte_keymap_CDK_KP_7[] = { | |||
347 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, "7", 1}, | |||
348 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
349 | }; | |||
350 | ||||
351 | static const struct _bte_keymap_entry _bte_keymap_CDK_KP_8[] = { | |||
352 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, "8", 1}, | |||
353 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
354 | }; | |||
355 | ||||
356 | static const struct _bte_keymap_entry _bte_keymap_CDK_KP_9[] = { | |||
357 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, "9", 1}, | |||
358 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
359 | }; | |||
360 | ||||
361 | /* These are the same keys as above, but without numlock. */ | |||
362 | static const struct _bte_keymap_entry _bte_keymap_CDK_KP_Insert[] = { | |||
363 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_CSI"\033" "[" "2~", -1}, | |||
364 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
365 | }; | |||
366 | ||||
367 | static const struct _bte_keymap_entry _bte_keymap_CDK_KP_End[] = { | |||
368 | {cursor_app, keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_SS3"\033" "O" "F", -1}, | |||
369 | {cursor_default, keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_CSI"\033" "[" "F", -1}, | |||
370 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
371 | }; | |||
372 | ||||
373 | static const struct _bte_keymap_entry _bte_keymap_CDK_KP_Down[] = { | |||
374 | {cursor_app, keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_SS3"\033" "O" "B", -1}, | |||
375 | {cursor_default, keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_CSI"\033" "[" "B", -1}, | |||
376 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
377 | }; | |||
378 | ||||
379 | static const struct _bte_keymap_entry _bte_keymap_CDK_KP_Page_Down[] = { | |||
380 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_CSI"\033" "[" "6~", -1}, | |||
381 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
382 | }; | |||
383 | ||||
384 | static const struct _bte_keymap_entry _bte_keymap_CDK_KP_Left[] = { | |||
385 | {cursor_app, keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_SS3"\033" "O" "D", -1}, | |||
386 | {cursor_default, keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_CSI"\033" "[" "D", -1}, | |||
387 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
388 | }; | |||
389 | ||||
390 | static const struct _bte_keymap_entry _bte_keymap_CDK_KP_Begin[] = { | |||
391 | {cursor_app, keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_SS3"\033" "O" "E", -1}, | |||
392 | {cursor_default, keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_CSI"\033" "[" "E", -1}, | |||
393 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
394 | }; | |||
395 | ||||
396 | static const struct _bte_keymap_entry _bte_keymap_CDK_KP_Right[] = { | |||
397 | {cursor_app, keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_SS3"\033" "O" "C", -1}, | |||
398 | {cursor_default, keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_CSI"\033" "[" "C", -1}, | |||
399 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
400 | }; | |||
401 | ||||
402 | static const struct _bte_keymap_entry _bte_keymap_CDK_KP_Home[] = { | |||
403 | {cursor_app, keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_SS3"\033" "O" "H", -1}, | |||
404 | {cursor_default, keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_CSI"\033" "[" "H", -1}, | |||
405 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
406 | }; | |||
407 | ||||
408 | static const struct _bte_keymap_entry _bte_keymap_CDK_KP_Up[] = { | |||
409 | {cursor_app, keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_SS3"\033" "O" "A", -1}, | |||
410 | {cursor_default, keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_CSI"\033" "[" "A", -1}, | |||
411 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
412 | }; | |||
413 | ||||
414 | static const struct _bte_keymap_entry _bte_keymap_CDK_KP_Page_Up[] = { | |||
415 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_CSI"\033" "[" "5~", -1}, | |||
416 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
417 | }; | |||
418 | ||||
419 | static const struct _bte_keymap_entry _bte_keymap_CDK_F1[] = { | |||
420 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), CDK_CONTROL_MASK, _BTE_CAP_CSI"\033" "[" "P", -1}, | |||
421 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), CDK_SHIFT_MASK, _BTE_CAP_CSI"\033" "[" "P", -1}, | |||
422 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), BTE_ALT_MASKCDK_MOD1_MASK, _BTE_CAP_CSI"\033" "[" "P", -1}, | |||
423 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_SS3"\033" "O" "P", -1}, | |||
424 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
425 | }; | |||
426 | ||||
427 | static const struct _bte_keymap_entry _bte_keymap_CDK_F2[] = { | |||
428 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), CDK_CONTROL_MASK, _BTE_CAP_CSI"\033" "[" "Q", -1}, | |||
429 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), CDK_SHIFT_MASK, _BTE_CAP_CSI"\033" "[" "Q", -1}, | |||
430 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), BTE_ALT_MASKCDK_MOD1_MASK, _BTE_CAP_CSI"\033" "[" "Q", -1}, | |||
431 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_SS3"\033" "O" "Q", -1}, | |||
432 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
433 | }; | |||
434 | ||||
435 | static const struct _bte_keymap_entry _bte_keymap_CDK_F3[] = { | |||
436 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), CDK_CONTROL_MASK, _BTE_CAP_CSI"\033" "[" "R", -1}, | |||
437 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), CDK_SHIFT_MASK, _BTE_CAP_CSI"\033" "[" "R", -1}, | |||
438 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), BTE_ALT_MASKCDK_MOD1_MASK, _BTE_CAP_CSI"\033" "[" "R", -1}, | |||
439 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_SS3"\033" "O" "R", -1}, | |||
440 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
441 | }; | |||
442 | ||||
443 | static const struct _bte_keymap_entry _bte_keymap_CDK_F4[] = { | |||
444 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), CDK_CONTROL_MASK, _BTE_CAP_CSI"\033" "[" "S", -1}, | |||
445 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), CDK_SHIFT_MASK, _BTE_CAP_CSI"\033" "[" "S", -1}, | |||
446 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), BTE_ALT_MASKCDK_MOD1_MASK, _BTE_CAP_CSI"\033" "[" "S", -1}, | |||
447 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_SS3"\033" "O" "S", -1}, | |||
448 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
449 | }; | |||
450 | ||||
451 | static const struct _bte_keymap_entry _bte_keymap_CDK_F5[] = { | |||
452 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_CSI"\033" "[" "15~", -1}, | |||
453 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
454 | }; | |||
455 | ||||
456 | static const struct _bte_keymap_entry _bte_keymap_CDK_F6[] = { | |||
457 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_CSI"\033" "[" "17~", -1}, | |||
458 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
459 | }; | |||
460 | ||||
461 | static const struct _bte_keymap_entry _bte_keymap_CDK_F7[] = { | |||
462 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_CSI"\033" "[" "18~", -1}, | |||
463 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
464 | }; | |||
465 | ||||
466 | static const struct _bte_keymap_entry _bte_keymap_CDK_F8[] = { | |||
467 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_CSI"\033" "[" "19~", -1}, | |||
468 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
469 | }; | |||
470 | ||||
471 | static const struct _bte_keymap_entry _bte_keymap_CDK_F9[] = { | |||
472 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_CSI"\033" "[" "20~", -1}, | |||
473 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
474 | }; | |||
475 | ||||
476 | static const struct _bte_keymap_entry _bte_keymap_CDK_F10[] = { | |||
477 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_CSI"\033" "[" "21~", -1}, | |||
478 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
479 | }; | |||
480 | ||||
481 | static const struct _bte_keymap_entry _bte_keymap_CDK_F11[] = { | |||
482 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_CSI"\033" "[" "23~", -1}, | |||
483 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
484 | }; | |||
485 | ||||
486 | static const struct _bte_keymap_entry _bte_keymap_CDK_F12[] = { | |||
487 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_CSI"\033" "[" "24~", -1}, | |||
488 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
489 | }; | |||
490 | ||||
491 | static const struct _bte_keymap_entry _bte_keymap_CDK_F13[] = { | |||
492 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_CSI"\033" "[" "25~", -1}, | |||
493 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
494 | }; | |||
495 | ||||
496 | static const struct _bte_keymap_entry _bte_keymap_CDK_F14[] = { | |||
497 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_CSI"\033" "[" "26~", -1}, | |||
498 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
499 | }; | |||
500 | ||||
501 | static const struct _bte_keymap_entry _bte_keymap_CDK_F15[] = { | |||
502 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_CSI"\033" "[" "28~", -1}, | |||
503 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
504 | }; | |||
505 | ||||
506 | static const struct _bte_keymap_entry _bte_keymap_CDK_F16[] = { | |||
507 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_CSI"\033" "[" "29~", -1}, | |||
508 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
509 | }; | |||
510 | ||||
511 | static const struct _bte_keymap_entry _bte_keymap_CDK_F17[] = { | |||
512 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_CSI"\033" "[" "31~", -1}, | |||
513 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
514 | }; | |||
515 | ||||
516 | static const struct _bte_keymap_entry _bte_keymap_CDK_F18[] = { | |||
517 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_CSI"\033" "[" "32~", -1}, | |||
518 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
519 | }; | |||
520 | ||||
521 | static const struct _bte_keymap_entry _bte_keymap_CDK_F19[] = { | |||
522 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_CSI"\033" "[" "33~", -1}, | |||
523 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
524 | }; | |||
525 | ||||
526 | static const struct _bte_keymap_entry _bte_keymap_CDK_F20[] = { | |||
527 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_CSI"\033" "[" "34~", -1}, | |||
528 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
529 | }; | |||
530 | ||||
531 | static const struct _bte_keymap_entry _bte_keymap_CDK_F21[] = { | |||
532 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_CSI"\033" "[" "42~", -1}, | |||
533 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
534 | }; | |||
535 | ||||
536 | static const struct _bte_keymap_entry _bte_keymap_CDK_F22[] = { | |||
537 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_CSI"\033" "[" "43~", -1}, | |||
538 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
539 | }; | |||
540 | ||||
541 | static const struct _bte_keymap_entry _bte_keymap_CDK_F23[] = { | |||
542 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_CSI"\033" "[" "44~", -1}, | |||
543 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
544 | }; | |||
545 | ||||
546 | static const struct _bte_keymap_entry _bte_keymap_CDK_F24[] = { | |||
547 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_CSI"\033" "[" "45~", -1}, | |||
548 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
549 | }; | |||
550 | ||||
551 | static const struct _bte_keymap_entry _bte_keymap_CDK_F25[] = { | |||
552 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_CSI"\033" "[" "46~", -1}, | |||
553 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
554 | }; | |||
555 | ||||
556 | static const struct _bte_keymap_entry _bte_keymap_CDK_F26[] = { | |||
557 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_CSI"\033" "[" "47~", -1}, | |||
558 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
559 | }; | |||
560 | ||||
561 | static const struct _bte_keymap_entry _bte_keymap_CDK_F27[] = { | |||
562 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_CSI"\033" "[" "48~", -1}, | |||
563 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
564 | }; | |||
565 | ||||
566 | static const struct _bte_keymap_entry _bte_keymap_CDK_F28[] = { | |||
567 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_CSI"\033" "[" "49~", -1}, | |||
568 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
569 | }; | |||
570 | ||||
571 | static const struct _bte_keymap_entry _bte_keymap_CDK_F29[] = { | |||
572 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_CSI"\033" "[" "50~", -1}, | |||
573 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
574 | }; | |||
575 | ||||
576 | static const struct _bte_keymap_entry _bte_keymap_CDK_F30[] = { | |||
577 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_CSI"\033" "[" "51~", -1}, | |||
578 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
579 | }; | |||
580 | ||||
581 | static const struct _bte_keymap_entry _bte_keymap_CDK_F31[] = { | |||
582 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_CSI"\033" "[" "52~", -1}, | |||
583 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
584 | }; | |||
585 | ||||
586 | static const struct _bte_keymap_entry _bte_keymap_CDK_F32[] = { | |||
587 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_CSI"\033" "[" "53~", -1}, | |||
588 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
589 | }; | |||
590 | ||||
591 | static const struct _bte_keymap_entry _bte_keymap_CDK_F33[] = { | |||
592 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_CSI"\033" "[" "54~", -1}, | |||
593 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
594 | }; | |||
595 | ||||
596 | static const struct _bte_keymap_entry _bte_keymap_CDK_F34[] = { | |||
597 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_CSI"\033" "[" "55~", -1}, | |||
598 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
599 | }; | |||
600 | ||||
601 | static const struct _bte_keymap_entry _bte_keymap_CDK_F35[] = { | |||
602 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, _BTE_CAP_CSI"\033" "[" "56~", -1}, | |||
603 | {cursor_all(cursor_default | cursor_app), keypad_all(keypad_default | keypad_app), 0, X_NULL"", 0}, | |||
604 | }; | |||
605 | ||||
606 | static const struct _bte_keymap_group { | |||
607 | guint keyval; | |||
608 | const struct _bte_keymap_entry *entries; | |||
609 | } _bte_keymap[] = { | |||
610 | {CDK_KEY_space0x020, _bte_keymap_CDK_space}, | |||
611 | {CDK_KEY_Return0xff0d, _bte_keymap_CDK_Return}, | |||
612 | {CDK_KEY_Escape0xff1b, _bte_keymap_CDK_Escape}, | |||
613 | {CDK_KEY_Tab0xff09, _bte_keymap_CDK_Tab}, | |||
614 | {CDK_KEY_ISO_Left_Tab0xfe20, _bte_keymap_CDK_ISO_Left_Tab}, | |||
615 | {CDK_KEY_Home0xff50, _bte_keymap_CDK_Home}, | |||
616 | {CDK_KEY_End0xff57, _bte_keymap_CDK_End}, | |||
617 | {CDK_KEY_Insert0xff63, _bte_keymap_CDK_Insert}, | |||
618 | {CDK_KEY_slash0x02f, _bte_keymap_CDK_slash}, | |||
619 | {CDK_KEY_question0x03f, _bte_keymap_CDK_question}, | |||
620 | /* CDK_Delete is all handled in code, due to funkiness. */ | |||
621 | {CDK_KEY_Page_Up0xff55, _bte_keymap_CDK_Page_Up}, | |||
622 | {CDK_KEY_Page_Down0xff56, _bte_keymap_CDK_Page_Down}, | |||
623 | ||||
624 | {CDK_KEY_20x032, _bte_keymap_CDK_2}, | |||
625 | {CDK_KEY_30x033, _bte_keymap_CDK_3}, | |||
626 | {CDK_KEY_40x034, _bte_keymap_CDK_4}, | |||
627 | {CDK_KEY_50x035, _bte_keymap_CDK_5}, | |||
628 | {CDK_KEY_60x036, _bte_keymap_CDK_6}, | |||
629 | {CDK_KEY_70x037, _bte_keymap_CDK_7}, | |||
630 | {CDK_KEY_80x038, _bte_keymap_CDK_8}, | |||
631 | {CDK_KEY_minus0x02d, _bte_keymap_CDK_Minus}, | |||
632 | ||||
633 | {CDK_KEY_Up0xff52, _bte_keymap_CDK_Up}, | |||
634 | {CDK_KEY_Down0xff54, _bte_keymap_CDK_Down}, | |||
635 | {CDK_KEY_Right0xff53, _bte_keymap_CDK_Right}, | |||
636 | {CDK_KEY_Left0xff51, _bte_keymap_CDK_Left}, | |||
637 | ||||
638 | {CDK_KEY_KP_Space0xff80, _bte_keymap_CDK_KP_Space}, | |||
639 | {CDK_KEY_KP_Tab0xff89, _bte_keymap_CDK_KP_Tab}, | |||
640 | {CDK_KEY_KP_Enter0xff8d, _bte_keymap_CDK_KP_Enter}, | |||
641 | {CDK_KEY_KP_F10xff91, _bte_keymap_CDK_KP_F1}, | |||
642 | {CDK_KEY_KP_F20xff92, _bte_keymap_CDK_KP_F2}, | |||
643 | {CDK_KEY_KP_F30xff93, _bte_keymap_CDK_KP_F3}, | |||
644 | {CDK_KEY_KP_F40xff94, _bte_keymap_CDK_KP_F4}, | |||
645 | {CDK_KEY_KP_Multiply0xffaa, _bte_keymap_CDK_KP_Multiply}, | |||
646 | {CDK_KEY_KP_Add0xffab, _bte_keymap_CDK_KP_Add}, | |||
647 | {CDK_KEY_KP_Separator0xffac, _bte_keymap_CDK_KP_Separator}, | |||
648 | {CDK_KEY_KP_Subtract0xffad, _bte_keymap_CDK_KP_Subtract}, | |||
649 | {CDK_KEY_KP_Decimal0xffae, _bte_keymap_CDK_KP_Decimal_Delete}, | |||
650 | {CDK_KEY_KP_Delete0xff9f, _bte_keymap_CDK_KP_Decimal_Delete}, | |||
651 | {CDK_KEY_KP_Divide0xffaf, _bte_keymap_CDK_KP_Divide}, | |||
652 | {CDK_KEY_KP_00xffb0, _bte_keymap_CDK_KP_0}, | |||
653 | {CDK_KEY_KP_Insert0xff9e, _bte_keymap_CDK_KP_Insert}, | |||
654 | {CDK_KEY_KP_10xffb1, _bte_keymap_CDK_KP_1}, | |||
655 | {CDK_KEY_KP_End0xff9c, _bte_keymap_CDK_KP_End}, | |||
656 | {CDK_KEY_KP_20xffb2, _bte_keymap_CDK_KP_2}, | |||
657 | {CDK_KEY_KP_Down0xff99, _bte_keymap_CDK_KP_Down}, | |||
658 | {CDK_KEY_KP_30xffb3, _bte_keymap_CDK_KP_3}, | |||
659 | {CDK_KEY_KP_Page_Down0xff9b, _bte_keymap_CDK_KP_Page_Down}, | |||
660 | {CDK_KEY_KP_40xffb4, _bte_keymap_CDK_KP_4}, | |||
661 | {CDK_KEY_KP_Left0xff96, _bte_keymap_CDK_KP_Left}, | |||
662 | {CDK_KEY_KP_50xffb5, _bte_keymap_CDK_KP_5}, | |||
663 | {CDK_KEY_KP_Begin0xff9d, _bte_keymap_CDK_KP_Begin}, | |||
664 | {CDK_KEY_KP_60xffb6, _bte_keymap_CDK_KP_6}, | |||
665 | {CDK_KEY_KP_Right0xff98, _bte_keymap_CDK_KP_Right}, | |||
666 | {CDK_KEY_KP_70xffb7, _bte_keymap_CDK_KP_7}, | |||
667 | {CDK_KEY_KP_Home0xff95, _bte_keymap_CDK_KP_Home}, | |||
668 | {CDK_KEY_KP_80xffb8, _bte_keymap_CDK_KP_8}, | |||
669 | {CDK_KEY_KP_Up0xff97, _bte_keymap_CDK_KP_Up}, | |||
670 | {CDK_KEY_KP_90xffb9, _bte_keymap_CDK_KP_9}, | |||
671 | {CDK_KEY_KP_Page_Up0xff9a, _bte_keymap_CDK_KP_Page_Up}, | |||
672 | ||||
673 | {CDK_KEY_F10xffbe, _bte_keymap_CDK_F1}, | |||
674 | {CDK_KEY_F20xffbf, _bte_keymap_CDK_F2}, | |||
675 | {CDK_KEY_F30xffc0, _bte_keymap_CDK_F3}, | |||
676 | {CDK_KEY_F40xffc1, _bte_keymap_CDK_F4}, | |||
677 | {CDK_KEY_F50xffc2, _bte_keymap_CDK_F5}, | |||
678 | {CDK_KEY_F60xffc3, _bte_keymap_CDK_F6}, | |||
679 | {CDK_KEY_F70xffc4, _bte_keymap_CDK_F7}, | |||
680 | {CDK_KEY_F80xffc5, _bte_keymap_CDK_F8}, | |||
681 | {CDK_KEY_F90xffc6, _bte_keymap_CDK_F9}, | |||
682 | {CDK_KEY_F100xffc7, _bte_keymap_CDK_F10}, | |||
683 | {CDK_KEY_F110xffc8, _bte_keymap_CDK_F11}, | |||
684 | {CDK_KEY_F120xffc9, _bte_keymap_CDK_F12}, | |||
685 | {CDK_KEY_F130xffca, _bte_keymap_CDK_F13}, | |||
686 | {CDK_KEY_F140xffcb, _bte_keymap_CDK_F14}, | |||
687 | {CDK_KEY_F150xffcc, _bte_keymap_CDK_F15}, | |||
688 | {CDK_KEY_F160xffcd, _bte_keymap_CDK_F16}, | |||
689 | {CDK_KEY_F170xffce, _bte_keymap_CDK_F17}, | |||
690 | {CDK_KEY_F180xffcf, _bte_keymap_CDK_F18}, | |||
691 | {CDK_KEY_F190xffd0, _bte_keymap_CDK_F19}, | |||
692 | {CDK_KEY_F200xffd1, _bte_keymap_CDK_F20}, | |||
693 | {CDK_KEY_F210xffd2, _bte_keymap_CDK_F21}, | |||
694 | {CDK_KEY_F220xffd3, _bte_keymap_CDK_F22}, | |||
695 | {CDK_KEY_F230xffd4, _bte_keymap_CDK_F23}, | |||
696 | {CDK_KEY_F240xffd5, _bte_keymap_CDK_F24}, | |||
697 | {CDK_KEY_F250xffd6, _bte_keymap_CDK_F25}, | |||
698 | {CDK_KEY_F260xffd7, _bte_keymap_CDK_F26}, | |||
699 | {CDK_KEY_F270xffd8, _bte_keymap_CDK_F27}, | |||
700 | {CDK_KEY_F280xffd9, _bte_keymap_CDK_F28}, | |||
701 | {CDK_KEY_F290xffda, _bte_keymap_CDK_F29}, | |||
702 | {CDK_KEY_F300xffdb, _bte_keymap_CDK_F30}, | |||
703 | {CDK_KEY_F310xffdc, _bte_keymap_CDK_F31}, | |||
704 | {CDK_KEY_F320xffdd, _bte_keymap_CDK_F32}, | |||
705 | {CDK_KEY_F330xffde, _bte_keymap_CDK_F33}, | |||
706 | {CDK_KEY_F340xffdf, _bte_keymap_CDK_F34}, | |||
707 | {CDK_KEY_F350xffe0, _bte_keymap_CDK_F35}, | |||
708 | }; | |||
709 | ||||
710 | /* Map the specified keyval/modifier setup, dependent on the mode, to | |||
711 | * a literal string. */ | |||
712 | void | |||
713 | _bte_keymap_map(guint keyval, | |||
714 | guint modifiers, | |||
715 | gboolean app_cursor_keys, | |||
716 | gboolean app_keypad_keys, | |||
717 | char **normal, | |||
718 | gsize *normal_length) | |||
719 | { | |||
720 | gsize i; | |||
721 | const struct _bte_keymap_entry *entries; | |||
722 | enum _bte_cursor_mode cursor_mode; | |||
723 | enum _bte_keypad_mode keypad_mode; | |||
724 | ||||
725 | g_return_if_fail(normal != NULL)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_16 ; if (normal != __null) _g_boolean_var_16 = 1; else _g_boolean_var_16 = 0; _g_boolean_var_16; }), 1))) { } else { g_return_if_fail_warning ("BTE", ((const char*) (__PRETTY_FUNCTION__)), "normal != NULL" ); return; } } while (0); | |||
| ||||
726 | g_return_if_fail(normal_length != NULL)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_17 ; if (normal_length != __null) _g_boolean_var_17 = 1; else _g_boolean_var_17 = 0; _g_boolean_var_17; }), 1))) { } else { g_return_if_fail_warning ("BTE", ((const char*) (__PRETTY_FUNCTION__)), "normal_length != NULL" ); return; } } while (0); | |||
727 | ||||
728 | _BTE_DEBUG_IF(BTE_DEBUG_KEYBOARD)if (0) | |||
729 | _bte_keysym_print(keyval, modifiers); | |||
730 | ||||
731 | /* Start from scratch. */ | |||
732 | *normal = NULL__null; | |||
733 | *normal_length = 0; | |||
734 | ||||
735 | /* Search for the list for this key. */ | |||
736 | entries = NULL__null; | |||
737 | for (i = 0; i < G_N_ELEMENTS(_bte_keymap)(sizeof (_bte_keymap) / sizeof ((_bte_keymap)[0])); i++) { | |||
738 | if (_bte_keymap[i].keyval == keyval) { | |||
739 | /* Found it! */ | |||
740 | entries = _bte_keymap[i].entries; | |||
741 | break; | |||
742 | } | |||
743 | } | |||
744 | if (entries == NULL__null) { | |||
745 | _bte_debug_print(BTE_DEBUG_KEYBOARD,do { } while(0) | |||
746 | " (ignoring, no map for key).\n")do { } while(0); | |||
747 | return; | |||
748 | } | |||
749 | ||||
750 | /* Build mode masks. */ | |||
751 | cursor_mode = app_cursor_keys ? cursor_app : cursor_default; | |||
752 | keypad_mode = app_keypad_keys ? keypad_app : keypad_default; | |||
753 | modifiers &= CDK_SHIFT_MASK | CDK_CONTROL_MASK | BTE_ALT_MASKCDK_MOD1_MASK | BTE_NUMLOCK_MASKCDK_MOD2_MASK; | |||
754 | ||||
755 | /* Search for the conditions. */ | |||
756 | for (i = 0; entries[i].normal_length; i++) | |||
757 | if ((entries[i].cursor_mode & cursor_mode) && | |||
758 | (entries[i].keypad_mode & keypad_mode)) | |||
759 | if ((modifiers & entries[i].mod_mask) == entries[i].mod_mask) { | |||
760 | if (entries[i].normal_length != -1) { | |||
761 | *normal_length = entries[i].normal_length; | |||
762 | assert(entries[i].normal_length < G_MAXINT)(static_cast <bool> (entries[i].normal_length < 2147483647 ) ? void (0) : __assert_fail ("entries[i].normal_length < G_MAXINT" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); | |||
763 | *normal = (char*)g_memdup(entries[i].normal, | |||
764 | entries[i].normal_length); | |||
765 | } else { | |||
766 | *normal_length = strlen(entries[i].normal); | |||
767 | *normal = g_strdup(entries[i].normal)g_strdup_inline (entries[i].normal); | |||
768 | } | |||
769 | _bte_keymap_key_add_key_modifiers(keyval, | |||
770 | modifiers, | |||
771 | cursor_mode & cursor_app, | |||
772 | normal, | |||
773 | normal_length); | |||
774 | _bte_debug_print(BTE_DEBUG_KEYBOARD,do { } while(0) | |||
775 | " to '%s'.\n",do { } while(0) | |||
776 | _bte_debug_sequence_to_string(*normal, *normal_length))do { } while(0); | |||
777 | return; | |||
778 | } | |||
779 | ||||
780 | _bte_debug_print(BTE_DEBUG_KEYBOARD,do { } while(0) | |||
781 | " (ignoring, no match for modifier state).\n")do { } while(0); | |||
782 | } | |||
783 | ||||
784 | gboolean | |||
785 | _bte_keymap_key_is_modifier(guint keyval) | |||
786 | { | |||
787 | gboolean modifier = FALSE(0); | |||
788 | /* Determine if this is just a modifier key. */ | |||
789 | switch (keyval) { | |||
790 | case CDK_KEY_Alt_L0xffe9: | |||
791 | case CDK_KEY_Alt_R0xffea: | |||
792 | case CDK_KEY_Caps_Lock0xffe5: | |||
793 | case CDK_KEY_Control_L0xffe3: | |||
794 | case CDK_KEY_Control_R0xffe4: | |||
795 | case CDK_KEY_Eisu_Shift0xff2f: | |||
796 | case CDK_KEY_Hyper_L0xffed: | |||
797 | case CDK_KEY_Hyper_R0xffee: | |||
798 | case CDK_KEY_ISO_First_Group0xfe0c: | |||
799 | case CDK_KEY_ISO_First_Group_Lock0xfe0d: | |||
800 | case CDK_KEY_ISO_Group_Latch0xfe06: | |||
801 | case CDK_KEY_ISO_Group_Lock0xfe07: | |||
802 | case CDK_KEY_ISO_Group_Shift0xff7e: | |||
803 | case CDK_KEY_ISO_Last_Group0xfe0e: | |||
804 | case CDK_KEY_ISO_Last_Group_Lock0xfe0f: | |||
805 | case CDK_KEY_ISO_Level2_Latch0xfe02: | |||
806 | case CDK_KEY_ISO_Level3_Latch0xfe04: | |||
807 | case CDK_KEY_ISO_Level3_Lock0xfe05: | |||
808 | case CDK_KEY_ISO_Level3_Shift0xfe03: | |||
809 | case CDK_KEY_ISO_Level5_Latch0xfe12: | |||
810 | case CDK_KEY_ISO_Level5_Lock0xfe13: | |||
811 | case CDK_KEY_ISO_Level5_Shift0xfe11: | |||
812 | case CDK_KEY_ISO_Lock0xfe01: | |||
813 | case CDK_KEY_ISO_Next_Group0xfe08: | |||
814 | case CDK_KEY_ISO_Next_Group_Lock0xfe09: | |||
815 | case CDK_KEY_ISO_Prev_Group0xfe0a: | |||
816 | case CDK_KEY_ISO_Prev_Group_Lock0xfe0b: | |||
817 | case CDK_KEY_Kana_Lock0xff2d: | |||
818 | case CDK_KEY_Kana_Shift0xff2e: | |||
819 | case CDK_KEY_Meta_L0xffe7: | |||
820 | case CDK_KEY_Meta_R0xffe8: | |||
821 | case CDK_KEY_ModeLock0x1008ff01: | |||
822 | case CDK_KEY_Num_Lock0xff7f: | |||
823 | case CDK_KEY_Scroll_Lock0xff14: | |||
824 | case CDK_KEY_Shift_L0xffe1: | |||
825 | case CDK_KEY_Shift_Lock0xffe6: | |||
826 | case CDK_KEY_Shift_R0xffe2: | |||
827 | case CDK_KEY_Super_L0xffeb: | |||
828 | case CDK_KEY_Super_R0xffec: | |||
829 | modifier = TRUE(!(0)); | |||
830 | break; | |||
831 | default: | |||
832 | modifier = FALSE(0); | |||
833 | break; | |||
834 | } | |||
835 | return modifier; | |||
836 | } | |||
837 | ||||
838 | static enum _bte_modifier_encoding_method | |||
839 | _bte_keymap_key_get_modifier_encoding_method(guint keyval) | |||
840 | { | |||
841 | enum _bte_modifier_encoding_method method = MODIFIER_ENCODING_NONE; | |||
842 | /* Determine if this key gets modifiers. */ | |||
843 | switch (keyval) { | |||
844 | case CDK_KEY_Up0xff52: | |||
845 | case CDK_KEY_Down0xff54: | |||
846 | case CDK_KEY_Left0xff51: | |||
847 | case CDK_KEY_Right0xff53: | |||
848 | case CDK_KEY_Insert0xff63: | |||
849 | case CDK_KEY_Delete0xffff: | |||
850 | case CDK_KEY_Home0xff50: | |||
851 | case CDK_KEY_End0xff57: | |||
852 | case CDK_KEY_Page_Up0xff55: | |||
853 | case CDK_KEY_Page_Down0xff56: | |||
854 | case CDK_KEY_KP_Up0xff97: | |||
855 | case CDK_KEY_KP_Down0xff99: | |||
856 | case CDK_KEY_KP_Left0xff96: | |||
857 | case CDK_KEY_KP_Right0xff98: | |||
858 | case CDK_KEY_KP_Insert0xff9e: | |||
859 | case CDK_KEY_KP_Delete0xff9f: | |||
860 | case CDK_KEY_KP_Home0xff95: | |||
861 | case CDK_KEY_KP_End0xff9c: | |||
862 | case CDK_KEY_KP_Page_Up0xff9a: | |||
863 | case CDK_KEY_KP_Page_Down0xff9b: | |||
864 | case CDK_KEY_KP_Begin0xff9d: | |||
865 | case CDK_KEY_F10xffbe: | |||
866 | case CDK_KEY_F20xffbf: | |||
867 | case CDK_KEY_F30xffc0: | |||
868 | case CDK_KEY_F40xffc1: | |||
869 | case CDK_KEY_F50xffc2: | |||
870 | case CDK_KEY_F60xffc3: | |||
871 | case CDK_KEY_F70xffc4: | |||
872 | case CDK_KEY_F80xffc5: | |||
873 | case CDK_KEY_F90xffc6: | |||
874 | case CDK_KEY_F100xffc7: | |||
875 | case CDK_KEY_F110xffc8: | |||
876 | case CDK_KEY_F120xffc9: | |||
877 | case CDK_KEY_F130xffca: | |||
878 | case CDK_KEY_F140xffcb: | |||
879 | case CDK_KEY_F150xffcc: | |||
880 | case CDK_KEY_F160xffcd: | |||
881 | case CDK_KEY_F170xffce: | |||
882 | case CDK_KEY_F180xffcf: | |||
883 | case CDK_KEY_F190xffd0: | |||
884 | case CDK_KEY_F200xffd1: | |||
885 | case CDK_KEY_F210xffd2: | |||
886 | case CDK_KEY_F220xffd3: | |||
887 | case CDK_KEY_F230xffd4: | |||
888 | case CDK_KEY_F240xffd5: | |||
889 | case CDK_KEY_F250xffd6: | |||
890 | case CDK_KEY_F260xffd7: | |||
891 | case CDK_KEY_F270xffd8: | |||
892 | case CDK_KEY_F280xffd9: | |||
893 | case CDK_KEY_F290xffda: | |||
894 | case CDK_KEY_F300xffdb: | |||
895 | case CDK_KEY_F310xffdc: | |||
896 | case CDK_KEY_F320xffdd: | |||
897 | case CDK_KEY_F330xffde: | |||
898 | case CDK_KEY_F340xffdf: | |||
899 | case CDK_KEY_F350xffe0: | |||
900 | method = MODIFIER_ENCODING_LONG; | |||
901 | break; | |||
902 | case CDK_KEY_KP_Divide0xffaf: | |||
903 | case CDK_KEY_KP_Multiply0xffaa: | |||
904 | case CDK_KEY_KP_Subtract0xffad: | |||
905 | case CDK_KEY_KP_Add0xffab: | |||
906 | case CDK_KEY_KP_Enter0xff8d: | |||
907 | method = MODIFIER_ENCODING_SHORT; | |||
908 | break; | |||
909 | default: | |||
910 | method = MODIFIER_ENCODING_NONE; | |||
911 | break; | |||
912 | } | |||
913 | return method; | |||
914 | } | |||
915 | ||||
916 | /* Prior and Next are ommitted for the SS3 to CSI switch below */ | |||
917 | static gboolean | |||
918 | is_cursor_key(guint keyval) | |||
919 | { | |||
920 | switch (keyval) { | |||
921 | case CDK_KEY_Home0xff50: | |||
922 | case CDK_KEY_Left0xff51: | |||
923 | case CDK_KEY_Up0xff52: | |||
924 | case CDK_KEY_Right0xff53: | |||
925 | case CDK_KEY_Down0xff54: | |||
926 | case CDK_KEY_End0xff57: | |||
927 | case CDK_KEY_Begin0xff58: | |||
928 | ||||
929 | case CDK_KEY_KP_Home0xff95: | |||
930 | case CDK_KEY_KP_Left0xff96: | |||
931 | case CDK_KEY_KP_Up0xff97: | |||
932 | case CDK_KEY_KP_Right0xff98: | |||
933 | case CDK_KEY_KP_Down0xff99: | |||
934 | case CDK_KEY_KP_End0xff9c: | |||
935 | case CDK_KEY_KP_Begin0xff9d: | |||
936 | return TRUE(!(0)); | |||
937 | default: | |||
938 | return FALSE(0); | |||
939 | } | |||
940 | } | |||
941 | ||||
942 | ||||
943 | void | |||
944 | _bte_keymap_key_add_key_modifiers(guint keyval, | |||
945 | guint modifiers, | |||
946 | gboolean cursor_app_mode, | |||
947 | char **normal, | |||
948 | gsize *normal_length) | |||
949 | { | |||
950 | int modifier; | |||
951 | char *nnormal; | |||
952 | enum _bte_modifier_encoding_method modifier_encoding_method; | |||
953 | guint significant_modifiers; | |||
954 | ||||
955 | significant_modifiers = CDK_SHIFT_MASK | | |||
956 | CDK_CONTROL_MASK | | |||
957 | BTE_ALT_MASKCDK_MOD1_MASK; | |||
958 | ||||
959 | modifier_encoding_method = _bte_keymap_key_get_modifier_encoding_method(keyval); | |||
960 | if (modifier_encoding_method
| |||
961 | return; | |||
962 | } | |||
963 | ||||
964 | switch (modifiers & significant_modifiers) { | |||
965 | case 0: | |||
966 | modifier = 0; | |||
967 | break; | |||
968 | case CDK_SHIFT_MASK: | |||
969 | modifier = 2; | |||
970 | break; | |||
971 | case BTE_ALT_MASKCDK_MOD1_MASK: | |||
972 | modifier = 3; | |||
973 | break; | |||
974 | case CDK_SHIFT_MASK | BTE_ALT_MASKCDK_MOD1_MASK: | |||
975 | modifier = 4; | |||
976 | break; | |||
977 | case CDK_CONTROL_MASK: | |||
978 | modifier = 5; | |||
979 | break; | |||
980 | case CDK_SHIFT_MASK | CDK_CONTROL_MASK: | |||
981 | modifier = 6; | |||
982 | break; | |||
983 | case BTE_ALT_MASKCDK_MOD1_MASK | CDK_CONTROL_MASK: | |||
984 | modifier = 7; | |||
985 | break; | |||
986 | case CDK_SHIFT_MASK | BTE_ALT_MASKCDK_MOD1_MASK | CDK_CONTROL_MASK: | |||
987 | modifier = 8; | |||
988 | break; | |||
989 | default: | |||
990 | modifier = 8; | |||
991 | break; | |||
992 | } | |||
993 | ||||
994 | if (modifier
| |||
995 | return; | |||
996 | } | |||
997 | ||||
998 | nnormal = g_new0(char, *normal_length + 4)(char *) (__extension__ ({ gsize __n = (gsize) (*normal_length + 4); gsize __s = sizeof (char); gpointer __p; if (__s == 1) __p = g_malloc0 (__n); else if (__builtin_constant_p (__n) && (__s == 0 || __n <= (9223372036854775807L *2UL+1UL) / __s )) __p = g_malloc0 (__n * __s); else __p = g_malloc0_n (__n, __s ); __p; })); | |||
999 | memcpy(nnormal, *normal, *normal_length); | |||
1000 | if (strlen(nnormal) > 1) { | |||
1001 | /* SS3 should have no modifiers so make it CSI instead. See | |||
1002 | * http://cvsweb.xfree86.org/cvsweb/xc/programs/xterm/input.c.diff?r1=3.57&r2=3.58 | |||
1003 | */ | |||
1004 | if (cursor_app_mode
| |||
1005 | g_str_has_prefix(nnormal, _BTE_CAP_SS3)(__builtin_constant_p ("\033" "O")? __extension__ ({ const char * const __str = (nnormal); const char * const __prefix = ("\033" "O"); gboolean __result = (0); if (__builtin_expect (__extension__ ({ int _g_boolean_var_18; if (__str == __null || __prefix == __null) _g_boolean_var_18 = 1; else _g_boolean_var_18 = 0; _g_boolean_var_18 ; }), 0)) __result = (g_str_has_prefix) (__str, __prefix); else { const size_t __str_len = strlen (((__str) + !(__str))); const size_t __prefix_len = strlen (((__prefix) + !(__prefix))); if (__str_len >= __prefix_len) __result = memcmp (((__str) + !(__str)), ((__prefix) + !(__prefix)), __prefix_len) == 0; } __result; }) : (g_str_has_prefix) (nnormal, "\033" "O") ) | |||
1006 | && is_cursor_key(keyval)) { | |||
1007 | nnormal[1] = '['; | |||
1008 | } | |||
1009 | ||||
1010 | /* Get the offset of the last character. */ | |||
1011 | int offset = strlen(nnormal) - 1; | |||
1012 | if (g_ascii_isdigit(nnormal[offset - 1])((g_ascii_table[(guchar) (nnormal[offset - 1])] & G_ASCII_DIGIT ) != 0)) { | |||
1013 | /* Stuff a semicolon and the modifier in right before | |||
1014 | * that last character. */ | |||
1015 | nnormal[offset + 2] = nnormal[offset]; | |||
1016 | nnormal[offset + 1] = modifier + '0'; | |||
1017 | nnormal[offset + 0] = ';'; | |||
1018 | *normal_length += 2; | |||
1019 | } else if (modifier_encoding_method
| |||
1020 | /* Stuff a "1", a semicolon and the modifier in right | |||
1021 | * before that last character, matching Xterm most of the time. */ | |||
1022 | nnormal[offset + 3] = nnormal[offset]; | |||
| ||||
1023 | nnormal[offset + 2] = modifier + '0'; | |||
1024 | nnormal[offset + 1] = ';'; | |||
1025 | nnormal[offset + 0] = '1'; | |||
1026 | *normal_length += 3; | |||
1027 | } else { | |||
1028 | /* Stuff the modifier in right before that last | |||
1029 | * character, matching what people expect, | |||
1030 | * and what Xterm does with numpad math operators */ | |||
1031 | nnormal[offset + 1] = nnormal[offset]; | |||
1032 | nnormal[offset + 0] = modifier + '0'; | |||
1033 | *normal_length += 1; | |||
1034 | } | |||
1035 | g_free(*normal); | |||
1036 | *normal = nnormal; | |||
1037 | } else { | |||
1038 | g_free(nnormal); | |||
1039 | } | |||
1040 | } |