summaryrefslogtreecommitdiff
path: root/users/drashna/keyrecords/caps_word.h
diff options
context:
space:
mode:
authorQMK Bot <hello@qmk.fm>2022-03-07 06:12:48 +0000
committerQMK Bot <hello@qmk.fm>2022-03-07 06:12:48 +0000
commit99edf15a696b6a116fb919ec98b2e9477ba8b124 (patch)
treed523d7e5129dd64d20869eaef7d352ced67b3145 /users/drashna/keyrecords/caps_word.h
parentf9df57b722427d9a3c5d9123addf2cf88083b97b (diff)
parentff6c70415c536e6435023627197550889ffa1501 (diff)
Merge remote-tracking branch 'origin/master' into develop
Diffstat (limited to 'users/drashna/keyrecords/caps_word.h')
-rw-r--r--users/drashna/keyrecords/caps_word.h77
1 files changed, 77 insertions, 0 deletions
diff --git a/users/drashna/keyrecords/caps_word.h b/users/drashna/keyrecords/caps_word.h
index 79e410ddda..4279d7e831 100644
--- a/users/drashna/keyrecords/caps_word.h
+++ b/users/drashna/keyrecords/caps_word.h
@@ -5,4 +5,81 @@
#include "drashna.h"
+// Call this function from `process_record_user()` to implement Caps Word.
bool process_caps_word(uint16_t keycode, keyrecord_t* record);
+
+// If CAPS_WORD_IDLE_TIMEOUT is set, call `caps_word_task()` from
+// `matrix_scan_user()` as described above.
+//
+// If CAPS_WORD_IDLE_TIMEOUT isn't set, calling this function has no effect (but
+// will still compile).
+#if CAPS_WORD_IDLE_TIMEOUT > 0
+void caps_word_task(void);
+#else
+static inline void caps_word_task(void) {}
+#endif
+
+// Activates or deactivates Caps Word. For instance activate Caps Word with a
+// combo by defining a `COMBO_ACTION` that calls `caps_word_set(true)`:
+//
+// void process_combo_event(uint16_t combo_index, bool pressed) {
+// switch(combo_index) {
+// case CAPS_COMBO:
+// if (pressed) {
+// caps_word_set(true); // Activate Caps Word.
+// }
+// break;
+//
+// // Other combos...
+// }
+// }
+void caps_word_set(bool active);
+
+// Returns whether Caps Word is currently active.
+bool caps_word_get(void);
+
+// An optional callback that gets called when Caps Word turns on or off. This is
+// useful to represent the current Caps Word state, e.g. by setting an LED or
+// playing a sound. In your keymap, define
+//
+// void caps_word_set_user(bool active) {
+// if (active) {
+// // Do something when Caps Word activates.
+// } else {
+// // Do something when Caps Word deactivates.
+// }
+// }
+void caps_word_set_user(bool active);
+
+// An optional callback which is called on every key press while Caps Word is
+// active. When the key should be shifted (that is, a letter key), the callback
+// should call `add_weak_mods(MOD_BIT(KC_LSFT))` to shift the key. The callback
+// also determines whether the key should continue Caps Word. Returning true
+// continues the current "word", while returning false is "word breaking" and
+// deactivates Caps Word. The default callback is
+//
+// bool caps_word_press_user(uint16_t keycode) {
+// switch (keycode) {
+// // Keycodes that continue Caps Word, with shift applied.
+// case KC_A ... KC_Z:
+// add_weak_mods(MOD_BIT(KC_LSFT)); // Apply shift to the next key.
+// return true;
+//
+// // Keycodes that continue Caps Word, without shifting.
+// case KC_1 ... KC_0:
+// case KC_BSPC:
+// case KC_MINS:
+// case KC_UNDS:
+// return true;
+//
+// default:
+// return false; // Deactivate Caps Word.
+// }
+// }
+//
+// To customize, copy the above function into your keymap and add/remove
+// keycodes to the above cases.
+//
+// NOTE: Outside of this callback, you can use `caps_word_set(false)` to
+// deactivate Caps Word.
+bool caps_word_press_user(uint16_t keycode);