diff options
Diffstat (limited to 'docs')
-rw-r--r-- | docs/feature_macros.md | 40 | ||||
-rw-r--r-- | docs/understanding_qmk.md | 9 |
2 files changed, 49 insertions, 0 deletions
diff --git a/docs/feature_macros.md b/docs/feature_macros.md index 99dd564bf..1bd2d74e7 100644 --- a/docs/feature_macros.md +++ b/docs/feature_macros.md | |||
@@ -88,6 +88,46 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |||
88 | }; | 88 | }; |
89 | ``` | 89 | ``` |
90 | 90 | ||
91 | ### Advanced Macros | ||
92 | |||
93 | In addition to the `process_record_user()` function, is the `post_process_record_user()` function. This runs after `process_record` and can be used to do things after a keystroke has been sent. This is useful if you want to have a key pressed before and released after a normal key, for instance. | ||
94 | |||
95 | In this example, we modify most normal keypresses so that `F22` is pressed before the keystroke is normally sent, and release it __only after__ it's been released. | ||
96 | |||
97 | ```c | ||
98 | static uint8_t f22_tracker; | ||
99 | |||
100 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
101 | switch (keycode) { | ||
102 | case KC_A ... KC_F21: //notice how it skips over F22 | ||
103 | case KC_F23 ... KC_EXSEL: //exsel is the last one before the modifier keys | ||
104 | if (record->event.pressed) { | ||
105 | register_code(KC_F22); //this means to send F22 down | ||
106 | f22_tracker++; | ||
107 | register_code(keycode); | ||
108 | return false; | ||
109 | } | ||
110 | break; | ||
111 | } | ||
112 | return true; | ||
113 | } | ||
114 | |||
115 | void post_process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
116 | switch (keycode) { | ||
117 | case KC_A ... KC_F21: //notice how it skips over F22 | ||
118 | case KC_F23 ... KC_EXSEL: //exsel is the last one before the modifier keys | ||
119 | if (!record->event.pressed) { | ||
120 | f22_tracker--; | ||
121 | if (!f22_tracker) { | ||
122 | unregister_code(KC_F22); //this means to send F22 up | ||
123 | } | ||
124 | } | ||
125 | break; | ||
126 | } | ||
127 | } | ||
128 | ``` | ||
129 | |||
130 | |||
91 | ### TAP, DOWN and UP | 131 | ### TAP, DOWN and UP |
92 | 132 | ||
93 | You may want to use keys in your macros that you can't write down, such as `Ctrl` or `Home`. | 133 | You may want to use keys in your macros that you can't write down, such as `Ctrl` or `Home`. |
diff --git a/docs/understanding_qmk.md b/docs/understanding_qmk.md index 81cedfcf5..939642425 100644 --- a/docs/understanding_qmk.md +++ b/docs/understanding_qmk.md | |||
@@ -162,6 +162,15 @@ The `process_record()` function itself is deceptively simple, but hidden within | |||
162 | 162 | ||
163 | At any step during this chain of events a function (such as `process_record_kb()`) can `return false` to halt all further processing. | 163 | At any step during this chain of events a function (such as `process_record_kb()`) can `return false` to halt all further processing. |
164 | 164 | ||
165 | After this is called, `post_process_record()` is called, which can be used to handle additional cleanup that needs to be run after the keycode is normally handled. | ||
166 | |||
167 | * [`void post_process_record(keyrecord_t *record)`]() | ||
168 | * [`void post_process_record_quantum(keyrecord_t *record)`]() | ||
169 | * [Map this record to a keycode]() | ||
170 | * [`void post_process_clicky(uint16_t keycode, keyrecord_t *record)`]() | ||
171 | * [`void post_process_record_kb(uint16_t keycode, keyrecord_t *record)`]() | ||
172 | * [`void post_process_record_user(uint16_t keycode, keyrecord_t *record)`]() | ||
173 | |||
165 | <!-- | 174 | <!-- |
166 | #### Mouse Handling | 175 | #### Mouse Handling |
167 | 176 | ||