summary refs log tree commit diff
path: root/quantum
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@live.com>2022-03-17 14:19:34 -0700
committerGitHub <noreply@github.com>2022-03-17 21:19:34 +0000
commit02655690f48ec64ba982499cd3272ee6076b73b3 (patch)
treed7c0530d0142f93c99b895120460a5ac2303c453 /quantum
parent2749346a539c2385218a32937ae7992cf80fb263 (diff)
[Core] Add compile/make macro to core (#15959)
* [Core] Add KC_MAKE keycode to core

fix linting

fix testing error

work around test idiocyncracies

fix more lint

something something stupid tests

add doc

* updates based on feedback

* Add bad names

* Fixup docs

* semantics but cleaner

Co-authored-by: precondition <57645186+precondition@users.noreply.github.com>

* Hide oneshot checks behind preprocessors

* Move no-compile option around

* Fix formatting

* make shift optional

* Make opt in

* fix formatting

* update send string function name

Co-authored-by: Joel Challis <git@zvecr.com>

Co-authored-by: precondition <57645186+precondition@users.noreply.github.com>
Co-authored-by: Joel Challis <git@zvecr.com>
Diffstat (limited to 'quantum')
-rw-r--r--quantum/quantum.c20
-rw-r--r--quantum/quantum_keycodes.h2
2 files changed, 22 insertions, 0 deletions
diff --git a/quantum/quantum.c b/quantum/quantum.c
index ef6e5ac1df..d4e91ddd37 100644
--- a/quantum/quantum.c
+++ b/quantum/quantum.c
@@ -358,6 +358,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
         }
     }
 
diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h
index 2552c48165..dacfe5bdcd 100644
--- a/quantum/quantum_keycodes.h
+++ b/quantum/quantum_keycodes.h
@@ -595,6 +595,8 @@ enum quantum_keycodes {
 
     MAGIC_TOGGLE_CONTROL_CAPSLOCK,
 
+    QK_MAKE,
+
     // Start of custom keycode range for keyboards and keymaps - always leave at the end
     SAFE_RANGE
 };