Add toggle2 (#270)

master
Raheman Vaiya 4 years ago
parent bf63568d72
commit fd6840ddf4
  1. BIN
      data/keyd-application-mapper.1.gz
  2. BIN
      data/keyd.1.gz
  3. 4
      docs/keyd.scdoc
  4. 1
      src/descriptor.c
  5. 1
      src/descriptor.h
  6. 10
      src/keyboard.c
  7. 1
      t/test.conf
  8. 25
      t/toggle-2.t
  9. 46
      t/toggle2.t

Binary file not shown.

Binary file not shown.

@ -467,6 +467,10 @@ arguments.
*toggle(<layer>)*
Permanently toggle the state of the given layer.
*toggle2(<layer>, <macro>)*
Equivalent to *toggle*, but additionally executes the supplied macro before
toggling the layer.
*overload(<layer>, <action>)*
Activates the given layer while held and executes <action> on tap.

@ -36,6 +36,7 @@ static struct {
{ "swap2", OP_SWAP2, { ARG_LAYER, ARG_MACRO } },
{ "oneshot", OP_ONESHOT, { ARG_LAYER } },
{ "toggle", OP_TOGGLE, { ARG_LAYER } },
{ "toggle2", OP_TOGGLE2, { ARG_LAYER, ARG_MACRO } },
{ "layer", OP_LAYER, { ARG_LAYER } },
{ "overload", OP_OVERLOAD, { ARG_LAYER, ARG_DESCRIPTOR } },
{ "timeout", OP_TIMEOUT, { ARG_DESCRIPTOR, ARG_TIMEOUT, ARG_DESCRIPTOR } },

@ -25,6 +25,7 @@ enum op {
OP_LAYER,
OP_OVERLOAD,
OP_TOGGLE,
OP_TOGGLE2,
OP_MACRO,
OP_MACRO2,

@ -483,16 +483,26 @@ static long process_descriptor(struct keyboard *kbd, uint8_t code,
}
break;
case OP_TOGGLE2:
case OP_TOGGLE:
idx = d->args[0].idx;
if (!pressed) {
if (d->op == OP_TOGGLE2) {
macro = &kbd->config.macros[d->args[1].idx];
execute_macro(kbd, dl, macro);
}
kbd->layer_state[idx].toggled = !kbd->layer_state[idx].toggled;
if (kbd->layer_state[idx].toggled)
activate_layer(kbd, code, idx);
else
deactivate_layer(kbd, idx);
update_mods(kbd, -1, 0);
} else {
clear_oneshot(kbd);
}
break;

@ -28,6 +28,7 @@ s = layer(shift)
- = toggle(dvorak)
= = timeout(a, 300, b)
\ = 😄
[ = toggle2(control, macro(one))
[layout2:layout]

@ -0,0 +1,25 @@
2 down
2 up
t down
t up
b down
b up
b down
b up
t down
t up
b down
b up
shift down
shift up
a down
a up
shift down
shift up
a down
a up
shift down
shift up
b down
b up

@ -1,25 +1,23 @@
2 down
2 up
t down
t up
b down
b up
b down
b up
t down
t up
b down
b up
[ down
[ up
k down
k up
[ down
[ up
shift down
shift up
a down
a up
shift down
shift up
a down
a up
shift down
shift up
b down
b up
o down
o up
n down
n up
e down
e up
control down
k down
k up
o down
o up
n down
n up
e down
e up
control up

Loading…
Cancel
Save