@ -136,30 +136,40 @@ void Layer_::on(uint8_t layer) {
if ( layer_count ! = 0 & & layer > = layer_count )
if ( layer_count ! = 0 & & layer > = layer_count )
return ;
return ;
bool wasOn = isOn ( layer ) ;
// If the target layer was already on, return
if ( isOn ( layer ) )
return ;
// Otherwise, turn on its bit in LayerState
bitSet ( LayerState , layer ) ;
bitSet ( LayerState , layer ) ;
// If the target layer is above the previous highest active layer,
// update highestLayer
if ( layer > highestLayer )
if ( layer > highestLayer )
updateHighestLayer ( ) ;
updateHighestLayer ( ) ;
/* If the layer did turn on, update the keymap cache. See layers.h for an
// Update the keymap cache (but not liveCompositeKeymap; that gets
* explanation about the caches we have . */
// updated separately, when keys toggle on or off. See layers.h)
if ( ! wasOn )
updateActiveLayers ( ) ;
updateActiveLayers ( ) ;
}
}
// Deactivate a given layer
// Deactivate a given layer
void Layer_ : : off ( uint8_t layer ) {
void Layer_ : : off ( uint8_t layer ) {
bool wasOn = isOn ( layer ) ;
// If the target layer was already off, return
if ( ! bitRead ( LayerState , layer ) )
return ;
// Turn off its bit in LayerState
bitClear ( LayerState , layer ) ;
bitClear ( LayerState , layer ) ;
// If the target layer was the previous highest active layer,
// update highestLayer
if ( layer = = highestLayer )
if ( layer = = highestLayer )
updateHighestLayer ( ) ;
updateHighestLayer ( ) ;
/* If the layer did turn off, update the keymap cache. See layers.h for an
// Update the keymap cache (but not liveCompositeKeymap; that gets
* explanation about the caches we have . */
// updated separately, when keys toggle on or off. See layers.h)
if ( wasOn )
updateActiveLayers ( ) ;
updateActiveLayers ( ) ;
}
}
boolean Layer_ : : isOn ( uint8_t layer ) {
boolean Layer_ : : isOn ( uint8_t layer ) {