Deprecate Layer.defaultLayer()

In the original `KeyboardioFirmware`, this was used to store the default keymap
index in EEPROM. When we removed the EEPROM storage, it was meant to be used by
sketches to set a default layer (the minimum layer one can switch to), which was
not nearly as useful. Even worse, the behaviour was complicated to reason about,
and it wasn't used anyway.

For these reasons, it is now deprecated, and will eventually be removed.

Signed-off-by: Gergely Nagy <algernon@keyboard.io>
pull/260/head
Gergely Nagy 6 years ago
parent 24604cba41
commit 8d16a13131
No known key found for this signature in database
GPG Key ID: AC1E90BAC433F68F

@ -16,6 +16,7 @@ If any of this does not make sense to you, or you have trouble updating your .in
- [MagicCombo](#magiccombo) - [MagicCombo](#magiccombo)
- [TypingBreaks](#typingbreaks) - [TypingBreaks](#typingbreaks)
+ [Deprecated APIs and their replacements](#deprecated-apis-and-their-replacements) + [Deprecated APIs and their replacements](#deprecated-apis-and-their-replacements)
- [Removal of Layer.defaultLayer](#removal-of-layerdefaultlayer)
- [Finer OneShot stickability control](#finer-oneshot-stickability-control) - [Finer OneShot stickability control](#finer-oneshot-stickability-control)
- [Source code and namespace rearrangement](#source-code-and-namespace-rearrangement) - [Source code and namespace rearrangement](#source-code-and-namespace-rearrangement)
* [Removed APIs](#removed-apis) * [Removed APIs](#removed-apis)
@ -434,6 +435,12 @@ Storing the settable settings in EEPROM makes it depend on `Kaleidoscope-EEPROM-
## Deprecated APIs and their replacements ## Deprecated APIs and their replacements
### Removal of Layer.defaultLayer
The `Layer.defaultLayer()` method has been deprecated, because it wasn't widely used, nor tested well, and needlessly complicated the layering logic. If one wants to set a default layer, which the keyboard switches to when booting up, `EEPROMSettings.default_layer()` may be of use.
`Layer.defaultLayer` is slated for removal by **2019-02-14**.
### Finer OneShot stickability control ### Finer OneShot stickability control
The [OneShot plugin](doc/plugin/OneShot.md) has much improved stickability control. Instead of only being able to control if one-shot layers should be stickable too, or disabling the sticky feature in general, it is now possible to control stickiness on a per-key basis with the new `OneShot.enableStickability()` and `OneShot.disableStickablity()` methods. The [OneShot plugin](doc/plugin/OneShot.md) has much improved stickability control. Instead of only being able to control if one-shot layers should be stickable too, or disabling the sticky feature in general, it is now possible to control stickiness on a per-key basis with the new `OneShot.enableStickability()` and `OneShot.disableStickablity()` methods.

@ -27,7 +27,6 @@
uint8_t layer_count __attribute__((weak)) = MAX_LAYERS; uint8_t layer_count __attribute__((weak)) = MAX_LAYERS;
namespace kaleidoscope { namespace kaleidoscope {
uint8_t Layer_::DefaultLayer;
uint32_t Layer_::LayerState; uint32_t Layer_::LayerState;
uint8_t Layer_::highestLayer; uint8_t Layer_::highestLayer;
Key Layer_::liveCompositeKeymap[ROWS][COLS]; Key Layer_::liveCompositeKeymap[ROWS][COLS];
@ -107,12 +106,12 @@ void Layer_::updateLiveCompositeKeymap(byte row, byte col) {
} }
void Layer_::updateActiveLayers(void) { void Layer_::updateActiveLayers(void) {
memset(activeLayers, DefaultLayer, ROWS * COLS); memset(activeLayers, 0, ROWS * COLS);
for (byte row = 0; row < ROWS; row++) { for (byte row = 0; row < ROWS; row++) {
for (byte col = 0; col < COLS; col++) { for (byte col = 0; col < COLS; col++) {
int8_t layer = highestLayer; int8_t layer = highestLayer;
while (layer > DefaultLayer) { while (layer > 0) {
if (Layer.isOn(layer)) { if (Layer.isOn(layer)) {
Key mappedKey = (*getKey)(layer, row, col); Key mappedKey = (*getKey)(layer, row, col);
@ -130,7 +129,7 @@ void Layer_::updateActiveLayers(void) {
void Layer_::updateHighestLayer(void) { void Layer_::updateHighestLayer(void) {
// If layer_count is set, start there, otherwise search from the // If layer_count is set, start there, otherwise search from the
// highest possible layer (MAX_LAYERS) for the top active layer // highest possible layer (MAX_LAYERS) for the top active layer
for (byte i = (layer_count - 1); i > DefaultLayer; i--) { for (byte i = (layer_count - 1); i > 0; i--) {
if (bitRead(LayerState, i)) { if (bitRead(LayerState, i)) {
highestLayer = i; highestLayer = i;
return; return;
@ -138,7 +137,7 @@ void Layer_::updateHighestLayer(void) {
} }
// It's not possible to turn off the default layer (see // It's not possible to turn off the default layer (see
// updateActiveLayers()), so if no other layers are active: // updateActiveLayers()), so if no other layers are active:
highestLayer = DefaultLayer; highestLayer = 0;
} }
void Layer_::move(uint8_t layer) { void Layer_::move(uint8_t layer) {
@ -205,15 +204,6 @@ void Layer_::previous(void) {
off(highestLayer); off(highestLayer);
} }
void Layer_::defaultLayer(uint8_t layer) {
move(layer);
DefaultLayer = layer;
}
uint8_t Layer_::defaultLayer(void) {
return DefaultLayer;
}
uint32_t Layer_::getLayerState(void) { uint32_t Layer_::getLayerState(void) {
return LayerState; return LayerState;
} }

@ -83,14 +83,16 @@ class Layer_ {
static uint8_t top(void) { static uint8_t top(void) {
return highestLayer; return highestLayer;
} }
static void defaultLayer(uint8_t layer) DEPRECATED(LAYER_DEFAULT) {}
static uint8_t defaultLayer(void) DEPRECATED(LAYER_DEFAULT) {
return 0;
}
static void next(void); static void next(void);
static void previous(void); static void previous(void);
static boolean isOn(uint8_t layer); static boolean isOn(uint8_t layer);
static void defaultLayer(uint8_t layer);
static uint8_t defaultLayer(void);
static uint32_t getLayerState(void); static uint32_t getLayerState(void);
static Key eventHandler(Key mappedKey, byte row, byte col, uint8_t keyState); static Key eventHandler(Key mappedKey, byte row, byte col, uint8_t keyState);

@ -26,3 +26,8 @@
"------------------------------------------------------------------------\n" \ "------------------------------------------------------------------------\n" \
/* Messages */ /* Messages */
#define _DEPRECATED_MESSAGE_LAYER_DEFAULT \
"Layer.defaultLayer() is deprecated, and a no-op.\n" \
"\n" \
"If you want to set the default layer for the keyboard, consider using\n" \
"EEPROMSettings.default_layer() instead."

Loading…
Cancel
Save