1 /************************************************************
2 * Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
4 * Permission to use, copy, modify, and distribute this
5 * software and its documentation for any purpose and without
6 * fee is hereby granted, provided that the above copyright
7 * notice appear in all copies and that both that copyright
8 * notice and this permission notice appear in supporting
9 * documentation, and that the name of Silicon Graphics not be
10 * used in advertising or publicity pertaining to distribution
11 * of the software without specific prior written permission.
12 * Silicon Graphics makes no representation about the suitability
13 * of this software for any purpose. It is provided "as is"
14 * without any express or implied warranty.
16 * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
17 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
18 * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
19 * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
20 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
21 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
22 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
23 * THE USE OR PERFORMANCE OF THIS SOFTWARE.
25 ********************************************************/
28 * Copyright © 2012 Intel Corporation
30 * Permission is hereby granted, free of charge, to any person obtaining a
31 * copy of this software and associated documentation files (the "Software"),
32 * to deal in the Software without restriction, including without limitation
33 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
34 * and/or sell copies of the Software, and to permit persons to whom the
35 * Software is furnished to do so, subject to the following conditions:
37 * The above copyright notice and this permission notice (including the next
38 * paragraph) shall be included in all copies or substantial portions of the
41 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
42 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
43 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
44 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
45 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
46 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
47 * DEALINGS IN THE SOFTWARE.
49 * Author: Daniel Stone <daniel@fooishbar.org>
61 #define VMOD_HIDE_VALUE 0
62 #define VMOD_SHOW_VALUE 1
63 #define VMOD_COMMENT_VALUE 2
65 #define BUF_CHUNK_SIZE 4096
68 do_realloc(char **buf, size_t *size, size_t offset, size_t at_least)
72 *size += BUF_CHUNK_SIZE;
73 if (at_least >= BUF_CHUNK_SIZE)
76 new = realloc(*buf, *size);
81 memset(*buf + offset, 0, *size - offset);
86 /* This whole thing should be a function, but you can't call vsnprintf
88 #define check_write_buf(keymap, buf, size, offset, ...) \
93 /* Concatenate the strings, and check whether or not the output was \
95 while ((_printed = snprintf(*buf + *offset, *size - *offset, \
97 (*size - *offset)) { \
98 /* If it was truncated, embiggen the string and roll from the top. */ \
99 if (!do_realloc(buf, size, *offset, _printed)) { \
101 "xkbcommon: couldn't allocate %zu bytes for keymap\n", \
110 *offset += _printed; \
113 #define write_buf(keymap, buf, size, offset, ...) \
115 check_write_buf(keymap, buf, size, offset, __VA_ARGS__); \
121 write_vmods(struct xkb_keymap *keymap, char **buf, size_t *size,
127 for (i = 0; i < XkbNumVirtualMods; i++) {
128 if (!keymap->vmod_names[i])
131 write_buf(keymap, buf, size, offset, "\t\tvirtual_modifiers ");
133 write_buf(keymap, buf, size, offset, ",");
134 write_buf(keymap, buf, size, offset, "%s", keymap->vmod_names[i]);
139 write_buf(keymap, buf, size, offset, ";\n\n");
144 #define GET_TEXT_BUF_SIZE 512
146 #define append_get_text(...) do { \
147 int _size = snprintf(ret, GET_TEXT_BUF_SIZE, __VA_ARGS__); \
148 if (_size >= GET_TEXT_BUF_SIZE) \
152 /* FIXME: Merge with src/xkbcomp/expr.c::modIndexNames. */
153 static const char *core_mod_names[] = {
165 get_mod_index_text(uint8_t real_mod)
167 return core_mod_names[real_mod];
171 get_mod_mask_text(struct xkb_keymap *keymap, uint8_t real_mods,
174 static char ret[GET_TEXT_BUF_SIZE], ret2[GET_TEXT_BUF_SIZE];
177 memset(ret, 0, GET_TEXT_BUF_SIZE);
179 if (real_mods == 0 && vmods == 0) {
184 /* This is so broken. If we have a real modmask of 0xff and a
185 * vmodmask, we'll get, e.g., all+RightControl. But, it's what xkbfile
187 if (real_mods == 0xff) {
190 else if (real_mods) {
191 for (i = 0; i < XkbNumModifiers; i++) {
192 if (!(real_mods & (1 << i)))
194 if (ret[0] != '\0') {
196 append_get_text("%s+%s", ret2, core_mod_names[i]);
199 append_get_text("%s", core_mod_names[i]);
207 for (i = 0; i < XkbNumVirtualMods; i++) {
208 if (!(vmods & (1 << i)))
210 if (ret[0] != '\0') {
212 append_get_text("%s+%s", ret2, keymap->vmod_names[i]);
215 append_get_text("%s", keymap->vmod_names[i]);
223 get_indicator_state_text(uint8_t which)
226 static char ret[GET_TEXT_BUF_SIZE];
227 /* FIXME: Merge with ... something ... in xkbcomp? */
228 static const char *state_names[] = {
236 memset(ret, 0, GET_TEXT_BUF_SIZE);
238 which &= XkbIM_UseAnyMods;
245 for (i = 0; which != 0; i++) {
246 if (!(which & (1 << i)))
251 append_get_text("%s+%s", ret, state_names[i]);
253 append_get_text("%s", state_names[i]);
260 get_control_mask_text(uint32_t control_mask)
263 static char ret[GET_TEXT_BUF_SIZE];
264 /* FIXME: Merge with ... something ... in xkbcomp. */
265 static const char *ctrl_names[] = {
281 memset(ret, 0, GET_TEXT_BUF_SIZE);
283 control_mask &= XkbAllBooleanCtrlsMask;
285 if (control_mask == 0) {
289 else if (control_mask == XkbAllBooleanCtrlsMask) {
294 for (i = 0; control_mask; i++) {
295 if (!(control_mask & (1 << i)))
297 control_mask &= ~(1 << i);
300 append_get_text("%s+%s", ret, ctrl_names[i]);
302 append_get_text("%s", ctrl_names[i]);
309 write_keycodes(struct xkb_keymap *keymap, char **buf, size_t *size,
313 struct xkb_key_alias *alias;
316 if (keymap->keycodes_section_name)
317 write_buf(keymap, buf, size, offset, "\txkb_keycodes \"%s\" {\n",
318 keymap->keycodes_section_name);
320 write_buf(keymap, buf, size, offset, "\txkb_keycodes {\n");
322 write_buf(keymap, buf, size, offset, "\t\tminimum = %d;\n",
323 keymap->min_key_code);
324 write_buf(keymap, buf, size, offset, "\t\tmaximum = %d;\n",
325 keymap->max_key_code);
327 for (kc = keymap->min_key_code; kc <= keymap->max_key_code; kc++) {
328 if (darray_item(keymap->key_names, kc).name[0] == '\0')
331 write_buf(keymap, buf, size, offset, "\t\t%6s = %d;\n",
332 XkbcKeyNameText(darray_item(keymap->key_names, kc).name),
336 for (i = 0; i < XkbNumIndicators; i++) {
337 if (!keymap->indicator_names[i])
339 write_buf(keymap, buf, size, offset, "\t\tindicator %d = \"%s\";\n",
340 i + 1, keymap->indicator_names[i]);
344 darray_foreach(alias, keymap->key_aliases)
345 write_buf(keymap, buf, size, offset, "\t\talias %6s = %6s;\n",
346 XkbcKeyNameText(alias->alias),
347 XkbcKeyNameText(alias->real));
349 write_buf(keymap, buf, size, offset, "\t};\n\n");
354 write_types(struct xkb_keymap *keymap, char **buf, size_t *size,
358 struct xkb_key_type *type;
360 if (keymap->types_section_name)
361 write_buf(keymap, buf, size, offset, "\txkb_types \"%s\" {\n\n",
362 keymap->types_section_name);
364 write_buf(keymap, buf, size, offset, "\txkb_types {\n\n");
366 write_vmods(keymap, buf, size, offset);
368 darray_foreach(type, keymap->types) {
369 write_buf(keymap, buf, size, offset, "\t\ttype \"%s\" {\n",
371 write_buf(keymap, buf, size, offset, "\t\t\tmodifiers= %s;\n",
372 get_mod_mask_text(keymap, type->mods.real_mods,
375 for (n = 0; n < darray_size(type->map); n++) {
376 struct xkb_kt_map_entry *entry = &darray_item(type->map, n);
379 str = get_mod_mask_text(keymap, entry->mods.real_mods,
381 write_buf(keymap, buf, size, offset, "\t\t\tmap[%s]= Level%d;\n",
382 str, entry->level + 1);
384 if (!type->preserve || (!type->preserve[n].real_mods &&
385 !type->preserve[n].vmods))
387 write_buf(keymap, buf, size, offset, "\t\t\tpreserve[%s]= ", str);
388 write_buf(keymap, buf, size, offset, "%s;\n",
389 get_mod_mask_text(keymap, type->preserve[n].real_mods,
390 type->preserve[n].vmods));
393 if (type->level_names) {
394 for (n = 0; n < type->num_levels; n++) {
395 if (!type->level_names[n])
397 write_buf(keymap, buf, size, offset,
398 "\t\t\tlevel_name[Level%d]= \"%s\";\n", n + 1,
399 type->level_names[n]);
402 write_buf(keymap, buf, size, offset, "\t\t};\n");
405 write_buf(keymap, buf, size, offset, "\t};\n\n");
410 write_indicator_map(struct xkb_keymap *keymap, char **buf, size_t *size,
411 size_t *offset, int num)
413 struct xkb_indicator_map *led = &keymap->indicators[num];
415 write_buf(keymap, buf, size, offset, "\t\tindicator \"%s\" {\n",
416 keymap->indicator_names[num]);
418 if (led->which_groups) {
419 if (led->which_groups != XkbIM_UseEffective) {
420 write_buf(keymap, buf, size, offset,
421 "\t\t\twhichGroupState= %s;\n",
422 get_indicator_state_text(
425 write_buf(keymap, buf, size, offset, "\t\t\tgroups= 0x%02x;\n",
429 if (led->which_mods) {
430 if (led->which_mods != XkbIM_UseEffective) {
431 write_buf(keymap, buf, size, offset, "\t\t\twhichModState= %s;\n",
432 get_indicator_state_text(led->which_mods));
434 write_buf(keymap, buf, size, offset, "\t\t\tmodifiers= %s;\n",
435 get_mod_mask_text(keymap, led->mods.real_mods,
440 write_buf(keymap, buf, size, offset, "\t\t\tcontrols= %s;\n",
441 get_control_mask_text(led->ctrls));
444 write_buf(keymap, buf, size, offset, "\t\t};\n");
449 get_interp_match_text(uint8_t type)
453 switch (type & XkbSI_OpMask) {
455 sprintf(ret, "NoneOf");
458 case XkbSI_AnyOfOrNone:
459 sprintf(ret, "AnyOfOrNone");
463 sprintf(ret, "AnyOf");
467 sprintf(ret, "AllOf");
471 sprintf(ret, "Exactly");
475 sprintf(ret, "0x%x", type & XkbSI_OpMask);
483 write_action(struct xkb_keymap *keymap, char **buf, size_t *size,
484 size_t *offset, union xkb_action *action, const char *prefix,
487 const char *type = NULL;
488 const char *args = NULL;
495 switch (action->any.type) {
499 case XkbSA_LatchMods:
505 if (action->mods.flags & XkbSA_UseModMapMods)
508 args = get_mod_mask_text(keymap, action->mods.real_mods,
510 write_buf(keymap, buf, size, offset, "%s%s(modifiers=%s%s%s)%s",
512 (action->any.type != XkbSA_LockGroup &&
513 (action->mods.flags & XkbSA_ClearLocks)) ?
515 (action->any.type != XkbSA_LockGroup &&
516 (action->mods.flags & XkbSA_LatchToLock)) ?
524 case XkbSA_LatchGroup:
527 case XkbSA_LockGroup:
531 keymap, buf, size, offset, "%s%s(group=%s%d%s%s)%s",
533 (!(action->group.flags & XkbSA_GroupAbsolute) &&
534 action->group.group > 0) ? "+" : "",
535 (action->group.flags & XkbSA_GroupAbsolute) ?
536 action->group.group + 1 : action->group.group,
537 (action->any.type != XkbSA_LockGroup &&
538 (action->group.flags & XkbSA_ClearLocks)) ?
540 (action->any.type != XkbSA_LockGroup &&
541 (action->group.flags & XkbSA_LatchToLock)) ?
546 case XkbSA_Terminate:
547 write_buf(keymap, buf, size, offset, "%sTerminate()%s", prefix,
552 write_buf(keymap, buf, size, offset, "%sMovePtr(x=%s%d,y=%s%d%s)%s",
554 (!(action->ptr.flags & XkbSA_MoveAbsoluteX) &&
555 action->ptr.x >= 0) ? "+" : "",
557 (!(action->ptr.flags & XkbSA_MoveAbsoluteY) &&
558 action->ptr.y >= 0) ? "+" : "",
560 (action->ptr.flags & XkbSA_NoAcceleration) ? ",!accel" : "",
567 case XkbSA_LockPtrBtn:
570 switch (action->btn.flags &
571 (XkbSA_LockNoUnlock | XkbSA_LockNoLock)) {
572 case XkbSA_LockNoUnlock:
573 args = ",affect=lock";
576 case XkbSA_LockNoLock:
577 args = ",affect=unlock";
580 case XkbSA_LockNoLock | XkbSA_LockNoUnlock:
581 args = ",affect=neither";
585 args = ",affect=both";
592 write_buf(keymap, buf, size, offset, "%s%s(button=", prefix, type);
593 if (action->btn.button > 0 && action->btn.button <= 5)
594 write_buf(keymap, buf, size, offset, "%d", action->btn.button);
596 write_buf(keymap, buf, size, offset, "default");
597 if (action->btn.count)
598 write_buf(keymap, buf, size, offset, ",count=%d",
601 write_buf(keymap, buf, size, offset, "%s", args);
602 write_buf(keymap, buf, size, offset, ")%s", suffix);
605 case XkbSA_SetPtrDflt:
606 write_buf(keymap, buf, size, offset, "%sSetPtrDflt(", prefix);
607 if (action->dflt.affect == XkbSA_AffectDfltBtn)
608 write_buf(keymap, buf, size, offset, "affect=button,button=%s%d",
609 (!(action->dflt.flags & XkbSA_DfltBtnAbsolute) &&
610 action->dflt.value >= 0) ? "+" : "",
612 write_buf(keymap, buf, size, offset, ")%s", suffix);
615 case XkbSA_SwitchScreen:
616 write_buf(keymap, buf, size, offset,
617 "%sSwitchScreen(screen=%s%d,%ssame)%s", prefix,
618 (!(action->screen.flags & XkbSA_SwitchAbsolute) &&
619 action->screen.screen >= 0) ? "+" : "",
620 action->screen.screen,
621 (action->screen.flags & XkbSA_SwitchApplication) ? "!" : "",
625 /* Deprecated actions below here */
626 case XkbSA_SetControls:
628 type = "SetControls";
629 case XkbSA_LockControls:
631 type = "LockControls";
632 write_buf(keymap, buf, size, offset, "%s%s(controls=%s)%s",
633 prefix, type, get_control_mask_text(action->ctrls.ctrls),
638 case XkbSA_ActionMessage:
639 case XkbSA_RedirectKey:
640 case XkbSA_DeviceBtn:
641 case XkbSA_LockDeviceBtn:
644 write_buf(keymap, buf, size, offset, "%sNoAction()%s", prefix, suffix);
647 case XkbSA_XFree86Private:
649 write_buf(keymap, buf, size, offset,
650 "%sPrivate(type=0x%02x,data[0]=0x%02x,data[1]=0x%02x,data[2]=0x%02x,data[3]=0x%02x,data[4]=0x%02x,data[5]=0x%02x,data[6]=0x%02x)%s",
651 prefix, action->any.type, action->any.data[0],
652 action->any.data[1], action->any.data[2],
653 action->any.data[3], action->any.data[4],
654 action->any.data[5], action->any.data[6],
663 write_compat(struct xkb_keymap *keymap, char **buf, size_t *size,
667 struct xkb_sym_interpret *interp;
669 if (keymap->compat_section_name)
670 write_buf(keymap, buf, size, offset,
671 "\txkb_compatibility \"%s\" {\n\n",
672 keymap->compat_section_name);
674 write_buf(keymap, buf, size, offset, "\txkb_compatibility {\n\n");
676 write_vmods(keymap, buf, size, offset);
678 write_buf(keymap, buf, size, offset,
679 "\t\tinterpret.useModMapMods= AnyLevel;\n");
680 write_buf(keymap, buf, size, offset, "\t\tinterpret.repeat= False;\n");
681 write_buf(keymap, buf, size, offset, "\t\tinterpret.locking= False;\n");
683 darray_foreach(interp, keymap->sym_interpret) {
684 char keysym_name[64];
686 if (interp->sym == XKB_KEY_NoSymbol)
687 sprintf(keysym_name, "Any");
689 xkb_keysym_get_name(interp->sym, keysym_name, sizeof(keysym_name));
691 write_buf(keymap, buf, size, offset, "\t\tinterpret %s+%s(%s) {\n",
693 get_interp_match_text(interp->match),
694 get_mod_mask_text(keymap, interp->mods, 0));
696 if (interp->virtual_mod != XkbNoModifier) {
697 write_buf(keymap, buf, size, offset,
698 "\t\t\tvirtualModifier= %s;\n",
699 keymap->vmod_names[interp->virtual_mod]);
702 if (interp->match & XkbSI_LevelOneOnly)
703 write_buf(keymap, buf, size, offset,
704 "\t\t\tuseModMapMods=level1;\n");
705 if (interp->flags & XkbSI_LockingKey)
706 write_buf(keymap, buf, size, offset, "\t\t\tlocking= True;\n");
707 if (interp->flags & XkbSI_AutoRepeat)
708 write_buf(keymap, buf, size, offset, "\t\t\trepeat= True;\n");
710 write_action(keymap, buf, size, offset, &interp->act,
711 "\t\t\taction= ", ";\n");
712 write_buf(keymap, buf, size, offset, "\t\t};\n");
715 for (i = 0; i < XkbNumKbdGroups; i++) {
718 gc = &keymap->groups[i];
719 if (gc->real_mods == 0 && gc->vmods == 0)
721 write_buf(keymap, buf, size, offset,
722 "\t\tgroup %d = %s;\n", i + 1,
723 get_mod_mask_text(keymap, gc->real_mods, gc->vmods));
726 for (i = 0; i < XkbNumIndicators; i++) {
727 struct xkb_indicator_map *map = &keymap->indicators[i];
728 if (map->flags == 0 && map->which_groups == 0 &&
729 map->groups == 0 && map->which_mods == 0 &&
730 map->mods.real_mods == 0 && map->mods.vmods == 0 &&
733 write_indicator_map(keymap, buf, size, offset, i);
736 write_buf(keymap, buf, size, offset, "\t};\n\n");
742 write_keysyms(struct xkb_keymap *keymap, char **buf, size_t *size,
743 size_t *offset, xkb_keycode_t kc, unsigned int group)
745 const xkb_keysym_t *syms;
747 #define OUT_BUF_LEN 128
748 char out_buf[OUT_BUF_LEN];
750 for (level = 0; level < XkbKeyGroupWidth(keymap, kc, group); level++) {
752 write_buf(keymap, buf, size, offset, ", ");
753 num_syms = xkb_key_get_syms_by_level(keymap, kc, group, level,
756 write_buf(keymap, buf, size, offset, "%15s", "NoSymbol");
758 else if (num_syms == 1) {
759 xkb_keysym_get_name(syms[0], out_buf, OUT_BUF_LEN);
760 write_buf(keymap, buf, size, offset, "%15s", out_buf);
764 write_buf(keymap, buf, size, offset, "{ ");
765 for (s = 0; s < num_syms; s++) {
767 write_buf(keymap, buf, size, offset, ", ");
768 xkb_keysym_get_name(syms[s], out_buf, OUT_BUF_LEN);
769 write_buf(keymap, buf, size, offset, "%15s", out_buf);
771 write_buf(keymap, buf, size, offset, " }");
780 write_symbols(struct xkb_keymap *keymap, char **buf, size_t *size,
787 if (keymap->symbols_section_name)
788 write_buf(keymap, buf, size, offset, "\txkb_symbols \"%s\" {\n\n",
789 keymap->symbols_section_name);
791 write_buf(keymap, buf, size, offset, "\txkb_symbols {\n\n");
793 for (tmp = group = 0; group < XkbNumKbdGroups; group++) {
794 if (!keymap->group_names[group])
796 write_buf(keymap, buf, size, offset,
797 "\t\tname[group%d]=\"%s\";\n", group + 1,
798 keymap->group_names[group]);
802 write_buf(keymap, buf, size, offset, "\n");
804 for (kc = keymap->min_key_code; kc <= keymap->max_key_code; kc++) {
807 if (xkb_key_num_groups(keymap, kc) == 0)
810 write_buf(keymap, buf, size, offset, "\t\tkey %6s {",
811 XkbcKeyNameText(darray_item(keymap->key_names, kc).name));
812 if (keymap->explicit) {
813 if ((keymap->explicit[kc] & XkbExplicitKeyTypesMask)) {
814 bool multi_type = false;
815 int type = XkbKeyTypeIndex(keymap, kc, 0);
819 for (group = 0; group < xkb_key_num_groups(keymap, kc);
821 if (XkbKeyTypeIndex(keymap, kc, group) != type) {
828 group < xkb_key_num_groups(keymap, kc);
830 if (!(keymap->explicit[kc] & (1 << group)))
832 type = XkbKeyTypeIndex(keymap, kc, group);
833 write_buf(keymap, buf, size, offset,
834 "\n\t\t\ttype[group%d]= \"%s\",",
836 darray_item(keymap->types, type).name);
840 write_buf(keymap, buf, size, offset,
841 "\n\t\t\ttype= \"%s\",",
842 darray_item(keymap->types, type).name);
845 if (keymap->explicit[kc] & XkbExplicitAutoRepeatMask) {
846 if (keymap->per_key_repeat[kc / 8] & (1 << (kc % 8)))
847 write_buf(keymap, buf, size, offset,
848 "\n\t\t\trepeat= Yes,");
850 write_buf(keymap, buf, size, offset,
851 "\n\t\t\trepeat= No,");
854 if (keymap->vmodmap[kc] &&
855 (keymap->explicit[kc] & XkbExplicitVModMapMask)) {
856 write_buf(keymap, buf, size, offset,
857 "\n\t\t\tvirtualMods= %s,",
858 get_mod_mask_text(keymap, 0, keymap->vmodmap[kc]));
862 switch (XkbOutOfRangeGroupAction(XkbKeyGroupInfo(keymap, kc))) {
863 case XkbClampIntoRange:
864 write_buf(keymap, buf, size, offset, "\n\t\t\tgroupsClamp,");
867 case XkbRedirectIntoRange:
868 write_buf(keymap, buf, size, offset,
869 "\n\t\t\tgroupsRedirect= Group%d,",
870 XkbOutOfRangeGroupNumber(XkbKeyGroupInfo(keymap,
875 if (keymap->explicit == NULL ||
876 (keymap->explicit[kc] & XkbExplicitInterpretMask))
877 showActions = XkbKeyHasActions(keymap, kc);
881 if (xkb_key_num_groups(keymap, kc) > 1 || showActions)
885 write_buf(keymap, buf, size, offset, "\t[ ");
886 if (!write_keysyms(keymap, buf, size, offset, kc, 0))
888 write_buf(keymap, buf, size, offset, " ] };\n");
891 union xkb_action *acts;
894 acts = XkbKeyActionsPtr(keymap, kc);
895 for (group = 0; group < xkb_key_num_groups(keymap, kc); group++) {
897 write_buf(keymap, buf, size, offset, ",");
898 write_buf(keymap, buf, size, offset,
899 "\n\t\t\tsymbols[Group%d]= [ ", group + 1);
900 if (!write_keysyms(keymap, buf, size, offset, kc, group))
902 write_buf(keymap, buf, size, offset, " ]");
904 write_buf(keymap, buf, size, offset,
905 ",\n\t\t\tactions[Group%d]= [ ", group + 1);
907 level < XkbKeyGroupWidth(keymap, kc, group);
910 write_buf(keymap, buf, size, offset, ", ");
911 write_action(keymap, buf, size, offset, &acts[level],
914 write_buf(keymap, buf, size, offset, " ]");
915 acts += XkbKeyGroupsWidth(keymap, kc);
918 write_buf(keymap, buf, size, offset, "\n\t\t};\n");
921 if (keymap->modmap) {
922 for (kc = keymap->min_key_code; kc <= keymap->max_key_code; kc++) {
925 if (keymap->modmap[kc] == 0)
928 for (mod = 0; mod < XkbNumModifiers; mod++) {
929 if (!(keymap->modmap[kc] & (1 << mod)))
932 write_buf(keymap, buf, size, offset,
933 "\t\tmodifier_map %s { %s };\n",
934 get_mod_index_text(mod),
935 XkbcKeyNameText(darray_item(keymap->key_names,
941 write_buf(keymap, buf, size, offset, "\t};\n\n");
946 xkb_map_get_as_string(struct xkb_keymap *keymap)
952 check_write_buf(keymap, &ret, &size, &offset, "xkb_keymap {\n");
955 if (!write_keycodes(keymap, &ret, &size, &offset))
957 if (!write_types(keymap, &ret, &size, &offset))
959 if (!write_compat(keymap, &ret, &size, &offset))
961 if (!write_symbols(keymap, &ret, &size, &offset))
963 check_write_buf(keymap, &ret, &size, &offset, "};\n");