]> git.donarmstrong.com Git - qmk_firmware.git/commitdiff
[Docs] Update the KC_MAKE example in Userspace docs (#5337)
authorDrashna Jaelre <drashna@live.com>
Fri, 8 Mar 2019 15:56:08 +0000 (07:56 -0800)
committerMechMerlin <30334081+mechmerlin@users.noreply.github.com>
Fri, 8 Mar 2019 15:56:08 +0000 (07:56 -0800)
This includes a much more feature rich version of the code, as well as updating for changes that have occurred in QMK Firmware

docs/feature_userspace.md

index 5a9fc287b3e17f33ce3d492abb034c6ea4be13d2..d82d43138d7789c3c4d0d835267cce8ecd826fa0 100644 (file)
@@ -201,27 +201,51 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
 
 bool process_record_user(uint16_t keycode, keyrecord_t *record) {
   switch (keycode) {
-  case KC_MAKE:
-    if (!record->event.pressed) {
-      SEND_STRING("make " QMK_KEYBOARD ":" QMK_KEYMAP
-#if  (defined(BOOTLOADER_DFU) || defined(BOOTLOADER_LUFA_DFU) || defined(BOOTLOADER_QMK_DFU))
-       ":dfu "
-#elif defined(BOOTLOADER_HALFKAY)
-      ":teensy "
-#elif defined(BOOTLOADER_CATERINA)
-       ":avrdude "
-#endif
-        SS_TAP(X_ENTER));
-    }
-    return false;
-    break;
+    case KC_MAKE:  // Compiles the firmware, and adds the flash command based on keyboard bootloader
+            if (!record->event.pressed) {
+            uint8_t temp_mod = get_mods();
+            uint8_t temp_osm = get_oneshot_mods();
+            clear_mods(); clear_oneshot_mods();
+            SEND_STRING("make " QMK_KEYBOARD ":" QMK_KEYMAP);
+    #ifndef FLASH_BOOTLOADER
+            if ( (temp_mod | temp_osm) & MOD_MASK_SHIFT ) 
+    #endif
+            { // 
+                #if defined(__arm__)  // only run for ARM boards
+                    SEND_STRING(":dfu-util");
+                #elif defined(BOOTLOADER_DFU) // only run for DFU boards
+                    SEND_STRING(":dfu");
+                #elif defined(BOOTLOADER_HALFKAY) // only run for teensy boards
+                    SEND_STRING(":teensy");
+                #elif defined(BOOTLOADER_CATERINA) // only run for Pro Micros
+                    SEND_STRING(":avrdude");
+                #endif // bootloader options
+            }
+            if ( (temp_mod | temp_osm) & MOD_MASK_CTRL) { 
+                SEND_STRING(" -j8 --output-sync"); 
+            }
+            SEND_STRING(SS_TAP(X_ENTER));
+            set_mods(temp_mod);
+        }
+        break;
+
   }
   return process_record_keymap(keycode, record);
 }
 ```
 
+For boards that may not have a shift button (such as on a macro pad), we need a way to always include the bootloader option.  To do that, add the following to the `rules.mk` in your userspace folder: 
+
+```make 
+ifeq ($(strip $(FLASH_BOOTLOADER)), yes)
+    OPT_DEFS += -DFLASH_BOOTLOADER
+endif
+```
+
 This will add a new `KC_MAKE` keycode that can be used in any of your keymaps.  And this keycode will output `make <keyboard>:<keymap>`, making frequent compiling easier.  And this will work with any keyboard and any keymap as it will output the current boards info, so that you don't have to type this out every time.
 
-Additionally, this should flash the newly compiled firmware automatically, using the correct utility, based on the bootloader settings (or default to just generating the HEX file). However, it should be noted that this may not work on all systems. AVRDUDE doesn't work on WSL, namely (and will dump the HEX in the ".build" folder instead).
+Also, holding `shift` will add the appropriate flashing command (`:dfu`, `:teensy`, `:avrdude`, `:dfu-util`) for a majority of keyboards.  Holding `control` will add some commands that will speed up compiling time by processing multiple files at once. 
 
+And for the boards that lack a shift key, or that you want to always attempt the flashing part, you can add `FLASH_BOOTLOADER = yes` to the `rules.mk` of that keymap.
 
+?> This should flash the newly compiled firmware automatically, using the correct utility, based on the bootloader settings (or default to just generating the HEX file). However, it should be noted that this may not work on all systems. AVRDUDE doesn't work on WSL, namely. And this doesn't support BootloadHID or mdloader.