master
Raheman Vaiya 4 years ago
parent 076a1868e5
commit ff8680d7bc
  1. 10
      src/keyboard.c
  2. 24
      src/keyd.c
  3. 4
      t/disarm3.t
  4. 19
      t/macro-disarm.t
  5. 4
      t/test.conf

@ -279,17 +279,15 @@ static void kbd_execute_macro(struct keyboard *kbd,
int hold_start = -1;
uint16_t active_mods = kbd_compute_mods(kbd);
send_mods(active_mods, 0);
disarm_mods(active_mods);
for (i = 0; i < macro->sz; i++) {
const struct macro_entry *ent = &macro->entries[i];
switch (ent->type) {
case MACRO_HOLD:
if (hold_start == -1) {
if (hold_start == -1)
hold_start = i;
set_mods(0);
}
send_key(ent->data.sequence.code, 1);
@ -305,10 +303,12 @@ static void kbd_execute_macro(struct keyboard *kbd,
}
break;
case MACRO_KEYSEQUENCE:
set_mods(ent->data.sequence.mods);
send_mods(ent->data.sequence.mods, 1);
send_key(ent->data.sequence.code, 1);
send_key(ent->data.sequence.code, 0);
send_mods(ent->data.sequence.mods, 0);
break;
case MACRO_TIMEOUT:
usleep(ent->data.timeout*1E3);

@ -103,30 +103,6 @@ static void send_repetitions()
}
}
void set_mods(uint16_t mods)
{
static uint16_t state = 0;
size_t i;
uint16_t diff = mods ^ state;
if (debug && diff)
fprintf(stderr, "Active mods: %s\n", modstring(mods));
if (MOD_CTRL & diff)
send_key(KEY_LEFTCTRL, !!(MOD_CTRL & mods));
if (MOD_ALT_GR & diff)
send_key(KEY_RIGHTALT, !!(MOD_ALT_GR & mods));
if (MOD_SHIFT & diff)
send_key(KEY_LEFTSHIFT, !!(MOD_SHIFT & mods));
if (MOD_SUPER & diff)
send_key(KEY_LEFTMETA, !!(MOD_SUPER & mods));
if (MOD_ALT & diff)
send_key(KEY_LEFTALT, !!(MOD_ALT & mods));
state = mods;
}
/* Block on the given keyboard nodes until no keys are depressed. */
static void await_keyboard_neutrality(char **devs, int n)
{

@ -1,6 +1,6 @@
alt down
m down
m up
7 down
7 up
alt up
alt down

@ -0,0 +1,19 @@
alt down
m down
m up
alt up
alt down
control down
alt up
control up
control down
x down
x up
control up
m down
m up
alt down
control down
alt up
control up

@ -65,8 +65,8 @@ a = b
9 = layout(main)
[myalt:A]
m = x
m = macro(C-x m)
7 = x
s = swap(swapped1)
` = swap(tablayer)
1 = swap(tablayer, tab)

Loading…
Cancel
Save