qmk_firmware

QMK firmware for my keyboards (Corne, Sweep Ferris) and trackball (Ploopy Adept)
Log | Files | Refs | Submodules | LICENSE

process_quantum.c (2199B)


      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 }