diff options
| author | Joel Challis <git@zvecr.com> | 2025-06-03 23:44:46 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-03 23:44:46 +0100 |
| commit | f096e5a3f3af404e6f752185260f183d3ecd503e (patch) | |
| tree | b3f628aebf2968434473eba8a1000eca410171f5 | |
| parent | 53c6fa5de75da248fe3d5549f9e79660682bc64c (diff) | |
Relocate remaining `process_record_quantum` keycodes (#25328)
| -rw-r--r-- | builddefs/common_features.mk | 2 | ||||
| -rw-r--r-- | quantum/process_keycode/process_oneshot.c | 25 | ||||
| -rw-r--r-- | quantum/process_keycode/process_oneshot.h | 10 | ||||
| -rw-r--r-- | quantum/process_keycode/process_quantum.c | 76 | ||||
| -rw-r--r-- | quantum/process_keycode/process_quantum.h | 10 | ||||
| -rw-r--r-- | quantum/process_keycode/process_underglow.c | 5 | ||||
| -rw-r--r-- | quantum/quantum.c | 83 |
7 files changed, 136 insertions, 75 deletions
diff --git a/builddefs/common_features.mk b/builddefs/common_features.mk index ca60873bec..90231c9a96 100644 --- a/builddefs/common_features.mk +++ b/builddefs/common_features.mk | |||
| @@ -29,6 +29,8 @@ QUANTUM_SRC += \ | |||
| 29 | $(QUANTUM_DIR)/logging/debug.c \ | 29 | $(QUANTUM_DIR)/logging/debug.c \ |
| 30 | $(QUANTUM_DIR)/logging/sendchar.c \ | 30 | $(QUANTUM_DIR)/logging/sendchar.c \ |
| 31 | $(QUANTUM_DIR)/process_keycode/process_default_layer.c \ | 31 | $(QUANTUM_DIR)/process_keycode/process_default_layer.c \ |
| 32 | $(QUANTUM_DIR)/process_keycode/process_oneshot.c \ | ||
| 33 | $(QUANTUM_DIR)/process_keycode/process_quantum.c \ | ||
| 32 | 34 | ||
| 33 | include $(QUANTUM_DIR)/nvm/rules.mk | 35 | include $(QUANTUM_DIR)/nvm/rules.mk |
| 34 | 36 | ||
diff --git a/quantum/process_keycode/process_oneshot.c b/quantum/process_keycode/process_oneshot.c new file mode 100644 index 0000000000..6c43da1011 --- /dev/null +++ b/quantum/process_keycode/process_oneshot.c | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | // Copyright 2025 QMK | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #include "process_oneshot.h" | ||
| 5 | #include "action_util.h" | ||
| 6 | |||
| 7 | bool process_oneshot(uint16_t keycode, keyrecord_t *record) { | ||
| 8 | #ifndef NO_ACTION_ONESHOT | ||
| 9 | if (record->event.pressed) { | ||
| 10 | switch (keycode) { | ||
| 11 | case QK_ONE_SHOT_TOGGLE: | ||
| 12 | oneshot_toggle(); | ||
| 13 | return false; | ||
| 14 | case QK_ONE_SHOT_ON: | ||
| 15 | oneshot_enable(); | ||
| 16 | return false; | ||
| 17 | case QK_ONE_SHOT_OFF: | ||
| 18 | oneshot_disable(); | ||
| 19 | return false; | ||
| 20 | } | ||
| 21 | } | ||
| 22 | #endif | ||
| 23 | |||
| 24 | return true; | ||
| 25 | } | ||
diff --git a/quantum/process_keycode/process_oneshot.h b/quantum/process_keycode/process_oneshot.h new file mode 100644 index 0000000000..11445b9b38 --- /dev/null +++ b/quantum/process_keycode/process_oneshot.h | |||
| @@ -0,0 +1,10 @@ | |||
| 1 | // Copyright 2025 QMK | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include <stdint.h> | ||
| 7 | #include <stdbool.h> | ||
| 8 | #include "action.h" | ||
| 9 | |||
| 10 | bool process_oneshot(uint16_t keycode, keyrecord_t *record); | ||
diff --git a/quantum/process_keycode/process_quantum.c b/quantum/process_keycode/process_quantum.c new file mode 100644 index 0000000000..703e00755b --- /dev/null +++ b/quantum/process_keycode/process_quantum.c | |||
| @@ -0,0 +1,76 @@ | |||
| 1 | // Copyright 2025 QMK | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #include "process_quantum.h" | ||
| 5 | #include "quantum.h" | ||
| 6 | |||
| 7 | #ifdef ENABLE_COMPILE_KEYCODE | ||
| 8 | /** \brief Compiles the firmware, and adds the flash command based on keyboard bootloader | ||
| 9 | */ | ||
| 10 | static void send_make_command(void) { | ||
| 11 | # ifdef NO_ACTION_ONESHOT | ||
| 12 | const uint8_t temp_mod = mod_config(get_mods()); | ||
| 13 | # else | ||
| 14 | const uint8_t temp_mod = mod_config(get_mods() | get_oneshot_mods()); | ||
| 15 | clear_oneshot_mods(); | ||
| 16 | # endif | ||
| 17 | clear_mods(); | ||
| 18 | |||
| 19 | SEND_STRING_DELAY("qmk", TAP_CODE_DELAY); | ||
| 20 | if (temp_mod & MOD_MASK_SHIFT) { // if shift is held, flash rather than compile | ||
| 21 | SEND_STRING_DELAY(" flash ", TAP_CODE_DELAY); | ||
| 22 | } else { | ||
| 23 | SEND_STRING_DELAY(" compile ", TAP_CODE_DELAY); | ||
| 24 | } | ||
| 25 | # if defined(CONVERTER_ENABLED) | ||
| 26 | SEND_STRING_DELAY("-kb " QMK_KEYBOARD " -km " QMK_KEYMAP " -e CONVERT_TO=" CONVERTER_TARGET SS_TAP(X_ENTER), TAP_CODE_DELAY); | ||
| 27 | # else | ||
| 28 | SEND_STRING_DELAY("-kb " QMK_KEYBOARD " -km " QMK_KEYMAP SS_TAP(X_ENTER), TAP_CODE_DELAY); | ||
| 29 | # endif | ||
| 30 | if (temp_mod & MOD_MASK_SHIFT && temp_mod & MOD_MASK_CTRL) { | ||
| 31 | reset_keyboard(); | ||
| 32 | } | ||
| 33 | } | ||
| 34 | #endif | ||
| 35 | |||
| 36 | bool process_quantum(uint16_t keycode, keyrecord_t *record) { | ||
| 37 | if (record->event.pressed) { | ||
| 38 | switch (keycode) { | ||
| 39 | #ifndef NO_RESET | ||
| 40 | case QK_BOOTLOADER: | ||
| 41 | reset_keyboard(); | ||
| 42 | return false; | ||
| 43 | case QK_REBOOT: | ||
| 44 | soft_reset_keyboard(); | ||
| 45 | return false; | ||
| 46 | #endif | ||
| 47 | #ifndef NO_DEBUG | ||
| 48 | case QK_DEBUG_TOGGLE: | ||
| 49 | debug_enable ^= 1; | ||
| 50 | if (debug_enable) { | ||
| 51 | print("DEBUG: enabled.\n"); | ||
| 52 | } else { | ||
| 53 | print("DEBUG: disabled.\n"); | ||
| 54 | } | ||
| 55 | return false; | ||
| 56 | #endif | ||
| 57 | case QK_CLEAR_EEPROM: | ||
| 58 | #ifdef NO_RESET | ||
| 59 | eeconfig_init(); | ||
| 60 | #else | ||
| 61 | eeconfig_disable(); | ||
| 62 | soft_reset_keyboard(); | ||
| 63 | #endif | ||
| 64 | return false; | ||
| 65 | #ifdef ENABLE_COMPILE_KEYCODE | ||
| 66 | case QK_MAKE: | ||
| 67 | send_make_command(); | ||
| 68 | return false; | ||
| 69 | #endif | ||
| 70 | default: | ||
| 71 | break; | ||
| 72 | } | ||
| 73 | } | ||
| 74 | |||
| 75 | return true; | ||
| 76 | } | ||
diff --git a/quantum/process_keycode/process_quantum.h b/quantum/process_keycode/process_quantum.h new file mode 100644 index 0000000000..5c2462be01 --- /dev/null +++ b/quantum/process_keycode/process_quantum.h | |||
| @@ -0,0 +1,10 @@ | |||
| 1 | // Copyright 2025 QMK | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include <stdint.h> | ||
| 7 | #include <stdbool.h> | ||
| 8 | #include "action.h" | ||
| 9 | |||
| 10 | bool process_quantum(uint16_t keycode, keyrecord_t *record); | ||
diff --git a/quantum/process_keycode/process_underglow.c b/quantum/process_keycode/process_underglow.c index b8d8989ef3..78006ee099 100644 --- a/quantum/process_keycode/process_underglow.c +++ b/quantum/process_keycode/process_underglow.c | |||
| @@ -200,6 +200,11 @@ bool process_underglow(uint16_t keycode, keyrecord_t *record) { | |||
| 200 | } | 200 | } |
| 201 | #endif | 201 | #endif |
| 202 | return false; | 202 | return false; |
| 203 | #ifdef VELOCIKEY_ENABLE | ||
| 204 | case QK_VELOCIKEY_TOGGLE: | ||
| 205 | velocikey_toggle(); | ||
| 206 | return false; | ||
| 207 | #endif | ||
| 203 | } | 208 | } |
| 204 | } | 209 | } |
| 205 | 210 | ||
diff --git a/quantum/quantum.c b/quantum/quantum.c index 319f477ae7..5503c88953 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c | |||
| @@ -15,6 +15,7 @@ | |||
| 15 | */ | 15 | */ |
| 16 | 16 | ||
| 17 | #include "quantum.h" | 17 | #include "quantum.h" |
| 18 | #include "process_quantum.h" | ||
| 18 | 19 | ||
| 19 | #ifdef BACKLIGHT_ENABLE | 20 | #ifdef BACKLIGHT_ENABLE |
| 20 | # include "process_backlight.h" | 21 | # include "process_backlight.h" |
| @@ -84,6 +85,10 @@ | |||
| 84 | # include "process_layer_lock.h" | 85 | # include "process_layer_lock.h" |
| 85 | #endif | 86 | #endif |
| 86 | 87 | ||
| 88 | #ifndef NO_ACTION_ONESHOT | ||
| 89 | # include "process_oneshot.h" | ||
| 90 | #endif | ||
| 91 | |||
| 87 | #ifdef AUDIO_ENABLE | 92 | #ifdef AUDIO_ENABLE |
| 88 | # ifndef GOODBYE_SONG | 93 | # ifndef GOODBYE_SONG |
| 89 | # define GOODBYE_SONG SONG(GOODBYE_SOUND) | 94 | # define GOODBYE_SONG SONG(GOODBYE_SOUND) |
| @@ -439,83 +444,11 @@ bool process_record_quantum(keyrecord_t *record) { | |||
| 439 | #ifdef CONNECTION_ENABLE | 444 | #ifdef CONNECTION_ENABLE |
| 440 | process_connection(keycode, record) && | 445 | process_connection(keycode, record) && |
| 441 | #endif | 446 | #endif |
| 442 | true)) { | ||
| 443 | return false; | ||
| 444 | } | ||
| 445 | |||
| 446 | if (record->event.pressed) { | ||
| 447 | switch (keycode) { | ||
| 448 | #ifndef NO_RESET | ||
| 449 | case QK_BOOTLOADER: | ||
| 450 | reset_keyboard(); | ||
| 451 | return false; | ||
| 452 | case QK_REBOOT: | ||
| 453 | soft_reset_keyboard(); | ||
| 454 | return false; | ||
| 455 | #endif | ||
| 456 | #ifndef NO_DEBUG | ||
| 457 | case QK_DEBUG_TOGGLE: | ||
| 458 | debug_enable ^= 1; | ||
| 459 | if (debug_enable) { | ||
| 460 | print("DEBUG: enabled.\n"); | ||
| 461 | } else { | ||
| 462 | print("DEBUG: disabled.\n"); | ||
| 463 | } | ||
| 464 | return false; | ||
| 465 | #endif | ||
| 466 | case QK_CLEAR_EEPROM: | ||
| 467 | #ifdef NO_RESET | ||
| 468 | eeconfig_init(); | ||
| 469 | #else | ||
| 470 | eeconfig_disable(); | ||
| 471 | soft_reset_keyboard(); | ||
| 472 | #endif | ||
| 473 | return false; | ||
| 474 | #ifdef VELOCIKEY_ENABLE | ||
| 475 | case QK_VELOCIKEY_TOGGLE: | ||
| 476 | velocikey_toggle(); | ||
| 477 | return false; | ||
| 478 | #endif | ||
| 479 | #ifndef NO_ACTION_ONESHOT | 447 | #ifndef NO_ACTION_ONESHOT |
| 480 | case QK_ONE_SHOT_TOGGLE: | 448 | process_oneshot(keycode, record) && |
| 481 | oneshot_toggle(); | ||
| 482 | return false; | ||
| 483 | case QK_ONE_SHOT_ON: | ||
| 484 | oneshot_enable(); | ||
| 485 | return false; | ||
| 486 | case QK_ONE_SHOT_OFF: | ||
| 487 | oneshot_disable(); | ||
| 488 | return false; | ||
| 489 | #endif | ||
| 490 | #ifdef ENABLE_COMPILE_KEYCODE | ||
| 491 | case QK_MAKE: // Compiles the firmware, and adds the flash command based on keyboard bootloader | ||
| 492 | { | ||
| 493 | # ifdef NO_ACTION_ONESHOT | ||
| 494 | const uint8_t temp_mod = mod_config(get_mods()); | ||
| 495 | # else | ||
| 496 | const uint8_t temp_mod = mod_config(get_mods() | get_oneshot_mods()); | ||
| 497 | clear_oneshot_mods(); | ||
| 498 | # endif | ||
| 499 | clear_mods(); | ||
| 500 | |||
| 501 | SEND_STRING_DELAY("qmk", TAP_CODE_DELAY); | ||
| 502 | if (temp_mod & MOD_MASK_SHIFT) { // if shift is held, flash rather than compile | ||
| 503 | SEND_STRING_DELAY(" flash ", TAP_CODE_DELAY); | ||
| 504 | } else { | ||
| 505 | SEND_STRING_DELAY(" compile ", TAP_CODE_DELAY); | ||
| 506 | } | ||
| 507 | # if defined(CONVERTER_ENABLED) | ||
| 508 | SEND_STRING_DELAY("-kb " QMK_KEYBOARD " -km " QMK_KEYMAP " -e CONVERT_TO=" CONVERTER_TARGET SS_TAP(X_ENTER), TAP_CODE_DELAY); | ||
| 509 | # else | ||
| 510 | SEND_STRING_DELAY("-kb " QMK_KEYBOARD " -km " QMK_KEYMAP SS_TAP(X_ENTER), TAP_CODE_DELAY); | ||
| 511 | # endif | ||
| 512 | if (temp_mod & MOD_MASK_SHIFT && temp_mod & MOD_MASK_CTRL) { | ||
| 513 | reset_keyboard(); | ||
| 514 | } | ||
| 515 | return false; | ||
| 516 | } | ||
| 517 | #endif | 449 | #endif |
| 518 | } | 450 | process_quantum(keycode, record))) { |
| 451 | return false; | ||
| 519 | } | 452 | } |
| 520 | 453 | ||
| 521 | return process_action_kb(record); | 454 | return process_action_kb(record); |
