diff --git a/src/config.c b/src/config.c index 537ac9d..59ce475 100644 --- a/src/config.c +++ b/src/config.c @@ -52,6 +52,7 @@ static struct { { "layer", OP_LAYER, { ARG_LAYER } }, { "overload", OP_OVERLOAD, { ARG_LAYER, ARG_DESCRIPTOR } }, { "overload2", OP_OVERLOAD2, { ARG_LAYER, ARG_DESCRIPTOR, ARG_TIMEOUT } }, + { "overload3", OP_OVERLOAD3, { ARG_LAYER, ARG_DESCRIPTOR, ARG_TIMEOUT } }, { "timeout", OP_TIMEOUT, { ARG_DESCRIPTOR, ARG_TIMEOUT, ARG_DESCRIPTOR } }, { "macro2", OP_MACRO2, { ARG_TIMEOUT, ARG_TIMEOUT, ARG_MACRO } }, { "setlayout", OP_LAYOUT, { ARG_LAYOUT } }, diff --git a/src/config.h b/src/config.h index 8565ac9..80609b6 100644 --- a/src/config.h +++ b/src/config.h @@ -32,6 +32,7 @@ enum op { OP_CLEAR, OP_OVERLOAD, OP_OVERLOAD2, + OP_OVERLOAD3, OP_TOGGLE, OP_TOGGLE2, diff --git a/src/keyboard.c b/src/keyboard.c index 595b555..de11d35 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -365,6 +365,7 @@ static long process_descriptor(struct keyboard *kbd, uint8_t code, } break; + case OP_OVERLOAD3: case OP_OVERLOAD2: if (pressed) { uint8_t layer = d->args[0].idx; @@ -372,6 +373,7 @@ static long process_descriptor(struct keyboard *kbd, uint8_t code, timeout = d->args[2].idx; kbd->overload2.active = 1; + kbd->overload2.resolve_on_tap = d->op == OP_OVERLOAD2 ? 0 : 1; kbd->overload2.code = code; kbd->overload2.layer = layer; kbd->overload2.action = action; @@ -710,7 +712,7 @@ static long process_event(struct keyboard *kbd, uint8_t code, int pressed, int t ev->timestamp = time; //TODO: make this optional (overload3) - if (!pressed) { + if (kbd->overload2.resolve_on_tap && !pressed) { size_t i; for (i = 0; i < kbd->overload2.n; i++) if (kbd->overload2.queued[i].code == code && diff --git a/src/keyboard.h b/src/keyboard.h index fc82a72..27df75e 100644 --- a/src/keyboard.h +++ b/src/keyboard.h @@ -62,6 +62,7 @@ struct keyboard { struct key_event queued[32]; uint8_t n; + uint8_t resolve_on_tap; } overload2; struct { diff --git a/t/overload_2.t b/t/overload_2.t index 70cd2e0..c9cc5ef 100644 --- a/t/overload_2.t +++ b/t/overload_2.t @@ -21,10 +21,10 @@ a down a up control down control up -control down +a down +a up x down x up -control up a down a up x down diff --git a/t/overload_3.t b/t/overload_3.t new file mode 100644 index 0000000..af195ad --- /dev/null +++ b/t/overload_3.t @@ -0,0 +1,26 @@ +' down +x down +x up +' up +' down +x down +' up +x up +' down +x down +11ms +' up +x up + +control down +x down +x up +control up +' down +' up +x down +x up +control down +x down +control up +x up diff --git a/t/test.conf b/t/test.conf index d55d922..5210d5e 100644 --- a/t/test.conf +++ b/t/test.conf @@ -25,6 +25,7 @@ m = macro(C-h one) c = oneshot(control) s = layer(shift) o = overload2(control, a, 10) +' = overload3(control, ', 10) ; = overload2(shift, b, 10) - = toggle(dvorak) = = timeout(a, 300, b)