aboutsummaryrefslogtreecommitdiff
path: root/docs/feature_stenography.md
diff options
context:
space:
mode:
authorSeebs <seebs@seebs.net>2017-11-18 09:38:15 -0600
committerJack Humbert <jack.humb@gmail.com>2018-04-07 17:12:44 -0400
commitc0baf2a964b10d708281c704c0b049a1cf0f4914 (patch)
tree197350c318be03b332d1d4cd5f544d78f426fe39 /docs/feature_stenography.md
parent5f4c2dfd84467dc7f04e8e07c294ebfa5b4ca459 (diff)
downloadqmk_firmware-c0baf2a964b10d708281c704c0b049a1cf0f4914.tar.gz
qmk_firmware-c0baf2a964b10d708281c704c0b049a1cf0f4914.zip
Improve state/chord handling and clean up namespace
Some values that can never, ever, change were held in local variables, rather than in PROGMEM. Fixed. Change "pressed" to a signed int so the test for < 0 makes sense, and to avoid possible weird failure modes in the case where a key release comes in when pressed is already zero. (Shouldn't happen, sure, but computers are weird.) A lot of things in process_steno had external linkage for no particular reason. They've been marked static. Stuff still builds. Distinguish between currently-held keys and keys that have been held, and expose these values through a nicely-named API so other code could, say, check on the current set of steno chording in order to make displays. Also in passing fix up the "state" value having external linkage so it could clash with other people's variable declarations. The API also provides hooks for key processing and steno chord events, so you can monitor those events without having to run in matrix_scan_user and recheck the values directly. Also document these. There is no path through processing a key that doesn't end with a return false, so the nested return foo() are gone and we just return false.
Diffstat (limited to 'docs/feature_stenography.md')
-rw-r--r--docs/feature_stenography.md24
1 files changed, 24 insertions, 0 deletions
diff --git a/docs/feature_stenography.md b/docs/feature_stenography.md
index 9fb224b5d..0b2c82422 100644
--- a/docs/feature_stenography.md
+++ b/docs/feature_stenography.md
@@ -56,6 +56,29 @@ On the display tab click 'Open stroke display'. With Plover disabled you should
56* [Steno Jig](https://joshuagrams.github.io/steno-jig/) 56* [Steno Jig](https://joshuagrams.github.io/steno-jig/)
57* More resources at the Plover [Learning Stenography](https://github.com/openstenoproject/plover/wiki/Learning-Stenography) wiki 57* More resources at the Plover [Learning Stenography](https://github.com/openstenoproject/plover/wiki/Learning-Stenography) wiki
58 58
59## Interfacing with the code
60
61The steno code has three interceptible hooks. If you define these functions, they will be called at certain points in processing; if they return true, processing continues, otherwise it's assumed you handled things.
62
63```C
64bool send_steno_chord_user(steno_mode_t mode, uint8_t chord[6]);
65```
66
67This function is called when a chord is about to be sent. Mode will be one of `STENO_MODE_BOLT` or `STENO_MODE_GEMINI`. This represents the actual chord that would be sent via whichever protocol. You can modify the chord provided to alter what gets sent. Remember to return true if you want the regular sending process to happen.
68
69```C
70bool process_steno_user(uint16_t keycode, keyrecord_t *record) { return true; }
71```
72
73This function is called when a keypress has come in, before it is processed. The keycode should be one of `QK_STENO_BOLT`, `QK_STENO_GEMINI`, or one of the `STN_*` key values.
74
75```C
76bool postprocess_steno_user(uint16_t keycode, keyrecord_t *record, steno_mode_t mode, uint8_t chord[6], int8_t pressed);
77```
78
79This function is called after a key has been processed, but before any decision about whether or not to send a chord. If `IS_PRESSED(record->event)` is false, and `pressed` is 0 or 1, the chord will be sent shortly, but has not yet been sent. This is where to put hooks for things like, say, live displays of steno chords or keys.
80
81
59## Keycode Reference 82## Keycode Reference
60 83
61As defined in `keymap_steno.h`. 84As defined in `keymap_steno.h`.
@@ -106,3 +129,4 @@ As defined in `keymap_steno.h`.
106|`STN_RES1`||(GeminiPR only)| 129|`STN_RES1`||(GeminiPR only)|
107|`STN_RES2`||(GeminiPR only)| 130|`STN_RES2`||(GeminiPR only)|
108|`STN_PWR`||(GeminiPR only)| 131|`STN_PWR`||(GeminiPR only)|
132