summaryrefslogtreecommitdiffstats
path: root/quantum/quantum.c
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/quantum.c')
-rw-r--r--quantum/quantum.c62
1 files changed, 61 insertions, 1 deletions
diff --git a/quantum/quantum.c b/quantum/quantum.c
index ef6e5ac1df..ac3e2d90b4 100644
--- a/quantum/quantum.c
+++ b/quantum/quantum.c
@@ -121,7 +121,7 @@ __attribute__((weak)) void post_process_record_kb(uint16_t keycode, keyrecord_t
__attribute__((weak)) void post_process_record_user(uint16_t keycode, keyrecord_t *record) {}
-void reset_keyboard(void) {
+void shutdown_quantum(void) {
clear_keyboard();
#if defined(MIDI_ENABLE) && defined(MIDI_BASIC)
process_midi_all_notes_off();
@@ -143,9 +143,18 @@ void reset_keyboard(void) {
#ifdef HAPTIC_ENABLE
haptic_shutdown();
#endif
+}
+
+void reset_keyboard(void) {
+ shutdown_quantum();
bootloader_jump();
}
+void soft_reset_keyboard(void) {
+ shutdown_quantum();
+ mcu_reset();
+}
+
/* Convert record into usable keycode via the contained event. */
uint16_t get_record_keycode(keyrecord_t *record, bool update_layer_cache) {
#ifdef COMBO_ENABLE
@@ -212,6 +221,12 @@ bool process_record_quantum(keyrecord_t *record) {
// return false;
// }
+#if defined(SECURE_ENABLE)
+ if (!preprocess_secure(keycode, record)) {
+ return false;
+ }
+#endif
+
#ifdef VELOCIKEY_ENABLE
if (velocikey_enabled() && record->event.pressed) {
velocikey_accelerate();
@@ -247,6 +262,9 @@ bool process_record_quantum(keyrecord_t *record) {
process_record_via(keycode, record) &&
#endif
process_record_kb(keycode, record) &&
+#if defined(SECURE_ENABLE)
+ process_secure(keycode, record) &&
+#endif
#if defined(SEQUENCER_ENABLE)
process_sequencer(keycode, record) &&
#endif
@@ -289,6 +307,9 @@ bool process_record_quantum(keyrecord_t *record) {
#ifdef TERMINAL_ENABLE
process_terminal(keycode, record) &&
#endif
+#ifdef CAPS_WORD_ENABLE
+ process_caps_word(keycode, record) &&
+#endif
#ifdef SPACE_CADET_ENABLE
process_space_cadet(keycode, record) &&
#endif
@@ -317,6 +338,9 @@ bool process_record_quantum(keyrecord_t *record) {
case QK_BOOTLOADER:
reset_keyboard();
return false;
+ case QK_REBOOT:
+ soft_reset_keyboard();
+ return false;
#endif
#ifndef NO_DEBUG
case QK_DEBUG_TOGGLE:
@@ -330,6 +354,9 @@ bool process_record_quantum(keyrecord_t *record) {
return false;
case QK_CLEAR_EEPROM:
eeconfig_init();
+#ifndef NO_RESET
+ soft_reset_keyboard();
+#endif
return false;
#ifdef VELOCIKEY_ENABLE
case VLK_TOG:
@@ -358,6 +385,26 @@ bool process_record_quantum(keyrecord_t *record) {
oneshot_disable();
break;
#endif
+#ifdef ENABLE_COMPILE_KEYCODE
+ case QK_MAKE: // Compiles the firmware, and adds the flash command based on keyboard bootloader
+ {
+# ifdef NO_ACTION_ONESHOT
+ const uint8_t temp_mod = mod_config(get_mods());
+# else
+ const uint8_t temp_mod = mod_config(get_mods() | get_oneshot_mods());
+ clear_oneshot_mods();
+# endif
+ clear_mods();
+
+ SEND_STRING_DELAY("qmk", TAP_CODE_DELAY);
+ if (temp_mod & MOD_MASK_SHIFT) { // if shift is held, flash rather than compile
+ SEND_STRING_DELAY(" flash ", TAP_CODE_DELAY);
+ } else {
+ SEND_STRING_DELAY(" compile ", TAP_CODE_DELAY);
+ }
+ SEND_STRING_DELAY("-kb " QMK_KEYBOARD " -km " QMK_KEYMAP SS_TAP(X_ENTER), TAP_CODE_DELAY);
+ }
+#endif
}
}
@@ -524,3 +571,16 @@ const char *get_u16_str(uint16_t curr_num, char curr_pad) {
last_pad = curr_pad;
return get_numeric_str(buf, sizeof(buf), curr_num, curr_pad);
}
+
+#if defined(SECURE_ENABLE)
+void secure_hook_quantum(secure_status_t secure_status) {
+ // If keys are being held when this is triggered, they may not be released properly
+ // this can result in stuck keys, mods and layers. To prevent that, manually
+ // clear these, when it is triggered.
+
+ if (secure_status == SECURE_PENDING) {
+ clear_keyboard();
+ layer_clear();
+ }
+}
+#endif