1
0
Fork 0

matrix_scan_x -> x_task (#13748)

This commit is contained in:
Joel Challis 2021-07-28 12:01:23 +01:00 committed by GitHub
parent c52c69d45f
commit 03d258c222
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 27 additions and 31 deletions

View file

@ -50,7 +50,7 @@ The main entry point is `process_tap_dance()`, called from `process_record_quant
This means that you have `TAPPING_TERM` time to tap the key again; you do not have to input all the taps within a single `TAPPING_TERM` timeframe. This allows for longer tap counts, with minimal impact on responsiveness. This means that you have `TAPPING_TERM` time to tap the key again; you do not have to input all the taps within a single `TAPPING_TERM` timeframe. This allows for longer tap counts, with minimal impact on responsiveness.
Our next stop is `matrix_scan_tap_dance()`. This handles the timeout of tap-dance keys. Our next stop is `tap_dance_task()`. This handles the timeout of tap-dance keys.
For the sake of flexibility, tap-dance actions can be either a pair of keycodes, or a user function. The latter allows one to handle higher tap counts, or do extra things, like blink the LEDs, fiddle with the backlighting, and so on. This is accomplished by using an union, and some clever macros. For the sake of flexibility, tap-dance actions can be either a pair of keycodes, or a user function. The latter allows one to handle higher tap counts, or do extra things, like blink the LEDs, fiddle with the backlighting, and so on. This is accomplished by using an union, and some clever macros.

View file

@ -59,7 +59,7 @@
このことは、あなたは再びキーをタップするまでの時間として `TAPPING_TERM` の時間を持っていることを意味します。そのため、あなたは1つの `TAPPING_TERM` の時間内に全てのタップを行う必要はありません。これにより、キーの反応への影響を最小限に抑えながら、より長いタップ回数を可能にします。 このことは、あなたは再びキーをタップするまでの時間として `TAPPING_TERM` の時間を持っていることを意味します。そのため、あなたは1つの `TAPPING_TERM` の時間内に全てのタップを行う必要はありません。これにより、キーの反応への影響を最小限に抑えながら、より長いタップ回数を可能にします。
次は `matrix_scan_tap_dance()` です。この関数はタップダンスキーのタイムアウトを制御します。 次は `tap_dance_task()` です。この関数はタップダンスキーのタイムアウトを制御します。
柔軟性のために、タップダンスは、キーコードの組み合わせにも、ユーザー関数にもなることができます。後者は、より高度なタップ回数の制御や、LED を点滅させたり、バックライトをいじったり、等々の制御を可能にします。これは、1つの共用体と、いくつかの賢いマクロによって成し遂げられています。 柔軟性のために、タップダンスは、キーコードの組み合わせにも、ユーザー関数にもなることができます。後者は、より高度なタップ回数の制御や、LED を点滅させたり、バックライトをいじったり、等々の制御を可能にします。これは、1つの共用体と、いくつかの賢いマクロによって成し遂げられています。

View file

@ -184,7 +184,7 @@ bool process_combo(uint16_t keycode, keyrecord_t *record) {
return !is_combo_key; return !is_combo_key;
} }
void matrix_scan_combo(void) { void combo_task(void) {
if (b_combo_enable && is_active && timer && timer_elapsed(timer) > COMBO_TERM) { if (b_combo_enable && is_active && timer && timer_elapsed(timer) > COMBO_TERM) {
/* This disables the combo, meaning key events for this /* This disables the combo, meaning key events for this
* combo will be handled by the next processors in the chain * combo will be handled by the next processors in the chain

View file

@ -54,7 +54,7 @@ typedef struct {
#endif #endif
bool process_combo(uint16_t keycode, keyrecord_t *record); bool process_combo(uint16_t keycode, keyrecord_t *record);
void matrix_scan_combo(void); void combo_task(void);
void process_combo_event(uint16_t combo_index, bool pressed); void process_combo_event(uint16_t combo_index, bool pressed);
void combo_enable(void); void combo_enable(void);

View file

@ -296,7 +296,7 @@ void music_mode_cycle(void) {
# endif # endif
} }
void matrix_scan_music(void) { void music_task(void) {
if (music_sequence_playing) { if (music_sequence_playing) {
if ((music_sequence_timer == 0) || (timer_elapsed(music_sequence_timer) > music_sequence_interval)) { if ((music_sequence_timer == 0) || (timer_elapsed(music_sequence_timer) > music_sequence_interval)) {
music_sequence_timer = timer_read(); music_sequence_timer = timer_read();

View file

@ -44,7 +44,7 @@ void music_scale_user(void);
void music_all_notes_off(void); void music_all_notes_off(void);
void music_mode_cycle(void); void music_mode_cycle(void);
void matrix_scan_music(void); void music_task(void);
bool music_mask(uint16_t keycode); bool music_mask(uint16_t keycode);
bool music_mask_kb(uint16_t keycode); bool music_mask_kb(uint16_t keycode);

View file

@ -161,7 +161,7 @@ bool process_tap_dance(uint16_t keycode, keyrecord_t *record) {
return true; return true;
} }
void matrix_scan_tap_dance() { void tap_dance_task() {
if (highest_td == -1) return; if (highest_td == -1) return;
uint16_t tap_user_defined; uint16_t tap_user_defined;

View file

@ -85,7 +85,7 @@ extern qk_tap_dance_action_t tap_dance_actions[];
void preprocess_tap_dance(uint16_t keycode, keyrecord_t *record); void preprocess_tap_dance(uint16_t keycode, keyrecord_t *record);
bool process_tap_dance(uint16_t keycode, keyrecord_t *record); bool process_tap_dance(uint16_t keycode, keyrecord_t *record);
void matrix_scan_tap_dance(void); void tap_dance_task(void);
void reset_tap_dance(qk_tap_dance_state_t *state); void reset_tap_dance(qk_tap_dance_state_t *state);
void qk_tap_dance_pair_on_each_tap(qk_tap_dance_state_t *state, void *user_data); void qk_tap_dance_pair_on_each_tap(qk_tap_dance_state_t *state, void *user_data);

View file

@ -411,7 +411,7 @@ void matrix_scan_quantum() {
#endif #endif
#if defined(AUDIO_ENABLE) && !defined(NO_MUSIC_MODE) #if defined(AUDIO_ENABLE) && !defined(NO_MUSIC_MODE)
matrix_scan_music(); music_task();
#endif #endif
#ifdef KEY_OVERRIDE_ENABLE #ifdef KEY_OVERRIDE_ENABLE
@ -419,15 +419,15 @@ void matrix_scan_quantum() {
#endif #endif
#ifdef SEQUENCER_ENABLE #ifdef SEQUENCER_ENABLE
matrix_scan_sequencer(); sequencer_task();
#endif #endif
#ifdef TAP_DANCE_ENABLE #ifdef TAP_DANCE_ENABLE
matrix_scan_tap_dance(); tap_dance_task();
#endif #endif
#ifdef COMBO_ENABLE #ifdef COMBO_ENABLE
matrix_scan_combo(); combo_task();
#endif #endif
#ifdef LED_MATRIX_ENABLE #ifdef LED_MATRIX_ENABLE

View file

@ -212,10 +212,6 @@ void set_single_persistent_default_layer(uint8_t default_layer);
#define IS_LAYER_ON_STATE(state, layer) layer_state_cmp(state, layer) #define IS_LAYER_ON_STATE(state, layer) layer_state_cmp(state, layer)
#define IS_LAYER_OFF_STATE(state, layer) !layer_state_cmp(state, layer) #define IS_LAYER_OFF_STATE(state, layer) !layer_state_cmp(state, layer)
void matrix_init_kb(void);
void matrix_scan_kb(void);
void matrix_init_user(void);
void matrix_scan_user(void);
uint16_t get_record_keycode(keyrecord_t *record, bool update_layer_cache); uint16_t get_record_keycode(keyrecord_t *record, bool update_layer_cache);
uint16_t get_event_keycode(keyevent_t event, bool update_layer_cache); uint16_t get_event_keycode(keyevent_t event, bool update_layer_cache);
bool process_action_kb(keyrecord_t *record); bool process_action_kb(keyrecord_t *record);

View file

@ -211,7 +211,7 @@ void sequencer_phase_pause(void) {
sequencer_internal_state.phase = SEQUENCER_PHASE_ATTACK; sequencer_internal_state.phase = SEQUENCER_PHASE_ATTACK;
} }
void matrix_scan_sequencer(void) { void sequencer_task(void) {
if (!sequencer_config.enabled) { if (!sequencer_config.enabled) {
return; return;
} }

View file

@ -119,4 +119,4 @@ uint16_t sequencer_get_step_duration(void);
uint16_t get_beat_duration(uint8_t tempo); uint16_t get_beat_duration(uint8_t tempo);
uint16_t get_step_duration(uint8_t tempo, sequencer_resolution_t resolution); uint16_t get_step_duration(uint8_t tempo, sequencer_resolution_t resolution);
void matrix_scan_sequencer(void); void sequencer_task(void);

View file

@ -386,7 +386,7 @@ void setUpMatrixScanSequencerTest(void) {
TEST_F(SequencerTest, TestMatrixScanSequencerShouldAttackFirstTrackOfFirstStep) { TEST_F(SequencerTest, TestMatrixScanSequencerShouldAttackFirstTrackOfFirstStep) {
setUpMatrixScanSequencerTest(); setUpMatrixScanSequencerTest();
matrix_scan_sequencer(); sequencer_task();
EXPECT_EQ(last_noteon, MI_C); EXPECT_EQ(last_noteon, MI_C);
EXPECT_EQ(last_noteoff, 0); EXPECT_EQ(last_noteoff, 0);
} }
@ -394,7 +394,7 @@ TEST_F(SequencerTest, TestMatrixScanSequencerShouldAttackFirstTrackOfFirstStep)
TEST_F(SequencerTest, TestMatrixScanSequencerShouldAttackSecondTrackAfterFirstTrackOfFirstStep) { TEST_F(SequencerTest, TestMatrixScanSequencerShouldAttackSecondTrackAfterFirstTrackOfFirstStep) {
setUpMatrixScanSequencerTest(); setUpMatrixScanSequencerTest();
matrix_scan_sequencer(); sequencer_task();
EXPECT_EQ(sequencer_internal_state.current_step, 0); EXPECT_EQ(sequencer_internal_state.current_step, 0);
EXPECT_EQ(sequencer_internal_state.current_track, 1); EXPECT_EQ(sequencer_internal_state.current_track, 1);
EXPECT_EQ(sequencer_internal_state.phase, SEQUENCER_PHASE_ATTACK); EXPECT_EQ(sequencer_internal_state.phase, SEQUENCER_PHASE_ATTACK);
@ -409,7 +409,7 @@ TEST_F(SequencerTest, TestMatrixScanSequencerShouldNotAttackInactiveTrackFirstSt
// Wait some time after the first track has been attacked // Wait some time after the first track has been attacked
advance_time(SEQUENCER_TRACK_THROTTLE); advance_time(SEQUENCER_TRACK_THROTTLE);
matrix_scan_sequencer(); sequencer_task();
EXPECT_EQ(last_noteon, 0); EXPECT_EQ(last_noteon, 0);
EXPECT_EQ(last_noteoff, 0); EXPECT_EQ(last_noteoff, 0);
} }
@ -423,7 +423,7 @@ TEST_F(SequencerTest, TestMatrixScanSequencerShouldAttackThirdTrackAfterSecondTr
// Wait some time after the second track has been attacked // Wait some time after the second track has been attacked
advance_time(2 * SEQUENCER_TRACK_THROTTLE); advance_time(2 * SEQUENCER_TRACK_THROTTLE);
matrix_scan_sequencer(); sequencer_task();
EXPECT_EQ(sequencer_internal_state.current_step, 0); EXPECT_EQ(sequencer_internal_state.current_step, 0);
EXPECT_EQ(sequencer_internal_state.current_track, 2); EXPECT_EQ(sequencer_internal_state.current_track, 2);
EXPECT_EQ(sequencer_internal_state.phase, SEQUENCER_PHASE_ATTACK); EXPECT_EQ(sequencer_internal_state.phase, SEQUENCER_PHASE_ATTACK);
@ -438,7 +438,7 @@ TEST_F(SequencerTest, TestMatrixScanSequencerShouldEnterReleasePhaseAfterLastTra
// Wait until all notes have been attacked // Wait until all notes have been attacked
advance_time((SEQUENCER_TRACKS - 1) * SEQUENCER_TRACK_THROTTLE); advance_time((SEQUENCER_TRACKS - 1) * SEQUENCER_TRACK_THROTTLE);
matrix_scan_sequencer(); sequencer_task();
EXPECT_EQ(last_noteon, 0); EXPECT_EQ(last_noteon, 0);
EXPECT_EQ(last_noteoff, 0); EXPECT_EQ(last_noteoff, 0);
EXPECT_EQ(sequencer_internal_state.current_step, 0); EXPECT_EQ(sequencer_internal_state.current_step, 0);
@ -458,7 +458,7 @@ TEST_F(SequencerTest, TestMatrixScanSequencerShouldReleaseBackwards) {
// + the release timeout // + the release timeout
advance_time(SEQUENCER_PHASE_RELEASE_TIMEOUT); advance_time(SEQUENCER_PHASE_RELEASE_TIMEOUT);
matrix_scan_sequencer(); sequencer_task();
EXPECT_EQ(sequencer_internal_state.current_step, 0); EXPECT_EQ(sequencer_internal_state.current_step, 0);
EXPECT_EQ(sequencer_internal_state.current_track, SEQUENCER_TRACKS - 2); EXPECT_EQ(sequencer_internal_state.current_track, SEQUENCER_TRACKS - 2);
EXPECT_EQ(sequencer_internal_state.phase, SEQUENCER_PHASE_RELEASE); EXPECT_EQ(sequencer_internal_state.phase, SEQUENCER_PHASE_RELEASE);
@ -476,7 +476,7 @@ TEST_F(SequencerTest, TestMatrixScanSequencerShouldNotReleaseInactiveTrackFirstS
// + the release timeout // + the release timeout
advance_time(SEQUENCER_PHASE_RELEASE_TIMEOUT); advance_time(SEQUENCER_PHASE_RELEASE_TIMEOUT);
matrix_scan_sequencer(); sequencer_task();
EXPECT_EQ(last_noteon, 0); EXPECT_EQ(last_noteon, 0);
EXPECT_EQ(last_noteoff, 0); EXPECT_EQ(last_noteoff, 0);
} }
@ -495,7 +495,7 @@ TEST_F(SequencerTest, TestMatrixScanSequencerShouldReleaseFirstTrackFirstStep) {
// + all the other notes have been released // + all the other notes have been released
advance_time((SEQUENCER_TRACKS - 1) * SEQUENCER_TRACK_THROTTLE); advance_time((SEQUENCER_TRACKS - 1) * SEQUENCER_TRACK_THROTTLE);
matrix_scan_sequencer(); sequencer_task();
EXPECT_EQ(last_noteon, 0); EXPECT_EQ(last_noteon, 0);
EXPECT_EQ(last_noteoff, MI_C); EXPECT_EQ(last_noteoff, MI_C);
} }
@ -514,7 +514,7 @@ TEST_F(SequencerTest, TestMatrixScanSequencerShouldEnterPausePhaseAfterRelease)
// + all the other notes have been released // + all the other notes have been released
advance_time((SEQUENCER_TRACKS - 1) * SEQUENCER_TRACK_THROTTLE); advance_time((SEQUENCER_TRACKS - 1) * SEQUENCER_TRACK_THROTTLE);
matrix_scan_sequencer(); sequencer_task();
EXPECT_EQ(sequencer_internal_state.current_step, 0); EXPECT_EQ(sequencer_internal_state.current_step, 0);
EXPECT_EQ(sequencer_internal_state.current_track, 0); EXPECT_EQ(sequencer_internal_state.current_track, 0);
EXPECT_EQ(sequencer_internal_state.phase, SEQUENCER_PHASE_PAUSE); EXPECT_EQ(sequencer_internal_state.phase, SEQUENCER_PHASE_PAUSE);
@ -536,7 +536,7 @@ TEST_F(SequencerTest, TestMatrixScanSequencerShouldProcessFirstTrackOfSecondStep
// + the step duration (one 16th at tempo=120 lasts 125ms) // + the step duration (one 16th at tempo=120 lasts 125ms)
advance_time(125); advance_time(125);
matrix_scan_sequencer(); sequencer_task();
EXPECT_EQ(sequencer_internal_state.current_step, 1); EXPECT_EQ(sequencer_internal_state.current_step, 1);
EXPECT_EQ(sequencer_internal_state.current_track, 1); EXPECT_EQ(sequencer_internal_state.current_track, 1);
EXPECT_EQ(sequencer_internal_state.phase, SEQUENCER_PHASE_ATTACK); EXPECT_EQ(sequencer_internal_state.phase, SEQUENCER_PHASE_ATTACK);
@ -548,7 +548,7 @@ TEST_F(SequencerTest, TestMatrixScanSequencerShouldProcessSecondTrackTooEarly) {
sequencer_internal_state.current_step = 2; sequencer_internal_state.current_step = 2;
sequencer_internal_state.current_track = 1; sequencer_internal_state.current_track = 1;
matrix_scan_sequencer(); sequencer_task();
EXPECT_EQ(last_noteon, 0); EXPECT_EQ(last_noteon, 0);
EXPECT_EQ(last_noteoff, 0); EXPECT_EQ(last_noteoff, 0);
} }
@ -562,7 +562,7 @@ TEST_F(SequencerTest, TestMatrixScanSequencerShouldProcessSecondTrackOnTime) {
// Wait until first track has been attacked // Wait until first track has been attacked
advance_time(SEQUENCER_TRACK_THROTTLE); advance_time(SEQUENCER_TRACK_THROTTLE);
matrix_scan_sequencer(); sequencer_task();
EXPECT_EQ(last_noteon, MI_D); EXPECT_EQ(last_noteon, MI_D);
EXPECT_EQ(last_noteoff, 0); EXPECT_EQ(last_noteoff, 0);
} }
@ -583,7 +583,7 @@ TEST_F(SequencerTest, TestMatrixScanSequencerShouldLoopOnceSequenceIsOver) {
// + the step duration (one 16th at tempo=120 lasts 125ms) // + the step duration (one 16th at tempo=120 lasts 125ms)
advance_time(125); advance_time(125);
matrix_scan_sequencer(); sequencer_task();
EXPECT_EQ(sequencer_internal_state.current_step, 0); EXPECT_EQ(sequencer_internal_state.current_step, 0);
EXPECT_EQ(sequencer_internal_state.current_track, 1); EXPECT_EQ(sequencer_internal_state.current_track, 1);
EXPECT_EQ(sequencer_internal_state.phase, SEQUENCER_PHASE_ATTACK); EXPECT_EQ(sequencer_internal_state.phase, SEQUENCER_PHASE_ATTACK);