1 /* Copyright 2017 Brian Fong
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 #include QMK_KEYBOARD_H
18 // Each layer gets a name for readability, which is then used in the keymap matrix below.
19 // The underscores don't mean anything - you can have a layer called STUFF or any other name.
20 // Layer names don't all need to be of the same length, obviously, and you can also skip them
21 // entirely and just use numbers.
27 // Readability keycodes
28 #define _______ KC_TRNS
31 /////////////// TAP DANCE SECTION START ///////////////
32 //Tap Dance Declarations (list of my tap dance configurations)
40 ///// QUAD FUNCTION TAP DANCE GENERAL SETUP SECTION START /////
41 ///// (no need to edit this section) /////
42 //Enums used to clearly convey the state of the tap dance
48 DOUBLE_SINGLE_TAP = 5 //send SINGLE_TAP twice - NOT DOUBLE_TAP
49 // Add more enums here if you want for triple, quadruple, etc.
57 int cur_dance (qk_tap_dance_state_t *state) {
58 if (state->count == 1) {
59 //If count = 1, and it has been interrupted - it doesn't matter if it is pressed or not: Send SINGLE_TAP
60 if (state->interrupted || !state->pressed) return SINGLE_TAP;
61 if (state->interrupted) return SINGLE_TAP;
62 else return SINGLE_HOLD;
64 //If count = 2, and it has been interrupted - assume that user is trying to type the letter associated
66 else if (state->count == 2) {
67 if (state->interrupted) return DOUBLE_SINGLE_TAP;
68 else if (state->pressed) return DOUBLE_HOLD;
69 else return DOUBLE_TAP;
71 else return 6; //magic number. At some point this method will expand to work for more presses
73 ///// QUAD FUNCTION TAP DANCE GENERAL SETUP SECTION END /////
74 ///// QUAD FUNCTION TAP DANCE PERSONALIZATION SECTION START /////
75 //instantialize an instance of 'tap' for the 'ENT' tap dance.
76 static tap ENTtap_state = {
77 .is_press_action = true,
81 void ENT_finished (qk_tap_dance_state_t *state, void *user_data) {
82 ENTtap_state.state = cur_dance(state);
83 switch (ENTtap_state.state) {
84 case SINGLE_TAP: register_code(KC_SPC); break;
85 case SINGLE_HOLD: register_code(KC_LSFT); break;
86 case DOUBLE_TAP: register_code(KC_ENT); break;
87 case DOUBLE_HOLD: register_code(KC_NO); break; // setting double hold to do nothing (change this if you want)
88 case DOUBLE_SINGLE_TAP: register_code(KC_SPC); unregister_code(KC_SPC); register_code(KC_SPC);
89 //Last case is for fast typing. Assuming your key is `f`:
90 //For example, when typing the word `buffer`, and you want to make sure that you send `ff` and not `Esc`.
91 //In order to type `ff` when typing fast, the next character will have to be hit within the `TAPPING_TERM`, which by default is 200ms.
95 void ENT_reset (qk_tap_dance_state_t *state, void *user_data) {
96 switch (ENTtap_state.state) {
97 case SINGLE_TAP: unregister_code(KC_SPC); break;
98 case SINGLE_HOLD: unregister_code(KC_LSFT); break;
99 case DOUBLE_TAP: unregister_code(KC_ENT); break;
100 case DOUBLE_HOLD: unregister_code(KC_NO);
101 case DOUBLE_SINGLE_TAP: unregister_code(KC_SPC);
103 ENTtap_state.state = 0;
106 //instanalize an instance of 'tap' for the 'DEL' tap dance.
107 static tap DELtap_state = {
108 .is_press_action = true,
112 void DEL_finished (qk_tap_dance_state_t *state, void *user_data) {
113 DELtap_state.state = cur_dance(state);
114 switch (DELtap_state.state) {
115 case SINGLE_TAP: register_code(KC_BSPC); break;
116 case SINGLE_HOLD: register_code(KC_LCTL); break;
117 case DOUBLE_TAP: register_code(KC_DEL); break;
118 case DOUBLE_HOLD: register_code(KC_NO); break;
119 case DOUBLE_SINGLE_TAP: register_code(KC_BSPC); unregister_code(KC_BSPC); register_code(KC_BSPC);
123 void DEL_reset (qk_tap_dance_state_t *state, void *user_data) {
124 switch (DELtap_state.state) {
125 case SINGLE_TAP: unregister_code(KC_BSPC); break;
126 case SINGLE_HOLD: unregister_code(KC_LCTL); break;
127 case DOUBLE_TAP: unregister_code(KC_DEL); break;
128 case DOUBLE_HOLD: unregister_code(KC_NO);
129 case DOUBLE_SINGLE_TAP: unregister_code(KC_BSPC);
131 DELtap_state.state = 0;
133 ///// QUAD FUNCTION TAP DANCE PERSONALIZATION SECTION END /////
135 //Tap Dance Definitions
136 //THIS SECTION HAS TO BE AT THE END OF THE TAP DANCE SECTION
137 qk_tap_dance_action_t tap_dance_actions[] = {
138 [TD_SFT_CAPS] = ACTION_TAP_DANCE_DOUBLE(KC_LSFT, KC_CAPS)
139 // Other declarations would go here, separated by commas, if you have them
140 ,[TD_Q_ESC] = ACTION_TAP_DANCE_DOUBLE(KC_Q, KC_ESC)
141 ,[ENT_TAP_DANCE] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, ENT_finished, ENT_reset)
142 ,[DEL_TAP_DANCE] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, DEL_finished, DEL_reset)
145 //In Layer declaration, add tap dance item in place of a key code
148 ///////////// TAP DANCE SECTION END ///////////////
150 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
153 * .-----------------------------------------------------------------------------------------.
154 * | Q//ESC | W | E | R | T | Y | U | I | O | P |
155 * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
156 * | A | S | D | F | G | H | J | K | L | ENTER |
157 * | | | | | | | | | |SFThold |
158 * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
159 * | Z | X | C | V/NUM | B/ETC | N | M/DIR | ,/GUI | ./ALT | BKSC |
160 * | SFThold| | | | | | | | |CTRLhold|
161 * '-----------------------------------------------------------------------------------------'
163 [_QW] = LAYOUT_ortho_3x10( /* Qwerty*/
164 TD(TD_Q_ESC), KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P,
165 KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, SFT_T(KC_SPC),
166 SFT_T(KC_Z), KC_X, KC_C, LT(NUM, KC_V), LT(ETC, KC_B), KC_N, LT(DIR, KC_M), GUI_T(KC_COMM), ALT_T(KC_DOT), CTL_T(KC_BSPC)
170 * Directional Modifiers
171 * .-----------------------------------------------------------------------------------------.
172 * | TAB | up | | INS | CTRL | SHIFT | PgUp | HOME | - | = |
173 * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
174 * | left | down | right | PrScr | SHIFT | CTRL | PgDn | END | [ | ] |
175 * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
176 * | P-Brk | | | | | | | RGUI | ALT | / |
177 * '-----------------------------------------------------------------------------------------'
179 [DIR] = LAYOUT_ortho_3x10( /* Directional Modifiers */
180 KC_TAB, KC_UP, _______, KC_INS, KC_LCTL, KC_RSFT, KC_PGUP, KC_HOME, KC_MINS, KC_EQL,
181 KC_LEFT, KC_DOWN, KC_RGHT, KC_PSCR, KC_LSFT, KC_RCTL, KC_PGDN, KC_END, KC_LBRC, KC_RBRC,
182 KC_PAUS, _______, _______, _______, _______, _______, _______, KC_RGUI, KC_LALT, KC_SLSH
187 * .-----------------------------------------------------------------------------------------.
188 * | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 |
189 * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
190 * | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 |
191 * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
192 * | F11 | F12 | | | | ENTER | SHIFT | GUI | ./ALT | BKSC |
193 * | | | | | | | | | |CTRLhold|
194 * '-----------------------------------------------------------------------------------------'
196 [NUM] = LAYOUT_ortho_3x10 ( /* Numbers */
197 KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10,
198 KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0,
199 KC_F11, KC_F12, _______, _______, _______, KC_ENT, KC_RSFT, KC_RGUI, ALT_T(KC_DOT), CTL_T(KC_BSPC)
204 * .-----------------------------------------------------------------------------------------.
205 * | ` | mUP | | | RESET | SHIFT | mUp | mDown | | \ |
206 * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
207 * | mLeft | mDown | mRight | | SHIFT | mBtn3 | mBtn1 | mBtn2 | ; | ' |
208 * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
209 * | Sft//Cp| | | | | C-A-D | | | ALT | DEL |
210 * '-----------------------------------------------------------------------------------------'
212 [ETC] = LAYOUT_ortho_3x10( /* ETC */
213 KC_GRV, KC_MS_U, _______, _______, RESET, KC_RSFT, KC_WH_U, KC_WH_D, _______, KC_BSLS,
214 KC_MS_L, KC_MS_D, KC_MS_R, _______, KC_LSFT, KC_BTN3, KC_BTN1, KC_BTN2, KC_SCLN, KC_QUOT,
215 TD(TD_SFT_CAPS), _______, _______, _______, _______, LALT(LCTL(KC_DEL)), _______, _______, KC_LALT, KC_DEL