diff options
Diffstat (limited to 'docs/feature_combo.md')
| -rw-r--r-- | docs/feature_combo.md | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/docs/feature_combo.md b/docs/feature_combo.md new file mode 100644 index 000000000..05ffc0d72 --- /dev/null +++ b/docs/feature_combo.md | |||
| @@ -0,0 +1,89 @@ | |||
| 1 | # Combos | ||
| 2 | |||
| 3 | The Combo feature is a chording type solution for adding custom actions. It lets you hit multiple keys at once and produce a different effect. For instance, hitting `A` and `S` within the tapping term would hit `ESC` instead, or have it perform even more complex tasks. | ||
| 4 | |||
| 5 | To enable this feature, yu need to add `COMBO_ENABLE = yes` to your `rules.mk`. | ||
| 6 | |||
| 7 | Additionally, in your `config.h`, you'll need to specify the number of combos that you'll be using, by adding `#define COMBO_COUNT 1` (replacing 1 with the number that you're using). | ||
| 8 | <!-- At this time, this is necessary --> | ||
| 9 | |||
| 10 | Also, by default, the tapping term for the Combos is set to the same value as `TAPPING_TERM` (200 by default on most boards). But you can specify a different value by defining it in your `config.h`. For instance: `#define COMBO_TERM 300` would set the time out period for combos to 300ms. | ||
| 11 | |||
| 12 | Then, your `keymap.c` file, you'll need to define a sequence of keys, terminated with `COMBO_END`, and a structure to list the combination of keys, and it's resulting action. | ||
| 13 | |||
| 14 | ```c | ||
| 15 | const uint16_t PROGMEM test_combo[] = {KC_A, KC_B, COMBO_END}; | ||
| 16 | combo_t key_combos[COMBO_COUNT] = {COMBO(test_combo, KC_ESC)}; | ||
| 17 | ``` | ||
| 18 | |||
| 19 | This will send "Escape" if you hit the A and B keys. | ||
| 20 | |||
| 21 | !> This method only supports [basic keycodes](keycodes_basic.md). See the examples for more control. | ||
| 22 | !> You cannot reuse (share) keys in combos. Each key should only belong to a single combo. | ||
| 23 | |||
| 24 | ## Examples | ||
| 25 | |||
| 26 | If you want to add a list, then you'd use something like this: | ||
| 27 | |||
| 28 | ```c | ||
| 29 | enum combos { | ||
| 30 | AB_ESC, | ||
| 31 | JK_TAB | ||
| 32 | } | ||
| 33 | const uint16_t PROGMEM ab_combo[] = {KC_A, KC_B, COMBO_END}; | ||
| 34 | const uint16_t PROGMEM jk_combo[] = {KC_J, KC_K, COMBO_END}; | ||
| 35 | |||
| 36 | combo_t key_combos[COMBO_COUNT] = { | ||
| 37 | [AB_ESC] = COMBO(ab_combo, KC_ESC), | ||
| 38 | [JK_TAB] = COMBO(jk_combo, KC_TAB) | ||
| 39 | }; | ||
| 40 | ``` | ||
| 41 | |||
| 42 | For a more complicated implementation, you can use the `process_combo_event` function to add custom handling. | ||
| 43 | |||
| 44 | ```c | ||
| 45 | enum combo_events { | ||
| 46 | ZC_COPY, | ||
| 47 | XV_PASTE | ||
| 48 | }; | ||
| 49 | |||
| 50 | const uint16_t PROGMEM copy_combo[] = {KC_Z, KC_C, COMBO_END}; | ||
| 51 | const uint16_t PROGMEM paste_combo[] = {KC_X, KC_V, COMBO_END}; | ||
| 52 | |||
| 53 | combo_t key_combos[COMBO_COUNT] = { | ||
| 54 | [ZC_COPY] = COMBO_ACTION(copy_combo), | ||
| 55 | [XV_PASTE] = COMBO_ACTION(paste_combo), | ||
| 56 | }; | ||
| 57 | |||
| 58 | void process_combo_event(uint8_t combo_index, bool pressed) { | ||
| 59 | switch(combo_index) { | ||
| 60 | case ZC_COPY: | ||
| 61 | if (pressed) { | ||
| 62 | register_code(KC_LCTL); | ||
| 63 | register_code(KC_C); | ||
| 64 | unregister_code(KC_C); | ||
| 65 | unregister_code(KC_LCTL); | ||
| 66 | } | ||
| 67 | break; | ||
| 68 | |||
| 69 | case XV_PASTE: | ||
| 70 | if (pressed) { | ||
| 71 | register_code(KC_LCTL); | ||
| 72 | register_code(KC_V); | ||
| 73 | unregister_code(KC_V); | ||
| 74 | unregister_code(KC_LCTL); | ||
| 75 | } | ||
| 76 | break; | ||
| 77 | } | ||
| 78 | } | ||
| 79 | ``` | ||
| 80 | |||
| 81 | This will send Ctrl+C if you hit Z and C, and Ctrl+V if you hit X and V. But you could change this to do stuff like change layers, play sounds, or change settings. | ||
| 82 | |||
| 83 | ## Additional Configuration | ||
| 84 | |||
| 85 | If you're using long combos, or even longer combos, you may run into issues with this, as the structure may not be large enough to accommodate what you're doing. | ||
| 86 | |||
| 87 | In this case, you can add either `#define EXTRA_LONG_COMBOS` or `#define EXTRA_EXTRA_LONG_COMBOS` in your `config.h` file. | ||
| 88 | |||
| 89 | You may also be able to enable action keys by defining `COMBO_ALLOW_ACTION_KEYS`. | ||
