diff options
Diffstat (limited to 'docs/feature_tap_dance.md')
| -rw-r--r-- | docs/feature_tap_dance.md | 38 |
1 files changed, 9 insertions, 29 deletions
diff --git a/docs/feature_tap_dance.md b/docs/feature_tap_dance.md index 93d190883..f2f274944 100644 --- a/docs/feature_tap_dance.md +++ b/docs/feature_tap_dance.md | |||
| @@ -26,6 +26,8 @@ This array specifies what actions shall be taken when a tap-dance key is in acti | |||
| 26 | 26 | ||
| 27 | The first option is enough for a lot of cases, that just want dual roles. For example, `ACTION_TAP_DANCE_DOUBLE(KC_SPC, KC_ENT)` will result in `Space` being sent on single-tap, `Enter` otherwise. | 27 | The first option is enough for a lot of cases, that just want dual roles. For example, `ACTION_TAP_DANCE_DOUBLE(KC_SPC, KC_ENT)` will result in `Space` being sent on single-tap, `Enter` otherwise. |
| 28 | 28 | ||
| 29 | !> Keep in mind that only [basic keycodes](keycodes_basic.md) are supported here. Custom keycodes are not supported. | ||
| 30 | |||
| 29 | And that's the bulk of it! | 31 | And that's the bulk of it! |
| 30 | 32 | ||
| 31 | And now, on to the explanation of how it works! | 33 | And now, on to the explanation of how it works! |
| @@ -183,29 +185,11 @@ Below is a specific example: | |||
| 183 | 185 | ||
| 184 | ## Setup | 186 | ## Setup |
| 185 | 187 | ||
| 186 | You will need a few things that can be used for 'Quad Function Tap-Dance'. The suggested setup is to create a user directory for yourself. This directory will contain rules.mk `<your_name>.c` and `<your_name>.h`. This directory should be called `<your_name>`, and located in the top level `users` directory. There should already be a few examples to look at there. | 188 | You will need a few things that can be used for 'Quad Function Tap-Dance'. |
| 187 | |||
| 188 | ### In `/qmk_firmware/users/<your_name>/rules.mk` | ||
| 189 | |||
| 190 | Put the following: | ||
| 191 | ```c | ||
| 192 | TAP_DANCE_ENABLE = yes | ||
| 193 | SRC += your_name.c | ||
| 194 | ``` | ||
| 195 | |||
| 196 | Pretty simple. It is a nice way to keep some rules common on all your keymaps. | ||
| 197 | |||
| 198 | 189 | ||
| 199 | ### In `/qmk_firmware/users/<your_name>/<your_name>.h` | 190 | You'll need to add these to the top of your `keymap.c` file, before your keymap. |
| 200 | |||
| 201 | You will need a few things in this file: | ||
| 202 | 191 | ||
| 203 | ```c | 192 | ```c |
| 204 | #pragma once | ||
| 205 | |||
| 206 | #include "quantum.h" | ||
| 207 | #include "process_keycode/process_tap_dance.h" | ||
| 208 | |||
| 209 | typedef struct { | 193 | typedef struct { |
| 210 | bool is_press_action; | 194 | bool is_press_action; |
| 211 | int state; | 195 | int state; |
| @@ -232,18 +216,12 @@ int cur_dance (qk_tap_dance_state_t *state); | |||
| 232 | //for the x tap dance. Put it here so it can be used in any keymap | 216 | //for the x tap dance. Put it here so it can be used in any keymap |
| 233 | void x_finished (qk_tap_dance_state_t *state, void *user_data); | 217 | void x_finished (qk_tap_dance_state_t *state, void *user_data); |
| 234 | void x_reset (qk_tap_dance_state_t *state, void *user_data); | 218 | void x_reset (qk_tap_dance_state_t *state, void *user_data); |
| 235 | ``` | ||
| 236 | 219 | ||
| 237 | ### In `/qmk_firmware/users/<your_name>/<your_name>.c` | 220 | ``` |
| 238 | 221 | ||
| 239 | And then in your user's `.c` file you implement the functions above: | 222 | Now, at the bottom of your `keymap.c` file, you'll need to add the following: |
| 240 | 223 | ||
| 241 | ```c | 224 | ```c |
| 242 | #include "<your_name>.h" | ||
| 243 | #include "quantum.h" | ||
| 244 | #include "action.h" | ||
| 245 | #include "process_keycode/process_tap_dance.h" | ||
| 246 | |||
| 247 | /* Return an integer that corresponds to what kind of tap dance should be executed. | 225 | /* Return an integer that corresponds to what kind of tap dance should be executed. |
| 248 | * | 226 | * |
| 249 | * How to figure out tap dance state: interrupted and pressed. | 227 | * How to figure out tap dance state: interrupted and pressed. |
| @@ -333,4 +311,6 @@ qk_tap_dance_action_t tap_dance_actions[] = { | |||
| 333 | }; | 311 | }; |
| 334 | ``` | 312 | ``` |
| 335 | 313 | ||
| 336 | And then simply use `TD(X_CTL)` anywhere in your keymap after including `<your_name>.h`. | 314 | And then simply use `TD(X_CTL)` anywhere in your keymap. |
| 315 | |||
| 316 | If you want to implement this in your userspace, then you may want to check out how [DanielGGordon](https://github.com/qmk/qmk_firmware/tree/master/users/gordon) has implemented this in their userspace. | ||
