aliases: Assign keycodes of valid alias key names by default

master
Raheman Vaiya 4 years ago
parent 67a2af0f7f
commit c1655dffbc
  1. BIN
      data/keyd.1.gz
  2. 16
      docs/keyd.scdoc
  3. 19
      src/config.c

Binary file not shown.

@ -279,9 +279,11 @@ E.G
## Aliases
An *alias* may be assigned to a key and used as a valid left hand value.
Multiple keys may be bound to a single alias, but _a given key may only be
assigned to one alias at a time_. For example, the keys 'leftmeta' and
Each key may optionally be assigned to an *alias*. This alias may be used in place
of the key as a valid left hand value. Multiple keys may be bound to the same alias,
but only one alias may be assigned to a key at a given time.
For example, the keys 'leftmeta' and
'rightmeta' are bound to the alias *meta* by default. Thus the binding 'meta =
a' is equivalent to the bindings 'leftmeta = a' and 'rightmeta = a'.
@ -293,9 +295,11 @@ the form:
where _<key>_ must be a valid key name.
Note that <name> may itself be a valid key name, in which case all references
to the key within the config file will be replaced with the new key. When used
judiciously, aliases can be used in conjunction with the include directive to
share bindings between keyboards with different physical layouts.
to the key within the config file will be replaced with the new key.
Additionally, if the assigned alias is a valid key name, the corresponding
keycode will be assigned to the key by default. This makes it possible to
redefine keys before any bindings are applied and is particularly useful in
conjunction with the include mechanism to account for variations in hardware.
For example:

@ -336,21 +336,32 @@ static void parse_aliases(const char *path, struct config *config, struct ini_se
for (i = 0; i < section->nr_entries; i++) {
uint8_t code;
struct ini_entry *ent = &section->entries[i];
const char *name = ent->val;
if ((code = lookup_keycode(ent->key))) {
ssize_t len = strlen(ent->val);
ssize_t len = strlen(name);
if (len > MAX_ALIAS_LEN) {
fprintf(stderr,
"\tERROR: %s exceeds the maximum alias length (%d)\n",
ent->val, MAX_ALIAS_LEN);
name, MAX_ALIAS_LEN);
} else {
strcpy(config->aliases[code], ent->val);
uint8_t alias_code;
if ((alias_code = lookup_keycode(name))) {
struct descriptor *d = &config->layers[0].keymap[code];
d->op = OP_KEYSEQUENCE;
d->args[0].code = alias_code;
d->args[1].mods = 0;
}
strcpy(config->aliases[code], name);
}
} else {
fprintf(stderr,
"\tERROR %s:%zd: Failed to define alias %s, %s is not a valid keycode\n",
path, ent->lnum, ent->key, ent->val);
path, ent->lnum, ent->key, name);
}
}
}

Loading…
Cancel
Save