-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathimgui_keyboard.cpp
More file actions
1799 lines (1652 loc) · 80.4 KB
/
Copy pathimgui_keyboard.cpp
File metadata and controls
1799 lines (1652 loc) · 80.4 KB
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
#include "imgui_keyboard.h"
#include "imgui_internal.h"
namespace ImKeyboard {
#ifndef IMGUI_DISABLE
ImGuiKeyboardStyle::ImGuiKeyboardStyle() {
KeyUnit = 34.0f;
SectionGap = 15.0f;
KeyBorderSize = 1.0f;
KeyRounding = 3.0f;
KeyFaceRounding = 2.0f;
KeyFaceBorderSize = 2.0f;
KeyFaceOffset = ImVec2(4.0f, 3.0f);
KeyLabelOffset = ImVec2(6.0f, 4.0f);
BoardPadding = 5.0f;
BoardRounding = 5.0f;
Colors[ImGuiKeyboardCol_BoardBackground] = ImVec4(0.2f, 0.2f, 0.2f, 0.0f); // Dark gray
Colors[ImGuiKeyboardCol_KeyBackground] = ImVec4(0.8f, 0.8f, 0.8f, 1.0f); // Light gray
Colors[ImGuiKeyboardCol_KeyBorder] = ImVec4(0.094f, 0.094f, 0.094f, 1.0f); // Dark gray
Colors[ImGuiKeyboardCol_KeyFaceBorder] = ImVec4(0.757f, 0.757f, 0.757f, 1.0f); // Medium gray
Colors[ImGuiKeyboardCol_KeyFace] = ImVec4(0.988f, 0.988f, 0.988f, 1.0f); // Near white
Colors[ImGuiKeyboardCol_KeyLabel] = ImVec4(0.25f, 0.25f, 0.25f, 1.0f); // Dark text
Colors[ImGuiKeyboardCol_KeyPressed] = ImVec4(1.0f, 0.0f, 0.0f, 0.5f); // Red
Colors[ImGuiKeyboardCol_KeyHighlighted] = ImVec4(0.0f, 1.0f, 0.0f, 0.5f); // Green
Colors[ImGuiKeyboardCol_KeyPressedHighlighted] = ImVec4(1.0f, 1.0f, 0.0f, 0.5f); // Yellow
Colors[ImGuiKeyboardCol_KeyRecorded] = ImVec4(0.0f, 0.5f, 1.0f, 0.5f); // Blue (for keybinding selection)
}
struct KeyLayoutData {
float X, Y; // Position in key units (not pixels)
float Width, Height; // Size in key units (1.0 = standard key)
const char *Label;
const char *ShiftLabel; // Label when Shift is pressed (nullptr if same as Label)
ImGuiKey Key;
};
struct KeyboardContext {
ImVector<ImGuiKey> HighlightedKeys;
ImVector<ImGuiKey> RecordedKeys;
ImGuiKeyboardStyle Style;
KeyboardContext() {
}
};
static KeyboardContext *GetContext() {
static KeyboardContext ctx;
return &ctx;
}
ImGuiKeyboardStyle &GetStyle() {
return GetContext()->Style;
}
static ImU32 GetColorU32(ImGuiKeyboardCol idx) {
return ImGui::ColorConvertFloat4ToU32(GetContext()->Style.Colors[idx]);
}
static bool IsKeyHighlighted(ImGuiKey key) {
KeyboardContext *ctx = GetContext();
for (int i = 0; i < ctx->HighlightedKeys.Size; i++) {
if (ctx->HighlightedKeys[i] == key) {
return true;
}
}
return false;
}
static bool IsKeyRecorded(ImGuiKey key) {
KeyboardContext *ctx = GetContext();
for (int i = 0; i < ctx->RecordedKeys.Size; i++) {
if (ctx->RecordedKeys[i] == key) {
return true;
}
}
return false;
}
// Numeric keypad layout
static const KeyLayoutData numpad_keys[] = {
// Row 0 - NumLock, /, *, -
{0.0f, 0.0f, 1.0f, 1.0f, "Num", nullptr, ImGuiKey_NumLock},
{1.0f, 0.0f, 1.0f, 1.0f, "/", nullptr, ImGuiKey_KeypadDivide},
{2.0f, 0.0f, 1.0f, 1.0f, "*", nullptr, ImGuiKey_KeypadMultiply},
{3.0f, 0.0f, 1.0f, 1.0f, "-", nullptr, ImGuiKey_KeypadSubtract},
// Row 1 - 7, 8, 9, + (+ spans 2 rows)
{0.0f, 1.0f, 1.0f, 1.0f, "7", nullptr, ImGuiKey_Keypad7},
{1.0f, 1.0f, 1.0f, 1.0f, "8", nullptr, ImGuiKey_Keypad8},
{2.0f, 1.0f, 1.0f, 1.0f, "9", nullptr, ImGuiKey_Keypad9},
{3.0f, 1.0f, 1.0f, 2.0f, "+", nullptr, ImGuiKey_KeypadAdd},
// Row 2 - 4, 5, 6
{0.0f, 2.0f, 1.0f, 1.0f, "4", nullptr, ImGuiKey_Keypad4},
{1.0f, 2.0f, 1.0f, 1.0f, "5", nullptr, ImGuiKey_Keypad5},
{2.0f, 2.0f, 1.0f, 1.0f, "6", nullptr, ImGuiKey_Keypad6},
// Row 3 - 1, 2, 3, Enter (Enter spans 2 rows)
{0.0f, 3.0f, 1.0f, 1.0f, "1", nullptr, ImGuiKey_Keypad1},
{1.0f, 3.0f, 1.0f, 1.0f, "2", nullptr, ImGuiKey_Keypad2},
{2.0f, 3.0f, 1.0f, 1.0f, "3", nullptr, ImGuiKey_Keypad3},
{3.0f, 3.0f, 1.0f, 2.0f, "Ent", nullptr, ImGuiKey_KeypadEnter},
// Row 4 - 0 (spans 2 columns), .
{0.0f, 4.0f, 2.0f, 1.0f, "0", nullptr, ImGuiKey_Keypad0},
{2.0f, 4.0f, 1.0f, 1.0f, ".", nullptr, ImGuiKey_KeypadDecimal},
};
// Function key row (F1-F12 + Esc)
static const KeyLayoutData function_row_keys[] = {
{0.0f, 0.0f, 1.0f, 1.0f, "Esc", nullptr, ImGuiKey_Escape},
// Gap
{2.0f, 0.0f, 1.0f, 1.0f, "F1", nullptr, ImGuiKey_F1},
{3.0f, 0.0f, 1.0f, 1.0f, "F2", nullptr, ImGuiKey_F2},
{4.0f, 0.0f, 1.0f, 1.0f, "F3", nullptr, ImGuiKey_F3},
{5.0f, 0.0f, 1.0f, 1.0f, "F4", nullptr, ImGuiKey_F4},
// Gap
{6.5f, 0.0f, 1.0f, 1.0f, "F5", nullptr, ImGuiKey_F5},
{7.5f, 0.0f, 1.0f, 1.0f, "F6", nullptr, ImGuiKey_F6},
{8.5f, 0.0f, 1.0f, 1.0f, "F7", nullptr, ImGuiKey_F7},
{9.5f, 0.0f, 1.0f, 1.0f, "F8", nullptr, ImGuiKey_F8},
// Gap
{11.0f, 0.0f, 1.0f, 1.0f, "F9", nullptr, ImGuiKey_F9},
{12.0f, 0.0f, 1.0f, 1.0f, "F10", nullptr, ImGuiKey_F10},
{13.0f, 0.0f, 1.0f, 1.0f, "F11", nullptr, ImGuiKey_F11},
{14.0f, 0.0f, 1.0f, 1.0f, "F12", nullptr, ImGuiKey_F12},
};
// Print, Scroll, Pause - rendered separately to align with nav cluster using section_gap
static const KeyLayoutData function_row_nav_keys[] = {
{0.0f, 0.0f, 1.0f, 1.0f, "Prt", nullptr, ImGuiKey_PrintScreen},
{1.0f, 0.0f, 1.0f, 1.0f, "Scr", nullptr, ImGuiKey_ScrollLock},
{2.0f, 0.0f, 1.0f, 1.0f, "Pse", nullptr, ImGuiKey_Pause},
};
// Apple layout: F13, F14, F15 instead of Print Screen, Scroll Lock, Pause
static const KeyLayoutData apple_function_row_nav_keys[] = {
{0.0f, 0.0f, 1.0f, 1.0f, "F13", nullptr, ImGuiKey_PrintScreen},
{1.0f, 0.0f, 1.0f, 1.0f, "F14", nullptr, ImGuiKey_ScrollLock},
{2.0f, 0.0f, 1.0f, 1.0f, "F15", nullptr, ImGuiKey_Pause},
};
// Navigation cluster (Insert, Delete, Home, End, PageUp, PageDown, Arrows)
static const KeyLayoutData nav_cluster_keys[] = {
// Row 0 - Insert, Home, PageUp
{0.0f, 0.0f, 1.0f, 1.0f, "Ins", nullptr, ImGuiKey_Insert},
{1.0f, 0.0f, 1.0f, 1.0f, "Hm", nullptr, ImGuiKey_Home},
{2.0f, 0.0f, 1.0f, 1.0f, "PgU", nullptr, ImGuiKey_PageUp},
// Row 1 - Delete, End, PageDown
{0.0f, 1.0f, 1.0f, 1.0f, "Del", nullptr, ImGuiKey_Delete},
{1.0f, 1.0f, 1.0f, 1.0f, "End", nullptr, ImGuiKey_End},
{2.0f, 1.0f, 1.0f, 1.0f, "PgD", nullptr, ImGuiKey_PageDown},
// Row 3 - Arrow Up (centered) - aligned with bottom modifier row
{1.0f, 3.0f, 1.0f, 1.0f, "^", nullptr, ImGuiKey_UpArrow},
// Row 4 - Arrow Left, Down, Right
{0.0f, 4.0f, 1.0f, 1.0f, "<", nullptr, ImGuiKey_LeftArrow},
{1.0f, 4.0f, 1.0f, 1.0f, "v", nullptr, ImGuiKey_DownArrow},
{2.0f, 4.0f, 1.0f, 1.0f, ">", nullptr, ImGuiKey_RightArrow},
};
// Main keyboard - Number row (US layout shift symbols)
static const KeyLayoutData number_row_keys[] = {
{0.0f, 0.0f, 1.0f, 1.0f, "`", "~", ImGuiKey_GraveAccent},
{1.0f, 0.0f, 1.0f, 1.0f, "1", "!", ImGuiKey_1},
{2.0f, 0.0f, 1.0f, 1.0f, "2", "@", ImGuiKey_2},
{3.0f, 0.0f, 1.0f, 1.0f, "3", "#", ImGuiKey_3},
{4.0f, 0.0f, 1.0f, 1.0f, "4", "$", ImGuiKey_4},
{5.0f, 0.0f, 1.0f, 1.0f, "5", "%", ImGuiKey_5},
{6.0f, 0.0f, 1.0f, 1.0f, "6", "^", ImGuiKey_6},
{7.0f, 0.0f, 1.0f, 1.0f, "7", "&", ImGuiKey_7},
{8.0f, 0.0f, 1.0f, 1.0f, "8", "*", ImGuiKey_8},
{9.0f, 0.0f, 1.0f, 1.0f, "9", "(", ImGuiKey_9},
{10.0f, 0.0f, 1.0f, 1.0f, "0", ")", ImGuiKey_0},
{11.0f, 0.0f, 1.0f, 1.0f, "-", "_", ImGuiKey_Minus},
{12.0f, 0.0f, 1.0f, 1.0f, "=", "+", ImGuiKey_Equal},
{13.0f, 0.0f, 2.0f, 1.0f, "Back", nullptr, ImGuiKey_Backspace},
};
// German number row (QWERTZ layout shift symbols)
static const KeyLayoutData number_row_qwertz_keys[] = {
{0.0f, 0.0f, 1.0f, 1.0f, "^", nullptr, ImGuiKey_GraveAccent},
{1.0f, 0.0f, 1.0f, 1.0f, "1", "!", ImGuiKey_1},
{2.0f, 0.0f, 1.0f, 1.0f, "2", "\"", ImGuiKey_2},
{3.0f, 0.0f, 1.0f, 1.0f, "3", "\xc2\xa7", ImGuiKey_3},
{4.0f, 0.0f, 1.0f, 1.0f, "4", "$", ImGuiKey_4},
{5.0f, 0.0f, 1.0f, 1.0f, "5", "%", ImGuiKey_5},
{6.0f, 0.0f, 1.0f, 1.0f, "6", "&", ImGuiKey_6},
{7.0f, 0.0f, 1.0f, 1.0f, "7", "/", ImGuiKey_7},
{8.0f, 0.0f, 1.0f, 1.0f, "8", "(", ImGuiKey_8},
{9.0f, 0.0f, 1.0f, 1.0f, "9", ")", ImGuiKey_9},
{10.0f, 0.0f, 1.0f, 1.0f, "0", "=", ImGuiKey_0},
{11.0f, 0.0f, 1.0f, 1.0f, "\xc3\x9f", "?", ImGuiKey_Minus},
{12.0f, 0.0f, 1.0f, 1.0f, "'", "`", ImGuiKey_Equal},
{13.0f, 0.0f, 2.0f, 1.0f, "Back", nullptr, ImGuiKey_Backspace},
};
// French number row (AZERTY layout - numbers require shift)
static const KeyLayoutData number_row_azerty_keys[] = {
{0.0f, 0.0f, 1.0f, 1.0f, "2", nullptr, ImGuiKey_GraveAccent},
{1.0f, 0.0f, 1.0f, 1.0f, "&", "1", ImGuiKey_1},
{2.0f, 0.0f, 1.0f, 1.0f, "\xc3\xa9", "2", ImGuiKey_2},
{3.0f, 0.0f, 1.0f, 1.0f, "\"", "3", ImGuiKey_3},
{4.0f, 0.0f, 1.0f, 1.0f, "'", "4", ImGuiKey_4},
{5.0f, 0.0f, 1.0f, 1.0f, "(", "5", ImGuiKey_5},
{6.0f, 0.0f, 1.0f, 1.0f, "-", "6", ImGuiKey_6},
{7.0f, 0.0f, 1.0f, 1.0f, "\xc3\xa8", "7", ImGuiKey_7},
{8.0f, 0.0f, 1.0f, 1.0f, "_", "8", ImGuiKey_8},
{9.0f, 0.0f, 1.0f, 1.0f, "\xc3\xa7", "9", ImGuiKey_9},
{10.0f, 0.0f, 1.0f, 1.0f, "\xc3\xa0", "0", ImGuiKey_0},
{11.0f, 0.0f, 1.0f, 1.0f, ")", nullptr, ImGuiKey_Minus},
{12.0f, 0.0f, 1.0f, 1.0f, "=", "+", ImGuiKey_Equal},
{13.0f, 0.0f, 2.0f, 1.0f, "Back", nullptr, ImGuiKey_Backspace},
};
// QWERTY letter rows
static const KeyLayoutData qwerty_row1_keys[] = {
{0.0f, 0.0f, 1.5f, 1.0f, "Tab", nullptr, ImGuiKey_Tab},
{1.5f, 0.0f, 1.0f, 1.0f, "Q", nullptr, ImGuiKey_Q},
{2.5f, 0.0f, 1.0f, 1.0f, "W", nullptr, ImGuiKey_W},
{3.5f, 0.0f, 1.0f, 1.0f, "E", nullptr, ImGuiKey_E},
{4.5f, 0.0f, 1.0f, 1.0f, "R", nullptr, ImGuiKey_R},
{5.5f, 0.0f, 1.0f, 1.0f, "T", nullptr, ImGuiKey_T},
{6.5f, 0.0f, 1.0f, 1.0f, "Y", nullptr, ImGuiKey_Y},
{7.5f, 0.0f, 1.0f, 1.0f, "U", nullptr, ImGuiKey_U},
{8.5f, 0.0f, 1.0f, 1.0f, "I", nullptr, ImGuiKey_I},
{9.5f, 0.0f, 1.0f, 1.0f, "O", nullptr, ImGuiKey_O},
{10.5f, 0.0f, 1.0f, 1.0f, "P", nullptr, ImGuiKey_P},
{11.5f, 0.0f, 1.0f, 1.0f, "[", "{", ImGuiKey_LeftBracket},
{12.5f, 0.0f, 1.0f, 1.0f, "]", "}", ImGuiKey_RightBracket},
{13.5f, 0.0f, 1.5f, 1.0f, "\\", "|", ImGuiKey_Backslash},
};
static const KeyLayoutData qwerty_row2_keys[] = {
{0.0f, 0.0f, 1.75f, 1.0f, "Caps", nullptr, ImGuiKey_CapsLock},
{1.75f, 0.0f, 1.0f, 1.0f, "A", nullptr, ImGuiKey_A},
{2.75f, 0.0f, 1.0f, 1.0f, "S", nullptr, ImGuiKey_S},
{3.75f, 0.0f, 1.0f, 1.0f, "D", nullptr, ImGuiKey_D},
{4.75f, 0.0f, 1.0f, 1.0f, "F", nullptr, ImGuiKey_F},
{5.75f, 0.0f, 1.0f, 1.0f, "G", nullptr, ImGuiKey_G},
{6.75f, 0.0f, 1.0f, 1.0f, "H", nullptr, ImGuiKey_H},
{7.75f, 0.0f, 1.0f, 1.0f, "J", nullptr, ImGuiKey_J},
{8.75f, 0.0f, 1.0f, 1.0f, "K", nullptr, ImGuiKey_K},
{9.75f, 0.0f, 1.0f, 1.0f, "L", nullptr, ImGuiKey_L},
{10.75f, 0.0f, 1.0f, 1.0f, ";", ":", ImGuiKey_Semicolon},
{11.75f, 0.0f, 1.0f, 1.0f, "'", "\"", ImGuiKey_Apostrophe},
{12.75f, 0.0f, 2.25f, 1.0f, "Enter", nullptr, ImGuiKey_Enter},
};
static const KeyLayoutData qwerty_row3_keys[] = {
{0.0f, 0.0f, 2.25f, 1.0f, "Shift", nullptr, ImGuiKey_LeftShift},
{2.25f, 0.0f, 1.0f, 1.0f, "Z", nullptr, ImGuiKey_Z},
{3.25f, 0.0f, 1.0f, 1.0f, "X", nullptr, ImGuiKey_X},
{4.25f, 0.0f, 1.0f, 1.0f, "C", nullptr, ImGuiKey_C},
{5.25f, 0.0f, 1.0f, 1.0f, "V", nullptr, ImGuiKey_V},
{6.25f, 0.0f, 1.0f, 1.0f, "B", nullptr, ImGuiKey_B},
{7.25f, 0.0f, 1.0f, 1.0f, "N", nullptr, ImGuiKey_N},
{8.25f, 0.0f, 1.0f, 1.0f, "M", nullptr, ImGuiKey_M},
{9.25f, 0.0f, 1.0f, 1.0f, ",", "<", ImGuiKey_Comma},
{10.25f, 0.0f, 1.0f, 1.0f, ".", ">", ImGuiKey_Period},
{11.25f, 0.0f, 1.0f, 1.0f, "/", "?", ImGuiKey_Slash},
{12.25f, 0.0f, 2.75f, 1.0f, "Shift", nullptr, ImGuiKey_RightShift},
};
// QWERTZ letter rows (German layout - Y and Z swapped)
static const KeyLayoutData qwertz_row1_keys[] = {
{0.0f, 0.0f, 1.5f, 1.0f, "Tab", nullptr, ImGuiKey_Tab},
{1.5f, 0.0f, 1.0f, 1.0f, "Q", nullptr, ImGuiKey_Q},
{2.5f, 0.0f, 1.0f, 1.0f, "W", nullptr, ImGuiKey_W},
{3.5f, 0.0f, 1.0f, 1.0f, "E", nullptr, ImGuiKey_E},
{4.5f, 0.0f, 1.0f, 1.0f, "R", nullptr, ImGuiKey_R},
{5.5f, 0.0f, 1.0f, 1.0f, "T", nullptr, ImGuiKey_T},
{6.5f, 0.0f, 1.0f, 1.0f, "Z", nullptr, ImGuiKey_Z},
{7.5f, 0.0f, 1.0f, 1.0f, "U", nullptr, ImGuiKey_U},
{8.5f, 0.0f, 1.0f, 1.0f, "I", nullptr, ImGuiKey_I},
{9.5f, 0.0f, 1.0f, 1.0f, "O", nullptr, ImGuiKey_O},
{10.5f, 0.0f, 1.0f, 1.0f, "P", nullptr, ImGuiKey_P},
{11.5f, 0.0f, 1.0f, 1.0f, "\xc3\x9c", nullptr, ImGuiKey_LeftBracket},
{12.5f, 0.0f, 1.0f, 1.0f, "+", "*", ImGuiKey_RightBracket},
{13.5f, 0.0f, 1.5f, 1.0f, "#", "'", ImGuiKey_Backslash},
};
static const KeyLayoutData qwertz_row2_keys[] = {
{0.0f, 0.0f, 1.75f, 1.0f, "Caps", nullptr, ImGuiKey_CapsLock},
{1.75f, 0.0f, 1.0f, 1.0f, "A", nullptr, ImGuiKey_A},
{2.75f, 0.0f, 1.0f, 1.0f, "S", nullptr, ImGuiKey_S},
{3.75f, 0.0f, 1.0f, 1.0f, "D", nullptr, ImGuiKey_D},
{4.75f, 0.0f, 1.0f, 1.0f, "F", nullptr, ImGuiKey_F},
{5.75f, 0.0f, 1.0f, 1.0f, "G", nullptr, ImGuiKey_G},
{6.75f, 0.0f, 1.0f, 1.0f, "H", nullptr, ImGuiKey_H},
{7.75f, 0.0f, 1.0f, 1.0f, "J", nullptr, ImGuiKey_J},
{8.75f, 0.0f, 1.0f, 1.0f, "K", nullptr, ImGuiKey_K},
{9.75f, 0.0f, 1.0f, 1.0f, "L", nullptr, ImGuiKey_L},
{10.75f, 0.0f, 1.0f, 1.0f, "\xc3\x96", nullptr, ImGuiKey_Semicolon},
{11.75f, 0.0f, 1.0f, 1.0f, "\xc3\x84", nullptr, ImGuiKey_Apostrophe},
{12.75f, 0.0f, 2.25f, 1.0f, "Enter", nullptr, ImGuiKey_Enter},
};
static const KeyLayoutData qwertz_row3_keys[] = {
{0.0f, 0.0f, 2.25f, 1.0f, "Shift", nullptr, ImGuiKey_LeftShift},
{2.25f, 0.0f, 1.0f, 1.0f, "Y", nullptr, ImGuiKey_Y},
{3.25f, 0.0f, 1.0f, 1.0f, "X", nullptr, ImGuiKey_X},
{4.25f, 0.0f, 1.0f, 1.0f, "C", nullptr, ImGuiKey_C},
{5.25f, 0.0f, 1.0f, 1.0f, "V", nullptr, ImGuiKey_V},
{6.25f, 0.0f, 1.0f, 1.0f, "B", nullptr, ImGuiKey_B},
{7.25f, 0.0f, 1.0f, 1.0f, "N", nullptr, ImGuiKey_N},
{8.25f, 0.0f, 1.0f, 1.0f, "M", nullptr, ImGuiKey_M},
{9.25f, 0.0f, 1.0f, 1.0f, ",", ";", ImGuiKey_Comma},
{10.25f, 0.0f, 1.0f, 1.0f, ".", ":", ImGuiKey_Period},
{11.25f, 0.0f, 1.0f, 1.0f, "-", "_", ImGuiKey_Slash},
{12.25f, 0.0f, 2.75f, 1.0f, "Shift", nullptr, ImGuiKey_RightShift},
};
// AZERTY letter rows (French layout)
static const KeyLayoutData azerty_row1_keys[] = {
{0.0f, 0.0f, 1.5f, 1.0f, "Tab", nullptr, ImGuiKey_Tab},
{1.5f, 0.0f, 1.0f, 1.0f, "A", nullptr, ImGuiKey_A},
{2.5f, 0.0f, 1.0f, 1.0f, "Z", nullptr, ImGuiKey_Z},
{3.5f, 0.0f, 1.0f, 1.0f, "E", nullptr, ImGuiKey_E},
{4.5f, 0.0f, 1.0f, 1.0f, "R", nullptr, ImGuiKey_R},
{5.5f, 0.0f, 1.0f, 1.0f, "T", nullptr, ImGuiKey_T},
{6.5f, 0.0f, 1.0f, 1.0f, "Y", nullptr, ImGuiKey_Y},
{7.5f, 0.0f, 1.0f, 1.0f, "U", nullptr, ImGuiKey_U},
{8.5f, 0.0f, 1.0f, 1.0f, "I", nullptr, ImGuiKey_I},
{9.5f, 0.0f, 1.0f, 1.0f, "O", nullptr, ImGuiKey_O},
{10.5f, 0.0f, 1.0f, 1.0f, "P", nullptr, ImGuiKey_P},
{11.5f, 0.0f, 1.0f, 1.0f, "^", nullptr, ImGuiKey_LeftBracket},
{12.5f, 0.0f, 1.0f, 1.0f, "$", nullptr, ImGuiKey_RightBracket},
{13.5f, 0.0f, 1.5f, 1.0f, "*", nullptr, ImGuiKey_Backslash},
};
static const KeyLayoutData azerty_row2_keys[] = {
{0.0f, 0.0f, 1.75f, 1.0f, "Caps", nullptr, ImGuiKey_CapsLock},
{1.75f, 0.0f, 1.0f, 1.0f, "Q", nullptr, ImGuiKey_Q},
{2.75f, 0.0f, 1.0f, 1.0f, "S", nullptr, ImGuiKey_S},
{3.75f, 0.0f, 1.0f, 1.0f, "D", nullptr, ImGuiKey_D},
{4.75f, 0.0f, 1.0f, 1.0f, "F", nullptr, ImGuiKey_F},
{5.75f, 0.0f, 1.0f, 1.0f, "G", nullptr, ImGuiKey_G},
{6.75f, 0.0f, 1.0f, 1.0f, "H", nullptr, ImGuiKey_H},
{7.75f, 0.0f, 1.0f, 1.0f, "J", nullptr, ImGuiKey_J},
{8.75f, 0.0f, 1.0f, 1.0f, "K", nullptr, ImGuiKey_K},
{9.75f, 0.0f, 1.0f, 1.0f, "L", nullptr, ImGuiKey_L},
{10.75f, 0.0f, 1.0f, 1.0f, "M", nullptr, ImGuiKey_M},
{11.75f, 0.0f, 1.0f, 1.0f, "\xc3\xb9", "%", ImGuiKey_Apostrophe},
{12.75f, 0.0f, 2.25f, 1.0f, "Enter", nullptr, ImGuiKey_Enter},
};
static const KeyLayoutData azerty_row3_keys[] = {
{0.0f, 0.0f, 2.25f, 1.0f, "Shift", nullptr, ImGuiKey_LeftShift},
{2.25f, 0.0f, 1.0f, 1.0f, "W", nullptr, ImGuiKey_W},
{3.25f, 0.0f, 1.0f, 1.0f, "X", nullptr, ImGuiKey_X},
{4.25f, 0.0f, 1.0f, 1.0f, "C", nullptr, ImGuiKey_C},
{5.25f, 0.0f, 1.0f, 1.0f, "V", nullptr, ImGuiKey_V},
{6.25f, 0.0f, 1.0f, 1.0f, "B", nullptr, ImGuiKey_B},
{7.25f, 0.0f, 1.0f, 1.0f, "N", nullptr, ImGuiKey_N},
{8.25f, 0.0f, 1.0f, 1.0f, ",", "?", ImGuiKey_Comma},
{9.25f, 0.0f, 1.0f, 1.0f, ";", ".", ImGuiKey_Semicolon},
{10.25f, 0.0f, 1.0f, 1.0f, ":", "/", ImGuiKey_Period},
{11.25f, 0.0f, 1.0f, 1.0f, "!", nullptr, ImGuiKey_Slash},
{12.25f, 0.0f, 2.75f, 1.0f, "Shift", nullptr, ImGuiKey_RightShift},
};
// Colemak letter rows
static const KeyLayoutData colemak_row1_keys[] = {
{0.0f, 0.0f, 1.5f, 1.0f, "Tab", nullptr, ImGuiKey_Tab},
{1.5f, 0.0f, 1.0f, 1.0f, "Q", nullptr, ImGuiKey_Q},
{2.5f, 0.0f, 1.0f, 1.0f, "W", nullptr, ImGuiKey_W},
{3.5f, 0.0f, 1.0f, 1.0f, "F", nullptr, ImGuiKey_F},
{4.5f, 0.0f, 1.0f, 1.0f, "P", nullptr, ImGuiKey_P},
{5.5f, 0.0f, 1.0f, 1.0f, "G", nullptr, ImGuiKey_G},
{6.5f, 0.0f, 1.0f, 1.0f, "J", nullptr, ImGuiKey_J},
{7.5f, 0.0f, 1.0f, 1.0f, "L", nullptr, ImGuiKey_L},
{8.5f, 0.0f, 1.0f, 1.0f, "U", nullptr, ImGuiKey_U},
{9.5f, 0.0f, 1.0f, 1.0f, "Y", nullptr, ImGuiKey_Y},
{10.5f, 0.0f, 1.0f, 1.0f, ";", ":", ImGuiKey_Semicolon},
{11.5f, 0.0f, 1.0f, 1.0f, "[", "{", ImGuiKey_LeftBracket},
{12.5f, 0.0f, 1.0f, 1.0f, "]", "}", ImGuiKey_RightBracket},
{13.5f, 0.0f, 1.5f, 1.0f, "\\", "|", ImGuiKey_Backslash},
};
static const KeyLayoutData colemak_row2_keys[] = {
{0.0f, 0.0f, 1.75f, 1.0f, "Bksp", nullptr, ImGuiKey_Backspace},
{1.75f, 0.0f, 1.0f, 1.0f, "A", nullptr, ImGuiKey_A},
{2.75f, 0.0f, 1.0f, 1.0f, "R", nullptr, ImGuiKey_R},
{3.75f, 0.0f, 1.0f, 1.0f, "S", nullptr, ImGuiKey_S},
{4.75f, 0.0f, 1.0f, 1.0f, "T", nullptr, ImGuiKey_T},
{5.75f, 0.0f, 1.0f, 1.0f, "D", nullptr, ImGuiKey_D},
{6.75f, 0.0f, 1.0f, 1.0f, "H", nullptr, ImGuiKey_H},
{7.75f, 0.0f, 1.0f, 1.0f, "N", nullptr, ImGuiKey_N},
{8.75f, 0.0f, 1.0f, 1.0f, "E", nullptr, ImGuiKey_E},
{9.75f, 0.0f, 1.0f, 1.0f, "I", nullptr, ImGuiKey_I},
{10.75f, 0.0f, 1.0f, 1.0f, "O", nullptr, ImGuiKey_O},
{11.75f, 0.0f, 1.0f, 1.0f, "'", "\"", ImGuiKey_Apostrophe},
{12.75f, 0.0f, 2.25f, 1.0f, "Enter", nullptr, ImGuiKey_Enter},
};
static const KeyLayoutData colemak_row3_keys[] = {
{0.0f, 0.0f, 2.25f, 1.0f, "Shift", nullptr, ImGuiKey_LeftShift},
{2.25f, 0.0f, 1.0f, 1.0f, "Z", nullptr, ImGuiKey_Z},
{3.25f, 0.0f, 1.0f, 1.0f, "X", nullptr, ImGuiKey_X},
{4.25f, 0.0f, 1.0f, 1.0f, "C", nullptr, ImGuiKey_C},
{5.25f, 0.0f, 1.0f, 1.0f, "V", nullptr, ImGuiKey_V},
{6.25f, 0.0f, 1.0f, 1.0f, "B", nullptr, ImGuiKey_B},
{7.25f, 0.0f, 1.0f, 1.0f, "K", nullptr, ImGuiKey_K},
{8.25f, 0.0f, 1.0f, 1.0f, "M", nullptr, ImGuiKey_M},
{9.25f, 0.0f, 1.0f, 1.0f, ",", "<", ImGuiKey_Comma},
{10.25f, 0.0f, 1.0f, 1.0f, ".", ">", ImGuiKey_Period},
{11.25f, 0.0f, 1.0f, 1.0f, "/", "?", ImGuiKey_Slash},
{12.25f, 0.0f, 2.75f, 1.0f, "Shift", nullptr, ImGuiKey_RightShift},
};
// Dvorak letter rows
static const KeyLayoutData dvorak_row1_keys[] = {
{0.0f, 0.0f, 1.5f, 1.0f, "Tab", nullptr, ImGuiKey_Tab}, {1.5f, 0.0f, 1.0f, 1.0f, "'", "\"", ImGuiKey_Apostrophe},
{2.5f, 0.0f, 1.0f, 1.0f, ",", "<", ImGuiKey_Comma}, {3.5f, 0.0f, 1.0f, 1.0f, ".", ">", ImGuiKey_Period},
{4.5f, 0.0f, 1.0f, 1.0f, "P", nullptr, ImGuiKey_P}, {5.5f, 0.0f, 1.0f, 1.0f, "Y", nullptr, ImGuiKey_Y},
{6.5f, 0.0f, 1.0f, 1.0f, "F", nullptr, ImGuiKey_F}, {7.5f, 0.0f, 1.0f, 1.0f, "G", nullptr, ImGuiKey_G},
{8.5f, 0.0f, 1.0f, 1.0f, "C", nullptr, ImGuiKey_C}, {9.5f, 0.0f, 1.0f, 1.0f, "R", nullptr, ImGuiKey_R},
{10.5f, 0.0f, 1.0f, 1.0f, "L", nullptr, ImGuiKey_L}, {11.5f, 0.0f, 1.0f, 1.0f, "/", "?", ImGuiKey_Slash},
{12.5f, 0.0f, 1.0f, 1.0f, "=", "+", ImGuiKey_Equal}, {13.5f, 0.0f, 1.5f, 1.0f, "\\", "|", ImGuiKey_Backslash},
};
static const KeyLayoutData dvorak_row2_keys[] = {
{0.0f, 0.0f, 1.75f, 1.0f, "Caps", nullptr, ImGuiKey_CapsLock}, {1.75f, 0.0f, 1.0f, 1.0f, "A", nullptr, ImGuiKey_A},
{2.75f, 0.0f, 1.0f, 1.0f, "O", nullptr, ImGuiKey_O}, {3.75f, 0.0f, 1.0f, 1.0f, "E", nullptr, ImGuiKey_E},
{4.75f, 0.0f, 1.0f, 1.0f, "U", nullptr, ImGuiKey_U}, {5.75f, 0.0f, 1.0f, 1.0f, "I", nullptr, ImGuiKey_I},
{6.75f, 0.0f, 1.0f, 1.0f, "D", nullptr, ImGuiKey_D}, {7.75f, 0.0f, 1.0f, 1.0f, "H", nullptr, ImGuiKey_H},
{8.75f, 0.0f, 1.0f, 1.0f, "T", nullptr, ImGuiKey_T}, {9.75f, 0.0f, 1.0f, 1.0f, "N", nullptr, ImGuiKey_N},
{10.75f, 0.0f, 1.0f, 1.0f, "S", nullptr, ImGuiKey_S}, {11.75f, 0.0f, 1.0f, 1.0f, "-", "_", ImGuiKey_Minus},
{12.75f, 0.0f, 2.25f, 1.0f, "Enter", nullptr, ImGuiKey_Enter},
};
static const KeyLayoutData dvorak_row3_keys[] = {
{0.0f, 0.0f, 2.25f, 1.0f, "Shift", nullptr, ImGuiKey_LeftShift},
{2.25f, 0.0f, 1.0f, 1.0f, ";", ":", ImGuiKey_Semicolon},
{3.25f, 0.0f, 1.0f, 1.0f, "Q", nullptr, ImGuiKey_Q},
{4.25f, 0.0f, 1.0f, 1.0f, "J", nullptr, ImGuiKey_J},
{5.25f, 0.0f, 1.0f, 1.0f, "K", nullptr, ImGuiKey_K},
{6.25f, 0.0f, 1.0f, 1.0f, "X", nullptr, ImGuiKey_X},
{7.25f, 0.0f, 1.0f, 1.0f, "B", nullptr, ImGuiKey_B},
{8.25f, 0.0f, 1.0f, 1.0f, "M", nullptr, ImGuiKey_M},
{9.25f, 0.0f, 1.0f, 1.0f, "W", nullptr, ImGuiKey_W},
{10.25f, 0.0f, 1.0f, 1.0f, "V", nullptr, ImGuiKey_V},
{11.25f, 0.0f, 1.0f, 1.0f, "Z", nullptr, ImGuiKey_Z},
{12.25f, 0.0f, 2.75f, 1.0f, "Shift", nullptr, ImGuiKey_RightShift},
};
// ISO layout rows - ISO keyboards have:
// - L-shaped Enter key (spans row 1 and row 2)
// - Shorter left Shift with extra key next to it
// - No backslash key on row 1 (it's part of Enter or moved to row 3)
// ISO QWERTY row 1 - Enter key rendered separately as L-shape
static const KeyLayoutData qwerty_iso_row1_keys[] = {
{0.0f, 0.0f, 1.5f, 1.0f, "Tab", nullptr, ImGuiKey_Tab},
{1.5f, 0.0f, 1.0f, 1.0f, "Q", nullptr, ImGuiKey_Q},
{2.5f, 0.0f, 1.0f, 1.0f, "W", nullptr, ImGuiKey_W},
{3.5f, 0.0f, 1.0f, 1.0f, "E", nullptr, ImGuiKey_E},
{4.5f, 0.0f, 1.0f, 1.0f, "R", nullptr, ImGuiKey_R},
{5.5f, 0.0f, 1.0f, 1.0f, "T", nullptr, ImGuiKey_T},
{6.5f, 0.0f, 1.0f, 1.0f, "Y", nullptr, ImGuiKey_Y},
{7.5f, 0.0f, 1.0f, 1.0f, "U", nullptr, ImGuiKey_U},
{8.5f, 0.0f, 1.0f, 1.0f, "I", nullptr, ImGuiKey_I},
{9.5f, 0.0f, 1.0f, 1.0f, "O", nullptr, ImGuiKey_O},
{10.5f, 0.0f, 1.0f, 1.0f, "P", nullptr, ImGuiKey_P},
{11.5f, 0.0f, 1.0f, 1.0f, "[", "{", ImGuiKey_LeftBracket},
{12.5f, 0.0f, 1.0f, 1.0f, "]", "}", ImGuiKey_RightBracket},
};
// ISO QWERTY row 2 - Enter key is rendered separately as L-shape polygon
static const KeyLayoutData qwerty_iso_row2_keys[] = {
{0.0f, 0.0f, 1.75f, 1.0f, "Caps", nullptr, ImGuiKey_CapsLock},
{1.75f, 0.0f, 1.0f, 1.0f, "A", nullptr, ImGuiKey_A},
{2.75f, 0.0f, 1.0f, 1.0f, "S", nullptr, ImGuiKey_S},
{3.75f, 0.0f, 1.0f, 1.0f, "D", nullptr, ImGuiKey_D},
{4.75f, 0.0f, 1.0f, 1.0f, "F", nullptr, ImGuiKey_F},
{5.75f, 0.0f, 1.0f, 1.0f, "G", nullptr, ImGuiKey_G},
{6.75f, 0.0f, 1.0f, 1.0f, "H", nullptr, ImGuiKey_H},
{7.75f, 0.0f, 1.0f, 1.0f, "J", nullptr, ImGuiKey_J},
{8.75f, 0.0f, 1.0f, 1.0f, "K", nullptr, ImGuiKey_K},
{9.75f, 0.0f, 1.0f, 1.0f, "L", nullptr, ImGuiKey_L},
{10.75f, 0.0f, 1.0f, 1.0f, ";", ":", ImGuiKey_Semicolon},
{11.75f, 0.0f, 1.0f, 1.0f, "'", "\"", ImGuiKey_Apostrophe},
{12.75f, 0.0f, 1.0f, 1.0f, "#", "~", ImGuiKey_Backslash}, // ISO hash key (left of Enter)
};
// ISO QWERTY row 3 - shorter left Shift with extra key
static const KeyLayoutData qwerty_iso_row3_keys[] = {
{0.0f, 0.0f, 1.25f, 1.0f, "Shift", nullptr, ImGuiKey_LeftShift},
{1.25f, 0.0f, 1.0f, 1.0f, "\\", "|", ImGuiKey_Oem102}, // ISO extra key
{2.25f, 0.0f, 1.0f, 1.0f, "Z", nullptr, ImGuiKey_Z},
{3.25f, 0.0f, 1.0f, 1.0f, "X", nullptr, ImGuiKey_X},
{4.25f, 0.0f, 1.0f, 1.0f, "C", nullptr, ImGuiKey_C},
{5.25f, 0.0f, 1.0f, 1.0f, "V", nullptr, ImGuiKey_V},
{6.25f, 0.0f, 1.0f, 1.0f, "B", nullptr, ImGuiKey_B},
{7.25f, 0.0f, 1.0f, 1.0f, "N", nullptr, ImGuiKey_N},
{8.25f, 0.0f, 1.0f, 1.0f, "M", nullptr, ImGuiKey_M},
{9.25f, 0.0f, 1.0f, 1.0f, ",", "<", ImGuiKey_Comma},
{10.25f, 0.0f, 1.0f, 1.0f, ".", ">", ImGuiKey_Period},
{11.25f, 0.0f, 1.0f, 1.0f, "/", "?", ImGuiKey_Slash},
{12.25f, 0.0f, 2.75f, 1.0f, "Shift", nullptr, ImGuiKey_RightShift},
};
// ISO QWERTZ (German) rows
static const KeyLayoutData qwertz_iso_row1_keys[] = {
{0.0f, 0.0f, 1.5f, 1.0f, "Tab", nullptr, ImGuiKey_Tab},
{1.5f, 0.0f, 1.0f, 1.0f, "Q", nullptr, ImGuiKey_Q},
{2.5f, 0.0f, 1.0f, 1.0f, "W", nullptr, ImGuiKey_W},
{3.5f, 0.0f, 1.0f, 1.0f, "E", nullptr, ImGuiKey_E},
{4.5f, 0.0f, 1.0f, 1.0f, "R", nullptr, ImGuiKey_R},
{5.5f, 0.0f, 1.0f, 1.0f, "T", nullptr, ImGuiKey_T},
{6.5f, 0.0f, 1.0f, 1.0f, "Z", nullptr, ImGuiKey_Z},
{7.5f, 0.0f, 1.0f, 1.0f, "U", nullptr, ImGuiKey_U},
{8.5f, 0.0f, 1.0f, 1.0f, "I", nullptr, ImGuiKey_I},
{9.5f, 0.0f, 1.0f, 1.0f, "O", nullptr, ImGuiKey_O},
{10.5f, 0.0f, 1.0f, 1.0f, "P", nullptr, ImGuiKey_P},
{11.5f, 0.0f, 1.0f, 1.0f, "\xc3\x9c", nullptr, ImGuiKey_LeftBracket},
{12.5f, 0.0f, 1.0f, 1.0f, "+", "*", ImGuiKey_RightBracket},
};
static const KeyLayoutData qwertz_iso_row2_keys[] = {
{0.0f, 0.0f, 1.75f, 1.0f, "Caps", nullptr, ImGuiKey_CapsLock},
{1.75f, 0.0f, 1.0f, 1.0f, "A", nullptr, ImGuiKey_A},
{2.75f, 0.0f, 1.0f, 1.0f, "S", nullptr, ImGuiKey_S},
{3.75f, 0.0f, 1.0f, 1.0f, "D", nullptr, ImGuiKey_D},
{4.75f, 0.0f, 1.0f, 1.0f, "F", nullptr, ImGuiKey_F},
{5.75f, 0.0f, 1.0f, 1.0f, "G", nullptr, ImGuiKey_G},
{6.75f, 0.0f, 1.0f, 1.0f, "H", nullptr, ImGuiKey_H},
{7.75f, 0.0f, 1.0f, 1.0f, "J", nullptr, ImGuiKey_J},
{8.75f, 0.0f, 1.0f, 1.0f, "K", nullptr, ImGuiKey_K},
{9.75f, 0.0f, 1.0f, 1.0f, "L", nullptr, ImGuiKey_L},
{10.75f, 0.0f, 1.0f, 1.0f, "\xc3\x96", nullptr, ImGuiKey_Semicolon},
{11.75f, 0.0f, 1.0f, 1.0f, "\xc3\x84", nullptr, ImGuiKey_Apostrophe},
{12.75f, 0.0f, 1.0f, 1.0f, "#", "'", ImGuiKey_Backslash},
};
static const KeyLayoutData qwertz_iso_row3_keys[] = {
{0.0f, 0.0f, 1.25f, 1.0f, "Shift", nullptr, ImGuiKey_LeftShift},
{1.25f, 0.0f, 1.0f, 1.0f, "<", ">", ImGuiKey_Oem102},
{2.25f, 0.0f, 1.0f, 1.0f, "Y", nullptr, ImGuiKey_Y},
{3.25f, 0.0f, 1.0f, 1.0f, "X", nullptr, ImGuiKey_X},
{4.25f, 0.0f, 1.0f, 1.0f, "C", nullptr, ImGuiKey_C},
{5.25f, 0.0f, 1.0f, 1.0f, "V", nullptr, ImGuiKey_V},
{6.25f, 0.0f, 1.0f, 1.0f, "B", nullptr, ImGuiKey_B},
{7.25f, 0.0f, 1.0f, 1.0f, "N", nullptr, ImGuiKey_N},
{8.25f, 0.0f, 1.0f, 1.0f, "M", nullptr, ImGuiKey_M},
{9.25f, 0.0f, 1.0f, 1.0f, ",", ";", ImGuiKey_Comma},
{10.25f, 0.0f, 1.0f, 1.0f, ".", ":", ImGuiKey_Period},
{11.25f, 0.0f, 1.0f, 1.0f, "-", "_", ImGuiKey_Slash},
{12.25f, 0.0f, 2.75f, 1.0f, "Shift", nullptr, ImGuiKey_RightShift},
};
// ISO AZERTY (French) rows
static const KeyLayoutData azerty_iso_row1_keys[] = {
{0.0f, 0.0f, 1.5f, 1.0f, "Tab", nullptr, ImGuiKey_Tab},
{1.5f, 0.0f, 1.0f, 1.0f, "A", nullptr, ImGuiKey_A},
{2.5f, 0.0f, 1.0f, 1.0f, "Z", nullptr, ImGuiKey_Z},
{3.5f, 0.0f, 1.0f, 1.0f, "E", nullptr, ImGuiKey_E},
{4.5f, 0.0f, 1.0f, 1.0f, "R", nullptr, ImGuiKey_R},
{5.5f, 0.0f, 1.0f, 1.0f, "T", nullptr, ImGuiKey_T},
{6.5f, 0.0f, 1.0f, 1.0f, "Y", nullptr, ImGuiKey_Y},
{7.5f, 0.0f, 1.0f, 1.0f, "U", nullptr, ImGuiKey_U},
{8.5f, 0.0f, 1.0f, 1.0f, "I", nullptr, ImGuiKey_I},
{9.5f, 0.0f, 1.0f, 1.0f, "O", nullptr, ImGuiKey_O},
{10.5f, 0.0f, 1.0f, 1.0f, "P", nullptr, ImGuiKey_P},
{11.5f, 0.0f, 1.0f, 1.0f, "^", nullptr, ImGuiKey_LeftBracket},
{12.5f, 0.0f, 1.0f, 1.0f, "$", nullptr, ImGuiKey_RightBracket},
};
static const KeyLayoutData azerty_iso_row2_keys[] = {
{0.0f, 0.0f, 1.75f, 1.0f, "Caps", nullptr, ImGuiKey_CapsLock},
{1.75f, 0.0f, 1.0f, 1.0f, "Q", nullptr, ImGuiKey_Q},
{2.75f, 0.0f, 1.0f, 1.0f, "S", nullptr, ImGuiKey_S},
{3.75f, 0.0f, 1.0f, 1.0f, "D", nullptr, ImGuiKey_D},
{4.75f, 0.0f, 1.0f, 1.0f, "F", nullptr, ImGuiKey_F},
{5.75f, 0.0f, 1.0f, 1.0f, "G", nullptr, ImGuiKey_G},
{6.75f, 0.0f, 1.0f, 1.0f, "H", nullptr, ImGuiKey_H},
{7.75f, 0.0f, 1.0f, 1.0f, "J", nullptr, ImGuiKey_J},
{8.75f, 0.0f, 1.0f, 1.0f, "K", nullptr, ImGuiKey_K},
{9.75f, 0.0f, 1.0f, 1.0f, "L", nullptr, ImGuiKey_L},
{10.75f, 0.0f, 1.0f, 1.0f, "M", nullptr, ImGuiKey_M},
{11.75f, 0.0f, 1.0f, 1.0f, "\xc3\xb9", "%", ImGuiKey_Apostrophe},
{12.75f, 0.0f, 1.0f, 1.0f, "*", nullptr, ImGuiKey_Backslash},
};
static const KeyLayoutData azerty_iso_row3_keys[] = {
{0.0f, 0.0f, 1.25f, 1.0f, "Shift", nullptr, ImGuiKey_LeftShift},
{1.25f, 0.0f, 1.0f, 1.0f, "<", ">", ImGuiKey_Oem102},
{2.25f, 0.0f, 1.0f, 1.0f, "W", nullptr, ImGuiKey_W},
{3.25f, 0.0f, 1.0f, 1.0f, "X", nullptr, ImGuiKey_X},
{4.25f, 0.0f, 1.0f, 1.0f, "C", nullptr, ImGuiKey_C},
{5.25f, 0.0f, 1.0f, 1.0f, "V", nullptr, ImGuiKey_V},
{6.25f, 0.0f, 1.0f, 1.0f, "B", nullptr, ImGuiKey_B},
{7.25f, 0.0f, 1.0f, 1.0f, "N", nullptr, ImGuiKey_N},
{8.25f, 0.0f, 1.0f, 1.0f, ",", "?", ImGuiKey_Comma},
{9.25f, 0.0f, 1.0f, 1.0f, ";", ".", ImGuiKey_Semicolon},
{10.25f, 0.0f, 1.0f, 1.0f, ":", "/", ImGuiKey_Period},
{11.25f, 0.0f, 1.0f, 1.0f, "!", nullptr, ImGuiKey_Slash},
{12.25f, 0.0f, 2.75f, 1.0f, "Shift", nullptr, ImGuiKey_RightShift},
};
// Apple ANSI layout rows (US Mac keyboard)
// Apple keyboards use Command (⌘) instead of Win, Option instead of Alt
static const KeyLayoutData apple_ansi_row1_keys[] = {
{0.0f, 0.0f, 1.5f, 1.0f, "Tab", nullptr, ImGuiKey_Tab},
{1.5f, 0.0f, 1.0f, 1.0f, "Q", nullptr, ImGuiKey_Q},
{2.5f, 0.0f, 1.0f, 1.0f, "W", nullptr, ImGuiKey_W},
{3.5f, 0.0f, 1.0f, 1.0f, "E", nullptr, ImGuiKey_E},
{4.5f, 0.0f, 1.0f, 1.0f, "R", nullptr, ImGuiKey_R},
{5.5f, 0.0f, 1.0f, 1.0f, "T", nullptr, ImGuiKey_T},
{6.5f, 0.0f, 1.0f, 1.0f, "Y", nullptr, ImGuiKey_Y},
{7.5f, 0.0f, 1.0f, 1.0f, "U", nullptr, ImGuiKey_U},
{8.5f, 0.0f, 1.0f, 1.0f, "I", nullptr, ImGuiKey_I},
{9.5f, 0.0f, 1.0f, 1.0f, "O", nullptr, ImGuiKey_O},
{10.5f, 0.0f, 1.0f, 1.0f, "P", nullptr, ImGuiKey_P},
{11.5f, 0.0f, 1.0f, 1.0f, "[", "{", ImGuiKey_LeftBracket},
{12.5f, 0.0f, 1.0f, 1.0f, "]", "}", ImGuiKey_RightBracket},
{13.5f, 0.0f, 1.5f, 1.0f, "\\", "|", ImGuiKey_Backslash},
};
static const KeyLayoutData apple_ansi_row2_keys[] = {
{0.0f, 0.0f, 1.75f, 1.0f, "Caps", nullptr, ImGuiKey_CapsLock},
{1.75f, 0.0f, 1.0f, 1.0f, "A", nullptr, ImGuiKey_A},
{2.75f, 0.0f, 1.0f, 1.0f, "S", nullptr, ImGuiKey_S},
{3.75f, 0.0f, 1.0f, 1.0f, "D", nullptr, ImGuiKey_D},
{4.75f, 0.0f, 1.0f, 1.0f, "F", nullptr, ImGuiKey_F},
{5.75f, 0.0f, 1.0f, 1.0f, "G", nullptr, ImGuiKey_G},
{6.75f, 0.0f, 1.0f, 1.0f, "H", nullptr, ImGuiKey_H},
{7.75f, 0.0f, 1.0f, 1.0f, "J", nullptr, ImGuiKey_J},
{8.75f, 0.0f, 1.0f, 1.0f, "K", nullptr, ImGuiKey_K},
{9.75f, 0.0f, 1.0f, 1.0f, "L", nullptr, ImGuiKey_L},
{10.75f, 0.0f, 1.0f, 1.0f, ";", ":", ImGuiKey_Semicolon},
{11.75f, 0.0f, 1.0f, 1.0f, "'", "\"", ImGuiKey_Apostrophe},
{12.75f, 0.0f, 2.25f, 1.0f, "Return", nullptr, ImGuiKey_Enter},
};
static const KeyLayoutData apple_ansi_row3_keys[] = {
{0.0f, 0.0f, 2.25f, 1.0f, "Shift", nullptr, ImGuiKey_LeftShift},
{2.25f, 0.0f, 1.0f, 1.0f, "Z", nullptr, ImGuiKey_Z},
{3.25f, 0.0f, 1.0f, 1.0f, "X", nullptr, ImGuiKey_X},
{4.25f, 0.0f, 1.0f, 1.0f, "C", nullptr, ImGuiKey_C},
{5.25f, 0.0f, 1.0f, 1.0f, "V", nullptr, ImGuiKey_V},
{6.25f, 0.0f, 1.0f, 1.0f, "B", nullptr, ImGuiKey_B},
{7.25f, 0.0f, 1.0f, 1.0f, "N", nullptr, ImGuiKey_N},
{8.25f, 0.0f, 1.0f, 1.0f, "M", nullptr, ImGuiKey_M},
{9.25f, 0.0f, 1.0f, 1.0f, ",", "<", ImGuiKey_Comma},
{10.25f, 0.0f, 1.0f, 1.0f, ".", ">", ImGuiKey_Period},
{11.25f, 0.0f, 1.0f, 1.0f, "/", "?", ImGuiKey_Slash},
{12.25f, 0.0f, 2.75f, 1.0f, "Shift", nullptr, ImGuiKey_RightShift},
};
// Apple full keyboard bottom row (Ctrl, Option, Command, Space, Command, Option, Ctrl)
// Full-size layout like Apple Magic Keyboard with Numeric Keypad - no Fn key, wider modifier keys
static const KeyLayoutData apple_bottom_row_keys[] = {
{0.0f, 0.0f, 1.5f, 1.0f, "Ctrl", nullptr, ImGuiKey_LeftCtrl},
{1.5f, 0.0f, 1.25f, 1.0f, "Opt", nullptr, ImGuiKey_LeftAlt},
{2.75f, 0.0f, 1.5f, 1.0f, "Cmd", nullptr, ImGuiKey_LeftSuper},
{4.25f, 0.0f, 6.25f, 1.0f, "Space", nullptr, ImGuiKey_Space},
{10.5f, 0.0f, 1.5f, 1.0f, "Cmd", nullptr, ImGuiKey_RightSuper},
{12.0f, 0.0f, 1.25f, 1.0f, "Opt", nullptr, ImGuiKey_RightAlt},
{13.25f, 0.0f, 1.75f, 1.0f, "Ctrl", nullptr, ImGuiKey_RightCtrl},
};
// Apple ISO layout rows (UK/International Mac keyboard)
// Same as Apple ANSI but with ISO Enter key and extra key next to left Shift
static const KeyLayoutData apple_iso_row1_keys[] = {
{0.0f, 0.0f, 1.5f, 1.0f, "Tab", nullptr, ImGuiKey_Tab},
{1.5f, 0.0f, 1.0f, 1.0f, "Q", nullptr, ImGuiKey_Q},
{2.5f, 0.0f, 1.0f, 1.0f, "W", nullptr, ImGuiKey_W},
{3.5f, 0.0f, 1.0f, 1.0f, "E", nullptr, ImGuiKey_E},
{4.5f, 0.0f, 1.0f, 1.0f, "R", nullptr, ImGuiKey_R},
{5.5f, 0.0f, 1.0f, 1.0f, "T", nullptr, ImGuiKey_T},
{6.5f, 0.0f, 1.0f, 1.0f, "Y", nullptr, ImGuiKey_Y},
{7.5f, 0.0f, 1.0f, 1.0f, "U", nullptr, ImGuiKey_U},
{8.5f, 0.0f, 1.0f, 1.0f, "I", nullptr, ImGuiKey_I},
{9.5f, 0.0f, 1.0f, 1.0f, "O", nullptr, ImGuiKey_O},
{10.5f, 0.0f, 1.0f, 1.0f, "P", nullptr, ImGuiKey_P},
{11.5f, 0.0f, 1.0f, 1.0f, "[", "{", ImGuiKey_LeftBracket},
{12.5f, 0.0f, 1.0f, 1.0f, "]", "}", ImGuiKey_RightBracket},
};
static const KeyLayoutData apple_iso_row2_keys[] = {
{0.0f, 0.0f, 1.75f, 1.0f, "Caps", nullptr, ImGuiKey_CapsLock},
{1.75f, 0.0f, 1.0f, 1.0f, "A", nullptr, ImGuiKey_A},
{2.75f, 0.0f, 1.0f, 1.0f, "S", nullptr, ImGuiKey_S},
{3.75f, 0.0f, 1.0f, 1.0f, "D", nullptr, ImGuiKey_D},
{4.75f, 0.0f, 1.0f, 1.0f, "F", nullptr, ImGuiKey_F},
{5.75f, 0.0f, 1.0f, 1.0f, "G", nullptr, ImGuiKey_G},
{6.75f, 0.0f, 1.0f, 1.0f, "H", nullptr, ImGuiKey_H},
{7.75f, 0.0f, 1.0f, 1.0f, "J", nullptr, ImGuiKey_J},
{8.75f, 0.0f, 1.0f, 1.0f, "K", nullptr, ImGuiKey_K},
{9.75f, 0.0f, 1.0f, 1.0f, "L", nullptr, ImGuiKey_L},
{10.75f, 0.0f, 1.0f, 1.0f, ";", ":", ImGuiKey_Semicolon},
{11.75f, 0.0f, 1.0f, 1.0f, "'", "\"", ImGuiKey_Apostrophe},
{12.75f, 0.0f, 1.0f, 1.0f, "#", "~", ImGuiKey_Backslash},
};
static const KeyLayoutData apple_iso_row3_keys[] = {
{0.0f, 0.0f, 1.25f, 1.0f, "Shift", nullptr, ImGuiKey_LeftShift},
{1.25f, 0.0f, 1.0f, 1.0f, "`", "~", ImGuiKey_Oem102},
{2.25f, 0.0f, 1.0f, 1.0f, "Z", nullptr, ImGuiKey_Z},
{3.25f, 0.0f, 1.0f, 1.0f, "X", nullptr, ImGuiKey_X},
{4.25f, 0.0f, 1.0f, 1.0f, "C", nullptr, ImGuiKey_C},
{5.25f, 0.0f, 1.0f, 1.0f, "V", nullptr, ImGuiKey_V},
{6.25f, 0.0f, 1.0f, 1.0f, "B", nullptr, ImGuiKey_B},
{7.25f, 0.0f, 1.0f, 1.0f, "N", nullptr, ImGuiKey_N},
{8.25f, 0.0f, 1.0f, 1.0f, "M", nullptr, ImGuiKey_M},
{9.25f, 0.0f, 1.0f, 1.0f, ",", "<", ImGuiKey_Comma},
{10.25f, 0.0f, 1.0f, 1.0f, ".", ">", ImGuiKey_Period},
{11.25f, 0.0f, 1.0f, 1.0f, "/", "?", ImGuiKey_Slash},
{12.25f, 0.0f, 2.75f, 1.0f, "Shift", nullptr, ImGuiKey_RightShift},
};
// Bottom row (modifiers + spacebar)
static const KeyLayoutData bottom_row_keys[] = {
{0.0f, 0.0f, 1.25f, 1.0f, "Ctrl", nullptr, ImGuiKey_LeftCtrl},
{1.25f, 0.0f, 1.25f, 1.0f, "Win", nullptr, ImGuiKey_LeftSuper},
{2.5f, 0.0f, 1.25f, 1.0f, "Alt", nullptr, ImGuiKey_LeftAlt},
{3.75f, 0.0f, 6.25f, 1.0f, "Space", nullptr, ImGuiKey_Space},
{10.0f, 0.0f, 1.25f, 1.0f, "Alt", nullptr, ImGuiKey_RightAlt},
{11.25f, 0.0f, 1.25f, 1.0f, "Win", nullptr, ImGuiKey_RightSuper},
{12.5f, 0.0f, 1.25f, 1.0f, "Menu", nullptr, ImGuiKey_Menu},
{13.75f, 0.0f, 1.25f, 1.0f, "Ctrl", nullptr, ImGuiKey_RightCtrl},
};
static void RenderKey(ImDrawList *draw_list, const ImVec2 &key_min, const ImVec2 &key_size, const char *label,
const char *shiftLabel, ImGuiKey key, float scale, ImGuiKeyboardFlags flags) {
const ImGuiKeyboardStyle &style = GetStyle();
const float key_rounding = style.KeyRounding * scale;
const float key_face_rounding = style.KeyFaceRounding * scale;
const ImVec2 key_face_pos(style.KeyFaceOffset.x * scale, style.KeyFaceOffset.y * scale);
const ImVec2 key_label_pos(style.KeyLabelOffset.x * scale, style.KeyLabelOffset.y * scale);
ImVec2 key_max = ImVec2(key_min.x + key_size.x, key_min.y + key_size.y);
ImVec2 key_face_size =
ImVec2(key_size.x - style.KeyFaceOffset.x * 2.0f * scale, key_size.y - style.KeyFaceOffset.y * 2.0f * scale);
// Key background
draw_list->AddRectFilled(key_min, key_max, GetColorU32(ImGuiKeyboardCol_KeyBackground), key_rounding);
draw_list->AddRect(key_min, key_max, GetColorU32(ImGuiKeyboardCol_KeyBorder), key_rounding);
// Key face
ImVec2 face_min = ImVec2(key_min.x + key_face_pos.x, key_min.y + key_face_pos.y);
ImVec2 face_max = ImVec2(face_min.x + key_face_size.x, face_min.y + key_face_size.y);
draw_list->AddRect(face_min, face_max, GetColorU32(ImGuiKeyboardCol_KeyFaceBorder), key_face_rounding,
ImDrawFlags_None, style.KeyFaceBorderSize);
draw_list->AddRectFilled(face_min, face_max, GetColorU32(ImGuiKeyboardCol_KeyFace), key_face_rounding);
// Label rendering
ImVec2 label_min = ImVec2(key_min.x + key_label_pos.x, key_min.y + key_label_pos.y);
// Check if we should draw icons instead of text
const bool showIcons = (flags & ImGuiKeyboardFlags_ShowIcons);
const bool isWindowsKey = (key == ImGuiKey_LeftSuper || key == ImGuiKey_RightSuper);
const bool isArrowKey = (key == ImGuiKey_UpArrow || key == ImGuiKey_DownArrow || key == ImGuiKey_LeftArrow ||
key == ImGuiKey_RightArrow);
const bool isShiftKey = (key == ImGuiKey_LeftShift || key == ImGuiKey_RightShift);
const bool isTabKey = (key == ImGuiKey_Tab);
const bool isCapsLockKey = (key == ImGuiKey_CapsLock);
const bool isEnterKey = (key == ImGuiKey_Enter || key == ImGuiKey_KeypadEnter);
const bool isAppleModifier = (label && (strcmp(label, "Ctrl") == 0 || strcmp(label, "Opt") == 0 || strcmp(label, "Cmd") == 0));
// Numpad navigation keys (when NumLock is off, these act as navigation keys)
const bool numLockActive = ImGui::IsKeyDown(ImGuiKey_NumLock);
const bool isNumpadArrowKey = !numLockActive && (key == ImGuiKey_Keypad8 || key == ImGuiKey_Keypad2 ||
key == ImGuiKey_Keypad4 || key == ImGuiKey_Keypad6);
const bool isNumpadNavKey =
!numLockActive && (key == ImGuiKey_Keypad7 || key == ImGuiKey_Keypad9 || key == ImGuiKey_Keypad1 ||
key == ImGuiKey_Keypad3 || key == ImGuiKey_Keypad0 || key == ImGuiKey_KeypadDecimal);
if (showIcons && isWindowsKey && !isAppleModifier) {
// Draw Windows logo (4 squares in a 2x2 grid)
const float logo_size = ImGui::GetFontSize() * 0.9f;
const float quad_size = logo_size * 0.45f;
const float gap = logo_size * 0.1f;
ImVec2 logo_min = ImVec2(label_min.x, label_min.y);
ImU32 logo_color = GetColorU32(ImGuiKeyboardCol_KeyLabel);
// Top-left quad
draw_list->AddRectFilled(logo_min, ImVec2(logo_min.x + quad_size, logo_min.y + quad_size), logo_color);
// Top-right quad
draw_list->AddRectFilled(ImVec2(logo_min.x + quad_size + gap, logo_min.y),
ImVec2(logo_min.x + quad_size * 2.0f + gap, logo_min.y + quad_size), logo_color);
// Bottom-left quad
draw_list->AddRectFilled(ImVec2(logo_min.x, logo_min.y + quad_size + gap),
ImVec2(logo_min.x + quad_size, logo_min.y + quad_size * 2.0f + gap), logo_color);
// Bottom-right quad
draw_list->AddRectFilled(ImVec2(logo_min.x + quad_size + gap, logo_min.y + quad_size + gap),
ImVec2(logo_min.x + quad_size * 2.0f + gap, logo_min.y + quad_size * 2.0f + gap),
logo_color);
} else if (showIcons && isArrowKey) {
// Draw arrow triangles centered on the key face
const float arrow_size = ImGui::GetFontSize() * 0.7f;
ImU32 arrow_color = GetColorU32(ImGuiKeyboardCol_KeyLabel);
ImVec2 center = ImVec2((face_min.x + face_max.x) * 0.5f, (face_min.y + face_max.y) * 0.5f);
if (key == ImGuiKey_UpArrow) {
// Triangle pointing up
draw_list->AddTriangleFilled(ImVec2(center.x, center.y - arrow_size * 0.5f),
ImVec2(center.x - arrow_size * 0.5f, center.y + arrow_size * 0.5f),
ImVec2(center.x + arrow_size * 0.5f, center.y + arrow_size * 0.5f),
arrow_color);
} else if (key == ImGuiKey_DownArrow) {
// Triangle pointing down
draw_list->AddTriangleFilled(ImVec2(center.x, center.y + arrow_size * 0.5f),
ImVec2(center.x - arrow_size * 0.5f, center.y - arrow_size * 0.5f),
ImVec2(center.x + arrow_size * 0.5f, center.y - arrow_size * 0.5f),
arrow_color);
} else if (key == ImGuiKey_LeftArrow) {
// Triangle pointing left
draw_list->AddTriangleFilled(ImVec2(center.x - arrow_size * 0.5f, center.y),
ImVec2(center.x + arrow_size * 0.5f, center.y - arrow_size * 0.5f),
ImVec2(center.x + arrow_size * 0.5f, center.y + arrow_size * 0.5f),
arrow_color);
} else if (key == ImGuiKey_RightArrow) {
// Triangle pointing right
draw_list->AddTriangleFilled(ImVec2(center.x + arrow_size * 0.5f, center.y),
ImVec2(center.x - arrow_size * 0.5f, center.y - arrow_size * 0.5f),
ImVec2(center.x - arrow_size * 0.5f, center.y + arrow_size * 0.5f),
arrow_color);
}
} else if (showIcons && isNumpadArrowKey) {
// Draw number label first, then small arrow icon in corner (when NumLock is off)
draw_list->AddText(label_min, GetColorU32(ImGuiKeyboardCol_KeyLabel), label);
// Draw small arrow in bottom-right corner
const float arrow_size = ImGui::GetFontSize() * 0.35f;
ImU32 arrow_color = GetColorU32(ImGuiKeyboardCol_KeyLabel);
ImVec2 center = ImVec2(face_max.x - arrow_size * 0.8f, face_max.y - arrow_size * 0.8f);
if (key == ImGuiKey_Keypad8) {
// Triangle pointing up
draw_list->AddTriangleFilled(ImVec2(center.x, center.y - arrow_size * 0.5f),
ImVec2(center.x - arrow_size * 0.5f, center.y + arrow_size * 0.5f),
ImVec2(center.x + arrow_size * 0.5f, center.y + arrow_size * 0.5f),
arrow_color);
} else if (key == ImGuiKey_Keypad2) {
// Triangle pointing down
draw_list->AddTriangleFilled(ImVec2(center.x, center.y + arrow_size * 0.5f),
ImVec2(center.x - arrow_size * 0.5f, center.y - arrow_size * 0.5f),
ImVec2(center.x + arrow_size * 0.5f, center.y - arrow_size * 0.5f),
arrow_color);
} else if (key == ImGuiKey_Keypad4) {
// Triangle pointing left
draw_list->AddTriangleFilled(ImVec2(center.x - arrow_size * 0.5f, center.y),
ImVec2(center.x + arrow_size * 0.5f, center.y - arrow_size * 0.5f),
ImVec2(center.x + arrow_size * 0.5f, center.y + arrow_size * 0.5f),
arrow_color);
} else if (key == ImGuiKey_Keypad6) {
// Triangle pointing right
draw_list->AddTriangleFilled(ImVec2(center.x + arrow_size * 0.5f, center.y),
ImVec2(center.x - arrow_size * 0.5f, center.y - arrow_size * 0.5f),
ImVec2(center.x - arrow_size * 0.5f, center.y + arrow_size * 0.5f),
arrow_color);
}
} else if (showIcons && isNumpadNavKey) {
// Draw number label first, then small nav label in corner (when NumLock is off)
draw_list->AddText(label_min, GetColorU32(ImGuiKeyboardCol_KeyLabel), label);
// Draw small nav label in bottom-right corner
const char *navLabel = nullptr;
if (key == ImGuiKey_Keypad7)
navLabel = "Hm";
else if (key == ImGuiKey_Keypad9)
navLabel = "PU";
else if (key == ImGuiKey_Keypad1)
navLabel = "En";
else if (key == ImGuiKey_Keypad3)
navLabel = "PD";
else if (key == ImGuiKey_Keypad0)
navLabel = "In";
else if (key == ImGuiKey_KeypadDecimal)
navLabel = "De";
if (navLabel) {
ImVec2 text_size = ImGui::CalcTextSize(navLabel);
ImVec2 nav_pos = ImVec2(face_max.x - text_size.x - 2.0f, face_max.y - text_size.y - 2.0f);
draw_list->AddText(nav_pos, GetColorU32(ImGuiKeyboardCol_KeyLabel), navLabel);
}
} else if (showIcons && isAppleModifier) {
// Draw Apple modifier icons: Control, Option, Command
const float icon_size = ImGui::GetFontSize() * 0.8f;
ImU32 icon_color = GetColorU32(ImGuiKeyboardCol_KeyLabel);
ImVec2 center = ImVec2(label_min.x + icon_size * 0.5f, label_min.y + icon_size * 0.5f);
const float half = icon_size * 0.5f;
const float thickness = icon_size * 0.12f;
if (strcmp(label, "Ctrl") == 0) {
// Control symbol - caret/chevron pointing up
draw_list->AddTriangle(
ImVec2(center.x, center.y - half * 0.6f),
ImVec2(center.x - half * 0.7f, center.y + half * 0.3f),
ImVec2(center.x + half * 0.7f, center.y + half * 0.3f),
icon_color, thickness * 1.5f);
} else if (strcmp(label, "Opt") == 0) {
// Option symbol - split horizontal line with diagonal
// Top right horizontal segment
draw_list->AddLine(
ImVec2(center.x + half * 0.1f, center.y - half * 0.4f),
ImVec2(center.x + half * 0.8f, center.y - half * 0.4f),
icon_color, thickness * 1.5f);
// Diagonal from top right going down-left
draw_list->AddLine(
ImVec2(center.x + half * 0.1f, center.y - half * 0.4f),
ImVec2(center.x - half * 0.4f, center.y + half * 0.3f),
icon_color, thickness * 1.5f);
// Bottom left horizontal segment from diagonal end
draw_list->AddLine(
ImVec2(center.x - half * 0.8f, center.y + half * 0.3f),
ImVec2(center.x - half * 0.4f, center.y + half * 0.3f),
icon_color, thickness * 1.5f);
// Top left short horizontal line
draw_list->AddLine(
ImVec2(center.x - half * 0.8f, center.y - half * 0.4f),
ImVec2(center.x - half * 0.1f, center.y - half * 0.4f),
icon_color, thickness * 1.5f);
} else if (strcmp(label, "Cmd") == 0) {
// Command symbol - four loops
const float loopSize = half * 0.35f;
const float loopOffset = half * 0.4f;
// Four corner loops
draw_list->AddCircle(ImVec2(center.x - loopOffset, center.y - loopOffset), loopSize, icon_color, 12, thickness * 1.5f);
draw_list->AddCircle(ImVec2(center.x + loopOffset, center.y - loopOffset), loopSize, icon_color, 12, thickness * 1.5f);
draw_list->AddCircle(ImVec2(center.x - loopOffset, center.y + loopOffset), loopSize, icon_color, 12, thickness * 1.5f);
draw_list->AddCircle(ImVec2(center.x + loopOffset, center.y + loopOffset), loopSize, icon_color, 12, thickness * 1.5f);
// Cross connecting the loops
draw_list->AddLine(ImVec2(center.x - loopOffset, center.y - loopOffset - loopSize),
ImVec2(center.x - loopOffset, center.y + loopOffset + loopSize), icon_color, thickness * 1.5f);
draw_list->AddLine(ImVec2(center.x + loopOffset, center.y - loopOffset - loopSize),
ImVec2(center.x + loopOffset, center.y + loopOffset + loopSize), icon_color, thickness * 1.5f);
draw_list->AddLine(ImVec2(center.x - loopOffset - loopSize, center.y - loopOffset),
ImVec2(center.x + loopOffset + loopSize, center.y - loopOffset), icon_color, thickness * 1.5f);
draw_list->AddLine(ImVec2(center.x - loopOffset - loopSize, center.y + loopOffset),
ImVec2(center.x + loopOffset + loopSize, center.y + loopOffset), icon_color, thickness * 1.5f);
}
} else if (showIcons && isShiftKey) {
// Draw Shift icon
const float icon_size = ImGui::GetFontSize() * 0.8f;
ImU32 icon_color = GetColorU32(ImGuiKeyboardCol_KeyLabel);
ImVec2 center = ImVec2(label_min.x + icon_size * 0.5f, label_min.y + icon_size * 0.5f);
const float half = icon_size * 0.5f;
const float thickness = icon_size * 0.15f;
// Outer triangle (arrow head)
draw_list->AddTriangleFilled(ImVec2(center.x, center.y - half), ImVec2(center.x - half, center.y + half * 0.2f),
ImVec2(center.x + half, center.y + half * 0.2f), icon_color);
// Stem rectangle
draw_list->AddRectFilled(ImVec2(center.x - thickness, center.y + half * 0.2f),
ImVec2(center.x + thickness, center.y + half), icon_color);
} else if (showIcons && isTabKey) {
// Draw Tab icon (arrow pointing right with vertical bar)
const float icon_size = ImGui::GetFontSize() * 0.8f;
ImU32 icon_color = GetColorU32(ImGuiKeyboardCol_KeyLabel);
ImVec2 center = ImVec2(label_min.x + icon_size * 0.5f, label_min.y + icon_size * 0.5f);
const float half = icon_size * 0.5f;
const float thickness = icon_size * 0.12f;
// Horizontal line
draw_list->AddRectFilled(ImVec2(center.x - half, center.y - thickness * 0.5f),
ImVec2(center.x + half * 0.5f, center.y + thickness * 0.5f), icon_color);
// Arrow head (triangle pointing right)
draw_list->AddTriangleFilled(ImVec2(center.x + half * 0.5f, center.y - half * 0.4f),
ImVec2(center.x + half * 0.5f, center.y + half * 0.4f),
ImVec2(center.x + half, center.y), icon_color);
// Vertical bar at end
draw_list->AddRectFilled(ImVec2(center.x + half - thickness, center.y - half * 0.5f),
ImVec2(center.x + half, center.y + half * 0.5f), icon_color);
} else if (showIcons && isCapsLockKey) {
// Draw Caps Lock icon (upward arrow with horizontal bar underneath)
const float icon_size = ImGui::GetFontSize() * 0.8f;
ImU32 icon_color = GetColorU32(ImGuiKeyboardCol_KeyLabel);
ImVec2 center = ImVec2(label_min.x + icon_size * 0.5f, label_min.y + icon_size * 0.5f);
const float half = icon_size * 0.5f;
const float thickness = icon_size * 0.15f;
// Arrow head pointing up
draw_list->AddTriangleFilled(ImVec2(center.x, center.y - half),
ImVec2(center.x - half * 0.6f, center.y - half * 0.1f),
ImVec2(center.x + half * 0.6f, center.y - half * 0.1f), icon_color);
// Stem
draw_list->AddRectFilled(ImVec2(center.x - thickness, center.y - half * 0.1f),
ImVec2(center.x + thickness, center.y + half * 0.4f), icon_color);
// Horizontal bar underneath
draw_list->AddRectFilled(ImVec2(center.x - half * 0.5f, center.y + half * 0.6f),
ImVec2(center.x + half * 0.5f, center.y + half * 0.8f), icon_color);
} else if (showIcons && isEnterKey) {
// Draw Enter icon
const float icon_size = ImGui::GetFontSize() * 0.8f;
ImU32 icon_color = GetColorU32(ImGuiKeyboardCol_KeyLabel);
ImVec2 start = ImVec2(label_min.x, label_min.y);
const float thickness = icon_size * 0.12f;
// Vertical line going up on the right
draw_list->AddRectFilled(ImVec2(start.x + icon_size * 0.8f - thickness, start.y),
ImVec2(start.x + icon_size * 0.8f, start.y + icon_size * 0.5f), icon_color);
// Horizontal line going left
draw_list->AddRectFilled(ImVec2(start.x + icon_size * 0.15f, start.y + icon_size * 0.5f - thickness),
ImVec2(start.x + icon_size * 0.8f, start.y + icon_size * 0.5f), icon_color);
// Arrow head pointing left
draw_list->AddTriangleFilled(
ImVec2(start.x, start.y + icon_size * 0.5f - thickness * 0.5f),
ImVec2(start.x + icon_size * 0.25f, start.y + icon_size * 0.5f - icon_size * 0.25f),
ImVec2(start.x + icon_size * 0.25f, start.y + icon_size * 0.5f + icon_size * 0.15f), icon_color);
} else if ((flags & ImGuiKeyboardFlags_ShowBothLabels) && shiftLabel) {