Skip to content

Commit

Permalink
[Core] Add compile/make macro to core (#15959)
Browse files Browse the repository at this point in the history
* [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 <[email protected]>

* 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 <[email protected]>

Co-authored-by: precondition <[email protected]>
Co-authored-by: Joel Challis <[email protected]>
  • Loading branch information
3 people authored Mar 17, 2022
1 parent 2749346 commit 0265569
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 10 deletions.
2 changes: 2 additions & 0 deletions docs/config_options.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ If you define these options you will disable the associated feature, which can s

If you define these options you will enable the associated feature, which may increase your code size.

* `#define ENABLE_COMPILE_KEYCODE`
* Enables the `QK_MAKE` keycode
* `#define FORCE_NKRO`
* NKRO by default requires to be turned on, this forces it on during keyboard startup regardless of EEPROM setting. NKRO can still be turned off but will be turned on again if the keyboard reboots.
* `#define STRICT_LAYER_RELEASE`
Expand Down
11 changes: 6 additions & 5 deletions docs/keycodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,12 @@ See also: [Basic Keycodes](keycodes_basic.md)

See also: [Quantum Keycodes](quantum_keycodes.md#qmk-keycodes)

|Key |Aliases |Description |
|-----------------|---------|-------------------------------------------------------|
|`QK_BOOTLOADER` |`QK_BOOT`|Put the keyboard into bootloader mode for flashing |
|`QK_DEBUG_TOGGLE`|`DB_TOGG`|Toggle debug mode |
|`QK_CLEAR_EEPROM`|`EE_CLR` |Reinitializes the keyboard's EEPROM (persistent memory)|
|Key |Aliases |Description |
|-----------------|---------|---------------------------------------------------------------------------------|
|`QK_BOOTLOADER` |`QK_BOOT`|Put the keyboard into bootloader mode for flashing |
|`QK_DEBUG_TOGGLE`|`DB_TOGG`|Toggle debug mode |
|`QK_CLEAR_EEPROM`|`EE_CLR` |Reinitializes the keyboard's EEPROM (persistent memory) |
|`QK_MAKE` | |Sends `qmk compile -kb (keyboard) -km (keymap)`, or `qmk flash` if shift is held |

## Audio Keys :id=audio-keys

Expand Down
11 changes: 6 additions & 5 deletions docs/quantum_keycodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ On this page we have documented keycodes between `0x00FF` and `0xFFFF` which are

## QMK Keycodes :id=qmk-keycodes

|Key |Aliases |Description |
|-----------------|---------|-------------------------------------------------------|
|`QK_BOOTLOADER` |`QK_BOOT`|Put the keyboard into bootloader mode for flashing |
|`QK_DEBUG_TOGGLE`|`DB_TOGG`|Toggle debug mode |
|`QK_CLEAR_EEPROM`|`EE_CLR` |Reinitializes the keyboard's EEPROM (persistent memory)|
|Key |Aliases |Description |
|-----------------|---------|---------------------------------------------------------------------------------|
|`QK_BOOTLOADER` |`QK_BOOT`|Put the keyboard into bootloader mode for flashing |
|`QK_DEBUG_TOGGLE`|`DB_TOGG`|Toggle debug mode |
|`QK_CLEAR_EEPROM`|`EE_CLR` |Reinitializes the keyboard's EEPROM (persistent memory) |
|`QK_MAKE` | |Sends `qmk compile -kb (keyboard) -km (keymap)`, or `qmk flash` if shift is held |
20 changes: 20 additions & 0 deletions quantum/quantum.c
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,26 @@ bool process_record_quantum(keyrecord_t *record) {
case ONESHOT_DISABLE:
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
}
}
Expand Down
2 changes: 2 additions & 0 deletions quantum/quantum_keycodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand Down

0 comments on commit 0265569

Please sign in to comment.