summaryrefslogtreecommitdiff
path: root/quantum/process_keycode
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/process_keycode')
-rw-r--r--quantum/process_keycode/process_combo.c6
-rwxr-xr-x[-rw-r--r--]quantum/process_keycode/process_grave_esc.h0
-rw-r--r--quantum/process_keycode/process_magic.c5
-rw-r--r--quantum/process_keycode/process_midi.c23
-rw-r--r--quantum/process_keycode/process_rgb.c14
-rw-r--r--quantum/process_keycode/process_tap_dance.c4
-rw-r--r--quantum/process_keycode/process_tap_dance.h8
-rw-r--r--quantum/process_keycode/process_unicode_common.c6
8 files changed, 35 insertions, 31 deletions
diff --git a/quantum/process_keycode/process_combo.c b/quantum/process_keycode/process_combo.c
index 0f1257e396..f38d7d47a0 100644
--- a/quantum/process_keycode/process_combo.c
+++ b/quantum/process_keycode/process_combo.c
@@ -20,8 +20,8 @@
#ifndef COMBO_VARIABLE_LEN
__attribute__((weak)) combo_t key_combos[COMBO_COUNT] = {};
#else
-extern combo_t key_combos[];
-extern int COMBO_LEN;
+extern combo_t key_combos[];
+extern int COMBO_LEN;
#endif
__attribute__((weak)) void process_combo_event(uint16_t combo_index, bool pressed) {}
@@ -146,7 +146,7 @@ bool process_combo(uint16_t keycode, keyrecord_t *record) {
}
#ifndef COMBO_VARIABLE_LEN
for (current_combo_index = 0; current_combo_index < COMBO_COUNT; ++current_combo_index) {
-#else
+#else
for (current_combo_index = 0; current_combo_index < COMBO_LEN; ++current_combo_index) {
#endif
combo_t *combo = &key_combos[current_combo_index];
diff --git a/quantum/process_keycode/process_grave_esc.h b/quantum/process_keycode/process_grave_esc.h
index bbf4483763..bbf4483763 100644..100755
--- a/quantum/process_keycode/process_grave_esc.h
+++ b/quantum/process_keycode/process_grave_esc.h
diff --git a/quantum/process_keycode/process_magic.c b/quantum/process_keycode/process_magic.c
index c70764dea1..44dd5f0579 100644
--- a/quantum/process_keycode/process_magic.c
+++ b/quantum/process_keycode/process_magic.c
@@ -42,7 +42,7 @@ bool process_magic(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) {
switch (keycode) {
case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_TOGGLE_ALT_GUI:
- case MAGIC_SWAP_LCTL_LGUI ... MAGIC_TOGGLE_CTL_GUI:
+ case MAGIC_SWAP_LCTL_LGUI ... MAGIC_EE_HANDS_RIGHT:
/* keymap config */
keymap_config.raw = eeconfig_read_keymap();
switch (keycode) {
@@ -158,15 +158,14 @@ bool process_magic(uint16_t keycode, keyrecord_t *record) {
clear_keyboard(); // clear first buffer to prevent stuck keys
keymap_config.nkro = !keymap_config.nkro;
break;
-#if 0
case MAGIC_EE_HANDS_LEFT:
eeconfig_update_handedness(true);
break;
case MAGIC_EE_HANDS_RIGHT:
eeconfig_update_handedness(false);
break;
-#endif
}
+
eeconfig_update_keymap(keymap_config.raw);
clear_keyboard(); // clear to prevent stuck keys
diff --git a/quantum/process_keycode/process_midi.c b/quantum/process_keycode/process_midi.c
index 8e2fb955e7..9632d2b757 100644
--- a/quantum/process_keycode/process_midi.c
+++ b/quantum/process_keycode/process_midi.c
@@ -34,7 +34,7 @@ void process_midi_all_notes_off(void) { midi_send_cc(&midi_device, 0, 0x7B, 0);
# include "timer.h"
-static uint8_t tone_status[MIDI_TONE_COUNT];
+static uint8_t tone_status[2][MIDI_TONE_COUNT];
static uint8_t midi_modulation;
static int8_t midi_modulation_step;
@@ -51,7 +51,8 @@ void midi_init(void) {
midi_config.modulation_interval = 8;
for (uint8_t i = 0; i < MIDI_TONE_COUNT; i++) {
- tone_status[i] = MIDI_INVALID_NOTE;
+ tone_status[0][i] = MIDI_INVALID_NOTE;
+ tone_status[1][i] = 0;
}
midi_modulation = 0;
@@ -68,19 +69,21 @@ bool process_midi(uint16_t keycode, keyrecord_t *record) {
uint8_t tone = keycode - MIDI_TONE_MIN;
uint8_t velocity = midi_config.velocity;
if (record->event.pressed) {
- if (tone_status[tone] == MIDI_INVALID_NOTE) {
- uint8_t note = midi_compute_note(keycode);
- midi_send_noteon(&midi_device, channel, note, velocity);
- dprintf("midi noteon channel:%d note:%d velocity:%d\n", channel, note, velocity);
- tone_status[tone] = note;
+ uint8_t note = midi_compute_note(keycode);
+ midi_send_noteon(&midi_device, channel, note, velocity);
+ dprintf("midi noteon channel:%d note:%d velocity:%d\n", channel, note, velocity);
+ tone_status[1][tone] += 1;
+ if (tone_status[0][tone] == MIDI_INVALID_NOTE) {
+ tone_status[0][tone] = note;
}
} else {
- uint8_t note = tone_status[tone];
- if (note != MIDI_INVALID_NOTE) {
+ uint8_t note = tone_status[0][tone];
+ tone_status[1][tone] -= 1;
+ if (tone_status[1][tone] == 0) {
midi_send_noteoff(&midi_device, channel, note, velocity);
dprintf("midi noteoff channel:%d note:%d velocity:%d\n", channel, note, velocity);
+ tone_status[0][tone] = MIDI_INVALID_NOTE;
}
- tone_status[tone] = MIDI_INVALID_NOTE;
}
return false;
}
diff --git a/quantum/process_keycode/process_rgb.c b/quantum/process_keycode/process_rgb.c
index db31011d98..5dd8e7809d 100644
--- a/quantum/process_keycode/process_rgb.c
+++ b/quantum/process_keycode/process_rgb.c
@@ -167,7 +167,7 @@ bool process_rgb(const uint16_t keycode, const keyrecord_t *record) {
#endif
return false;
case RGB_MODE_RAINBOW:
-#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined( RGBLIGHT_EFFECT_RAINBOW_MOOD)
+#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined(RGBLIGHT_EFFECT_RAINBOW_MOOD)
handleKeycodeRGBMode(RGBLIGHT_MODE_RAINBOW_MOOD, RGBLIGHT_MODE_RAINBOW_MOOD_end);
#endif
#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES) && !defined(DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT)
@@ -175,7 +175,7 @@ bool process_rgb(const uint16_t keycode, const keyrecord_t *record) {
#endif
return false;
case RGB_MODE_SWIRL:
-#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined( RGBLIGHT_EFFECT_RAINBOW_SWIRL)
+#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined(RGBLIGHT_EFFECT_RAINBOW_SWIRL)
handleKeycodeRGBMode(RGBLIGHT_MODE_RAINBOW_SWIRL, RGBLIGHT_MODE_RAINBOW_SWIRL_end);
#endif
#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES) && !defined(DISABLE_RGB_MATRIX_CYCLE_PINWHEEL)
@@ -183,27 +183,27 @@ bool process_rgb(const uint16_t keycode, const keyrecord_t *record) {
#endif
return false;
case RGB_MODE_SNAKE:
-#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined( RGBLIGHT_EFFECT_SNAKE)
+#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined(RGBLIGHT_EFFECT_SNAKE)
handleKeycodeRGBMode(RGBLIGHT_MODE_SNAKE, RGBLIGHT_MODE_SNAKE_end);
#endif
return false;
case RGB_MODE_KNIGHT:
-#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined( RGBLIGHT_EFFECT_KNIGHT)
+#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined(RGBLIGHT_EFFECT_KNIGHT)
handleKeycodeRGBMode(RGBLIGHT_MODE_KNIGHT, RGBLIGHT_MODE_KNIGHT_end);
#endif
return false;
case RGB_MODE_XMAS:
-#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined( RGBLIGHT_EFFECT_CHRISTMAS)
+#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined(RGBLIGHT_EFFECT_CHRISTMAS)
rgblight_mode(RGBLIGHT_MODE_CHRISTMAS);
#endif
return false;
case RGB_MODE_GRADIENT:
-#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined( RGBLIGHT_EFFECT_STATIC_GRADIENT)
+#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined(RGBLIGHT_EFFECT_STATIC_GRADIENT)
handleKeycodeRGBMode(RGBLIGHT_MODE_STATIC_GRADIENT, RGBLIGHT_MODE_STATIC_GRADIENT_end);
#endif
return false;
case RGB_MODE_RGBTEST:
-#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined( RGBLIGHT_EFFECT_RGB_TEST)
+#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined(RGBLIGHT_EFFECT_RGB_TEST)
rgblight_mode(RGBLIGHT_MODE_RGB_TEST);
#endif
return false;
diff --git a/quantum/process_keycode/process_tap_dance.c b/quantum/process_keycode/process_tap_dance.c
index 138de0eba2..17dc540a64 100644
--- a/quantum/process_keycode/process_tap_dance.c
+++ b/quantum/process_keycode/process_tap_dance.c
@@ -117,6 +117,10 @@ void preprocess_tap_dance(uint16_t keycode, keyrecord_t *record) {
action->state.interrupting_keycode = keycode;
process_tap_dance_action_on_dance_finished(action);
reset_tap_dance(&action->state);
+
+ // Tap dance actions can leave some weak mods active (e.g., if the tap dance is mapped to a keycode with
+ // modifiers), but these weak mods should not affect the keypress which interrupted the tap dance.
+ clear_weak_mods();
}
}
}
diff --git a/quantum/process_keycode/process_tap_dance.h b/quantum/process_keycode/process_tap_dance.h
index b04767ca65..a013c5cabf 100644
--- a/quantum/process_keycode/process_tap_dance.h
+++ b/quantum/process_keycode/process_tap_dance.h
@@ -63,10 +63,10 @@ typedef struct {
{ .fn = {qk_tap_dance_pair_on_each_tap, qk_tap_dance_pair_finished, qk_tap_dance_pair_reset}, .user_data = (void *)&((qk_tap_dance_pair_t){kc1, kc2}), }
# define ACTION_TAP_DANCE_DUAL_ROLE(kc, layer) \
- { .fn = { qk_tap_dance_dual_role_on_each_tap, qk_tap_dance_dual_role_finished, qk_tap_dance_dual_role_reset }, .user_data = (void *)&((qk_tap_dance_dual_role_t) { kc, layer, layer_move }), }
+ { .fn = {qk_tap_dance_dual_role_on_each_tap, qk_tap_dance_dual_role_finished, qk_tap_dance_dual_role_reset}, .user_data = (void *)&((qk_tap_dance_dual_role_t){kc, layer, layer_move}), }
-# define ACTION_TAP_DANCE_TOGGLE_LAYER(kc, layer) \
- { .fn = { NULL, qk_tap_dance_dual_role_finished, qk_tap_dance_dual_role_reset }, .user_data = (void *)&((qk_tap_dance_dual_role_t) { kc, layer, layer_invert }), }
+# define ACTION_TAP_DANCE_LAYER_TOGGLE(kc, layer) \
+ { .fn = {NULL, qk_tap_dance_dual_role_finished, qk_tap_dance_dual_role_reset}, .user_data = (void *)&((qk_tap_dance_dual_role_t){kc, layer, layer_invert}), }
# define ACTION_TAP_DANCE_LAYER_MOVE(kc, layer) ACTION_TAP_DANCE_DUAL_ROLE(kc, layer)
@@ -79,8 +79,6 @@ typedef struct {
# define ACTION_TAP_DANCE_FN_ADVANCED_TIME(user_fn_on_each_tap, user_fn_on_dance_finished, user_fn_on_dance_reset, tap_specific_tapping_term) \
{ .fn = {user_fn_on_each_tap, user_fn_on_dance_finished, user_fn_on_dance_reset}, .user_data = NULL, .custom_tapping_term = tap_specific_tapping_term, }
-
-
extern qk_tap_dance_action_t tap_dance_actions[];
/* To be used internally */
diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c
index bac9fbcc0f..46fcaaa86b 100644
--- a/quantum/process_keycode/process_unicode_common.c
+++ b/quantum/process_keycode/process_unicode_common.c
@@ -158,7 +158,7 @@ __attribute__((weak)) void unicode_input_cancel(void) {
void register_hex(uint16_t hex) {
for (int i = 3; i >= 0; i--) {
uint8_t digit = ((hex >> (i * 4)) & 0xF);
- tap_code16(hex_to_keycode(digit));
+ send_nibble(digit);
}
}
@@ -171,10 +171,10 @@ void register_hex32(uint32_t hex) {
uint8_t digit = ((hex >> (i * 4)) & 0xF);
if (digit == 0) {
if (!onzerostart) {
- tap_code16(hex_to_keycode(digit));
+ send_nibble(digit);
}
} else {
- tap_code16(hex_to_keycode(digit));
+ send_nibble(digit);
onzerostart = false;
}
}