vial/tap-dance: initial implementation
This commit is contained in:
@ -78,7 +78,7 @@ static pin_t encoders_pad_a[] = ENCODERS_PAD_A;
|
||||
|
||||
#define VIAL_QMK_SETTINGS_EEPROM_ADDR (VIAL_ENCODERS_EEPROM_ADDR + VIAL_ENCODERS_SIZE)
|
||||
|
||||
// QMK settings area is just past encoders, or dynamic keymaps if encoders aren't enabled
|
||||
// QMK settings area is just past encoders
|
||||
#ifdef QMK_SETTINGS
|
||||
#include "qmk_settings.h"
|
||||
#define VIAL_QMK_SETTINGS_SIZE (sizeof(qmk_settings_t))
|
||||
@ -86,9 +86,17 @@ static pin_t encoders_pad_a[] = ENCODERS_PAD_A;
|
||||
#define VIAL_QMK_SETTINGS_SIZE 0
|
||||
#endif
|
||||
|
||||
// Dynamic macro starts after encoders, or dynamic keymaps if encoders aren't enabled
|
||||
#define VIAL_TAP_DANCE_EEPROM_ADDR (VIAL_QMK_SETTINGS_EEPROM_ADDR + VIAL_QMK_SETTINGS_SIZE)
|
||||
|
||||
#ifdef VIAL_TAP_DANCE_ENABLE
|
||||
#define VIAL_TAP_DANCE_SIZE (sizeof(vial_tap_dance_entry_t) * VIAL_TAP_DANCE_ENTRIES)
|
||||
#else
|
||||
#define VIAL_TAP_DANCE_SIZE 0
|
||||
#endif
|
||||
|
||||
// Dynamic macro starts after tap-dance
|
||||
#ifndef DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR
|
||||
# define DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR (VIAL_QMK_SETTINGS_EEPROM_ADDR + VIAL_QMK_SETTINGS_SIZE)
|
||||
# define DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR (VIAL_TAP_DANCE_EEPROM_ADDR + VIAL_TAP_DANCE_SIZE)
|
||||
#endif
|
||||
|
||||
// Sanity check that dynamic keymaps fit in available EEPROM
|
||||
@ -185,6 +193,28 @@ void dynamic_keymap_set_qmk_settings(uint16_t offset, uint8_t value) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef VIAL_TAP_DANCE_ENABLE
|
||||
int dynamic_keymap_get_tap_dance(uint8_t index, vial_tap_dance_entry_t *entry) {
|
||||
if (index >= VIAL_TAP_DANCE_ENTRIES)
|
||||
return -1;
|
||||
|
||||
void *address = (void*)(VIAL_TAP_DANCE_EEPROM_ADDR + index * sizeof(vial_tap_dance_entry_t));
|
||||
eeprom_read_block(entry, address, sizeof(vial_tap_dance_entry_t));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dynamic_keymap_set_tap_dance(uint8_t index, const vial_tap_dance_entry_t *entry) {
|
||||
if (index >= VIAL_TAP_DANCE_ENTRIES)
|
||||
return -1;
|
||||
|
||||
void *address = (void*)(VIAL_TAP_DANCE_EEPROM_ADDR + index * sizeof(vial_tap_dance_entry_t));
|
||||
eeprom_write_block(entry, address, sizeof(vial_tap_dance_entry_t));
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(VIAL_ENCODERS_ENABLE) && defined(VIAL_ENCODER_DEFAULT)
|
||||
static const uint16_t PROGMEM vial_encoder_default[] = VIAL_ENCODER_DEFAULT;
|
||||
_Static_assert(sizeof(vial_encoder_default)/sizeof(*vial_encoder_default) == 2 * DYNAMIC_KEYMAP_LAYER_COUNT * NUMBER_OF_ENCODERS,
|
||||
@ -225,6 +255,13 @@ void dynamic_keymap_reset(void) {
|
||||
qmk_settings_reset();
|
||||
#endif
|
||||
|
||||
#ifdef VIAL_TAP_DANCE_ENABLE
|
||||
vial_tap_dance_entry_t td = { KC_NO, KC_NO, KC_NO, KC_NO, TAPPING_TERM };
|
||||
for (size_t i = 0; i < VIAL_TAP_DANCE_ENTRIES; ++i) {
|
||||
dynamic_keymap_set_tap_dance(i, &td);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef VIAL_ENABLE
|
||||
/* re-lock the keyboard */
|
||||
vial_unlocked = vial_unlocked_prev;
|
||||
|
Reference in New Issue
Block a user