forked from keyboardio/Model01-Firmware
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Model01.ino
1242 lines (948 loc) · 44 KB
/
Model01.ino
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
// -*- mode: c++ -*-
// Copyright 2016 Keyboardio, inc. <jesse@keyboard.io>
// See "LICENSE" for license details
// TODO: as version, use the hash of this file and display/print the last 4 characters for short
// or map the hash to a cool name, like Indigo or smth.
#ifndef BUILD_INFORMATION
#define BUILD_INFORMATION "M01 version 1"
//#define BUILD_INFORMATION "M01 firmware version: " __DATE__ " " __TIME__
#endif
/**
* These #include directives pull in the Kaleidoscope firmware core,
* as well as the Kaleidoscope plugins we use in the Model 01's firmware
*/
#include "strings_file.h"
// The Kaleidoscope core
#include "Kaleidoscope.h"
// Support for storing the keymap in EEPROM
#include "Kaleidoscope-EEPROM-Settings.h"
#include "Kaleidoscope-EEPROM-Keymap.h"
// Support for communicating with the host via a simple Serial protocol
#include "Kaleidoscope-FocusSerial.h"
// Support for keys that move the mouse
#include "Kaleidoscope-MouseKeys.h"
// Support for macros
#include "Kaleidoscope-Macros.h"
// Support for controlling the keyboard's LEDs
#include "Kaleidoscope-LEDControl.h"
// Support for "Numpad" mode, which is mostly just the Numpad specific LED mode
//#include "Kaleidoscope-NumPad.h"
// Support for the "Boot greeting" effect, which pulses the 'LED' button for 10s
// when the keyboard is connected to a computer (or that computer is powered on)
#include "Kaleidoscope-LEDEffect-BootGreeting.h"
// Support for LED modes that set all LEDs to a single color
#include "Kaleidoscope-LEDEffect-SolidColor.h"
// Support for an LED mode that makes all the LEDs 'breathe'
#include "Kaleidoscope-LEDEffect-Breathe.h"
// Support for an LED mode that makes a red pixel chase a blue pixel across the keyboard
#include "Kaleidoscope-LEDEffect-Chase.h"
// Support for LED modes that pulse the keyboard's LED in a rainbow pattern
#include "Kaleidoscope-LEDEffect-Rainbow.h"
// Support for an LED mode that lights up the keys as you press them
#include "Kaleidoscope-LED-Stalker.h"
// Support for an LED mode that prints the keys you press in letters 4px high
#include "Kaleidoscope-LED-AlphaSquare.h"
// Support for shared palettes for other plugins, like Colormap below
#include "Kaleidoscope-LED-Palette-Theme.h"
// Support for an LED mode that lets one configure per-layer color maps
#include "Kaleidoscope-Colormap.h"
// Support for Keyboardio's internal keyboard testing mode
#include "Kaleidoscope-HardwareTestMode.h"
// Support for host power management (suspend & wakeup)
#include "Kaleidoscope-HostPowerManagement.h"
// Support for magic combos (key chords that trigger an action)
#include "Kaleidoscope-MagicCombo.h"
// Support for USB quirks, like changing the key state report protocol
#include "Kaleidoscope-USB-Quirks.h"
#include "Kaleidoscope-TopsyTurvy.h"
#include "Kaleidoscope-TapDance.h"
#include <Kaleidoscope-OneShot.h>
#include <Kaleidoscope-Escape-OneShot.h>
/** This 'enum' is a list of all the macros used by the Model 01's firmware
* The names aren't particularly important. What is important is that each
* is unique.
*
* These are the names of your macros. They'll be used in two places.
* The first is in your keymap definitions. There, you'll use the syntax
* `M(MACRO_NAME)` to mark a specific keymap position as triggering `MACRO_NAME`
*
* The second usage is in the 'switch' statement in the `macroAction` function.
* That switch statement actually runs the code associated with a macro when
* a macro key is pressed.
*/
enum { MACRO_VERSION_INFO,
MACRO_ANY,
MACRO_TOGGLE_FACTORY_LAYOUT,
MACRO_LED_DEACTIVATION,
MACRO_VIELE_GR,
MACRO_LENNY,
MACRO_SHRUG,
MACRO_DISAPPROVAL,
MACRO_APP_BROWSER_OPEN_SEARCH,
MACRO_COPY,
MACRO_CUT,
MACRO_PASTE,
MACRO_UNDO,
MACRO_ZOOM_IN,
MACRO_ZOOM_OUT,
MACRO_AUTOCOMPLETE,
MACRO_HEATMAP,
MACRO_MOVE_LINE_UP,
MACRO_MOVE_LINE_DOWN,
////////////////////////////////////////////////////
// Emacs Macros
////////////////////////////////////////////////////
MACRO_FOCUS_EMACS,
// Save file macro: sends a long key combo that is translated by autohotkey
// to the proper save file keyboard shortcut, depending on the currently active
// program. ("C-x s" in emacs was too cumbersome in the end)
MACRO_SAVE_FILE,
// Instantly go to prev/next buffer
MACRO_KILL_BUFFER,
//MACRO_DELETE_WINDOW,
MACRO_FORWARD_DELETE_WORD,
MACRO_FIND,
// MACRO_ENTER_KEY,
MACRO_ORG_EMACS_CAPTURE,
MACRO_EMACS_ORG_REFILE,
MACRO_ORG_CLOCK_GOTO,
MACRO_ORG_CLOCK_IN,
MACRO_ORG_CLOCK_OUT,
//MACRO_EMACS_AGENDA_SEARCH,
MACRO_EMACS_MOVE_TO_PREV_MARKED_POS,
MACRO_EMACS_CcCc,
MACRO_EMACS_CAPTURE_TODO,
MACRO_EMACS_CAPTURE_NOTE,
MACRO_EMACS_CAPTURE_JOURNAL,
////////////////////////////////////////////////////
// Workaround macros
////////////////////////////////////////////////////
// sends '()' and shifts cursor one to the right
// directoly from the keyboard, since AHK does such
// a buggy job of it for some reason (and only for
// the normal parens)
MACRO_PAREN_PAIR,
MACRO_BRACKET_PAIR,
MACRO_CURLYBRACKET_PAIR,
////////////////////////////////////////////////////
// App Macros
////////////////////////////////////////////////////
// Foobar2k
MACRO_APP_FOOBAR2K_UnFOCUS,
MACRO_APP_FOOBAR2K_SEEK_FW1MIN,
MACRO_APP_FOOBAR2K_RATE1,
MACRO_APP_FOOBAR2K_PAUSE,
MACRO_FOCUS_IDE,
////////////////////////////////////////////////////
// "Abstract" AHK Command Keys
// (as opposed to named ones)
// Their actual function is assigned in AHK
////////////////////////////////////////////////////
MACRO_RFN_PGDN, // RFN+PGDN
MACRO_RFN_PGUP, // RFN+PGUP
MACRO_BUTTERFLY, // butterfly key
MACRO_LED_KEY,
MACRO_SHUTDOWN,
////////////////////////////////////////////////////
// IDE Development Keys
////////////////////////////////////////////////////
MACRO_DEV_GENERATE,
MACRO_DEV_NEW_CLASS,
////////////////////////////////////////////////////
// OTHER
////////////////////////////////////////////////////
MACRO_PRINT_MY_MAIL,
MACRO_PRINT_STRING_0,
MACRO_PRINT_STRING_1,
MACRO_PRINT_STRING_2,
MACRO_PRINT_STRING_3,
MACRO_PRINT_STRING_4
};
enum TapDanceKey {
CAPTURE_TEMPLATES,
LeftBrackets,
RightBrackets,
// single tap: call helm-filtered-bookmarks
// double tap: set bookmark
Bookmarks,
OrgAgendaAndCapture,
OrgClocking,
Butterfly,
// Because something like Key_Copy hasn't worked yet
// (maybe it'll work after setting the HostID to Windows or smth)
CopyCut,
Music
};
/** The Model 01's key layouts are defined as 'keymaps'. By default, there are three
* keymaps: The standard QWERTY keymap, the "Function layer" keymap and the "Numpad"
* keymap.
*
* Each keymap is defined as a list using the 'KEYMAP_STACKED' macro, built
* of first the left hand's layout, followed by the right hand's layout.
*
* Keymaps typically consist mostly of `Key_` definitions. There are many, many keys
* defined as part of the USB HID Keyboard specification. You can find the names
* (if not yet the explanations) for all the standard `Key_` defintions offered by
* Kaleidoscope in these files:
* https://github.com/keyboardio/Kaleidoscope/blob/master/src/key_defs_keyboard.h
* https://github.com/keyboardio/Kaleidoscope/blob/master/src/key_defs_consumerctl.h
* https://github.com/keyboardio/Kaleidoscope/blob/master/src/key_defs_sysctl.h
* https://github.com/keyboardio/Kaleidoscope/blob/master/src/key_defs_keymaps.h
*
* Additional things that should be documented here include
* using ___ to let keypresses fall through to the previously active layer
* using XXX to mark a keyswitch as 'blocked' on this layer
* using ShiftToLayer() and LockLayer() keys to change the active keymap.
* keeping NUM and FN consistent and accessible on all layers
*
* The PROG key is special, since it is how you indicate to the board that you
* want to flash the firmware. However, it can be remapped to a regular key.
* When the keyboard boots, it first looks to see whether the PROG key is held
* down; if it is, it simply awaits further flashing instructions. If it is
* not, it continues loading the rest of the firmware and the keyboard
* functions normally, with whatever binding you have set to PROG. More detail
* here: https://community.keyboard.io/t/how-the-prog-key-gets-you-into-the-bootloader/506/8
*
* The "keymaps" data structure is a list of the keymaps compiled into the firmware.
* The order of keymaps in the list is important, as the ShiftToLayer(#) and LockLayer(#)
* macros switch to key layers based on this list.
*
*
* A key defined as 'ShiftToLayer(FUNCTION)' will switch to FUNCTION while held.
* Similarly, a key defined as 'LockLayer(NUMPAD)' will switch to NUMPAD when tapped.
*/
/**
* Layers are "0-indexed" -- That is the first one is layer 0. The second one is layer 1.
* The third one is layer 2.
* This 'enum' lets us use names like QWERTY, FUNCTION, and NUMPAD in place of
* the numbers 0, 1 and 2.
*
*/
// enum { QWERTY, FUNCTION, NUMPAD }; // layers
enum {
DVORAK,
//SHIFT,
// Left FN
LFN,
// Right FN
RFN,
LFNandRFN,
// AltLayer,
// For numpad, etc
LFN2,
// For app control (foobar2k etc)
RFN2,
LFNandLFN2,
// FACTORY_QWERTY,
// FACTORY_FN
};
/* Key modifiers
LCTRL(k)
LALT(k)
RALT(k)
LSHIFT(k)
LGUI(k)
Turns out most R-variants (eg RSHIFT) are missing because they take
up to many bits in the keys variable or something, and if
they were to be used, there would be fewer layers available in total
*/
#ifndef NAMED_HOTKEYS
//////////////////////////////////////////////
//
//////////////////////////////////////////////
// These Umlaute key combinations are fixed by the external EURKey layout
#define CHAR_UMLAUT_A RALT(Key_A)
#define CHAR_UMLAUT_CA RALT(LSHIFT(Key_A)) // capital A
#define CHAR_UMLAUT_O RALT(Key_O)
#define CHAR_UMLAUT_CO RALT(LSHIFT(Key_O)) // capital O
#define CHAR_UMLAUT_U RALT(Key_U)
#define CHAR_UMLAUT_CU RALT(LSHIFT(Key_U)) // capital U
#define CHAR_UMLAUT_S RALT(Key_S)
//////////////////////////////////////////////
// LCTRL+LSHIFT + F_<0-24>
//////////////////////////////////////////////
// #define EDITOR_GOTO_PREV_BUFFER LCTRL(LSHIFT(Key_F1)) // Fore some reason, this won't register in IntelliJ
// #define EDITOR_GOTO_NEXT_BUFFER LCTRL(LSHIFT(Key_F2)) // ... while this one works
//////////////////////////////////////////////
// LCTRL+LSHIFT+LALT + F_<0-24>
//////////////////////////////////////////////
// General editor and dev macros
#define EDITOR_FIND_IN_FILES LCTRL(LSHIFT(LALT(Key_F1))) // eg. Emacs' agenda search, IntelliJ's Find in PATH...
#define EDITOR_GOTO_PREV_BUFFER LCTRL(LSHIFT(LALT(Key_F2))) // Fore some reason, this won't register in IntelliJJ
#define EDITOR_GOTO_NEXT_BUFFER LCTRL(LSHIFT(LALT(Key_F3))) // ... while this one works
#define EDITOR_RENAME LCTRL(LSHIFT(LALT(Key_F4))) // former DEV_RENAME
#define EDITOR_SMART_ENTER LCTRL(LSHIFT(LALT(Key_F5))) // this is 'C-c C-c' in emacs and 'complete current statement' in intellij (former DEV_SMART_ENTER)
#define EDITOR_FIND_FILE LCTRL(LSHIFT(LALT(Key_F6)))
// case MACRO_DEV_GENERATE:
// return MACRO(D(LeftControl), D(LeftShift), D(LeftAlt), T(F4), U(LeftAlt), U(LeftControl), U(LeftShift));
// case MACRO_DEV_COMMENT:
// return MACRO(D(LeftControl), D(LeftShift), D(LeftAlt), T(F5), U(LeftAlt), U(LeftControl), U(LeftShift));
// // case MACRO_DEV_NEW_CLASS:
// // return MACRO(D(LeftControl), D(LeftShift), D(LeftAlt), T(F5), U(LeftAlt), U(LeftControl), U(LeftShift));
// case MACRO_FIND_FILE:
// return MACRO(D(LeftControl), D(LeftShift), D(LeftAlt), T(F6), U(LeftAlt), U(LeftControl), U(LeftShift));
//
//
// case MACRO_ORG_CLOCK_IN:
// return MACRO(D(LeftControl), D(LeftShift), D(LeftAlt), T(F7), U(LeftAlt), U(LeftControl), U(LeftShift));
// case MACRO_ORG_CLOCK_OUT:
// return MACRO(D(LeftControl), D(LeftShift), D(LeftAlt), T(F8), U(LeftAlt), U(LeftControl), U(LeftShift));
// #define EDITOR_GOTO_PREV_BUFFER LCTRL(LSHIFT(LALT(Key_F17))) // Fore some reason, this won't register in IntelliJ
// #define EDITOR_GOTO_NEXT_BUFFER LCTRL(LSHIFT(LALT(Key_F18))) // ... while this one works
// Worflow for proofreading:
// 1. select the text and call chatgpt-shell-proofread-german-region
// 2. call copy-proofread-result-and-delete-other-window
// (I would have loved to put them together in a single function, but that would require to install a hook for when chatgpt is done streaming, and i do not have the time for it right now)
#define EMACS_SWITCH_TO_OTHER_WINDOW LCTRL(LSHIFT(LALT(Key_F9))) // delete other window
#define EMACS_DELETE_OTHER_WINDOW LCTRL(LSHIFT(LALT(Key_F10))) // delete other window
#define EMACS_COPY_PROOFREAD_RESULT_AND_DELETE_OTHER_WINDOW LCTRL(LSHIFT(LALT(Key_F11)))
#define EMACS_CHATGPT_PROOFREAD_DE LCTRL(LSHIFT(LALT(Key_F12))) //call chatgpt-shell-proofread-german-region
// #define EMACS_OTHER_WINDOW LCTRL(LSHIFT(LALT(Key_F12))) // switch to other window
#define EDITOR_LINE_COMMENT LCTRL(LSHIFT(LALT(Key_F13))) // insert eg // in java or % in latex
#define TEXT_EXPAND LCTRL(LSHIFT(LALT(Key_F14))) // eg expand word from dictionary
#define EMACS_FLUSH_TO_FILE LCTRL(LSHIFT(LALT(Key_F15))) // like flush scratch or chatgpt-shell buffer to file (save content)
#define EMACS_CHATGPT_CLEAR LCTRL(LSHIFT(LALT(Key_F16)))
#define EMACS_CHATGPT LCTRL(LSHIFT(LALT(Key_F17)))
#define EMACS_SCRATCH LCTRL(LSHIFT(LALT(Key_F18)))
#define EDITOR_ACE_JUMP LCTRL(LSHIFT(LALT(Key_F19)))
#define EDITOR_SHOW_BUFFERS LCTRL(LSHIFT(LALT(Key_F20)))
#define EDITOR_SHOW_BOOKMARKS LCTRL(LSHIFT(LALT(Key_F21)))
#define EDITOR_SET_BOOKMARK LCTRL(LSHIFT(LALT(Key_F22)))
#define CAPTURE_TODO LCTRL(LSHIFT(LALT(Key_F23)))
#define CAPTURE_NOTE LCTRL(LSHIFT(LALT(Key_F24)))
//////////////////////////////////////////////
// LCTRL+LSHIFT+LALT+LGUI + F_<0-24>
//////////////////////////////////////////////
#define FOCUS_Browser LGUI(Key_1) //LCTRL(LSHIFT(LALT(LGUI(Key_F2))))
#define FOCUS_Emacs LGUI(Key_3) //LCTRL(LSHIFT(LALT(LGUI(Key_F1))))
#define FOCUS_IDE1 LGUI(Key_4) //LCTRL(LSHIFT(LALT(LGUI(Key_F3))))
#define FOCUS_Terminal LGUI(Key_5) //LCTRL(LSHIFT(LALT(LGUI(Key_F5))))
#define FOCUS_IDE2 /*LGUI(Key_1)*/ LCTRL(LSHIFT(LALT(LGUI(Key_F4))))
// couple more focus things, maybe foobar2k, .. till F9
#define OPNEN_IN_TERMINAL LCTRL(LSHIFT(LALT(LGUI(Key_F10))))
// 3 window docking shortcuts (dock left, right, maximize)
#define WINDOW_MAXIMIZE LCTRL(LSHIFT(LALT(LGUI(Key_F11))))
#define WINDOW_DOCK_LEFT LGUI(Key_LeftArrow) //LCTRL(LSHIFT(LALT(LGUI(Key_F12))))
#define WINDOW_DOCK_RIGHT LGUI(Key_RightArrow) //LCTRL(LSHIFT(LALT(LGUI(Key_F13))))
// ... till F15
// Text formatting... eg format as bold, italic, verbatim
#define TEXT_FORMAT_1 LCTRL(LSHIFT(LALT(LGUI(Key_F16))))
#define TEXT_FORMAT_2 LCTRL(LSHIFT(LALT(LGUI(Key_F17))))
#define TEXT_FORMAT_3 LCTRL(LSHIFT(LALT(LGUI(Key_F18))))
// till F20
// Music
#define MUSIC_TOGGLE_PAUSE LSHIFT(LALT(LGUI(Key_F7)))
#define MUSIC_NEXT_SONG LSHIFT(LALT(LGUI(Key_F8)))
// none assigned yet
//////////////////////////////////////////////
// Others
//////////////////////////////////////////////
#define EMACS_JustOneSpace LALT(Key_Space)
#define EMACS_KillLine LCTRL(Key_K)
#define EMACS_Command LALT(Key_X) /* is: M-x */
#define EMACS_SetMark LCTRL(Key_Space)
#define EMACS_CenterScreen LCTRL(Key_L)
#define EMACS_RemoveWhitespaces LCTRL(Key_F13)
#define EMACS_EditLines LCTRL(Key_F14)
#define EMACS_MarkAllLikeThis LCTRL(Key_F15)
#define EMACS_MoveToPrevMarkedPos M(MACRO_EMACS_MOVE_TO_PREV_MARKED_POS)
//#define EMACS_MoveLineUp M(MACRO_MOVE_LINE_UP) //LCTRL(Key_F16)
//#define EMACS_MoveLineDown M(MACRO_MOVE_LINE_DOWN) //LCTRL(Key_F17)
#define All_MoveLineUp LCTRL(Key_F16)
#define All_MoveLineDown LCTRL(Key_F17)
#define All_CopyLine LCTRL(Key_F18)
#define EMACS_CutLine LCTRL(Key_F19)
#define EMACS_Refile M(MACRO_EMACS_ORG_REFILE)// LCTRL(Key_F20) // use C-c C-w since it's view-dependant (agenda, normal)
#define EMACS_InsertLink LCTRL(Key_F21)
//#define EMACS_AceJump MACRO_ACE_JUMP //M(MACRO_ACE_JUMP)
#define EMACS_SwitchWindow LCTRL(Key_F23) // uses ace-window
#define EMACS_CcCc M(MACRO_EMACS_CcCc) // C-c C-c
#define EMACS_MarkNextLikeThis LCTRL(Key_F24)
#define EMACS_CaptureTodo M(MACRO_EMACS_CAPTURE_TODO)
#define EMACS_CaptureNote M(MACRO_EMACS_CAPTURE_NOTE)
#define EMACS_CaptureJournal M(MACRO_EMACS_CAPTURE_JOURNAL)
//#define EMACS_DeleteWindow M(MACRO_DELETE_WINDOW)
#define EMACS_KillBuffer M(MACRO_KILL_BUFFER)
#define EMACS_ForwardDeleteWord LCTRL(LSHIFT(Key_F7)) // M(MACRO_FORWARD_DELETE_WORD)
#define LOCKSCREEN LGUI(Key_L)
#define WINDOWS_Shutdown M(MACRO_SHUTDOWN)
//#define DEV_FindInPath M(MACRO_DEV_FIND_IN_PATH)
#define All_SaveFile LCTRL(Key_S) //M(MACRO_SAVE_FILE) //LCTRL(Key_S)
#define All_Copy LCTRL(Key_C) //M(MACRO_COPY)
#define All_Cut LCTRL(Key_X) //M(MACRO_CUT)
#define All_Paste LCTRL(Key_V) //M(MACRO_PASTE)
#define EMACS_KeyboardQuit LCTRL(Key_G) // C-g // lets try C-z for undo (and implicit keyboard-quit)
#define All_Undo LCTRL(Key_Z) // M(MACRO_UNDO)
#define All_SearchForward LCTRL(Key_F) // M(MACRO_FIND)
#define EMACS_SearchBackward LCTRL(Key_R) // Emacs only functionality??
#endif
KEYMAPS
(
[DVORAK] = KEYMAP_STACKED
(___, Key_1, Key_2, Key_3, Key_4, Key_5, TD(TapDanceKey::Music),
Key_Backtick, Key_Quote, Key_Comma, Key_Period, Key_P, Key_Y, M(MACRO_PAREN_PAIR),
All_Paste, Key_A, Key_O, Key_E, Key_U, Key_I,
TD(TapDanceKey::CopyCut), Key_Semicolon, Key_Q, Key_J, Key_K, Key_X, Key_Escape,
/*OSM(LeftShift)*/Key_LeftShift, Key_Space, Key_LeftAlt, ShiftToLayer(LFN2),
ShiftToLayer(LFN),
TD(TapDanceKey::CAPTURE_TEMPLATES), Key_6, Key_7, Key_8, Key_9, Key_0, ___,
___, Key_F, Key_G, Key_C, Key_R, Key_L, Key_Slash,
Key_D, Key_H, Key_T, Key_N, Key_S, Key_Minus,
EMACS_CHATGPT, Key_B, Key_M, Key_W, Key_V, Key_Z, Key_Equals,
ShiftToLayer(RFN2), Key_Enter, Key_Backspace, Key_RightControl,
ShiftToLayer(RFN)),
[LFN] = KEYMAP_STACKED
(___, Key_F1, Key_F2, Key_F3, Key_F4, Key_F5, Key_F12,
___, ___, ___, ___, ___, All_Paste, ___,
___, Key_Home, EMACS_SetMark, Key_End, Key_Tab, EDITOR_ACE_JUMP,
___, ___, ___, ___, EMACS_KillLine, ___, ___,
___, EMACS_JustOneSpace, Key_LeftAlt, ShiftToLayer(LFNandLFN2),
___,
Key_RightGui, Key_F6, Key_F7, Key_F8, Key_F9, Key_F10, ___,
___, EMACS_CHATGPT_PROOFREAD_DE, EMACS_KeyboardQuit, Key_UpArrow, TEXT_EXPAND, EMACS_CenterScreen, Key_Backslash,
EMACS_ForwardDeleteWord, Key_LeftArrow, Key_DownArrow, Key_RightArrow, All_SaveFile, ___,
EMACS_CHATGPT_CLEAR, EDITOR_SHOW_BOOKMARKS, EMACS_RemoveWhitespaces, All_Cut, ___, M(MACRO_AUTOCOMPLETE), Key_Pipe,
/*RFN2key, don't override, it should open yet another layer, eg via LFN+RFN2 :*/___, EDITOR_SMART_ENTER, Key_Delete, ___/* CTRL: don't override or (LFN|RFN)+CTRL+SOME_KEY won't work*/,
ShiftToLayer(LFNandRFN)/*explanation: right on this layer, we already are on the first layer (i.e LFN), so from here the second layer key must then activate the next layer (the combined layer of LFN+SOME_OTHER_LAYER)*/),
// old
// Key_RightGui, Key_F6, Key_F7, Key_F8, Key_F9, Key_F10, Key_F11,
// EMACS_SCRATCH, EDITOR_FIND_FILE, EMACS_KeyboardQuit, Key_UpArrow, ___, EMACS_CenterScreen, Key_Backslash,
// EMACS_ForwardDeleteWord, Key_LeftArrow, Key_DownArrow, Key_RightArrow, All_SaveFile, ___,
// EMACS_CHATGPT_CLEAR, EDITOR_SMART_ENTER, TD(TapDanceKey::Bookmarks), EMACS_RemoveWhitespaces, All_Cut, ___, M(MACRO_AUTOCOMPLETE), Key_Pipe,
// ___, /*LFN+RFN2 should open yet another layer!*/ Key_Delete, ___/*Cannot set this or LFN+CTRL+a (go to beginning) wont work*/,
// ShiftToLayer(LFNandRFN)),
[RFN] = KEYMAP_STACKED
(LOCKSCREEN, Key_F1, Key_F2, Key_F3, Key_F4, Key_F5, M(MACRO_CURLYBRACKET_PAIR),
___, FOCUS_IDE1, FOCUS_Browser, FOCUS_Emacs, FOCUS_IDE2, FOCUS_Terminal, TD(TapDanceKey::RightBrackets),
M(MACRO_ZOOM_IN), CHAR_UMLAUT_A, CHAR_UMLAUT_O, LSHIFT(Key_Quote), CHAR_UMLAUT_U, CHAR_UMLAUT_S,
M(MACRO_ZOOM_OUT), EMACS_SwitchWindow, EMACS_KillBuffer, EDITOR_GOTO_PREV_BUFFER, EDITOR_GOTO_NEXT_BUFFER, EMACS_Command, M(MACRO_BRACKET_PAIR),
Key_mouseBtnR, Key_mouseBtnL, Key_mouseBtnR, ___,
ShiftToLayer(LFNandRFN),
___, Key_F6, Key_F7, Key_F8, Key_F9, Key_F10, Key_F11,
___, ___, All_Undo, Key_mouseUp, EMACS_SearchBackward, ___, Key_F12,
___, Key_mouseL, Key_mouseDn, FOCUS_Terminal, All_SearchForward, ___,
___, TD(TapDanceKey::Bookmarks), ___, ___, EMACS_MoveToPrevMarkedPos, ___, ___,
___, ___, ___, ___,
___),
[LFNandRFN] = KEYMAP_STACKED
(___, TEXT_FORMAT_1, TEXT_FORMAT_2, TEXT_FORMAT_3, ___, ___, Key_LEDEffectNext,
___, ___, ___, All_MoveLineUp, ___, ___, ___,
___, EMACS_InsertLink, ___, All_MoveLineDown, ___, ___,
___, ___, ___, EMACS_CaptureJournal, ___, ___, ___,
___, ___, ___, ___,
___,
EMACS_FLUSH_TO_FILE, ___, ___, ___, ___, ___, ___,
___, EMACS_EditLines, EMACS_CutLine, All_CopyLine, EMACS_Refile, ___, ___,
EMACS_MarkAllLikeThis, ___, EMACS_CaptureTodo, EMACS_CaptureNote, EDITOR_FIND_IN_FILES, ___,
Key_LEDEffectNext, EMACS_MarkNextLikeThis, ___, ___, ___, ___, ___,
___, ___, ___, ___,
___),
[LFN2] = KEYMAP_STACKED
(___, ___, ___, ___, ___, ___, WINDOW_DOCK_LEFT,
___, ___, ___, ___, ___, ___, WINDOW_MAXIMIZE,
Key_PageUp, M(MACRO_APP_BROWSER_OPEN_SEARCH), M(MACRO_APP_FOOBAR2K_UnFOCUS), M(MACRO_APP_FOOBAR2K_PAUSE), M(MACRO_APP_FOOBAR2K_SEEK_FW1MIN), ___,
Key_PageDown, LSHIFT(Key_Semicolon), ___, ___, ___, ___, WINDOW_DOCK_RIGHT,
___, ___, ___, ___,
ShiftToLayer(LFNandLFN2),
EDITOR_FIND_FILE, M(MACRO_PRINT_MY_MAIL), ___, ___, ___, ___, ___,
EMACS_SCRATCH, Key_KeypadAdd, Key_4, Key_5, Key_6, Key_Equals, ___,
Key_0, Key_1, Key_2, Key_3, Key_KeypadMultiply, ___,
___, Key_KeypadSubtract, Key_7, Key_8, Key_9, Key_KeypadDivide, ___,
Key_Space, Key_Enter, ___, Key_Space,
___),
// RFN2 is for development stuff
[RFN2] = KEYMAP_STACKED
(M(MACRO_PRINT_STRING_0), M(MACRO_PRINT_STRING_1), M(MACRO_PRINT_STRING_2), M(MACRO_PRINT_STRING_3), M(MACRO_PRINT_STRING_4), ___, M(MACRO_LED_DEACTIVATION),
___, ___, ___, ___, ___, ___, ___,
___, CHAR_UMLAUT_CA, CHAR_UMLAUT_CO, ___, CHAR_UMLAUT_CU, ___,
___, ___, ___/*EMACS_DELETE_OTHER_WINDOW*/, ___, ___, ___, ___,
___, ___, ___, ___,
___,
___, ___, ___, ___, ___, ___, ___,
___, ___, M(MACRO_DEV_GENERATE), EDITOR_LINE_COMMENT, EDITOR_RENAME, ___, ___,
___, ___, ___, ___, ___, ___,
___, ___, ___, ___, ___, ___, ___,
___, ___, ___, ___,
___),
[LFNandLFN2] = KEYMAP_STACKED
(___, ___, ___, ___, ___, ___, ___,
___, ___, ___, ___, ___, ___, ___,
___, ___, ___, ___, ___, ___,
___, ___, ___, ___, ___, ___, ___,
___, ___, ___, ___,
___,
___, ___, ___, ___, ___, ___, ___,
___, EMACS_COPY_PROOFREAD_RESULT_AND_DELETE_OTHER_WINDOW, ___, ___, ___, ___, ___,
EMACS_DELETE_OTHER_WINDOW, ___, ___, ___, ___, ___,
___, EMACS_SWITCH_TO_OTHER_WINDOW, ___, ___, ___, ___, ___,
___, ___, ___, ___,
___),
// [AltLayer] = KEYMAP_STACKED // look at how many ALT keys are i am replicating. the only keys that changed are pageUp/Down. Why bother
// (___, ___, ___, ___, ___, ___, ___,
// ___, ___, ___, ___, ___, ___, ___,
// ___, ___, ___, ___, ___, ___,
// ___, ___, LALT(Key_Q), ___, ___, ___, ___,
// ___, ___, ___, ___,
// ___,
//
// ___, ___, ___, ___, ___, ___, ___,
// ___, ___, ___, Key_PageUp, ___, ___, ___,
// LALT(Key_D), LALT(Key_H), Key_PageDown, LALT(Key_N), LALT(Key_S), ___,
// ___, ___, ___, LALT(Key_W), ___, ___, ___,
// ___, LALT(Key_Enter), LALT(Key_Backspace), ___,
// ___),
// ___, ___, ___, ___, ___, ___, ___,
// ___, ___, ___, LALT(Key_PageUp), ___, ___, ___,
// LALT(Key_D), LALT(Key_LeftArrow), LALT(Key_PageDown), LALT(Key_RightArrow), LALT(Key_S), ___,
// ___, ___, ___, LALT(Key_W), ___, ___, ___,
// ___, LALT(Key_Enter), ___, ___,
// ___),
) // KEYMAPS(
/* Re-enable astyle's indent enforcement */
// *INDENT-ON*
/** versionInfoMacro handles the 'firmware version info' macro
* When a key bound to the macro is pressed, this macro
* prints out the firmware build information as virtual keystrokes
*/
static void versionInfoMacro(uint8_t keyState) {
if (keyToggledOn(keyState)) {
Macros.type(PSTR(BUILD_INFORMATION));
}
}
static void printMyMail(uint8_t keyState) {
if (keyToggledOn(keyState)) {
Macros.type(PSTR(MY_MAIL));
}
}
static void printString0(uint8_t keyState) {
if (keyToggledOn(keyState)) {
Macros.type(PSTR(STRING_0));
}
}
static void printString1(uint8_t keyState) {
if (keyToggledOn(keyState)) {
Macros.type(PSTR(STRING_1));
}
}
static void printString2(uint8_t keyState) {
if (keyToggledOn(keyState)) {
Macros.type(PSTR(STRING_2));
}
}
static void printString3(uint8_t keyState) {
if (keyToggledOn(keyState)) {
Macros.type(PSTR(STRING_3));
}
}
static void printString4(uint8_t keyState) {
if (keyToggledOn(keyState)) {
Macros.type(PSTR(STRING_4));
}
}
/** anyKeyMacro is used to provide the functionality of the 'Any' key.
*
* When the 'any key' macro is toggled on, a random alphanumeric key is
* selected. While the key is held, the function generates a synthetic
* keypress event repeating that randomly selected key.
*
*/
/*
static void anyKeyMacro(uint8_t keyState) {
static Key lastKey;
if (keyToggledOn(keyState)) {
lastKey.setKeyCode(Key_A.getKeyCode() + (uint8_t)(millis() % 36));
}
if (keyIsPressed(keyState))
Kaleidoscope.hid().keyboard().pressKey(lastKey);
}
*/
/** macroAction dispatches keymap events that are tied to a macro
to that macro. It takes two uint8_t parameters.
The first is the macro being called (the entry in the 'enum' earlier in this file).
The second is the state of the keyswitch. You can use the keyswitch state to figure out
if the key has just been toggled on, is currently pressed or if it's just been released.
The 'switch' statement should have a 'case' for each entry of the macro enum.
Each 'case' statement should call out to a function to handle the macro in question.
*/
//#define FNTOAHK(KEY) MACRODOWN(D(RightGui), D(RightControl), T(KEY), U(RightControl), U(RightGui))
//#define FNtoAHK(N1, N2, N3) MACRODOWN(T(F12), T(N1), T(N2), T(N3))
//#define FNtoAHK(N1, N2) MACRODOWN(T(F13), T(N1), T(N2))
#define FNtoAHK(N1, N2) MACRO_NONE;
const macro_t* macroAction(uint8_t macroIndex, KeyEvent &event) {
if (keyToggledOn(event.state)) {
switch (macroIndex) {
case MACRO_VERSION_INFO:
versionInfoMacro(event.state);
break;
case MACRO_PRINT_MY_MAIL:
printMyMail(event.state);
break;
case MACRO_PRINT_STRING_0:
printString0(event.state);
break;
case MACRO_PRINT_STRING_1:
printString1(event.state);
break;
case MACRO_PRINT_STRING_2:
printString2(event.state);
break;
case MACRO_PRINT_STRING_3:
printString3(event.state);
break;
case MACRO_PRINT_STRING_4:
printString4(event.state);
break;
//case MACRO_ANY:
//anyKeyMacro(event.state, Key_O); // too many args to anyKeyMacro
//break;
// case MACRO_TOGGLE_FACTORY_LAYOUT:
// toggleFactoryLayout(event.state);
// break;
case MACRO_LED_DEACTIVATION:
//deactivateLeds(event.state);
break;
// case MACRO_FORWARD_DELETE_WORD:
//return MACRO(T(F7), T(N1), T(N2))
case MACRO_EMACS_CcCc:
return MACRO(D(RightControl), T(C), T(C), U(RightControl));
case MACRO_EMACS_ORG_REFILE:
return MACRO(D(RightControl), T(C), T(W), U(RightControl));
case MACRO_EMACS_MOVE_TO_PREV_MARKED_POS:
return MACRO(D(RightControl), T(U), T(Space), U(RightControl));
case MACRO_PAREN_PAIR:
return MACRO(T(LeftParen), T(RightParen), T(LeftArrow));
case MACRO_BRACKET_PAIR:
return MACRO(T(LeftBracket), T(RightBracket), T(LeftArrow));
case MACRO_CURLYBRACKET_PAIR:
return MACRO(T(LeftCurlyBracket), T(RightCurlyBracket), T(LeftArrow));
case MACRO_HEATMAP:
//HeatmapEffect.activate();
break;
//////////////////////////////////////////////////////////////
// C-F<number>: See #define directives using LCTRL(F<number>)
//////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
// C-S-M-F<number> shortcuts for development (a reserved range at least)
////////////////////////////////////////////////////////////////////////
/* case MACRO_GOTO_PREV_BUFFER:
return MACRO(D(LeftControl), D(LeftShift), D(LeftAlt), T(F17), U(LeftAlt), U(LeftControl), U(LeftShift));
case MACRO_GOTO_NEXT_BUFFER:
return MACRO(D(LeftControl), D(LeftShift), D(LeftAlt), T(F18), U(LeftAlt), U(LeftControl), U(LeftShift));
case MACRO_ACE_JUMP:
return MACRO(D(LeftControl), D(LeftShift), D(LeftAlt), T(F19), U(LeftAlt), U(LeftControl), U(LeftShift));
case MACRO_SHOW_BUFFERS:
return MACRO(D(LeftControl), D(LeftShift), D(LeftAlt), T(F20), U(LeftAlt), U(LeftControl), U(LeftShift));
case MACRO_SHOW_BOOKMARKS:
return MACRO(D(LeftControl), D(LeftShift), D(LeftAlt), T(F21), U(LeftAlt), U(LeftControl), U(LeftShift));
case MACRO_SET_BOOKMARK:
return MACRO(D(LeftControl), D(LeftShift), D(LeftAlt), T(F22), U(LeftAlt), U(LeftControl), U(LeftShift));*/
// case MACRO_AUTOCOMPLETE:
// return MACRO(D(LeftControl), D(LeftShift), D(LeftAlt), T(F6), U(LeftAlt), U(LeftControl), U(LeftShift));
// case MACRO_SAVE_FILE:
// //return FNtoAHK(0,0);
// return MACRO(D(LeftControl), D(LeftShift), T(F8), U(LeftControl), U(LeftShift));
// case MACRO_FIND:
// //return FNtoAHK(0,0);
// return MACRO(D(LeftControl), D(LeftShift), T(F8), U(LeftControl), U(LeftShift));
// case MACRO_VIELE_GR:
// return FNtoAHK(0,8);
//
// case MACRO_LENNY:
// return FNtoAHK(0,9);
//
// case MACRO_SHRUG:
// //return FNTOAHK(TODO);
//
// case MACRO_DISAPPROVAL:
// return FNTOAHK(F);
//9 - 12 are free
case MACRO_APP_FOOBAR2K_SEEK_FW1MIN:
return FNtoAHK(1,3);
case MACRO_APP_FOOBAR2K_RATE1:
return FNtoAHK(1,4);
case MACRO_APP_FOOBAR2K_PAUSE:
return FNtoAHK(1,5);
case MACRO_APP_BROWSER_OPEN_SEARCH:
return FNtoAHK(1,6);
case MACRO_FOCUS_EMACS:
return FNtoAHK(1,8);
// case MACRO_DELETE_WINDOW:
// return FNtoAHK(1,9);
// case MACRO_ENTER_KEY:
// return FNtoAHK(2,0);
case MACRO_ORG_EMACS_CAPTURE:
return FNtoAHK(2,1);
case MACRO_ORG_CLOCK_GOTO:
return FNtoAHK(2,2);
// case MACRO_ORG_CLOCK_IN:
// return FNtoAHK(2,3);
// case MACRO_ORG_CLOCK_OUT:
// return FNtoAHK(2,4);
case MACRO_APP_FOOBAR2K_UnFOCUS:
return FNtoAHK(2,5);
case MACRO_COPY: //not in use
return FNtoAHK(2,6);
case MACRO_CUT: //not in use
return FNtoAHK(2,7);
case MACRO_PASTE: //not in use
return FNtoAHK(2,8);
case MACRO_ZOOM_IN:
return MACRO(D(LeftControl), T(mouseScrollUp), U(LeftControl));
// handleKeyswitchEvent(Key_LeftControl, Macros.row, Macros.col, keyState);
// handleKeyswitchEvent(Key_mouseScrollUp, Macros.row, Macros.col, keyState);
// break;
case MACRO_ZOOM_OUT:
return MACRO(D(LeftControl), T(mouseScrollDn), U(LeftControl));
//handleKeyswitchEvent(Key_LeftControl, Macros.row, Macros.col, keyState);
//handleKeyswitchEvent(Key_mouseScrollDn, Macros.row, Macros.col, keyState);
//break;
//case MACRO_RFN_PGDN:
//return FNtoAHK(2,9);
//case MACRO_RFN_PGUP:
//return FNtoAHK(3,0);
case MACRO_BUTTERFLY:
return FNtoAHK(3,1);
// case MACRO_EMACS_AGENDA_SEARCH:
// return FNtoAHK(3,2);
case MACRO_LED_KEY:
return FNtoAHK(3,3);
// FNtoAHK(3,4) not in use
case MACRO_UNDO:
return FNtoAHK(3,5);
case MACRO_SHUTDOWN:
return FNtoAHK(3,6);
case MACRO_EMACS_CAPTURE_TODO:
return FNtoAHK(3,7);
case MACRO_EMACS_CAPTURE_NOTE:
return FNtoAHK(3,8);
case MACRO_EMACS_CAPTURE_JOURNAL:
return FNtoAHK(3,9);
//42 till 45 are free
case MACRO_FOCUS_IDE:
return FNtoAHK(4,6);
case MACRO_KILL_BUFFER:
return FNtoAHK(4,7);
}
}
return MACRO_NONE;
}
void tapDanceAction(uint8_t tap_dance_index, KeyAddr key_addr, uint8_t tap_count,
kaleidoscope::plugin::TapDance::ActionType tap_dance_action) {
//void tapDanceAction(uint8_t tap_dance_index, byte row, byte col, uint8_t tap_count,
// kaleidoscope::plugin::TapDance::ActionType tap_dance_action) {
switch (tap_dance_index) {
case TapDanceKey::CAPTURE_TEMPLATES: {
return tapDanceActionKeys(tap_count, tap_dance_action, CAPTURE_NOTE, CAPTURE_TODO);
}
case TapDanceKey::LeftBrackets: {
return tapDanceActionKeys(tap_count, tap_dance_action, M(MACRO_PAREN_PAIR), M(MACRO_BRACKET_PAIR), M(MACRO_CURLYBRACKET_PAIR));
}
case TapDanceKey::RightBrackets: {
return tapDanceActionKeys(tap_count, tap_dance_action, Key_RightParen, Key_RightBracket, Key_RightCurlyBracket);
}
case TapDanceKey::Bookmarks: {
return tapDanceActionKeys(tap_count, tap_dance_action, /*EDITOR_SHOW_BOOKMARKS,*/ EDITOR_SHOW_BUFFERS, EDITOR_SET_BOOKMARK);
}
// case TapDanceKey::OrgAgendaAndCapture: {
// return tapDanceActionKeys(tap_count, tap_dance_action, M(MACRO_ENTER_KEY), M(MACRO_ORG_EMACS_CAPTURE));
// }
/* case TapDanceKey::OrgClocking: {
return tapDanceActionKeys(tap_count, tap_dance_action, M(MACRO_ORG_CLOCK_GOTO), M(MACRO_ORG_CLOCK_IN), M(MACRO_ORG_CLOCK_OUT));
} */
case TapDanceKey::CopyCut: {
return tapDanceActionKeys(tap_count, tap_dance_action, All_Copy, All_Cut);
}
case TapDanceKey::Music: {
return tapDanceActionKeys(tap_count, tap_dance_action, MUSIC_TOGGLE_PAUSE, MUSIC_NEXT_SONG);