[Keyboard] Hub16 keymap bugfix (#9345)

This commit is contained in:
Josh Johnson 2020-06-15 19:17:30 +10:00 committed by GitHub
parent c029c5b187
commit da76734fe0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 13 deletions

View File

@ -81,8 +81,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define DEBOUNCE 20
/* ENCODER THINGS */
// #define NUMBER_OF_ENCODERS 2
// #define ENCODER_DIRECTION_FLIP
#define ENCODERS_PAD_A \
{ F6, B4 }
#define ENCODERS_PAD_B \

View File

@ -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);
}
}

View File

@ -1,8 +1,8 @@
# Hub16
Hub16 is a 16 Key Macro Pad with inbuilt USB 2.0 hub and dual rotary encoders.
Hub16 is a 16 Key Macro Pad with an inbuilt USB 2.0 hub and dual rotary encoders.
For more information regarding the keyboard, please visit the [Hub16 Webpage](https://www.joshajohnson.com/hub16-keyboard/) or [GitHub Repo](https://github.com/joshajohnson/Hub16).
For more information regarding the keyboard, please visit the [Hub16 Website](https://www.joshajohnson.com/hub16-keyboard/) or [GitHub Repo](https://github.com/joshajohnson/Hub16).
* Keyboard Maintainer: [Josh Johnson](https://github.com/joshajohnson)
* Hardware Supported: Hub16 PCB (atmega32u4)