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 shortucuts - not to be used directly
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
148 #ifdef FAUXCLICKY_ENABLE
155 // Music mode on/off/toggle
163 // Music voice iterate
168 #if !MIDI_ENABLE_STRICT || (defined(MIDI_ENABLE) && defined(MIDI_BASIC))
174 #if !MIDI_ENABLE_STRICT || (defined(MIDI_ENABLE) && defined(MIDI_ADVANCED))
177 #if !MIDI_ENABLE_STRICT || MIDI_TONE_KEYCODE_OCTAVES > 0
178 MI_C = MIDI_TONE_MIN,
197 #if !MIDI_ENABLE_STRICT || MIDI_TONE_KEYCODE_OCTAVES > 1
217 #if !MIDI_ENABLE_STRICT || MIDI_TONE_KEYCODE_OCTAVES > 2
237 #if !MIDI_ENABLE_STRICT || MIDI_TONE_KEYCODE_OCTAVES > 3
257 #if !MIDI_ENABLE_STRICT || MIDI_TONE_KEYCODE_OCTAVES > 4
277 #if !MIDI_ENABLE_STRICT || MIDI_TONE_KEYCODE_OCTAVES > 5
297 #if !MIDI_ENABLE_STRICT || MIDI_TONE_KEYCODE_OCTAVES > 5
298 MIDI_TONE_MAX = MI_B_5,
299 #elif MIDI_TONE_KEYCODE_OCTAVES > 4
300 MIDI_TONE_MAX = MI_B_4,
301 #elif MIDI_TONE_KEYCODE_OCTAVES > 3
302 MIDI_TONE_MAX = MI_B_3,
303 #elif MIDI_TONE_KEYCODE_OCTAVES > 2
304 MIDI_TONE_MAX = MI_B_2,
305 #elif MIDI_TONE_KEYCODE_OCTAVES > 1
306 MIDI_TONE_MAX = MI_B_1,
307 #elif MIDI_TONE_KEYCODE_OCTAVES > 0
308 MIDI_TONE_MAX = MI_B,
312 MI_OCT_N2 = MIDI_OCTAVE_MIN,
322 MIDI_OCTAVE_MAX = MI_OCT_7,
323 MI_OCTD, // octave down
324 MI_OCTU, // octave up
327 MI_TRNS_N6 = MIDI_TRANSPOSE_MIN,
340 MIDI_TRANSPOSE_MAX = MI_TRNS_6,
341 MI_TRNSD, // transpose down
342 MI_TRNSU, // transpose up
345 MI_VEL_1 = MIDI_VELOCITY_MIN,
355 MIDI_VELOCITY_MAX = MI_VEL_10,
356 MI_VELD, // velocity down
357 MI_VELU, // velocity up
360 MI_CH1 = MIDI_CHANNEL_MIN,
376 MIDI_CHANNEL_MAX = MI_CH16,
377 MI_CHD, // previous channel
378 MI_CHU, // next channel
380 MI_ALLOFF, // all notes off
383 MI_PORT, // portamento
384 MI_SOST, // sostenuto
385 MI_SOFT, // soft pedal
388 MI_MOD, // modulation
389 MI_MODSD, // decrease modulation speed
390 MI_MODSU, // increase modulation speed
392 MI_BENDD, // Bend down
394 #endif // MIDI_ADVANCED
396 // Backlight functionality
427 //Momentum matching toggle
430 // Left shift, open paren
433 // Right shift, close paren
446 #ifdef BLUETOOTH_ENABLE
450 #ifdef KEY_LOCK_ENABLE
454 #ifdef TERMINAL_ENABLE
461 UNICODE_MODE_FORWARD,
462 UNICODE_MODE_REVERSE,
480 // Left control, open paren
483 // Right control, close paren
486 // Left control, open paren
489 // Right control, close paren
492 // always leave at the end
496 // Ability to use mods in layouts
497 #define LCTL(kc) (QK_LCTL | (kc))
498 #define LSFT(kc) (QK_LSFT | (kc))
499 #define LALT(kc) (QK_LALT | (kc))
500 #define LGUI(kc) (QK_LGUI | (kc))
501 #define LCMD(kc) LGUI(kc)
502 #define LWIN(kc) LGUI(kc)
503 #define RCTL(kc) (QK_RCTL | (kc))
504 #define RSFT(kc) (QK_RSFT | (kc))
505 #define RALT(kc) (QK_RALT | (kc))
506 #define ALGR(kc) RALT(kc)
507 #define RGUI(kc) (QK_RGUI | (kc))
508 #define RCMD(kc) RGUI(kc)
509 #define RWIN(kc) RGUI(kc)
511 #define HYPR(kc) (QK_LCTL | QK_LSFT | QK_LALT | QK_LGUI | (kc))
512 #define MEH(kc) (QK_LCTL | QK_LSFT | QK_LALT | (kc))
513 #define LCAG(kc) (QK_LCTL | QK_LALT | QK_LGUI | (kc))
514 #define SGUI(kc) (QK_LGUI | QK_LSFT | (kc))
515 #define SCMD(kc) SGUI(kc)
516 #define SWIN(kc) SGUI(kc)
517 #define LCA(kc) (QK_LCTL | QK_LALT | (kc))
522 // Aliases for shifted symbols
523 // Each key has a 4-letter code, and some have longer aliases too.
524 // While the long aliases are descriptive, the 4-letter codes
525 // make for nicer grid layouts (everything lines up), and are
526 // the preferred style for Quantum.
527 #define KC_TILD LSFT(KC_GRV) // ~
528 #define KC_TILDE KC_TILD
530 #define KC_EXLM LSFT(KC_1) // !
531 #define KC_EXCLAIM KC_EXLM
533 #define KC_AT LSFT(KC_2) // @
535 #define KC_HASH LSFT(KC_3) // #
537 #define KC_DLR LSFT(KC_4) // $
538 #define KC_DOLLAR KC_DLR
540 #define KC_PERC LSFT(KC_5) // %
541 #define KC_PERCENT KC_PERC
543 #define KC_CIRC LSFT(KC_6) // ^
544 #define KC_CIRCUMFLEX KC_CIRC
546 #define KC_AMPR LSFT(KC_7) // &
547 #define KC_AMPERSAND KC_AMPR
549 #define KC_ASTR LSFT(KC_8) // *
550 #define KC_ASTERISK KC_ASTR
552 #define KC_LPRN LSFT(KC_9) // (
553 #define KC_LEFT_PAREN KC_LPRN
555 #define KC_RPRN LSFT(KC_0) // )
556 #define KC_RIGHT_PAREN KC_RPRN
558 #define KC_UNDS LSFT(KC_MINS) // _
559 #define KC_UNDERSCORE KC_UNDS
561 #define KC_PLUS LSFT(KC_EQL) // +
563 #define KC_LCBR LSFT(KC_LBRC) // {
564 #define KC_LEFT_CURLY_BRACE KC_LCBR
566 #define KC_RCBR LSFT(KC_RBRC) // }
567 #define KC_RIGHT_CURLY_BRACE KC_RCBR
569 #define KC_LABK LSFT(KC_COMM) // <
570 #define KC_LEFT_ANGLE_BRACKET KC_LABK
572 #define KC_RABK LSFT(KC_DOT) // >
573 #define KC_RIGHT_ANGLE_BRACKET KC_RABK
575 #define KC_COLN LSFT(KC_SCLN) // :
576 #define KC_COLON KC_COLN
578 #define KC_PIPE LSFT(KC_BSLS) // |
580 #define KC_LT LSFT(KC_COMM) // <
582 #define KC_GT LSFT(KC_DOT) // >
584 #define KC_QUES LSFT(KC_SLSH) // ?
585 #define KC_QUESTION KC_QUES
587 #define KC_DQT LSFT(KC_QUOT) // "
588 #define KC_DOUBLE_QUOTE KC_DQT
589 #define KC_DQUO KC_DQT
591 #define KC_DELT KC_DELETE // Del key (four letter code)
593 // Alias for function layers than expand past FN31
594 #define FUNC(kc) (QK_FUNCTION | (kc))
597 #define C(kc) LCTL(kc)
598 #define S(kc) LSFT(kc)
599 #define A(kc) LALT(kc)
600 #define G(kc) LGUI(kc)
602 #define F(kc) FUNC(kc)
603 #define M(kc) (QK_MACRO | (kc))
605 #define MACROTAP(kc) (QK_MACRO | (FUNC_TAP << 8) | (kc))
606 #define MACRODOWN(...) (record->event.pressed ? MACRO(__VA_ARGS__) : MACRO_NONE)
608 #define KC_GESC GRAVE_ESC
610 #define EEP_RST EEPROM_RESET
612 #define CK_TOGG CLICKY_TOGGLE
613 #define CK_RST CLICKY_RESET
614 #define CK_UP CLICKY_UP
615 #define CK_DOWN CLICKY_DOWN
616 #define CK_ON CLICKY_ENABLE
617 #define CK_OFF CLICKY_DISABLE
619 #define RGB_MOD RGB_MODE_FORWARD
620 #define RGB_RMOD RGB_MODE_REVERSE
622 #define RGB_M_P RGB_MODE_PLAIN
623 #define RGB_M_B RGB_MODE_BREATHE
624 #define RGB_M_R RGB_MODE_RAINBOW
625 #define RGB_M_SW RGB_MODE_SWIRL
626 #define RGB_M_SN RGB_MODE_SNAKE
627 #define RGB_M_K RGB_MODE_KNIGHT
628 #define RGB_M_X RGB_MODE_XMAS
629 #define RGB_M_G RGB_MODE_GRADIENT
630 #define RGB_M_T RGB_MODE_RGBTEST
632 // L-ayer, T-ap - 256 keycode max, 16 layer max
633 #define LT(layer, kc) (QK_LAYER_TAP | (((layer) & 0xF) << 8) | ((kc) & 0xFF))
635 #define AG_SWAP MAGIC_SWAP_ALT_GUI
636 #define AG_NORM MAGIC_UNSWAP_ALT_GUI
637 #define AG_TOGG MAGIC_TOGGLE_ALT_GUI
639 // GOTO layer - 16 layers max
643 // Unless you have a good reason not to do so, prefer ON_PRESS (1) as your default.
644 // In fact, we changed it to assume ON_PRESS for sanity/simplicity. If needed, you can add your own
645 // keycode modeled after the old version, kept below for this.
646 /* #define TO(layer, when) (QK_TO | (when << 0x4) | (layer & 0xFF)) */
647 #define TO(layer) (QK_TO | (ON_PRESS << 0x4) | ((layer) & 0xFF))
649 // Momentary switch layer - 256 layer max
650 #define MO(layer) (QK_MOMENTARY | ((layer) & 0xFF))
652 // Set default layer - 256 layer max
653 #define DF(layer) (QK_DEF_LAYER | ((layer) & 0xFF))
655 // Toggle to layer - 256 layer max
656 #define TG(layer) (QK_TOGGLE_LAYER | ((layer) & 0xFF))
658 // One-shot layer - 256 layer max
659 #define OSL(layer) (QK_ONE_SHOT_LAYER | ((layer) & 0xFF))
661 // L-ayer M-od: Momentary switch layer with modifiers active - 16 layer max, left mods only
662 #define LM(layer, mod) (QK_LAYER_MOD | (((layer) & 0xF) << 4) | ((mod) & 0xF))
665 #define OSM(mod) (QK_ONE_SHOT_MOD | ((mod) & 0xFF))
668 #define TT(layer) (QK_LAYER_TAP_TOGGLE | ((layer) & 0xFF))
670 // M-od, T-ap - 256 keycode max
671 #define MT(mod, kc) (QK_MOD_TAP | (((mod) & 0x1F) << 8) | ((kc) & 0xFF))
673 #define LCTL_T(kc) MT(MOD_LCTL, kc)
674 #define RCTL_T(kc) MT(MOD_RCTL, kc)
675 #define CTL_T(kc) LCTL_T(kc)
677 #define LSFT_T(kc) MT(MOD_LSFT, kc)
678 #define RSFT_T(kc) MT(MOD_RSFT, kc)
679 #define SFT_T(kc) LSFT_T(kc)
681 #define LALT_T(kc) MT(MOD_LALT, kc)
682 #define RALT_T(kc) MT(MOD_RALT, kc)
683 #define ALT_T(kc) LALT_T(kc)
684 #define ALGR_T(kc) RALT_T(kc)
686 #define LGUI_T(kc) MT(MOD_LGUI, kc)
687 #define RGUI_T(kc) MT(MOD_RGUI, kc)
688 #define LCMD_T(kc) LGUI_T(kc)
689 #define LWIN_T(kc) LGUI_T(kc)
690 #define RCMD_T(kc) RGUI_T(kc)
691 #define RWIN_T(kc) RGUI_T(kc)
692 #define GUI_T(kc) LGUI_T(kc)
693 #define CMD_T(kc) LCMD_T(kc)
694 #define WIN_T(kc) LWIN_T(kc)
696 #define C_S_T(kc) MT(MOD_LCTL | MOD_LSFT, kc) // Left Control + Shift e.g. for gnome-terminal
697 #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
698 #define LCAG_T(kc) MT(MOD_LCTL | MOD_LALT | MOD_LGUI, kc) // Left Control + Alt + GUI
699 #define RCAG_T(kc) MT(MOD_RCTL | MOD_RALT | MOD_RGUI, kc) // Right Control + Alt + GUI
700 #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/
701 #define SGUI_T(kc) MT(MOD_LGUI | MOD_LSFT, kc) // Left Shift + GUI
702 #define SCMD_T(kc) SGUI_T(kc)
703 #define SWIN_T(kc) SGUI_T(kc)
704 #define LCA_T(kc) MT(MOD_LCTL | MOD_LALT, kc) // Left Control + Alt
705 #define ALL_T(kc) HYPR_T(kc)
707 // Dedicated keycode versions for Hyper and Meh, if you want to use them as standalone keys rather than mod-tap
708 #define KC_HYPR HYPR(KC_NO)
709 #define KC_MEH MEH(KC_NO)
711 #ifdef UNICODE_ENABLE
712 // Allows Unicode input up to 0x7FFF
713 #define UC(c) (QK_UNICODE | (c))
715 #ifdef UNICODEMAP_ENABLE
716 // Allows Unicode input up to 0x10FFFF, requires unicode_map
717 #define X(i) (QK_UNICODEMAP | (i))
718 #define XP(i, j) (QK_UNICODEMAP_PAIR | ((i) & 0x7F) | (((j) & 0x7F) << 7)) // 127 max i and j
721 #define UC_MOD UNICODE_MODE_FORWARD
722 #define UC_RMOD UNICODE_MODE_REVERSE
724 #define UC_M_OS UNICODE_MODE_OSX
725 #define UC_M_LN UNICODE_MODE_LNX
726 #define UC_M_WI UNICODE_MODE_WIN
727 #define UC_M_BS UNICODE_MODE_BSD
728 #define UC_M_WC UNICODE_MODE_WINC
730 #ifdef SWAP_HANDS_ENABLE
731 #define SH_T(kc) (QK_SWAP_HANDS | (kc))
732 #define SH_TG (QK_SWAP_HANDS | OP_SH_TOGGLE)
733 #define SH_TT (QK_SWAP_HANDS | OP_SH_TAP_TOGGLE)
734 #define SH_MON (QK_SWAP_HANDS | OP_SH_ON_OFF)
735 #define SH_MOFF (QK_SWAP_HANDS | OP_SH_OFF_ON)
736 #define SH_ON (QK_SWAP_HANDS | OP_SH_ON)
737 #define SH_OFF (QK_SWAP_HANDS | OP_SH_OFF)
740 #endif // QUANTUM_KEYCODES_H