mirror of
https://github.com/jjsullivan5196/wvkbd.git
synced 2025-03-13 02:42:47 +01:00
allow modifiers with next layer button to switch to first/previous layer
- shift (or capslock) switch to the previous layer in the defined order - control, alt or compose resets the view to the first layer related fix: compose key resets on layer switch (doesn't stick now)
This commit is contained in:
parent
14f0f0824b
commit
a10b504cda
34
keyboard.c
34
keyboard.c
@ -245,8 +245,8 @@ kbd_motion_key(struct kbd *kb, uint32_t time, uint32_t x, uint32_t y) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
kbd_press_key(struct kbd *kb, struct key *k, uint32_t time) {
|
kbd_press_key(struct kbd *kb, struct key *k, uint32_t time) {
|
||||||
if ((kb->compose == 1) && (k->type != Compose) && (k->type != Mod) &&
|
if ((kb->compose == 1) && (k->type != Compose) && (k->type != Mod) &&
|
||||||
(k->layout)) {
|
(k->type != NextLayer) && (k->layout)) {
|
||||||
kb->compose++;
|
kb->compose++;
|
||||||
if (kb->debug)
|
if (kb->debug)
|
||||||
fprintf(stderr, "showing compose %d\n", kb->compose);
|
fprintf(stderr, "showing compose %d\n", kb->compose);
|
||||||
@ -308,8 +308,30 @@ kbd_press_key(struct kbd *kb, struct key *k, uint32_t time) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case NextLayer:
|
case NextLayer:
|
||||||
// switch to the next layout in the layer sequence
|
if ((kb->mods & Ctrl) || (kb->mods & Alt) || (kb->mods & AltGr) || ((bool)kb->compose)) {
|
||||||
kb->layer_index++;
|
// with modifiers: switch to the first layer
|
||||||
|
kb->layer_index = 0;
|
||||||
|
kb->mods = 0;
|
||||||
|
} else if ((kb->mods & Shift) || (kb->mods & CapsLock)) {
|
||||||
|
// with modifiers: switch to the previous layout in the layer sequence
|
||||||
|
if (kb->layer_index > 0) {
|
||||||
|
kb->layer_index--;
|
||||||
|
} else {
|
||||||
|
size_t layercount = 0;
|
||||||
|
for (size_t i = 0; layercount == 0; i++) {
|
||||||
|
if (kb->landscape) {
|
||||||
|
if (kb->landscape_layers[i] == NumLayouts) layercount = i;
|
||||||
|
} else {
|
||||||
|
if (kb->layers[i] == NumLayouts) layercount = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
kb->layer_index = layercount - 1;
|
||||||
|
}
|
||||||
|
kb->mods = 0;
|
||||||
|
} else {
|
||||||
|
// normal behaviour: switch to the next layout in the layer sequence
|
||||||
|
kb->layer_index++;
|
||||||
|
}
|
||||||
enum layout_id layer;
|
enum layout_id layer;
|
||||||
if (kb->landscape) {
|
if (kb->landscape) {
|
||||||
layer = kb->landscape_layers[kb->layer_index];
|
layer = kb->landscape_layers[kb->layer_index];
|
||||||
@ -324,6 +346,10 @@ kbd_press_key(struct kbd *kb, struct key *k, uint32_t time) {
|
|||||||
layer = kb->layers[kb->layer_index];
|
layer = kb->layers[kb->layer_index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ((bool)kb->compose) {
|
||||||
|
kb->compose = 0;
|
||||||
|
kbd_draw_key(kb, k, Unpress);
|
||||||
|
}
|
||||||
kbd_switch_layout(kb, &kb->layouts[layer]);
|
kbd_switch_layout(kb, &kb->layouts[layer]);
|
||||||
break;
|
break;
|
||||||
case BackLayer:
|
case BackLayer:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user