aboutsummaryrefslogtreecommitdiff
path: root/quantum
diff options
context:
space:
mode:
authorJack Humbert <jack.humb@gmail.com>2016-06-18 14:30:24 -0400
committerGitHub <noreply@github.com>2016-06-18 14:30:24 -0400
commitdb32864ce7029d758f57729cc2f75e051a28d0a2 (patch)
treef3ac60d9c826a9ad5ef5bc4d199efaddae156ba6 /quantum
parent1923cffd41d9d71cd9f434092654dba05513137b (diff)
downloadqmk_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')
-rw-r--r--quantum/audio/audio.c2
-rw-r--r--quantum/audio/audio_pwm.c2
-rw-r--r--quantum/keycode_config.c74
-rw-r--r--quantum/keycode_config.h21
-rw-r--r--quantum/keymap.c163
-rw-r--r--quantum/keymap.h315
-rw-r--r--quantum/keymap_common.c323
-rw-r--r--quantum/keymap_common.h292
-rw-r--r--quantum/keymap_extras/keymap_bepo.h2
-rw-r--r--quantum/keymap_extras/keymap_colemak.h2
-rw-r--r--quantum/keymap_extras/keymap_dvorak.h2
-rw-r--r--quantum/keymap_extras/keymap_fr_ch.h2
-rw-r--r--quantum/keymap_extras/keymap_french.h2
-rw-r--r--quantum/keymap_extras/keymap_french_osx.h2
-rw-r--r--quantum/keymap_extras/keymap_german.h2
-rw-r--r--quantum/keymap_extras/keymap_german_ch.h2
-rw-r--r--quantum/keymap_extras/keymap_german_osx.h2
-rw-r--r--quantum/keymap_extras/keymap_neo2.h2
-rw-r--r--quantum/keymap_extras/keymap_nordic.h2
-rw-r--r--quantum/keymap_extras/keymap_plover.h2
-rw-r--r--quantum/keymap_extras/keymap_spanish.h2
-rw-r--r--quantum/keymap_extras/keymap_uk.h2
-rw-r--r--quantum/keymap_midi.c2
-rw-r--r--quantum/quantum.c183
-rw-r--r--quantum/quantum.h13
-rw-r--r--quantum/template/template.h2
26 files changed, 724 insertions, 696 deletions
diff --git a/quantum/audio/audio.c b/quantum/audio/audio.c
index 3ca249fdf..ead5fbf3e 100644
--- a/quantum/audio/audio.c
+++ b/quantum/audio/audio.c
@@ -6,7 +6,7 @@
6#include <avr/io.h> 6#include <avr/io.h>
7#include "print.h" 7#include "print.h"
8#include "audio.h" 8#include "audio.h"
9#include "keymap_common.h" 9#include "keymap.h"
10 10
11#include "eeconfig.h" 11#include "eeconfig.h"
12 12
diff --git a/quantum/audio/audio_pwm.c b/quantum/audio/audio_pwm.c
index 328a253a7..f820eec1b 100644
--- a/quantum/audio/audio_pwm.c
+++ b/quantum/audio/audio_pwm.c
@@ -6,7 +6,7 @@
6#include <avr/io.h> 6#include <avr/io.h>
7#include "print.h" 7#include "print.h"
8#include "audio.h" 8#include "audio.h"
9#include "keymap_common.h" 9#include "keymap.h"
10 10
11#include "eeconfig.h" 11#include "eeconfig.h"
12 12
diff --git a/quantum/keycode_config.c b/quantum/keycode_config.c
new file mode 100644
index 000000000..6d90781a1
--- /dev/null
+++ b/quantum/keycode_config.c
@@ -0,0 +1,74 @@
1#include "keycode_config.h"
2
3extern keymap_config_t keymap_config;
4
5uint16_t keycode_config(uint16_t keycode) {
6
7 switch (keycode) {
8 case KC_CAPSLOCK:
9 case KC_LOCKING_CAPS:
10 if (keymap_config.swap_control_capslock || keymap_config.capslock_to_control) {
11 return KC_LCTL;
12 }
13 return keycode;
14 case KC_LCTL:
15 if (keymap_config.swap_control_capslock) {
16 return KC_CAPSLOCK;
17 }
18 return KC_LCTL;
19 case KC_LALT:
20 if (keymap_config.swap_lalt_lgui) {
21 if (keymap_config.no_gui) {
22 return KC_NO;
23 }
24 return KC_LGUI;
25 }
26 return KC_LALT;
27 case KC_LGUI:
28 if (keymap_config.swap_lalt_lgui) {
29 return KC_LALT;
30 }
31 if (keymap_config.no_gui) {
32 return KC_NO;
33 }
34 return KC_LGUI;
35 case KC_RALT:
36 if (keymap_config.swap_ralt_rgui) {
37 if (keymap_config.no_gui) {
38 return KC_NO;
39 }
40 return KC_RGUI;
41 }
42 return KC_RALT;
43 case KC_RGUI:
44 if (keymap_config.swap_ralt_rgui) {
45 return KC_RALT;
46 }
47 if (keymap_config.no_gui) {
48 return KC_NO;
49 }
50 return KC_RGUI;
51 case KC_GRAVE:
52 if (keymap_config.swap_grave_esc) {
53 return KC_ESC;
54 }
55 return KC_GRAVE;
56 case KC_ESC:
57 if (keymap_config.swap_grave_esc) {
58 return KC_GRAVE;
59 }
60 return KC_ESC;
61 case KC_BSLASH:
62 if (keymap_config.swap_backslash_backspace) {
63 return KC_BSPACE;
64 }
65 return KC_BSLASH;
66 case KC_BSPACE:
67 if (keymap_config.swap_backslash_backspace) {
68 return KC_BSLASH;
69 }
70 return KC_BSPACE;
71 default:
72 return keycode;
73 }
74} \ No newline at end of file
diff --git a/quantum/keycode_config.h b/quantum/keycode_config.h
new file mode 100644
index 000000000..c41c08706
--- /dev/null
+++ b/quantum/keycode_config.h
@@ -0,0 +1,21 @@
1#include "eeconfig.h"
2#include "keycode.h"
3
4uint16_t keycode_config(uint16_t keycode);
5
6/* NOTE: Not portable. Bit field order depends on implementation */
7typedef union {
8 uint16_t raw;
9 struct {
10 bool swap_control_capslock:1;
11 bool capslock_to_control:1;
12 bool swap_lalt_lgui:1;
13 bool swap_ralt_rgui:1;
14 bool no_gui:1;
15 bool swap_grave_esc:1;
16 bool swap_backslash_backspace:1;
17 bool nkro:1;
18 };
19} keymap_config_t;
20
21keymap_config_t keymap_config; \ No newline at end of file
diff --git a/quantum/keymap.c b/quantum/keymap.c
new file mode 100644
index 000000000..203a82d95
--- /dev/null
+++ b/quantum/keymap.c
@@ -0,0 +1,163 @@
1/*
2Copyright 2012,2013 Jun Wako <wakojun@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#include "keymap.h"
19#include "report.h"
20#include "keycode.h"
21#include "action_layer.h"
22#include <util/delay.h>
23#include "action.h"
24#include "action_macro.h"
25#include "debug.h"
26#include "backlight.h"
27#include "quantum.h"
28
29#ifdef MIDI_ENABLE
30 #include "keymap_midi.h"
31#endif
32
33extern keymap_config_t keymap_config;
34
35#include <stdio.h>
36#include <inttypes.h>
37
38/* converts key to action */
39action_t action_for_key(uint8_t layer, keypos_t key)
40{
41 // 16bit keycodes - important
42 uint16_t keycode = keymap_key_to_keycode(layer, key);
43
44 // keycode remapping
45 keycode = keycode_config(keycode);
46
47 action_t action;
48 uint8_t action_layer, when, mod;
49
50 switch (keycode) {
51 case KC_FN0 ... KC_FN31:
52 action.code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]);
53 break;
54 case KC_A ... KC_EXSEL:
55 case KC_LCTRL ... KC_RGUI:
56 action.code = ACTION_KEY(keycode);
57 break;
58 case KC_SYSTEM_POWER ... KC_SYSTEM_WAKE:
59 action.code = ACTION_USAGE_SYSTEM(KEYCODE2SYSTEM(keycode));
60 break;
61 case KC_AUDIO_MUTE ... KC_WWW_FAVORITES:
62 action.code = ACTION_USAGE_CONSUMER(KEYCODE2CONSUMER(keycode));
63 break;
64 case KC_MS_UP ... KC_MS_ACCEL2:
65 action.code = ACTION_MOUSEKEY(keycode);
66 break;
67 case KC_TRNS:
68 action.code = ACTION_TRANSPARENT;
69 break;
70 case QK_MODS ... QK_MODS_MAX: ;
71 // Has a modifier
72 // Split it up
73 action.code = ACTION_MODS_KEY(keycode >> 8, keycode & 0xFF); // adds modifier to key
74 break;
75 case QK_FUNCTION ... QK_FUNCTION_MAX: ;
76 // Is a shortcut for function action_layer, pull last 12bits
77 // This means we have 4,096 FN macros at our disposal
78 action.code = pgm_read_word(&fn_actions[(int)keycode & 0xFFF]);
79 break;
80 case QK_MACRO ... QK_MACRO_MAX:
81 action.code = ACTION_MACRO(keycode & 0xFF);
82 break;
83 case QK_LAYER_TAP ... QK_LAYER_TAP_MAX:
84 action.code = ACTION_LAYER_TAP_KEY((keycode >> 0x8) & 0xF, keycode & 0xFF);
85 break;
86 case QK_TO ... QK_TO_MAX: ;
87 // Layer set "GOTO"
88 when = (keycode >> 0x4) & 0x3;
89 action_layer = keycode & 0xF;
90 action.code = ACTION_LAYER_SET(action_layer, when);
91 break;
92 case QK_MOMENTARY ... QK_MOMENTARY_MAX: ;
93 // Momentary action_layer
94 action_layer = keycode & 0xFF;
95 action.code = ACTION_LAYER_MOMENTARY(action_layer);
96 break;
97 case QK_DEF_LAYER ... QK_DEF_LAYER_MAX: ;
98 // Set default action_layer
99 action_layer = keycode & 0xFF;
100 action.code = ACTION_DEFAULT_LAYER_SET(action_layer);
101 break;
102 case QK_TOGGLE_LAYER ... QK_TOGGLE_LAYER_MAX: ;
103 // Set toggle
104 action_layer = keycode & 0xFF;
105 action.code = ACTION_LAYER_TOGGLE(action_layer);
106 break;
107 case QK_ONE_SHOT_LAYER ... QK_ONE_SHOT_LAYER_MAX: ;
108 // OSL(action_layer) - One-shot action_layer
109 action_layer = keycode & 0xFF;
110 action.code = ACTION_LAYER_ONESHOT(action_layer);
111 break;
112 case QK_ONE_SHOT_MOD ... QK_ONE_SHOT_MOD_MAX: ;
113 // OSM(mod) - One-shot mod
114 mod = keycode & 0xFF;
115 action.code = ACTION_MODS_ONESHOT(mod);
116 break;
117 case QK_MOD_TAP ... QK_MOD_TAP_MAX:
118 action.code = ACTION_MODS_TAP_KEY((keycode >> 0x8) & 0xF, keycode & 0xFF);
119 break;
120 #ifdef BACKLIGHT_ENABLE
121 case BL_0 ... BL_15:
122 action.code = ACTION_BACKLIGHT_LEVEL(keycode - BL_0);
123 break;
124 case BL_DEC:
125 action.code = ACTION_BACKLIGHT_DECREASE();
126 break;
127 case BL_INC:
128 action.code = ACTION_BACKLIGHT_INCREASE();
129 break;
130 case BL_TOGG:
131 action.code = ACTION_BACKLIGHT_TOGGLE();
132 break;
133 case BL_STEP:
134 action.code = ACTION_BACKLIGHT_STEP();
135 break;
136 #endif
137 default:
138 action.code = ACTION_NO;
139 break;
140 }
141 return action;
142}
143
144
145/* Macro */
146__attribute__ ((weak))
147const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
148{
149 return MACRO_NONE;
150}
151
152/* Function */
153__attribute__ ((weak))
154void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
155{
156}
157
158/* translates key to keycode */
159uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
160{
161 // Read entire word (16bits)
162 return pgm_read_word(&keymaps[(layer)][(key.row)][(key.col)]);
163}
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/*
2Copyright 2012,2013 Jun Wako <wakojun@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along 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 */
34uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key);
35
36/* translates Fn keycode to action */
37action_t keymap_fn_to_action(uint16_t keycode);
38
39extern const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
40extern const uint16_t fn_actions[];
41
42enum 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
diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c
deleted file mode 100644
index ba7269388..000000000
--- a/quantum/keymap_common.c
+++ /dev/null
@@ -1,323 +0,0 @@
1/*
2Copyright 2012,2013 Jun Wako <wakojun@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#include "keymap_common.h"
19#include "report.h"
20#include "keycode.h"
21#include "action_layer.h"
22#include <util/delay.h>
23#include "action.h"
24#include "action_macro.h"
25#include "debug.h"
26#include "backlight.h"
27#include "bootloader.h"
28#include "eeconfig.h"
29#include "quantum.h"
30
31#ifdef MIDI_ENABLE
32 #include "keymap_midi.h"
33#endif
34
35extern keymap_config_t keymap_config;
36
37#include <stdio.h>
38#include <inttypes.h>
39#ifdef AUDIO_ENABLE
40 #include "audio.h"
41#endif /* AUDIO_ENABLE */
42
43static action_t keycode_to_action(uint16_t keycode);
44
45/* converts key to action */
46action_t action_for_key(uint8_t layer, keypos_t key)
47{
48 // 16bit keycodes - important
49 uint16_t keycode = keymap_key_to_keycode(layer, key);
50
51 switch (keycode) {
52 case KC_FN0 ... KC_FN31:
53 return keymap_fn_to_action(keycode);
54 case KC_CAPSLOCK:
55 case KC_LOCKING_CAPS:
56 if (keymap_config.swap_control_capslock || keymap_config.capslock_to_control) {
57 return keycode_to_action(KC_LCTL);
58 }
59 return keycode_to_action(keycode);
60 case KC_LCTL:
61 if (keymap_config.swap_control_capslock) {
62 return keycode_to_action(KC_CAPSLOCK);
63 }
64 return keycode_to_action(KC_LCTL);
65 case KC_LALT:
66 if (keymap_config.swap_lalt_lgui) {
67 if (keymap_config.no_gui) {
68 return keycode_to_action(ACTION_NO);
69 }
70 return keycode_to_action(KC_LGUI);
71 }
72 return keycode_to_action(KC_LALT);
73 case KC_LGUI:
74 if (keymap_config.swap_lalt_lgui) {
75 return keycode_to_action(KC_LALT);
76 }
77 if (keymap_config.no_gui) {
78 return keycode_to_action(ACTION_NO);
79 }
80 return keycode_to_action(KC_LGUI);
81 case KC_RALT:
82 if (keymap_config.swap_ralt_rgui) {
83 if (keymap_config.no_gui) {
84 return keycode_to_action(ACTION_NO);
85 }
86 return keycode_to_action(KC_RGUI);
87 }
88 return keycode_to_action(KC_RALT);
89 case KC_RGUI:
90 if (keymap_config.swap_ralt_rgui) {
91 return keycode_to_action(KC_RALT);
92 }
93 if (keymap_config.no_gui) {
94 return keycode_to_action(ACTION_NO);
95 }
96 return keycode_to_action(KC_RGUI);
97 case KC_GRAVE:
98 if (keymap_config.swap_grave_esc) {
99 return keycode_to_action(KC_ESC);
100 }
101 return keycode_to_action(KC_GRAVE);
102 case KC_ESC:
103 if (keymap_config.swap_grave_esc) {
104 return keycode_to_action(KC_GRAVE);
105 }
106 return keycode_to_action(KC_ESC);
107 case KC_BSLASH:
108 if (keymap_config.swap_backslash_backspace) {
109 return keycode_to_action(KC_BSPACE);
110 }
111 return keycode_to_action(KC_BSLASH);
112 case KC_BSPACE:
113 if (keymap_config.swap_backslash_backspace) {
114 return keycode_to_action(KC_BSLASH);
115 }
116 return keycode_to_action(KC_BSPACE);
117 default:
118 return keycode_to_action(keycode);
119 }
120}
121
122
123/* Macro */
124__attribute__ ((weak))
125const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
126{
127 return MACRO_NONE;
128}
129
130/* Function */
131__attribute__ ((weak))
132void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
133{
134}
135
136/* translates keycode to action */
137static action_t keycode_to_action(uint16_t keycode)
138{
139 action_t action;
140 switch (keycode) {
141 case KC_A ... KC_EXSEL:
142 case KC_LCTRL ... KC_RGUI:
143 action.code = ACTION_KEY(keycode);
144 break;
145 case KC_SYSTEM_POWER ... KC_SYSTEM_WAKE:
146 action.code = ACTION_USAGE_SYSTEM(KEYCODE2SYSTEM(keycode));
147 break;
148 case KC_AUDIO_MUTE ... KC_WWW_FAVORITES:
149 action.code = ACTION_USAGE_CONSUMER(KEYCODE2CONSUMER(keycode));
150 break;
151 case KC_MS_UP ... KC_MS_ACCEL2:
152 action.code = ACTION_MOUSEKEY(keycode);
153 break;
154 case KC_TRNS:
155 action.code = ACTION_TRANSPARENT;
156 break;
157 case LCTL(0) ... 0x1FFF: ;
158 // Has a modifier
159 // Split it up
160 action.code = ACTION_MODS_KEY(keycode >> 8, keycode & 0xFF); // adds modifier to key
161 break;
162 case FUNC(0) ... FUNC(0xFFF): ;
163 // Is a shortcut for function layer, pull last 12bits
164 // This means we have 4,096 FN macros at our disposal
165 return keymap_func_to_action(keycode & 0xFFF);
166 break;
167 case M(0) ... M(0xFF):
168 action.code = ACTION_MACRO(keycode & 0xFF);
169 break;
170 case LT(0, 0) ... LT(0xFF, 0xF):
171 action.code = ACTION_LAYER_TAP_KEY((keycode >> 0x8) & 0xF, keycode & 0xFF);
172 break;
173 #ifdef BACKLIGHT_ENABLE
174 case BL_0 ... BL_15:
175 action.code = ACTION_BACKLIGHT_LEVEL(keycode & 0x000F);
176 break;
177 case BL_DEC:
178 action.code = ACTION_BACKLIGHT_DECREASE();
179 break;
180 case BL_INC:
181 action.code = ACTION_BACKLIGHT_INCREASE();
182 break;
183 case BL_TOGG:
184 action.code = ACTION_BACKLIGHT_TOGGLE();
185 break;
186 case BL_STEP:
187 action.code = ACTION_BACKLIGHT_STEP();
188 break;
189 #endif
190 case RESET: ; // RESET is 0x5000, which is why this is here
191 clear_keyboard();
192 #ifdef AUDIO_ENABLE
193 stop_all_notes();
194 shutdown_user();
195 #endif
196 _delay_ms(250);
197 #ifdef ATREUS_ASTAR
198 *(uint16_t *)0x0800 = 0x7777; // these two are a-star-specific
199 #endif
200 bootloader_jump();
201 break;
202 case DEBUG: ; // DEBUG is 0x5001
203 print("\nDEBUG: enabled.\n");
204 debug_enable = true;
205 break;
206 case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_UNSWAP_ALT_GUI:
207 // MAGIC actions (BOOTMAGIC without the boot)
208 if (!eeconfig_is_enabled()) {
209 eeconfig_init();
210 }
211 /* keymap config */
212 keymap_config.raw = eeconfig_read_keymap();
213 if (keycode == MAGIC_SWAP_CONTROL_CAPSLOCK) {
214 keymap_config.swap_control_capslock = 1;
215 } else if (keycode == MAGIC_CAPSLOCK_TO_CONTROL) {
216 keymap_config.capslock_to_control = 1;
217 } else if (keycode == MAGIC_SWAP_LALT_LGUI) {
218 keymap_config.swap_lalt_lgui = 1;
219 } else if (keycode == MAGIC_SWAP_RALT_RGUI) {
220 keymap_config.swap_ralt_rgui = 1;
221 } else if (keycode == MAGIC_NO_GUI) {
222 keymap_config.no_gui = 1;
223 } else if (keycode == MAGIC_SWAP_GRAVE_ESC) {
224 keymap_config.swap_grave_esc = 1;
225 } else if (keycode == MAGIC_SWAP_BACKSLASH_BACKSPACE) {
226 keymap_config.swap_backslash_backspace = 1;
227 } else if (keycode == MAGIC_HOST_NKRO) {
228 keymap_config.nkro = 1;
229 } else if (keycode == MAGIC_SWAP_ALT_GUI) {
230 keymap_config.swap_lalt_lgui = 1;
231 keymap_config.swap_ralt_rgui = 1;
232 }
233 /* UNs */
234 else if (keycode == MAGIC_UNSWAP_CONTROL_CAPSLOCK) {
235 keymap_config.swap_control_capslock = 0;
236 } else if (keycode == MAGIC_UNCAPSLOCK_TO_CONTROL) {
237 keymap_config.capslock_to_control = 0;
238 } else if (keycode == MAGIC_UNSWAP_LALT_LGUI) {
239 keymap_config.swap_lalt_lgui = 0;
240 } else if (keycode == MAGIC_UNSWAP_RALT_RGUI) {
241 keymap_config.swap_ralt_rgui = 0;
242 } else if (keycode == MAGIC_UNNO_GUI) {
243 keymap_config.no_gui = 0;
244 } else if (keycode == MAGIC_UNSWAP_GRAVE_ESC) {
245 keymap_config.swap_grave_esc = 0;
246 } else if (keycode == MAGIC_UNSWAP_BACKSLASH_BACKSPACE) {
247 keymap_config.swap_backslash_backspace = 0;
248 } else if (keycode == MAGIC_UNHOST_NKRO) {
249 keymap_config.nkro = 0;
250 } else if (keycode == MAGIC_UNSWAP_ALT_GUI) {
251 keymap_config.swap_lalt_lgui = 0;
252 keymap_config.swap_ralt_rgui = 0;
253 }
254 eeconfig_update_keymap(keymap_config.raw);
255 break;
256 case TO(0, 1) ... OSM(0xFF): ;
257 // Layer movement shortcuts
258 // See .h to see constraints/usage
259 int type = (keycode >> 0x8) & 0xF;
260 if (type == 0x1) {
261 // Layer set "GOTO"
262 int when = (keycode >> 0x4) & 0x3;
263 int layer = keycode & 0xF;
264 action.code = ACTION_LAYER_SET(layer, when);
265 } else if (type == 0x2) {
266 // Momentary layer
267 int layer = keycode & 0xFF;
268 action.code = ACTION_LAYER_MOMENTARY(layer);
269 } else if (type == 0x3) {
270 // Set default layer
271 int layer = keycode & 0xFF;
272 action.code = ACTION_DEFAULT_LAYER_SET(layer);
273 } else if (type == 0x4) {
274 // Set default layer
275 int layer = keycode & 0xFF;
276 action.code = ACTION_LAYER_TOGGLE(layer);
277 } else if (type == 0x5) {
278 // OSL(layer) - One-shot layer
279 int layer = keycode & 0xFF;
280 action.code = ACTION_LAYER_ONESHOT(layer);
281 } else if (type == 0x6) {
282 // OSM(mod) - One-shot mod
283 int mod = keycode & 0xFF;
284 action.code = ACTION_MODS_ONESHOT(mod);
285 }
286 break;
287 case MT(0, 0) ... MT(0xF, 0xFF):
288 action.code = ACTION_MODS_TAP_KEY((keycode >> 0x8) & 0xF, keycode & 0xFF);
289 break;
290 default:
291 action.code = ACTION_NO;
292 break;
293 }
294 return action;
295}
296
297
298/* translates key to keycode */
299uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
300{
301 // Read entire word (16bits)
302 return pgm_read_word(&keymaps[(layer)][(key.row)][(key.col)]);
303}
304
305/* translates Fn keycode to action */
306action_t keymap_fn_to_action(uint16_t keycode)
307{
308 return (action_t){ .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]) };
309}
310
311action_t keymap_func_to_action(uint16_t keycode)
312{
313 // For FUNC without 8bit limit
314 return (action_t){ .code = pgm_read_word(&fn_actions[(int)keycode]) };
315}
316
317void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3) {
318 if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) {
319 layer_on(layer3);
320 } else {
321 layer_off(layer3);
322 }
323}
diff --git a/quantum/keymap_common.h b/quantum/keymap_common.h
deleted file mode 100644
index c72c0bc29..000000000
--- a/quantum/keymap_common.h
+++ /dev/null
@@ -1,292 +0,0 @@
1/*
2Copyright 2012,2013 Jun Wako <wakojun@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along 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 "keymap.h"
27#include "action_macro.h"
28#include "report.h"
29#include "host.h"
30// #include "print.h"
31#include "debug.h"
32
33/* NOTE: Not portable. Bit field order depends on implementation */
34typedef union {
35 uint16_t raw;
36 struct {
37 bool swap_control_capslock:1;
38 bool capslock_to_control:1;
39 bool swap_lalt_lgui:1;
40 bool swap_ralt_rgui:1;
41 bool no_gui:1;
42 bool swap_grave_esc:1;
43 bool swap_backslash_backspace:1;
44 bool nkro:1;
45 };
46} keymap_config_t;
47
48
49/* translates key to keycode */
50uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key);
51
52/* translates Fn keycode to action */
53action_t keymap_fn_to_action(uint16_t keycode);
54
55/* translates Fn keycode to action */
56action_t keymap_func_to_action(uint16_t keycode);
57
58extern const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
59extern const uint16_t fn_actions[];
60
61// Ability to use mods in layouts
62#define LCTL(kc) kc | 0x0100
63#define LSFT(kc) kc | 0x0200
64#define LALT(kc) kc | 0x0400
65#define LGUI(kc) kc | 0x0800
66#define HYPR(kc) kc | 0x0F00
67#define MEH(kc) kc | 0x0700
68#define LCAG(kc) kc | 0x0D00 // Modifier Ctrl Alt and GUI
69
70#define MOD_HYPR 0xf
71#define MOD_MEH 0x7
72
73#define RCTL(kc) kc | 0x1100
74#define RSFT(kc) kc | 0x1200
75#define RALT(kc) kc | 0x1400
76#define RGUI(kc) kc | 0x1800
77
78// Aliases for shifted symbols
79// Each key has a 4-letter code, and some have longer aliases too.
80// While the long aliases are descriptive, the 4-letter codes
81// make for nicer grid layouts (everything lines up), and are
82// the preferred style for Quantum.
83#define KC_TILD LSFT(KC_GRV) // ~
84#define KC_TILDE KC_TILD
85
86#define KC_EXLM LSFT(KC_1) // !
87#define KC_EXCLAIM KC_EXLM
88
89#define KC_AT LSFT(KC_2) // @
90
91#define KC_HASH LSFT(KC_3) // #
92
93#define KC_DLR LSFT(KC_4) // $
94#define KC_DOLLAR KC_DLR
95
96#define KC_PERC LSFT(KC_5) // %
97#define KC_PERCENT KC_PERC
98
99#define KC_CIRC LSFT(KC_6) // ^
100#define KC_CIRCUMFLEX KC_CIRC
101
102#define KC_AMPR LSFT(KC_7) // &
103#define KC_AMPERSAND KC_AMPR
104
105#define KC_ASTR LSFT(KC_8) // *
106#define KC_ASTERISK KC_ASTR
107
108#define KC_LPRN LSFT(KC_9) // (
109#define KC_LEFT_PAREN KC_LPRN
110
111#define KC_RPRN LSFT(KC_0) // )
112#define KC_RIGHT_PAREN KC_RPRN
113
114#define KC_UNDS LSFT(KC_MINS) // _
115#define KC_UNDERSCORE KC_UNDS
116
117#define KC_PLUS LSFT(KC_EQL) // +
118
119#define KC_LCBR LSFT(KC_LBRC) // {
120#define KC_LEFT_CURLY_BRACE KC_LCBR
121
122#define KC_RCBR LSFT(KC_RBRC) // }
123#define KC_RIGHT_CURLY_BRACE KC_RCBR
124
125#define KC_LABK LSFT(KC_COMM) // <
126#define KC_LEFT_ANGLE_BRACKET KC_LABK
127
128#define KC_RABK LSFT(KC_DOT) // >
129#define KC_RIGHT_ANGLE_BRACKET KC_RABK
130
131#define KC_COLN LSFT(KC_SCLN) // :
132#define KC_COLON KC_COLN
133
134#define KC_PIPE LSFT(KC_BSLS) // |
135
136#define KC_LT LSFT(KC_COMM) // <
137
138#define KC_GT LSFT(KC_DOT) // >
139
140#define KC_QUES LSFT(KC_SLSH) // ?
141#define KC_QUESTION KC_QUES
142
143#define KC_DQT LSFT(KC_QUOT) // "
144#define KC_DOUBLE_QUOTE KC_DQT
145#define KC_DQUO KC_DQT
146
147#define KC_DELT KC_DELETE // Del key (four letter code)
148
149// Alias for function layers than expand past FN31
150#define FUNC(kc) kc | 0x2000
151
152// Aliases
153#define S(kc) LSFT(kc)
154#define F(kc) FUNC(kc)
155
156#define M(kc) (kc | 0x3000)
157
158#define MACRODOWN(...) (record->event.pressed ? MACRO(__VA_ARGS__) : MACRO_NONE)
159
160// 0x3100+ is free
161
162// L-ayer, T-ap - 256 keycode max, 16 layer max
163#define LT(layer, kc) (kc | 0x4000 | ((layer & 0xF) << 8))
164
165#define RESET 0x5000
166#define DEBUG 0x5001
167
168// MAGIC keycodes
169#define MAGIC_SWAP_CONTROL_CAPSLOCK 0x5002
170#define MAGIC_UNSWAP_CONTROL_CAPSLOCK 0x5003
171#define MAGIC_CAPSLOCK_TO_CONTROL 0x5004
172#define MAGIC_UNCAPSLOCK_TO_CONTROL 0x5005
173#define MAGIC_SWAP_LALT_LGUI 0x5006
174#define MAGIC_UNSWAP_LALT_LGUI 0x5007
175#define MAGIC_SWAP_RALT_RGUI 0x5008
176#define MAGIC_UNSWAP_RALT_RGUI 0x5009
177#define MAGIC_NO_GUI 0x500a
178#define MAGIC_UNNO_GUI 0x500b
179#define MAGIC_SWAP_GRAVE_ESC 0x500c
180#define MAGIC_UNSWAP_GRAVE_ESC 0x500d
181#define MAGIC_SWAP_BACKSLASH_BACKSPACE 0x500e
182#define MAGIC_UNSWAP_BACKSLASH_BACKSPACE 0x500f
183#define MAGIC_HOST_NKRO 0x5010
184#define MAGIC_UNHOST_NKRO 0x5011
185#define MAGIC_SWAP_ALT_GUI 0x5012
186#define MAGIC_UNSWAP_ALT_GUI 0x5013
187
188#define AG_SWAP MAGIC_SWAP_ALT_GUI
189#define AG_NORM MAGIC_UNSWAP_ALT_GUI
190
191#define KC_LEAD 0x5014
192
193// Audio on/off
194#define AU_ON 0x5020
195#define AU_OFF 0x5021
196#define AU_TOG 0x5022
197
198// Music mode on/off
199#define MU_ON 0x5023
200#define MU_OFF 0x5024
201#define MU_TOG 0x5025
202
203// Music voice iterate
204#define MUV_IN 0x5026
205#define MUV_DE 0x5027
206
207// Midi mode on/off
208#define MI_ON 0x5028
209#define MI_OFF 0x5029
210
211// These affect the backlight (if your keyboard has one).
212// We don't need to comment them out if your keyboard doesn't have a backlight,
213// since they don't take up any space.
214#define BL_ON 0x5079
215#define BL_OFF 0x5070
216#define BL_0 0x5070
217#define BL_1 0x5071
218#define BL_2 0x5072
219#define BL_3 0x5073
220#define BL_4 0x5074
221#define BL_5 0x5075
222#define BL_6 0x5076
223#define BL_7 0x5077
224#define BL_8 0x5078
225#define BL_9 0x5079
226#define BL_10 0x507A
227#define BL_11 0x507B
228#define BL_12 0x507C
229#define BL_13 0x507D
230#define BL_14 0x507E
231#define BL_15 0x507F
232#define BL_DEC 0x5080
233#define BL_INC 0x5081
234#define BL_TOGG 0x5082
235#define BL_STEP 0x5083
236
237#define KC_LSPO 0x5084 // Left shift, open parens when tapped
238#define KC_RSPC 0x5085 // Right shift, close parens when tapped
239// GOTO layer - 16 layers max
240// when:
241// ON_PRESS = 1
242// ON_RELEASE = 2
243// Unless you have a good reason not to do so, prefer ON_PRESS (1) as your default.
244#define TO(layer, when) (layer | 0x5100 | (when << 0x4))
245
246// Momentary switch layer - 256 layer max
247#define MO(layer) (layer | 0x5200)
248
249// Set default layer - 256 layer max
250#define DF(layer) (layer | 0x5300)
251
252// Toggle to layer - 256 layer max
253#define TG(layer) (layer | 0x5400)
254
255// One-shot layer - 256 layer max
256#define OSL(layer) (layer | 0x5500)
257
258// One-shot mod
259#define OSM(layer) (layer | 0x5600)
260
261// chording is currently at 0x57xx
262
263// M-od, T-ap - 256 keycode max
264#define MT(mod, kc) (kc | 0x7000 | ((mod & 0xF) << 8))
265#define CTL_T(kc) MT(0x1, kc)
266#define SFT_T(kc) MT(0x2, kc)
267#define ALT_T(kc) MT(0x4, kc)
268#define GUI_T(kc) MT(0x8, kc)
269#define C_S_T(kc) MT(0x3, kc) // Control + Shift e.g. for gnome-terminal
270#define MEH_T(kc) MT(0x7, kc) // Meh is a less hyper version of the Hyper key -- doesn't include Win or Cmd, so just alt+shift+ctrl
271#define LCAG_T(kc) MT(0xD, kc) // Left control alt and gui
272#define ALL_T(kc) MT(0xF, kc) // see http://brettterpstra.com/2012/12/08/a-useful-caps-lock-key/
273
274// Dedicated keycode versions for Hyper and Meh, if you want to use them as standalone keys rather than mod-tap
275#define KC_HYPR HYPR(KC_NO)
276#define KC_MEH MEH(KC_NO)
277
278#ifdef UNICODE_ENABLE
279 // For sending unicode codes.
280 // You may not send codes over 7FFF -- this supports most of UTF8.
281 // To have a key that sends out Å’, go UC(0x0152)
282 #define UNICODE(n) (n | 0x8000)
283 #define UC(n) UNICODE(n)
284#endif
285
286// For tri-layer
287void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3);
288#define IS_LAYER_ON(layer) (layer_state & (1UL << (layer)))
289#define IS_LAYER_OFF(layer) (~layer_state & (1UL << (layer)))
290
291
292#endif
diff --git a/quantum/keymap_extras/keymap_bepo.h b/quantum/keymap_extras/keymap_bepo.h
index 1ab2d63dd..4c3096054 100644
--- a/quantum/keymap_extras/keymap_bepo.h
+++ b/quantum/keymap_extras/keymap_bepo.h
@@ -2,7 +2,7 @@
2#ifndef KEYMAP_BEPO_H 2#ifndef KEYMAP_BEPO_H
3#define KEYMAP_BEPO_H 3#define KEYMAP_BEPO_H
4 4
5#include "keymap_common.h" 5#include "keymap.h"
6 6
7// Alt gr 7// Alt gr
8#ifndef ALTGR 8#ifndef ALTGR
diff --git a/quantum/keymap_extras/keymap_colemak.h b/quantum/keymap_extras/keymap_colemak.h
index 8a418c615..b8d615748 100644
--- a/quantum/keymap_extras/keymap_colemak.h
+++ b/quantum/keymap_extras/keymap_colemak.h
@@ -1,7 +1,7 @@
1#ifndef KEYMAP_COLEMAK_H 1#ifndef KEYMAP_COLEMAK_H
2#define KEYMAP_COLEMAK_H 2#define KEYMAP_COLEMAK_H
3 3
4#include "keymap_common.h" 4#include "keymap.h"
5// For software implementation of colemak 5// For software implementation of colemak
6#define CM_Q KC_Q 6#define CM_Q KC_Q
7#define CM_W KC_W 7#define CM_W KC_W
diff --git a/quantum/keymap_extras/keymap_dvorak.h b/quantum/keymap_extras/keymap_dvorak.h
index 93e355bf9..e855056e8 100644
--- a/quantum/keymap_extras/keymap_dvorak.h
+++ b/quantum/keymap_extras/keymap_dvorak.h
@@ -1,7 +1,7 @@
1#ifndef KEYMAP_DVORAK_H 1#ifndef KEYMAP_DVORAK_H
2#define KEYMAP_DVORAK_H 2#define KEYMAP_DVORAK_H
3 3
4#include "keymap_common.h" 4#include "keymap.h"
5 5
6// Normal characters 6// Normal characters
7#define DV_GRV KC_GRV 7#define DV_GRV KC_GRV
diff --git a/quantum/keymap_extras/keymap_fr_ch.h b/quantum/keymap_extras/keymap_fr_ch.h
index d3884c19a..3fd971357 100644
--- a/quantum/keymap_extras/keymap_fr_ch.h
+++ b/quantum/keymap_extras/keymap_fr_ch.h
@@ -1,7 +1,7 @@
1#ifndef KEYMAP_FR_CH 1#ifndef KEYMAP_FR_CH
2#define KEYMAP_FR_CH 2#define KEYMAP_FR_CH
3 3
4#include "keymap_common.h" 4#include "keymap.h"
5 5
6// Alt gr 6// Alt gr
7#define ALGR(kc) kc | 0x1400 7#define ALGR(kc) kc | 0x1400
diff --git a/quantum/keymap_extras/keymap_french.h b/quantum/keymap_extras/keymap_french.h
index e03a121a2..2a44c80b1 100644
--- a/quantum/keymap_extras/keymap_french.h
+++ b/quantum/keymap_extras/keymap_french.h
@@ -1,7 +1,7 @@
1#ifndef KEYMAP_FRENCH_H 1#ifndef KEYMAP_FRENCH_H
2#define KEYMAP_FRENCH_H 2#define KEYMAP_FRENCH_H
3 3
4#include "keymap_common.h" 4#include "keymap.h"
5 5
6// Alt gr 6// Alt gr
7#define ALGR(kc) kc | 0x1400 7#define ALGR(kc) kc | 0x1400
diff --git a/quantum/keymap_extras/keymap_french_osx.h b/quantum/keymap_extras/keymap_french_osx.h
index eb31bfb4d..004d73ee2 100644
--- a/quantum/keymap_extras/keymap_french_osx.h
+++ b/quantum/keymap_extras/keymap_french_osx.h
@@ -1,7 +1,7 @@
1#ifndef KEYMAP_FRENCH_OSX_H 1#ifndef KEYMAP_FRENCH_OSX_H
2#define KEYMAP_FRENCH_OSX_H 2#define KEYMAP_FRENCH_OSX_H
3 3
4#include "keymap_common.h" 4#include "keymap.h"
5 5
6// Normal characters 6// Normal characters
7#define FR_AT KC_GRV 7#define FR_AT KC_GRV
diff --git a/quantum/keymap_extras/keymap_german.h b/quantum/keymap_extras/keymap_german.h
index dbad26f8a..3f9ae8bad 100644
--- a/quantum/keymap_extras/keymap_german.h
+++ b/quantum/keymap_extras/keymap_german.h
@@ -1,7 +1,7 @@
1#ifndef KEYMAP_GERMAN 1#ifndef KEYMAP_GERMAN
2#define KEYMAP_GERMAN 2#define KEYMAP_GERMAN
3 3
4#include "keymap_common.h" 4#include "keymap.h"
5 5
6// Alt gr 6// Alt gr
7#define ALGR(kc) kc | 0x1400 7#define ALGR(kc) kc | 0x1400
diff --git a/quantum/keymap_extras/keymap_german_ch.h b/quantum/keymap_extras/keymap_german_ch.h
index 0874abf7d..6a782bcd7 100644
--- a/quantum/keymap_extras/keymap_german_ch.h
+++ b/quantum/keymap_extras/keymap_german_ch.h
@@ -1,7 +1,7 @@
1#ifndef KEYMAP_SWISS_GERMAN 1#ifndef KEYMAP_SWISS_GERMAN
2#define KEYMAP_SWISS_GERMAN 2#define KEYMAP_SWISS_GERMAN
3 3
4#include "keymap_common.h" 4#include "keymap.h"
5 5
6// Alt gr 6// Alt gr
7#define ALGR(kc) kc | 0x1400 7#define ALGR(kc) kc | 0x1400
diff --git a/quantum/keymap_extras/keymap_german_osx.h b/quantum/keymap_extras/keymap_german_osx.h
index ee725bad5..b2040a278 100644
--- a/quantum/keymap_extras/keymap_german_osx.h
+++ b/quantum/keymap_extras/keymap_german_osx.h
@@ -4,7 +4,7 @@
4#ifdef KEYMAP_GERMAN 4#ifdef KEYMAP_GERMAN
5 #warning redefining german keys 5 #warning redefining german keys
6#endif 6#endif
7#include "keymap_common.h" 7#include "keymap.h"
8 8
9// Alt gr 9// Alt gr
10 10
diff --git a/quantum/keymap_extras/keymap_neo2.h b/quantum/keymap_extras/keymap_neo2.h
index a35ba55a5..b54cb74b9 100644
--- a/quantum/keymap_extras/keymap_neo2.h
+++ b/quantum/keymap_extras/keymap_neo2.h
@@ -1,7 +1,7 @@
1#ifndef KEYMAP_NEO2 1#ifndef KEYMAP_NEO2
2#define KEYMAP_NEO2 2#define KEYMAP_NEO2
3 3
4#include "keymap_common.h" 4#include "keymap.h"
5#include "keymap_extras/keymap_german.h" 5#include "keymap_extras/keymap_german.h"
6 6
7#define NEO_A KC_D 7#define NEO_A KC_D
diff --git a/quantum/keymap_extras/keymap_nordic.h b/quantum/keymap_extras/keymap_nordic.h
index 7ef41fb79..3acb8b698 100644
--- a/quantum/keymap_extras/keymap_nordic.h
+++ b/quantum/keymap_extras/keymap_nordic.h
@@ -1,7 +1,7 @@
1#ifndef KEYMAP_NORDIC_H 1#ifndef KEYMAP_NORDIC_H
2#define KEYMAP_NORDIC_H 2#define KEYMAP_NORDIC_H
3 3
4#include "keymap_common.h" 4#include "keymap.h"
5 5
6// Alt gr 6// Alt gr
7#define ALGR(kc) kc | 0x1400 7#define ALGR(kc) kc | 0x1400
diff --git a/quantum/keymap_extras/keymap_plover.h b/quantum/keymap_extras/keymap_plover.h
index 98e57ab7b..9b88f7d84 100644
--- a/quantum/keymap_extras/keymap_plover.h
+++ b/quantum/keymap_extras/keymap_plover.h
@@ -1,7 +1,7 @@
1#ifndef KEYMAP_PLOVER_H 1#ifndef KEYMAP_PLOVER_H
2#define KEYMAP_PLOVER_H 2#define KEYMAP_PLOVER_H
3 3
4#include "keymap_common.h" 4#include "keymap.h"
5 5
6#define PV_NUM KC_1 6#define PV_NUM KC_1
7#define PV_LS KC_Q 7#define PV_LS KC_Q
diff --git a/quantum/keymap_extras/keymap_spanish.h b/quantum/keymap_extras/keymap_spanish.h
index 7f980afbc..512d8a374 100644
--- a/quantum/keymap_extras/keymap_spanish.h
+++ b/quantum/keymap_extras/keymap_spanish.h
@@ -1,7 +1,7 @@
1#ifndef KEYMAP_SPANISH_H 1#ifndef KEYMAP_SPANISH_H
2#define KEYMAP_SPANISH_H 2#define KEYMAP_SPANISH_H
3 3
4#include "keymap_common.h" 4#include "keymap.h"
5 5
6// Alt gr 6// Alt gr
7#define ALGR(kc) kc | 0x1400 7#define ALGR(kc) kc | 0x1400
diff --git a/quantum/keymap_extras/keymap_uk.h b/quantum/keymap_extras/keymap_uk.h
index 5b4bd3c0d..5c5d95179 100644
--- a/quantum/keymap_extras/keymap_uk.h
+++ b/quantum/keymap_extras/keymap_uk.h
@@ -1,7 +1,7 @@
1#ifndef KEYMAP_UK_H 1#ifndef KEYMAP_UK_H
2#define KEYMAP_UK_H 2#define KEYMAP_UK_H
3 3
4#include "keymap_common.h" 4#include "keymap.h"
5 5
6// Alt gr 6// Alt gr
7#define ALGR(kc) kc | 0x1400 7#define ALGR(kc) kc | 0x1400
diff --git a/quantum/keymap_midi.c b/quantum/keymap_midi.c
index ac45d2589..46049b987 100644
--- a/quantum/keymap_midi.c
+++ b/quantum/keymap_midi.c
@@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>. 15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/ 16*/
17 17
18#include "keymap_common.h" 18#include "keymap.h"
19#include "keymap_midi.h" 19#include "keymap_midi.h"
20 20
21uint8_t starting_note = 0x0C; 21uint8_t starting_note = 0x0C;
diff --git a/quantum/quantum.c b/quantum/quantum.c
index 0a900aac2..a310608e0 100644
--- a/quantum/quantum.c
+++ b/quantum/quantum.c
@@ -1,5 +1,4 @@
1#include "quantum.h" 1#include "quantum.h"
2#include "timer.h"
3 2
4__attribute__ ((weak)) 3__attribute__ ((weak))
5void matrix_init_kb(void) {} 4void matrix_init_kb(void) {}
@@ -35,15 +34,15 @@ int offset = 7;
35#ifdef AUDIO_ENABLE 34#ifdef AUDIO_ENABLE
36 bool music_activated = false; 35 bool music_activated = false;
37 36
38// music sequencer 37 // music sequencer
39static bool music_sequence_recording = false; 38 static bool music_sequence_recording = false;
40static bool music_sequence_playing = false; 39 static bool music_sequence_playing = false;
41static float music_sequence[16] = {0}; 40 static float music_sequence[16] = {0};
42static uint8_t music_sequence_count = 0; 41 static uint8_t music_sequence_count = 0;
43static uint8_t music_sequence_position = 0; 42 static uint8_t music_sequence_position = 0;
44 43
45static uint16_t music_sequence_timer = 0; 44 static uint16_t music_sequence_timer = 0;
46static uint16_t music_sequence_interval = 100; 45 static uint16_t music_sequence_interval = 100;
47 46
48#endif 47#endif
49 48
@@ -172,10 +171,6 @@ bool process_record_quantum(keyrecord_t *record) {
172 if (record->event.pressed) { 171 if (record->event.pressed) {
173 starting_note++; // Change key 172 starting_note++; // Change key
174 midi_send_cc(&midi_device, 0, 0x7B, 0); 173 midi_send_cc(&midi_device, 0, 0x7B, 0);
175 // midi_send_cc(&midi_device, 1, 0x7B, 0);
176 // midi_send_cc(&midi_device, 2, 0x7B, 0);
177 // midi_send_cc(&midi_device, 3, 0x7B, 0);
178 // midi_send_cc(&midi_device, 4, 0x7B, 0);
179 } 174 }
180 return false; 175 return false;
181 } 176 }
@@ -183,29 +178,17 @@ bool process_record_quantum(keyrecord_t *record) {
183 if (record->event.pressed) { 178 if (record->event.pressed) {
184 starting_note--; // Change key 179 starting_note--; // Change key
185 midi_send_cc(&midi_device, 0, 0x7B, 0); 180 midi_send_cc(&midi_device, 0, 0x7B, 0);
186 // midi_send_cc(&midi_device, 1, 0x7B, 0);
187 // midi_send_cc(&midi_device, 2, 0x7B, 0);
188 // midi_send_cc(&midi_device, 3, 0x7B, 0);
189 // midi_send_cc(&midi_device, 4, 0x7B, 0);
190 } 181 }
191 return false; 182 return false;
192 } 183 }
193 if (record->event.key.col == (MATRIX_COLS - 3) && record->event.key.row == (MATRIX_ROWS - 1) && record->event.pressed) { 184 if (record->event.key.col == (MATRIX_COLS - 3) && record->event.key.row == (MATRIX_ROWS - 1) && record->event.pressed) {
194 offset++; // Change scale 185 offset++; // Change scale
195 midi_send_cc(&midi_device, 0, 0x7B, 0); 186 midi_send_cc(&midi_device, 0, 0x7B, 0);
196 // midi_send_cc(&midi_device, 1, 0x7B, 0);
197 // midi_send_cc(&midi_device, 2, 0x7B, 0);
198 // midi_send_cc(&midi_device, 3, 0x7B, 0);
199 // midi_send_cc(&midi_device, 4, 0x7B, 0);
200 return false; 187 return false;
201 } 188 }
202 if (record->event.key.col == (MATRIX_COLS - 4) && record->event.key.row == (MATRIX_ROWS - 1) && record->event.pressed) { 189 if (record->event.key.col == (MATRIX_COLS - 4) && record->event.key.row == (MATRIX_ROWS - 1) && record->event.pressed) {
203 offset--; // Change scale 190 offset--; // Change scale
204 midi_send_cc(&midi_device, 0, 0x7B, 0); 191 midi_send_cc(&midi_device, 0, 0x7B, 0);
205 // midi_send_cc(&midi_device, 1, 0x7B, 0);
206 // midi_send_cc(&midi_device, 2, 0x7B, 0);
207 // midi_send_cc(&midi_device, 3, 0x7B, 0);
208 // midi_send_cc(&midi_device, 4, 0x7B, 0);
209 return false; 192 return false;
210 } 193 }
211 // basic 194 // basic
@@ -365,7 +348,7 @@ bool process_record_quantum(keyrecord_t *record) {
365#define DISABLE_CHORDING 348#define DISABLE_CHORDING
366#ifndef DISABLE_CHORDING 349#ifndef DISABLE_CHORDING
367 350
368 if (keycode >= 0x5700 && keycode <= 0x57FF) { 351 if (keycode >= QK_CHORDING && keycode <= QK_CHORDING_MAX) {
369 if (record->event.pressed) { 352 if (record->event.pressed) {
370 if (!chording) { 353 if (!chording) {
371 chording = true; 354 chording = true;
@@ -403,7 +386,7 @@ bool process_record_quantum(keyrecord_t *record) {
403 386
404#ifdef UNICODE_ENABLE 387#ifdef UNICODE_ENABLE
405 388
406 if (keycode > UNICODE(0) && record->event.pressed) { 389 if (keycode > QK_UNICODE && record->event.pressed) {
407 uint16_t unicode = keycode & 0x7FFF; 390 uint16_t unicode = keycode & 0x7FFF;
408 switch(input_mode) { 391 switch(input_mode) {
409 case UC_OSX: 392 case UC_OSX:
@@ -443,42 +426,117 @@ bool process_record_quantum(keyrecord_t *record) {
443 // Shift / paren setup 426 // Shift / paren setup
444 427
445 switch(keycode) { 428 switch(keycode) {
429 case RESET:
430 if (record->event.pressed) {
431 clear_keyboard();
432 #ifdef AUDIO_ENABLE
433 stop_all_notes();
434 shutdown_user();
435 #endif
436 _delay_ms(250);
437 #ifdef ATREUS_ASTAR
438 *(uint16_t *)0x0800 = 0x7777; // these two are a-star-specific
439 #endif
440 bootloader_jump();
441 return false;
442 }
443 break;
444 case DEBUG:
445 if (record->event.pressed) {
446 print("\nDEBUG: enabled.\n");
447 debug_enable = true;
448 return false;
449 }
450 break;
451 case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_UNSWAP_ALT_GUI:
452 if (record->event.pressed) {
453 // MAGIC actions (BOOTMAGIC without the boot)
454 if (!eeconfig_is_enabled()) {
455 eeconfig_init();
456 }
457 /* keymap config */
458 keymap_config.raw = eeconfig_read_keymap();
459 if (keycode == MAGIC_SWAP_CONTROL_CAPSLOCK) {
460 keymap_config.swap_control_capslock = 1;
461 } else if (keycode == MAGIC_CAPSLOCK_TO_CONTROL) {
462 keymap_config.capslock_to_control = 1;
463 } else if (keycode == MAGIC_SWAP_LALT_LGUI) {
464 keymap_config.swap_lalt_lgui = 1;
465 } else if (keycode == MAGIC_SWAP_RALT_RGUI) {
466 keymap_config.swap_ralt_rgui = 1;
467 } else if (keycode == MAGIC_NO_GUI) {
468 keymap_config.no_gui = 1;
469 } else if (keycode == MAGIC_SWAP_GRAVE_ESC) {
470 keymap_config.swap_grave_esc = 1;
471 } else if (keycode == MAGIC_SWAP_BACKSLASH_BACKSPACE) {
472 keymap_config.swap_backslash_backspace = 1;
473 } else if (keycode == MAGIC_HOST_NKRO) {
474 keymap_config.nkro = 1;
475 } else if (keycode == MAGIC_SWAP_ALT_GUI) {
476 keymap_config.swap_lalt_lgui = 1;
477 keymap_config.swap_ralt_rgui = 1;
478 }
479 /* UNs */
480 else if (keycode == MAGIC_UNSWAP_CONTROL_CAPSLOCK) {
481 keymap_config.swap_control_capslock = 0;
482 } else if (keycode == MAGIC_UNCAPSLOCK_TO_CONTROL) {
483 keymap_config.capslock_to_control = 0;
484 } else if (keycode == MAGIC_UNSWAP_LALT_LGUI) {
485 keymap_config.swap_lalt_lgui = 0;
486 } else if (keycode == MAGIC_UNSWAP_RALT_RGUI) {
487 keymap_config.swap_ralt_rgui = 0;
488 } else if (keycode == MAGIC_UNNO_GUI) {
489 keymap_config.no_gui = 0;
490 } else if (keycode == MAGIC_UNSWAP_GRAVE_ESC) {
491 keymap_config.swap_grave_esc = 0;
492 } else if (keycode == MAGIC_UNSWAP_BACKSLASH_BACKSPACE) {
493 keymap_config.swap_backslash_backspace = 0;
494 } else if (keycode == MAGIC_UNHOST_NKRO) {
495 keymap_config.nkro = 0;
496 } else if (keycode == MAGIC_UNSWAP_ALT_GUI) {
497 keymap_config.swap_lalt_lgui = 0;
498 keymap_config.swap_ralt_rgui = 0;
499 }
500 eeconfig_update_keymap(keymap_config.raw);
501 return false;
502 }
503 break;
446 case KC_LSPO: { 504 case KC_LSPO: {
447 if (record->event.pressed) { 505 if (record->event.pressed) {
448 shift_interrupted[0] = false; 506 shift_interrupted[0] = false;
449 register_mods(MOD_LSFT); 507 register_mods(MOD_LSFT);
450 } 508 }
451 else { 509 else {
452 if (!shift_interrupted[0]) { 510 if (!shift_interrupted[0]) {
453 register_code(LSPO_KEY); 511 register_code(LSPO_KEY);
454 unregister_code(LSPO_KEY); 512 unregister_code(LSPO_KEY);
455 } 513 }
456 unregister_mods(MOD_LSFT); 514 unregister_mods(MOD_LSFT);
457 } 515 }
458 return false; 516 return false;
459 break; 517 break;
460 } 518 }
461 519
462 case KC_RSPC: { 520 case KC_RSPC: {
463 if (record->event.pressed) { 521 if (record->event.pressed) {
464 shift_interrupted[1] = false; 522 shift_interrupted[1] = false;
465 register_mods(MOD_RSFT); 523 register_mods(MOD_RSFT);
466 } 524 }
467 else { 525 else {
468 if (!shift_interrupted[1]) { 526 if (!shift_interrupted[1]) {
469 register_code(RSPC_KEY); 527 register_code(RSPC_KEY);
470 unregister_code(RSPC_KEY); 528 unregister_code(RSPC_KEY);
471 } 529 }
472 unregister_mods(MOD_RSFT); 530 unregister_mods(MOD_RSFT);
473 } 531 }
474 return false; 532 return false;
475 break; 533 break;
476 } 534 }
477 default: { 535 default: {
478 shift_interrupted[0] = true; 536 shift_interrupted[0] = true;
479 shift_interrupted[1] = true; 537 shift_interrupted[1] = true;
480 break; 538 break;
481 } 539 }
482 } 540 }
483 541
484 return process_action_kb(record); 542 return process_action_kb(record);
@@ -586,6 +644,13 @@ void send_string(const char *str) {
586 } 644 }
587} 645}
588 646
647void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3) {
648 if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) {
649 layer_on(layer3);
650 } else {
651 layer_off(layer3);
652 }
653}
589 654
590void matrix_init_quantum() { 655void matrix_init_quantum() {
591 matrix_init_kb(); 656 matrix_init_kb();
diff --git a/quantum/quantum.h b/quantum/quantum.h
index 69277b9e3..e15003805 100644
--- a/quantum/quantum.h
+++ b/quantum/quantum.h
@@ -3,7 +3,7 @@
3 3
4#include <avr/pgmspace.h> 4#include <avr/pgmspace.h>
5#include "matrix.h" 5#include "matrix.h"
6#include "keymap_common.h" 6#include "keymap.h"
7#ifdef BACKLIGHT_ENABLE 7#ifdef BACKLIGHT_ENABLE
8 #include "backlight.h" 8 #include "backlight.h"
9#endif 9#endif
@@ -25,8 +25,8 @@
25#include <stddef.h> 25#include <stddef.h>
26#include <avr/io.h> 26#include <avr/io.h>
27#include <util/delay.h> 27#include <util/delay.h>
28 28#include "bootloader.h"
29#define SEND_STRING(str) send_string(PSTR(str)) 29#include "timer.h"
30 30
31extern uint32_t default_layer_state; 31extern uint32_t default_layer_state;
32 32
@@ -62,15 +62,20 @@ extern uint32_t default_layer_state;
62 #define LEADER_DICTIONARY() if (leading && timer_elapsed(leader_time) > LEADER_TIMEOUT) 62 #define LEADER_DICTIONARY() if (leading && timer_elapsed(leader_time) > LEADER_TIMEOUT)
63#endif 63#endif
64 64
65#define SEND_STRING(str) send_string(PSTR(str))
65void send_string(const char *str); 66void send_string(const char *str);
66 67
68// For tri-layer
69void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3);
70#define IS_LAYER_ON(layer) (layer_state & (1UL << (layer)))
71#define IS_LAYER_OFF(layer) (~layer_state & (1UL << (layer)))
72
67void matrix_init_kb(void); 73void matrix_init_kb(void);
68void matrix_scan_kb(void); 74void matrix_scan_kb(void);
69bool process_action_kb(keyrecord_t *record); 75bool process_action_kb(keyrecord_t *record);
70bool process_record_kb(uint16_t keycode, keyrecord_t *record); 76bool process_record_kb(uint16_t keycode, keyrecord_t *record);
71bool process_record_user(uint16_t keycode, keyrecord_t *record); 77bool process_record_user(uint16_t keycode, keyrecord_t *record);
72 78
73
74bool is_music_on(void); 79bool is_music_on(void);
75void music_toggle(void); 80void music_toggle(void);
76void music_on(void); 81void music_on(void);
diff --git a/quantum/template/template.h b/quantum/template/template.h
index 8537e3b4b..b8e7a0456 100644
--- a/quantum/template/template.h
+++ b/quantum/template/template.h
@@ -2,7 +2,7 @@
2#define %KEYBOARD_UPPERCASE%_H 2#define %KEYBOARD_UPPERCASE%_H
3 3
4#include "matrix.h" 4#include "matrix.h"
5#include "keymap_common.h" 5#include "keymap.h"
6#ifdef BACKLIGHT_ENABLE 6#ifdef BACKLIGHT_ENABLE
7 #include "backlight.h" 7 #include "backlight.h"
8#endif 8#endif