summaryrefslogtreecommitdiff
path: root/quantum/process_keycode
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/process_keycode')
-rw-r--r--quantum/process_keycode/process_caps_word.c4
-rw-r--r--quantum/process_keycode/process_midi.c23
-rw-r--r--quantum/process_keycode/process_space_cadet.c6
-rw-r--r--quantum/process_keycode/process_space_cadet.h1
-rw-r--r--quantum/process_keycode/process_steno.c3
-rw-r--r--quantum/process_keycode/process_tap_dance.c6
-rw-r--r--quantum/process_keycode/process_tap_dance.h4
7 files changed, 25 insertions, 22 deletions
diff --git a/quantum/process_keycode/process_caps_word.c b/quantum/process_keycode/process_caps_word.c
index 1088c8f76c..b8fb868c6d 100644
--- a/quantum/process_keycode/process_caps_word.c
+++ b/quantum/process_keycode/process_caps_word.c
@@ -14,6 +14,7 @@
#include "process_caps_word.h"
#include "process_auto_shift.h"
+#include "process_space_cadet.h"
#include "caps_word.h"
#include "keycodes.h"
#include "quantum_keycodes.h"
@@ -110,6 +111,9 @@ bool process_caps_word(uint16_t keycode, keyrecord_t* record) {
# endif // COMMAND_ENABLE
) {
caps_word_on();
+# ifdef SPACE_CADET_ENABLE
+ reset_space_cadet();
+# endif // SPACE_CADET_ENABLE
}
# endif // defined(COMMAND_ENABLE) && !defined(IS_COMMAND)
#endif // BOTH_SHIFTS_TURNS_ON_CAPS_WORD
diff --git a/quantum/process_keycode/process_midi.c b/quantum/process_keycode/process_midi.c
index 377fcb69e2..5ecd897d16 100644
--- a/quantum/process_keycode/process_midi.c
+++ b/quantum/process_keycode/process_midi.c
@@ -38,7 +38,7 @@ void process_midi_all_notes_off(void) {
#endif // MIDI_BASIC
#ifdef MIDI_ADVANCED
-static uint8_t tone_status[2][MIDI_TONE_COUNT];
+static uint8_t tone_status[MIDI_TONE_COUNT];
static uint8_t midi_modulation;
static int8_t midi_modulation_step;
@@ -57,8 +57,7 @@ void midi_init(void) {
midi_config.modulation_interval = 8;
for (uint8_t i = 0; i < MIDI_TONE_COUNT; i++) {
- tone_status[0][i] = MIDI_INVALID_NOTE;
- tone_status[1][i] = 0;
+ tone_status[i] = MIDI_INVALID_NOTE;
}
midi_modulation = 0;
@@ -77,21 +76,19 @@ 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) {
- 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;
+ 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;
}
} else {
- uint8_t note = tone_status[0][tone];
- tone_status[1][tone] -= 1;
- if (tone_status[1][tone] == 0) {
+ uint8_t note = tone_status[tone];
+ if (note != MIDI_INVALID_NOTE) {
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_space_cadet.c b/quantum/process_keycode/process_space_cadet.c
index f948ad6238..3e280d57d9 100644
--- a/quantum/process_keycode/process_space_cadet.c
+++ b/quantum/process_keycode/process_space_cadet.c
@@ -157,10 +157,14 @@ bool process_space_cadet(uint16_t keycode, keyrecord_t *record) {
}
default: {
if (record->event.pressed) {
- sc_last = 0;
+ reset_space_cadet();
}
break;
}
}
return true;
}
+
+void reset_space_cadet() {
+ sc_last = 0;
+}
diff --git a/quantum/process_keycode/process_space_cadet.h b/quantum/process_keycode/process_space_cadet.h
index 6d10051532..9d254e26fd 100644
--- a/quantum/process_keycode/process_space_cadet.h
+++ b/quantum/process_keycode/process_space_cadet.h
@@ -21,3 +21,4 @@
void perform_space_cadet(keyrecord_t *record, uint16_t sc_keycode, uint8_t holdMod, uint8_t tapMod, uint8_t keycode);
bool process_space_cadet(uint16_t keycode, keyrecord_t *record);
+void reset_space_cadet(void);
diff --git a/quantum/process_keycode/process_steno.c b/quantum/process_keycode/process_steno.c
index bd4361580b..c491d6f1d8 100644
--- a/quantum/process_keycode/process_steno.c
+++ b/quantum/process_keycode/process_steno.c
@@ -128,9 +128,6 @@ static const uint16_t combinedmap_second[] PROGMEM = {STN_S2, STN_KL, STN_WL, ST
#ifdef STENO_ENABLE_ALL
void steno_init(void) {
- if (!eeconfig_is_enabled()) {
- eeconfig_init();
- }
mode = eeprom_read_byte(EECONFIG_STENOMODE);
}
diff --git a/quantum/process_keycode/process_tap_dance.c b/quantum/process_keycode/process_tap_dance.c
index b8a8d32f35..ce3b8fc81f 100644
--- a/quantum/process_keycode/process_tap_dance.c
+++ b/quantum/process_keycode/process_tap_dance.c
@@ -133,7 +133,7 @@ bool preprocess_tap_dance(uint16_t keycode, keyrecord_t *record) {
if (!active_td || keycode == active_td) return false;
- action = &tap_dance_actions[TD_INDEX(active_td)];
+ action = &tap_dance_actions[QK_TAP_DANCE_GET_INDEX(active_td)];
action->state.interrupted = true;
action->state.interrupting_keycode = keycode;
process_tap_dance_action_on_dance_finished(action);
@@ -154,7 +154,7 @@ bool process_tap_dance(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case QK_TAP_DANCE ... QK_TAP_DANCE_MAX:
- action = &tap_dance_actions[TD_INDEX(keycode)];
+ action = &tap_dance_actions[QK_TAP_DANCE_GET_INDEX(keycode)];
action->state.pressed = record->event.pressed;
if (record->event.pressed) {
@@ -182,7 +182,7 @@ void tap_dance_task(void) {
if (!active_td || timer_elapsed(last_tap_time) <= GET_TAPPING_TERM(active_td, &(keyrecord_t){})) return;
- action = &tap_dance_actions[TD_INDEX(active_td)];
+ action = &tap_dance_actions[QK_TAP_DANCE_GET_INDEX(active_td)];
if (!action->state.interrupted) {
process_tap_dance_action_on_dance_finished(action);
}
diff --git a/quantum/process_keycode/process_tap_dance.h b/quantum/process_keycode/process_tap_dance.h
index 2b114dabd3..c0137c14a3 100644
--- a/quantum/process_keycode/process_tap_dance.h
+++ b/quantum/process_keycode/process_tap_dance.h
@@ -19,6 +19,7 @@
#include <stdint.h>
#include <stdbool.h>
#include "action.h"
+#include "quantum_keycodes.h"
typedef struct {
uint16_t interrupting_keycode;
@@ -74,8 +75,7 @@ typedef struct {
#define ACTION_TAP_DANCE_FN_ADVANCED_WITH_RELEASE(user_fn_on_each_tap, user_fn_on_each_release, user_fn_on_dance_finished, user_fn_on_dance_reset) \
{ .fn = {user_fn_on_each_tap, user_fn_on_dance_finished, user_fn_on_dance_reset, user_fn_on_each_release}, .user_data = NULL, }
-#define TD(n) (QK_TAP_DANCE | TD_INDEX(n))
-#define TD_INDEX(code) ((code)&0xFF)
+#define TD_INDEX(code) QK_TAP_DANCE_GET_INDEX(code)
#define TAP_DANCE_KEYCODE(state) TD(((tap_dance_action_t *)state) - tap_dance_actions)
extern tap_dance_action_t tap_dance_actions[];