mirror of
https://github.com/qmk/qmk_firmware.git
synced 2024-11-22 11:29:26 +00:00
Add easier way to set default single layer (#24376)
* Add set_single_default_layer to match set_single_persistent_default_layer * Implements exactly the same behavior, except the write to EEPROM
This commit is contained in:
parent
208ebf54a9
commit
3cf94cb308
@ -74,6 +74,7 @@ There are a number of functions (and variables) related to how you can use or ma
|
|||||||
| `default_layer_and(layer_mask)` | Turns on layers based on matching enabled bits between specifed layer and existing default layer state. |
|
| `default_layer_and(layer_mask)` | Turns on layers based on matching enabled bits between specifed layer and existing default layer state. |
|
||||||
| `default_layer_xor(layer_mask)` | Turns on layers based on non-matching bits between specifed layer and existing default layer state. |
|
| `default_layer_xor(layer_mask)` | Turns on layers based on non-matching bits between specifed layer and existing default layer state. |
|
||||||
| `default_layer_debug(layer_mask)` | Prints out the current bit mask and highest active default layer to debugger console. |
|
| `default_layer_debug(layer_mask)` | Prints out the current bit mask and highest active default layer to debugger console. |
|
||||||
|
| [`set_single_default_layer(layer)`](ref_functions.md#setting-the-persistent-default-layer) | Sets the default layer, but does _not_ write it to persistent memory (EEPROM). |
|
||||||
| [`set_single_persistent_default_layer(layer)`](ref_functions.md#setting-the-persistent-default-layer) | Sets the default layer and writes it to persistent memory (EEPROM). |
|
| [`set_single_persistent_default_layer(layer)`](ref_functions.md#setting-the-persistent-default-layer) | Sets the default layer and writes it to persistent memory (EEPROM). |
|
||||||
| [`update_tri_layer(x, y, z)`](ref_functions.md#update_tri_layerx-y-z) | Checks if layers `x` and `y` are both on, and sets `z` based on that (on if both on, otherwise off). |
|
| [`update_tri_layer(x, y, z)`](ref_functions.md#update_tri_layerx-y-z) | Checks if layers `x` and `y` are both on, and sets `z` based on that (on if both on, otherwise off). |
|
||||||
| [`update_tri_layer_state(state, x, y, z)`](ref_functions.md#update_tri_layer_statestate-x-y-z) | Does the same as `update_tri_layer(x, y, z)`, but from `layer_state_set_*` functions. |
|
| [`update_tri_layer_state(state, x, y, z)`](ref_functions.md#update_tri_layer_statestate-x-y-z) | Does the same as `update_tri_layer(x, y, z)`, but from `layer_state_set_*` functions. |
|
||||||
|
@ -69,7 +69,7 @@ layer_state_t layer_state_set_user(layer_state_t state) {
|
|||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
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).
|
To do 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).
|
||||||
|
|
||||||
This will set the default layer, update the persistent settings, and play a tune if you have [Audio](features/audio) enabled on your board, and the default layer sounds set.
|
This will set the default layer, update the persistent settings, and play a tune if you have [Audio](features/audio) enabled on your board, and the default layer sounds set.
|
||||||
|
|
||||||
@ -82,6 +82,8 @@ To configure the default layer sounds, you would want to define this in your `co
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
If you do not require it to be retained after you unplug the board, use `set_single_default_layer(layer)` instead.
|
||||||
|
|
||||||
|
|
||||||
::: tip
|
::: tip
|
||||||
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.
|
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.
|
||||||
|
@ -477,14 +477,18 @@ bool process_record_quantum(keyrecord_t *record) {
|
|||||||
return process_action_kb(record);
|
return process_action_kb(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_single_persistent_default_layer(uint8_t default_layer) {
|
void set_single_default_layer(uint8_t default_layer) {
|
||||||
#if defined(AUDIO_ENABLE) && defined(DEFAULT_LAYER_SONGS)
|
#if defined(AUDIO_ENABLE) && defined(DEFAULT_LAYER_SONGS)
|
||||||
PLAY_SONG(default_layer_songs[default_layer]);
|
PLAY_SONG(default_layer_songs[default_layer]);
|
||||||
#endif
|
#endif
|
||||||
eeconfig_update_default_layer((layer_state_t)1 << default_layer);
|
|
||||||
default_layer_set((layer_state_t)1 << default_layer);
|
default_layer_set((layer_state_t)1 << default_layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void set_single_persistent_default_layer(uint8_t default_layer) {
|
||||||
|
eeconfig_update_default_layer((layer_state_t)1 << default_layer);
|
||||||
|
set_single_default_layer(default_layer);
|
||||||
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// Override these functions in your keymap file to play different tunes on
|
// Override these functions in your keymap file to play different tunes on
|
||||||
// different events such as startup and bootloader jump
|
// different events such as startup and bootloader jump
|
||||||
|
@ -240,6 +240,7 @@ extern layer_state_t layer_state;
|
|||||||
# include "os_detection.h"
|
# include "os_detection.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void set_single_default_layer(uint8_t default_layer);
|
||||||
void set_single_persistent_default_layer(uint8_t default_layer);
|
void set_single_persistent_default_layer(uint8_t default_layer);
|
||||||
|
|
||||||
#define IS_LAYER_ON(layer) layer_state_is(layer)
|
#define IS_LAYER_ON(layer) layer_state_is(layer)
|
||||||
|
Loading…
Reference in New Issue
Block a user