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,
314 struct xkb_key_alias *alias;
317 if (keymap->keycodes_section_name)
318 write_buf(keymap, buf, size, offset, "\txkb_keycodes \"%s\" {\n",
319 keymap->keycodes_section_name);
321 write_buf(keymap, buf, size, offset, "\txkb_keycodes {\n");
323 write_buf(keymap, buf, size, offset, "\t\tminimum = %d;\n",
324 keymap->min_key_code);
325 write_buf(keymap, buf, size, offset, "\t\tmaximum = %d;\n",
326 keymap->max_key_code);
328 for (kc = keymap->min_key_code; kc <= keymap->max_key_code; kc++) {
329 key = XkbKey(keymap, kc);
330 if (key->name.name[0] == '\0')
333 write_buf(keymap, buf, size, offset, "\t\t%6s = %d;\n",
334 XkbcKeyNameText(key->name.name), kc);
337 for (i = 0; i < XkbNumIndicators; i++) {
338 if (!keymap->indicator_names[i])
340 write_buf(keymap, buf, size, offset, "\t\tindicator %d = \"%s\";\n",
341 i + 1, keymap->indicator_names[i]);
345 darray_foreach(alias, keymap->key_aliases)
346 write_buf(keymap, buf, size, offset, "\t\talias %6s = %6s;\n",
347 XkbcKeyNameText(alias->alias),
348 XkbcKeyNameText(alias->real));
350 write_buf(keymap, buf, size, offset, "\t};\n\n");
355 write_types(struct xkb_keymap *keymap, char **buf, size_t *size,
359 struct xkb_key_type *type;
361 if (keymap->types_section_name)
362 write_buf(keymap, buf, size, offset, "\txkb_types \"%s\" {\n\n",
363 keymap->types_section_name);
365 write_buf(keymap, buf, size, offset, "\txkb_types {\n\n");
367 write_vmods(keymap, buf, size, offset);
369 darray_foreach(type, keymap->types) {
370 write_buf(keymap, buf, size, offset, "\t\ttype \"%s\" {\n",
372 write_buf(keymap, buf, size, offset, "\t\t\tmodifiers= %s;\n",
373 get_mod_mask_text(keymap, type->mods.real_mods,
376 for (n = 0; n < darray_size(type->map); n++) {
377 struct xkb_kt_map_entry *entry = &darray_item(type->map, n);
380 str = get_mod_mask_text(keymap, entry->mods.real_mods,
382 write_buf(keymap, buf, size, offset, "\t\t\tmap[%s]= Level%d;\n",
383 str, entry->level + 1);
385 if (!type->preserve || (!type->preserve[n].real_mods &&
386 !type->preserve[n].vmods))
388 write_buf(keymap, buf, size, offset, "\t\t\tpreserve[%s]= ", str);
389 write_buf(keymap, buf, size, offset, "%s;\n",
390 get_mod_mask_text(keymap, type->preserve[n].real_mods,
391 type->preserve[n].vmods));
394 if (type->level_names) {
395 for (n = 0; n < type->num_levels; n++) {
396 if (!type->level_names[n])
398 write_buf(keymap, buf, size, offset,
399 "\t\t\tlevel_name[Level%d]= \"%s\";\n", n + 1,
400 type->level_names[n]);
403 write_buf(keymap, buf, size, offset, "\t\t};\n");
406 write_buf(keymap, buf, size, offset, "\t};\n\n");
411 write_indicator_map(struct xkb_keymap *keymap, char **buf, size_t *size,
412 size_t *offset, int num)
414 struct xkb_indicator_map *led = &keymap->indicators[num];
416 write_buf(keymap, buf, size, offset, "\t\tindicator \"%s\" {\n",
417 keymap->indicator_names[num]);
419 if (led->which_groups) {
420 if (led->which_groups != XkbIM_UseEffective) {
421 write_buf(keymap, buf, size, offset,
422 "\t\t\twhichGroupState= %s;\n",
423 get_indicator_state_text(
426 write_buf(keymap, buf, size, offset, "\t\t\tgroups= 0x%02x;\n",
430 if (led->which_mods) {
431 if (led->which_mods != XkbIM_UseEffective) {
432 write_buf(keymap, buf, size, offset, "\t\t\twhichModState= %s;\n",
433 get_indicator_state_text(led->which_mods));
435 write_buf(keymap, buf, size, offset, "\t\t\tmodifiers= %s;\n",
436 get_mod_mask_text(keymap, led->mods.real_mods,
441 write_buf(keymap, buf, size, offset, "\t\t\tcontrols= %s;\n",
442 get_control_mask_text(led->ctrls));
445 write_buf(keymap, buf, size, offset, "\t\t};\n");
450 get_interp_match_text(uint8_t type)
454 switch (type & XkbSI_OpMask) {
456 sprintf(ret, "NoneOf");
459 case XkbSI_AnyOfOrNone:
460 sprintf(ret, "AnyOfOrNone");
464 sprintf(ret, "AnyOf");
468 sprintf(ret, "AllOf");
472 sprintf(ret, "Exactly");
476 sprintf(ret, "0x%x", type & XkbSI_OpMask);
484 write_action(struct xkb_keymap *keymap, char **buf, size_t *size,
485 size_t *offset, union xkb_action *action, const char *prefix,
488 const char *type = NULL;
489 const char *args = NULL;
496 switch (action->any.type) {
500 case XkbSA_LatchMods:
506 if (action->mods.flags & XkbSA_UseModMapMods)
509 args = get_mod_mask_text(keymap, action->mods.real_mods,
511 write_buf(keymap, buf, size, offset, "%s%s(modifiers=%s%s%s)%s",
513 (action->any.type != XkbSA_LockGroup &&
514 (action->mods.flags & XkbSA_ClearLocks)) ?
516 (action->any.type != XkbSA_LockGroup &&
517 (action->mods.flags & XkbSA_LatchToLock)) ?
525 case XkbSA_LatchGroup:
528 case XkbSA_LockGroup:
532 keymap, buf, size, offset, "%s%s(group=%s%d%s%s)%s",
534 (!(action->group.flags & XkbSA_GroupAbsolute) &&
535 action->group.group > 0) ? "+" : "",
536 (action->group.flags & XkbSA_GroupAbsolute) ?
537 action->group.group + 1 : action->group.group,
538 (action->any.type != XkbSA_LockGroup &&
539 (action->group.flags & XkbSA_ClearLocks)) ?
541 (action->any.type != XkbSA_LockGroup &&
542 (action->group.flags & XkbSA_LatchToLock)) ?
547 case XkbSA_Terminate:
548 write_buf(keymap, buf, size, offset, "%sTerminate()%s", prefix,
553 write_buf(keymap, buf, size, offset, "%sMovePtr(x=%s%d,y=%s%d%s)%s",
555 (!(action->ptr.flags & XkbSA_MoveAbsoluteX) &&
556 action->ptr.x >= 0) ? "+" : "",
558 (!(action->ptr.flags & XkbSA_MoveAbsoluteY) &&
559 action->ptr.y >= 0) ? "+" : "",
561 (action->ptr.flags & XkbSA_NoAcceleration) ? ",!accel" : "",
568 case XkbSA_LockPtrBtn:
571 switch (action->btn.flags &
572 (XkbSA_LockNoUnlock | XkbSA_LockNoLock)) {
573 case XkbSA_LockNoUnlock:
574 args = ",affect=lock";
577 case XkbSA_LockNoLock:
578 args = ",affect=unlock";
581 case XkbSA_LockNoLock | XkbSA_LockNoUnlock:
582 args = ",affect=neither";
586 args = ",affect=both";
593 write_buf(keymap, buf, size, offset, "%s%s(button=", prefix, type);
594 if (action->btn.button > 0 && action->btn.button <= 5)
595 write_buf(keymap, buf, size, offset, "%d", action->btn.button);
597 write_buf(keymap, buf, size, offset, "default");
598 if (action->btn.count)
599 write_buf(keymap, buf, size, offset, ",count=%d",
602 write_buf(keymap, buf, size, offset, "%s", args);
603 write_buf(keymap, buf, size, offset, ")%s", suffix);
606 case XkbSA_SetPtrDflt:
607 write_buf(keymap, buf, size, offset, "%sSetPtrDflt(", prefix);
608 if (action->dflt.affect == XkbSA_AffectDfltBtn)
609 write_buf(keymap, buf, size, offset, "affect=button,button=%s%d",
610 (!(action->dflt.flags & XkbSA_DfltBtnAbsolute) &&
611 action->dflt.value >= 0) ? "+" : "",
613 write_buf(keymap, buf, size, offset, ")%s", suffix);
616 case XkbSA_SwitchScreen:
617 write_buf(keymap, buf, size, offset,
618 "%sSwitchScreen(screen=%s%d,%ssame)%s", prefix,
619 (!(action->screen.flags & XkbSA_SwitchAbsolute) &&
620 action->screen.screen >= 0) ? "+" : "",
621 action->screen.screen,
622 (action->screen.flags & XkbSA_SwitchApplication) ? "!" : "",
626 /* Deprecated actions below here */
627 case XkbSA_SetControls:
629 type = "SetControls";
630 case XkbSA_LockControls:
632 type = "LockControls";
633 write_buf(keymap, buf, size, offset, "%s%s(controls=%s)%s",
634 prefix, type, get_control_mask_text(action->ctrls.ctrls),
639 case XkbSA_ActionMessage:
640 case XkbSA_RedirectKey:
641 case XkbSA_DeviceBtn:
642 case XkbSA_LockDeviceBtn:
645 write_buf(keymap, buf, size, offset, "%sNoAction()%s", prefix, suffix);
648 case XkbSA_XFree86Private:
650 write_buf(keymap, buf, size, offset,
651 "%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",
652 prefix, action->any.type, action->any.data[0],
653 action->any.data[1], action->any.data[2],
654 action->any.data[3], action->any.data[4],
655 action->any.data[5], action->any.data[6],
664 write_compat(struct xkb_keymap *keymap, char **buf, size_t *size,
668 struct xkb_sym_interpret *interp;
670 if (keymap->compat_section_name)
671 write_buf(keymap, buf, size, offset,
672 "\txkb_compatibility \"%s\" {\n\n",
673 keymap->compat_section_name);
675 write_buf(keymap, buf, size, offset, "\txkb_compatibility {\n\n");
677 write_vmods(keymap, buf, size, offset);
679 write_buf(keymap, buf, size, offset,
680 "\t\tinterpret.useModMapMods= AnyLevel;\n");
681 write_buf(keymap, buf, size, offset, "\t\tinterpret.repeat= False;\n");
682 write_buf(keymap, buf, size, offset, "\t\tinterpret.locking= False;\n");
684 darray_foreach(interp, keymap->sym_interpret) {
685 char keysym_name[64];
687 if (interp->sym == XKB_KEY_NoSymbol)
688 sprintf(keysym_name, "Any");
690 xkb_keysym_get_name(interp->sym, keysym_name, sizeof(keysym_name));
692 write_buf(keymap, buf, size, offset, "\t\tinterpret %s+%s(%s) {\n",
694 get_interp_match_text(interp->match),
695 get_mod_mask_text(keymap, interp->mods, 0));
697 if (interp->virtual_mod != XkbNoModifier) {
698 write_buf(keymap, buf, size, offset,
699 "\t\t\tvirtualModifier= %s;\n",
700 keymap->vmod_names[interp->virtual_mod]);
703 if (interp->match & XkbSI_LevelOneOnly)
704 write_buf(keymap, buf, size, offset,
705 "\t\t\tuseModMapMods=level1;\n");
706 if (interp->flags & XkbSI_LockingKey)
707 write_buf(keymap, buf, size, offset, "\t\t\tlocking= True;\n");
708 if (interp->flags & XkbSI_AutoRepeat)
709 write_buf(keymap, buf, size, offset, "\t\t\trepeat= True;\n");
711 write_action(keymap, buf, size, offset, &interp->act,
712 "\t\t\taction= ", ";\n");
713 write_buf(keymap, buf, size, offset, "\t\t};\n");
716 for (i = 0; i < XkbNumKbdGroups; i++) {
719 gc = &keymap->groups[i];
720 if (gc->real_mods == 0 && gc->vmods == 0)
722 write_buf(keymap, buf, size, offset,
723 "\t\tgroup %d = %s;\n", i + 1,
724 get_mod_mask_text(keymap, gc->real_mods, gc->vmods));
727 for (i = 0; i < XkbNumIndicators; i++) {
728 struct xkb_indicator_map *map = &keymap->indicators[i];
729 if (map->flags == 0 && map->which_groups == 0 &&
730 map->groups == 0 && map->which_mods == 0 &&
731 map->mods.real_mods == 0 && map->mods.vmods == 0 &&
734 write_indicator_map(keymap, buf, size, offset, i);
737 write_buf(keymap, buf, size, offset, "\t};\n\n");
743 write_keysyms(struct xkb_keymap *keymap, char **buf, size_t *size,
744 size_t *offset, xkb_keycode_t kc, unsigned int group)
746 const xkb_keysym_t *syms;
748 #define OUT_BUF_LEN 128
749 char out_buf[OUT_BUF_LEN];
751 for (level = 0; level < XkbKeyGroupWidth(keymap, kc, group); level++) {
753 write_buf(keymap, buf, size, offset, ", ");
754 num_syms = xkb_key_get_syms_by_level(keymap, kc, group, level,
757 write_buf(keymap, buf, size, offset, "%15s", "NoSymbol");
759 else if (num_syms == 1) {
760 xkb_keysym_get_name(syms[0], out_buf, OUT_BUF_LEN);
761 write_buf(keymap, buf, size, offset, "%15s", out_buf);
765 write_buf(keymap, buf, size, offset, "{ ");
766 for (s = 0; s < num_syms; s++) {
768 write_buf(keymap, buf, size, offset, ", ");
769 xkb_keysym_get_name(syms[s], out_buf, OUT_BUF_LEN);
770 write_buf(keymap, buf, size, offset, "%15s", out_buf);
772 write_buf(keymap, buf, size, offset, " }");
781 write_symbols(struct xkb_keymap *keymap, char **buf, size_t *size,
789 if (keymap->symbols_section_name)
790 write_buf(keymap, buf, size, offset, "\txkb_symbols \"%s\" {\n\n",
791 keymap->symbols_section_name);
793 write_buf(keymap, buf, size, offset, "\txkb_symbols {\n\n");
795 for (tmp = group = 0; group < XkbNumKbdGroups; group++) {
796 if (!keymap->group_names[group])
798 write_buf(keymap, buf, size, offset,
799 "\t\tname[group%d]=\"%s\";\n", group + 1,
800 keymap->group_names[group]);
804 write_buf(keymap, buf, size, offset, "\n");
806 for (kc = keymap->min_key_code; kc <= keymap->max_key_code; kc++) {
808 key = XkbKey(keymap, kc);
810 if (xkb_key_num_groups(keymap, kc) == 0)
813 write_buf(keymap, buf, size, offset, "\t\tkey %6s {",
814 XkbcKeyNameText(key->name.name));
816 if (key->explicit & XkbExplicitKeyTypesMask) {
817 bool multi_type = false;
818 int type = XkbKeyTypeIndex(keymap, kc, 0);
822 for (group = 0; group < xkb_key_num_groups(keymap, kc);
824 if (XkbKeyTypeIndex(keymap, kc, group) != type) {
832 group < xkb_key_num_groups(keymap, kc);
834 if (!(key->explicit & (1 << group)))
836 type = XkbKeyTypeIndex(keymap, kc, group);
837 write_buf(keymap, buf, size, offset,
838 "\n\t\t\ttype[group%d]= \"%s\",",
840 darray_item(keymap->types, type).name);
844 write_buf(keymap, buf, size, offset,
845 "\n\t\t\ttype= \"%s\",",
846 darray_item(keymap->types, type).name);
850 if (key->explicit & XkbExplicitAutoRepeatMask) {
852 write_buf(keymap, buf, size, offset,
853 "\n\t\t\trepeat= Yes,");
855 write_buf(keymap, buf, size, offset,
856 "\n\t\t\trepeat= No,");
860 if (key->vmodmap && (key->explicit & XkbExplicitVModMapMask)) {
861 write_buf(keymap, buf, size, offset, "\n\t\t\tvirtualMods= %s,",
862 get_mod_mask_text(keymap, 0, key->vmodmap));
865 switch (XkbOutOfRangeGroupAction(XkbKeyGroupInfo(keymap, kc))) {
866 case XkbClampIntoRange:
867 write_buf(keymap, buf, size, offset, "\n\t\t\tgroupsClamp,");
870 case XkbRedirectIntoRange:
871 write_buf(keymap, buf, size, offset,
872 "\n\t\t\tgroupsRedirect= Group%d,",
873 XkbOutOfRangeGroupNumber(XkbKeyGroupInfo(keymap,
878 if (key->explicit & XkbExplicitInterpretMask)
879 showActions = XkbKeyHasActions(keymap, kc);
883 if (xkb_key_num_groups(keymap, kc) > 1 || showActions)
887 write_buf(keymap, buf, size, offset, "\t[ ");
888 if (!write_keysyms(keymap, buf, size, offset, kc, 0))
890 write_buf(keymap, buf, size, offset, " ] };\n");
893 union xkb_action *acts;
896 acts = XkbKeyActionsPtr(keymap, kc);
897 for (group = 0; group < xkb_key_num_groups(keymap, kc); group++) {
899 write_buf(keymap, buf, size, offset, ",");
900 write_buf(keymap, buf, size, offset,
901 "\n\t\t\tsymbols[Group%d]= [ ", group + 1);
902 if (!write_keysyms(keymap, buf, size, offset, kc, group))
904 write_buf(keymap, buf, size, offset, " ]");
906 write_buf(keymap, buf, size, offset,
907 ",\n\t\t\tactions[Group%d]= [ ", group + 1);
909 level < XkbKeyGroupWidth(keymap, kc, group);
912 write_buf(keymap, buf, size, offset, ", ");
913 write_action(keymap, buf, size, offset, &acts[level],
916 write_buf(keymap, buf, size, offset, " ]");
917 acts += XkbKeyGroupsWidth(keymap, kc);
920 write_buf(keymap, buf, size, offset, "\n\t\t};\n");
924 for (kc = keymap->min_key_code; kc <= keymap->max_key_code; kc++) {
926 key = XkbKey(keymap, kc);
928 if (key->modmap == 0)
931 for (mod = 0; mod < XkbNumModifiers; mod++) {
932 if (!(key->modmap & (1 << mod)))
935 write_buf(keymap, buf, size, offset,
936 "\t\tmodifier_map %s { %s };\n",
937 get_mod_index_text(mod),
938 XkbcKeyNameText(key->name.name));
942 write_buf(keymap, buf, size, offset, "\t};\n\n");
947 xkb_map_get_as_string(struct xkb_keymap *keymap)
953 check_write_buf(keymap, &ret, &size, &offset, "xkb_keymap {\n");
956 if (!write_keycodes(keymap, &ret, &size, &offset))
958 if (!write_types(keymap, &ret, &size, &offset))
960 if (!write_compat(keymap, &ret, &size, &offset))
962 if (!write_symbols(keymap, &ret, &size, &offset))
964 check_write_buf(keymap, &ret, &size, &offset, "};\n");