diff options
| author | Drashna Jaelre <drashna@live.com> | 2020-03-22 06:29:05 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-03-23 00:29:05 +1100 |
| commit | 5117dff6a26aec4eca04fb9787b4f428884739bc (patch) | |
| tree | ecc94acb888c3ed330c11008fa6324b1d73b12cc /quantum | |
| parent | e5d34fd084a7bdde0867749470b27c50e8144eb8 (diff) | |
| download | qmk_firmware-5117dff6a26aec4eca04fb9787b4f428884739bc.tar.gz qmk_firmware-5117dff6a26aec4eca04fb9787b4f428884739bc.zip | |
Add Post Processing to process_record (#4892)
* Improve process_record system
Code based on @colinta's
* Rename and better handle functions
* Fix incorrect function call to process_record_user
* Add documentation for post_process_record
* Add both get_event_keycode and get_record_keycode functions
And add some comments about these functions
* Update code format
* Cleanup merge artifacts
Diffstat (limited to 'quantum')
| -rw-r--r-- | quantum/quantum.c | 20 | ||||
| -rw-r--r-- | quantum/quantum.h | 2 |
2 files changed, 19 insertions, 3 deletions
diff --git a/quantum/quantum.c b/quantum/quantum.c index 49767819d..d7dbc49dc 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c | |||
| @@ -120,6 +120,14 @@ __attribute__((weak)) bool process_record_kb(uint16_t keycode, keyrecord_t *reco | |||
| 120 | 120 | ||
| 121 | __attribute__((weak)) bool process_record_user(uint16_t keycode, keyrecord_t *record) { return true; } | 121 | __attribute__((weak)) bool process_record_user(uint16_t keycode, keyrecord_t *record) { return true; } |
| 122 | 122 | ||
| 123 | __attribute__ ((weak)) | ||
| 124 | void post_process_record_kb(uint16_t keycode, keyrecord_t *record) { | ||
| 125 | post_process_record_user(keycode, record); | ||
| 126 | } | ||
| 127 | |||
| 128 | __attribute__ ((weak)) | ||
| 129 | void post_process_record_user(uint16_t keycode, keyrecord_t *record) {} | ||
| 130 | |||
| 123 | void reset_keyboard(void) { | 131 | void reset_keyboard(void) { |
| 124 | clear_keyboard(); | 132 | clear_keyboard(); |
| 125 | #if defined(MIDI_ENABLE) && defined(MIDI_BASIC) | 133 | #if defined(MIDI_ENABLE) && defined(MIDI_BASIC) |
| @@ -172,9 +180,15 @@ uint16_t get_event_keycode(keyevent_t event) { | |||
| 172 | return keymap_key_to_keycode(layer_switch_get_layer(event.key), event.key); | 180 | return keymap_key_to_keycode(layer_switch_get_layer(event.key), event.key); |
| 173 | } | 181 | } |
| 174 | 182 | ||
| 175 | /* Main keycode processing function. Hands off handling to other functions, | 183 | /* Get keycode, and then call keyboard function */ |
| 176 | * then processes internal Quantum keycodes, then processes ACTIONs. | 184 | void post_process_record_quantum(keyrecord_t *record) { |
| 177 | */ | 185 | uint16_t keycode = get_record_keycode(record); |
| 186 | post_process_record_kb(keycode, record); | ||
| 187 | } | ||
| 188 | |||
| 189 | /* Core keycode function, hands off handling to other functions, | ||
| 190 | then processes internal quantum keycodes, and then processes | ||
| 191 | ACTIONs. */ | ||
| 178 | bool process_record_quantum(keyrecord_t *record) { | 192 | bool process_record_quantum(keyrecord_t *record) { |
| 179 | uint16_t keycode = get_record_keycode(record); | 193 | uint16_t keycode = get_record_keycode(record); |
| 180 | 194 | ||
diff --git a/quantum/quantum.h b/quantum/quantum.h index 191407fab..4b94ebcc0 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h | |||
| @@ -257,6 +257,8 @@ uint16_t get_event_keycode(keyevent_t event); | |||
| 257 | bool process_action_kb(keyrecord_t *record); | 257 | bool process_action_kb(keyrecord_t *record); |
| 258 | bool process_record_kb(uint16_t keycode, keyrecord_t *record); | 258 | bool process_record_kb(uint16_t keycode, keyrecord_t *record); |
| 259 | bool process_record_user(uint16_t keycode, keyrecord_t *record); | 259 | bool process_record_user(uint16_t keycode, keyrecord_t *record); |
| 260 | void post_process_record_kb(uint16_t keycode, keyrecord_t *record); | ||
| 261 | void post_process_record_user(uint16_t keycode, keyrecord_t *record); | ||
| 260 | 262 | ||
| 261 | #ifndef BOOTMAGIC_LITE_COLUMN | 263 | #ifndef BOOTMAGIC_LITE_COLUMN |
| 262 | # define BOOTMAGIC_LITE_COLUMN 0 | 264 | # define BOOTMAGIC_LITE_COLUMN 0 |
