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.

85 lines
2.7 KiB

  1. // Copyright 2021 Google LLC.
  2. // SPDX-License-Identifier: Apache-2.0
  3. #pragma once
  4. #include "drashna.h"
  5. // Call this function from `process_record_user()` to implement Caps Word.
  6. bool process_caps_word(uint16_t keycode, keyrecord_t* record);
  7. // If CAPS_WORD_IDLE_TIMEOUT is set, call `caps_word_task()` from
  8. // `matrix_scan_user()` as described above.
  9. //
  10. // If CAPS_WORD_IDLE_TIMEOUT isn't set, calling this function has no effect (but
  11. // will still compile).
  12. #if CAPS_WORD_IDLE_TIMEOUT > 0
  13. void caps_word_task(void);
  14. #else
  15. static inline void caps_word_task(void) {}
  16. #endif
  17. // Activates or deactivates Caps Word. For instance activate Caps Word with a
  18. // combo by defining a `COMBO_ACTION` that calls `caps_word_set(true)`:
  19. //
  20. // void process_combo_event(uint16_t combo_index, bool pressed) {
  21. // switch(combo_index) {
  22. // case CAPS_COMBO:
  23. // if (pressed) {
  24. // caps_word_set(true); // Activate Caps Word.
  25. // }
  26. // break;
  27. //
  28. // // Other combos...
  29. // }
  30. // }
  31. void caps_word_set(bool active);
  32. // Returns whether Caps Word is currently active.
  33. bool caps_word_get(void);
  34. // An optional callback that gets called when Caps Word turns on or off. This is
  35. // useful to represent the current Caps Word state, e.g. by setting an LED or
  36. // playing a sound. In your keymap, define
  37. //
  38. // void caps_word_set_user(bool active) {
  39. // if (active) {
  40. // // Do something when Caps Word activates.
  41. // } else {
  42. // // Do something when Caps Word deactivates.
  43. // }
  44. // }
  45. void caps_word_set_user(bool active);
  46. // An optional callback which is called on every key press while Caps Word is
  47. // active. When the key should be shifted (that is, a letter key), the callback
  48. // should call `add_weak_mods(MOD_BIT(KC_LSFT))` to shift the key. The callback
  49. // also determines whether the key should continue Caps Word. Returning true
  50. // continues the current "word", while returning false is "word breaking" and
  51. // deactivates Caps Word. The default callback is
  52. //
  53. // bool caps_word_press_user(uint16_t keycode) {
  54. // switch (keycode) {
  55. // // Keycodes that continue Caps Word, with shift applied.
  56. // case KC_A ... KC_Z:
  57. // add_weak_mods(MOD_BIT(KC_LSFT)); // Apply shift to the next key.
  58. // return true;
  59. //
  60. // // Keycodes that continue Caps Word, without shifting.
  61. // case KC_1 ... KC_0:
  62. // case KC_BSPC:
  63. // case KC_MINS:
  64. // case KC_UNDS:
  65. // return true;
  66. //
  67. // default:
  68. // return false; // Deactivate Caps Word.
  69. // }
  70. // }
  71. //
  72. // To customize, copy the above function into your keymap and add/remove
  73. // keycodes to the above cases.
  74. //
  75. // NOTE: Outside of this callback, you can use `caps_word_set(false)` to
  76. // deactivate Caps Word.
  77. bool caps_word_press_user(uint16_t keycode);