diff options
| author | Albert Y <76888457+filterpaper@users.noreply.github.com> | 2023-05-13 15:42:06 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-13 08:42:06 +0100 |
| commit | 128f808496cf7800fde3c7508388745bd99e8016 (patch) | |
| tree | 4acee52bde06ed861a96420c01bb140c6c478f15 /quantum | |
| parent | 8cb13b67507246cc2b362dcf255c857d9192a1dd (diff) | |
Add a user callback for pre process record (#20584)
Diffstat (limited to 'quantum')
| -rw-r--r-- | quantum/action.c | 5 | ||||
| -rw-r--r-- | quantum/quantum.c | 17 | ||||
| -rw-r--r-- | quantum/quantum.h | 3 |
3 files changed, 16 insertions, 9 deletions
diff --git a/quantum/action.c b/quantum/action.c index a683ff1130..59bfefc495 100644 --- a/quantum/action.c +++ b/quantum/action.c | |||
| @@ -30,6 +30,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 30 | #include "wait.h" | 30 | #include "wait.h" |
| 31 | #include "keycode_config.h" | 31 | #include "keycode_config.h" |
| 32 | #include "debug.h" | 32 | #include "debug.h" |
| 33 | #include "quantum.h" | ||
| 33 | 34 | ||
| 34 | #ifdef BACKLIGHT_ENABLE | 35 | #ifdef BACKLIGHT_ENABLE |
| 35 | # include "backlight.h" | 36 | # include "backlight.h" |
| @@ -65,10 +66,6 @@ __attribute__((weak)) bool get_retro_tapping(uint16_t keycode, keyrecord_t *reco | |||
| 65 | } | 66 | } |
| 66 | #endif | 67 | #endif |
| 67 | 68 | ||
| 68 | __attribute__((weak)) bool pre_process_record_quantum(keyrecord_t *record) { | ||
| 69 | return true; | ||
| 70 | } | ||
| 71 | |||
| 72 | /** \brief Called to execute an action. | 69 | /** \brief Called to execute an action. |
| 73 | * | 70 | * |
| 74 | * FIXME: Needs documentation. | 71 | * FIXME: Needs documentation. |
diff --git a/quantum/quantum.c b/quantum/quantum.c index 0587f215fe..950be3182e 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c | |||
| @@ -114,6 +114,14 @@ __attribute__((weak)) void tap_code16(uint16_t code) { | |||
| 114 | tap_code16_delay(code, code == KC_CAPS_LOCK ? TAP_HOLD_CAPS_DELAY : TAP_CODE_DELAY); | 114 | tap_code16_delay(code, code == KC_CAPS_LOCK ? TAP_HOLD_CAPS_DELAY : TAP_CODE_DELAY); |
| 115 | } | 115 | } |
| 116 | 116 | ||
| 117 | __attribute__((weak)) bool pre_process_record_kb(uint16_t keycode, keyrecord_t *record) { | ||
| 118 | return pre_process_record_user(keycode, record); | ||
| 119 | } | ||
| 120 | |||
| 121 | __attribute__((weak)) bool pre_process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
| 122 | return true; | ||
| 123 | } | ||
| 124 | |||
| 117 | __attribute__((weak)) bool process_action_kb(keyrecord_t *record) { | 125 | __attribute__((weak)) bool process_action_kb(keyrecord_t *record) { |
| 118 | return true; | 126 | return true; |
| 119 | } | 127 | } |
| @@ -202,14 +210,13 @@ uint16_t get_event_keycode(keyevent_t event, bool update_layer_cache) { | |||
| 202 | 210 | ||
| 203 | /* Get keycode, and then process pre tapping functionality */ | 211 | /* Get keycode, and then process pre tapping functionality */ |
| 204 | bool pre_process_record_quantum(keyrecord_t *record) { | 212 | bool pre_process_record_quantum(keyrecord_t *record) { |
| 205 | if (!( | 213 | uint16_t keycode = get_record_keycode(record, true); |
| 206 | #ifdef COMBO_ENABLE | 214 | #ifdef COMBO_ENABLE |
| 207 | process_combo(get_record_keycode(record, true), record) && | 215 | if (!(process_combo(keycode, record))) { |
| 208 | #endif | ||
| 209 | true)) { | ||
| 210 | return false; | 216 | return false; |
| 211 | } | 217 | } |
| 212 | return true; // continue processing | 218 | #endif |
| 219 | return pre_process_record_kb(keycode, record); | ||
| 213 | } | 220 | } |
| 214 | 221 | ||
| 215 | /* Get keycode, and then call keyboard function */ | 222 | /* Get keycode, and then call keyboard function */ |
diff --git a/quantum/quantum.h b/quantum/quantum.h index 38186a48a3..fec92a5244 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h | |||
| @@ -261,6 +261,9 @@ void set_single_persistent_default_layer(uint8_t default_layer); | |||
| 261 | 261 | ||
| 262 | uint16_t get_record_keycode(keyrecord_t *record, bool update_layer_cache); | 262 | uint16_t get_record_keycode(keyrecord_t *record, bool update_layer_cache); |
| 263 | uint16_t get_event_keycode(keyevent_t event, bool update_layer_cache); | 263 | uint16_t get_event_keycode(keyevent_t event, bool update_layer_cache); |
| 264 | bool pre_process_record_quantum(keyrecord_t *record); | ||
| 265 | bool pre_process_record_kb(uint16_t keycode, keyrecord_t *record); | ||
| 266 | bool pre_process_record_user(uint16_t keycode, keyrecord_t *record); | ||
| 264 | bool process_action_kb(keyrecord_t *record); | 267 | bool process_action_kb(keyrecord_t *record); |
| 265 | bool process_record_kb(uint16_t keycode, keyrecord_t *record); | 268 | bool process_record_kb(uint16_t keycode, keyrecord_t *record); |
| 266 | bool process_record_user(uint16_t keycode, keyrecord_t *record); | 269 | bool process_record_user(uint16_t keycode, keyrecord_t *record); |
