Change: 0 means default_layer in current_layer now
- current_layer indicates active layer at the time - default_layer indicates base layer - default_layer is used when current_layer is 0 - with this LAYER_BIT action works as overlay even if default_layer varies other than layer 0.master
parent
a43ab35b7b
commit
a4aae1c505
|
@ -289,6 +289,7 @@ void action_exec(keyevent_t event)
|
||||||
static action_t get_action(key_t key)
|
static action_t get_action(key_t key)
|
||||||
{
|
{
|
||||||
action_t action;
|
action_t action;
|
||||||
|
action.code = ACTION_NO;
|
||||||
|
|
||||||
/* layer stack */
|
/* layer stack */
|
||||||
for (layer_item_t i = layer_stack[top_layer]; i.used; i = layer_stack[i.next]) {
|
for (layer_item_t i = layer_stack[top_layer]; i.used; i = layer_stack[i.next]) {
|
||||||
|
@ -301,14 +302,18 @@ static action_t get_action(key_t key)
|
||||||
debug("layer_stack: through. "); debug_dec(i.layer); debug("\n");
|
debug("layer_stack: through. "); debug_dec(i.layer); debug("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* current layer */
|
/* current layer: 0 means default layer */
|
||||||
action = action_for_key(current_layer, key);
|
if (current_layer) {
|
||||||
|
action = action_for_key(current_layer, key);
|
||||||
|
if (action.code != ACTION_TRANSPARENT) {
|
||||||
|
debug("current layer: used. "); debug_dec(current_layer); debug("\n");
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* default layer */
|
/* default layer */
|
||||||
if (action.code == ACTION_TRANSPARENT) {
|
debug("default layer: used. \n");
|
||||||
debug("TRNASPARENT: "); debug_hex16(action.code); debug("\n");
|
action = action_for_key(default_layer, key);
|
||||||
action = action_for_key(default_layer, key);
|
|
||||||
}
|
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -469,7 +474,7 @@ static void process_action(keyrecord_t *record)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// NOTE: This is needed by legacy keymap support
|
// NOTE: This is needed by legacy keymap support
|
||||||
layer_switch(default_layer);
|
layer_switch(0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case LAYER_ON_PRESS:
|
case LAYER_ON_PRESS:
|
||||||
|
@ -500,18 +505,18 @@ static void process_action(keyrecord_t *record)
|
||||||
case LAYER_SET_DEFAULT_ON_PRESS:
|
case LAYER_SET_DEFAULT_ON_PRESS:
|
||||||
if (event.pressed) {
|
if (event.pressed) {
|
||||||
default_layer = action.layer.val;
|
default_layer = action.layer.val;
|
||||||
layer_switch(default_layer);
|
layer_switch(0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case LAYER_SET_DEFAULT_ON_RELEASE:
|
case LAYER_SET_DEFAULT_ON_RELEASE:
|
||||||
if (!event.pressed) {
|
if (!event.pressed) {
|
||||||
default_layer = action.layer.val;
|
default_layer = action.layer.val;
|
||||||
layer_switch(default_layer);
|
layer_switch(0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case LAYER_SET_DEFAULT_ON_BOTH:
|
case LAYER_SET_DEFAULT_ON_BOTH:
|
||||||
default_layer = action.layer.val;
|
default_layer = action.layer.val;
|
||||||
layer_switch(default_layer);
|
layer_switch(0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
/* tap key */
|
/* tap key */
|
||||||
|
@ -530,7 +535,7 @@ static void process_action(keyrecord_t *record)
|
||||||
} else {
|
} else {
|
||||||
// NOTE: This is needed by legacy keymap support
|
// NOTE: This is needed by legacy keymap support
|
||||||
debug("LAYER_SET: No tap: return to default layer(on release)\n");
|
debug("LAYER_SET: No tap: return to default layer(on release)\n");
|
||||||
layer_switch(default_layer);
|
layer_switch(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -573,19 +578,19 @@ static void process_action(keyrecord_t *record)
|
||||||
break;
|
break;
|
||||||
case LAYER_SET_DEFAULT_ON_PRESS:
|
case LAYER_SET_DEFAULT_ON_PRESS:
|
||||||
if (event.pressed) {
|
if (event.pressed) {
|
||||||
default_layer = current_layer ^ action.layer.val;
|
default_layer = default_layer ^ action.layer.val;
|
||||||
layer_switch(default_layer);
|
layer_switch(0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case LAYER_SET_DEFAULT_ON_RELEASE:
|
case LAYER_SET_DEFAULT_ON_RELEASE:
|
||||||
if (!event.pressed) {
|
if (!event.pressed) {
|
||||||
default_layer = current_layer ^ action.layer.val;
|
default_layer = default_layer ^ action.layer.val;
|
||||||
layer_switch(default_layer);
|
layer_switch(0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case LAYER_SET_DEFAULT_ON_BOTH:
|
case LAYER_SET_DEFAULT_ON_BOTH:
|
||||||
default_layer = current_layer ^ action.layer.val;
|
default_layer = default_layer ^ action.layer.val;
|
||||||
layer_switch(default_layer);
|
layer_switch(0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// tap key
|
// tap key
|
||||||
|
|
|
@ -261,8 +261,9 @@ static bool command_common(uint8_t code)
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
case KC_ESC:
|
||||||
|
case KC_GRV:
|
||||||
case KC_0:
|
case KC_0:
|
||||||
case KC_F10:
|
|
||||||
clear_keyboard();
|
clear_keyboard();
|
||||||
switch_layer(0);
|
switch_layer(0);
|
||||||
break;
|
break;
|
||||||
|
@ -270,7 +271,7 @@ static bool command_common(uint8_t code)
|
||||||
clear_keyboard();
|
clear_keyboard();
|
||||||
switch_layer((code - KC_1) + 1);
|
switch_layer((code - KC_1) + 1);
|
||||||
break;
|
break;
|
||||||
case KC_F1 ... KC_F9:
|
case KC_F1 ... KC_F12:
|
||||||
clear_keyboard();
|
clear_keyboard();
|
||||||
switch_layer((code - KC_F1) + 1);
|
switch_layer((code - KC_F1) + 1);
|
||||||
break;
|
break;
|
||||||
|
@ -545,7 +546,7 @@ static void switch_layer(uint8_t layer)
|
||||||
{
|
{
|
||||||
print_val_hex8(current_layer);
|
print_val_hex8(current_layer);
|
||||||
print_val_hex8(default_layer);
|
print_val_hex8(default_layer);
|
||||||
current_layer = layer;
|
|
||||||
default_layer = layer;
|
default_layer = layer;
|
||||||
|
current_layer = 0;
|
||||||
print("switch to "); print_val_hex8(layer);
|
print("switch to "); print_val_hex8(layer);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue