forked from obsproject/obs-studio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobs-nix-wayland.c
1630 lines (1574 loc) · 40.4 KB
/
obs-nix-wayland.c
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
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/******************************************************************************
Copyright (C) 2019 by Jason Francis <cycl0ps@tuta.io>
This program 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, either version 2 of the License, or
(at your option) any later version.
This program 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. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
#include "obs-internal.h"
#include "obs-nix-platform.h"
#include "obs-nix-wayland.h"
#include <unistd.h>
#include <sys/mman.h>
#include <string.h>
#include <wayland-client.h>
#include <xkbcommon/xkbcommon.h>
// X11 only supports 256 scancodes, most keyboards dont have 256 keys so this should be reasonable.
#define MAX_KEYCODES 256
// X11 keymaps only have 4 shift levels, im not sure xkbcommon supports a way to shift the state into a higher level anyway.
#define MAX_SHIFT_LEVELS 4
struct obs_hotkeys_platform {
struct wl_display *display;
struct wl_seat *seat;
struct wl_keyboard *keyboard;
struct xkb_context *xkb_context;
struct xkb_keymap *xkb_keymap;
struct xkb_state *xkb_state;
xkb_keysym_t key_to_sym[MAX_SHIFT_LEVELS][MAX_KEYCODES];
xkb_keysym_t obs_to_key[OBS_KEY_LAST_VALUE];
uint32_t current_layout;
};
static obs_key_t obs_nix_wayland_key_from_virtual_key(int sym);
static void load_keymap_data(struct xkb_keymap *keymap, xkb_keycode_t key,
void *data)
{
obs_hotkeys_platform_t *plat = (obs_hotkeys_platform_t *)data;
if (key >= MAX_KEYCODES)
return;
const xkb_keysym_t *syms;
for (int level = 0; level < MAX_SHIFT_LEVELS; level++) {
int nsyms = xkb_keymap_key_get_syms_by_level(
keymap, key, plat->current_layout, level, &syms);
if (nsyms < 1)
continue;
obs_key_t obs_key =
obs_nix_wayland_key_from_virtual_key(syms[0]);
// This avoids ambiguity where multiple scancodes produce the same symbols.
// e.g. LSGT and Shift+AB08 produce `<` on default US layout.
if (!plat->obs_to_key[obs_key])
plat->obs_to_key[obs_key] = key;
plat->key_to_sym[level][key] = syms[0];
}
}
static void rebuild_keymap_data(obs_hotkeys_platform_t *plat)
{
memset(plat->key_to_sym, 0,
sizeof(xkb_keysym_t) * MAX_SHIFT_LEVELS * MAX_KEYCODES);
memset(plat->obs_to_key, 0, sizeof(xkb_keysym_t) * OBS_KEY_LAST_VALUE);
xkb_keymap_key_for_each(plat->xkb_keymap, load_keymap_data, plat);
}
static void platform_keyboard_keymap(void *data, struct wl_keyboard *keyboard,
uint32_t format, int32_t fd, uint32_t size)
{
UNUSED_PARAMETER(keyboard);
UNUSED_PARAMETER(format);
obs_hotkeys_platform_t *plat = (obs_hotkeys_platform_t *)data;
char *keymap_shm = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);
if (keymap_shm == MAP_FAILED) {
close(fd);
return;
}
struct xkb_keymap *xkb_keymap = xkb_keymap_new_from_string(
plat->xkb_context, keymap_shm, XKB_KEYMAP_FORMAT_TEXT_V1,
XKB_KEYMAP_COMPILE_NO_FLAGS);
munmap(keymap_shm, size);
close(fd);
// cleanup old keymap and state
xkb_keymap_unref(plat->xkb_keymap);
xkb_state_unref(plat->xkb_state);
plat->xkb_keymap = xkb_keymap;
plat->xkb_state = xkb_state_new(xkb_keymap);
rebuild_keymap_data(plat);
}
static void platform_keyboard_modifiers(void *data,
struct wl_keyboard *keyboard,
uint32_t serial,
uint32_t mods_depressed,
uint32_t mods_latched,
uint32_t mods_locked, uint32_t group)
{
UNUSED_PARAMETER(keyboard);
UNUSED_PARAMETER(serial);
obs_hotkeys_platform_t *plat = (obs_hotkeys_platform_t *)data;
xkb_state_update_mask(plat->xkb_state, mods_depressed, mods_latched,
mods_locked, 0, 0, group);
if (plat->current_layout != group) {
plat->current_layout = group;
rebuild_keymap_data(plat);
}
}
static void platform_keyboard_key(void *data, struct wl_keyboard *keyboard,
uint32_t serial, uint32_t time, uint32_t key,
uint32_t state)
{
UNUSED_PARAMETER(data);
UNUSED_PARAMETER(keyboard);
UNUSED_PARAMETER(serial);
UNUSED_PARAMETER(time);
UNUSED_PARAMETER(key);
UNUSED_PARAMETER(state);
// We have access to the keyboard input here, but behave like other
// platforms and let Qt inform us of key events through the platform
// callbacks.
}
static void platform_keyboard_enter(void *data, struct wl_keyboard *keyboard,
uint32_t serial, struct wl_surface *surface,
struct wl_array *keys)
{
UNUSED_PARAMETER(data);
UNUSED_PARAMETER(keyboard);
UNUSED_PARAMETER(serial);
UNUSED_PARAMETER(surface);
UNUSED_PARAMETER(keys);
// Nothing to do here.
}
static void platform_keyboard_leave(void *data, struct wl_keyboard *keyboard,
uint32_t serial, struct wl_surface *surface)
{
UNUSED_PARAMETER(data);
UNUSED_PARAMETER(keyboard);
UNUSED_PARAMETER(serial);
UNUSED_PARAMETER(surface);
// Nothing to do.
}
static void platform_keyboard_repeat_info(void *data,
struct wl_keyboard *keyboard,
int32_t rate, int32_t delay)
{
UNUSED_PARAMETER(data);
UNUSED_PARAMETER(keyboard);
UNUSED_PARAMETER(rate);
UNUSED_PARAMETER(delay);
// Nothing to do.
}
const struct wl_keyboard_listener keyboard_listener = {
.keymap = platform_keyboard_keymap,
.enter = platform_keyboard_enter,
.leave = platform_keyboard_leave,
.key = platform_keyboard_key,
.modifiers = platform_keyboard_modifiers,
.repeat_info = platform_keyboard_repeat_info,
};
static void platform_seat_capabilities(void *data, struct wl_seat *seat,
uint32_t capabilities)
{
UNUSED_PARAMETER(seat);
obs_hotkeys_platform_t *plat = (obs_hotkeys_platform_t *)data;
bool kb_present = capabilities & WL_SEAT_CAPABILITY_KEYBOARD;
if (kb_present && plat->keyboard == NULL) {
plat->keyboard = wl_seat_get_keyboard(plat->seat);
wl_keyboard_add_listener(plat->keyboard, &keyboard_listener,
plat);
} else if (!kb_present && plat->keyboard != NULL) {
wl_keyboard_release(plat->keyboard);
plat->keyboard = NULL;
}
}
static void platform_seat_name(void *data, struct wl_seat *seat,
const char *name)
{
UNUSED_PARAMETER(data);
UNUSED_PARAMETER(seat);
UNUSED_PARAMETER(name);
// Nothing to do.
}
const struct wl_seat_listener seat_listener = {
.capabilities = platform_seat_capabilities,
.name = platform_seat_name,
};
static void platform_registry_handler(void *data, struct wl_registry *registry,
uint32_t id, const char *interface,
uint32_t version)
{
UNUSED_PARAMETER(version);
obs_hotkeys_platform_t *plat = (obs_hotkeys_platform_t *)data;
if (strcmp(interface, wl_seat_interface.name) == 0) {
if (version < 4) {
blog(LOG_WARNING,
"[wayland] hotkeys disabled, compositor is too old");
return;
}
// Only negotiate up to version 7, the current wl_seat at time of writing.
plat->seat = wl_registry_bind(registry, id, &wl_seat_interface,
version <= 7 ? version : 7);
wl_seat_add_listener(plat->seat, &seat_listener, plat);
}
}
static void platform_registry_remover(void *data, struct wl_registry *registry,
uint32_t id)
{
UNUSED_PARAMETER(data);
UNUSED_PARAMETER(registry);
UNUSED_PARAMETER(id);
// Nothing to do.
}
const struct wl_registry_listener registry_listener = {
.global = platform_registry_handler,
.global_remove = platform_registry_remover,
};
void obs_nix_wayland_log_info(void)
{
struct wl_display *display = obs_get_nix_platform_display();
if (display == NULL) {
blog(LOG_INFO, "Unable to connect to Wayland server");
return;
}
//TODO: query some information about the wayland server if possible
blog(LOG_INFO, "Connected to Wayland server");
}
static bool
obs_nix_wayland_hotkeys_platform_init(struct obs_core_hotkeys *hotkeys)
{
struct wl_display *display = obs_get_nix_platform_display();
hotkeys->platform_context = bzalloc(sizeof(obs_hotkeys_platform_t));
hotkeys->platform_context->display = display;
hotkeys->platform_context->xkb_context =
xkb_context_new(XKB_CONTEXT_NO_FLAGS);
struct wl_registry *registry = wl_display_get_registry(display);
wl_registry_add_listener(registry, ®istry_listener,
hotkeys->platform_context);
wl_display_roundtrip(display);
return true;
}
static void
obs_nix_wayland_hotkeys_platform_free(struct obs_core_hotkeys *hotkeys)
{
obs_hotkeys_platform_t *plat = hotkeys->platform_context;
xkb_context_unref(plat->xkb_context);
xkb_keymap_unref(plat->xkb_keymap);
xkb_state_unref(plat->xkb_state);
bfree(plat);
}
static bool
obs_nix_wayland_hotkeys_platform_is_pressed(obs_hotkeys_platform_t *context,
obs_key_t key)
{
UNUSED_PARAMETER(context);
UNUSED_PARAMETER(key);
// This function is only used by the hotkey thread for capturing out of
// focus hotkey triggers. Since wayland never delivers key events when out
// of focus we leave this blank intentionally.
return false;
}
static void obs_nix_wayland_key_to_str(obs_key_t key, struct dstr *dstr)
{
if (key >= OBS_KEY_MOUSE1 && key <= OBS_KEY_MOUSE29) {
if (obs->hotkeys.translations[key]) {
dstr_copy(dstr, obs->hotkeys.translations[key]);
} else {
dstr_printf(dstr, "Mouse %d",
(int)(key - OBS_KEY_MOUSE1 + 1));
}
return;
}
if (key >= OBS_KEY_NUM0 && key <= OBS_KEY_NUM9) {
if (obs->hotkeys.translations[key]) {
dstr_copy(dstr, obs->hotkeys.translations[key]);
} else {
dstr_printf(dstr, "Numpad %d",
(int)(key - OBS_KEY_NUM0));
}
return;
}
#define translate_key(key, def) \
dstr_copy(dstr, obs_get_hotkey_translation(key, def))
switch (key) {
case OBS_KEY_INSERT:
return translate_key(key, "Insert");
case OBS_KEY_DELETE:
return translate_key(key, "Delete");
case OBS_KEY_HOME:
return translate_key(key, "Home");
case OBS_KEY_END:
return translate_key(key, "End");
case OBS_KEY_PAGEUP:
return translate_key(key, "Page Up");
case OBS_KEY_PAGEDOWN:
return translate_key(key, "Page Down");
case OBS_KEY_NUMLOCK:
return translate_key(key, "Num Lock");
case OBS_KEY_SCROLLLOCK:
return translate_key(key, "Scroll Lock");
case OBS_KEY_CAPSLOCK:
return translate_key(key, "Caps Lock");
case OBS_KEY_BACKSPACE:
return translate_key(key, "Backspace");
case OBS_KEY_TAB:
return translate_key(key, "Tab");
case OBS_KEY_PRINT:
return translate_key(key, "Print");
case OBS_KEY_PAUSE:
return translate_key(key, "Pause");
case OBS_KEY_LEFT:
return translate_key(key, "Left");
case OBS_KEY_RIGHT:
return translate_key(key, "Right");
case OBS_KEY_UP:
return translate_key(key, "Up");
case OBS_KEY_DOWN:
return translate_key(key, "Down");
case OBS_KEY_SHIFT:
return translate_key(key, "Shift");
case OBS_KEY_ALT:
return translate_key(key, "Alt");
case OBS_KEY_CONTROL:
return translate_key(key, "Control");
case OBS_KEY_META:
return translate_key(key, "Super");
case OBS_KEY_MENU:
return translate_key(key, "Menu");
case OBS_KEY_NUMASTERISK:
return translate_key(key, "Numpad *");
case OBS_KEY_NUMPLUS:
return translate_key(key, "Numpad +");
case OBS_KEY_NUMMINUS:
return translate_key(key, "Numpad -");
case OBS_KEY_NUMCOMMA:
return translate_key(key, "Numpad ,");
case OBS_KEY_NUMPERIOD:
return translate_key(key, "Numpad .");
case OBS_KEY_NUMSLASH:
return translate_key(key, "Numpad /");
case OBS_KEY_SPACE:
return translate_key(key, "Space");
case OBS_KEY_ESCAPE:
return translate_key(key, "Escape");
default:;
}
if (key >= OBS_KEY_F1 && key <= OBS_KEY_F35) {
dstr_printf(dstr, "F%d", (int)(key - OBS_KEY_F1 + 1));
return;
}
obs_hotkeys_platform_t *plat = obs->hotkeys.platform_context;
// Translate the obs key back down to shift level 1 and then back to obs key.
xkb_keycode_t keycode = plat->obs_to_key[key];
xkb_keysym_t base_sym = plat->key_to_sym[0][keycode];
if (base_sym != 0) {
char buf[16] = {0};
if (xkb_keysym_to_utf8(base_sym, buf, 15)) {
// Normally obs uses capital letters but we are shift level 1 (lower case).
dstr_copy(dstr, buf);
}
}
if (key != OBS_KEY_NONE && dstr_is_empty(dstr)) {
dstr_copy(dstr, obs_key_to_name(key));
}
}
static obs_key_t obs_nix_wayland_key_from_virtual_key(int sym)
{
switch (sym) {
case XKB_KEY_0:
return OBS_KEY_0;
case XKB_KEY_1:
return OBS_KEY_1;
case XKB_KEY_2:
return OBS_KEY_2;
case XKB_KEY_3:
return OBS_KEY_3;
case XKB_KEY_4:
return OBS_KEY_4;
case XKB_KEY_5:
return OBS_KEY_5;
case XKB_KEY_6:
return OBS_KEY_6;
case XKB_KEY_7:
return OBS_KEY_7;
case XKB_KEY_8:
return OBS_KEY_8;
case XKB_KEY_9:
return OBS_KEY_9;
case XKB_KEY_A:
return OBS_KEY_A;
case XKB_KEY_a:
return OBS_KEY_A;
case XKB_KEY_Aacute:
return OBS_KEY_AACUTE;
case XKB_KEY_aacute:
return OBS_KEY_AACUTE;
case XKB_KEY_Acircumflex:
return OBS_KEY_ACIRCUMFLEX;
case XKB_KEY_acircumflex:
return OBS_KEY_ACIRCUMFLEX;
case XKB_KEY_acute:
return OBS_KEY_ACUTE;
case XKB_KEY_Adiaeresis:
return OBS_KEY_ADIAERESIS;
case XKB_KEY_adiaeresis:
return OBS_KEY_ADIAERESIS;
case XKB_KEY_AE:
return OBS_KEY_AE;
case XKB_KEY_ae:
return OBS_KEY_AE;
case XKB_KEY_Agrave:
return OBS_KEY_AGRAVE;
case XKB_KEY_agrave:
return OBS_KEY_AGRAVE;
case XKB_KEY_ampersand:
return OBS_KEY_AMPERSAND;
case XKB_KEY_apostrophe:
return OBS_KEY_APOSTROPHE;
case XKB_KEY_Aring:
return OBS_KEY_ARING;
case XKB_KEY_aring:
return OBS_KEY_ARING;
case XKB_KEY_asciicircum:
return OBS_KEY_ASCIICIRCUM;
case XKB_KEY_asciitilde:
return OBS_KEY_ASCIITILDE;
case XKB_KEY_asterisk:
return OBS_KEY_ASTERISK;
case XKB_KEY_at:
return OBS_KEY_AT;
case XKB_KEY_Atilde:
return OBS_KEY_ATILDE;
case XKB_KEY_atilde:
return OBS_KEY_ATILDE;
case XKB_KEY_B:
return OBS_KEY_B;
case XKB_KEY_b:
return OBS_KEY_B;
case XKB_KEY_backslash:
return OBS_KEY_BACKSLASH;
case XKB_KEY_BackSpace:
return OBS_KEY_BACKSPACE;
case XKB_KEY_BackTab:
return OBS_KEY_BACKTAB;
case XKB_KEY_bar:
return OBS_KEY_BAR;
case XKB_KEY_braceleft:
return OBS_KEY_BRACELEFT;
case XKB_KEY_braceright:
return OBS_KEY_BRACERIGHT;
case XKB_KEY_bracketleft:
return OBS_KEY_BRACKETLEFT;
case XKB_KEY_bracketright:
return OBS_KEY_BRACKETRIGHT;
case XKB_KEY_brokenbar:
return OBS_KEY_BROKENBAR;
case XKB_KEY_C:
return OBS_KEY_C;
case XKB_KEY_c:
return OBS_KEY_C;
case XKB_KEY_Cancel:
return OBS_KEY_CANCEL;
case XKB_KEY_Ccedilla:
return OBS_KEY_CCEDILLA;
case XKB_KEY_ccedilla:
return OBS_KEY_CCEDILLA;
case XKB_KEY_cedilla:
return OBS_KEY_CEDILLA;
case XKB_KEY_cent:
return OBS_KEY_CENT;
case XKB_KEY_Clear:
return OBS_KEY_CLEAR;
case XKB_KEY_Codeinput:
return OBS_KEY_CODEINPUT;
case XKB_KEY_colon:
return OBS_KEY_COLON;
case XKB_KEY_comma:
return OBS_KEY_COMMA;
case XKB_KEY_copyright:
return OBS_KEY_COPYRIGHT;
case XKB_KEY_currency:
return OBS_KEY_CURRENCY;
case XKB_KEY_D:
return OBS_KEY_D;
case XKB_KEY_d:
return OBS_KEY_D;
case XKB_KEY_dead_abovedot:
return OBS_KEY_DEAD_ABOVEDOT;
case XKB_KEY_dead_abovering:
return OBS_KEY_DEAD_ABOVERING;
case XKB_KEY_dead_acute:
return OBS_KEY_DEAD_ACUTE;
case XKB_KEY_dead_belowdot:
return OBS_KEY_DEAD_BELOWDOT;
case XKB_KEY_dead_breve:
return OBS_KEY_DEAD_BREVE;
case XKB_KEY_dead_caron:
return OBS_KEY_DEAD_CARON;
case XKB_KEY_dead_cedilla:
return OBS_KEY_DEAD_CEDILLA;
case XKB_KEY_dead_circumflex:
return OBS_KEY_DEAD_CIRCUMFLEX;
case XKB_KEY_dead_diaeresis:
return OBS_KEY_DEAD_DIAERESIS;
case XKB_KEY_dead_doubleacute:
return OBS_KEY_DEAD_DOUBLEACUTE;
case XKB_KEY_dead_grave:
return OBS_KEY_DEAD_GRAVE;
case XKB_KEY_dead_hook:
return OBS_KEY_DEAD_HOOK;
case XKB_KEY_dead_horn:
return OBS_KEY_DEAD_HORN;
case XKB_KEY_dead_iota:
return OBS_KEY_DEAD_IOTA;
case XKB_KEY_dead_macron:
return OBS_KEY_DEAD_MACRON;
case XKB_KEY_dead_ogonek:
return OBS_KEY_DEAD_OGONEK;
case XKB_KEY_dead_semivoiced_sound:
return OBS_KEY_DEAD_SEMIVOICED_SOUND;
case XKB_KEY_dead_tilde:
return OBS_KEY_DEAD_TILDE;
case XKB_KEY_dead_voiced_sound:
return OBS_KEY_DEAD_VOICED_SOUND;
case XKB_KEY_degree:
return OBS_KEY_DEGREE;
case XKB_KEY_Delete:
return OBS_KEY_DELETE;
case XKB_KEY_diaeresis:
return OBS_KEY_DIAERESIS;
case XKB_KEY_division:
return OBS_KEY_DIVISION;
case XKB_KEY_dollar:
return OBS_KEY_DOLLAR;
case XKB_KEY_Down:
return OBS_KEY_DOWN;
case XKB_KEY_E:
return OBS_KEY_E;
case XKB_KEY_e:
return OBS_KEY_E;
case XKB_KEY_Eacute:
return OBS_KEY_EACUTE;
case XKB_KEY_eacute:
return OBS_KEY_EACUTE;
case XKB_KEY_Ecircumflex:
return OBS_KEY_ECIRCUMFLEX;
case XKB_KEY_ecircumflex:
return OBS_KEY_ECIRCUMFLEX;
case XKB_KEY_Ediaeresis:
return OBS_KEY_EDIAERESIS;
case XKB_KEY_ediaeresis:
return OBS_KEY_EDIAERESIS;
case XKB_KEY_Egrave:
return OBS_KEY_EGRAVE;
case XKB_KEY_egrave:
return OBS_KEY_EGRAVE;
case XKB_KEY_Eisu_Shift:
return OBS_KEY_EISU_SHIFT;
case XKB_KEY_Eisu_toggle:
return OBS_KEY_EISU_TOGGLE;
case XKB_KEY_End:
return OBS_KEY_END;
case XKB_KEY_equal:
return OBS_KEY_EQUAL;
case XKB_KEY_Escape:
return OBS_KEY_ESCAPE;
case XKB_KEY_Eth:
return OBS_KEY_ETH;
case XKB_KEY_eth:
return OBS_KEY_ETH;
case XKB_KEY_exclam:
return OBS_KEY_EXCLAM;
case XKB_KEY_exclamdown:
return OBS_KEY_EXCLAMDOWN;
case XKB_KEY_Execute:
return OBS_KEY_EXECUTE;
case XKB_KEY_F:
return OBS_KEY_F;
case XKB_KEY_f:
return OBS_KEY_F;
case XKB_KEY_F1:
return OBS_KEY_F1;
case XKB_KEY_F10:
return OBS_KEY_F10;
case XKB_KEY_F11:
return OBS_KEY_F11;
case XKB_KEY_F12:
return OBS_KEY_F12;
case XKB_KEY_F13:
return OBS_KEY_F13;
case XKB_KEY_F14:
return OBS_KEY_F14;
case XKB_KEY_F15:
return OBS_KEY_F15;
case XKB_KEY_F16:
return OBS_KEY_F16;
case XKB_KEY_F17:
return OBS_KEY_F17;
case XKB_KEY_F18:
return OBS_KEY_F18;
case XKB_KEY_F19:
return OBS_KEY_F19;
case XKB_KEY_F2:
return OBS_KEY_F2;
case XKB_KEY_F20:
return OBS_KEY_F20;
case XKB_KEY_F21:
return OBS_KEY_F21;
case XKB_KEY_F22:
return OBS_KEY_F22;
case XKB_KEY_F23:
return OBS_KEY_F23;
case XKB_KEY_F24:
return OBS_KEY_F24;
case XKB_KEY_F25:
return OBS_KEY_F25;
case XKB_KEY_F26:
return OBS_KEY_F26;
case XKB_KEY_F27:
return OBS_KEY_F27;
case XKB_KEY_F28:
return OBS_KEY_F28;
case XKB_KEY_F29:
return OBS_KEY_F29;
case XKB_KEY_F3:
return OBS_KEY_F3;
case XKB_KEY_F30:
return OBS_KEY_F30;
case XKB_KEY_F31:
return OBS_KEY_F31;
case XKB_KEY_F32:
return OBS_KEY_F32;
case XKB_KEY_F33:
return OBS_KEY_F33;
case XKB_KEY_F34:
return OBS_KEY_F34;
case XKB_KEY_F35:
return OBS_KEY_F35;
case XKB_KEY_F4:
return OBS_KEY_F4;
case XKB_KEY_F5:
return OBS_KEY_F5;
case XKB_KEY_F6:
return OBS_KEY_F6;
case XKB_KEY_F7:
return OBS_KEY_F7;
case XKB_KEY_F8:
return OBS_KEY_F8;
case XKB_KEY_F9:
return OBS_KEY_F9;
case XKB_KEY_Find:
return OBS_KEY_FIND;
case XKB_KEY_G:
return OBS_KEY_G;
case XKB_KEY_g:
return OBS_KEY_G;
case XKB_KEY_greater:
return OBS_KEY_GREATER;
case XKB_KEY_guillemotleft:
return OBS_KEY_GUILLEMOTLEFT;
case XKB_KEY_guillemotright:
return OBS_KEY_GUILLEMOTRIGHT;
case XKB_KEY_H:
return OBS_KEY_H;
case XKB_KEY_h:
return OBS_KEY_H;
case XKB_KEY_Hangul:
return OBS_KEY_HANGUL;
case XKB_KEY_Hangul_Banja:
return OBS_KEY_HANGUL_BANJA;
case XKB_KEY_Hangul_End:
return OBS_KEY_HANGUL_END;
case XKB_KEY_Hangul_Hanja:
return OBS_KEY_HANGUL_HANJA;
case XKB_KEY_Hangul_Jamo:
return OBS_KEY_HANGUL_JAMO;
case XKB_KEY_Hangul_Jeonja:
return OBS_KEY_HANGUL_JEONJA;
case XKB_KEY_Hangul_PostHanja:
return OBS_KEY_HANGUL_POSTHANJA;
case XKB_KEY_Hangul_PreHanja:
return OBS_KEY_HANGUL_PREHANJA;
case XKB_KEY_Hangul_Romaja:
return OBS_KEY_HANGUL_ROMAJA;
case XKB_KEY_Hangul_Special:
return OBS_KEY_HANGUL_SPECIAL;
case XKB_KEY_Hangul_Start:
return OBS_KEY_HANGUL_START;
case XKB_KEY_Hankaku:
return OBS_KEY_HANKAKU;
case XKB_KEY_Help:
return OBS_KEY_HELP;
case XKB_KEY_Henkan:
return OBS_KEY_HENKAN;
case XKB_KEY_Hiragana:
return OBS_KEY_HIRAGANA;
case XKB_KEY_Hiragana_Katakana:
return OBS_KEY_HIRAGANA_KATAKANA;
case XKB_KEY_Home:
return OBS_KEY_HOME;
case XKB_KEY_Hyper_L:
return OBS_KEY_HYPER_L;
case XKB_KEY_Hyper_R:
return OBS_KEY_HYPER_R;
case XKB_KEY_hyphen:
return OBS_KEY_HYPHEN;
case XKB_KEY_I:
return OBS_KEY_I;
case XKB_KEY_i:
return OBS_KEY_I;
case XKB_KEY_Iacute:
return OBS_KEY_IACUTE;
case XKB_KEY_iacute:
return OBS_KEY_IACUTE;
case XKB_KEY_Icircumflex:
return OBS_KEY_ICIRCUMFLEX;
case XKB_KEY_icircumflex:
return OBS_KEY_ICIRCUMFLEX;
case XKB_KEY_Idiaeresis:
return OBS_KEY_IDIAERESIS;
case XKB_KEY_idiaeresis:
return OBS_KEY_IDIAERESIS;
case XKB_KEY_Igrave:
return OBS_KEY_IGRAVE;
case XKB_KEY_igrave:
return OBS_KEY_IGRAVE;
case XKB_KEY_Insert:
return OBS_KEY_INSERT;
case XKB_KEY_J:
return OBS_KEY_J;
case XKB_KEY_j:
return OBS_KEY_J;
case XKB_KEY_K:
return OBS_KEY_K;
case XKB_KEY_k:
return OBS_KEY_K;
case XKB_KEY_Kana_Lock:
return OBS_KEY_KANA_LOCK;
case XKB_KEY_Kana_Shift:
return OBS_KEY_KANA_SHIFT;
case XKB_KEY_Kanji:
return OBS_KEY_KANJI;
case XKB_KEY_Katakana:
return OBS_KEY_KATAKANA;
case XKB_KEY_L:
return OBS_KEY_L;
case XKB_KEY_l:
return OBS_KEY_L;
case XKB_KEY_Left:
return OBS_KEY_LEFT;
case XKB_KEY_less:
return OBS_KEY_LESS;
case XKB_KEY_M:
return OBS_KEY_M;
case XKB_KEY_m:
return OBS_KEY_M;
case XKB_KEY_macron:
return OBS_KEY_MACRON;
case XKB_KEY_masculine:
return OBS_KEY_MASCULINE;
case XKB_KEY_Massyo:
return OBS_KEY_MASSYO;
case XKB_KEY_Menu:
return OBS_KEY_MENU;
case XKB_KEY_minus:
return OBS_KEY_MINUS;
case XKB_KEY_Mode_switch:
return OBS_KEY_MODE_SWITCH;
case XKB_KEY_mu:
return OBS_KEY_MU;
case XKB_KEY_Muhenkan:
return OBS_KEY_MUHENKAN;
case XKB_KEY_MultipleCandidate:
return OBS_KEY_MULTIPLECANDIDATE;
case XKB_KEY_multiply:
return OBS_KEY_MULTIPLY;
case XKB_KEY_Multi_key:
return OBS_KEY_MULTI_KEY;
case XKB_KEY_N:
return OBS_KEY_N;
case XKB_KEY_n:
return OBS_KEY_N;
case XKB_KEY_nobreakspace:
return OBS_KEY_NOBREAKSPACE;
case XKB_KEY_notsign:
return OBS_KEY_NOTSIGN;
case XKB_KEY_Ntilde:
return OBS_KEY_NTILDE;
case XKB_KEY_ntilde:
return OBS_KEY_NTILDE;
case XKB_KEY_numbersign:
return OBS_KEY_NUMBERSIGN;
case XKB_KEY_O:
return OBS_KEY_O;
case XKB_KEY_o:
return OBS_KEY_O;
case XKB_KEY_Oacute:
return OBS_KEY_OACUTE;
case XKB_KEY_oacute:
return OBS_KEY_OACUTE;
case XKB_KEY_Ocircumflex:
return OBS_KEY_OCIRCUMFLEX;
case XKB_KEY_ocircumflex:
return OBS_KEY_OCIRCUMFLEX;
case XKB_KEY_Odiaeresis:
return OBS_KEY_ODIAERESIS;
case XKB_KEY_odiaeresis:
return OBS_KEY_ODIAERESIS;
case XKB_KEY_Ograve:
return OBS_KEY_OGRAVE;
case XKB_KEY_ograve:
return OBS_KEY_OGRAVE;
case XKB_KEY_onehalf:
return OBS_KEY_ONEHALF;
case XKB_KEY_onequarter:
return OBS_KEY_ONEQUARTER;
case XKB_KEY_onesuperior:
return OBS_KEY_ONESUPERIOR;
case XKB_KEY_Ooblique:
return OBS_KEY_OOBLIQUE;
case XKB_KEY_ooblique:
return OBS_KEY_OOBLIQUE;
case XKB_KEY_ordfeminine:
return OBS_KEY_ORDFEMININE;
case XKB_KEY_Otilde:
return OBS_KEY_OTILDE;
case XKB_KEY_otilde:
return OBS_KEY_OTILDE;
case XKB_KEY_P:
return OBS_KEY_P;
case XKB_KEY_p:
return OBS_KEY_P;
case XKB_KEY_paragraph:
return OBS_KEY_PARAGRAPH;
case XKB_KEY_parenleft:
return OBS_KEY_PARENLEFT;
case XKB_KEY_parenright:
return OBS_KEY_PARENRIGHT;
case XKB_KEY_Pause:
return OBS_KEY_PAUSE;
case XKB_KEY_percent:
return OBS_KEY_PERCENT;
case XKB_KEY_period:
return OBS_KEY_PERIOD;
case XKB_KEY_periodcentered:
return OBS_KEY_PERIODCENTERED;
case XKB_KEY_plus:
return OBS_KEY_PLUS;
case XKB_KEY_plusminus:
return OBS_KEY_PLUSMINUS;
case XKB_KEY_PreviousCandidate:
return OBS_KEY_PREVIOUSCANDIDATE;
case XKB_KEY_Print:
return OBS_KEY_PRINT;
case XKB_KEY_Q:
return OBS_KEY_Q;
case XKB_KEY_q:
return OBS_KEY_Q;
case XKB_KEY_question:
return OBS_KEY_QUESTION;
case XKB_KEY_questiondown:
return OBS_KEY_QUESTIONDOWN;
case XKB_KEY_quotedbl:
return OBS_KEY_QUOTEDBL;
case XKB_KEY_quoteleft:
return OBS_KEY_QUOTELEFT;
case XKB_KEY_R:
return OBS_KEY_R;
case XKB_KEY_r:
return OBS_KEY_R;
case XKB_KEY_Redo:
return OBS_KEY_REDO;
case XKB_KEY_registered:
return OBS_KEY_REGISTERED;
case XKB_KEY_Return:
return OBS_KEY_RETURN;
case XKB_KEY_Right:
return OBS_KEY_RIGHT;
case XKB_KEY_Romaji:
return OBS_KEY_ROMAJI;
case XKB_KEY_S:
return OBS_KEY_S;
case XKB_KEY_s:
return OBS_KEY_S;
case XKB_KEY_section:
return OBS_KEY_SECTION;
case XKB_KEY_Select:
return OBS_KEY_SELECT;
case XKB_KEY_semicolon:
return OBS_KEY_SEMICOLON;
case XKB_KEY_SingleCandidate:
return OBS_KEY_SINGLECANDIDATE;
case XKB_KEY_slash:
return OBS_KEY_SLASH;
case XKB_KEY_space:
return OBS_KEY_SPACE;
case XKB_KEY_ssharp:
return OBS_KEY_SSHARP;
case XKB_KEY_sterling:
return OBS_KEY_STERLING;
case XKB_KEY_T:
return OBS_KEY_T;
case XKB_KEY_t:
return OBS_KEY_T;
case XKB_KEY_Tab:
return OBS_KEY_TAB;
case XKB_KEY_Thorn:
return OBS_KEY_THORN;
case XKB_KEY_thorn:
return OBS_KEY_THORN;
case XKB_KEY_threequarters:
return OBS_KEY_THREEQUARTERS;
case XKB_KEY_threesuperior:
return OBS_KEY_THREESUPERIOR;
case XKB_KEY_Touroku:
return OBS_KEY_TOUROKU;
case XKB_KEY_twosuperior:
return OBS_KEY_TWOSUPERIOR;
case XKB_KEY_U:
return OBS_KEY_U;
case XKB_KEY_u:
return OBS_KEY_U;
case XKB_KEY_Uacute:
return OBS_KEY_UACUTE;
case XKB_KEY_uacute:
return OBS_KEY_UACUTE;
case XKB_KEY_Ucircumflex:
return OBS_KEY_UCIRCUMFLEX;
case XKB_KEY_ucircumflex:
return OBS_KEY_UCIRCUMFLEX;
case XKB_KEY_Udiaeresis:
return OBS_KEY_UDIAERESIS;
case XKB_KEY_udiaeresis:
return OBS_KEY_UDIAERESIS;
case XKB_KEY_Ugrave:
return OBS_KEY_UGRAVE;
case XKB_KEY_ugrave:
return OBS_KEY_UGRAVE;
case XKB_KEY_underscore:
return OBS_KEY_UNDERSCORE;
case XKB_KEY_Undo:
return OBS_KEY_UNDO;
case XKB_KEY_Up:
return OBS_KEY_UP;
case XKB_KEY_V:
return OBS_KEY_V;
case XKB_KEY_v:
return OBS_KEY_V;
case XKB_KEY_W:
return OBS_KEY_W;
case XKB_KEY_w:
return OBS_KEY_W;
case XKB_KEY_X:
return OBS_KEY_X;
case XKB_KEY_x:
return OBS_KEY_X;
case XKB_KEY_Y: