aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErez Zukerman <bulk@ezuk.org>2016-05-15 00:27:32 -0400
committerJack Humbert <jack.humb@gmail.com>2016-05-15 00:27:32 -0400
commit1a8c0dd22d6a2255511d0db6a456315541b5815b (patch)
tree6c7d5e9dc66f9ce864cfe87a72dfb47e6f06d3a7
parent79d26f331a275c99f76a30d34752fbd65bb3f335 (diff)
downloadqmk_firmware-1a8c0dd22d6a2255511d0db6a456315541b5815b.tar.gz
qmk_firmware-1a8c0dd22d6a2255511d0db6a456315541b5815b.zip
Leader key implementation (#326)
* implements leader key for planck experimental * allows override of leader timeout * adds ability to use the leader key in seq * fixes leader keycode * adds chording prototype * fixes keycode detection * moves music mode to quantum.c * disables chording by default * updates process_action functions to return bool
-rw-r--r--keyboard/atomic/atomic.c7
-rw-r--r--keyboard/atomic/atomic.h2
-rw-r--r--keyboard/gh60_rev_c/gh60.c7
-rw-r--r--keyboard/gh60_rev_c/gh60.h2
-rw-r--r--keyboard/planck/keymaps/experimental/keymap.c48
-rw-r--r--keyboard/planck/planck.c8
-rw-r--r--keyboard/planck/planck.h16
-rw-r--r--keyboard/preonic/preonic.c8
-rw-r--r--keyboard/preonic/preonic.h2
-rw-r--r--quantum/keymap_common.c2
-rw-r--r--quantum/keymap_common.h4
-rw-r--r--quantum/matrix.c8
-rw-r--r--quantum/quantum.c167
-rw-r--r--quantum/quantum.h48
-rw-r--r--quantum/quantum.mk3
-rw-r--r--quantum/template/template.c7
-rw-r--r--quantum/template/template.h2
-rw-r--r--tmk_core/common/action.c7
-rw-r--r--tmk_core/common/action.h2
-rw-r--r--tmk_core/common/matrix.h4
20 files changed, 290 insertions, 64 deletions
diff --git a/keyboard/atomic/atomic.c b/keyboard/atomic/atomic.c
index b4b261457..fa218a48f 100644
--- a/keyboard/atomic/atomic.c
+++ b/keyboard/atomic/atomic.c
@@ -11,8 +11,9 @@ void matrix_scan_user(void) {
11} 11}
12 12
13__attribute__ ((weak)) 13__attribute__ ((weak))
14void process_action_user(keyrecord_t *record) { 14bool process_action_user(keyrecord_t *record) {
15 // leave this function blank - it can be defined in a keymap file 15 // leave this function blank - it can be defined in a keymap file
16 return true;
16} 17}
17 18
18__attribute__ ((weak)) 19__attribute__ ((weak))
@@ -45,11 +46,11 @@ void matrix_scan_kb(void) {
45 matrix_scan_user(); 46 matrix_scan_user();
46} 47}
47 48
48void process_action_kb(keyrecord_t *record) { 49bool process_action_kb(keyrecord_t *record) {
49 // put your per-action keyboard code here 50 // put your per-action keyboard code here
50 // runs for every action, just before processing by the firmware 51 // runs for every action, just before processing by the firmware
51 52
52 process_action_user(record); 53 return process_action_user(record);
53} 54}
54 55
55void led_set_kb(uint8_t usb_led) { 56void led_set_kb(uint8_t usb_led) {
diff --git a/keyboard/atomic/atomic.h b/keyboard/atomic/atomic.h
index 845a9043e..2d6b4c6cb 100644
--- a/keyboard/atomic/atomic.h
+++ b/keyboard/atomic/atomic.h
@@ -29,7 +29,7 @@
29 29
30void matrix_init_user(void); 30void matrix_init_user(void);
31void matrix_scan_user(void); 31void matrix_scan_user(void);
32void process_action_user(keyrecord_t *record); 32bool process_action_user(keyrecord_t *record);
33void led_set_user(uint8_t usb_led); 33void led_set_user(uint8_t usb_led);
34void backlight_init_ports(void); 34void backlight_init_ports(void);
35 35
diff --git a/keyboard/gh60_rev_c/gh60.c b/keyboard/gh60_rev_c/gh60.c
index 8e7219bfe..6da4d8ee3 100644
--- a/keyboard/gh60_rev_c/gh60.c
+++ b/keyboard/gh60_rev_c/gh60.c
@@ -12,8 +12,9 @@ void matrix_scan_user(void) {
12} 12}
13 13
14__attribute__ ((weak)) 14__attribute__ ((weak))
15void process_action_user(keyrecord_t *record) { 15bool process_action_user(keyrecord_t *record) {
16 // leave this function blank - it can be defined in a keymap file 16 // leave this function blank - it can be defined in a keymap file
17 return true;
17} 18}
18 19
19__attribute__ ((weak)) 20__attribute__ ((weak))
@@ -35,11 +36,11 @@ void matrix_scan_kb(void) {
35 matrix_scan_user(); 36 matrix_scan_user();
36} 37}
37 38
38void process_action_kb(keyrecord_t *record) { 39bool process_action_kb(keyrecord_t *record) {
39 // put your per-action keyboard code here 40 // put your per-action keyboard code here
40 // runs for every action, just before processing by the firmware 41 // runs for every action, just before processing by the firmware
41 42
42 process_action_user(record); 43 return process_action_user(record);
43} 44}
44 45
45void led_set_kb(uint8_t usb_led) { 46void led_set_kb(uint8_t usb_led) {
diff --git a/keyboard/gh60_rev_c/gh60.h b/keyboard/gh60_rev_c/gh60.h
index 2373ad333..95e5e1ebc 100644
--- a/keyboard/gh60_rev_c/gh60.h
+++ b/keyboard/gh60_rev_c/gh60.h
@@ -75,7 +75,7 @@ inline void gh60_wasd_leds_off(void) { DDRF &= ~(1<<7); PORTF &= ~(1<<7); }
75 75
76void matrix_init_user(void); 76void matrix_init_user(void);
77void matrix_scan_user(void); 77void matrix_scan_user(void);
78void process_action_user(keyrecord_t *record); 78bool process_action_user(keyrecord_t *record);
79void led_set_user(uint8_t usb_led); 79void led_set_user(uint8_t usb_led);
80 80
81#endif 81#endif
diff --git a/keyboard/planck/keymaps/experimental/keymap.c b/keyboard/planck/keymaps/experimental/keymap.c
index fc3ac4a97..8dc158c73 100644
--- a/keyboard/planck/keymaps/experimental/keymap.c
+++ b/keyboard/planck/keymaps/experimental/keymap.c
@@ -6,6 +6,7 @@
6#ifdef AUDIO_ENABLE 6#ifdef AUDIO_ENABLE
7 #include "audio.h" 7 #include "audio.h"
8#endif 8#endif
9
9#include "eeconfig.h" 10#include "eeconfig.h"
10 11
11extern keymap_config_t keymap_config; 12extern keymap_config_t keymap_config;
@@ -78,7 +79,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
78 {KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC}, 79 {KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC},
79 {KC_ESC, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT}, 80 {KC_ESC, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT},
80 {KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT }, 81 {KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT },
81 {M(M_BL), KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT} 82 {KC_LEAD, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT}
82}, 83},
83 84
84/* Dvorak 85/* Dvorak
@@ -291,7 +292,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
291 case 8: 292 case 8:
292 if (record->event.pressed) { 293 if (record->event.pressed) {
293 #ifdef AUDIO_ENABLE 294 #ifdef AUDIO_ENABLE
294 layer_off(_MUSIC); 295 music_activated = false;
295 stop_all_notes(); 296 stop_all_notes();
296 #endif 297 #endif
297 } 298 }
@@ -300,7 +301,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
300 if (record->event.pressed) { 301 if (record->event.pressed) {
301 #ifdef AUDIO_ENABLE 302 #ifdef AUDIO_ENABLE
302 PLAY_NOTE_ARRAY(music_scale, false, 0); 303 PLAY_NOTE_ARRAY(music_scale, false, 0);
303 layer_on(_MUSIC); 304 music_activated = true;
304 #endif 305 #endif
305 } 306 }
306 break; 307 break;
@@ -360,24 +361,35 @@ void matrix_init_user(void) {
360} 361}
361 362
362#ifdef AUDIO_ENABLE 363#ifdef AUDIO_ENABLE
363void play_goodbye_tone() 364 void play_goodbye_tone(void)
364{ 365 {
365 PLAY_NOTE_ARRAY(goodbye, false, 0); 366 PLAY_NOTE_ARRAY(goodbye, false, 0);
366 _delay_ms(150); 367 _delay_ms(150);
367} 368 }
369#endif
368 370
369uint8_t starting_note = 0x0C; 371LEADER_EXTERNS();
370int offset = 0;
371 372
372void process_action_user(keyrecord_t *record) { 373#define LEADER_TIMEOUT 300
373 374
374 if (IS_LAYER_ON(_MUSIC)) { 375void matrix_scan_user(void) {
375 if (record->event.pressed) { 376 LEADER_DICTIONARY() {
376 play_note(((double)220.0)*pow(2.0, -4.0)*pow(2.0,(starting_note + SCALE[record->event.key.col + offset])/12.0+(MATRIX_ROWS - record->event.key.row)), 0xF); 377 leading = false;
377 } else { 378 leader_end();
378 stop_note(((double)220.0)*pow(2.0, -4.0)*pow(2.0,(starting_note + SCALE[record->event.key.col + offset])/12.0+(MATRIX_ROWS - record->event.key.row))); 379
380 SEQ_ONE_KEY(KC_F) {
381 register_code(KC_S);
382 unregister_code(KC_S);
383 }
384 SEQ_TWO_KEYS(KC_A, KC_S) {
385 register_code(KC_H);
386 unregister_code(KC_H);
387 }
388 SEQ_THREE_KEYS(KC_A, KC_S, KC_D) {
389 register_code(KC_LGUI);
390 register_code(KC_S);
391 unregister_code(KC_S);
392 unregister_code(KC_LGUI);
379 } 393 }
380 } 394 }
381
382} 395}
383#endif
diff --git a/keyboard/planck/planck.c b/keyboard/planck/planck.c
index 446353dbf..da7b3a170 100644
--- a/keyboard/planck/planck.c
+++ b/keyboard/planck/planck.c
@@ -7,7 +7,9 @@ __attribute__ ((weak))
7void matrix_scan_user(void) {} 7void matrix_scan_user(void) {}
8 8
9__attribute__ ((weak)) 9__attribute__ ((weak))
10void process_action_user(keyrecord_t *record) {} 10bool process_action_user(keyrecord_t *record) {
11 return true;
12}
11 13
12__attribute__ ((weak)) 14__attribute__ ((weak))
13void led_set_user(uint8_t usb_led) {} 15void led_set_user(uint8_t usb_led) {}
@@ -32,8 +34,8 @@ void matrix_scan_kb(void) {
32 matrix_scan_user(); 34 matrix_scan_user();
33} 35}
34 36
35void process_action_kb(keyrecord_t *record) { 37bool process_action_kb(keyrecord_t *record) {
36 process_action_user(record); 38 return process_action_user(record);
37} 39}
38 40
39void led_set_kb(uint8_t usb_led) { 41void led_set_kb(uint8_t usb_led) {
diff --git a/keyboard/planck/planck.h b/keyboard/planck/planck.h
index cfd4956bf..8aec6b262 100644
--- a/keyboard/planck/planck.h
+++ b/keyboard/planck/planck.h
@@ -1,19 +1,7 @@
1#ifndef PLANCK_H 1#ifndef PLANCK_H
2#define PLANCK_H 2#define PLANCK_H
3 3
4#include "matrix.h" 4#include "quantum.h"
5#include "keymap_common.h"
6#ifdef BACKLIGHT_ENABLE
7 #include "backlight.h"
8#endif
9#ifdef RGBLIGHT_ENABLE
10 #include "rgblight.h"
11#endif
12#include <stddef.h>
13#include <avr/io.h>
14#ifdef MIDI_ENABLE
15 #include <keymap_midi.h>
16#endif
17 5
18#define PLANCK_MIT( \ 6#define PLANCK_MIT( \
19 k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0a, k0b, \ 7 k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0a, k0b, \
@@ -43,7 +31,7 @@
43 31
44void matrix_init_user(void); 32void matrix_init_user(void);
45void matrix_scan_user(void); 33void matrix_scan_user(void);
46void process_action_user(keyrecord_t *record); 34bool process_action_user(keyrecord_t *record);
47 35
48void led_set_user(uint8_t usb_led); 36void led_set_user(uint8_t usb_led);
49void backlight_init_ports(void); 37void backlight_init_ports(void);
diff --git a/keyboard/preonic/preonic.c b/keyboard/preonic/preonic.c
index 211f8d029..13e05c65a 100644
--- a/keyboard/preonic/preonic.c
+++ b/keyboard/preonic/preonic.c
@@ -11,8 +11,8 @@ void matrix_scan_user(void) {
11}; 11};
12 12
13__attribute__ ((weak)) 13__attribute__ ((weak))
14void process_action_user(keyrecord_t *record) { 14bool process_action_user(keyrecord_t *record) {
15 15 return true;
16}; 16};
17 17
18void matrix_init_kb(void) { 18void matrix_init_kb(void) {
@@ -36,8 +36,8 @@ void matrix_scan_kb(void) {
36 matrix_scan_user(); 36 matrix_scan_user();
37}; 37};
38 38
39void process_action_kb(keyrecord_t *record) { 39bool process_action_kb(keyrecord_t *record) {
40 process_action_user(record); 40 return process_action_user(record);
41} 41}
42 42
43#ifdef BACKLIGHT_ENABLE 43#ifdef BACKLIGHT_ENABLE
diff --git a/keyboard/preonic/preonic.h b/keyboard/preonic/preonic.h
index 030acdadb..2406a11d7 100644
--- a/keyboard/preonic/preonic.h
+++ b/keyboard/preonic/preonic.h
@@ -47,6 +47,6 @@
47 47
48void matrix_init_user(void); 48void matrix_init_user(void);
49void matrix_scan_user(void); 49void matrix_scan_user(void);
50void process_action_kb(keyrecord_t *record); 50bool process_action_kb(keyrecord_t *record);
51 51
52#endif 52#endif
diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c
index 8f00f9cc3..0184770c4 100644
--- a/quantum/keymap_common.c
+++ b/quantum/keymap_common.c
@@ -251,7 +251,7 @@ static action_t keycode_to_action(uint16_t keycode)
251 } 251 }
252 eeconfig_update_keymap(keymap_config.raw); 252 eeconfig_update_keymap(keymap_config.raw);
253 break; 253 break;
254 case 0x5100 ... 0x5FFF: ; 254 case 0x5100 ... 0x56FF: ;
255 // Layer movement shortcuts 255 // Layer movement shortcuts
256 // See .h to see constraints/usage 256 // See .h to see constraints/usage
257 int type = (keycode >> 0x8) & 0xF; 257 int type = (keycode >> 0x8) & 0xF;
diff --git a/quantum/keymap_common.h b/quantum/keymap_common.h
index 322fda498..2ad1ba6c6 100644
--- a/quantum/keymap_common.h
+++ b/quantum/keymap_common.h
@@ -159,7 +159,7 @@ extern const uint16_t fn_actions[];
159#define S(kc) LSFT(kc) 159#define S(kc) LSFT(kc)
160#define F(kc) FUNC(kc) 160#define F(kc) FUNC(kc)
161 161
162#define M(kc) kc | 0x3000 162#define M(kc) (kc | 0x3000)
163 163
164#define MACRODOWN(...) (record->event.pressed ? MACRO(__VA_ARGS__) : MACRO_NONE) 164#define MACRODOWN(...) (record->event.pressed ? MACRO(__VA_ARGS__) : MACRO_NONE)
165 165
@@ -191,6 +191,8 @@ extern const uint16_t fn_actions[];
191 191
192#define RESET 0x5000 192#define RESET 0x5000
193#define DEBUG 0x5001 193#define DEBUG 0x5001
194#define KC_LEAD 0x5014
195
194 196
195// MAGIC keycodes 197// MAGIC keycodes
196#define MAGIC_SWAP_CONTROL_CAPSLOCK 0x5002 198#define MAGIC_SWAP_CONTROL_CAPSLOCK 0x5002
diff --git a/quantum/matrix.c b/quantum/matrix.c
index 7d70f728d..cab39e117 100644
--- a/quantum/matrix.c
+++ b/quantum/matrix.c
@@ -55,12 +55,12 @@ static void unselect_rows(void);
55static void select_row(uint8_t row); 55static void select_row(uint8_t row);
56 56
57__attribute__ ((weak)) 57__attribute__ ((weak))
58void matrix_init_kb(void) { 58void matrix_init_quantum(void) {
59 59
60} 60}
61 61
62__attribute__ ((weak)) 62__attribute__ ((weak))
63void matrix_scan_kb(void) { 63void matrix_scan_quantum(void) {
64 64
65} 65}
66 66
@@ -93,7 +93,7 @@ void matrix_init(void)
93 matrix_debouncing[i] = 0; 93 matrix_debouncing[i] = 0;
94 } 94 }
95 95
96 matrix_init_kb(); 96 matrix_init_quantum();
97} 97}
98 98
99 99
@@ -157,7 +157,7 @@ uint8_t matrix_scan(void)
157 } 157 }
158#endif 158#endif
159 159
160 matrix_scan_kb(); 160 matrix_scan_quantum();
161 161
162 return 1; 162 return 1;
163} 163}
diff --git a/quantum/quantum.c b/quantum/quantum.c
new file mode 100644
index 000000000..e274d846f
--- /dev/null
+++ b/quantum/quantum.c
@@ -0,0 +1,167 @@
1#include "quantum.h"
2
3__attribute__ ((weak))
4void matrix_init_kb(void) {}
5
6__attribute__ ((weak))
7void matrix_scan_kb(void) {}
8
9__attribute__ ((weak))
10bool process_action_kb(keyrecord_t *record) {
11 return true;
12}
13
14__attribute__ ((weak))
15void leader_start(void) {}
16
17__attribute__ ((weak))
18void leader_end(void) {}
19
20#ifdef AUDIO_ENABLE
21 uint8_t starting_note = 0x0C;
22 int offset = 0;
23 bool music_activated = false;
24#endif
25
26// Leader key stuff
27bool leading = false;
28uint16_t leader_time = 0;
29
30uint16_t leader_sequence[3] = {0, 0, 0};
31uint8_t leader_sequence_size = 0;
32
33// Chording stuff
34#define CHORDING_MAX 4
35bool chording = false;
36
37uint8_t chord_keys[CHORDING_MAX] = {0};
38uint8_t chord_key_count = 0;
39uint8_t chord_key_down = 0;
40
41bool keys_chord(uint8_t keys[]) {
42 uint8_t keys_size = sizeof(keys)/sizeof(keys[0]);
43 bool pass = true;
44 uint8_t in = 0;
45 for (uint8_t i = 0; i < chord_key_count; i++) {
46 bool found = false;
47 for (uint8_t j = 0; j < keys_size; j++) {
48 if (chord_keys[i] == (keys[j] & 0xFF)) {
49 in++; // detects key in chord
50 found = true;
51 break;
52 }
53 }
54 if (found)
55 continue;
56 if (chord_keys[i] != 0) {
57 pass = false; // makes sure rest are blank
58 }
59 }
60 return (pass && (in == keys_size));
61}
62
63bool process_action_quantum(keyrecord_t *record) {
64
65 /* This gets the keycode from the key pressed */
66 keypos_t key = record->event.key;
67 uint16_t keycode;
68
69 #if !defined(NO_ACTION_LAYER) && defined(PREVENT_STUCK_MODIFIERS)
70 uint8_t layer;
71
72 if (record->event.pressed) {
73 layer = layer_switch_get_layer(key);
74 update_source_layers_cache(key, layer);
75 } else {
76 layer = read_source_layers_cache(key);
77 }
78 keycode = keymap_key_to_keycode(layer, key);
79 #else
80 keycode = keymap_key_to_keycode(layer_switch_get_layer(key), key);
81 #endif
82
83 #ifdef AUDIO_ENABLE
84 if (music_activated) {
85 if (record->event.pressed) {
86 play_note(((double)220.0)*pow(2.0, -4.0)*pow(2.0,(starting_note + SCALE[record->event.key.col + offset])/12.0+(MATRIX_ROWS - record->event.key.row)), 0xF);
87 } else {
88 stop_note(((double)220.0)*pow(2.0, -4.0)*pow(2.0,(starting_note + SCALE[record->event.key.col + offset])/12.0+(MATRIX_ROWS - record->event.key.row)));
89 }
90 if (keycode < 0xFF) // ignores all normal keycodes, but lets RAISE, LOWER, etc through
91 return false;
92 }
93 #endif
94
95
96
97#ifndef DISABLE_LEADER
98 // Leader key set-up
99 if (record->event.pressed) {
100 if (!leading && keycode == KC_LEAD) {
101 leader_start();
102 leading = true;
103 leader_time = timer_read();
104 leader_sequence_size = 0;
105 leader_sequence[0] = 0;
106 leader_sequence[1] = 0;
107 leader_sequence[2] = 0;
108 return false;
109 }
110 if (leading && timer_elapsed(leader_time) < LEADER_TIMEOUT) {
111 leader_sequence[leader_sequence_size] = keycode;
112 leader_sequence_size++;
113 return false;
114 }
115 }
116#endif
117
118#define DISABLE_CHORDING
119#ifndef DISABLE_CHORDING
120
121 if (keycode >= 0x5700 && keycode <= 0x57FF) {
122 if (record->event.pressed) {
123 if (!chording) {
124 chording = true;
125 for (uint8_t i = 0; i < CHORDING_MAX; i++)
126 chord_keys[i] = 0;
127 chord_key_count = 0;
128 chord_key_down = 0;
129 }
130 chord_keys[chord_key_count] = (keycode & 0xFF);
131 chord_key_count++;
132 chord_key_down++;
133 return false;
134 } else {
135 if (chording) {
136 chord_key_down--;
137 if (chord_key_down == 0) {
138 chording = false;
139 // Chord Dictionary
140 if (keys_chord((uint8_t[]){KC_ENTER, KC_SPACE})) {
141 register_code(KC_A);
142 unregister_code(KC_A);
143 return false;
144 }
145 for (uint8_t i = 0; i < chord_key_count; i++) {
146 register_code(chord_keys[i]);
147 unregister_code(chord_keys[i]);
148 return false;
149 }
150 }
151 }
152 }
153 }
154
155#endif
156
157
158 return process_action_kb(record);
159}
160
161void matrix_init_quantum() {
162 matrix_init_kb();
163}
164
165void matrix_scan_quantum() {
166 matrix_scan_kb();
167} \ No newline at end of file
diff --git a/quantum/quantum.h b/quantum/quantum.h
new file mode 100644
index 000000000..db726ad42
--- /dev/null
+++ b/quantum/quantum.h
@@ -0,0 +1,48 @@
1#ifndef QUANTUM_H
2#define QUANTUM_H
3
4#include "matrix.h"
5#include "keymap_common.h"
6#ifdef BACKLIGHT_ENABLE
7 #include "backlight.h"
8#endif
9#ifdef RGBLIGHT_ENABLE
10 #include "rgblight.h"
11#endif
12#ifdef AUDIO_ENABLE
13 #include "audio.h"
14#endif
15#ifdef MIDI_ENABLE
16 #include <keymap_midi.h>
17#endif
18#include "action_layer.h"
19#include "eeconfig.h"
20#include <stddef.h>
21#include <avr/io.h>
22
23extern uint32_t default_layer_state;
24
25#ifndef NO_ACTION_LAYER
26 extern uint32_t layer_state;
27#endif
28
29bool music_activated;
30
31void matrix_init_kb(void);
32void matrix_scan_kb(void);
33bool process_action_kb(keyrecord_t *record);
34
35void leader_start(void);
36void leader_end(void);
37
38#ifndef LEADER_TIMEOUT
39 #define LEADER_TIMEOUT 200
40#endif
41#define SEQ_ONE_KEY(key) if (leader_sequence[0] == (key) && leader_sequence[1] == 0 && leader_sequence[2] == 0)
42#define SEQ_TWO_KEYS(key1, key2) if (leader_sequence[0] == (key1) && leader_sequence[1] == (key2) && leader_sequence[2] == 0)
43#define SEQ_THREE_KEYS(key1, key2, key3) if (leader_sequence[0] == (key1) && leader_sequence[1] == (key2) && leader_sequence[2] == (key3))
44
45#define LEADER_EXTERNS() extern bool leading; extern uint16_t leader_time; extern uint16_t leader_sequence[3]; extern uint8_t leader_sequence_size
46#define LEADER_DICTIONARY() if (leading && timer_elapsed(leader_time) > LEADER_TIMEOUT)
47
48#endif \ No newline at end of file
diff --git a/quantum/quantum.mk b/quantum/quantum.mk
index 5f4c2f045..b45ad850a 100644
--- a/quantum/quantum.mk
+++ b/quantum/quantum.mk
@@ -1,7 +1,8 @@
1QUANTUM_DIR = quantum 1QUANTUM_DIR = quantum
2 2
3# # project specific files 3# # project specific files
4SRC += $(QUANTUM_DIR)/keymap_common.c \ 4SRC += $(QUANTUM_DIR)/quantum.c \
5 $(QUANTUM_DIR)/keymap_common.c \
5 $(QUANTUM_DIR)/led.c 6 $(QUANTUM_DIR)/led.c
6 7
7# ifdef KEYMAP_FILE 8# ifdef KEYMAP_FILE
diff --git a/quantum/template/template.c b/quantum/template/template.c
index 6050a2d20..649072eb2 100644
--- a/quantum/template/template.c
+++ b/quantum/template/template.c
@@ -11,8 +11,9 @@ void matrix_scan_user(void) {
11} 11}
12 12
13__attribute__ ((weak)) 13__attribute__ ((weak))
14void process_action_user(keyrecord_t *record) { 14bool process_action_user(keyrecord_t *record) {
15 // leave this function blank - it can be defined in a keymap file 15 // leave this function blank - it can be defined in a keymap file
16 return true;
16} 17}
17 18
18__attribute__ ((weak)) 19__attribute__ ((weak))
@@ -34,11 +35,11 @@ void matrix_scan_kb(void) {
34 matrix_scan_user(); 35 matrix_scan_user();
35} 36}
36 37
37void process_action_kb(keyrecord_t *record) { 38bool process_action_kb(keyrecord_t *record) {
38 // put your per-action keyboard code here 39 // put your per-action keyboard code here
39 // runs for every action, just before processing by the firmware 40 // runs for every action, just before processing by the firmware
40 41
41 process_action_user(record); 42 return process_action_user(record);
42} 43}
43 44
44void led_set_kb(uint8_t usb_led) { 45void led_set_kb(uint8_t usb_led) {
diff --git a/quantum/template/template.h b/quantum/template/template.h
index 22742105a..8537e3b4b 100644
--- a/quantum/template/template.h
+++ b/quantum/template/template.h
@@ -24,7 +24,7 @@
24 24
25void matrix_init_user(void); 25void matrix_init_user(void);
26void matrix_scan_user(void); 26void matrix_scan_user(void);
27void process_action_user(keyrecord_t *record); 27bool process_action_user(keyrecord_t *record);
28void led_set_user(uint8_t usb_led); 28void led_set_user(uint8_t usb_led);
29 29
30#endif 30#endif
diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c
index 081e90b2d..c026b96d9 100644
--- a/tmk_core/common/action.c
+++ b/tmk_core/common/action.c
@@ -70,7 +70,9 @@ void process_action_nocache(keyrecord_t *record)
70#endif 70#endif
71 71
72__attribute__ ((weak)) 72__attribute__ ((weak))
73void process_action_kb(keyrecord_t *record) {} 73bool process_action_quantum(keyrecord_t *record) {
74 return true;
75}
74 76
75void process_action(keyrecord_t *record) 77void process_action(keyrecord_t *record)
76{ 78{
@@ -89,7 +91,8 @@ void process_action(keyrecord_t *record)
89 } 91 }
90#endif 92#endif
91 93
92 process_action_kb(record); 94 if (!process_action_quantum(record))
95 return;
93 96
94 action_t action = store_or_get_action(event.pressed, event.key); 97 action_t action = store_or_get_action(event.pressed, event.key);
95 dprint("ACTION: "); debug_action(action); 98 dprint("ACTION: "); debug_action(action);
diff --git a/tmk_core/common/action.h b/tmk_core/common/action.h
index 44ec3047b..7d1cbafe9 100644
--- a/tmk_core/common/action.h
+++ b/tmk_core/common/action.h
@@ -59,7 +59,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt);
59void action_function(keyrecord_t *record, uint8_t id, uint8_t opt); 59void action_function(keyrecord_t *record, uint8_t id, uint8_t opt);
60 60
61/* keyboard-specific key event (pre)processing */ 61/* keyboard-specific key event (pre)processing */
62void process_action_kb(keyrecord_t *record); 62bool process_action_quantum(keyrecord_t *record);
63 63
64/* Utilities for actions. */ 64/* Utilities for actions. */
65#if !defined(NO_ACTION_LAYER) && defined(PREVENT_STUCK_MODIFIERS) 65#if !defined(NO_ACTION_LAYER) && defined(PREVENT_STUCK_MODIFIERS)
diff --git a/tmk_core/common/matrix.h b/tmk_core/common/matrix.h
index 0b013fc98..ad0871bfb 100644
--- a/tmk_core/common/matrix.h
+++ b/tmk_core/common/matrix.h
@@ -64,8 +64,8 @@ void matrix_power_up(void);
64void matrix_power_down(void); 64void matrix_power_down(void);
65 65
66/* keyboard-specific setup/loop functionality */ 66/* keyboard-specific setup/loop functionality */
67void matrix_init_kb(void); 67void matrix_init_quantum(void);
68void matrix_scan_kb(void); 68void matrix_scan_quantum(void);
69 69
70#ifdef __cplusplus 70#ifdef __cplusplus
71} 71}