1 /* Copyright 2016-2017 Jack Humbert
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 #ifndef QUANTUM_KEYCODES_H
17 #define QUANTUM_KEYCODES_H
19 #ifndef MIDI_ENABLE_STRICT
20 # define MIDI_ENABLE_STRICT 0
23 #if !MIDI_ENABLE_STRICT || (defined(MIDI_ENABLE) && defined(MIDI_ADVANCED))
24 # ifndef MIDI_TONE_KEYCODE_OCTAVES
25 # define MIDI_TONE_KEYCODE_OCTAVES 3
29 // Fillers to make layering more clear
30 #define _______ KC_TRNS
33 enum quantum_keycodes {
34 // Ranges used in shortcuts - not to be used directly
36 QK_BASIC_MAX = 0x00FF,
42 QK_RMODS_MIN = 0x1000,
49 QK_FUNCTION_MAX = 0x2FFF,
51 QK_MACRO_MAX = 0x3FFF,
52 QK_LAYER_TAP = 0x4000,
53 QK_LAYER_TAP_MAX = 0x4FFF,
56 QK_MOMENTARY = 0x5100,
57 QK_MOMENTARY_MAX = 0x51FF,
58 QK_DEF_LAYER = 0x5200,
59 QK_DEF_LAYER_MAX = 0x52FF,
60 QK_TOGGLE_LAYER = 0x5300,
61 QK_TOGGLE_LAYER_MAX = 0x53FF,
62 QK_ONE_SHOT_LAYER = 0x5400,
63 QK_ONE_SHOT_LAYER_MAX = 0x54FF,
64 QK_ONE_SHOT_MOD = 0x5500,
65 QK_ONE_SHOT_MOD_MAX = 0x55FF,
66 QK_TAP_DANCE = 0x5700,
67 QK_TAP_DANCE_MAX = 0x57FF,
68 QK_LAYER_TAP_TOGGLE = 0x5800,
69 QK_LAYER_TAP_TOGGLE_MAX = 0x58FF,
70 QK_LAYER_MOD = 0x5900,
71 QK_LAYER_MOD_MAX = 0x59FF,
74 QK_STENO_BOLT = 0x5A30,
75 QK_STENO_GEMINI = 0x5A31,
76 QK_STENO_MAX = 0x5A3F,
78 #ifdef SWAP_HANDS_ENABLE
79 QK_SWAP_HANDS = 0x5B00,
80 QK_SWAP_HANDS_MAX = 0x5BFF,
83 QK_MOD_TAP_MAX = 0x7FFF,
86 QK_UNICODE_MAX = 0xFFFF,
88 #ifdef UNICODEMAP_ENABLE
89 QK_UNICODEMAP = 0x8000,
90 QK_UNICODEMAP_MAX = 0xBFFF,
91 QK_UNICODEMAP_PAIR = 0xC000,
92 QK_UNICODEMAP_PAIR_MAX = 0xFFFF,
95 // Loose keycodes - to be used directly
99 MAGIC_SWAP_CONTROL_CAPSLOCK,
100 MAGIC_CAPSLOCK_TO_CONTROL,
101 MAGIC_SWAP_LALT_LGUI,
102 MAGIC_SWAP_RALT_RGUI,
104 MAGIC_SWAP_GRAVE_ESC,
105 MAGIC_SWAP_BACKSLASH_BACKSPACE,
108 MAGIC_UNSWAP_CONTROL_CAPSLOCK,
109 MAGIC_UNCAPSLOCK_TO_CONTROL,
110 MAGIC_UNSWAP_LALT_LGUI,
111 MAGIC_UNSWAP_RALT_RGUI,
113 MAGIC_UNSWAP_GRAVE_ESC,
114 MAGIC_UNSWAP_BACKSLASH_BACKSPACE,
116 MAGIC_UNSWAP_ALT_GUI,
118 MAGIC_TOGGLE_ALT_GUI,
134 // Audio on/off/toggle
139 // Faux clicky as part of main audio feature
147 #ifdef FAUXCLICKY_ENABLE
154 // Music mode on/off/toggle
162 // Music voice iterate
167 #if !MIDI_ENABLE_STRICT || (defined(MIDI_ENABLE) && defined(MIDI_BASIC))
173 #if !MIDI_ENABLE_STRICT || (defined(MIDI_ENABLE) && defined(MIDI_ADVANCED))
176 # if !MIDI_ENABLE_STRICT || MIDI_TONE_KEYCODE_OCTAVES > 0
177 MI_C = MIDI_TONE_MIN,
196 # if !MIDI_ENABLE_STRICT || MIDI_TONE_KEYCODE_OCTAVES > 1
216 # if !MIDI_ENABLE_STRICT || MIDI_TONE_KEYCODE_OCTAVES > 2
236 # if !MIDI_ENABLE_STRICT || MIDI_TONE_KEYCODE_OCTAVES > 3
256 # if !MIDI_ENABLE_STRICT || MIDI_TONE_KEYCODE_OCTAVES > 4
276 # if !MIDI_ENABLE_STRICT || MIDI_TONE_KEYCODE_OCTAVES > 5
296 # if !MIDI_ENABLE_STRICT || MIDI_TONE_KEYCODE_OCTAVES > 5
297 MIDI_TONE_MAX = MI_B_5,
298 # elif MIDI_TONE_KEYCODE_OCTAVES > 4
299 MIDI_TONE_MAX = MI_B_4,
300 # elif MIDI_TONE_KEYCODE_OCTAVES > 3
301 MIDI_TONE_MAX = MI_B_3,
302 # elif MIDI_TONE_KEYCODE_OCTAVES > 2
303 MIDI_TONE_MAX = MI_B_2,
304 # elif MIDI_TONE_KEYCODE_OCTAVES > 1
305 MIDI_TONE_MAX = MI_B_1,
306 # elif MIDI_TONE_KEYCODE_OCTAVES > 0
307 MIDI_TONE_MAX = MI_B,
311 MI_OCT_N2 = MIDI_OCTAVE_MIN,
321 MIDI_OCTAVE_MAX = MI_OCT_7,
322 MI_OCTD, // octave down
323 MI_OCTU, // octave up
326 MI_TRNS_N6 = MIDI_TRANSPOSE_MIN,
339 MIDI_TRANSPOSE_MAX = MI_TRNS_6,
340 MI_TRNSD, // transpose down
341 MI_TRNSU, // transpose up
344 MI_VEL_1 = MIDI_VELOCITY_MIN,
354 MIDI_VELOCITY_MAX = MI_VEL_10,
355 MI_VELD, // velocity down
356 MI_VELU, // velocity up
359 MI_CH1 = MIDI_CHANNEL_MIN,
375 MIDI_CHANNEL_MAX = MI_CH16,
376 MI_CHD, // previous channel
377 MI_CHU, // next channel
379 MI_ALLOFF, // all notes off
382 MI_PORT, // portamento
383 MI_SOST, // sostenuto
384 MI_SOFT, // soft pedal
387 MI_MOD, // modulation
388 MI_MODSD, // decrease modulation speed
389 MI_MODSU, // increase modulation speed
391 MI_BENDD, // Bend down
393 #endif // MIDI_ADVANCED
395 // Backlight functionality
426 // Momentum matching toggle
429 // Left shift, open paren
432 // Right shift, close paren
445 #ifdef BLUETOOTH_ENABLE
449 #ifdef KEY_LOCK_ENABLE
453 #ifdef TERMINAL_ENABLE
460 UNICODE_MODE_FORWARD,
461 UNICODE_MODE_REVERSE,
482 // Left control, open paren
485 // Right control, close paren
488 // Left control, open paren
491 // Right control, close paren
498 MAGIC_SWAP_LCTL_LGUI,
499 MAGIC_SWAP_RCTL_RGUI,
500 MAGIC_UNSWAP_LCTL_LGUI,
501 MAGIC_UNSWAP_RCTL_RGUI,
503 MAGIC_UNSWAP_CTL_GUI,
504 MAGIC_TOGGLE_CTL_GUI,
506 MAGIC_EE_HANDS_RIGHT,
515 // always leave at the end
519 // Ability to use mods in layouts
520 #define LCTL(kc) (QK_LCTL | (kc))
521 #define LSFT(kc) (QK_LSFT | (kc))
522 #define LALT(kc) (QK_LALT | (kc))
523 #define LGUI(kc) (QK_LGUI | (kc))
524 #define LCMD(kc) LGUI(kc)
525 #define LWIN(kc) LGUI(kc)
526 #define RCTL(kc) (QK_RCTL | (kc))
527 #define RSFT(kc) (QK_RSFT | (kc))
528 #define RALT(kc) (QK_RALT | (kc))
529 #define ALGR(kc) RALT(kc)
530 #define RGUI(kc) (QK_RGUI | (kc))
531 #define RCMD(kc) RGUI(kc)
532 #define RWIN(kc) RGUI(kc)
534 #define HYPR(kc) (QK_LCTL | QK_LSFT | QK_LALT | QK_LGUI | (kc))
535 #define MEH(kc) (QK_LCTL | QK_LSFT | QK_LALT | (kc))
536 #define LCAG(kc) (QK_LCTL | QK_LALT | QK_LGUI | (kc))
537 #define SGUI(kc) (QK_LGUI | QK_LSFT | (kc))
538 #define SCMD(kc) SGUI(kc)
539 #define SWIN(kc) SGUI(kc)
540 #define LCA(kc) (QK_LCTL | QK_LALT | (kc))
545 // Aliases for shifted symbols
546 // Each key has a 4-letter code, and some have longer aliases too.
547 // While the long aliases are descriptive, the 4-letter codes
548 // make for nicer grid layouts (everything lines up), and are
549 // the preferred style for Quantum.
550 #define KC_TILD LSFT(KC_GRV) // ~
551 #define KC_TILDE KC_TILD
553 #define KC_EXLM LSFT(KC_1) // !
554 #define KC_EXCLAIM KC_EXLM
556 #define KC_AT LSFT(KC_2) // @
558 #define KC_HASH LSFT(KC_3) // #
560 #define KC_DLR LSFT(KC_4) // $
561 #define KC_DOLLAR KC_DLR
563 #define KC_PERC LSFT(KC_5) // %
564 #define KC_PERCENT KC_PERC
566 #define KC_CIRC LSFT(KC_6) // ^
567 #define KC_CIRCUMFLEX KC_CIRC
569 #define KC_AMPR LSFT(KC_7) // &
570 #define KC_AMPERSAND KC_AMPR
572 #define KC_ASTR LSFT(KC_8) // *
573 #define KC_ASTERISK KC_ASTR
575 #define KC_LPRN LSFT(KC_9) // (
576 #define KC_LEFT_PAREN KC_LPRN
578 #define KC_RPRN LSFT(KC_0) // )
579 #define KC_RIGHT_PAREN KC_RPRN
581 #define KC_UNDS LSFT(KC_MINS) // _
582 #define KC_UNDERSCORE KC_UNDS
584 #define KC_PLUS LSFT(KC_EQL) // +
586 #define KC_LCBR LSFT(KC_LBRC) // {
587 #define KC_LEFT_CURLY_BRACE KC_LCBR
589 #define KC_RCBR LSFT(KC_RBRC) // }
590 #define KC_RIGHT_CURLY_BRACE KC_RCBR
592 #define KC_LABK LSFT(KC_COMM) // <
593 #define KC_LEFT_ANGLE_BRACKET KC_LABK
595 #define KC_RABK LSFT(KC_DOT) // >
596 #define KC_RIGHT_ANGLE_BRACKET KC_RABK
598 #define KC_COLN LSFT(KC_SCLN) // :
599 #define KC_COLON KC_COLN
601 #define KC_PIPE LSFT(KC_BSLS) // |
603 #define KC_LT LSFT(KC_COMM) // <
605 #define KC_GT LSFT(KC_DOT) // >
607 #define KC_QUES LSFT(KC_SLSH) // ?
608 #define KC_QUESTION KC_QUES
610 #define KC_DQT LSFT(KC_QUOT) // "
611 #define KC_DOUBLE_QUOTE KC_DQT
612 #define KC_DQUO KC_DQT
614 #define KC_DELT KC_DELETE // Del key (four letter code)
616 // Alias for function layers than expand past FN31
617 #define FUNC(kc) (QK_FUNCTION | (kc))
620 #define C(kc) LCTL(kc)
621 #define S(kc) LSFT(kc)
622 #define A(kc) LALT(kc)
623 #define G(kc) LGUI(kc)
625 #define F(kc) FUNC(kc)
626 #define M(kc) (QK_MACRO | (kc))
628 #define MACROTAP(kc) (QK_MACRO | (FUNC_TAP << 8) | (kc))
629 #define MACRODOWN(...) (record->event.pressed ? MACRO(__VA_ARGS__) : MACRO_NONE)
631 #define KC_GESC GRAVE_ESC
633 #define EEP_RST EEPROM_RESET
635 #define CK_TOGG CLICKY_TOGGLE
636 #define CK_RST CLICKY_RESET
637 #define CK_UP CLICKY_UP
638 #define CK_DOWN CLICKY_DOWN
639 #define CK_ON CLICKY_ENABLE
640 #define CK_OFF CLICKY_DISABLE
642 #define RGB_MOD RGB_MODE_FORWARD
643 #define RGB_RMOD RGB_MODE_REVERSE
645 #define RGB_M_P RGB_MODE_PLAIN
646 #define RGB_M_B RGB_MODE_BREATHE
647 #define RGB_M_R RGB_MODE_RAINBOW
648 #define RGB_M_SW RGB_MODE_SWIRL
649 #define RGB_M_SN RGB_MODE_SNAKE
650 #define RGB_M_K RGB_MODE_KNIGHT
651 #define RGB_M_X RGB_MODE_XMAS
652 #define RGB_M_G RGB_MODE_GRADIENT
653 #define RGB_M_T RGB_MODE_RGBTEST
655 // L-ayer, T-ap - 256 keycode max, 16 layer max
656 #define LT(layer, kc) (QK_LAYER_TAP | (((layer)&0xF) << 8) | ((kc)&0xFF))
658 #define CL_SWAP MAGIC_SWAP_CONTROL_CAPSLOCK
659 #define CL_NORM MAGIC_UNSWAP_CONTROL_CAPSLOCK
660 #define CL_CTRL MAGIC_CAPSLOCK_TO_CONTROL
661 #define CL_CAPS MAGIC_UNCAPSLOCK_TO_CONTROL
663 #define LCG_SWP MAGIC_SWAP_LCTL_LGUI
664 #define LCG_NRM MAGIC_UNSWAP_LCTL_LGUI
665 #define RCG_SWP MAGIC_SWAP_RCTL_RGUI
666 #define RCG_NRM MAGIC_UNSWAP_RCTL_RGUI
667 #define CG_SWAP MAGIC_SWAP_CTL_GUI
668 #define CG_NORM MAGIC_UNSWAP_CTL_GUI
669 #define CG_TOGG MAGIC_TOGGLE_CTL_GUI
671 #define LAG_SWP MAGIC_SWAP_LALT_LGUI
672 #define LAG_NRM MAGIC_UNSWAP_LALT_LGUI
673 #define RAG_SWP MAGIC_SWAP_RALT_RGUI
674 #define RAG_NRM MAGIC_UNSWAP_RALT_RGUI
675 #define AG_SWAP MAGIC_SWAP_ALT_GUI
676 #define AG_NORM MAGIC_UNSWAP_ALT_GUI
677 #define AG_TOGG MAGIC_TOGGLE_ALT_GUI
679 #define GUI_OFF MAGIC_NO_GUI
680 #define GUI_ON MAGIC_UNNO_GUI
682 #define GE_SWAP MAGIC_SWAP_GRAVE_ESC
683 #define GE_NORM MAGIC_UNSWAP_GRAVE_ESC
685 #define BS_SWAP MAGIC_SWAP_BACKSLASH_BACKSPACE
686 #define BS_NORM MAGIC_UNSWAP_BACKSLASH_BACKSPACE
688 #define NK_ON MAGIC_HOST_NKRO
689 #define NK_OFF MAGIC_UNHOST_NKRO
690 #define NK_TOGG MAGIC_TOGGLE_NKRO
692 #define EH_LEFT MAGIC_EE_HANDS_LEFT
693 #define EH_RGHT MAGIC_EE_HANDS_RIGHT
695 // GOTO layer - 16 layers max
699 // Unless you have a good reason not to do so, prefer ON_PRESS (1) as your default.
700 // In fact, we changed it to assume ON_PRESS for sanity/simplicity. If needed, you can add your own
701 // keycode modeled after the old version, kept below for this.
702 /* #define TO(layer, when) (QK_TO | (when << 0x4) | (layer & 0xFF)) */
703 #define TO(layer) (QK_TO | (ON_PRESS << 0x4) | ((layer)&0xFF))
705 // Momentary switch layer - 256 layer max
706 #define MO(layer) (QK_MOMENTARY | ((layer)&0xFF))
708 // Set default layer - 256 layer max
709 #define DF(layer) (QK_DEF_LAYER | ((layer)&0xFF))
711 // Toggle to layer - 256 layer max
712 #define TG(layer) (QK_TOGGLE_LAYER | ((layer)&0xFF))
714 // One-shot layer - 256 layer max
715 #define OSL(layer) (QK_ONE_SHOT_LAYER | ((layer)&0xFF))
717 // L-ayer M-od: Momentary switch layer with modifiers active - 16 layer max, left mods only
718 #define LM(layer, mod) (QK_LAYER_MOD | (((layer)&0xF) << 4) | ((mod)&0xF))
721 #define OSM(mod) (QK_ONE_SHOT_MOD | ((mod)&0xFF))
724 #define TT(layer) (QK_LAYER_TAP_TOGGLE | ((layer)&0xFF))
726 // M-od, T-ap - 256 keycode max
727 #define MT(mod, kc) (QK_MOD_TAP | (((mod)&0x1F) << 8) | ((kc)&0xFF))
729 #define LCTL_T(kc) MT(MOD_LCTL, kc)
730 #define RCTL_T(kc) MT(MOD_RCTL, kc)
731 #define CTL_T(kc) LCTL_T(kc)
733 #define LSFT_T(kc) MT(MOD_LSFT, kc)
734 #define RSFT_T(kc) MT(MOD_RSFT, kc)
735 #define SFT_T(kc) LSFT_T(kc)
737 #define LALT_T(kc) MT(MOD_LALT, kc)
738 #define RALT_T(kc) MT(MOD_RALT, kc)
739 #define ALT_T(kc) LALT_T(kc)
740 #define ALGR_T(kc) RALT_T(kc)
742 #define LGUI_T(kc) MT(MOD_LGUI, kc)
743 #define RGUI_T(kc) MT(MOD_RGUI, kc)
744 #define LCMD_T(kc) LGUI_T(kc)
745 #define LWIN_T(kc) LGUI_T(kc)
746 #define RCMD_T(kc) RGUI_T(kc)
747 #define RWIN_T(kc) RGUI_T(kc)
748 #define GUI_T(kc) LGUI_T(kc)
749 #define CMD_T(kc) LCMD_T(kc)
750 #define WIN_T(kc) LWIN_T(kc)
752 #define C_S_T(kc) MT(MOD_LCTL | MOD_LSFT, kc) // Left Control + Shift e.g. for gnome-terminal
753 #define MEH_T(kc) MT(MOD_LCTL | MOD_LSFT | MOD_LALT, kc) // Meh is a less hyper version of the Hyper key -- doesn't include GUI, so just Left Control + Shift + Alt
754 #define LCAG_T(kc) MT(MOD_LCTL | MOD_LALT | MOD_LGUI, kc) // Left Control + Alt + GUI
755 #define RCAG_T(kc) MT(MOD_RCTL | MOD_RALT | MOD_RGUI, kc) // Right Control + Alt + GUI
756 #define HYPR_T(kc) MT(MOD_LCTL | MOD_LSFT | MOD_LALT | MOD_LGUI, kc) // see http://brettterpstra.com/2012/12/08/a-useful-caps-lock-key/
757 #define SGUI_T(kc) MT(MOD_LGUI | MOD_LSFT, kc) // Left Shift + GUI
758 #define SCMD_T(kc) SGUI_T(kc)
759 #define SWIN_T(kc) SGUI_T(kc)
760 #define LCA_T(kc) MT(MOD_LCTL | MOD_LALT, kc) // Left Control + Alt
761 #define ALL_T(kc) HYPR_T(kc)
763 // Dedicated keycode versions for Hyper and Meh, if you want to use them as standalone keys rather than mod-tap
764 #define KC_HYPR HYPR(KC_NO)
765 #define KC_MEH MEH(KC_NO)
767 #ifdef UNICODE_ENABLE
768 // Allows Unicode input up to 0x7FFF
769 # define UC(c) (QK_UNICODE | (c))
771 #ifdef UNICODEMAP_ENABLE
772 // Allows Unicode input up to 0x10FFFF, requires unicode_map
773 # define X(i) (QK_UNICODEMAP | (i))
774 # define XP(i, j) (QK_UNICODEMAP_PAIR | ((i)&0x7F) | (((j)&0x7F) << 7)) // 127 max i and j
777 #define UC_MOD UNICODE_MODE_FORWARD
778 #define UC_RMOD UNICODE_MODE_REVERSE
780 #define UC_M_OS UNICODE_MODE_OSX
781 #define UC_M_LN UNICODE_MODE_LNX
782 #define UC_M_WI UNICODE_MODE_WIN
783 #define UC_M_BS UNICODE_MODE_BSD
784 #define UC_M_WC UNICODE_MODE_WINC
786 #ifdef SWAP_HANDS_ENABLE
787 # define SH_T(kc) (QK_SWAP_HANDS | (kc))
788 # define SH_TG (QK_SWAP_HANDS | OP_SH_TOGGLE)
789 # define SH_TT (QK_SWAP_HANDS | OP_SH_TAP_TOGGLE)
790 # define SH_MON (QK_SWAP_HANDS | OP_SH_ON_OFF)
791 # define SH_MOFF (QK_SWAP_HANDS | OP_SH_OFF_ON)
792 # define SH_ON (QK_SWAP_HANDS | OP_SH_ON)
793 # define SH_OFF (QK_SWAP_HANDS | OP_SH_OFF)
796 // Dynamic Macros aliases
797 #define DM_REC1 DYN_REC_START1
798 #define DM_REC2 DYN_REC_START2
799 #define DM_RSTP DYN_REC_STOP
800 #define DM_PLY1 DYN_MACRO_PLAY1
801 #define DM_PLY2 DYN_MACRO_PLAY2
803 #endif // QUANTUM_KEYCODES_H