summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGustaf Rydholm <gustaf.rydholm@gmail.com>2022-08-30 19:29:44 +0200
committerGustaf Rydholm <gustaf.rydholm@gmail.com>2022-08-30 19:29:44 +0200
commitd1d76a0a9a934cbff4d907ba432ccc4710528e50 (patch)
treed266c6cd7c35d72225e898fea99f6b6e13f3f2a0
parent50a41d1d0d42f7e87ad2d53860ec48e64d318cac (diff)
Update layer structure
Rework layer structure to make each layer have a clear purpose: - nav: vim style navigation - sym: symbols - num: numbers - fun: functional keys, bootloader mode, and tty support - media: media keys
-rw-r--r--aktersnurra/keymap.c60
-rw-r--r--aktersnurra/rules.mk1
-rw-r--r--aktersnurra/tap_dance.c81
-rw-r--r--aktersnurra/tap_dance.h17
4 files changed, 47 insertions, 112 deletions
diff --git a/aktersnurra/keymap.c b/aktersnurra/keymap.c
index 18cd7b6..2bf424f 100644
--- a/aktersnurra/keymap.c
+++ b/aktersnurra/keymap.c
@@ -2,7 +2,6 @@
// This is the canonical layout file for the Quantum project. If you want to add another keyboard,
#include QMK_KEYBOARD_H
-#include "tap_dance.h"
// Each layer gets a name for readability, which is then used in the keymap matrix below.
// The underscores don't mean anything - you can have a layer called STUFF or any other name.
@@ -19,25 +18,60 @@
#define KC_HE CTL_T(KC_E)
#define KC_HN SFT_T(KC_N)
+#define KC_ALT_CTL LALT(KC_LCTL)
+
+#define NAV LT(_NAV, KC_SPC)
+#define SYM LT(_SYM, KC_BSPC)
+#define NUM LT(_NUM, KC_TAB)
+
+enum { _COLEMAK_DH, _NAV, _NUM, _SYM, _FUN, _MEDIA } layers;
+enum { M_ESC } tap_dances;
+
+// Tap Dance Definitions
+qk_tap_dance_action_t tap_dance_actions[] = {
+ [M_ESC] = ACTION_TAP_DANCE_DOUBLE(KC_M, KC_ESC)
+};
+
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[_COLEMAK_DH] = LAYOUT( /* COLEMAK MOD DH */
- KC_Q, KC_W, KC_F, KC_P, KC_B, KC_J, KC_L, KC_U, KC_Y, KC_SCLN,
- KC_HA, KC_HR, KC_HS, KC_HT, KC_G, TD(M_ESC), KC_HN, KC_HE, KC_HI, KC_HO,
- KC_Z, KC_X, KC_C, KC_D, KC_V, KC_K, KC_H, KC_COMM, KC_DOT, KC_SLSH,
- KC_ENT, TD(TD_LOWER), TD(TD_RAISE), KC_TAB
+ KC_Q, KC_W, KC_F, KC_P, KC_B, KC_J, KC_L, KC_U, KC_Y, KC_SCLN,
+ KC_HA, KC_HR, KC_HS, KC_HT, KC_G, TD(M_ESC), KC_HN, KC_HE, KC_HI, KC_HO,
+ KC_Z, KC_X, KC_C, KC_D, KC_V, KC_K, KC_H, KC_COMM, KC_DOT, KC_SLSH,
+ KC_ENT, NAV, SYM, NUM
),
- [_LOWER] = LAYOUT( /* [> LOWER <] */
- KC_GRV, KC_EXLM, KC_PERC, KC_DLR, KC_AT, KC_PIPE, KC_HASH, KC_ASTR, KC_AMPR, KC_CIRC,
- KC_TRNS, KC_LBRC, KC_LPRN, KC_TRNS, KC_QUOT, KC_DQT, KC_TRNS, KC_EQL, KC_MINS, KC_BSLS,
- KC_TRNS, KC_RBRC, KC_RPRN, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
+ [_NAV] = LAYOUT( /* [> Navigation layer <] */
+ KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_LBRC, KC_RBRC, KC_TRNS, KC_TRNS,
+ KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_LEFT, KC_DOWN, KC_UP, KC_RIGHT, KC_TRNS,
+ KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_LPRN, KC_RPRN, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_BSPC, KC_TRNS
),
- [_RAISE] = LAYOUT( /* [> RAISE <] */
- KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0,
- KC_TRNS, KC_MUTE, KC_VOLU, KC_VOLD, KC_MPLY, KC_LEFT, KC_DOWN, KC_UP, KC_RIGHT, KC_TRNS,
- KC_LCTL, KC_LALT, KC_TRNS, KC_TRNS, KC_MPRV, KC_MNXT, KC_TRNS, KC_F1, KC_F2, KC_F3,
+ [_SYM] = LAYOUT( /* [> Symbol layer <] */
+ KC_GRV, KC_EXLM, KC_PERC, KC_DLR, KC_AT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
+ KC_HASH, KC_QUOT, KC_ASTR, KC_MINS, KC_EQL, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
+ KC_SLSH, KC_BSLS, KC_AMPR, KC_CIRC, KC_PIPE, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_SPC, KC_TRNS, KC_TRNS
+ ),
+
+ [_NUM] = LAYOUT( /* [> Number layer <] */
+ KC_TRNS, KC_7, KC_8, KC_9, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
+ KC_TRNS, KC_4, KC_5, KC_6, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
+ KC_0, KC_1, KC_2, KC_3, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
+ MO(_MEDIA), MO(_FUN), KC_TRNS, KC_TRNS
+ ),
+
+ [_MEDIA] = LAYOUT( /* [> Media layer <] */
+ KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MPRV, KC_MPLY, KC_MNXT, KC_TRNS,
+ KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_VOLD, KC_MUTE, KC_VOLU, KC_TRNS,
+ KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
+ KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS
+ ),
+
+ [_FUN] = LAYOUT( /* [> Function layer <] */
+ KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, QK_BOOT,
+ KC_TRNS, KC_TRNS, KC_TRNS, KC_ALT_CTL, KC_TRNS, KC_TRNS, KC_F1, KC_F2, KC_F3, KC_TRNS,
+ KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
+ KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS
)
};
diff --git a/aktersnurra/rules.mk b/aktersnurra/rules.mk
index 9d95467..ef39eb0 100644
--- a/aktersnurra/rules.mk
+++ b/aktersnurra/rules.mk
@@ -1,4 +1,3 @@
BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite
TAP_DANCE_ENABLE = yes
BOOTLOADER = atmel-dfu
-SRC += tap_dance.c
diff --git a/aktersnurra/tap_dance.c b/aktersnurra/tap_dance.c
deleted file mode 100644
index 265ef0d..0000000
--- a/aktersnurra/tap_dance.c
+++ /dev/null
@@ -1,81 +0,0 @@
-#include "tap_dance.h"
-
-static td_state_t td_state;
-
-int cur_dance(qk_tap_dance_state_t *state) {
- if (state->count == 1) {
- if (state->interrupted || !state->pressed) {
- return SINGLE_TAP;
- } else {
- return SINGLE_HOLD;
- }
- }
- if (state->count == 2) {
- return DOUBLE_SINGLE_TAP;
- } else {
- return 3;
- }
-}
-
-void raise_finished(qk_tap_dance_state_t *state, void *user_data) {
- td_state = cur_dance(state);
- switch (td_state) {
- case SINGLE_TAP:
- register_code16(KC_BSPC);
- break;
- case SINGLE_HOLD:
- layer_on(_RAISE);
- break;
- case DOUBLE_SINGLE_TAP:
- tap_code16(KC_BSPC);
- register_code16(KC_BSPC);
- }
-}
-
-void raise_reset(qk_tap_dance_state_t *state, void *user_data) {
- switch (td_state) {
- case SINGLE_TAP:
- unregister_code16(KC_BSPC);
- break;
- case SINGLE_HOLD:
- layer_off(_RAISE);
- break;
- case DOUBLE_SINGLE_TAP:
- unregister_code16(KC_BSPC);
- }
-}
-
-void lower_finished(qk_tap_dance_state_t *state, void *user_data) {
- td_state = cur_dance(state);
- switch (td_state) {
- case SINGLE_TAP:
- register_code16(KC_SPC);
- break;
- case SINGLE_HOLD:
- layer_on(_LOWER);
- break;
- case DOUBLE_SINGLE_TAP:
- tap_code16(KC_SPC);
- register_code16(KC_SPC);
- }
-}
-
-void lower_reset(qk_tap_dance_state_t *state, void *user_data) {
- switch (td_state) {
- case SINGLE_TAP:
- unregister_code16(KC_SPC);
- break;
- case SINGLE_HOLD:
- layer_off(_LOWER);
- break;
- case DOUBLE_SINGLE_TAP:
- unregister_code16(KC_SPC);
- }
-}
-
-qk_tap_dance_action_t tap_dance_actions[] = {
- [M_ESC] = ACTION_TAP_DANCE_DOUBLE(KC_M, KC_ESC),
- [TD_RAISE] =
- ACTION_TAP_DANCE_FN_ADVANCED(NULL, raise_finished, raise_reset),
- [TD_LOWER] =
- ACTION_TAP_DANCE_FN_ADVANCED(NULL, lower_finished, lower_reset)};
diff --git a/aktersnurra/tap_dance.h b/aktersnurra/tap_dance.h
deleted file mode 100644
index 5c7ec14..0000000
--- a/aktersnurra/tap_dance.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#pragma once
-
-#include QMK_KEYBOARD_H
-
-typedef enum { _COLEMAK_DH, _LOWER, _RAISE } layers;
-
-typedef enum { SINGLE_TAP, SINGLE_HOLD, DOUBLE_SINGLE_TAP } td_state_t;
-
-typedef enum { M_ESC, TD_LOWER, TD_RAISE } tap_dances;
-
-int cur_dance(qk_tap_dance_state_t *state);
-
-void raise_finished(qk_tap_dance_state_t *state, void *user_data);
-void raise_reset(qk_tap_dance_state_t *state, void *user_data);
-
-void lower_finished(qk_tap_dance_state_t *state, void *user_data);
-void lower_reset(qk_tap_dance_state_t *state, void *user_data);