Merge remote-tracking branch 'qmk/master' into merge-2023-06-03
This commit is contained in:
@ -14,6 +14,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "keymap_common.h"
|
||||
#include "print.h"
|
||||
#include "process_combo.h"
|
||||
#include "action_tapping.h"
|
||||
@ -24,14 +25,18 @@
|
||||
/* dynamic combos are stored entirely in ram */
|
||||
#undef pgm_read_word
|
||||
#define pgm_read_word(address_short) *((uint16_t*)(address_short))
|
||||
#endif
|
||||
|
||||
#ifdef COMBO_COUNT
|
||||
__attribute__((weak)) combo_t key_combos[COMBO_COUNT];
|
||||
uint16_t COMBO_LEN = COMBO_COUNT;
|
||||
uint16_t combo_count(void) {
|
||||
return VIAL_COMBO_ENTRIES;
|
||||
}
|
||||
|
||||
extern combo_t key_combos[];
|
||||
|
||||
combo_t* combo_get(uint16_t combo_idx) {
|
||||
return &key_combos[combo_idx];
|
||||
}
|
||||
#else
|
||||
extern combo_t key_combos[];
|
||||
extern uint16_t COMBO_LEN;
|
||||
#include "keymap_introspection.h"
|
||||
#endif
|
||||
|
||||
__attribute__((weak)) void process_combo_event(uint16_t combo_index, bool pressed) {}
|
||||
@ -151,7 +156,7 @@ static queued_combo_t combo_buffer[COMBO_BUFFER_LENGTH];
|
||||
static inline void release_combo(uint16_t combo_index, combo_t *combo) {
|
||||
if (combo->keycode) {
|
||||
keyrecord_t record = {
|
||||
.event = MAKE_KEYEVENT(KEYLOC_COMBO, KEYLOC_COMBO, false),
|
||||
.event = MAKE_COMBOEVENT(false),
|
||||
.keycode = combo->keycode,
|
||||
};
|
||||
#ifndef NO_ACTION_TAPPING
|
||||
@ -201,8 +206,8 @@ static inline uint16_t _get_combo_term(uint16_t combo_index, combo_t *combo) {
|
||||
void clear_combos(void) {
|
||||
uint16_t index = 0;
|
||||
longest_term = 0;
|
||||
for (index = 0; index < COMBO_LEN; ++index) {
|
||||
combo_t *combo = &key_combos[index];
|
||||
for (index = 0; index < combo_count(); ++index) {
|
||||
combo_t *combo = combo_get(index);
|
||||
if (!COMBO_ACTIVE(combo)) {
|
||||
RESET_COMBO_STATE(combo);
|
||||
}
|
||||
@ -239,7 +244,7 @@ static inline void dump_key_buffer(void) {
|
||||
process_record(record);
|
||||
#endif
|
||||
}
|
||||
record->event.time = 0;
|
||||
record->event.type = TICK_EVENT;
|
||||
|
||||
#if defined(CAPS_WORD_ENABLE) && defined(AUTO_SHIFT_ENABLE)
|
||||
// Edge case: preserve the weak Left Shift mod if both Caps Word and
|
||||
@ -293,7 +298,7 @@ void drop_combo_from_buffer(uint16_t combo_index) {
|
||||
queued_combo_t *qcombo = &combo_buffer[i];
|
||||
|
||||
if (qcombo->combo_index == combo_index) {
|
||||
combo_t *combo = &key_combos[combo_index];
|
||||
combo_t *combo = combo_get(combo_index);
|
||||
DISABLE_COMBO(combo);
|
||||
|
||||
if (i == combo_buffer_read) {
|
||||
@ -339,8 +344,9 @@ void apply_combo(uint16_t combo_index, combo_t *combo) {
|
||||
KEY_STATE_DOWN(state, key_index);
|
||||
if (ALL_COMBO_KEYS_ARE_DOWN(state, key_count)) {
|
||||
// this in the end executes the combo when the key_buffer is dumped.
|
||||
record->keycode = combo->keycode;
|
||||
record->event.key = MAKE_KEYPOS(KEYLOC_COMBO, KEYLOC_COMBO);
|
||||
record->keycode = combo->keycode;
|
||||
record->event.type = COMBO_EVENT;
|
||||
record->event.key = MAKE_KEYPOS(0, 0);
|
||||
|
||||
qrecord->combo_index = combo_index;
|
||||
ACTIVATE_COMBO(combo);
|
||||
@ -349,7 +355,7 @@ void apply_combo(uint16_t combo_index, combo_t *combo) {
|
||||
} else {
|
||||
// key was part of the combo but not the last one, "disable" it
|
||||
// by making it a TICK event.
|
||||
record->event.time = 0;
|
||||
record->event.type = TICK_EVENT;
|
||||
}
|
||||
}
|
||||
drop_combo_from_buffer(combo_index);
|
||||
@ -359,7 +365,7 @@ static inline void apply_combos(void) {
|
||||
// Apply all buffered normal combos.
|
||||
for (uint8_t i = combo_buffer_read; i != combo_buffer_write; INCREMENT_MOD(i)) {
|
||||
queued_combo_t *buffered_combo = &combo_buffer[i];
|
||||
combo_t * combo = &key_combos[buffered_combo->combo_index];
|
||||
combo_t * combo = combo_get(buffered_combo->combo_index);
|
||||
|
||||
#ifdef COMBO_MUST_TAP_PER_COMBO
|
||||
if (get_combo_must_tap(buffered_combo->combo_index, combo)) {
|
||||
@ -464,7 +470,7 @@ static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t *
|
||||
combo_t *drop = NULL;
|
||||
for (uint8_t combo_buffer_i = combo_buffer_read; combo_buffer_i != combo_buffer_write; INCREMENT_MOD(combo_buffer_i)) {
|
||||
queued_combo_t *qcombo = &combo_buffer[combo_buffer_i];
|
||||
combo_t * buffered_combo = &key_combos[qcombo->combo_index];
|
||||
combo_t * buffered_combo = combo_get(qcombo->combo_index);
|
||||
|
||||
if ((drop = overlaps(buffered_combo, combo))) {
|
||||
DISABLE_COMBO(drop);
|
||||
@ -570,8 +576,8 @@ bool process_combo(uint16_t keycode, keyrecord_t *record) {
|
||||
}
|
||||
#endif
|
||||
|
||||
for (uint16_t idx = 0; idx < COMBO_LEN; ++idx) {
|
||||
combo_t *combo = &key_combos[idx];
|
||||
for (uint16_t idx = 0; idx < combo_count(); ++idx) {
|
||||
combo_t *combo = combo_get(idx);
|
||||
is_combo_key |= process_single_combo(combo, keycode, record, idx);
|
||||
no_combo_keys_pressed = no_combo_keys_pressed && (NO_COMBO_KEYS_ARE_DOWN || COMBO_ACTIVE(combo) || COMBO_DISABLED(combo));
|
||||
}
|
||||
|
Reference in New Issue
Block a user