summaryrefslogtreecommitdiff
path: root/quantum/quantum.c
diff options
context:
space:
mode:
authorDrashna Jael're <drashna@live.com>2021-10-11 20:36:47 -0700
committerDrashna Jael're <drashna@live.com>2021-10-11 20:36:47 -0700
commitb34675555cbd9a71a797a7ebc2148cbf2e8f0efc (patch)
tree2d701310ccd3fc2c603d63536ab4a3c1d9b9381b /quantum/quantum.c
parentbcddde8738dbba48c548f1e3f12a10bbf60a65d8 (diff)
parentd9e077468ab3446cbd7306a453a73dad2c1403e8 (diff)
Merge commit 'd9e077468ab3446cbd7306a453a73dad2c1403e8' into firmware_21
Diffstat (limited to 'quantum/quantum.c')
-rw-r--r--quantum/quantum.c62
1 files changed, 42 insertions, 20 deletions
diff --git a/quantum/quantum.c b/quantum/quantum.c
index a9f5f5d95f..14f25597ca 100644
--- a/quantum/quantum.c
+++ b/quantum/quantum.c
@@ -50,21 +50,18 @@ float goodbye_song[][2] = GOODBYE_SONG;
# ifdef DEFAULT_LAYER_SONGS
float default_layer_songs[][16][2] = DEFAULT_LAYER_SONGS;
# endif
-# ifdef SENDSTRING_BELL
-float bell_song[][2] = SONG(TERMINAL_SOUND);
-# endif
#endif
#ifdef AUTO_SHIFT_ENABLE
# include "process_auto_shift.h"
#endif
-static void do_code16(uint16_t code, void (*f)(uint8_t)) {
+uint8_t extract_mod_bits(uint16_t code) {
switch (code) {
case QK_MODS ... QK_MODS_MAX:
break;
default:
- return;
+ return 0;
}
uint8_t mods_to_send = 0;
@@ -81,9 +78,11 @@ static void do_code16(uint16_t code, void (*f)(uint8_t)) {
if (code & QK_LGUI) mods_to_send |= MOD_BIT(KC_LGUI);
}
- f(mods_to_send);
+ return mods_to_send;
}
+static void do_code16(uint16_t code, void (*f)(uint8_t)) { f(extract_mod_bits(code)); }
+
void register_code16(uint16_t code) {
if (IS_MOD(code) || code == KC_NO) {
do_code16(code, register_mods);
@@ -145,7 +144,14 @@ void reset_keyboard(void) {
}
/* Convert record into usable keycode via the contained event. */
-uint16_t get_record_keycode(keyrecord_t *record, bool update_layer_cache) { return get_event_keycode(record->event, update_layer_cache); }
+uint16_t get_record_keycode(keyrecord_t *record, bool update_layer_cache) {
+#ifdef COMBO_ENABLE
+ if (record->keycode) { return record->keycode; }
+#endif
+ return get_event_keycode(record->event, update_layer_cache);
+}
+
+
/* Convert event into usable keycode. Checks the layer cache to ensure that it
* retains the correct keycode after a layer change, if the key is still pressed.
* "update_layer_cache" is to ensure that it only updates the layer cache when
@@ -170,6 +176,18 @@ uint16_t get_event_keycode(keyevent_t event, bool update_layer_cache) {
return keymap_key_to_keycode(layer_switch_get_layer(event.key), event.key);
}
+/* Get keycode, and then process pre tapping functionality */
+bool pre_process_record_quantum(keyrecord_t *record) {
+ if (!(
+#ifdef COMBO_ENABLE
+ process_combo(get_record_keycode(record, true), record) &&
+#endif
+ true)) {
+ return false;
+ }
+ return true; // continue processing
+}
+
/* Get keycode, and then call keyboard function */
void post_process_record_quantum(keyrecord_t *record) {
uint16_t keycode = get_record_keycode(record, false);
@@ -217,7 +235,7 @@ bool process_record_quantum(keyrecord_t *record) {
#endif
#if defined(AUDIO_ENABLE) && defined(AUDIO_CLICKY)
process_clicky(keycode, record) &&
-#endif // AUDIO_CLICKY
+#endif
#ifdef HAPTIC_ENABLE
process_haptic(keycode, record) &&
#endif // HAPTIC_ENABLE
@@ -246,6 +264,9 @@ bool process_record_quantum(keyrecord_t *record) {
#if (defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC))) && !defined(NO_MUSIC_MODE)
process_music(keycode, record) &&
#endif
+#ifdef KEY_OVERRIDE_ENABLE
+ process_key_override(keycode, record) &&
+#endif
#ifdef TAP_DANCE_ENABLE
process_tap_dance(keycode, record) &&
#endif
@@ -255,9 +276,6 @@ bool process_record_quantum(keyrecord_t *record) {
#ifdef LEADER_ENABLE
process_leader(keycode, record) &&
#endif
-#ifdef COMBO_ENABLE
- process_combo(keycode, record) &&
-#endif
#ifdef PRINTING_ENABLE
process_printer(keycode, record) &&
#endif
@@ -344,13 +362,13 @@ void set_single_persistent_default_layer(uint8_t default_layer) {
#if defined(AUDIO_ENABLE) && defined(DEFAULT_LAYER_SONGS)
PLAY_SONG(default_layer_songs[default_layer]);
#endif
- eeconfig_update_default_layer(1U << default_layer);
- default_layer_set(1U << default_layer);
+ eeconfig_update_default_layer((layer_state_t)1 << default_layer);
+ default_layer_set((layer_state_t)1 << default_layer);
}
layer_state_t update_tri_layer_state(layer_state_t state, uint8_t layer1, uint8_t layer2, uint8_t layer3) {
- layer_state_t mask12 = (1UL << layer1) | (1UL << layer2);
- layer_state_t mask3 = 1UL << layer3;
+ layer_state_t mask12 = ((layer_state_t)1 << layer1) | ((layer_state_t)1 << layer2);
+ layer_state_t mask3 = (layer_state_t)1 << layer3;
return (state & mask12) == mask12 ? (state | mask3) : (state & ~mask3);
}
@@ -394,7 +412,7 @@ void matrix_init_quantum() {
}
void matrix_scan_quantum() {
-#if defined(AUDIO_ENABLE)
+#if defined(AUDIO_ENABLE) && defined(AUDIO_INIT_DELAY)
// There are some tasks that need to be run a little bit
// after keyboard startup, or else they will not work correctly
// because of interaction with the USB device state, which
@@ -415,19 +433,23 @@ void matrix_scan_quantum() {
#endif
#if defined(AUDIO_ENABLE) && !defined(NO_MUSIC_MODE)
- matrix_scan_music();
+ music_task();
+#endif
+
+#ifdef KEY_OVERRIDE_ENABLE
+ key_override_task();
#endif
#ifdef SEQUENCER_ENABLE
- matrix_scan_sequencer();
+ sequencer_task();
#endif
#ifdef TAP_DANCE_ENABLE
- matrix_scan_tap_dance();
+ tap_dance_task();
#endif
#ifdef COMBO_ENABLE
- matrix_scan_combo();
+ combo_task();
#endif
#ifdef LED_MATRIX_ENABLE