2 Copyright 2012,2013 Jun Wako <wakojun@gmail.com>
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
24 #include <avr/pgmspace.h>
27 #include "action_macro.h"
33 #ifdef BOOTMAGIC_ENABLE
34 /* NOTE: Not portable. Bit field order depends on implementation */
38 bool swap_control_capslock:1;
39 bool capslock_to_control:1;
40 bool swap_lalt_lgui:1;
41 bool swap_ralt_rgui:1;
43 bool swap_grave_esc:1;
44 bool swap_backslash_backspace:1;
48 keymap_config_t keymap_config;
52 /* translates key to keycode */
53 uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key);
55 /* translates Fn keycode to action */
56 action_t keymap_fn_to_action(uint16_t keycode);
58 /* translates Fn keycode to action */
59 action_t keymap_func_to_action(uint16_t keycode);
61 extern const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
62 extern const uint16_t fn_actions[];
64 // Ability to use mods in layouts
65 #define LCTL(kc) kc | 0x0100
66 #define LSFT(kc) kc | 0x0200
67 #define LALT(kc) kc | 0x0400
68 #define LGUI(kc) kc | 0x0800
69 #define RCTL(kc) kc | 0x1100
70 #define RSFT(kc) kc | 0x1200
71 #define RALT(kc) kc | 0x1400
72 #define RGUI(kc) kc | 0x1800
74 // Aliases for shifted symbols
75 #define KC_TILD LSFT(KC_GRV) // ~
76 #define KC_TILDE KC_TILD
77 #define KC_EXLM LSFT(KC_1) // !
78 #define KC_EXCLAIM KC_EXLM
79 #define KC_AT LSFT(KC_2) // @
80 #define KC_HASH LSFT(KC_3) // #
81 #define KC_DLR LSFT(KC_4) // $
82 #define KC_DOLLAR KC_DLR
83 #define KC_PERC LSFT(KC_5) // %
84 #define KC_PERCENT KC_PERC
85 #define KC_CIRC LSFT(KC_6) // ^
86 #define KC_CIRCUMFLEX KC_CIRC
87 #define KC_AMPR LSFT(KC_7) // &
88 #define KC_AMPERSAND KC_AMPR
89 #define KC_ASTR LSFT(KC_8) // *
90 #define KC_ASTERISK KC_ASTR
91 #define KC_LPRN LSFT(KC_9) // (
92 #define KC_LEFT_PAREN KC_LPRN
93 #define KC_RPRN LSFT(KC_0) // )
94 #define KC_RIGHT_PAREN KC_RPRN
95 #define KC_UNDS LSFT(KC_MINS) // _
96 #define KC_UNDERSCORE KC_UNDS
97 #define KC_PLUS LSFT(KC_EQL) // +
98 #define KC_LCBR LSFT(KC_LBRC) // {
99 #define KC_LEFT_CURLY_BRACE KC_LCBR
100 #define KC_RCBR LSFT(KC_RBRC) // }
101 #define KC_RIGHT_CURLY_BRACE KC_RCBR
102 #define KC_PIPE LSFT(KC_SLSH) // |
104 // Alias for function layers than expand past FN31
105 #define FUNC(kc) kc | 0x2000
108 #define S(kc) LSFT(kc)
109 #define F(kc) FUNC(kc)
111 #define M(kc) kc | 0x3000
113 #define MACRODOWN(...) (record->event.pressed ? MACRO(__VA_ARGS__) : MACRO_NONE)
116 #define BL_OFF 0x4000
133 #define BL_DEC 0x4010
134 #define BL_INC 0x4011
135 #define BL_TOGG 0x4012
136 #define BL_STEP 0x4013
141 // GOTO layer - 16 layers max
146 #define TO(layer, when) (layer | 0x5100 | (when << 0x4))
148 // Momentary switch layer - 256 layer max
149 #define MO(layer) (layer | 0x5200)
151 // Set default layer - 256 layer max
152 #define DF(layer) (layer | 0x5300)
154 #define MIDI(n) (n | 0x6000)
156 #define UNI(n) (n | 0x8000)