Add oneshot_timeout option

master
Raheman Vaiya 3 years ago
parent 9b9ed69a6c
commit 7f2dc665fb
  1. BIN
      data/keyd-application-mapper.1.gz
  2. BIN
      data/keyd.1.gz
  3. 3
      docs/keyd.scdoc
  4. 4
      src/config.c
  5. 1
      src/config.h
  6. 10
      src/keyboard.c
  7. 1
      src/keyboard.h

Binary file not shown.

Binary file not shown.

@ -543,7 +543,10 @@ any of the following options:
*chord_hold_timeout:* The length of time a chord
must be held before being activated. (default: 0)
(default: 0)
*oneshot_timeout:* If non-zero, timeout a oneshot layer
activation after the supplied number of milliseconds.
(default: 0)
*Note:* Unicode characters and key sequences are treated as macros, and

@ -419,10 +419,10 @@ static void config_init(struct config *config)
/* In ms */
config->chord_interkey_timeout = 50;
config->chord_hold_timeout = 0;
config->oneshot_timeout = 0;
config->macro_timeout = 600;
config->macro_repeat_timeout = 50;
}
/* Modifies the input string */
@ -730,6 +730,8 @@ static void parse_global_section(struct config *config, struct ini_section *sect
config->macro_timeout = atoi(ent->val);
else if (!strcmp(ent->key, "macro_sequence_timeout"))
config->macro_sequence_timeout = atoi(ent->val);
else if (!strcmp(ent->key, "oneshot_timeout"))
config->oneshot_timeout = atoi(ent->val);
else if (!strcmp(ent->key, "chord_hold_timeout"))
config->chord_hold_timeout = atoi(ent->val);
else if (!strcmp(ent->key, "chord_timeout"))

@ -130,6 +130,7 @@ struct config {
long macro_timeout;
long macro_sequence_timeout;
long macro_repeat_timeout;
long oneshot_timeout;
long chord_interkey_timeout;
long chord_hold_timeout;

@ -404,6 +404,7 @@ static void clear_oneshot(struct keyboard *kbd)
}
kbd->oneshot_latch = 0;
kbd->oneshot_timeout = 0;
}
static void clear(struct keyboard *kbd)
@ -605,6 +606,10 @@ static long process_descriptor(struct keyboard *kbd, uint8_t code,
} else {
if (kbd->oneshot_latch) {
kbd->layer_state[idx].oneshot = 1;
if (kbd->config.oneshot_timeout) {
kbd->oneshot_timeout = time + kbd->config.oneshot_timeout;
schedule_timeout(kbd, kbd->oneshot_timeout);
}
} else {
deactivate_layer(kbd, idx);
update_mods(kbd, -1, 0);
@ -1039,6 +1044,11 @@ static long process_event(struct keyboard *kbd, uint8_t code, int pressed, long
if (handle_pending_key(kbd, code, pressed, time))
goto exit;
if (kbd->oneshot_timeout && time >= kbd->oneshot_timeout) {
clear_oneshot(kbd);
update_mods(kbd, -1, 0);
}
if (kbd->active_macro) {
if (code) {
kbd->active_macro = NULL;

@ -49,6 +49,7 @@ struct keyboard {
struct macro *active_macro;
int active_macro_layer;
long macro_timeout;
long oneshot_timeout;
long macro_repeat_interval;

Loading…
Cancel
Save