diff options
author | Danilo Vulicevic <danilo.vulicevic@yahoo.com> | 2019-02-14 21:09:27 +0100 |
---|---|---|
committer | Drashna Jaelre <drashna@live.com> | 2019-02-14 21:09:27 +0100 |
commit | 1e6797b4e7d888f0c0449e3cd577dc83eb4c4525 (patch) | |
tree | 054868cb8b176df99abdb91b3893e241727eaaf5 | |
parent | ce465c084bfdfb3dbd24414397b2542176da423d (diff) | |
download | qmk_firmware-1e6797b4e7d888f0c0449e3cd577dc83eb4c4525.tar.gz qmk_firmware-1e6797b4e7d888f0c0449e3cd577dc83eb4c4525.tar.xz |
[Keymap] Add my personal userspace and update my keymaps (#5128)
* Add billypython userspace and dz60 keymap
* Disable Bootmagic in dz60:billypython keymap
* Update whitefox:billypython keymap with userspace changes
Also remove numpad layer
-rw-r--r-- | keyboards/dz60/keymaps/billypython/config.h | 3 | ||||
-rw-r--r-- | keyboards/dz60/keymaps/billypython/keymap.c | 46 | ||||
-rw-r--r-- | keyboards/dz60/keymaps/billypython/rules.mk | 8 | ||||
-rw-r--r-- | keyboards/whitefox/keymaps/billypython/config.h | 16 | ||||
-rw-r--r-- | keyboards/whitefox/keymaps/billypython/keymap.c | 133 | ||||
-rw-r--r-- | keyboards/whitefox/keymaps/billypython/rules.mk | 9 | ||||
-rw-r--r-- | users/billypython/billypython.c | 32 | ||||
-rw-r--r-- | users/billypython/billypython.h | 34 | ||||
-rw-r--r-- | users/billypython/config.h | 19 | ||||
-rw-r--r-- | users/billypython/rules.mk | 6 | ||||
-rw-r--r-- | users/billypython/tap_dance.c | 33 | ||||
-rw-r--r-- | users/billypython/tap_dance.h | 9 |
12 files changed, 202 insertions, 146 deletions
diff --git a/keyboards/dz60/keymaps/billypython/config.h b/keyboards/dz60/keymaps/billypython/config.h new file mode 100644 index 000000000..4b511eb84 --- /dev/null +++ b/keyboards/dz60/keymaps/billypython/config.h @@ -0,0 +1,3 @@ +#pragma once + +#define LAYER_FN diff --git a/keyboards/dz60/keymaps/billypython/keymap.c b/keyboards/dz60/keymaps/billypython/keymap.c new file mode 100644 index 000000000..78fc55f6f --- /dev/null +++ b/keyboards/dz60/keymaps/billypython/keymap.c @@ -0,0 +1,46 @@ +#include QMK_KEYBOARD_H +#include "billypython.h" + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* Base layer + * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐ + * │Esc│ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 0 │ - │ = │ \ │ ` │ + * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┤ + * │ Tab │ Q │ W │ E │ R │ T │ Y │ U │ I │ O │ P │ [ │ ] │Bspc │ + * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤ + * │FnCaps│ A │ S │ D │ F │ G │ H │ J │ K │ L │ ; │ ' │ Enter │ + * ├──────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬───┬───┤ + * │LShift │ Z │ X │ C │ V │ B │ N │ M │ , │ . │ / │RSC│ ↑ │Del│ + * ├────┬──┴─┬─┴──┬┴───┴───┴───┴───┴───┴───┼───┼───┼───┼───┼───┤ + * │LCtl│LGui│LAlt│ Space │RAl│FnL│ ← │ ↓ │ → │ + * └────┴────┴────┴────────────────────────┴───┴───┴───┴───┴───┘ + */ + [L_BASE] = LAYOUT_directional( \ + KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSLS, KC_GRV, \ + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSPC, \ + FN_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, \ + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, RSF_RCT, KC_UP, KC_DEL, \ + KC_LCTL, KC_LGUI, KC_LALT, XXXXXXX, KC_SPC, XXXXXXX, KC_RALT, FN_FNLK, KC_LEFT, KC_DOWN, KC_RGHT \ + ), + + /* Function layer + * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐ + * │ │F1 │F2 │F3 │F4 │F5 │F6 │F7 │F8 │F9 │F10│F11│F12│ │PSc│ + * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┤ + * │ M4 │M2 │M↑ │M1 │M3 │M5 │ │PgU│ ↑ │PgD│Ply│Prv│Nxt│Clear│ + * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤ + * │ │M← │M↓ │M→ │MW↑│ │Hom│ ← │ ↓ │ → │End│ │ │ + * ├──────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬───┬───┤ + * │ │MA0│MA2│MW←│MW→│ │ │ │Vo-│Vo+│Mut│App│PgU│Ins│ + * ├────┬──┴─┬─┴──┬┴───┴───┴───┴───┴───┴───┼───┼───┼───┼───┼───┤ + * │ │ │ │ MW↓ │ │ │Hom│PgD│End│ + * └────┴────┴────┴────────────────────────┴───┴───┴───┴───┴───┘ + */ + [L_FN] = LAYOUT_directional( \ + _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, KC_PSCR, \ + KC_BTN4, KC_BTN2, KC_MS_U, KC_BTN1, KC_BTN3, KC_BTN5, _______, KC_PGUP, KC_UP, KC_PGDN, KC_MPLY, KC_MPRV, KC_MNXT, CLEAR, \ + _______, KC_MS_L, KC_MS_D, KC_MS_R, KC_WH_U, _______, KC_HOME, KC_LEFT, KC_DOWN, KC_RGHT, KC_END, _______, _______, \ + _______, KC_ACL0, KC_ACL2, KC_WH_L, KC_WH_R, _______, _______, _______, KC_VOLD, KC_VOLU, KC_MUTE, KC_APP, KC_PGUP, KC_INS, \ + _______, _______, _______, XXXXXXX, KC_WH_D, XXXXXXX, _______, _______, KC_HOME, KC_PGDN, KC_END \ + ), +}; diff --git a/keyboards/dz60/keymaps/billypython/rules.mk b/keyboards/dz60/keymaps/billypython/rules.mk new file mode 100644 index 000000000..332613604 --- /dev/null +++ b/keyboards/dz60/keymaps/billypython/rules.mk @@ -0,0 +1,8 @@ +BACKLIGHT_ENABLE = no +BOOTMAGIC_ENABLE = no +COMMAND_ENABLE = yes +CONSOLE_ENABLE = yes +EXTRAKEY_ENABLE = yes +MOUSEKEY_ENABLE = yes +RGBLIGHT_ENABLE = no +TAP_DANCE_ENABLE = yes diff --git a/keyboards/whitefox/keymaps/billypython/config.h b/keyboards/whitefox/keymaps/billypython/config.h index 275f8effb..4b511eb84 100644 --- a/keyboards/whitefox/keymaps/billypython/config.h +++ b/keyboards/whitefox/keymaps/billypython/config.h @@ -1,17 +1,3 @@ #pragma once -#define FORCE_NKRO - -#define MAGIC_KEY_LAYER0_ALT1 BSLS -#define MAGIC_KEY_BOOTLOADER ESC - -#define MOUSEKEY_DELAY 50 -#define MOUSEKEY_INTERVAL 15 -#define MOUSEKEY_MAX_SPEED 4 -#define MOUSEKEY_TIME_TO_MAX 50 -#define MOUSEKEY_WHEEL_MAX_SPEED 1 -#define MOUSEKEY_WHEEL_TIME_TO_MAX 50 - -#define PERMISSIVE_HOLD -#define TAPPING_TERM 200 -#define TAPPING_TOGGLE 2 +#define LAYER_FN diff --git a/keyboards/whitefox/keymaps/billypython/keymap.c b/keyboards/whitefox/keymaps/billypython/keymap.c index dfc7d6a96..79758de80 100644 --- a/keyboards/whitefox/keymaps/billypython/keymap.c +++ b/keyboards/whitefox/keymaps/billypython/keymap.c @@ -1,95 +1,5 @@ #include QMK_KEYBOARD_H - -#define TOP LCTL(KC_HOME) -#define BOTTOM LCTL(KC_END) - -#define FN MO(L_FN) -#define FN_CAPS LT(L_FN, KC_CAPS) -#define FN_FNLK TT(L_FN) - -#define RSF_RCT TD(TD_RSF_RCT) - -#define COMMA UC(0x002C) -#define L_PAREN UC(0x0028) -#define R_PAREN UC(0x0029) -#define EQUALS UC(0x003D) -#define TIMES UC(0x00D7) -#define DIVIDE UC(0x00F7) -#define MINUS UC(0x2212) - -void eeconfig_init_user(void) { - set_unicode_input_mode(UC_LNX); -} - -enum layers { - L_BASE, - L_FN, - L_NUMPAD, -}; - -enum custom_keycodes { - CLEAR = SAFE_RANGE, - NUMPAD, -}; - -bool process_record_user(uint16_t keycode, keyrecord_t *record) { - switch (keycode) { - case CLEAR: - if (record->event.pressed) { - SEND_STRING(SS_LCTRL("a") SS_TAP(X_DELETE)); - } - return false; - - case NUMPAD: - if (record->event.pressed) { - layer_invert(L_NUMPAD); - bool num_lock = host_keyboard_leds() & 1<<USB_LED_NUM_LOCK; - if (num_lock != (bool)IS_LAYER_ON(L_NUMPAD)) { - tap_code(KC_NLCK); // Toggle Num Lock to match layer state. - } - } - return false; - - default: - return true; - } -} - -#define ACTION_TAP_DANCE_DOUBLE_MODS(mod1, mod2) { \ - .fn = { td_double_mods_each, NULL, td_double_mods_reset }, \ - .user_data = &(qk_tap_dance_pair_t){ mod1, mod2 }, \ - } - -void td_double_mods_each(qk_tap_dance_state_t *state, void *user_data) { - qk_tap_dance_pair_t *mods = (qk_tap_dance_pair_t *)user_data; - // Single tap → mod1, double tap → mod2, triple tap etc. → mod1+mod2 - if (state->count == 1 || state->count == 3) { - register_code(mods->kc1); - } else if (state->count == 2) { - unregister_code(mods->kc1); - register_code(mods->kc2); - } - // Prevent tap dance from sending kc1 and kc2 as weak mods - state->weak_mods &= ~(MOD_BIT(mods->kc1) | MOD_BIT(mods->kc2)); -} - -void td_double_mods_reset(qk_tap_dance_state_t *state, void *user_data) { - qk_tap_dance_pair_t *mods = (qk_tap_dance_pair_t *)user_data; - if (state->count == 1 || state->count > 2) { - unregister_code(mods->kc1); - } - if (state->count >= 2) { - unregister_code(mods->kc2); - } -} - -enum tap_dance { - TD_RSF_RCT, -}; - -qk_tap_dance_action_t tap_dance_actions[] = { - [TD_RSF_RCT] = ACTION_TAP_DANCE_DOUBLE_MODS(KC_RSFT, KC_RCTL), -}; +#include "billypython.h" const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { /* Base layer @@ -106,11 +16,11 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * └────┴────┴────┴────────────────────────┴────┴────┘ └───┴───┴───┘ */ [L_BASE] = LAYOUT_truefox( \ - KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS,KC_EQL, KC_BSLS,KC_GRV, KC_PSCR, \ - KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC,KC_RBRC,KC_BSPC, KC_DEL, \ - FN_CAPS,KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN,KC_QUOT, KC_ENT, KC_PGUP, \ - KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM,KC_DOT, KC_SLSH,RSF_RCT, KC_UP, KC_PGDN, \ - KC_LCTL,KC_LGUI,KC_LALT, KC_SPC, KC_RALT,FN_FNLK, KC_LEFT,KC_DOWN,KC_RGHT \ + KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSLS, KC_GRV, KC_PSCR, \ + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSPC, KC_DEL, \ + FN_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_PGUP, \ + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, RSF_RCT, KC_UP, KC_PGDN, \ + KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, FN_FNLK, KC_LEFT, KC_DOWN, KC_RGHT \ ), /* Function layer @@ -127,31 +37,10 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * └────┴────┴────┴────────────────────────┴────┴────┘ └───┴───┴───┘ */ [L_FN] = LAYOUT_truefox( \ - _______,KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, NUMPAD, KC_SLCK,KC_PAUS, \ - KC_BTN4,KC_BTN2,KC_MS_U,KC_BTN1,KC_BTN3,KC_BTN5,_______,KC_PGUP,KC_UP, KC_PGDN,KC_MPLY,KC_MPRV,KC_MNXT,CLEAR, KC_INS, \ - _______,KC_MS_L,KC_MS_D,KC_MS_R,KC_WH_U,_______,KC_HOME,KC_LEFT,KC_DOWN,KC_RGHT,KC_END, _______, _______, TOP, \ - _______, KC_ACL0,KC_ACL2,KC_WH_L,KC_WH_R,_______,_______,_______,KC_VOLD,KC_VOLU,KC_MUTE,KC_APP, KC_PGUP,BOTTOM, \ - _______,_______,_______, KC_WH_D, _______,_______, KC_HOME,KC_PGDN,KC_END \ - ), - - /* Numpad layer - * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐ - * │Num│ │ │ │ │ │ │P7 │P8 │P9 │P- │ − │ = │Num│ │ │ - * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┼───┤ - * │ │ │ │ │ │ │ │P4 │P5 │P6 │P+ │ ( │ ) │ │ │ - * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┼───┤ - * │ │ │ │ │ │ │ │P1 │P2 │P3 │P* │ × │ PEnter │ │ - * ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────┬───┼───┤ - * │ │ │ │ │ │ │P0 │P0 │ , │P. │P/ │ ÷ │ │ │ - * ├────┬───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬─┬───┼───┼───┤ - * │ │ │ │ │ │ │ │ │ │ │ - * └────┴────┴────┴────────────────────────┴────┴────┘ └───┴───┴───┘ - */ - [L_NUMPAD] = LAYOUT_truefox( \ - NUMPAD, _______,_______,_______,_______,_______,_______,KC_P7, KC_P8, KC_P9, KC_PMNS,MINUS, EQUALS, NUMPAD, _______,_______, \ - _______,_______,_______,_______,_______,_______,_______,KC_P4, KC_P5, KC_P6, KC_PPLS,L_PAREN,R_PAREN,_______, _______, \ - _______,_______,_______,_______,_______,_______,_______,KC_P1, KC_P2, KC_P3, KC_PAST,TIMES, KC_PENT, _______, \ - _______, _______,_______,_______,_______,_______,KC_P0, KC_P0, COMMA, KC_PDOT,KC_PSLS,DIVIDE, _______,_______, \ - _______,_______,_______, _______, _______,_______, _______,_______,_______ \ + _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_NLCK, KC_SLCK, KC_PAUS, \ + KC_BTN4, KC_BTN2, KC_MS_U, KC_BTN1, KC_BTN3, KC_BTN5, _______, KC_PGUP, KC_UP, KC_PGDN, KC_MPLY, KC_MPRV, KC_MNXT, CLEAR, KC_INS, \ + _______, KC_MS_L, KC_MS_D, KC_MS_R, KC_WH_U, _______, KC_HOME, KC_LEFT, KC_DOWN, KC_RGHT, KC_END, _______, _______, TOP, \ + _______, KC_ACL0, KC_ACL2, KC_WH_L, KC_WH_R, _______, _______, _______, KC_VOLD, KC_VOLU, KC_MUTE, KC_APP, KC_PGUP, BOTTOM, \ + _______, _______, _______, KC_WH_D, _______, _______, KC_HOME, KC_PGDN, KC_END \ ), }; diff --git a/keyboards/whitefox/keymaps/billypython/rules.mk b/keyboards/whitefox/keymaps/billypython/rules.mk index 8fbc1f3af..133c7af54 100644 --- a/keyboards/whitefox/keymaps/billypython/rules.mk +++ b/keyboards/whitefox/keymaps/billypython/rules.mk @@ -1,15 +1,6 @@ -AUDIO_ENABLE = no BACKLIGHT_ENABLE = no -BLUETOOTH_ENABLE = no BOOTMAGIC_ENABLE = no COMMAND_ENABLE = yes CONSOLE_ENABLE = yes -EXTRAKEY_ENABLE = yes -MIDI_ENABLE = no -MOUSEKEY_ENABLE = yes -NKRO_ENABLE = yes -RGBLIGHT_ENABLE = no -SLEEP_LED_ENABLE = no TAP_DANCE_ENABLE = yes -UNICODE_ENABLE = yes VISUALIZER_ENABLE = no diff --git a/users/billypython/billypython.c b/users/billypython/billypython.c new file mode 100644 index 000000000..7bdfe33a4 --- /dev/null +++ b/users/billypython/billypython.c @@ -0,0 +1,32 @@ +#include "billypython.h" + +__attribute__((weak)) +bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { + return true; +} + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + if (!process_record_keymap(keycode, record)) { + return false; + } + + switch (keycode) { + case CLEAR: + if (record->event.pressed) { + SEND_STRING(SS_LCTRL("a") SS_TAP(X_DELETE)); + } + return false; + + default: + return true; + } +} + +__attribute__((weak)) +uint32_t layer_state_set_keymap(uint32_t state) { + return state; +} + +uint32_t layer_state_set_user(uint32_t state) { + return layer_state_set_keymap(state); +} diff --git a/users/billypython/billypython.h b/users/billypython/billypython.h new file mode 100644 index 000000000..4a444e978 --- /dev/null +++ b/users/billypython/billypython.h @@ -0,0 +1,34 @@ +#pragma once + +#include "quantum.h" + +#ifdef TAP_DANCE_ENABLE + #include "tap_dance.h" +#endif + +#ifdef LAYER_FN + #define FN MO(L_FN) + #define FN_CAPS LT(L_FN, KC_CAPS) + #define FN_FNLK TT(L_FN) +#endif + +#define TOP LCTL(KC_HOME) +#define BOTTOM LCTL(KC_END) + +enum keycodes_user { + CLEAR = SAFE_RANGE, + + RANGE_KEYMAP, +}; + +enum layers_user { + L_BASE, +#ifdef LAYER_FN + L_FN, +#endif + + L_RANGE_KEYMAP, +}; + +bool process_record_keymap(uint16_t keycode, keyrecord_t *record); +uint32_t layer_state_set_keymap(uint32_t state); diff --git a/users/billypython/config.h b/users/billypython/config.h new file mode 100644 index 000000000..705e6c934 --- /dev/null +++ b/users/billypython/config.h @@ -0,0 +1,19 @@ +#pragma once + +#define FORCE_NKRO + +#define MAGIC_KEY_BOOTLOADER B + +#define MOUSEKEY_DELAY 50 +#define MOUSEKEY_INTERVAL 15 +#define MOUSEKEY_MAX_SPEED 4 +#define MOUSEKEY_TIME_TO_MAX 50 +#define MOUSEKEY_WHEEL_MAX_SPEED 1 +#define MOUSEKEY_WHEEL_TIME_TO_MAX 50 + +#define NO_ACTION_FUNCTION +#define NO_ACTION_MACRO + +#define PERMISSIVE_HOLD +#define TAPPING_TERM 200 +#define TAPPING_TOGGLE 2 diff --git a/users/billypython/rules.mk b/users/billypython/rules.mk new file mode 100644 index 000000000..915323b49 --- /dev/null +++ b/users/billypython/rules.mk @@ -0,0 +1,6 @@ +SRC += billypython.c +ifeq ($(strip $(TAP_DANCE_ENABLE)), yes) + SRC += tap_dance.c +endif + +EXTRAFLAGS += -flto diff --git a/users/billypython/tap_dance.c b/users/billypython/tap_dance.c new file mode 100644 index 000000000..74ae16639 --- /dev/null +++ b/users/billypython/tap_dance.c @@ -0,0 +1,33 @@ +#include "tap_dance.h" + +#define ACTION_TAP_DANCE_DOUBLE_MODS(mod1, mod2) { \ + .fn = { td_double_mods_each, NULL, td_double_mods_reset }, \ + .user_data = &(qk_tap_dance_pair_t){ mod1, mod2 }, \ + } + +void td_double_mods_each(qk_tap_dance_state_t *state, void *user_data) { + qk_tap_dance_pair_t *mods = (qk_tap_dance_pair_t *)user_data; + // Single tap → mod1, double tap → mod2, triple tap etc. → mod1+mod2 + if (state->count == 1 || state->count == 3) { + register_code(mods->kc1); + } else if (state->count == 2) { + unregister_code(mods->kc1); + register_code(mods->kc2); + } + // Prevent tap dance from sending kc1 and kc2 as weak mods + state->weak_mods &= ~(MOD_BIT(mods->kc1) | MOD_BIT(mods->kc2)); +} + +void td_double_mods_reset(qk_tap_dance_state_t *state, void *user_data) { + qk_tap_dance_pair_t *mods = (qk_tap_dance_pair_t *)user_data; + if (state->count == 1 || state->count >= 3) { + unregister_code(mods->kc1); + } + if (state->count >= 2) { + unregister_code(mods->kc2); + } +} + +qk_tap_dance_action_t tap_dance_actions[] = { + [TD_RSF_RCT] = ACTION_TAP_DANCE_DOUBLE_MODS(KC_RSFT, KC_RCTL), +}; diff --git a/users/billypython/tap_dance.h b/users/billypython/tap_dance.h new file mode 100644 index 000000000..258198141 --- /dev/null +++ b/users/billypython/tap_dance.h @@ -0,0 +1,9 @@ +#pragma once + +#include "quantum.h" + +#define RSF_RCT TD(TD_RSF_RCT) + +enum tap_dance { + TD_RSF_RCT, +}; |