Introduce delayed overload

this is (for now) a copy of the regular overload; in the future it
will mimic the delayed keys of ahm, in the sense that no modifier or
key will be simulated on keypress, but we will wait until either
keyrelease or another key pressed to make a decision.
master
Jacopo De Simoi 1 year ago
parent 52ab10f41e
commit 4ccc7f91b9
  1. 3
      src/config.c
  2. 1
      src/config.h
  3. 31
      src/keyboard.c

@ -57,7 +57,7 @@ static struct {
{ "oneshotm", NULL, OP_ONESHOTM, { ARG_LAYER, ARG_MACRO } },
{ "layer", NULL, OP_LAYER, { ARG_LAYER } },
{ "overloadd", NULL, OP_OVERLOAD_DELAYED, {ARG_LAYER, ARG_DESCRIPTOR}},
{ "overload", NULL, OP_OVERLOAD, { ARG_LAYER, ARG_DESCRIPTOR } },
{ "overloadt", NULL, OP_OVERLOAD_TIMEOUT, { ARG_LAYER, ARG_DESCRIPTOR, ARG_TIMEOUT } },
{ "overloadt2", NULL, OP_OVERLOAD_TIMEOUT_TAP, { ARG_LAYER, ARG_DESCRIPTOR, ARG_TIMEOUT } },
@ -1027,4 +1027,3 @@ int config_add_entry(struct config *config, const char *exp)
return set_layer_entry(config, layer, keyname, &d);
}

@ -47,6 +47,7 @@ enum op {
OP_MACRO2,
OP_COMMAND,
OP_TIMEOUT,
OP_OVERLOAD_DELAYED,
/* Experimental */
OP_SCROLL_TOGGLE_ON,

@ -662,6 +662,37 @@ static long process_descriptor(struct keyboard *kbd, uint8_t code,
}
}
break;
case OP_OVERLOAD_DELAYED: //At the moment this is just a copy of overload
dbg("overload_delayed");
idx = d->args[0].idx;
action = &kbd->config.descriptors[d->args[1].idx];
if (pressed) {
kbd->overload_start_time = time;
activate_layer(kbd, code, idx);
update_mods(kbd, -1, 0);
} else {
deactivate_layer(kbd, idx);
update_mods(kbd, -1, 0);
if (kbd->last_pressed_code == code &&
(!kbd->config.overload_tap_timeout ||
((time - kbd->overload_start_time) < kbd->config.overload_tap_timeout))) {
if (action->op == OP_MACRO) {
/*
* Macro release relies on event logic, so we can't just synthesize a
* descriptor release.
*/
struct macro *macro = &kbd->config.macros[action->args[0].idx];
execute_macro(kbd, dl, macro);
} else {
process_descriptor(kbd, code, action, dl, 1, time);
process_descriptor(kbd, code, action, dl, 0, time);
}
}
}
break;
case OP_ONESHOTM:
case OP_ONESHOT:

Loading…
Cancel
Save