aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack Humbert <jack.humb@gmail.com>2017-02-07 13:18:47 -0500
committerGitHub <noreply@github.com>2017-02-07 13:18:47 -0500
commit3c7fa0acc10305a573bc3bb29243a7a3d601579b (patch)
tree49aa463e861b30c3fa0bd454679e1aefebcb7c9c
parent0c2b6951a6ad80649798c0eca36a9999ebae0b13 (diff)
parent77e54e34e129a03e58c128171a7188978ec908b4 (diff)
downloadqmk_firmware-3c7fa0acc10305a573bc3bb29243a7a3d601579b.tar.gz
qmk_firmware-3c7fa0acc10305a573bc3bb29243a7a3d601579b.zip
Merge pull request #1046 from LukeSilva/master
Add Tapping Macros to QMK
-rw-r--r--keyboards/planck/keymaps/luke/Makefile25
-rw-r--r--keyboards/planck/keymaps/luke/keymap.c355
-rw-r--r--keyboards/planck/keymaps/luke/readme.md2
-rw-r--r--quantum/keymap_common.c5
-rw-r--r--quantum/quantum_keycodes.h2
-rw-r--r--tmk_core/common/action_code.h10
-rw-r--r--tmk_core/common/action_macro.h26
7 files changed, 419 insertions, 6 deletions
diff --git a/keyboards/planck/keymaps/luke/Makefile b/keyboards/planck/keymaps/luke/Makefile
new file mode 100644
index 000000000..847686873
--- /dev/null
+++ b/keyboards/planck/keymaps/luke/Makefile
@@ -0,0 +1,25 @@
1
2
3# Build Options
4# change to "no" to disable the options, or define them in the Makefile in
5# the appropriate keymap folder that will get included automatically
6#
7BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000)
8MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
9EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
10CONSOLE_ENABLE = no # Console for debug(+400)
11COMMAND_ENABLE = no # Commands for debug and configuration
12NKRO_ENABLE = yes # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
13BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
14MIDI_ENABLE = no # MIDI controls
15AUDIO_ENABLE = no # Audio output on port C6
16UNICODE_ENABLE = yes # Unicode
17BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
18RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time.
19
20# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
21SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
22
23ifndef QUANTUM_DIR
24 include ../../../../Makefile
25endif
diff --git a/keyboards/planck/keymaps/luke/keymap.c b/keyboards/planck/keymaps/luke/keymap.c
new file mode 100644
index 000000000..26dcb451b
--- /dev/null
+++ b/keyboards/planck/keymaps/luke/keymap.c
@@ -0,0 +1,355 @@
1/*
2 * A keyboard layout for the gridded planck.
3 *
4 * Copyright (C) 2017 Luke Silva
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 *
20 * ,-----------------------------------------------------------------------------------.
21 * | | | | | | | | | | | | |
22 * |------+------+------+------+------+------+------+------+------+------+------+------|
23 * | | | | | | | | | | | | |
24 * |------+------+------+------+------+------+------+------+------+------+------+------|
25 * | | | | | | | | | | | | |
26 * |------+------+------+------+------+------+------+------+------+------+------+------|
27 * | | | | | | | | | | | | |
28 * `-----------------------------------------------------------------------------------'
29 *
30 * This layout uses colemak by default, and is designed for programming, with easy access to symbols
31 * through either double purpose modifiers or colemak style rolling for commonly used symbol clusters
32 * Eg: compare colemak 'this' to '(){\n}' on the symbol layer.
33 *
34 * The layout also supports a range of multilingual characters, covering those
35 * needed for French, German, Swedish and likely some other European Languages.
36 * In the future full support for Colemak's multilingual deadkeys may be introduced.
37 *
38 * The multilingual characters are inputted through QMK's unicode engine, using
39 * the Linux input method by default, however this can be changed at runtime.
40 *
41 */
42
43
44#include "planck.h"
45
46#define _______ KC_TRNS
47#define XXXXXXX KC_NO
48
49
50// Layers
51#define _COLEMAK 0
52#define _QWERTY 1
53#define _SYM 2
54#define _NUM 3
55#define _GR 4
56#define _GR_S 5
57#define _ADJ 6
58#define _NAV 7
59#define _PLOVER 8
60
61// Macro ID numbers
62#define M_ALT_HASH 1
63#define M_GR_DASH 2
64#define M_SYM_LPRN 3
65#define M_NAV_UNDS 4
66#define M_NUM_RPRN 5
67#define M_CTRL_DLR 6
68#define M_LCBR_ENT 7
69#define M_PLOVER 8
70#define M_EXT_PLV 9
71#define M_WINDOWS 10
72#define M_LINUX 11
73#define M_OSX 12
74#define M_FUNCTION 13
75#define M_THEN 14
76#define M_CATCH 15
77
78// Macro keys
79#define ALT_HASH MACROTAP(M_ALT_HASH) // tap for #, hold for Alt
80#define GR_DASH MACROTAP(M_GR_DASH) // tap for -, hold for GR layer a-class-name
81#define SYM_LPRN MACROTAP(M_SYM_LPRN) // tap for (, hold for symbols layer if()
82#define NAV_UNDS MACROTAP(M_NAV_UNDS) // tap for _, hold for navigation layer snake_case_variable
83#define NUM_RPRN MACROTAP(M_NUM_RPRN) // tap for ), hold for numbers layer else if()
84#define CTRL_DLR MACROTAP(M_CTRL_DLR) // tap for $, hold for ctrl $php_is_really_weird
85#define LCBR_ENT M(M_LCBR_ENT) // {\n easier code formatting
86#define PLOVER M(M_PLOVER) // PHROPB (plover) or ERFVIK(qwerty) starts plover
87#define EXT_PLV M(M_EXT_PLV) // PHRO*F (plover) or ERFVYU(qwerty) stops plover
88#define WINDOWS M(M_WINDOWS) // Sets Unicode handler to windows
89#define LINUX M(M_LINUX) // Sets Unicode handler to linux
90#define OSX M(M_OSX) // Sets Unicode handler to OSX
91#define FUNCTION M(M_FUNCTION)
92#define THEN M(M_THEN)
93#define CATCH M(M_CATCH)
94
95
96// Renames of QMK keys... (would have otherwise been a macro)
97#define QWERTY DF(_QWERTY)
98#define COLEMAK DF(_COLEMAK)
99
100
101
102
103
104const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
105
106/* Colemak
107 * ,-----------------------------------------------------------------------------------.
108 * | Tab | Q | W | F | P | G | J | L | U | Y | ;: | Bksp |
109 * |------+------+------+------+------+------+------+------+------+------+------+------|
110 * | Bksp | A | R | S | T | D | H | N | E | I | O | '" |
111 * |------+------+------+------+------+------+------+------+------+------+------+------`---.
112 * |Shift=| Z | X | C | V | B | K | M | ,< | .> | /? |Shift/Ent |
113 * |------+------+------+------+------+------+------+------+------+------+------+----------|
114 * |CtCaps|GUIF4 | Alt# | Gr- | Sym( | Nav_ |Space | Num) |Ctrl$ | F11 | F12 |Nav toggle|
115 * `---------------------------------------------------------------------------------------'
116 */
117
118[_COLEMAK] = {
119 {KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC},
120 {KC_BSPC, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT},
121 {SFT_T(KC_EQL), KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, SFT_T(KC_ENT) },
122 {CTL_T(KC_CAPS), KC_LGUI, ALT_HASH, GR_DASH, SYM_LPRN, NAV_UNDS, KC_SPC, NUM_RPRN, CTRL_DLR, KC_F11, KC_F12, TG(_NAV)}
123},
124
125
126
127/* QWERTY
128 * ,-----------------------------------------------------------------------------------.
129 * | Tab | Q | W | E | R | T | Y | U | I | O | P | Bksp |
130 * |------+------+------+------+------+------+------+------+------+------+------+------|
131 * | Bksp | A | S | D | F | G | H | J | K | L | ;: | '" |
132 * |------+------+------+------+------+------+------+------+------+------+------+------`---.
133 * |Shift=| Z | X | C | V | B | N | M | ,< | .> | /? |Shift/Ent |
134 * |------+------+------+------+------+------+------+------+------+------+------+----------|
135 * |CtCaps|GUIF4 | Alt# | Gr- | Sym( | Nav_ |Space | Num) |Ctrl$ | F11 | F12 |Nav toggle|
136 * `---------------------------------------------------------------------------------------'
137 */
138
139[_QWERTY] = {
140 {KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC},
141 {KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT},
142 {KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, SFT_T(KC_ENT) },
143 {CTL_T(KC_CAPS), KC_LGUI, KC_LALT, GR_DASH, SYM_LPRN,KC_SPC, KC_SPC, NUM_RPRN, KC_LEFT, KC_DOWN, KC_UP, KC_RIGHT}
144},
145
146
147/* Symbols
148 * ,-----------------------------------------------------------------------------------.
149 * | Tab | ` | @ | / | * | ^ | % | : | + | - | Del | Bksp |
150 * |------+------+------+------+------+------+------+------+------+------+------+------|
151 * | | [ | ; | } | ( | " | ' | ) | {\n | ! | ] | \ |
152 * |------+------+------+------+------+------+------+------+------+------+------+------|
153 * |Shift | . | { | < | > | ~ | X2 | = | & | | | ? |Enter |
154 * |------+------+------+------+------+------+------+------+------+------+------+------|
155 * | | | | | Sym | _ |Space | NUM | X2 | | | |
156 * `-----------------------------------------------------------------------------------'
157 */
158
159[_SYM] = {
160 {KC_TAB, KC_GRV, KC_AT, KC_SLSH, KC_ASTR, KC_CIRC, KC_PERC, KC_COLN, KC_PLUS, KC_MINS, KC_DEL, KC_BSPC},
161 {FUNCTION,KC_LBRC, KC_SCLN, KC_RCBR, KC_LPRN, KC_DQT, KC_QUOT, KC_RPRN, LCBR_ENT,KC_EXLM, KC_RBRC, KC_BSLS},
162 {KC_LSFT, KC_DOT, KC_LCBR, KC_LABK, KC_RABK, KC_TILD, _______, KC_EQL, KC_AMPR, KC_PIPE, KC_QUES, KC_ENT },
163 {THEN, CATCH, XXXXXXX, XXXXXXX, _______, _______, _______, _______, _______, XXXXXXX, XXXXXXX, _______}
164},
165
166
167/* Numbers
168 * ,-----------------------------------------------------------------------------------.
169 * | Tab | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp |
170 * |------+------+------+------+------+------+------+------+------+------+------+------|
171 * | Bksp | x | D | E | F | + | - | 4 | 5 | 6 | 0 |Enter |
172 * |------+------+------+------+------+------+------+------+------+------+------+------|
173 * |Shift | ( | A | B | C | * | / | 1 | 2 | 3 | ) |Enter |
174 * |------+------+------+------+------+------+------+------+------+------+------+------|
175 * | | | | GR | SYM | _ |Space | NUM | 0 | . | f | |
176 * `-----------------------------------------------------------------------------------'
177 */
178
179[_NUM] = {
180 {KC_TAB, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC},
181 {KC_BSPC, KC_X, S(KC_D), S(KC_E), S(KC_F), KC_PLUS, KC_MINS, KC_4, KC_5, KC_6, KC_0, KC_ENT },
182 {KC_LSFT, KC_LPRN, S(KC_A), S(KC_B), S(KC_C), KC_ASTR, KC_SLSH, KC_1, KC_2, KC_3, KC_RPRN, KC_ENT },
183 {_______, _______, _______, _______, _______, _______, _______, _______, KC_0, KC_DOT, KC_F, _______}
184},
185
186
187/* Gr layer / international keys
188 * ,-----------------------------------------------------------------------------------.
189 * | | ä | å | | ¢£ | €¥ | | ë | ê | ü | ù | |
190 * |------+------+------+------+------+------+------+------+------+------+------+------|
191 * | | â | à | ß | | | | è | é | ï | ö | |
192 * |------+------+------+------+------+------+------+------+------+------+------+------|
193 * | | æ | ô | ç | œ | | | û | « | » | î | |
194 * |------+------+------+------+------+------+------+------+------+------+------+------|
195 * | | | | | | | | | | | | |
196 * `-----------------------------------------------------------------------------------'
197 */
198
199[_GR] = {
200 {_______, UC(0xE4),UC(0xE5), _______,UC(0xA2), UC(0x20AC),_______,UC(0xEB),UC(0xEA),UC(0xFC),UC(0xF9), _______},
201 {_______, UC(0xE2),UC(0xE0),UC(0xDF), _______, _______, _______,UC(0xE8),UC(0xE9),UC(0xEF),UC(0xF6), _______},
202 {MO(_GR_S),UC(0xE6),UC(0xF4),UC(0xE7),UC(0x153),_______, _______,UC(0xFB),UC(0xAB),UC(0xBB),UC(0xEE), MO(_GR_S)},
203 {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______}
204},
205
206// Shifted layer of the above
207[_GR_S] = {
208 {_______, UC(0xC4),UC(0xC5), _______, UC(0xA3), UC(0xA5),_______, UC(0xCB),UC(0xCA),UC(0xDC),UC(0xD9),_______},
209 {_______, UC(0xC2),UC(0xC0), UC(0xDF),_______, _______, _______, UC(0xC8),UC(0xC9),UC(0xCF),UC(0xD6),_______},
210 {MO(_GR_S),UC(0xC6),UC(0xD4), UC(0xC7),UC(0x152),_______, _______, UC(0xDB),UC(0xAB),UC(0xBB),UC(0xCE),MO(_GR_S)},
211 {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______}
212},
213
214
215/* Adjust Layer (Gr + Num)
216 * ,-----------------------------------------------------------------------------------.
217 * | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 |
218 * |------+-------------+------+------+------+------+------+------+------+------+------|
219 * | | |Prntscr| ESC |VOLUP | PLAY | PREV |QWERTY|COLEMAK|PLOVER| | |
220 * |------+-------------+------+------+------+------+------+------+------+------+------|
221 * | | |BACKLIT| INS |VOLDWN| MUTE | NEXT | WIND |LINUX | OSX | | |
222 * |------+-------------+------+------+------+------+------+------+------+------+------|
223 * | | | | | | | | | | | | |
224 * `-----------------------------------------------------------------------------------'
225 */
226
227[_ADJ] = {
228 {KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12 },
229 {XXXXXXX, XXXXXXX, KC_PSCR, KC_ESC, KC_VOLU, KC_MPLY, KC_MPRV, QWERTY, COLEMAK, PLOVER, XXXXXXX, XXXXXXX},
230 {XXXXXXX, XXXXXXX, BL_STEP, KC_INS, KC_VOLD, KC_MUTE, KC_MNXT, WINDOWS, LINUX, OSX, XXXXXXX, XXXXXXX},
231 {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______}
232},
233
234
235/* Navigation
236 * ,-----------------------------------------------------------------------------------.
237 * | | | BTN3 | BTN2 | BTN1 | | ACL0 | HOME | PGDN | PGUP | END | Bksp |
238 * |------+------+------+------+------+------+------+------+------+------+------+------|
239 * | |MSLEFT| MSDN | MSUP |MSRGHT| | ACL1 | LEFT | DOWN | UP | RGHT |Enter |
240 * |------+------+------+------+------+------+------+------+------+------+------+------|
241 * | |WHLEFT| WHDN | WHUP |WHRGHT| | ACL2 |C-LEFT|C-PGDN|C-PGUP|C-RGHT|Enter |
242 * |------+------+------+------+------+------+------+------+------+------+------+------|
243 * | | | | | | _ |Space | ACL0 | ACL1 | ACL2 | |TGLNAV|
244 * `-----------------------------------------------------------------------------------'
245 */
246
247[_NAV] = {
248 {XXXXXXX, XXXXXXX, KC_BTN3, KC_BTN2, KC_BTN1, XXXXXXX, KC_ACL0, KC_HOME, KC_PGDN, KC_PGUP, KC_END, KC_BSPC},
249 {XXXXXXX, KC_MS_L, KC_MS_D, KC_MS_U, KC_MS_R, XXXXXXX, KC_ACL1, KC_LEFT, KC_DOWN, KC_UP, KC_RIGHT,KC_ENT },
250 {XXXXXXX, KC_WH_L, KC_WH_D, KC_WH_U, KC_WH_R, XXXXXXX, KC_ACL2, LCTL(KC_LEFT), LCTL(KC_PGDN), LCTL(KC_PGUP), LCTL(KC_RIGHT), KC_ENT },
251 {_______, _______, _______, _______, _______, _______, _______, KC_ACL0, KC_ACL1, KC_ACL2, _______, _______}
252},
253
254/* Plover Layer
255 * ,-----------------------------------------------------------------------------------.
256 * | | S | T | P | H | * | * | F | P | L | T | D |
257 * |------+------+------+------+------+------+------+------+------+------+------+------|
258 * |TogOut| S | K | W | R | * | * | R | B | G | S | Z |
259 * |------+------+------+------+------+------+------+------+------+------+------+------|
260 * | # | # | # | # | # | # | # | # | # | # | # | # |
261 * |------+------+------+------+------+------+------+------+------+------+------+------|
262 * | Exit | | | # | A | O | E | U | | | | |
263 * `-----------------------------------------------------------------------------------'
264 */
265
266[_PLOVER] = {
267 {XXXXXXX, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC},
268 {XXXXXXX, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT},
269 {KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1 },
270 {EXT_PLV, XXXXXXX, XXXXXXX, KC_1, KC_C, KC_V, KC_N, KC_M, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX}
271}
272
273
274};
275
276const uint16_t PROGMEM fn_actions[] = {
277};
278
279
280void matrix_init_user(){
281 set_unicode_input_mode(UC_LNX);
282}
283
284
285const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
286{
287 switch(id) {
288 case M_ALT_HASH:
289 return MACRO_TAP_SHFT_KEY_HOLD_MOD(record, 3, LALT);
290 case M_GR_DASH:
291 {
292 const macro_t* macro = MACRO_TAP_HOLD_LAYER(record, MACRO(T(MINS)), _GR);
293 update_tri_layer(_NUM, _GR, _ADJ);
294 return macro;
295 }
296 case M_SYM_LPRN:
297 return MACRO_TAP_SHFT_KEY_HOLD_LAYER(record, 9, _SYM);
298 case M_NAV_UNDS:
299 return MACRO_TAP_SHFT_KEY_HOLD_LAYER(record, MINS, _NAV);
300 case M_NUM_RPRN:
301 {
302 const macro_t* macro = MACRO_TAP_SHFT_KEY_HOLD_LAYER(record, 0, _NUM);
303 update_tri_layer(_NUM, _GR, _ADJ);
304 return macro;
305 }
306 case M_CTRL_DLR:
307 return MACRO_TAP_SHFT_KEY_HOLD_MOD(record, 4, LCTL);
308 case M_LCBR_ENT:
309 return MACRODOWN(I(10), D(LSFT), T(LBRC), U(LSFT), T(ENT), END);
310 case M_PLOVER:
311 if (record->event.pressed) {
312 layer_and(0);
313 layer_on(_PLOVER);
314 default_layer_set(_PLOVER);
315
316 // Starts plover
317 return MACRO(I(10), D(E), D(R), D(F), D(V), D(I), D(K), U(E), U(R), U(F), U(V), U(I), U(K), END);
318 }
319 break;
320 case M_EXT_PLV:
321 if (!record->event.pressed) {
322 layer_off(_PLOVER);
323 default_layer_set(_COLEMAK);
324
325 //Pauses plover
326 return MACRO(I(10), D(E), D(R), D(F), D(V), D(Y), D(U), U(E), U(R), U(F), U(V), U(Y), U(U), END);
327 }
328 break;
329 case M_WINDOWS:
330 set_unicode_input_mode(UC_WIN);
331 break;
332 case M_LINUX:
333 set_unicode_input_mode(UC_LNX);
334 break;
335 case M_OSX:
336 set_unicode_input_mode(UC_OSX);
337 break;
338 case M_FUNCTION:
339 if (record->event.pressed) {
340 SEND_STRING("function");
341 }
342 break;
343 case M_THEN:
344 if (record->event.pressed) {
345 SEND_STRING("then");
346 }
347 break;
348 case M_CATCH:
349 if (record->event.pressed) {
350 SEND_STRING("catch");
351 }
352 break;
353 }
354 return MACRO_NONE;
355};
diff --git a/keyboards/planck/keymaps/luke/readme.md b/keyboards/planck/keymaps/luke/readme.md
new file mode 100644
index 000000000..3a4824b5b
--- /dev/null
+++ b/keyboards/planck/keymaps/luke/readme.md
@@ -0,0 +1,2 @@
1# A more basic Planck Layout for copying
2
diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c
index eced3d2bb..5190f24e8 100644
--- a/quantum/keymap_common.c
+++ b/quantum/keymap_common.c
@@ -80,7 +80,10 @@ action_t action_for_key(uint8_t layer, keypos_t key)
80 action.code = keymap_function_id_to_action( (int)keycode & 0xFFF ); 80 action.code = keymap_function_id_to_action( (int)keycode & 0xFFF );
81 break; 81 break;
82 case QK_MACRO ... QK_MACRO_MAX: 82 case QK_MACRO ... QK_MACRO_MAX:
83 action.code = ACTION_MACRO(keycode & 0xFF); 83 if (keycode & 0x800) // tap macros have upper bit set
84 action.code = ACTION_MACRO_TAP(keycode & 0xFF);
85 else
86 action.code = ACTION_MACRO(keycode & 0xFF);
84 break; 87 break;
85 case QK_LAYER_TAP ... QK_LAYER_TAP_MAX: 88 case QK_LAYER_TAP ... QK_LAYER_TAP_MAX:
86 action.code = ACTION_LAYER_TAP_KEY((keycode >> 0x8) & 0xF, keycode & 0xFF); 89 action.code = ACTION_LAYER_TAP_KEY((keycode >> 0x8) & 0xF, keycode & 0xFF);
diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h
index a786bd322..8a78a58c9 100644
--- a/quantum/quantum_keycodes.h
+++ b/quantum/quantum_keycodes.h
@@ -256,8 +256,10 @@ enum quantum_keycodes {
256 256
257#define M(kc) (kc | QK_MACRO) 257#define M(kc) (kc | QK_MACRO)
258 258
259#define MACROTAP(kc) (kc | QK_MACRO | FUNC_TAP<<8)
259#define MACRODOWN(...) (record->event.pressed ? MACRO(__VA_ARGS__) : MACRO_NONE) 260#define MACRODOWN(...) (record->event.pressed ? MACRO(__VA_ARGS__) : MACRO_NONE)
260 261
262
261// L-ayer, T-ap - 256 keycode max, 16 layer max 263// L-ayer, T-ap - 256 keycode max, 16 layer max
262#define LT(layer, kc) (kc | QK_LAYER_TAP | ((layer & 0xF) << 8)) 264#define LT(layer, kc) (kc | QK_LAYER_TAP | ((layer & 0xF) << 8))
263 265
diff --git a/tmk_core/common/action_code.h b/tmk_core/common/action_code.h
index 33da35f35..b15aaa0eb 100644
--- a/tmk_core/common/action_code.h
+++ b/tmk_core/common/action_code.h
@@ -47,10 +47,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
47 * 0100|10| usage(10) (reserved) 47 * 0100|10| usage(10) (reserved)
48 * 0100|11| usage(10) (reserved) 48 * 0100|11| usage(10) (reserved)
49 * 49 *
50 * ACT_MOUSEKEY(0110): TODO: Not needed? 50 *
51 * ACT_MOUSEKEY(0101): TODO: Merge these two actions to conserve space?
51 * 0101|xxxx| keycode Mouse key 52 * 0101|xxxx| keycode Mouse key
52 * 53 *
53 * 011x|xxxx xxxx xxxx (reseved) 54 * ACT_SWAP_HANDS(0110):
55 * 0110|xxxx| keycode Swap hands (keycode on tap, or options)
56 *
57 *
58 * 0111|xxxx xxxx xxxx (reserved)
54 * 59 *
55 * 60 *
56 * Layer Actions(10xx) 61 * Layer Actions(10xx)
@@ -67,7 +72,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
67 * ee: on event(01:press, 10:release, 11:both) 72 * ee: on event(01:press, 10:release, 11:both)
68 * 73 *
69 * 1001|xxxx|xxxx xxxx (reserved) 74 * 1001|xxxx|xxxx xxxx (reserved)
70 * 1001|oopp|BBBB BBBB 8-bit Bitwise Operation???
71 * 75 *
72 * ACT_LAYER_TAP(101x): 76 * ACT_LAYER_TAP(101x):
73 * 101E|LLLL| keycode On/Off with tap key (0x00-DF)[TAP] 77 * 101E|LLLL| keycode On/Off with tap key (0x00-DF)[TAP]
diff --git a/tmk_core/common/action_macro.h b/tmk_core/common/action_macro.h
index aedc32ec6..f373f5068 100644
--- a/tmk_core/common/action_macro.h
+++ b/tmk_core/common/action_macro.h
@@ -20,11 +20,33 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
20#include "progmem.h" 20#include "progmem.h"
21 21
22 22
23#define MACRO_NONE 0 23
24typedef uint8_t macro_t;
25
26#define MACRO_NONE (macro_t*)0
24#define MACRO(...) ({ static const macro_t __m[] PROGMEM = { __VA_ARGS__ }; &__m[0]; }) 27#define MACRO(...) ({ static const macro_t __m[] PROGMEM = { __VA_ARGS__ }; &__m[0]; })
25#define MACRO_GET(p) pgm_read_byte(p) 28#define MACRO_GET(p) pgm_read_byte(p)
26 29
27typedef uint8_t macro_t; 30// Sends press when the macro key is pressed, release when release, or tap_macro when the key has been tapped
31#define MACRO_TAP_HOLD(record, press, release, tap_macro) ( ((record)->event.pressed) ? \
32 ( ((record)->tap.count <= 0 || (record)->tap.interrupted) ? (press) : MACRO_NONE ) : \
33 ( ((record)->tap.count > 0 && !((record)->tap.interrupted)) ? (tap_macro) : (release) ) )
34
35// Holds down the modifier mod when the macro key is held, or sends macro instead when tapped
36#define MACRO_TAP_HOLD_MOD(record, macro, mod) MACRO_TAP_HOLD(record, (MACRO(D(mod), END)), MACRO(U(mod), END), macro)
37
38// Holds down the modifier mod when the macro key is held, or pressed a shifted key when tapped (eg: shift+3 for #)
39#define MACRO_TAP_SHFT_KEY_HOLD_MOD(record, key, mod) MACRO_TAP_HOLD_MOD(record, (MACRO(I(10), D(LSFT), T(key), U(LSFT), END)), mod)
40
41
42// Momentary switch layer when held, sends macro if tapped
43#define MACRO_TAP_HOLD_LAYER(record, macro, layer) ( ((record)->event.pressed) ? \
44 ( ((record)->tap.count <= 0 || (record)->tap.interrupted) ? ({layer_on((layer)); MACRO_NONE; }) : MACRO_NONE ) : \
45 ( ((record)->tap.count > 0 && !((record)->tap.interrupted)) ? (macro) : ({layer_off((layer)); MACRO_NONE; }) ) )
46
47// Momentary switch layer when held, presses a shifted key when tapped (eg: shift+3 for #)
48#define MACRO_TAP_SHFT_KEY_HOLD_LAYER(record, key, layer) MACRO_TAP_HOLD_LAYER(record, MACRO(I(10), D(LSFT), T(key), U(LSFT), END), layer)
49
28 50
29 51
30#ifndef NO_ACTION_MACRO 52#ifndef NO_ACTION_MACRO