fix inconsistent zmk_layer_state_changed

This commit is contained in:
JP Bonn 2021-03-01 00:09:36 -07:00
parent 0f9fff7554
commit 49065a566d

View file

@ -19,8 +19,8 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
#include <zmk/events/layer_state_changed.h>
#include <zmk/events/sensor_event.h>
static zmk_keymap_layers_state_t _zmk_keymap_layer_state = 0;
static uint8_t _zmk_keymap_layer_default = 0;
static const uint8_t _zmk_keymap_layer_default = 0;
static zmk_keymap_layers_state_t _zmk_keymap_layer_state = BIT(_zmk_keymap_layer_default);
#define DT_DRV_COMPAT zmk_keymap
@ -87,7 +87,7 @@ static inline int set_layer_state(uint8_t layer, bool state) {
zmk_keymap_layers_state_t old_state = _zmk_keymap_layer_state;
WRITE_BIT(_zmk_keymap_layer_state, layer, state);
// Don't send state changes unless there was an actual change
if (old_state != _zmk_keymap_layer_state) {
if (old_state != _zmk_keymap_layer_state || layer == _zmk_keymap_layer_default) {
LOG_DBG("layer_changed: layer %d state %d", layer, state);
ZMK_EVENT_RAISE(create_layer_state_changed(layer, state));
}