Add landscape layers

This commit is contained in:
Stacy Harper
2021-08-26 19:20:20 +02:00
committed by John Sullivan
parent 450d43ff44
commit e100aafb05
4 changed files with 48 additions and 4 deletions

View File

@@ -97,7 +97,14 @@ void kbd_init(struct kbd *kb, struct layout * layouts, char * layer_names_list)
}
fprintf(stderr, "Found %d layers\n",i);
kb->layout = &kb->layouts[kb->layers[kb->layer_index]];
enum layout_id layer;
if (kb->landscape) {
layer = kb->landscape_layers[kb->layer_index];
} else {
layer = kb->layers[kb->layer_index];
}
kb->layout = &kb->layouts[layer];
kb->prevlayout = kb->layout;
/* upload keymap */
@@ -236,10 +243,21 @@ kbd_press_key(struct kbd *kb, struct key *k, uint32_t time) {
case NextLayer:
//switch to the next layout in the layer sequence
kb->layer_index++;
if (kb->layers[kb->layer_index] == NumLayouts) {
kb->layer_index = 0;
enum layout_id layer;
if (kb->landscape) {
layer = kb->landscape_layers[kb->layer_index];
} else {
layer = kb->layers[kb->layer_index];
}
kbd_switch_layout(kb, &kb->layouts[kb->layers[kb->layer_index]]);
if (layer == NumLayouts) {
kb->layer_index = 0;
if (kb->landscape) {
layer = kb->landscape_layers[kb->layer_index];
} else {
layer = kb->layers[kb->layer_index];
}
}
kbd_switch_layout(kb, &kb->layouts[layer]);
break;
case BackLayer:
//switch to the previously active layout