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 xkb_foreach_key(key, keymap) {
328 if (key->name[0] == '\0')
331 write_buf(keymap, buf, size, offset, "\t\t%6s = %d;\n",
332 KeyNameText(key->name), XkbKeyGetKeycode(keymap, key));
335 for (i = 0; i < XkbNumIndicators; i++) {
336 if (!keymap->indicator_names[i])
338 write_buf(keymap, buf, size, offset, "\t\tindicator %d = \"%s\";\n",
339 i + 1, keymap->indicator_names[i]);
343 darray_foreach(alias, keymap->key_aliases)
344 write_buf(keymap, buf, size, offset, "\t\talias %6s = %6s;\n",
345 KeyNameText(alias->alias),
346 KeyNameText(alias->real));
348 write_buf(keymap, buf, size, offset, "\t};\n\n");
353 write_types(struct xkb_keymap *keymap, char **buf, size_t *size,
357 struct xkb_key_type *type;
359 if (keymap->types_section_name)
360 write_buf(keymap, buf, size, offset, "\txkb_types \"%s\" {\n\n",
361 keymap->types_section_name);
363 write_buf(keymap, buf, size, offset, "\txkb_types {\n\n");
365 write_vmods(keymap, buf, size, offset);
367 darray_foreach(type, keymap->types) {
368 write_buf(keymap, buf, size, offset, "\t\ttype \"%s\" {\n",
370 write_buf(keymap, buf, size, offset, "\t\t\tmodifiers= %s;\n",
371 get_mod_mask_text(keymap, type->mods.real_mods,
374 for (n = 0; n < darray_size(type->map); n++) {
375 struct xkb_kt_map_entry *entry = &darray_item(type->map, n);
378 str = get_mod_mask_text(keymap, entry->mods.real_mods,
380 write_buf(keymap, buf, size, offset, "\t\t\tmap[%s]= Level%d;\n",
381 str, entry->level + 1);
383 if (!type->preserve || (!type->preserve[n].real_mods &&
384 !type->preserve[n].vmods))
386 write_buf(keymap, buf, size, offset, "\t\t\tpreserve[%s]= ", str);
387 write_buf(keymap, buf, size, offset, "%s;\n",
388 get_mod_mask_text(keymap, type->preserve[n].real_mods,
389 type->preserve[n].vmods));
392 if (type->level_names) {
393 for (n = 0; n < type->num_levels; n++) {
394 if (!type->level_names[n])
396 write_buf(keymap, buf, size, offset,
397 "\t\t\tlevel_name[Level%d]= \"%s\";\n", n + 1,
398 type->level_names[n]);
401 write_buf(keymap, buf, size, offset, "\t\t};\n");
404 write_buf(keymap, buf, size, offset, "\t};\n\n");
409 write_indicator_map(struct xkb_keymap *keymap, char **buf, size_t *size,
410 size_t *offset, int num)
412 struct xkb_indicator_map *led = &keymap->indicators[num];
414 write_buf(keymap, buf, size, offset, "\t\tindicator \"%s\" {\n",
415 keymap->indicator_names[num]);
417 if (led->which_groups) {
418 if (led->which_groups != XkbIM_UseEffective) {
419 write_buf(keymap, buf, size, offset,
420 "\t\t\twhichGroupState= %s;\n",
421 get_indicator_state_text(
424 write_buf(keymap, buf, size, offset, "\t\t\tgroups= 0x%02x;\n",
428 if (led->which_mods) {
429 if (led->which_mods != XkbIM_UseEffective) {
430 write_buf(keymap, buf, size, offset, "\t\t\twhichModState= %s;\n",
431 get_indicator_state_text(led->which_mods));
433 write_buf(keymap, buf, size, offset, "\t\t\tmodifiers= %s;\n",
434 get_mod_mask_text(keymap, led->mods.real_mods,
439 write_buf(keymap, buf, size, offset, "\t\t\tcontrols= %s;\n",
440 get_control_mask_text(led->ctrls));
443 write_buf(keymap, buf, size, offset, "\t\t};\n");
448 get_interp_match_text(uint8_t type)
452 switch (type & XkbSI_OpMask) {
454 sprintf(ret, "NoneOf");
457 case XkbSI_AnyOfOrNone:
458 sprintf(ret, "AnyOfOrNone");
462 sprintf(ret, "AnyOf");
466 sprintf(ret, "AllOf");
470 sprintf(ret, "Exactly");
474 sprintf(ret, "0x%x", type & XkbSI_OpMask);
482 write_action(struct xkb_keymap *keymap, char **buf, size_t *size,
483 size_t *offset, union xkb_action *action, const char *prefix,
486 const char *type = NULL;
487 const char *args = NULL;
494 switch (action->any.type) {
498 case XkbSA_LatchMods:
504 if (action->mods.flags & XkbSA_UseModMapMods)
507 args = get_mod_mask_text(keymap, action->mods.real_mods,
509 write_buf(keymap, buf, size, offset, "%s%s(modifiers=%s%s%s)%s",
511 (action->any.type != XkbSA_LockGroup &&
512 (action->mods.flags & XkbSA_ClearLocks)) ?
514 (action->any.type != XkbSA_LockGroup &&
515 (action->mods.flags & XkbSA_LatchToLock)) ?
523 case XkbSA_LatchGroup:
526 case XkbSA_LockGroup:
530 keymap, buf, size, offset, "%s%s(group=%s%d%s%s)%s",
532 (!(action->group.flags & XkbSA_GroupAbsolute) &&
533 action->group.group > 0) ? "+" : "",
534 (action->group.flags & XkbSA_GroupAbsolute) ?
535 action->group.group + 1 : action->group.group,
536 (action->any.type != XkbSA_LockGroup &&
537 (action->group.flags & XkbSA_ClearLocks)) ?
539 (action->any.type != XkbSA_LockGroup &&
540 (action->group.flags & XkbSA_LatchToLock)) ?
545 case XkbSA_Terminate:
546 write_buf(keymap, buf, size, offset, "%sTerminate()%s", prefix,
551 write_buf(keymap, buf, size, offset, "%sMovePtr(x=%s%d,y=%s%d%s)%s",
553 (!(action->ptr.flags & XkbSA_MoveAbsoluteX) &&
554 action->ptr.x >= 0) ? "+" : "",
556 (!(action->ptr.flags & XkbSA_MoveAbsoluteY) &&
557 action->ptr.y >= 0) ? "+" : "",
559 (action->ptr.flags & XkbSA_NoAcceleration) ? ",!accel" : "",
566 case XkbSA_LockPtrBtn:
569 switch (action->btn.flags &
570 (XkbSA_LockNoUnlock | XkbSA_LockNoLock)) {
571 case XkbSA_LockNoUnlock:
572 args = ",affect=lock";
575 case XkbSA_LockNoLock:
576 args = ",affect=unlock";
579 case XkbSA_LockNoLock | XkbSA_LockNoUnlock:
580 args = ",affect=neither";
584 args = ",affect=both";
591 write_buf(keymap, buf, size, offset, "%s%s(button=", prefix, type);
592 if (action->btn.button > 0 && action->btn.button <= 5)
593 write_buf(keymap, buf, size, offset, "%d", action->btn.button);
595 write_buf(keymap, buf, size, offset, "default");
596 if (action->btn.count)
597 write_buf(keymap, buf, size, offset, ",count=%d",
600 write_buf(keymap, buf, size, offset, "%s", args);
601 write_buf(keymap, buf, size, offset, ")%s", suffix);
604 case XkbSA_SetPtrDflt:
605 write_buf(keymap, buf, size, offset, "%sSetPtrDflt(", prefix);
606 if (action->dflt.affect == XkbSA_AffectDfltBtn)
607 write_buf(keymap, buf, size, offset, "affect=button,button=%s%d",
608 (!(action->dflt.flags & XkbSA_DfltBtnAbsolute) &&
609 action->dflt.value >= 0) ? "+" : "",
611 write_buf(keymap, buf, size, offset, ")%s", suffix);
614 case XkbSA_SwitchScreen:
615 write_buf(keymap, buf, size, offset,
616 "%sSwitchScreen(screen=%s%d,%ssame)%s", prefix,
617 (!(action->screen.flags & XkbSA_SwitchAbsolute) &&
618 action->screen.screen >= 0) ? "+" : "",
619 action->screen.screen,
620 (action->screen.flags & XkbSA_SwitchApplication) ? "!" : "",
624 /* Deprecated actions below here */
625 case XkbSA_SetControls:
627 type = "SetControls";
628 case XkbSA_LockControls:
630 type = "LockControls";
631 write_buf(keymap, buf, size, offset, "%s%s(controls=%s)%s",
632 prefix, type, get_control_mask_text(action->ctrls.ctrls),
637 case XkbSA_ActionMessage:
638 case XkbSA_RedirectKey:
639 case XkbSA_DeviceBtn:
640 case XkbSA_LockDeviceBtn:
643 write_buf(keymap, buf, size, offset, "%sNoAction()%s", prefix, suffix);
646 case XkbSA_XFree86Private:
648 write_buf(keymap, buf, size, offset,
649 "%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",
650 prefix, action->any.type, action->any.data[0],
651 action->any.data[1], action->any.data[2],
652 action->any.data[3], action->any.data[4],
653 action->any.data[5], action->any.data[6],
662 write_compat(struct xkb_keymap *keymap, char **buf, size_t *size,
666 struct xkb_sym_interpret *interp;
668 if (keymap->compat_section_name)
669 write_buf(keymap, buf, size, offset,
670 "\txkb_compatibility \"%s\" {\n\n",
671 keymap->compat_section_name);
673 write_buf(keymap, buf, size, offset, "\txkb_compatibility {\n\n");
675 write_vmods(keymap, buf, size, offset);
677 write_buf(keymap, buf, size, offset,
678 "\t\tinterpret.useModMapMods= AnyLevel;\n");
679 write_buf(keymap, buf, size, offset, "\t\tinterpret.repeat= False;\n");
680 write_buf(keymap, buf, size, offset, "\t\tinterpret.locking= False;\n");
682 darray_foreach(interp, keymap->sym_interpret) {
683 char keysym_name[64];
685 if (interp->sym == XKB_KEY_NoSymbol)
686 sprintf(keysym_name, "Any");
688 xkb_keysym_get_name(interp->sym, keysym_name, sizeof(keysym_name));
690 write_buf(keymap, buf, size, offset, "\t\tinterpret %s+%s(%s) {\n",
692 get_interp_match_text(interp->match),
693 get_mod_mask_text(keymap, interp->mods, 0));
695 if (interp->virtual_mod != XkbNoModifier) {
696 write_buf(keymap, buf, size, offset,
697 "\t\t\tvirtualModifier= %s;\n",
698 keymap->vmod_names[interp->virtual_mod]);
701 if (interp->match & XkbSI_LevelOneOnly)
702 write_buf(keymap, buf, size, offset,
703 "\t\t\tuseModMapMods=level1;\n");
704 if (interp->flags & XkbSI_LockingKey)
705 write_buf(keymap, buf, size, offset, "\t\t\tlocking= True;\n");
706 if (interp->flags & XkbSI_AutoRepeat)
707 write_buf(keymap, buf, size, offset, "\t\t\trepeat= True;\n");
709 write_action(keymap, buf, size, offset, &interp->act,
710 "\t\t\taction= ", ";\n");
711 write_buf(keymap, buf, size, offset, "\t\t};\n");
714 for (i = 0; i < XkbNumKbdGroups; i++) {
717 gc = &keymap->groups[i];
718 if (gc->real_mods == 0 && gc->vmods == 0)
720 write_buf(keymap, buf, size, offset,
721 "\t\tgroup %d = %s;\n", i + 1,
722 get_mod_mask_text(keymap, gc->real_mods, gc->vmods));
725 for (i = 0; i < XkbNumIndicators; i++) {
726 struct xkb_indicator_map *map = &keymap->indicators[i];
727 if (map->flags == 0 && map->which_groups == 0 &&
728 map->groups == 0 && map->which_mods == 0 &&
729 map->mods.real_mods == 0 && map->mods.vmods == 0 &&
732 write_indicator_map(keymap, buf, size, offset, i);
735 write_buf(keymap, buf, size, offset, "\t};\n\n");
741 write_keysyms(struct xkb_keymap *keymap, char **buf, size_t *size,
742 size_t *offset, struct xkb_key *key, xkb_group_index_t group)
744 const xkb_keysym_t *syms;
746 #define OUT_BUF_LEN 128
747 char out_buf[OUT_BUF_LEN];
749 for (level = 0; level < XkbKeyGroupWidth(keymap, key, group); level++) {
751 write_buf(keymap, buf, size, offset, ", ");
752 num_syms = xkb_key_get_syms_by_level(keymap, key, group, level,
755 write_buf(keymap, buf, size, offset, "%15s", "NoSymbol");
757 else if (num_syms == 1) {
758 xkb_keysym_get_name(syms[0], out_buf, OUT_BUF_LEN);
759 write_buf(keymap, buf, size, offset, "%15s", out_buf);
763 write_buf(keymap, buf, size, offset, "{ ");
764 for (s = 0; s < num_syms; s++) {
766 write_buf(keymap, buf, size, offset, ", ");
767 xkb_keysym_get_name(syms[s], out_buf, OUT_BUF_LEN);
768 write_buf(keymap, buf, size, offset, "%15s", out_buf);
770 write_buf(keymap, buf, size, offset, " }");
779 write_symbols(struct xkb_keymap *keymap, char **buf, size_t *size,
783 xkb_group_index_t group, tmp;
786 if (keymap->symbols_section_name)
787 write_buf(keymap, buf, size, offset, "\txkb_symbols \"%s\" {\n\n",
788 keymap->symbols_section_name);
790 write_buf(keymap, buf, size, offset, "\txkb_symbols {\n\n");
792 for (tmp = group = 0; group < XkbNumKbdGroups; group++) {
793 if (!keymap->group_names[group])
795 write_buf(keymap, buf, size, offset,
796 "\t\tname[group%d]=\"%s\";\n", group + 1,
797 keymap->group_names[group]);
801 write_buf(keymap, buf, size, offset, "\n");
803 xkb_foreach_key(key, keymap) {
806 if (key->num_groups == 0)
809 write_buf(keymap, buf, size, offset, "\t\tkey %6s {",
810 KeyNameText(key->name));
812 if (key->explicit & XkbExplicitKeyTypesMask) {
813 bool multi_type = false;
814 int type = XkbKeyTypeIndex(key, 0);
818 for (group = 0; group < key->num_groups; group++) {
819 if (XkbKeyTypeIndex(key, group) != type) {
826 for (group = 0; group < key->num_groups; group++) {
827 if (!(key->explicit & (1 << group)))
829 type = XkbKeyTypeIndex(key, group);
830 write_buf(keymap, buf, size, offset,
831 "\n\t\t\ttype[group%u]= \"%s\",",
833 darray_item(keymap->types, type).name);
837 write_buf(keymap, buf, size, offset,
838 "\n\t\t\ttype= \"%s\",",
839 darray_item(keymap->types, type).name);
843 if (key->explicit & XkbExplicitAutoRepeatMask) {
845 write_buf(keymap, buf, size, offset,
846 "\n\t\t\trepeat= Yes,");
848 write_buf(keymap, buf, size, offset,
849 "\n\t\t\trepeat= No,");
853 if (key->vmodmap && (key->explicit & XkbExplicitVModMapMask)) {
854 write_buf(keymap, buf, size, offset, "\n\t\t\tvirtualMods= %s,",
855 get_mod_mask_text(keymap, 0, key->vmodmap));
858 switch (key->out_of_range_group_action) {
859 case XkbClampIntoRange:
860 write_buf(keymap, buf, size, offset, "\n\t\t\tgroupsClamp,");
863 case XkbRedirectIntoRange:
864 write_buf(keymap, buf, size, offset,
865 "\n\t\t\tgroupsRedirect= Group%u,",
866 key->out_of_range_group_number + 1);
870 if (key->explicit & XkbExplicitInterpretMask)
871 showActions = XkbKeyHasActions(key);
875 if (key->num_groups > 1 || showActions)
879 write_buf(keymap, buf, size, offset, "\t[ ");
880 if (!write_keysyms(keymap, buf, size, offset, key, 0))
882 write_buf(keymap, buf, size, offset, " ] };\n");
885 union xkb_action *acts;
888 acts = XkbKeyActionsPtr(keymap, key);
889 for (group = 0; group < key->num_groups; group++) {
891 write_buf(keymap, buf, size, offset, ",");
892 write_buf(keymap, buf, size, offset,
893 "\n\t\t\tsymbols[Group%u]= [ ", group + 1);
894 if (!write_keysyms(keymap, buf, size, offset, key, group))
896 write_buf(keymap, buf, size, offset, " ]");
898 write_buf(keymap, buf, size, offset,
899 ",\n\t\t\tactions[Group%u]= [ ", group + 1);
901 level < XkbKeyGroupWidth(keymap, key, group);
904 write_buf(keymap, buf, size, offset, ", ");
905 write_action(keymap, buf, size, offset, &acts[level],
908 write_buf(keymap, buf, size, offset, " ]");
912 write_buf(keymap, buf, size, offset, "\n\t\t};\n");
916 xkb_foreach_key(key, keymap) {
919 if (key->modmap == 0)
922 for (mod = 0; mod < XkbNumModifiers; mod++) {
923 if (!(key->modmap & (1 << mod)))
926 write_buf(keymap, buf, size, offset,
927 "\t\tmodifier_map %s { %s };\n",
928 get_mod_index_text(mod),
929 KeyNameText(key->name));
933 write_buf(keymap, buf, size, offset, "\t};\n\n");
938 xkb_map_get_as_string(struct xkb_keymap *keymap)
944 check_write_buf(keymap, &ret, &size, &offset, "xkb_keymap {\n");
947 if (!write_keycodes(keymap, &ret, &size, &offset))
949 if (!write_types(keymap, &ret, &size, &offset))
951 if (!write_compat(keymap, &ret, &size, &offset))
953 if (!write_symbols(keymap, &ret, &size, &offset))
955 check_write_buf(keymap, &ret, &size, &offset, "};\n");