From 8ccef55b3ef657f4dd41246bff9528bdc83e15e4 Mon Sep 17 00:00:00 2001 From: Ilya Zhuravlev Date: Sat, 3 Jul 2021 23:12:12 -0400 Subject: [PATCH] vial/combo: prototype --- common_features.mk | 1 + quantum/process_keycode/process_combo.c | 4 ++++ quantum/process_keycode/process_combo.h | 4 ++++ quantum/vial.c | 15 +++++++++++++++ quantum/vial.h | 16 ++++++++++++++++ 5 files changed, 40 insertions(+) diff --git a/common_features.mk b/common_features.mk index 7f406ed9e5..3e0c6e9983 100644 --- a/common_features.mk +++ b/common_features.mk @@ -454,6 +454,7 @@ endif ifeq ($(strip $(VIAL_ENABLE)), yes) TAP_DANCE_ENABLE ?= yes + COMBO_ENABLE ?= yes SRC += $(QUANTUM_DIR)/vial.c EXTRAINCDIRS += $(KEYMAP_OUTPUT) OPT_DEFS += -DVIAL_ENABLE -DNO_DEBUG diff --git a/quantum/process_keycode/process_combo.c b/quantum/process_keycode/process_combo.c index f38d7d47a0..d2f52edd2e 100644 --- a/quantum/process_keycode/process_combo.c +++ b/quantum/process_keycode/process_combo.c @@ -126,6 +126,10 @@ bool process_combo(uint16_t keycode, keyrecord_t *record) { drop_buffer = false; bool no_combo_keys_pressed = true; + if (keycode == KC_NO) { + return true; + } + if (keycode == CMB_ON && record->event.pressed) { combo_enable(); return true; diff --git a/quantum/process_keycode/process_combo.h b/quantum/process_keycode/process_combo.h index e51a2f1f4e..50a5de24c1 100644 --- a/quantum/process_keycode/process_combo.h +++ b/quantum/process_keycode/process_combo.h @@ -16,6 +16,10 @@ #pragma once +#ifdef VIAL_ENABLE +#include "vial.h" +#endif + #include "progmem.h" #include "quantum.h" #include diff --git a/quantum/vial.c b/quantum/vial.c index 754832cb1c..9619fbb967 100644 --- a/quantum/vial.c +++ b/quantum/vial.c @@ -200,6 +200,7 @@ void vial_handle_cmd(uint8_t *msg, uint8_t length) { case dynamic_vial_get_number_of_entries: { memset(msg, 0, length); msg[0] = VIAL_TAP_DANCE_ENTRIES; + msg[1] = VIAL_COMBO_ENTRIES; break; } case dynamic_vial_tap_dance_get: { @@ -459,3 +460,17 @@ static void reload_tap_dance(void) { } } #endif + +#ifdef VIAL_COMBO_ENABLE +const uint16_t PROGMEM test_combo[] = {KC_X, KC_Z, COMBO_END}; +combo_t key_combos[COMBO_COUNT] = {COMBO_ACTION(test_combo)}; + +void process_combo_event(uint16_t combo_index, bool pressed) { + uprintf("combo event %d\n", combo_index); + if (pressed) + vial_keycode_down(0x5F12); + else + vial_keycode_up(0x5F12); +} + +#endif diff --git a/quantum/vial.h b/quantum/vial.h index 84ae0476b8..968f878ef3 100644 --- a/quantum/vial.h +++ b/quantum/vial.h @@ -79,3 +79,19 @@ _Static_assert(sizeof(vial_tap_dance_entry_t) == 10, "Unexpected size of the via #undef VIAL_TAP_DANCE_ENTRIES #define VIAL_TAP_DANCE_ENTRIES 0 #endif + +#ifdef COMBO_ENABLE +#define VIAL_COMBO_ENABLE + +#ifndef VIAL_COMBO_ENTRIES +#define VIAL_COMBO_ENTRIES 16 +#endif + +/* also to catch wrong include order in e.g. process_combo.h */ +#ifdef COMBO_COUNT +#error COMBO_COUNT redefined - define VIAL_COMBO_ENTRIES instead +#endif + +#define COMBO_COUNT VIAL_COMBO_ENTRIES + +#endif