write_keycodes(struct xkb_keymap *keymap, char **buf, size_t *size,
size_t *offset)
{
- xkb_keycode_t key;
+ struct xkb_key *key;
struct xkb_key_alias *alias;
int i;
write_buf(keymap, buf, size, offset, "\t\tmaximum = %d;\n",
keymap->max_key_code);
- for (key = keymap->min_key_code; key <= keymap->max_key_code; key++) {
- if (darray_item(keymap->key_names, key).name[0] == '\0')
+ xkb_foreach_key(key, keymap) {
+ if (key->name[0] == '\0')
continue;
write_buf(keymap, buf, size, offset, "\t\t%6s = %d;\n",
- XkbcKeyNameText(darray_item(keymap->key_names, key).name),
- key);
+ XkbcKeyNameText(key->name), XkbKeyGetKeycode(keymap, key));
}
for (i = 0; i < XkbNumIndicators; i++) {
static bool
write_keysyms(struct xkb_keymap *keymap, char **buf, size_t *size,
- size_t *offset, xkb_keycode_t key, unsigned int group)
+ size_t *offset, struct xkb_key *key, unsigned int group)
{
const xkb_keysym_t *syms;
int num_syms, level;
write_symbols(struct xkb_keymap *keymap, char **buf, size_t *size,
size_t *offset)
{
- xkb_keycode_t key;
+ struct xkb_key *key;
int group, tmp;
bool showActions;
if (tmp > 0)
write_buf(keymap, buf, size, offset, "\n");
- for (key = keymap->min_key_code; key <= keymap->max_key_code; key++) {
+ xkb_foreach_key(key, keymap) {
bool simple = true;
- if (xkb_key_num_groups(keymap, key) == 0)
+ if (key->num_groups == 0)
continue;
write_buf(keymap, buf, size, offset, "\t\tkey %6s {",
- XkbcKeyNameText(darray_item(keymap->key_names, key).name));
- if (keymap->explicit) {
- if ((keymap->explicit[key] & XkbExplicitKeyTypesMask)) {
- bool multi_type = false;
- int type = XkbKeyTypeIndex(keymap, key, 0);
-
- simple = false;
-
- for (group = 0; group < xkb_key_num_groups(keymap, key);
- group++) {
- if (XkbKeyTypeIndex(keymap, key, group) != type) {
- multi_type = true;
- break;
- }
- }
- if (multi_type) {
- for (group = 0;
- group < xkb_key_num_groups(keymap, key);
- group++) {
- if (!(keymap->explicit[key] & (1 << group)))
- continue;
- type = XkbKeyTypeIndex(keymap, key, group);
- write_buf(keymap, buf, size, offset,
- "\n\t\t\ttype[group%d]= \"%s\",",
- group + 1,
- darray_item(keymap->types, type).name);
- }
+ XkbcKeyNameText(key->name));
+
+ if (key->explicit & XkbExplicitKeyTypesMask) {
+ bool multi_type = false;
+ int type = XkbKeyTypeIndex(key, 0);
+
+ simple = false;
+
+ for (group = 0; group < key->num_groups; group++) {
+ if (XkbKeyTypeIndex(key, group) != type) {
+ multi_type = true;
+ break;
}
- else {
+ }
+
+ if (multi_type) {
+ for (group = 0; group < key->num_groups; group++) {
+ if (!(key->explicit & (1 << group)))
+ continue;
+ type = XkbKeyTypeIndex(key, group);
write_buf(keymap, buf, size, offset,
- "\n\t\t\ttype= \"%s\",",
+ "\n\t\t\ttype[group%d]= \"%s\",",
+ group + 1,
darray_item(keymap->types, type).name);
}
}
- if (keymap->ctrls &&
- (keymap->explicit[key] & XkbExplicitAutoRepeatMask)) {
- if (keymap->ctrls->per_key_repeat[key / 8] & (1 << (key % 8)))
- write_buf(keymap, buf, size, offset,
- "\n\t\t\trepeat= Yes,");
- else
- write_buf(keymap, buf, size, offset,
- "\n\t\t\trepeat= No,");
- simple = false;
- }
- if (keymap->vmodmap[key] &&
- (keymap->explicit[key] & XkbExplicitVModMapMask)) {
+ else {
write_buf(keymap, buf, size, offset,
- "\n\t\t\tvirtualMods= %s,",
- get_mod_mask_text(keymap, 0, keymap->vmodmap[key]));
+ "\n\t\t\ttype= \"%s\",",
+ darray_item(keymap->types, type).name);
}
}
- switch (XkbOutOfRangeGroupAction(XkbKeyGroupInfo(keymap, key))) {
+ if (key->explicit & XkbExplicitAutoRepeatMask) {
+ if (key->repeats)
+ write_buf(keymap, buf, size, offset,
+ "\n\t\t\trepeat= Yes,");
+ else
+ write_buf(keymap, buf, size, offset,
+ "\n\t\t\trepeat= No,");
+ simple = false;
+ }
+
+ if (key->vmodmap && (key->explicit & XkbExplicitVModMapMask)) {
+ write_buf(keymap, buf, size, offset, "\n\t\t\tvirtualMods= %s,",
+ get_mod_mask_text(keymap, 0, key->vmodmap));
+ }
+
+ switch (key->out_of_range_group_action) {
case XkbClampIntoRange:
write_buf(keymap, buf, size, offset, "\n\t\t\tgroupsClamp,");
break;
case XkbRedirectIntoRange:
write_buf(keymap, buf, size, offset,
"\n\t\t\tgroupsRedirect= Group%d,",
- XkbOutOfRangeGroupNumber(XkbKeyGroupInfo(keymap,
- key)) + 1);
+ key->out_of_range_group_number + 1);
break;
}
- if (keymap->explicit == NULL ||
- (keymap->explicit[key] & XkbExplicitInterpretMask))
- showActions = XkbKeyHasActions(keymap, key);
+ if (key->explicit & XkbExplicitInterpretMask)
+ showActions = XkbKeyHasActions(key);
else
showActions = false;
- if (xkb_key_num_groups(keymap, key) > 1 || showActions)
+ if (key->num_groups > 1 || showActions)
simple = false;
if (simple) {
int level;
acts = XkbKeyActionsPtr(keymap, key);
- for (group = 0; group < xkb_key_num_groups(keymap, key);
- group++) {
+ for (group = 0; group < key->num_groups; group++) {
if (group != 0)
write_buf(keymap, buf, size, offset, ",");
write_buf(keymap, buf, size, offset,
NULL, NULL);
}
write_buf(keymap, buf, size, offset, " ]");
- acts += XkbKeyGroupsWidth(keymap, key);
+ acts += key->width;
}
}
write_buf(keymap, buf, size, offset, "\n\t\t};\n");
}
}
- if (keymap->modmap) {
- for (key = keymap->min_key_code; key <= keymap->max_key_code;
- key++) {
- int mod;
- if (keymap->modmap[key] == 0)
- continue;
+ xkb_foreach_key(key, keymap) {
+ int mod;
- for (mod = 0; mod < XkbNumModifiers; mod++) {
- if (!(keymap->modmap[key] & (1 << mod)))
- continue;
+ if (key->modmap == 0)
+ continue;
- write_buf(keymap, buf, size, offset,
- "\t\tmodifier_map %s { %s };\n",
- get_mod_index_text(mod),
- XkbcKeyNameText(darray_item(keymap->key_names,
- key).name));
- }
+ for (mod = 0; mod < XkbNumModifiers; mod++) {
+ if (!(key->modmap & (1 << mod)))
+ continue;
+
+ write_buf(keymap, buf, size, offset,
+ "\t\tmodifier_map %s { %s };\n",
+ get_mod_index_text(mod),
+ XkbcKeyNameText(key->name));
}
}