You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

234 lines
14 KiB

Remove Full Bootmagic (#13846) * disambiguate Bootmagic rules in keymaps The files edited by this commit were added at a point in time where `BOOTMAGIC_ENABLE = yes` enabled full Bootmagic. This commit edits the files to specify that full Bootmagic is intended. * remove BOOTMAGIC_ENABLE=full setting * unify commented BOOTMAGIC_ENABLE rules in keyboards Explicitly sets `BOOTMAGIC_ENABLE = no` in keyboards where the rule was commented out. Command: ``` find keyboards/ -type f -name 'rules.mk' -and -not -path '*/keymaps/*' -exec sed -i -e 's;#[ \t]*\(BOOTMAGIC_ENABLE\)[ \t=]\+\([a-zA-Z]\+\).*;\1 = no # Virtual DIP switch configuration;g' {} + ``` * remove commented Bootmagic rules from keymap/user level Command: ``` find keyboards/ layouts/ users/ -type f -name 'rules.mk' -exec sed -i -e '/#.*\(BOOTMAGIC_ENABLE\)[ \t=]\+\([a-z]\+\).*/d' {} + ``` * update keyboard BOOTMAGIC_ENABLE rule formatting Sets the formatting of BOOTMAGIC_ENABLE rules to `BOOTMAGIC_ENABLE = [value]`, without the inline comments (which will be replaced later). Command: ``` find keyboards/ -type f -name 'rules.mk' -and -not -path '*/keymaps/*' -exec sed -i -e 's;\(BOOTMAGIC_ENABLE\)[ \t=]\+\([a-z]\+\).*;\1 = \2;g' '{}' + ``` * update keyboards' BOOTMAGIC_ENABLE settings Updates keyboard `rules.mk` files to use `BOOTMAGIC_ENABLE = lite` where `BOOTMAGIC_ENABLE = full` was being used. Command: ``` find keyboards/ -type f -name 'rules.mk' -and -not -path '*/keymaps/*' -exec sed -i -e 's;\(BOOTMAGIC_ENABLE = \)full;\1lite;g' '{}' + ``` * update keymap/user BOOTMAGIC_ENABLE settings Updates keymap/user `rules.mk` files to use `BOOTMAGIC_ENABLE = lite` where `BOOTMAGIC_ENABLE = full` was being used. Commands: ``` find keyboards/ -type f -name 'rules.mk' -and -path '*/keymaps/*' -exec sed -i -e 's;\(BOOTMAGIC_ENABLE[ \t=]\+\)full;\1lite;g' '{}' + find layouts/community/ users/ -type f -name 'rules.mk' -exec sed -i -e 's;\(BOOTMAGIC_ENABLE[ \t=]\+\)full;\1lite;g' '{}' + ``` * remove and replace inline comments in keyboards and keymap/user files Removes and replaces the inline comments, which have been updated to read `Enable Bootmagic Lite`. Commands: ``` find keyboards/ -type f -name 'rules.mk' -and -path '*/keymaps/*' -exec sed -i -e 's;\(BOOTMAGIC_ENABLE\)[ \t=]\+\([a-z]\+\).*;\1 = \2;g' '{}' + find layouts/community/ users/ -type f -name 'rules.mk' -exec sed -i -e 's;\(BOOTMAGIC_ENABLE\)[ \t=]\+\([a-z]\+\).*;\1 = \2;g' '{}' + find keyboards/ layouts/community/ users/ -type f -name 'rules.mk' -exec sed -i -e 's;\(BOOTMAGIC_ENABLE = lite\);\1 # Enable Bootmagic Lite;g' '{}' + find keyboards/ layouts/community/ users/ -type f -name 'rules.mk' -exec sed -i -e 's;\(BOOTMAGIC_ENABLE = yes\);\1 # Enable Bootmagic Lite;g' '{}' + find keyboards/ layouts/community/ users/ -type f -name 'rules.mk' -exec sed -i -e 's;\(BOOTMAGIC_ENABLE = no\);\1 # Enable Bootmagic Lite;g' '{}' + ``` * rename improperly named makefiles Some files intended to be used as makefiles had improper names causing them to not be used as intended when building. This commit corrects the filenames of the affected files. * update renamed file with new rule formatting * update QMK's template files Updates QMK's `rules.mk` templates to use the new inline comment. * update QMK Docs - remove documentation of full Bootmagic - update links to Bootmagic Lite doc - add doc for Magic Keycodes * rules.mk patch for coarse/ixora and coarse/vinta
2 years ago
Remove Full Bootmagic (#13846) * disambiguate Bootmagic rules in keymaps The files edited by this commit were added at a point in time where `BOOTMAGIC_ENABLE = yes` enabled full Bootmagic. This commit edits the files to specify that full Bootmagic is intended. * remove BOOTMAGIC_ENABLE=full setting * unify commented BOOTMAGIC_ENABLE rules in keyboards Explicitly sets `BOOTMAGIC_ENABLE = no` in keyboards where the rule was commented out. Command: ``` find keyboards/ -type f -name 'rules.mk' -and -not -path '*/keymaps/*' -exec sed -i -e 's;#[ \t]*\(BOOTMAGIC_ENABLE\)[ \t=]\+\([a-zA-Z]\+\).*;\1 = no # Virtual DIP switch configuration;g' {} + ``` * remove commented Bootmagic rules from keymap/user level Command: ``` find keyboards/ layouts/ users/ -type f -name 'rules.mk' -exec sed -i -e '/#.*\(BOOTMAGIC_ENABLE\)[ \t=]\+\([a-z]\+\).*/d' {} + ``` * update keyboard BOOTMAGIC_ENABLE rule formatting Sets the formatting of BOOTMAGIC_ENABLE rules to `BOOTMAGIC_ENABLE = [value]`, without the inline comments (which will be replaced later). Command: ``` find keyboards/ -type f -name 'rules.mk' -and -not -path '*/keymaps/*' -exec sed -i -e 's;\(BOOTMAGIC_ENABLE\)[ \t=]\+\([a-z]\+\).*;\1 = \2;g' '{}' + ``` * update keyboards' BOOTMAGIC_ENABLE settings Updates keyboard `rules.mk` files to use `BOOTMAGIC_ENABLE = lite` where `BOOTMAGIC_ENABLE = full` was being used. Command: ``` find keyboards/ -type f -name 'rules.mk' -and -not -path '*/keymaps/*' -exec sed -i -e 's;\(BOOTMAGIC_ENABLE = \)full;\1lite;g' '{}' + ``` * update keymap/user BOOTMAGIC_ENABLE settings Updates keymap/user `rules.mk` files to use `BOOTMAGIC_ENABLE = lite` where `BOOTMAGIC_ENABLE = full` was being used. Commands: ``` find keyboards/ -type f -name 'rules.mk' -and -path '*/keymaps/*' -exec sed -i -e 's;\(BOOTMAGIC_ENABLE[ \t=]\+\)full;\1lite;g' '{}' + find layouts/community/ users/ -type f -name 'rules.mk' -exec sed -i -e 's;\(BOOTMAGIC_ENABLE[ \t=]\+\)full;\1lite;g' '{}' + ``` * remove and replace inline comments in keyboards and keymap/user files Removes and replaces the inline comments, which have been updated to read `Enable Bootmagic Lite`. Commands: ``` find keyboards/ -type f -name 'rules.mk' -and -path '*/keymaps/*' -exec sed -i -e 's;\(BOOTMAGIC_ENABLE\)[ \t=]\+\([a-z]\+\).*;\1 = \2;g' '{}' + find layouts/community/ users/ -type f -name 'rules.mk' -exec sed -i -e 's;\(BOOTMAGIC_ENABLE\)[ \t=]\+\([a-z]\+\).*;\1 = \2;g' '{}' + find keyboards/ layouts/community/ users/ -type f -name 'rules.mk' -exec sed -i -e 's;\(BOOTMAGIC_ENABLE = lite\);\1 # Enable Bootmagic Lite;g' '{}' + find keyboards/ layouts/community/ users/ -type f -name 'rules.mk' -exec sed -i -e 's;\(BOOTMAGIC_ENABLE = yes\);\1 # Enable Bootmagic Lite;g' '{}' + find keyboards/ layouts/community/ users/ -type f -name 'rules.mk' -exec sed -i -e 's;\(BOOTMAGIC_ENABLE = no\);\1 # Enable Bootmagic Lite;g' '{}' + ``` * rename improperly named makefiles Some files intended to be used as makefiles had improper names causing them to not be used as intended when building. This commit corrects the filenames of the affected files. * update renamed file with new rule formatting * update QMK's template files Updates QMK's `rules.mk` templates to use the new inline comment. * update QMK Docs - remove documentation of full Bootmagic - update links to Bootmagic Lite doc - add doc for Magic Keycodes * rules.mk patch for coarse/ixora and coarse/vinta
2 years ago
  1. # QMK Keyboard Guidelines
  2. Since starting, QMK has grown by leaps and bounds thanks to people like you who contribute to creating and maintaining our community keyboards. As we've grown we've discovered some patterns that work well, and ask that you conform to them to make it easier for other people to benefit from your hard work.
  3. ## Use QMK Lint
  4. We have provided a tool, `qmk lint`, which will let you check over your keyboard for problems. We suggest using it frequently while working on your keyboard and keymap.
  5. Example passing check:
  6. ```
  7. $ qmk lint -kb rominronin/katana60/rev2
  8. Ψ Lint check passed!
  9. ```
  10. Example failing check:
  11. ```
  12. $ qmk lint -kb clueboard/66/rev3
  13. ☒ Missing keyboards/clueboard/66/rev3/readme.md
  14. ☒ Lint check failed!
  15. ```
  16. ## Naming Your Keyboard/Project
  17. All keyboard names are in lower case, consisting only of letters, numbers, and underscore (`_`). Names may not begin with an underscore. Forward slash (`/`) is used as a sub-folder separation character.
  18. The names `test`, `keyboard`, and `all` are reserved for make commands and may not be used as a keyboard or subfolder name.
  19. Valid Examples:
  20. * `412_64`
  21. * `chimera_ortho`
  22. * `clueboard/66/rev3`
  23. * `planck`
  24. * `v60_type_r`
  25. ## Sub-folders
  26. QMK uses sub-folders both for organization and to share code between revisions of the same keyboard. You can nest folders up to 4 levels deep:
  27. qmk_firmware/keyboards/top_folder/sub_1/sub_2/sub_3/sub_4
  28. If a sub-folder has a `rules.mk` file it will be considered a compilable keyboard. It will be available in QMK Configurator and tested with `make all`. If you are using a folder to organize several keyboards from the same maker you should not have a `rules.mk` file.
  29. Example:
  30. Clueboard uses sub-folders for both purposes, organization and keyboard revisions.
  31. * [`qmk_firmware`](https://github.com/qmk/qmk_firmware/tree/master)
  32. * [`keyboards`](https://github.com/qmk/qmk_firmware/tree/master/keyboards)
  33. * [`clueboard`](https://github.com/qmk/qmk_firmware/tree/master/keyboards/clueboard) ← This is the organization folder, there's no `rules.mk` file
  34. * [`60`](https://github.com/qmk/qmk_firmware/tree/master/keyboards/clueboard/60) ← This is a compilable keyboard, it has a `rules.mk` file
  35. * [`66`](https://github.com/qmk/qmk_firmware/tree/master/keyboards/clueboard/66) ← This is also compilable- it uses `DEFAULT_FOLDER` to specify `rev3` as the default revision
  36. * [`rev1`](https://github.com/qmk/qmk_firmware/tree/master/keyboards/clueboard/66/rev1) ← compilable: `make clueboard/66/rev1`
  37. * [`rev2`](https://github.com/qmk/qmk_firmware/tree/master/keyboards/clueboard/66/rev2) ← compilable: `make clueboard/66/rev2`
  38. * [`rev3`](https://github.com/qmk/qmk_firmware/tree/master/keyboards/clueboard/66/rev3) ← compilable: `make clueboard/66/rev3` or `make clueboard/66`
  39. ## Keyboard Folder Structure
  40. Your keyboard should be located in `qmk_firmware/keyboards/` and the folder name should be your keyboard's name as described in the previous section. Inside this folder should be several files:
  41. * `readme.md`
  42. * `info.json`
  43. * `config.h`
  44. * `rules.mk`
  45. * `<keyboard_name>.c`
  46. * `<keyboard_name>.h`
  47. ### `readme.md`
  48. All projects need to have a `readme.md` file that explains what the keyboard is, who made it and where it's available. If applicable, it should also contain links to more information, such as the maker's website. Please follow the [published template](documentation_templates.md#keyboard-readmemd-template).
  49. ### `info.json`
  50. This file is used by the [QMK API](https://github.com/qmk/qmk_api). It contains the information [QMK Configurator](https://config.qmk.fm/) needs to display a representation of your keyboard. You can also set metadata here. For more information see the [reference page](reference_info_json.md).
  51. ### `config.h`
  52. All projects need to have a `config.h` file that sets things like the matrix size, product name, USB VID/PID, description and other settings. In general, use this file to set essential information and defaults for your keyboard that will always work.
  53. The `config.h` files can also be placed in sub-folders, and the order in which they are read is as follows:
  54. * `keyboards/top_folder/config.h`
  55. * `keyboards/top_folder/sub_1/config.h`
  56. * `keyboards/top_folder/sub_1/sub_2/config.h`
  57. * `keyboards/top_folder/sub_1/sub_2/sub_3/config.h`
  58. * `keyboards/top_folder/sub_1/sub_2/sub_3/sub_4/config.h`
  59. * `users/a_user_folder/config.h`
  60. * `keyboards/top_folder/keymaps/a_keymap/config.h`
  61. * `keyboards/top_folder/sub_1/sub_2/sub_3/sub_4/post_config.h`
  62. * `keyboards/top_folder/sub_1/sub_2/sub_3/post_config.h`
  63. * `keyboards/top_folder/sub_1/sub_2/post_config.h`
  64. * `keyboards/top_folder/sub_1/post_config.h`
  65. * `keyboards/top_folder/post_config.h`
  66. The `post_config.h` file can be used for additional post-processing, depending on what is specified in the `config.h` file. For example, if you define the `IOS_DEVICE_ENABLE` macro in your keymap-level `config.h` file as follows, you can configure more detailed settings accordingly in the `post_config.h` file:
  67. * `keyboards/top_folder/keymaps/a_keymap/config.h`
  68. ```c
  69. #define IOS_DEVICE_ENABLE
  70. ```
  71. * `keyboards/top_folder/post_config.h`
  72. ```c
  73. #ifndef IOS_DEVICE_ENABLE
  74. // USB_MAX_POWER_CONSUMPTION value for this keyboard
  75. #define USB_MAX_POWER_CONSUMPTION 400
  76. #else
  77. // fix iPhone and iPad power adapter issue
  78. // iOS device need lessthan 100
  79. #define USB_MAX_POWER_CONSUMPTION 100
  80. #endif
  81. #ifdef RGBLIGHT_ENABLE
  82. #ifndef IOS_DEVICE_ENABLE
  83. #define RGBLIGHT_LIMIT_VAL 200
  84. #define RGBLIGHT_VAL_STEP 17
  85. #else
  86. #define RGBLIGHT_LIMIT_VAL 35
  87. #define RGBLIGHT_VAL_STEP 4
  88. #endif
  89. #ifndef RGBLIGHT_HUE_STEP
  90. #define RGBLIGHT_HUE_STEP 10
  91. #endif
  92. #ifndef RGBLIGHT_SAT_STEP
  93. #define RGBLIGHT_SAT_STEP 17
  94. #endif
  95. #endif
  96. ```
  97. ?> If you define options using `post_config.h` as in the above example, you should not define the same options in the keyboard- or user-level `config.h`.
  98. ### `rules.mk`
  99. The presence of this file means that the folder is a keyboard target and can be used in `make` commands. This is where you setup the build environment for your keyboard and configure the default set of features.
  100. The `rules.mk` file can also be placed in a sub-folder, and its reading order is as follows:
  101. * `keyboards/top_folder/rules.mk`
  102. * `keyboards/top_folder/sub_1/rules.mk`
  103. * `keyboards/top_folder/sub_1/sub_2/rules.mk`
  104. * `keyboards/top_folder/sub_1/sub_2/sub_3/rules.mk`
  105. * `keyboards/top_folder/sub_1/sub_2/sub_3/sub_4/rules.mk`
  106. * `keyboards/top_folder/keymaps/a_keymap/rules.mk`
  107. * `users/a_user_folder/rules.mk`
  108. * `common_features.mk`
  109. Many of the settings written in the `rules.mk` file are interpreted by `common_features.mk`, which sets the necessary source files and compiler options.
  110. ?> See `build_keyboard.mk` and `common_features.mk` for more details.
  111. ### `<keyboard_name.c>`
  112. This is where you will write custom code for your keyboard. Typically you will write code to initialize and interface with the hardware in your keyboard. If your keyboard consists of only a key matrix with no LEDs, speakers, or other auxiliary hardware this file can be blank.
  113. The following functions are typically defined in this file:
  114. * `void matrix_init_kb(void)`
  115. * `void matrix_scan_kb(void)`
  116. * `bool process_record_kb(uint16_t keycode, keyrecord_t *record)`
  117. * `void led_set_kb(uint8_t usb_led)`
  118. ### `<keyboard_name.h>`
  119. This file is used to define the matrix for your keyboard. You should define at least one C macro which translates an array into a matrix representing the physical switch matrix for your keyboard. If it's possible to build your keyboard with multiple layouts you should define additional macros.
  120. If you have only a single layout you should call this macro `LAYOUT`.
  121. When defining multiple layouts you should have a base layout, named `LAYOUT_all`, that supports all possible switch positions on your matrix, even if that layout is impossible to build physically. This is the macro you should use in your `default` keymap. You should then have additional keymaps named `default_<layout>` that use your other layout macros. This will make it easier for people to use the layouts you define.
  122. Layout macro names are entirely lowercase, except for the word `LAYOUT` at the front.
  123. As an example, if you have a 60% PCB that supports ANSI and ISO you might define the following layouts and keymaps:
  124. | Layout Name | Keymap Name | Description |
  125. |-------------|-------------|-------------|
  126. | LAYOUT_all | default | A layout that supports both ISO and ANSI |
  127. | LAYOUT_ansi | default_ansi | An ANSI layout |
  128. | LAYOUT_iso | default_iso | An ISO layout |
  129. ## Image/Hardware Files
  130. In an effort to keep the repo size down we're no longer accepting binary files of any format, with few exceptions. Hosting them elsewhere (such as <https://imgur.com>) and linking them in the `readme.md` is preferred.
  131. Hardware files (such as plates, cases, pcb) can be contributed to the [qmk.fm repo](https://github.com/qmk/qmk.fm) and they will be made available on [qmk.fm](https://qmk.fm). Downloadable files are stored in `/<keyboard>/` (name follows the same format as above) which are served at `https://qmk.fm/<keyboard>/`, and pages are generated from `/_pages/<keyboard>/` which are served at the same location (.md files are generated into .html files through Jekyll). Check out the `lets_split` folder for an example.
  132. ## Keyboard Defaults
  133. Given the amount of functionality that QMK exposes it's very easy to confuse new users. When putting together the default firmware for your keyboard we recommend limiting your enabled features and options to the minimal set needed to support your hardware. Recommendations for specific features follow.
  134. ### Magic Keycodes and Command
  135. [Magic Keycodes](keycodes_magic.md) and [Command](feature_command.md) are two related features that allow a user to control their keyboard in non-obvious ways. We recommend you think long and hard about if you're going to enable either feature, and how you will expose this functionality. Keep in mind that users who want this functionality can enable it in their personal keymaps without affecting all the novice users who may be using your keyboard as their first programmable board.
  136. By far the most common problem new users encounter is accidentally triggering Bootmagic while they're plugging in their keyboard. They're holding the keyboard by the bottom, unknowingly pressing in alt and spacebar, and then they find that these keys have been swapped on them. We recommend leaving this feature disabled by default, but if you do turn it on consider setting `BOOTMAGIC_KEY_SALT` to a key that is hard to press while plugging your keyboard in.
  137. If your keyboard does not have 2 shift keys you should provide a working default for `IS_COMMAND`, even when you have set `COMMAND_ENABLE = no`. This will give your users a default to conform to if they do enable Command.
  138. ## Custom Keyboard Programming
  139. As documented on [Customizing Functionality](custom_quantum_functions.md) you can define custom functions for your keyboard. Please keep in mind that your users may want to customize that behavior as well, and make it possible for them to do that. If you are providing a custom function, for example `process_record_kb()`, make sure that your function calls the `_user()` version of the call too. You should also take into account the return value of the `_user()` version, and only run your custom code if the user returns `true`.
  140. ## Non-Production/Handwired Projects
  141. We're happy to accept any project that uses QMK, including prototypes and handwired ones, but we have a separate `/keyboards/handwired/` folder for them, so the main `/keyboards/` folder doesn't get overcrowded. If a prototype project becomes a production project at some point in the future, we'd be happy to move it to the main `/keyboards/` folder!
  142. ## Warnings as Errors
  143. When developing your keyboard, keep in mind that all warnings will be treated as errors - these small warnings can build-up and cause larger errors down the road (and keeping them is generally a bad practice).
  144. ## Copyright Blurb
  145. If you're adapting your keyboard's setup from another project, but not using the same code, be sure to update the copyright header at the top of the files to show your name, in this format:
  146. Copyright 2017 Your Name <your@email.com>
  147. If you are modifying someone else's code and have made only trivial changes you should leave their name in the copyright statement. If you have done significant work on the file you should add your name to theirs, like so:
  148. Copyright 2017 Their Name <original_author@example.com> Your Name <you@example.com>
  149. The year should be the first year the file is created. If work was done to that file in later years you can reflect that by appending the second year to the first, like so:
  150. Copyright 2015-2017 Your Name <you@example.com>
  151. ## License
  152. The core of QMK is licensed under the [GNU General Public License](https://www.gnu.org/licenses/licenses.en.html). If you are shipping binaries for AVR processors you may choose either [GPLv2](https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) or [GPLv3](https://www.gnu.org/licenses/gpl.html). If you are shipping binaries for ARM processors you must choose [GPL Version 3](https://www.gnu.org/licenses/gpl.html) to comply with the [ChibiOS](https://www.chibios.org) GPLv3 license.
  153. If your keyboard makes use of the [uGFX](https://ugfx.io) features within QMK you must comply with the [uGFX License](https://ugfx.io/license.html), which requires a separate commercial license before selling a device containing uGFX.
  154. ## Technical Details
  155. If you're looking for more information on making your keyboard work with QMK, [check out the hardware section](hardware.md)!