Always use the longest composite layer

Currently composite layers will be activated in the order in which they
are defined which can cause shorter sequences to take precedence over
longer ones. This patch ensures the longest composite sequence always
takes precedence.
master
Raheman Vaiya 4 years ago
parent a9fc493d2d
commit 7752e4bf3b
  1. 6
      src/keyboard.c
  2. 21
      t/composite.t
  3. 25
      t/composite2.t
  4. 8
      t/test.conf

@ -200,6 +200,7 @@ void kbd_reset(struct keyboard *kbd)
static void lookup_descriptor(struct keyboard *kbd, uint8_t code, uint8_t *layer_mods, struct descriptor *d)
{
size_t max;
size_t i;
uint8_t active[MAX_LAYERS];
struct layer_table *lt = &kbd->layer_table;
@ -223,6 +224,7 @@ static void lookup_descriptor(struct keyboard *kbd, uint8_t code, uint8_t *layer
}
}
max = 0;
/* Scan for any composite matches (which take precedence). */
for (i = 0; i < lt->nr; i++) {
struct layer *layer = &lt->layers[i];
@ -239,9 +241,11 @@ static void lookup_descriptor(struct keyboard *kbd, uint8_t code, uint8_t *layer
match = 0;
}
if (match && layer->keymap[code].op) {
if (match && layer->keymap[code].op && (layer->nr_layers > max)) {
*layer_mods = mods;
*d = layer->keymap[code];
max = layer->nr_layers;
}
}
}

@ -0,0 +1,21 @@
control down
alt down
h down
h up
control up
alt up
control down
alt down
alt up
control up
shift down
h down
h up
shift up
control down
alt down
control up
control down
alt up
control up

@ -0,0 +1,25 @@
control down
shift down
alt down
h down
h up
control up
shift up
alt up
control down
shift down
alt down
alt up
control up
shift up
left down
left up
control down
shift down
alt down
control up
shift up
control down
alt up
control up

@ -73,6 +73,14 @@ s = swap(swapped1)
1 = swap(tablayer, tab)
2 = swap(tablayer2, tab)
[myalt+control+shift]
h = left
[myalt+control]
h = H
[swapped1]
a = b

Loading…
Cancel
Save