/* $XConsortium: xkbshow.c /main/10 1996/02/05 11:44:24 kaleb $ */ /************************************************************ Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc. Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of Silicon Graphics not be used in advertising or publicity pertaining to distribution of the software without specific prior written permission. Silicon Graphics makes no representation about the suitability of this software for any purpose. It is provided "as is" without any express or implied warranty. SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ********************************************************/ #include #include #include #include #include #include #include void #if NeedFunctionPrototypes printSyms(XkbKeyTypePtr map,KeySym *sym,int num) #else printSyms(map,sym,num) XkbKeyTypePtr map; KeySym * sym; int num; #endif { int i,nsPending; char *name; nsPending= 0; for (i=0;i0) { printf("NoSymbol "); nsPending--; } name = XKeysymToString(sym[i]); if ( name ) printf("%s ",name); else printf("unknown (0x%x)",sym[i]); } } } /***====================================================================***/ void #if NeedFunctionPrototypes showKeys(Display *dpy,XkbDescPtr xkb,unsigned which) #else showKeys(dpy,xkb,which) Display * dpy; XkbDescPtr xkb; unsigned which; #endif { int i,key,nKeys; XkbServerMapPtr srv; XkbClientMapPtr map; if ( !(which & (XkbKeySymsMask|XkbKeyBehaviorsMask|XkbKeyActionsMask)) ) return; map= xkb->map; srv= xkb->server; nKeys = xkb->max_key_code-xkb->min_key_code+1; for (i=0,key=xkb->min_key_code;itypes) { Atom name; Bool multiType; int g,ndx; ndx= XkbKeyKeyTypeIndex(xkb,key,0); for (multiType=False,g=1;gname; if (name==None) printf(" type=%d",XkbKeyKeyTypeIndex(xkb,key,0)); else printf(" %s",XkbAtomText(dpy,name,XkbMessage)); } else { for (g=0;gname; if (name==None) printf("%d",XkbKeyKeyTypeIndex(xkb,key,0)); else printf("%s",XkbAtomText(dpy,name,XkbMessage)); } } if (xkb->names && xkb->names->keys) { char buf[5]; memcpy(buf,xkb->names->keys[key].name,4); buf[4]= '\0'; printf(" <%s>",buf); } } if ((xkb->ctrls->per_key_repeat[key/8]&(1<<(key&0x7)))==0) { printf(", non-repeating"); if (xkb->server->explicit[key]&XkbExplicitAutoRepeatMask) printf("(explicit)"); } printf(":\n"); if ((map->modmap)&&(map->modmap[key]!=0)) { printf(" Affects real modifiers: %s\n", XkbModMaskText(map->modmap[key],XkbMessage)); } if ((srv->vmodmap)&&(srv->vmodmap[key]!=0)) { printf(" Affects virtual modifiers: %s\n", XkbVModMaskText(dpy,xkb,0,srv->vmodmap[key],XkbMessage)); } if ( which & XkbKeySymsMask ) { int n = XkbKeyNumSyms(xkb,key); int ng= XkbKeyNumGroups(xkb,key); int tmp; switch (XkbOutOfRangeGroupAction(XkbKeyGroupInfo(xkb,key))) { default: case XkbWrapIntoRange: printf(" Groups wrap into range\n"); break; case XkbClampIntoRange: printf(" Groups clamp into range\n"); break; case XkbRedirectIntoRange: printf(" Out of range groups redirected to Group%d\n", XkbOutOfRangeGroupNumber(XkbKeyGroupInfo(xkb,key))+1); break; } for (tmp=0;tmp1)||(acts[0].type!=XkbSA_NoAction)) { int nGroups= XkbKeyNumGroups(xkb,key); int nLevels= nActs/nGroups; int g,l; for (g=0;gserver->explicit[key]&XkbExplicitInterpretMask) printf("] (explicit)\n"); else printf("]\n"); } } } if ( which & XkbKeyBehaviorsMask ) { XkbBehavior *b= &xkb->server->behaviors[key]; if (b->type!=XkbKB_Default) { printf(" Behavior: %s%s\n",XkbBehaviorText(xkb,b,XkbMessage), (xkb->server->explicit[key]&XkbExplicitBehaviorMask? " (explicit)":"")); } } if (srv->explicit[key]&XkbExplicitKeyTypesMask) { int g; for (g=0;gexplicit[key]&(1<name; printf(" Type[Group%d]: %s (explicit)\n",g+1, XkbAtomText(dpy,name,XkbMessage)); } } } } } void #if NeedFunctionPrototypes showKeyTypes(Display *dpy,XkbDescPtr xkb) #else showKeyTypes(dpy,xkb) Display * dpy; XkbDescPtr xkb; #endif { XkbClientMapRec *map = xkb->map; int i,m; for (i=0;inum_types;i++) { XkbKeyTypeRec *type= &map->types[i]; printf("Key Type %d (%s):\n",i,XkbAtomText(dpy,type->name,XkbMessage)); printf(" mask: %s\n", XkbModMaskText(type->mods.mask,XkbMessage)); printf(" real mods: %s\n", XkbModMaskText(type->mods.real_mods,XkbMessage)); printf(" virtual mods: %s\n", XkbVModMaskText(dpy,xkb,0,type->mods.vmods,XkbMessage)); printf(" group width: %d\n",type->num_levels); if (type->map_count>0) { XkbKTMapEntryPtr me; printf(" map: "); for (m=0,me=&type->map[0];mmap_count;m++,me++) { if (m!=0) printf(" "); printf("%s= %d", XkbVModMaskText(dpy,xkb, me->mods.real_mods,me->mods.vmods, XkbMessage), me->level); if (!type->map[m].active) printf("(disabled)"); if (type->preserve) { unsigned rmods= type->preserve[m].real_mods; unsigned vmods= type->preserve[m].vmods; unsigned mask= type->preserve[m].mask; if (rmods!=0) { printf("\n [preserve %s (%s", XkbModMaskText(mask,XkbMessage), XkbModMaskText(rmods,XkbMessage)); if (type->preserve[m].vmods!=0) { printf("+%s)]", XkbVModMaskText(dpy,xkb,0,vmods,XkbMessage)); } else printf(")]"); } else if (vmods!=0) { printf(" [preserve %s (%s)]", XkbModMaskText(mask,XkbMessage), XkbVModMaskText(dpy,xkb,0,vmods,XkbMessage)); } } printf("\n"); } } if (type->level_names!=NULL) { for (m=0;mnum_levels;m++) { printf(" level %d: %s\n",m, XkbAtomText(dpy,type->level_names[m],XkbMessage)); } } else printf(" level names: none\n"); } return; } /***====================================================================***/ static char *dpyName = NULL; static int getState = -1; static int getMap = -1; static unsigned which = XkbAllMapComponentsMask; static int usePartialQueries = 0; static int synch = 0; static int debug = 0; int #if NeedFunctionPrototypes parseArgs(int argc,char *argv[]) #else parseArgs(argc,argv) int argc; char *argv[]; #endif { int i; for (i=1;i\n",argv[0]); fprintf(stderr,"Where legal options are:\n"); fprintf(stderr,"-display specifies display to use\n"); fprintf(stderr,"-debug turn on extra debugging\n"); fprintf(stderr,"-s report keyboard state\n"); fprintf(stderr,"-m specifies subset of keyboard mapping to display\n"); fprintf(stderr," Legal subsets are:\n"); fprintf(stderr," t: Key Types\n"); fprintf(stderr," s: Key Syms\n"); fprintf(stderr," a: Key Actions\n"); fprintf(stderr," b: Key Behaviors\n"); fprintf(stderr," r: Radio Groups\n"); fprintf(stderr,"-1 specifies use of partial queries\n"); return 1; } major= XkbMajorVersion; minor= XkbMinorVersion; dpy = XkbOpenDisplay(dpyName,NULL,NULL,&major,&minor,&why); if (dpy==NULL) { if (dpyName==NULL) dpyName= "default display"; switch (why) { case XkbOD_BadLibraryVersion: fprintf(stderr,"%s was compiled with XKB version %d.%02d\n", argv[0],XkbMajorVersion,XkbMinorVersion); fprintf(stderr,"Xlib supports incompatible version %d.%02d\n", major,minor); break; case XkbOD_ConnectionRefused: fprintf(stderr,"Cannot open display \"%s\"\n",dpyName); break; case XkbOD_NonXkbServer: fprintf(stderr,"XKB extension not present on %s\n",dpyName); break; case XkbOD_BadServerVersion: fprintf(stderr,"%s was compiled with XKB version %d.%02d\n", argv[0],XkbMajorVersion,XkbMinorVersion); fprintf(stderr,"Server %s uses incompatible version %d.%02d\n", dpyName,major,minor); break; default: fprintf(stderr, "Internal Error! Unknown error %d from XkbOpenDisplay\n", why); } return 1; } if (synch) XSynchronize(dpy,1); if ((getState>0) && (getMap<0)) getMap = 0; else if ((getMap>0) && (getState<0)) getState = 0; else if ((getMap<0) && (getState<0)) getMap = getState = 1; if ( getState ) { XGetKeyboardControl(dpy,&coreKbdState); if (XkbGetState(dpy,XkbUseCoreKbd,&state)!=Success) { fprintf(stderr,"get keyboard state request failed\n"); goto BAIL; } #define MMT(m) XkbModMaskText(m,XkbMessage) printf("group: %d\n",state.group+1); printf("base group: %d\n",state.base_group+1); printf("latched group: %d\n",state.latched_group+1); printf("locked group: %d\n",state.locked_group+1); printf("mods: %s\n",MMT(state.mods)); printf("base mods: %s\n",MMT(state.base_mods)); printf("latched: %s\n",MMT(state.latched_mods)); printf("locked: %s\n",MMT(state.locked_mods)); printf("grab mods: %s\n",MMT(state.grab_mods)); printf("lookup mods: %s\n",MMT(state.lookup_mods)); printf("compat state: %s\n",MMT(state.compat_state)); printf("compat grab mods: %s\n",MMT(state.compat_grab_mods)); printf("compat lookup mods: %s\n",MMT(state.compat_lookup_mods)); } if ( getMap ) { query = which; if (query&(XkbKeySymsMask|XkbKeyActionsMask)) query|= XkbKeyTypesMask; xkb= XkbGetMap(dpy,0,XkbUseCoreKbd); if ( !usePartialQueries ) { if ( XkbGetUpdatedMap(dpy,query,xkb)!=Success ) { fprintf(stderr,"get keyboard desc request failed\n"); goto BAIL; } } else { if ( query & XkbKeyTypesMask ) { if ( XkbGetKeyTypes(dpy,0,3,xkb)!=Success ) { fprintf(stderr,"XkbGetKeyTypes failed\n"); goto BAIL; } } } srv= xkb->server; if (XkbGetControls(dpy,XkbAllControlsMask,xkb)!=Success) { fprintf(stderr,"XkbGetControls failed\n"); goto BAIL; } if (XkbGetNames(dpy,XkbAllNamesMask,xkb)!=Success) { fprintf(stderr,"XkbGetNames failed\n"); goto BAIL; } if (XkbGetIndicatorMap(dpy,XkbAllIndicatorsMask,xkb)!=Success) { fprintf(stderr,"XkbGetIndicatorMap failed\n"); goto BAIL; } if (XkbGetIndicatorState(dpy,XkbUseCoreKbd,&istate)!=Success) { fprintf(stderr,"XkbGetIndicatorState failed\n"); goto BAIL; } ctrls= xkb->ctrls; nm= xkb->names; printf("Device ID: %d\n",xkb->device_spec); printf("keycodes type: %s\n",XkbAtomText(dpy,nm->keycodes,XkbMessage)); printf("geometry type: %s\n",XkbAtomText(dpy,nm->geometry,XkbMessage)); printf("symbols type: %s ",XkbAtomText(dpy,nm->symbols,XkbMessage)); printf("phys=%s\n",XkbAtomText(dpy,nm->phys_symbols,XkbMessage)); printf("types: %s\n",XkbAtomText(dpy,nm->types,XkbMessage)); printf("compat: %s\n",XkbAtomText(dpy,nm->compat,XkbMessage)); printf("keycode range: %d-%d\n",xkb->min_key_code,xkb->max_key_code); printf("audible bell: %s\n", ((ctrls->enabled_ctrls&XkbAudibleBellMask)?"on":"off")); printf("internal mods: %s ", XkbModMaskText(ctrls->internal.mask,XkbMessage)); printf("(%s) ",XkbModMaskText(ctrls->internal.real_mods,XkbMessage)); printf("(%s)\n", XkbVModMaskText(dpy,xkb,0,ctrls->internal.vmods,XkbMessage)); printf("ignore lock mods: %s ", XkbModMaskText(ctrls->ignore_lock.mask,XkbMessage)); printf("(%s) ",XkbModMaskText(ctrls->ignore_lock.real_mods,XkbMessage)); printf("(%s)\n", XkbVModMaskText(dpy,xkb,0,ctrls->ignore_lock.vmods,XkbMessage)); printf("ignore group lock: %s\n", ((ctrls->enabled_ctrls&XkbIgnoreGroupLockMask)?"on":"off")); printf("repeat keys: %s (%d/%d -- %s)\n", (coreKbdState.global_auto_repeat?"on":"off"), ctrls->repeat_delay,ctrls->repeat_interval, ((ctrls->enabled_ctrls&XkbRepeatKeysMask)?"sw":"hw")); printf("slow keys: %s (%d)\n", (ctrls->enabled_ctrls&XkbSlowKeysMask?"on":"off"), ctrls->slow_keys_delay); printf("bounce keys: %s (%d)\n", (ctrls->enabled_ctrls&XkbBounceKeysMask?"on":"off"), ctrls->debounce_delay); printf("sticky keys: %s\n", (ctrls->enabled_ctrls&XkbStickyKeysMask?"on":"off")); printf("mouse keys: %s (btn=%d,accel=%d/%d/%d/%d)\n", (ctrls->enabled_ctrls&XkbMouseKeysMask?"on":"off"), ctrls->mk_dflt_btn, ctrls->mk_delay, ctrls->mk_interval, ctrls->mk_time_to_max, ctrls->mk_curve); printf("access X keys: %s (timeout=%d)\n", (ctrls->enabled_ctrls&XkbAccessXKeysMask?"on":"off"), ctrls->ax_timeout); printf(" controls(mask= 0x%x,values=0x%x)\n", ctrls->axt_ctrls_mask,ctrls->axt_opts_mask); printf(" AXoptions(mask= 0x%x,values=0x%x)\n", ctrls->axt_opts_mask,ctrls->axt_opts_values); printf("overlay 1: %s\n", ((ctrls->enabled_ctrls&XkbOverlay1Mask)?"on":"off")); printf("overlay 2: %s\n", ((ctrls->enabled_ctrls&XkbOverlay2Mask)?"on":"off")); printf("virtual modifier names:\n"); for (i=0;ivmods[i]!=None) printf("%2d: %-12s",i, XkbAtomText(dpy,nm->vmods[i],XkbMessage)); else if (srv->vmods[i]!=XkbNoModifierMask) printf("%2d: %-12s",i,"(no name)"); else continue; printf(" = %s\n",XkbModMaskText(srv->vmods[i],XkbMessage)); } for (i=0;igroups[i]!=None) { static int been_here=0; if (!been_here) { been_here=1; printf("group names:\n"); } printf("%2d: %s\n",i+1, XkbAtomText(dpy,nm->groups[i],XkbMessage)); } } for (i=0;iindicators[i])!=None) { static int been_here=0; char *type; if (!been_here) { been_here=1; printf("indicators:\n"); } if (xkb->indicators==NULL) type= "unknown"; else if (xkb->indicators->phys_indicators&(1<key_aliases) { register int nKeys= nm->num_key_aliases; printf("Alias Real\n"); printf("----------------\n"); for (i=0;ikey_aliases[i].alias,XkbMessage), XkbKeyNameText(nm->key_aliases[i].real,XkbMessage)); } printf("----------------\n"); } else { printf("No key aliases defined\n"); } if (nm->keys) { register int nKeys= xkb->max_key_code-xkb->min_key_code+1; char buf[5]; buf[4]= '\0'; printf("keys:\n"); for (i=0;ikeys[i+xkb->min_key_code].name,4); printf("%-4s ",buf); if ((i&0x7)==7) printf("\n"); } if ((i&0x7)!=0) printf("\n"); } printf("%d keyboard groups\n",ctrls->num_groups); printf("keyboard groups %s\n", (ctrls->enabled_ctrls&XkbGroupsWrapMask)?"wrap":"don't wrap"); showKeys(dpy,xkb,which); if ( which & XkbKeyTypesMask ) showKeyTypes(dpy,xkb); XCloseDisplay(dpy); } return 0; BAIL: XCloseDisplay(dpy); return 0; }