summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Shields <dshields@bats.com>2017-06-02 11:10:22 +0100
committerDaniel Shields <dshields@bats.com>2017-06-06 13:09:55 +0100
commitad7a5bdc4f2527f47ca22885e5d0b689fb8d4518 (patch)
treea48ec9c4141cd41c54b27cedc8f04f267b84eba7
parent5e18e4ab48f12881a102f71265aa598163d1e34b (diff)
Additional tap dance keys/functions for planck/keymap/dshields
-rw-r--r--keyboards/planck/keymaps/dshields/config.h20
-rw-r--r--keyboards/planck/keymaps/dshields/keymap.c55
2 files changed, 63 insertions, 12 deletions
diff --git a/keyboards/planck/keymaps/dshields/config.h b/keyboards/planck/keymaps/dshields/config.h
index 8fa078cd92..5f2810287b 100644
--- a/keyboards/planck/keymaps/dshields/config.h
+++ b/keyboards/planck/keymaps/dshields/config.h
@@ -16,17 +16,37 @@
#define MOUSEKEY_MAX_SPEED 7
#define MOUSEKEY_WHEEL_DELAY 0
+// dynamic macro keys
#define DM_PLAY DYN_MACRO_PLAY1
#define DM_STRT DYN_REC_START1
#define DM_STOP DYN_REC_STOP
+// one-shot layer keys
#define OSL_RSE OSL(RSE)
#define OSL_LWR OSL(LWR)
#define OSL_FUN OSL(FUN)
+// one-shot modifier keys
#define OSM_CTL OSM(MOD_LCTL)
#define OSM_ALT OSM(MOD_LALT)
#define OSM_SFT OSM(MOD_LSFT)
+// tap dance keys
+#define TD_SCLN TD(TDK_SCLN)
+#define TD_COMM TD(TDK_COMM)
+#define TD_DOT TD(TDK_DOT)
+#define TD_SLSH TD(TDK_SLSH)
+
+#define ACTION_TAP_DANCE_FN_KEYCODE(user_fn, kc) { \
+ .fn = { NULL, user_fn, NULL }, \
+ .user_data = (void *)&((qk_tap_dance_pair_t) { kc, 0 }) \
+}
+
+#define ACTION_TAP_DANCE_FN_KEYCODE2(user_fn, kc1, kc2) { \
+ .fn = { NULL, user_fn, NULL }, \
+ .user_data = (void *)&((qk_tap_dance_pair_t) { kc1, kc2 }) \
+}
+
+
#endif
diff --git a/keyboards/planck/keymaps/dshields/keymap.c b/keyboards/planck/keymaps/dshields/keymap.c
index ed7621c77b..09bdc3e407 100644
--- a/keyboards/planck/keymaps/dshields/keymap.c
+++ b/keyboards/planck/keymaps/dshields/keymap.c
@@ -8,7 +8,7 @@ extern keymap_config_t keymap_config;
enum planck_layers { DEF, LWR, RSE, FUN };
enum planck_keycodes { DYNAMIC_MACRO_RANGE = SAFE_RANGE };
-enum tap_dance_keys { TD_SCLN };
+enum tap_dance_keys { TDK_SCLN, TDK_COMM, TDK_DOT, TDK_SLSH };
#include "dynamic_macro.h"
@@ -26,8 +26,8 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
*/
[DEF] = {
{KC_Q, KC_W, KC_E, KC_R, KC_T, KC_ESC, KC_BSPC, KC_Y, KC_U, KC_I, KC_O, KC_P},
- {KC_A, KC_S, KC_D, KC_F, KC_G, KC_TAB, KC_ENT, KC_H, KC_J, KC_K, KC_L, TD(TD_SCLN)},
- {KC_Z, KC_X, KC_C, KC_V, KC_B, OSM_SFT, DM_PLAY, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH},
+ {KC_A, KC_S, KC_D, KC_F, KC_G, KC_TAB, KC_ENT, KC_H, KC_J, KC_K, KC_L, TD_SCLN},
+ {KC_Z, KC_X, KC_C, KC_V, KC_B, OSM_SFT, DM_PLAY, KC_N, KC_M, TD_COMM, TD_DOT, TD_SLSH},
{OSM_CTL, KC_LGUI, OSM_ALT, OSL_FUN, OSL_LWR, KC_SPC, KC_SPC, OSL_RSE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT}
},
/* Lower
@@ -42,10 +42,10 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* `-----------------------------------------------------------------------------------'
*/
[LWR] = {
- {KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, _______, _______, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN},
- {S(KC_GRV), _______, _______, _______, _______, _______, _______, KC_UNDS, KC_PLUS, _______, S(KC_LBRC), S(KC_RBRC)},
- {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, S(KC_QUOT), S(KC_BSLS)},
- {_______, _______, _______, _______, _______, _______, _______, _______, KC_HOME, KC_PGDN, KC_PGUP, KC_END}
+ {KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, _______, _______, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN},
+ {KC_TILD, _______, _______, _______, _______, _______, _______, KC_UNDS, KC_PLUS, _______, KC_LCBR, KC_RCBR},
+ {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_DQUO, KC_PIPE},
+ {_______, _______, _______, _______, _______, _______, _______, _______, KC_HOME, KC_PGDN, KC_PGUP, KC_END}
},
/* Raise
* ,-----------------------------------------------------------------------------------.
@@ -59,10 +59,10 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* `-----------------------------------------------------------------------------------'
*/
[RSE] = {
- {KC_1, KC_2, KC_3, KC_4, KC_5, _______, _______, KC_6, KC_7, KC_8, KC_9, KC_0},
- {KC_GRV, _______, _______, _______, _______, _______, _______, KC_MINS, KC_EQL, _______, KC_LBRC, KC_RBRC},
- {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_QUOT, KC_BSLS},
- {_______, _______, _______, _______, _______, _______, _______, _______, KC_HOME, KC_PGDN, KC_PGUP, KC_END}
+ {KC_1, KC_2, KC_3, KC_4, KC_5, _______, _______, KC_6, KC_7, KC_8, KC_9, KC_0},
+ {KC_GRV, _______, _______, _______, _______, _______, _______, KC_MINS, KC_EQL, _______, KC_LBRC, KC_RBRC},
+ {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_QUOT, KC_BSLS},
+ {_______, _______, _______, _______, _______, _______, _______, _______, KC_HOME, KC_PGDN, KC_PGUP, KC_END}
},
/* Function
* ,-----------------------------------------------------------------------------------.
@@ -84,8 +84,39 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
};
+void tap(uint16_t keycode) {
+ register_code16(keycode);
+ unregister_code16(keycode);
+};
+
+void tap_dance_triple(qk_tap_dance_state_t *state, void *user_data) {
+ qk_tap_dance_pair_t *pair = (qk_tap_dance_pair_t *)user_data;
+ uint16_t keycode = pair->kc1;
+
+ switch(state->count) {
+ case 2:
+ register_code(KC_LSFT);
+ tap(keycode);
+ unregister_code(KC_LSFT);
+ break;
+ case 3:
+ if (pair->kc2) {
+ keycode = pair->kc2;
+ }
+ tap(keycode);
+ tap(keycode);
+ break;
+ default:
+ tap(keycode);
+ break;
+ }
+}
+
qk_tap_dance_action_t tap_dance_actions[] = {
- [TD_SCLN] = ACTION_TAP_DANCE_DOUBLE(KC_SCLN, S(KC_SCLN)) // once for semi-colon, twice for colon
+ [TDK_SCLN] = ACTION_TAP_DANCE_FN_KEYCODE2(tap_dance_triple, KC_SCLN, KC_COLN),
+ [TDK_COMM] = ACTION_TAP_DANCE_FN_KEYCODE (tap_dance_triple, KC_COMM),
+ [TDK_DOT] = ACTION_TAP_DANCE_FN_KEYCODE (tap_dance_triple, KC_DOT),
+ [TDK_SLSH] = ACTION_TAP_DANCE_FN_KEYCODE (tap_dance_triple, KC_SLSH)
};
bool process_record_user(uint16_t keycode, keyrecord_t *record) {