diff options
author | Jack Humbert <jack.humb@gmail.com> | 2016-06-18 14:30:24 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-06-18 14:30:24 -0400 |
commit | db32864ce7029d758f57729cc2f75e051a28d0a2 (patch) | |
tree | f3ac60d9c826a9ad5ef5bc4d199efaddae156ba6 /quantum/keymap.h | |
parent | 1923cffd41d9d71cd9f434092654dba05513137b (diff) | |
download | qmk_firmware-db32864ce7029d758f57729cc2f75e051a28d0a2.tar.gz qmk_firmware-db32864ce7029d758f57729cc2f75e051a28d0a2.zip |
Cleans up quantum/keymap situation, removes extra lufa folders (#416)
* sorts out keycodes
* move midi around
* remove mbed
* replaces keymap with qmk/keymap_common
* fixes keymap.h
* keymap, config, quantum rearrange
* removes unneeded lufa stuff
Diffstat (limited to 'quantum/keymap.h')
-rw-r--r-- | quantum/keymap.h | 315 |
1 files changed, 315 insertions, 0 deletions
diff --git a/quantum/keymap.h b/quantum/keymap.h new file mode 100644 index 000000000..979ab2da1 --- /dev/null +++ b/quantum/keymap.h | |||
@@ -0,0 +1,315 @@ | |||
1 | /* | ||
2 | Copyright 2012,2013 Jun Wako <wakojun@gmail.com> | ||
3 | |||
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. | ||
8 | |||
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. | ||
13 | |||
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/>. | ||
16 | */ | ||
17 | |||
18 | #ifndef KEYMAP_H | ||
19 | #define KEYMAP_H | ||
20 | |||
21 | #include <stdint.h> | ||
22 | #include <stdbool.h> | ||
23 | #include "action.h" | ||
24 | #include <avr/pgmspace.h> | ||
25 | #include "keycode.h" | ||
26 | #include "action_macro.h" | ||
27 | #include "report.h" | ||
28 | #include "host.h" | ||
29 | // #include "print.h" | ||
30 | #include "debug.h" | ||
31 | #include "keycode_config.h" | ||
32 | |||
33 | /* translates key to keycode */ | ||
34 | uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key); | ||
35 | |||
36 | /* translates Fn keycode to action */ | ||
37 | action_t keymap_fn_to_action(uint16_t keycode); | ||
38 | |||
39 | extern const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS]; | ||
40 | extern const uint16_t fn_actions[]; | ||
41 | |||
42 | enum quantum_keycodes { | ||
43 | // Ranges used in shortucuts - not to be used directly | ||
44 | QK_TMK = 0x0000, | ||
45 | QK_TMK_MAX = 0x00FF, | ||
46 | QK_MODS = 0x0100, | ||
47 | QK_LCTL = 0x0100, | ||
48 | QK_LSFT = 0x0200, | ||
49 | QK_LALT = 0x0400, | ||
50 | QK_LGUI = 0x0800, | ||
51 | QK_RCTL = 0x1100, | ||
52 | QK_RSFT = 0x1200, | ||
53 | QK_RALT = 0x1400, | ||
54 | QK_RGUI = 0x1800, | ||
55 | QK_MODS_MAX = 0x1FFF, | ||
56 | QK_FUNCTION = 0x2000, | ||
57 | QK_FUNCTION_MAX = 0x2FFF, | ||
58 | QK_MACRO = 0x3000, | ||
59 | QK_MACRO_MAX = 0x3FFF, | ||
60 | QK_LAYER_TAP = 0x4000, | ||
61 | QK_LAYER_TAP_MAX = 0x4FFF, | ||
62 | QK_TO = 0x5000, | ||
63 | QK_TO_MAX = 0x50FF, | ||
64 | QK_MOMENTARY = 0x5100, | ||
65 | QK_MOMENTARY_MAX = 0x51FF, | ||
66 | QK_DEF_LAYER = 0x5200, | ||
67 | QK_DEF_LAYER_MAX = 0x52FF, | ||
68 | QK_TOGGLE_LAYER = 0x5300, | ||
69 | QK_TOGGLE_LAYER_MAX = 0x53FF, | ||
70 | QK_ONE_SHOT_LAYER = 0x5400, | ||
71 | QK_ONE_SHOT_LAYER_MAX = 0x54FF, | ||
72 | QK_ONE_SHOT_MOD = 0x5500, | ||
73 | QK_ONE_SHOT_MOD_MAX = 0x55FF, | ||
74 | #ifndef DISABLE_CHORDING | ||
75 | QK_CHORDING = 0x5600, | ||
76 | QK_CHORDING_MAX = 0x56FF, | ||
77 | #endif | ||
78 | QK_MOD_TAP = 0x6000, | ||
79 | QK_MOD_TAP_MAX = 0x6FFF, | ||
80 | #ifdef UNICODE_ENABLE | ||
81 | QK_UNICODE = 0x8000, | ||
82 | QK_UNICODE_MAX = 0xFFFF, | ||
83 | #endif | ||
84 | |||
85 | // Loose keycodes - to be used directly | ||
86 | |||
87 | RESET = 0x7000, | ||
88 | DEBUG, | ||
89 | MAGIC_SWAP_CONTROL_CAPSLOCK, | ||
90 | MAGIC_CAPSLOCK_TO_CONTROL, | ||
91 | MAGIC_SWAP_LALT_LGUI, | ||
92 | MAGIC_SWAP_RALT_RGUI, | ||
93 | MAGIC_NO_GUI, | ||
94 | MAGIC_SWAP_GRAVE_ESC, | ||
95 | MAGIC_SWAP_BACKSLASH_BACKSPACE, | ||
96 | MAGIC_HOST_NKRO, | ||
97 | MAGIC_SWAP_ALT_GUI, | ||
98 | MAGIC_UNSWAP_CONTROL_CAPSLOCK, | ||
99 | MAGIC_UNCAPSLOCK_TO_CONTROL, | ||
100 | MAGIC_UNSWAP_LALT_LGUI, | ||
101 | MAGIC_UNSWAP_RALT_RGUI, | ||
102 | MAGIC_UNNO_GUI, | ||
103 | MAGIC_UNSWAP_GRAVE_ESC, | ||
104 | MAGIC_UNSWAP_BACKSLASH_BACKSPACE, | ||
105 | MAGIC_UNHOST_NKRO, | ||
106 | MAGIC_UNSWAP_ALT_GUI, | ||
107 | |||
108 | // Leader key | ||
109 | #ifndef DISABLE_LEADER | ||
110 | KC_LEAD, | ||
111 | #endif | ||
112 | |||
113 | // Audio on/off/toggle | ||
114 | AU_ON, | ||
115 | AU_OFF, | ||
116 | AU_TOG, | ||
117 | |||
118 | // Music mode on/off/toggle | ||
119 | MU_ON, | ||
120 | MU_OFF, | ||
121 | MU_TOG, | ||
122 | |||
123 | // Music voice iterate | ||
124 | MUV_IN, | ||
125 | MUV_DE, | ||
126 | |||
127 | // Midi mode on/off | ||
128 | MI_ON, | ||
129 | MI_OFF, | ||
130 | |||
131 | // Backlight functionality | ||
132 | BL_0, | ||
133 | BL_1, | ||
134 | BL_2, | ||
135 | BL_3, | ||
136 | BL_4, | ||
137 | BL_5, | ||
138 | BL_6, | ||
139 | BL_7, | ||
140 | BL_8, | ||
141 | BL_9, | ||
142 | BL_10, | ||
143 | BL_11, | ||
144 | BL_12, | ||
145 | BL_13, | ||
146 | BL_14, | ||
147 | BL_15, | ||
148 | BL_DEC, | ||
149 | BL_INC, | ||
150 | BL_TOGG, | ||
151 | BL_STEP, | ||
152 | |||
153 | // Left shift, open paren | ||
154 | KC_LSPO, | ||
155 | |||
156 | // Right shift, close paren | ||
157 | KC_RSPC, | ||
158 | }; | ||
159 | |||
160 | // Ability to use mods in layouts | ||
161 | #define LCTL(kc) (kc | QK_LCTL) | ||
162 | #define LSFT(kc) (kc | QK_LSFT) | ||
163 | #define LALT(kc) (kc | QK_LALT) | ||
164 | #define LGUI(kc) (kc | QK_LGUI) | ||
165 | #define RCTL(kc) (kc | QK_RCTL) | ||
166 | #define RSFT(kc) (kc | QK_RSFT) | ||
167 | #define RALT(kc) (kc | QK_RALT) | ||
168 | #define RGUI(kc) (kc | QK_RGUI) | ||
169 | |||
170 | #define HYPR(kc) (kc | QK_LCTL | QK_LSFT | QK_LALT | QK_LGUI) | ||
171 | #define MEH(kc) (kc | QK_LCTL | QK_LSFT | QK_LALT) | ||
172 | #define LCAG(kc) (kc | QK_LCTL | QK_LALT | QK_LGUI) | ||
173 | |||
174 | #define MOD_HYPR 0xf | ||
175 | #define MOD_MEH 0x7 | ||
176 | |||
177 | |||
178 | // Aliases for shifted symbols | ||
179 | // Each key has a 4-letter code, and some have longer aliases too. | ||
180 | // While the long aliases are descriptive, the 4-letter codes | ||
181 | // make for nicer grid layouts (everything lines up), and are | ||
182 | // the preferred style for Quantum. | ||
183 | #define KC_TILD LSFT(KC_GRV) // ~ | ||
184 | #define KC_TILDE KC_TILD | ||
185 | |||
186 | #define KC_EXLM LSFT(KC_1) // ! | ||
187 | #define KC_EXCLAIM KC_EXLM | ||
188 | |||
189 | #define KC_AT LSFT(KC_2) // @ | ||
190 | |||
191 | #define KC_HASH LSFT(KC_3) // # | ||
192 | |||
193 | #define KC_DLR LSFT(KC_4) // $ | ||
194 | #define KC_DOLLAR KC_DLR | ||
195 | |||
196 | #define KC_PERC LSFT(KC_5) // % | ||
197 | #define KC_PERCENT KC_PERC | ||
198 | |||
199 | #define KC_CIRC LSFT(KC_6) // ^ | ||
200 | #define KC_CIRCUMFLEX KC_CIRC | ||
201 | |||
202 | #define KC_AMPR LSFT(KC_7) // & | ||
203 | #define KC_AMPERSAND KC_AMPR | ||
204 | |||
205 | #define KC_ASTR LSFT(KC_8) // * | ||
206 | #define KC_ASTERISK KC_ASTR | ||
207 | |||
208 | #define KC_LPRN LSFT(KC_9) // ( | ||
209 | #define KC_LEFT_PAREN KC_LPRN | ||
210 | |||
211 | #define KC_RPRN LSFT(KC_0) // ) | ||
212 | #define KC_RIGHT_PAREN KC_RPRN | ||
213 | |||
214 | #define KC_UNDS LSFT(KC_MINS) // _ | ||
215 | #define KC_UNDERSCORE KC_UNDS | ||
216 | |||
217 | #define KC_PLUS LSFT(KC_EQL) // + | ||
218 | |||
219 | #define KC_LCBR LSFT(KC_LBRC) // { | ||
220 | #define KC_LEFT_CURLY_BRACE KC_LCBR | ||
221 | |||
222 | #define KC_RCBR LSFT(KC_RBRC) // } | ||
223 | #define KC_RIGHT_CURLY_BRACE KC_RCBR | ||
224 | |||
225 | #define KC_LABK LSFT(KC_COMM) // < | ||
226 | #define KC_LEFT_ANGLE_BRACKET KC_LABK | ||
227 | |||
228 | #define KC_RABK LSFT(KC_DOT) // > | ||
229 | #define KC_RIGHT_ANGLE_BRACKET KC_RABK | ||
230 | |||
231 | #define KC_COLN LSFT(KC_SCLN) // : | ||
232 | #define KC_COLON KC_COLN | ||
233 | |||
234 | #define KC_PIPE LSFT(KC_BSLS) // | | ||
235 | |||
236 | #define KC_LT LSFT(KC_COMM) // < | ||
237 | |||
238 | #define KC_GT LSFT(KC_DOT) // > | ||
239 | |||
240 | #define KC_QUES LSFT(KC_SLSH) // ? | ||
241 | #define KC_QUESTION KC_QUES | ||
242 | |||
243 | #define KC_DQT LSFT(KC_QUOT) // " | ||
244 | #define KC_DOUBLE_QUOTE KC_DQT | ||
245 | #define KC_DQUO KC_DQT | ||
246 | |||
247 | #define KC_DELT KC_DELETE // Del key (four letter code) | ||
248 | |||
249 | // Alias for function layers than expand past FN31 | ||
250 | #define FUNC(kc) (kc | QK_FUNCTION) | ||
251 | |||
252 | // Aliases | ||
253 | #define S(kc) LSFT(kc) | ||
254 | #define F(kc) FUNC(kc) | ||
255 | |||
256 | #define M(kc) (kc | QK_MACRO) | ||
257 | |||
258 | #define MACRODOWN(...) (record->event.pressed ? MACRO(__VA_ARGS__) : MACRO_NONE) | ||
259 | |||
260 | // L-ayer, T-ap - 256 keycode max, 16 layer max | ||
261 | #define LT(layer, kc) (kc | QK_LAYER_TAP | ((layer & 0xF) << 8)) | ||
262 | |||
263 | #define AG_SWAP MAGIC_SWAP_ALT_GUI | ||
264 | #define AG_NORM MAGIC_UNSWAP_ALT_GUI | ||
265 | |||
266 | #define BL_ON BL_9 | ||
267 | #define BL_OFF BL_0 | ||
268 | |||
269 | // GOTO layer - 16 layers max | ||
270 | // when: | ||
271 | // ON_PRESS = 1 | ||
272 | // ON_RELEASE = 2 | ||
273 | // Unless you have a good reason not to do so, prefer ON_PRESS (1) as your default. | ||
274 | #define TO(layer, when) (layer | QK_TO | (when << 0x4)) | ||
275 | |||
276 | // Momentary switch layer - 256 layer max | ||
277 | #define MO(layer) (layer | QK_MOMENTARY) | ||
278 | |||
279 | // Set default layer - 256 layer max | ||
280 | #define DF(layer) (layer | QK_DEF_LAYER) | ||
281 | |||
282 | // Toggle to layer - 256 layer max | ||
283 | #define TG(layer) (layer | QK_TOGGLE_LAYER) | ||
284 | |||
285 | // One-shot layer - 256 layer max | ||
286 | #define OSL(layer) (layer | QK_ONE_SHOT_LAYER) | ||
287 | |||
288 | // One-shot mod | ||
289 | #define OSM(layer) (layer | QK_ONE_SHOT_MOD) | ||
290 | |||
291 | // M-od, T-ap - 256 keycode max | ||
292 | #define MT(mod, kc) (kc | QK_MOD_TAP | ((mod & 0xF) << 8)) | ||
293 | #define CTL_T(kc) MT(MOD_LCTL, kc) | ||
294 | #define SFT_T(kc) MT(MOD_LSFT, kc) | ||
295 | #define ALT_T(kc) MT(MOD_LALT, kc) | ||
296 | #define GUI_T(kc) MT(MOD_LGUI, kc) | ||
297 | #define C_S_T(kc) MT(MOD_LCTL | MOD_LSFT, kc) // Control + Shift e.g. for gnome-terminal | ||
298 | #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 Win or Cmd, so just alt+shift+ctrl | ||
299 | #define LCAG_T(kc) MT(MOD_LCTL | MOD_LALT | MOD_LGUI, kc) // Left control alt and gui | ||
300 | #define ALL_T(kc) MT(MOD_LCTL | MOD_LSFT | MOD_LALT | MOD_LGUI, kc) // see http://brettterpstra.com/2012/12/08/a-useful-caps-lock-key/ | ||
301 | |||
302 | // Dedicated keycode versions for Hyper and Meh, if you want to use them as standalone keys rather than mod-tap | ||
303 | #define KC_HYPR HYPR(KC_NO) | ||
304 | #define KC_MEH MEH(KC_NO) | ||
305 | |||
306 | #ifdef UNICODE_ENABLE | ||
307 | // For sending unicode codes. | ||
308 | // You may not send codes over 7FFF -- this supports most of UTF8. | ||
309 | // To have a key that sends out Œ, go UC(0x0152) | ||
310 | #define UNICODE(n) (n | QK_UNICODE) | ||
311 | #define UC(n) UNICODE(n) | ||
312 | #endif | ||
313 | |||
314 | |||
315 | #endif | ||