From da76734fe0aba64140d4d127161cc4390776ffd7 Mon Sep 17 00:00:00 2001 From: Josh Johnson Date: Mon, 15 Jun 2020 19:17:30 +1000 Subject: [Keyboard] Hub16 keymap bugfix (#9345) --- keyboards/hub16/keymaps/default/keymap.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) (limited to 'keyboards/hub16/keymaps') diff --git a/keyboards/hub16/keymaps/default/keymap.c b/keyboards/hub16/keymaps/default/keymap.c index 2d12dba0d..d3cad67ae 100755 --- a/keyboards/hub16/keymaps/default/keymap.c +++ b/keyboards/hub16/keymaps/default/keymap.c @@ -21,16 +21,18 @@ // Keyboard Layers enum keyboard_layers{ _BASE = 0, - _CONTROL + _CTRL }; // Tap Dance Declarations -enum tap_dance { TD_TO_LED = 0, TD_TO_DEFAULT = 1 }; +void td_ctrl (qk_tap_dance_state_t *state, void *user_data); + +enum tap_dance { CTRL = 0, BASE = 1 }; qk_tap_dance_action_t tap_dance_actions[] = { - // Tap once for standard key, twice to toggle to control layer - [TD_TO_LED] = ACTION_TAP_DANCE_DUAL_ROLE(KC_P, _CONTROL), - [TD_TO_DEFAULT] = ACTION_TAP_DANCE_DUAL_ROLE(KC_P, _BASE)}; + // Tap once for standard key on base layer, twice to toggle to control layer + [CTRL] = ACTION_TAP_DANCE_FN(td_ctrl), + [BASE] = ACTION_TAP_DANCE_LAYER_MOVE(_______, _BASE)}; const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [_BASE] = LAYOUT( /* Base */ @@ -38,19 +40,19 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_A, KC_B, KC_C, KC_D, KC_E, KC_F, KC_G, KC_H, KC_I, KC_J, KC_K, KC_L, - KC_M, KC_N, KC_O, TD(TD_TO_LED) + KC_M, KC_N, KC_O, TD(CTRL) ), - [_CONTROL] = LAYOUT( /* LED Control */ + [_CTRL] = LAYOUT( /* Control */ KC_NO, KC_NO, _______, RGB_MOD, RGB_RMOD, RGB_TOG, RGB_VAD, RGB_VAI, RGB_HUD, RGB_HUI, RGB_SAD, RGB_SAI, _______, _______, - _______, _______, RESET, TD(TD_TO_DEFAULT) + _______, _______, RESET, TD(BASE) ), }; -// Keyboard is setup to 'warp' the pressed key with F24, +// Keyboard is setup to 'wrap' the pressed key with an unused Fxx key, // allowing for easy differentiation from a real keyboard. void encoder_update_user(uint8_t index, bool clockwise) { if (index == 0) { /* Left Encoder */ @@ -99,3 +101,15 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { } return true; } + +// Below works around TD() not running key press through process_record_user. +// Fixes bug of CTRL layer move key not being wrapped in by modifier on single tap +void td_ctrl (qk_tap_dance_state_t *state, void *user_data) { + if (state->count == 1) { + register_code(KC_WRAP); + tap_code(KC_P); + unregister_code(KC_WRAP); + } else if (state->count == 2) { + layer_move(_CTRL); + } +} \ No newline at end of file -- cgit v1.2.3