1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
|
/*
* Copyright © 2012 Ran Benita <ran234@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#include <linux/input.h>
#include "test.h"
enum {
DOWN,
REPEAT,
UP,
BOTH,
NEXT,
FINISH,
};
#define EVDEV_OFFSET 8
/*
* Test a sequence of keysyms, resulting from a sequence of key presses,
* against the keysyms they're supposed to generate.
*
* - Each test runs with a clean state.
* - Each line in the test is made up of:
* + A keycode, given as a KEY_* from linux/input.h.
* + A direction - DOWN for press, UP for release, BOTH for
* immediate press + release, REPEAT to just get the syms.
* + A sequence of keysyms that should result from this keypress.
*
* The vararg format is:
* <KEY_*> <DOWN | UP | BOTH> <XKB_KEY_* (zero or more)> <NEXT | FINISH>
*
* See below for examples.
*/
static int
test_key_seq(struct xkb_keymap *keymap, ...)
{
struct xkb_state *state;
va_list ap;
xkb_keycode_t kc;
int op;
xkb_keysym_t keysym;
const xkb_keysym_t *syms;
unsigned int nsyms, i;
char ksbuf[64];
fprintf(stderr, "----\n");
state = xkb_state_new(keymap);
assert(state);
va_start(ap, keymap);
for (;;) {
kc = va_arg(ap, int) + EVDEV_OFFSET;
op = va_arg(ap, int);
nsyms = xkb_state_key_get_syms(state, kc, &syms);
fprintf(stderr, "got %d syms for key 0x%x: [", nsyms, kc);
if (op == DOWN || op == BOTH)
xkb_state_update_key(state, kc, XKB_KEY_DOWN);
if (op == UP || op == BOTH)
xkb_state_update_key(state, kc, XKB_KEY_UP);
for (i = 0; i < nsyms; i++) {
keysym = va_arg(ap, int);
xkb_keysym_get_name(syms[i], ksbuf, sizeof(ksbuf));
fprintf(stderr, "%s%s", (i != 0) ? ", " : "", ksbuf);
if (keysym == FINISH || keysym == NEXT) {
xkb_keysym_get_name(syms[i], ksbuf, sizeof(ksbuf));
fprintf(stderr, "Did not expect keysym: %s.\n", ksbuf);
goto fail;
}
if (keysym != syms[i]) {
xkb_keysym_get_name(keysym, ksbuf, sizeof(ksbuf));
fprintf(stderr, "Expected keysym: %s. ", ksbuf);;
xkb_keysym_get_name(syms[i], ksbuf, sizeof(ksbuf));
fprintf(stderr, "Got keysym: %s.\n", ksbuf);;
goto fail;
}
}
fprintf(stderr, "]\n");
keysym = va_arg(ap, int);
if (keysym == NEXT)
continue;
if (keysym == FINISH)
break;
xkb_keysym_get_name(keysym, ksbuf, sizeof(ksbuf));
fprintf(stderr, "Expected keysym: %s. Didn't get it.\n", ksbuf);
goto fail;
}
va_end(ap);
xkb_state_unref(state);
return 1;
fail:
va_end(ap);
xkb_state_unref(state);
return 0;
}
int
main(void)
{
struct xkb_context *ctx = test_get_context();
struct xkb_keymap *keymap;
assert(ctx);
keymap = test_compile_rules(ctx, "evdev", "evdev",
"us,il,ru,de", ",,phonetic,neo",
"grp:alt_shift_toggle,grp:menu_toggle");
assert(keymap);
assert(test_key_seq(keymap,
KEY_H, BOTH, XKB_KEY_h, NEXT,
KEY_E, BOTH, XKB_KEY_e, NEXT,
KEY_L, BOTH, XKB_KEY_l, NEXT,
KEY_L, BOTH, XKB_KEY_l, NEXT,
KEY_O, BOTH, XKB_KEY_o, FINISH));
/* Simple shifted level. */
assert(test_key_seq(keymap,
KEY_H, BOTH, XKB_KEY_h, NEXT,
KEY_LEFTSHIFT, DOWN, XKB_KEY_Shift_L, NEXT,
KEY_E, BOTH, XKB_KEY_E, NEXT,
KEY_L, BOTH, XKB_KEY_L, NEXT,
KEY_LEFTSHIFT, UP, XKB_KEY_Shift_L, NEXT,
KEY_L, BOTH, XKB_KEY_l, NEXT,
KEY_O, BOTH, XKB_KEY_o, FINISH));
/* Key repeat shifted and unshifted in the middle. */
assert(test_key_seq(keymap,
KEY_H, DOWN, XKB_KEY_h, NEXT,
KEY_H, REPEAT, XKB_KEY_h, NEXT,
KEY_H, REPEAT, XKB_KEY_h, NEXT,
KEY_LEFTSHIFT, DOWN, XKB_KEY_Shift_L, NEXT,
KEY_H, REPEAT, XKB_KEY_H, NEXT,
KEY_H, REPEAT, XKB_KEY_H, NEXT,
KEY_LEFTSHIFT, UP, XKB_KEY_Shift_L, NEXT,
KEY_H, REPEAT, XKB_KEY_h, NEXT,
KEY_H, REPEAT, XKB_KEY_h, NEXT,
KEY_H, UP, XKB_KEY_h, NEXT,
KEY_H, BOTH, XKB_KEY_h, FINISH));
/* Base modifier cleared on key release... */
assert(test_key_seq(keymap,
KEY_H, BOTH, XKB_KEY_h, NEXT,
KEY_LEFTSHIFT, DOWN, XKB_KEY_Shift_L, NEXT,
KEY_E, BOTH, XKB_KEY_E, NEXT,
KEY_L, BOTH, XKB_KEY_L, NEXT,
KEY_LEFTSHIFT, DOWN, XKB_KEY_Shift_L, NEXT,
KEY_L, BOTH, XKB_KEY_L, NEXT,
KEY_O, BOTH, XKB_KEY_O, FINISH));
/* ... But only by the keycode that set it. */
assert(test_key_seq(keymap,
KEY_H, BOTH, XKB_KEY_h, NEXT,
KEY_LEFTSHIFT, DOWN, XKB_KEY_Shift_L, NEXT,
KEY_E, BOTH, XKB_KEY_E, NEXT,
KEY_L, BOTH, XKB_KEY_L, NEXT,
KEY_RIGHTSHIFT, UP, XKB_KEY_Shift_R, NEXT,
KEY_L, BOTH, XKB_KEY_L, NEXT,
KEY_O, BOTH, XKB_KEY_O, FINISH));
/*
* A base modifier should only be cleared when no other key affecting
* the modifier is down.
*/
assert(test_key_seq(keymap,
KEY_H, BOTH, XKB_KEY_h, NEXT,
KEY_LEFTSHIFT, DOWN, XKB_KEY_Shift_L, NEXT,
KEY_E, BOTH, XKB_KEY_E, NEXT,
KEY_RIGHTSHIFT, DOWN, XKB_KEY_Shift_R, NEXT,
KEY_L, BOTH, XKB_KEY_L, NEXT,
KEY_RIGHTSHIFT, UP, XKB_KEY_Shift_R, NEXT,
KEY_L, BOTH, XKB_KEY_L, NEXT,
KEY_LEFTSHIFT, UP, XKB_KEY_Shift_L, NEXT,
KEY_O, BOTH, XKB_KEY_o, FINISH));
/* Group switching / locking. */
assert(test_key_seq(keymap,
KEY_H, BOTH, XKB_KEY_h, NEXT,
KEY_E, BOTH, XKB_KEY_e, NEXT,
KEY_COMPOSE, BOTH, XKB_KEY_ISO_Next_Group, NEXT,
KEY_K, BOTH, XKB_KEY_hebrew_lamed, NEXT,
KEY_F, BOTH, XKB_KEY_hebrew_kaph, NEXT,
KEY_COMPOSE, BOTH, XKB_KEY_ISO_Next_Group, NEXT,
KEY_COMPOSE, BOTH, XKB_KEY_ISO_Next_Group, NEXT,
KEY_COMPOSE, BOTH, XKB_KEY_ISO_Next_Group, NEXT,
KEY_O, BOTH, XKB_KEY_o, FINISH));
assert(test_key_seq(keymap,
KEY_LEFTSHIFT, DOWN, XKB_KEY_Shift_L, NEXT,
KEY_LEFTALT, DOWN, XKB_KEY_ISO_Next_Group, NEXT,
KEY_LEFTALT, UP, XKB_KEY_ISO_Next_Group, NEXT,
KEY_LEFTSHIFT, UP, XKB_KEY_Shift_L, FINISH));
assert(test_key_seq(keymap,
KEY_LEFTALT, DOWN, XKB_KEY_Alt_L, NEXT,
KEY_LEFTSHIFT, DOWN, XKB_KEY_ISO_Next_Group, NEXT,
KEY_LEFTSHIFT, UP, XKB_KEY_ISO_Next_Group, NEXT,
KEY_LEFTALT, UP, XKB_KEY_Alt_L, FINISH));
/* Locked modifiers. */
assert(test_key_seq(keymap,
KEY_CAPSLOCK, BOTH, XKB_KEY_Caps_Lock, NEXT,
KEY_H, BOTH, XKB_KEY_H, NEXT,
KEY_E, BOTH, XKB_KEY_E, NEXT,
KEY_L, BOTH, XKB_KEY_L, NEXT,
KEY_L, BOTH, XKB_KEY_L, NEXT,
KEY_O, BOTH, XKB_KEY_O, FINISH));
assert(test_key_seq(keymap,
KEY_H, BOTH, XKB_KEY_h, NEXT,
KEY_E, BOTH, XKB_KEY_e, NEXT,
KEY_CAPSLOCK, BOTH, XKB_KEY_Caps_Lock, NEXT,
KEY_L, BOTH, XKB_KEY_L, NEXT,
KEY_L, BOTH, XKB_KEY_L, NEXT,
KEY_CAPSLOCK, BOTH, XKB_KEY_Caps_Lock, NEXT,
KEY_O, BOTH, XKB_KEY_o, FINISH));
assert(test_key_seq(keymap,
KEY_H, BOTH, XKB_KEY_h, NEXT,
KEY_CAPSLOCK, DOWN, XKB_KEY_Caps_Lock, NEXT,
KEY_E, BOTH, XKB_KEY_E, NEXT,
KEY_L, BOTH, XKB_KEY_L, NEXT,
KEY_L, BOTH, XKB_KEY_L, NEXT,
KEY_CAPSLOCK, UP, XKB_KEY_Caps_Lock, NEXT,
KEY_O, BOTH, XKB_KEY_O, FINISH));
assert(test_key_seq(keymap,
KEY_H, BOTH, XKB_KEY_h, NEXT,
KEY_E, BOTH, XKB_KEY_e, NEXT,
KEY_CAPSLOCK, UP, XKB_KEY_Caps_Lock, NEXT,
KEY_L, BOTH, XKB_KEY_l, NEXT,
KEY_L, BOTH, XKB_KEY_l, NEXT,
KEY_O, BOTH, XKB_KEY_o, FINISH));
/*
* A key release affecting a locked modifier should clear it
* regardless of the key press.
*/
/* assert(test_key_seq(keymap, */
/* KEY_H, BOTH, XKB_KEY_h, NEXT, */
/* KEY_CAPSLOCK, DOWN, XKB_KEY_Caps_Lock, NEXT, */
/* KEY_E, BOTH, XKB_KEY_E, NEXT, */
/* KEY_L, BOTH, XKB_KEY_L, NEXT, */
/* KEY_CAPSLOCK, UP, XKB_KEY_Caps_Lock, NEXT, */
/* KEY_L, BOTH, XKB_KEY_L, NEXT, */
/* KEY_CAPSLOCK, UP, XKB_KEY_Caps_Lock, NEXT, */
/* KEY_O, BOTH, XKB_KEY_o, FINISH)); */
/* Simple Num Lock sanity check. */
assert(test_key_seq(keymap,
KEY_KP1, BOTH, XKB_KEY_KP_End, NEXT,
KEY_NUMLOCK, BOTH, XKB_KEY_Num_Lock, NEXT,
KEY_KP1, BOTH, XKB_KEY_KP_1, NEXT,
KEY_KP2, BOTH, XKB_KEY_KP_2, NEXT,
KEY_NUMLOCK, BOTH, XKB_KEY_Num_Lock, NEXT,
KEY_KP2, BOTH, XKB_KEY_KP_Down, FINISH));
/* Test that the aliases in the ru(phonetic) symbols map work. */
assert(test_key_seq(keymap,
KEY_COMPOSE, BOTH, XKB_KEY_ISO_Next_Group, NEXT,
KEY_COMPOSE, BOTH, XKB_KEY_ISO_Next_Group, NEXT,
KEY_1, BOTH, XKB_KEY_1, NEXT,
KEY_Q, BOTH, XKB_KEY_Cyrillic_ya, NEXT,
KEY_LEFTSHIFT, DOWN, XKB_KEY_Shift_L, NEXT,
KEY_1, BOTH, XKB_KEY_exclam, NEXT,
KEY_Q, BOTH, XKB_KEY_Cyrillic_YA, NEXT,
KEY_LEFTSHIFT, UP, XKB_KEY_Shift_L, NEXT,
KEY_V, BOTH, XKB_KEY_Cyrillic_zhe, NEXT,
KEY_CAPSLOCK, BOTH, XKB_KEY_Caps_Lock, NEXT,
KEY_1, BOTH, XKB_KEY_1, NEXT,
KEY_V, BOTH, XKB_KEY_Cyrillic_ZHE, NEXT,
KEY_RIGHTSHIFT, DOWN, XKB_KEY_Shift_R, NEXT,
KEY_V, BOTH, XKB_KEY_Cyrillic_zhe, NEXT,
KEY_RIGHTSHIFT, UP, XKB_KEY_Shift_R, NEXT,
KEY_V, BOTH, XKB_KEY_Cyrillic_ZHE, FINISH));
#define KS(name) xkb_keysym_from_name(name, 0)
/* Test that levels (1-5) in de(neo) symbols map work. */
assert(test_key_seq(keymap,
/* Switch to the group. */
KEY_COMPOSE, BOTH, XKB_KEY_ISO_Next_Group, NEXT,
KEY_COMPOSE, BOTH, XKB_KEY_ISO_Next_Group, NEXT,
KEY_COMPOSE, BOTH, XKB_KEY_ISO_Next_Group, NEXT,
/* Level 1. */
KEY_1, BOTH, XKB_KEY_1, NEXT,
KEY_Q, BOTH, XKB_KEY_x, NEXT,
KEY_KP7, BOTH, XKB_KEY_KP_7, NEXT,
KEY_ESC, BOTH, XKB_KEY_Escape, NEXT,
/* Level 2 with Shift. */
KEY_LEFTSHIFT, DOWN, XKB_KEY_Shift_L, NEXT,
KEY_1, BOTH, XKB_KEY_degree, NEXT,
KEY_Q, BOTH, XKB_KEY_X, NEXT,
KEY_KP7, BOTH, KS("U2714"), NEXT,
KEY_ESC, BOTH, XKB_KEY_Escape, NEXT,
/*
* XXX: de(neo) uses shift(both_capslock) which causes
* the interesting result in the next line. Since it's
* a key release, it doesn't actually lock the modifier,
* and applications by-and-large ignore the keysym on
* release(?). Is this a problem?
*/
KEY_LEFTSHIFT, UP, XKB_KEY_Caps_Lock, NEXT,
/* Level 2 with the Lock modifier. */
KEY_LEFTSHIFT, DOWN, XKB_KEY_Shift_L, NEXT,
KEY_RIGHTSHIFT, BOTH, XKB_KEY_Caps_Lock, NEXT,
KEY_LEFTSHIFT, UP, XKB_KEY_Caps_Lock, NEXT,
KEY_6, BOTH, XKB_KEY_6, NEXT,
KEY_H, BOTH, XKB_KEY_S, NEXT,
KEY_KP3, BOTH, XKB_KEY_KP_3, NEXT,
KEY_ESC, BOTH, XKB_KEY_Escape, NEXT,
KEY_LEFTSHIFT, DOWN, XKB_KEY_Shift_L, NEXT,
KEY_RIGHTSHIFT, BOTH, XKB_KEY_Caps_Lock, NEXT,
KEY_LEFTSHIFT, UP, XKB_KEY_Caps_Lock, NEXT,
/* Level 3. */
KEY_CAPSLOCK, DOWN, XKB_KEY_ISO_Level3_Shift, NEXT,
KEY_6, BOTH, XKB_KEY_cent, NEXT,
KEY_Q, BOTH, XKB_KEY_ellipsis, NEXT,
KEY_KP7, BOTH, KS("U2195"), NEXT,
KEY_ESC, BOTH, XKB_KEY_Escape, NEXT,
KEY_CAPSLOCK, UP, XKB_KEY_ISO_Level3_Shift, NEXT,
/* Level 4. */
KEY_CAPSLOCK, DOWN, XKB_KEY_ISO_Level3_Shift, NEXT,
KEY_LEFTSHIFT, DOWN, XKB_KEY_Shift_L, NEXT,
KEY_5, BOTH, XKB_KEY_malesymbol, NEXT,
KEY_E, BOTH, XKB_KEY_Greek_lambda, NEXT,
KEY_SPACE, BOTH, XKB_KEY_nobreakspace, NEXT,
KEY_KP8, BOTH, XKB_KEY_intersection, NEXT,
KEY_ESC, BOTH, XKB_KEY_Escape, NEXT,
KEY_LEFTSHIFT, UP, XKB_KEY_Caps_Lock, NEXT,
KEY_CAPSLOCK, UP, XKB_KEY_ISO_Level3_Shift, NEXT,
/* Level 5. */
KEY_RIGHTALT, DOWN, XKB_KEY_ISO_Level5_Shift, NEXT,
KEY_5, BOTH, XKB_KEY_periodcentered, NEXT,
KEY_E, BOTH, XKB_KEY_Up, NEXT,
KEY_SPACE, BOTH, XKB_KEY_KP_0, NEXT,
KEY_KP8, BOTH, XKB_KEY_KP_Up, NEXT,
KEY_ESC, BOTH, XKB_KEY_Escape, NEXT,
KEY_RIGHTALT, UP, XKB_KEY_ISO_Level5_Shift, NEXT,
KEY_V, BOTH, XKB_KEY_p, FINISH));
xkb_keymap_unref(keymap);
assert(ctx);
keymap = test_compile_rules(ctx, "evdev", "", "us,il,ru", "",
"grp:alt_shift_toggle_bidir,grp:menu_toggle");
assert(keymap);
assert(test_key_seq(keymap,
KEY_LEFTSHIFT, DOWN, XKB_KEY_Shift_L, NEXT,
KEY_LEFTALT, DOWN, XKB_KEY_ISO_Prev_Group, NEXT,
KEY_LEFTALT, UP, XKB_KEY_ISO_Prev_Group, NEXT,
KEY_LEFTSHIFT, UP, XKB_KEY_Shift_L, FINISH));
assert(test_key_seq(keymap,
KEY_LEFTALT, DOWN, XKB_KEY_Alt_L, NEXT,
KEY_LEFTSHIFT, DOWN, XKB_KEY_ISO_Prev_Group, NEXT,
KEY_LEFTSHIFT, UP, XKB_KEY_ISO_Prev_Group, NEXT,
KEY_LEFTALT, UP, XKB_KEY_Alt_L, FINISH));
/* Check backwards (negative) group switching and wrapping. */
assert(test_key_seq(keymap,
KEY_H, BOTH, XKB_KEY_h, NEXT,
KEY_COMPOSE, BOTH, XKB_KEY_ISO_Next_Group, NEXT,
KEY_H, BOTH, XKB_KEY_hebrew_yod, NEXT,
KEY_COMPOSE, BOTH, XKB_KEY_ISO_Next_Group, NEXT,
KEY_H, BOTH, XKB_KEY_Cyrillic_er, NEXT,
KEY_LEFTSHIFT, DOWN, XKB_KEY_Shift_L, NEXT,
KEY_LEFTALT, BOTH, XKB_KEY_ISO_Prev_Group, NEXT,
KEY_LEFTSHIFT, UP, XKB_KEY_Shift_L, NEXT,
KEY_H, BOTH, XKB_KEY_hebrew_yod, NEXT,
KEY_LEFTSHIFT, DOWN, XKB_KEY_Shift_L, NEXT,
KEY_LEFTALT, BOTH, XKB_KEY_ISO_Prev_Group, NEXT,
KEY_LEFTSHIFT, UP, XKB_KEY_Shift_L, NEXT,
KEY_H, BOTH, XKB_KEY_h, NEXT,
KEY_LEFTSHIFT, DOWN, XKB_KEY_Shift_L, NEXT,
KEY_LEFTALT, BOTH, XKB_KEY_ISO_Prev_Group, NEXT,
KEY_LEFTSHIFT, UP, XKB_KEY_Shift_L, NEXT,
KEY_H, BOTH, XKB_KEY_Cyrillic_er, NEXT,
KEY_COMPOSE, BOTH, XKB_KEY_ISO_Next_Group, NEXT,
KEY_H, BOTH, XKB_KEY_h, FINISH));
xkb_keymap_unref(keymap);
keymap = test_compile_rules(ctx, "evdev", "", "us,il,ru", "",
"grp:switch,grp:lswitch,grp:menu_toggle");
assert(keymap);
/* Test depressed group works (Mode_switch). */
assert(test_key_seq(keymap,
KEY_H, BOTH, XKB_KEY_h, NEXT,
KEY_RIGHTALT, DOWN, XKB_KEY_Mode_switch, NEXT,
KEY_H, BOTH, XKB_KEY_hebrew_yod, NEXT,
KEY_RIGHTALT, UP, XKB_KEY_ISO_Level3_Shift, NEXT,
KEY_H, BOTH, XKB_KEY_h, NEXT,
KEY_RIGHTALT, DOWN, XKB_KEY_Mode_switch, NEXT,
KEY_H, BOTH, XKB_KEY_hebrew_yod, NEXT,
KEY_RIGHTALT, UP, XKB_KEY_ISO_Level3_Shift, NEXT,
KEY_H, BOTH, XKB_KEY_h, FINISH));
/* Test locked+depressed group works, with wrapping and accumulation. */
assert(test_key_seq(keymap,
KEY_H, BOTH, XKB_KEY_h, NEXT,
KEY_COMPOSE, BOTH, XKB_KEY_ISO_Next_Group, NEXT,
KEY_LEFTALT, DOWN, XKB_KEY_Mode_switch, NEXT,
KEY_H, BOTH, XKB_KEY_Cyrillic_er, NEXT,
KEY_LEFTALT, UP, XKB_KEY_Mode_switch, NEXT,
KEY_H, BOTH, XKB_KEY_hebrew_yod, NEXT,
KEY_COMPOSE, BOTH, XKB_KEY_ISO_Next_Group, NEXT,
KEY_LEFTALT, DOWN, XKB_KEY_Mode_switch, NEXT,
/* Should wrap back to first group. */
KEY_H, BOTH, XKB_KEY_h, NEXT,
KEY_LEFTALT, UP, XKB_KEY_Mode_switch, NEXT,
KEY_H, BOTH, XKB_KEY_Cyrillic_er, NEXT,
KEY_COMPOSE, BOTH, XKB_KEY_ISO_Next_Group, NEXT,
KEY_H, BOTH, XKB_KEY_h, NEXT,
/* Two SetGroup(+1)'s should add up. */
KEY_RIGHTALT, DOWN, XKB_KEY_Mode_switch, NEXT,
KEY_H, BOTH, XKB_KEY_hebrew_yod, NEXT,
KEY_LEFTALT, DOWN, XKB_KEY_Mode_switch, NEXT,
KEY_H, BOTH, XKB_KEY_Cyrillic_er, NEXT,
KEY_LEFTALT, UP, XKB_KEY_Mode_switch, NEXT,
KEY_H, BOTH, XKB_KEY_hebrew_yod, NEXT,
KEY_RIGHTALT, UP, XKB_KEY_ISO_Level3_Shift, NEXT,
KEY_H, BOTH, XKB_KEY_h, FINISH));
xkb_keymap_unref(keymap);
keymap = test_compile_file(ctx, "keymaps/unbound-vmod.xkb");
assert(keymap);
assert(test_key_seq(keymap,
KEY_H, BOTH, XKB_KEY_h, NEXT,
KEY_Z, BOTH, XKB_KEY_y, NEXT,
KEY_MINUS, BOTH, XKB_KEY_ssharp, NEXT,
KEY_Z, BOTH, XKB_KEY_y, FINISH));
xkb_keymap_unref(keymap);
xkb_context_unref(ctx);
return 0;
}
|