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>)* *toggle(<layer>)*
Permanently toggle the state of the given 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>)* *overload(<layer>, <action>)*
Activates the given layer while held and executes <action> on tap. Activates the given layer while held and executes <action> on tap.

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

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

@ -483,16 +483,26 @@ static long process_descriptor(struct keyboard *kbd, uint8_t code,
} }
break; break;
case OP_TOGGLE2:
case OP_TOGGLE: case OP_TOGGLE:
idx = d->args[0].idx; idx = d->args[0].idx;
if (!pressed) { 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; kbd->layer_state[idx].toggled = !kbd->layer_state[idx].toggled;
if (kbd->layer_state[idx].toggled) if (kbd->layer_state[idx].toggled)
activate_layer(kbd, code, idx); activate_layer(kbd, code, idx);
else else
deactivate_layer(kbd, idx); deactivate_layer(kbd, idx);
update_mods(kbd, -1, 0);
} else {
clear_oneshot(kbd);
} }
break; break;

@ -28,6 +28,7 @@ s = layer(shift)
- = toggle(dvorak) - = toggle(dvorak)
= = timeout(a, 300, b) = = timeout(a, 300, b)
\ = 😄 \ = 😄
[ = toggle2(control, macro(one))
[layout2:layout] [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 [ down
2 up [ up
t down k down
t up k up
b down [ down
b up [ up
b down
b up
t down
t up
b down
b up
shift down o down
shift up o up
a down n down
a up n up
shift down e down
shift up e up
a down control down
a up k down
shift down k up
shift up o down
b down o up
b up n down
n up
e down
e up
control up

Loading…
Cancel
Save