vial: restore dynamic combo functionality
This commit is contained in:
parent
cf548ab9e6
commit
d5d40132a3
@ -522,7 +522,7 @@ ifeq ($(strip $(QMK_SETTINGS)), yes)
|
||||
endif
|
||||
AUTO_SHIFT_ENABLE := yes
|
||||
SRC += $(QUANTUM_DIR)/qmk_settings.c
|
||||
OPT_DEFS += -DQMK_SETTINGS -DAUTO_SHIFT_NO_SETUP -DTAPPING_TERM_PER_KEY -DPERMISSIVE_HOLD_PER_KEY -DIGNORE_MOD_TAP_INTERRUPT_PER_KEY -DTAPPING_FORCE_HOLD_PER_KEY -DRETRO_TAPPING_PER_KEY
|
||||
OPT_DEFS += -DQMK_SETTINGS -DAUTO_SHIFT_NO_SETUP -DTAPPING_TERM_PER_KEY -DPERMISSIVE_HOLD_PER_KEY -DIGNORE_MOD_TAP_INTERRUPT_PER_KEY -DTAPPING_FORCE_HOLD_PER_KEY -DRETRO_TAPPING_PER_KEY -DCOMBO_TERM_PER_COMBO
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(DIP_SWITCH_ENABLE)), yes)
|
||||
|
@ -18,6 +18,12 @@
|
||||
#include "process_combo.h"
|
||||
#include "action_tapping.h"
|
||||
|
||||
#ifdef VIAL_COMBO_ENABLE
|
||||
#include "dynamic_keymap.h"
|
||||
/* 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];
|
||||
@ -212,8 +218,8 @@ static inline void dump_key_buffer(void) {
|
||||
static inline void _find_key_index_and_count(const uint16_t *keys, uint16_t keycode, uint16_t *key_index, uint8_t *key_count) {
|
||||
while (true) {
|
||||
uint16_t key = pgm_read_word(&keys[*key_count]);
|
||||
if (keycode == key) *key_index = *key_count;
|
||||
if (COMBO_END == key) break;
|
||||
if (keycode == key) *key_index = *key_count;
|
||||
(*key_count)++;
|
||||
}
|
||||
}
|
||||
|
@ -175,3 +175,7 @@ bool get_tapping_force_hold(uint16_t keycode, keyrecord_t *record) {
|
||||
bool get_retro_tapping(uint16_t keycode, keyrecord_t *record) {
|
||||
return QS.tapping & 8;
|
||||
}
|
||||
|
||||
uint16_t get_combo_term(uint16_t index, combo_t *combo) {
|
||||
return QS.combo_term;
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ static void reload_tap_dance(void);
|
||||
#endif
|
||||
|
||||
#ifdef VIAL_COMBO_ENABLE
|
||||
static void init_combo(void);
|
||||
static void reload_combo(void);
|
||||
#endif
|
||||
|
||||
void vial_init(void) {
|
||||
@ -63,7 +63,7 @@ void vial_init(void) {
|
||||
reload_tap_dance();
|
||||
#endif
|
||||
#ifdef VIAL_COMBO_ENABLE
|
||||
init_combo();
|
||||
reload_combo();
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -246,6 +246,7 @@ void vial_handle_cmd(uint8_t *msg, uint8_t length) {
|
||||
vial_combo_entry_t entry;
|
||||
memcpy(&entry, &msg[4], sizeof(entry));
|
||||
msg[0] = dynamic_keymap_set_combo(idx, &entry);
|
||||
reload_combo();
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
@ -493,22 +494,23 @@ static void reload_tap_dance(void) {
|
||||
|
||||
#ifdef VIAL_COMBO_ENABLE
|
||||
combo_t key_combos[VIAL_COMBO_ENTRIES];
|
||||
uint16_t key_combos_keys[VIAL_COMBO_ENTRIES][5];
|
||||
|
||||
static void init_combo(void) {
|
||||
static void reload_combo(void) {
|
||||
/* initialize with all keys = COMBO_END */
|
||||
memset(key_combos_keys, 0, sizeof(key_combos_keys));
|
||||
memset(key_combos, 0, sizeof(key_combos));
|
||||
|
||||
/* reload from eeprom */
|
||||
for (size_t i = 0; i < VIAL_COMBO_ENTRIES; ++i) {
|
||||
key_combos[i].keys = (void*)(uintptr_t)i;
|
||||
uint16_t *seq = key_combos_keys[i];
|
||||
key_combos[i].keys = seq;
|
||||
|
||||
vial_combo_entry_t entry;
|
||||
if (dynamic_keymap_get_combo(i, &entry) == 0) {
|
||||
memcpy(seq, entry.input, sizeof(entry.input));
|
||||
key_combos[i].keycode = entry.output;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void process_combo_event(uint16_t combo_index, bool pressed) {
|
||||
vial_combo_entry_t entry;
|
||||
if (dynamic_keymap_get_combo(combo_index, &entry) != 0)
|
||||
return;
|
||||
|
||||
if (pressed)
|
||||
vial_keycode_down(entry.output);
|
||||
else
|
||||
vial_keycode_up(entry.output);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user