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.

119 lines
5.4 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
  1. # List of Useful Core Functions To Make Your Keyboard Better
  2. There are a lot of hidden functions in QMK that are incredible useful, or may add a bit of functionality that you've been wanting. Functions that are specific to certain features are not included here, as those will be on their respective feature page.
  3. ## (OLKB) Tri Layers :id=olkb-tri-layers
  4. There are actually separate functions that you can use there, depending on what you're after.
  5. ### `update_tri_layer(x, y, z)`
  6. The first is the `update_tri_layer(x, y, z)` function. This function check to see if layers `x` and `y` are both on. If they are both on, then it turns on layer `z`. Otherwise, if both `x` and `y` are not both on (either only one is, or neither is), then it turns off layer `z`.
  7. This function is useful if you want to create specific keys that have this functionality, but other layer keycodes won't do this.
  8. #### Example
  9. ```c
  10. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  11. switch (keycode) {
  12. case LOWER:
  13. if (record->event.pressed) {
  14. layer_on(_LOWER);
  15. update_tri_layer(_LOWER, _RAISE, _ADJUST);
  16. } else {
  17. layer_off(_LOWER);
  18. update_tri_layer(_LOWER, _RAISE, _ADJUST);
  19. }
  20. return false;
  21. case RAISE:
  22. if (record->event.pressed) {
  23. layer_on(_RAISE);
  24. update_tri_layer(_LOWER, _RAISE, _ADJUST);
  25. } else {
  26. layer_off(_RAISE);
  27. update_tri_layer(_LOWER, _RAISE, _ADJUST);
  28. }
  29. return false;
  30. }
  31. return true;
  32. }
  33. ```
  34. ### `update_tri_layer_state(state, x, y, z)`
  35. The other function is `update_tri_layer_state(state, x, y, z)`. This function is meant to be called from the [`layer_state_set_*` functions](custom_quantum_functions.md#layer-change-code). This means that any time that you use a keycode to change the layer, this will be checked. So you could use `LT(layer, kc)` to change the layer and it will trigger the same layer check.
  36. There are a couple of caveats to this method:
  37. 1. You cannot access the `z` layer without having `x` and `y` layers on, since if you try to activate just layer `z`, it will run this code and turn off layer `z` before you could use it.
  38. 2. Because layers are processed from the highest number `z` should be a higher layer than `x` and `y` or you may not be able to access it.
  39. #### Example
  40. ```c
  41. layer_state_t layer_state_set_user(layer_state_t state) {
  42. return update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST);
  43. }
  44. ```
  45. Alternatively, you don't have to immediately "return" the value. This is useful if you want to add multiple tri layers, or if you want to add additional effects.
  46. ```c
  47. layer_state_t layer_state_set_user(layer_state_t state) {
  48. state = update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST);
  49. state = update_tri_layer_state(state, _RAISE, _SYMB, _SPECIAL);
  50. return state;
  51. }
  52. ```
  53. ## Setting the Persistent Default Layer
  54. Do you want to set the default layer, so that it's retained even after you unplug the board? If so, this is the function for you.
  55. To use this, you would use `set_single_persistent_default_layer(layer)`. If you have a name defined for your layer, you can use that instead (such as _QWERTY, _DVORAK or _COLEMAK).
  56. This will set the default layer, update the persistent settings, and play a tune if you have [Audio](feature_audio.md) enabled on your board, and the default layer sounds set.
  57. To configure the default layer sounds, you would want to define this in your `config.h` file, like this:
  58. ```c
  59. #define DEFAULT_LAYER_SONGS { SONG(QWERTY_SOUND), \
  60. SONG(COLEMAK_SOUND), \
  61. SONG(DVORAK_SOUND) \
  62. }
  63. ```
  64. ?> There are a large number of predefined songs in [quantum/audio/song_list.h](https://github.com/qmk/qmk_firmware/blob/master/quantum/audio/song_list.h) that you can use.
  65. ## Reseting the keyboard
  66. There is the `RESET` quantum keycode that you can use. But if you want to reset the board as part of a macro, rather than hitting a key separately, you can do that.
  67. And to do so, add `reset_keyboard()` to your function or macro, and this will reset to bootloader.
  68. ## Wiping the EEPROM (Persistent Storage)
  69. If you're having issues with Audio, RGB Underglow, backlighting or keys acting weird, then you can reset the EEPROM (persistent setting storage). To force an EEPROM reset, use the [`EEP_RST` keycode](quantum_keycodes.md) or [Bootmagic Lite](feature_bootmagic.md) functionality. If neither of those are an option, then you can use a custom macro to do so.
  70. To wipe the EEPROM, run `eeconfig_init()` from your function or macro to reset most of the settings to default.
  71. ## Tap random key
  72. If you want to send a random character to the host computer, you can use the `tap_random_base64()` function. This [pseudorandomly](https://en.wikipedia.org/wiki/Pseudorandom_number_generator) selects a number between 0 and 63, and then sends a key press based on that selection. (0–25 is `A`–`Z`, 26–51 is `a`–`z`, 52–61 is `0`–`9`, 62 is `+` and 63 is `/`).
  73. ?> Needless to say, but this is _not_ a cryptographically secure method of generating random Base64 keys or passwords.
  74. ## Software Timers
  75. It's possible to start timers and read values for time-specific events. Here's an example:
  76. ```c
  77. static uint16_t key_timer;
  78. key_timer = timer_read();
  79. if (timer_elapsed(key_timer) < 100) {
  80. // do something if less than 100ms have passed
  81. } else {
  82. // do something if 100ms or more have passed
  83. }
  84. ```