You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

154 lines
3.9 KiB

Process combos earlier & overlapping combos (#8591) * Combo processing improvements. Now it is possible to use ModTap and LayerTap keys as part of combos. Overlapping combos also don't trigger all the combos, just exactly the one that you press. New settings: - COMBO_MUST_HOLD_MODS - COMBO_MOD_TERM - COMBO_TERM_PER_COMBO - COMBO_MUST_HOLD_PER_COMBO - COMBO_STRICT_TIMER - COMBO_NO_TIMER * Remove the size flags from combo_t struct boolean members. This in the end actually saves space as the members are accessed so many times. The amount of operations needed to access the bits uses more memory than setting the size saves. * Fix `process_combo_key_release` not called correctly with tap-only combos * Fix not passing a pointer when NO_ACTION_TAPPING is defined. * Docs for `COMBO_ONLY_FROM_LAYER` * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update quantum/process_keycode/process_combo.c Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Add `EXTRA_SHORT_COMBOS` option. Stuff combo's `disabled` and `active` flags into `state`. Possibly can save some space. * Add more examples and clarify things with dict management system. - Simple examples now has a combo that has modifiers included. - The slightly more advanced examples now are actually more advanced instead of just `tap_code16(<modded-keycode>)`. - Added a note that `COMBO_ACTION`s are not needed anymore as you can just use custom keycodes. - Added a note that the `g/keymap_combo.h` macros use the `process_combo_event` function and that it is not usable in one's keymap afterwards. * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Change "the" combo action example to "email" example. * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Fix sneaky infinite loop with `combo_disable()` No need to call `dump_key_buffer` when disabling combos because the buffer is either being dumped if a combo-key was pressed, or the buffer is empty if a non-combo-key is pressed. * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> Co-authored-by: Drashna Jaelre <drashna@live.com>
2 years ago
Process combos earlier & overlapping combos (#8591) * Combo processing improvements. Now it is possible to use ModTap and LayerTap keys as part of combos. Overlapping combos also don't trigger all the combos, just exactly the one that you press. New settings: - COMBO_MUST_HOLD_MODS - COMBO_MOD_TERM - COMBO_TERM_PER_COMBO - COMBO_MUST_HOLD_PER_COMBO - COMBO_STRICT_TIMER - COMBO_NO_TIMER * Remove the size flags from combo_t struct boolean members. This in the end actually saves space as the members are accessed so many times. The amount of operations needed to access the bits uses more memory than setting the size saves. * Fix `process_combo_key_release` not called correctly with tap-only combos * Fix not passing a pointer when NO_ACTION_TAPPING is defined. * Docs for `COMBO_ONLY_FROM_LAYER` * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update quantum/process_keycode/process_combo.c Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Add `EXTRA_SHORT_COMBOS` option. Stuff combo's `disabled` and `active` flags into `state`. Possibly can save some space. * Add more examples and clarify things with dict management system. - Simple examples now has a combo that has modifiers included. - The slightly more advanced examples now are actually more advanced instead of just `tap_code16(<modded-keycode>)`. - Added a note that `COMBO_ACTION`s are not needed anymore as you can just use custom keycodes. - Added a note that the `g/keymap_combo.h` macros use the `process_combo_event` function and that it is not usable in one's keymap afterwards. * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Change "the" combo action example to "email" example. * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Fix sneaky infinite loop with `combo_disable()` No need to call `dump_key_buffer` when disabling combos because the buffer is either being dumped if a combo-key was pressed, or the buffer is empty if a non-combo-key is pressed. * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> Co-authored-by: Drashna Jaelre <drashna@live.com>
2 years ago
Process combos earlier & overlapping combos (#8591) * Combo processing improvements. Now it is possible to use ModTap and LayerTap keys as part of combos. Overlapping combos also don't trigger all the combos, just exactly the one that you press. New settings: - COMBO_MUST_HOLD_MODS - COMBO_MOD_TERM - COMBO_TERM_PER_COMBO - COMBO_MUST_HOLD_PER_COMBO - COMBO_STRICT_TIMER - COMBO_NO_TIMER * Remove the size flags from combo_t struct boolean members. This in the end actually saves space as the members are accessed so many times. The amount of operations needed to access the bits uses more memory than setting the size saves. * Fix `process_combo_key_release` not called correctly with tap-only combos * Fix not passing a pointer when NO_ACTION_TAPPING is defined. * Docs for `COMBO_ONLY_FROM_LAYER` * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update quantum/process_keycode/process_combo.c Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Add `EXTRA_SHORT_COMBOS` option. Stuff combo's `disabled` and `active` flags into `state`. Possibly can save some space. * Add more examples and clarify things with dict management system. - Simple examples now has a combo that has modifiers included. - The slightly more advanced examples now are actually more advanced instead of just `tap_code16(<modded-keycode>)`. - Added a note that `COMBO_ACTION`s are not needed anymore as you can just use custom keycodes. - Added a note that the `g/keymap_combo.h` macros use the `process_combo_event` function and that it is not usable in one's keymap afterwards. * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Change "the" combo action example to "email" example. * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Fix sneaky infinite loop with `combo_disable()` No need to call `dump_key_buffer` when disabling combos because the buffer is either being dumped if a combo-key was pressed, or the buffer is empty if a non-combo-key is pressed. * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> Co-authored-by: Drashna Jaelre <drashna@live.com>
2 years ago
  1. /*
  2. Copyright 2012,2013 Jun Wako <wakojun@gmail.com>
  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.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #pragma once
  15. #include <stdint.h>
  16. #include <stdbool.h>
  17. #include "progmem.h"
  18. #include "keyboard.h"
  19. #include "keycode.h"
  20. #include "action_code.h"
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. #ifndef TAP_CODE_DELAY
  25. # define TAP_CODE_DELAY 0
  26. #endif
  27. #ifndef TAP_HOLD_CAPS_DELAY
  28. # define TAP_HOLD_CAPS_DELAY 80
  29. #endif
  30. /* tapping count and state */
  31. typedef struct {
  32. bool interrupted : 1;
  33. bool reserved2 : 1;
  34. bool reserved1 : 1;
  35. bool reserved0 : 1;
  36. uint8_t count : 4;
  37. } tap_t;
  38. /* Key event container for recording */
  39. typedef struct {
  40. keyevent_t event;
  41. #ifndef NO_ACTION_TAPPING
  42. tap_t tap;
  43. #endif
  44. #if defined(COMBO_ENABLE) || defined(REPEAT_KEY_ENABLE)
  45. uint16_t keycode;
  46. #endif
  47. } keyrecord_t;
  48. /* Execute action per keyevent */
  49. void action_exec(keyevent_t event);
  50. /* action for key */
  51. action_t action_for_key(uint8_t layer, keypos_t key);
  52. action_t action_for_keycode(uint16_t keycode);
  53. /* keyboard-specific key event (pre)processing */
  54. bool process_record_quantum(keyrecord_t *record);
  55. /* Utilities for actions. */
  56. #if !defined(NO_ACTION_LAYER) && !defined(STRICT_LAYER_RELEASE)
  57. extern bool disable_action_cache;
  58. #endif
  59. /* Code for handling one-handed key modifiers. */
  60. #ifdef SWAP_HANDS_ENABLE
  61. extern bool swap_hands;
  62. extern const keypos_t PROGMEM hand_swap_config[MATRIX_ROWS][MATRIX_COLS];
  63. # if (MATRIX_COLS <= 8)
  64. typedef uint8_t swap_state_row_t;
  65. # elif (MATRIX_COLS <= 16)
  66. typedef uint16_t swap_state_row_t;
  67. # elif (MATRIX_COLS <= 32)
  68. typedef uint32_t swap_state_row_t;
  69. # else
  70. # error "MATRIX_COLS: invalid value"
  71. # endif
  72. /**
  73. * @brief Enable swap hands
  74. */
  75. void swap_hands_on(void);
  76. /**
  77. * @brief Disable swap hands
  78. */
  79. void swap_hands_off(void);
  80. /**
  81. * @brief Toggle swap hands enable state
  82. */
  83. void swap_hands_toggle(void);
  84. /**
  85. * @brief Get the swap hands enable state
  86. *
  87. * @return true
  88. * @return false
  89. */
  90. bool is_swap_hands_on(void);
  91. void process_hand_swap(keyevent_t *record);
  92. #endif
  93. void process_record_nocache(keyrecord_t *record);
  94. void process_record(keyrecord_t *record);
  95. void process_record_handler(keyrecord_t *record);
  96. void post_process_record_quantum(keyrecord_t *record);
  97. void process_action(keyrecord_t *record, action_t action);
  98. void register_code(uint8_t code);
  99. void unregister_code(uint8_t code);
  100. void tap_code(uint8_t code);
  101. void tap_code_delay(uint8_t code, uint16_t delay);
  102. void register_mods(uint8_t mods);
  103. void unregister_mods(uint8_t mods);
  104. void register_weak_mods(uint8_t mods);
  105. void unregister_weak_mods(uint8_t mods);
  106. // void set_mods(uint8_t mods);
  107. void clear_keyboard(void);
  108. void clear_keyboard_but_mods(void);
  109. void clear_keyboard_but_mods_and_keys(void);
  110. void layer_switch(uint8_t new_layer);
  111. bool is_tap_record(keyrecord_t *record);
  112. bool is_tap_action(action_t action);
  113. #ifndef NO_ACTION_TAPPING
  114. void process_record_tap_hint(keyrecord_t *record);
  115. #endif
  116. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  117. // Helpers
  118. #ifdef ACTION_DEBUG
  119. # include "debug.h"
  120. # include "print.h"
  121. # define ac_dprintf(...) dprintf(__VA_ARGS__)
  122. #else
  123. # define ac_dprintf(...) \
  124. do { \
  125. } while (0)
  126. #endif
  127. void debug_event(keyevent_t event);
  128. void debug_record(keyrecord_t record);
  129. void debug_action(action_t action);
  130. #ifdef __cplusplus
  131. }
  132. #endif