/* $XConsortium: xkblock.c /main/7 1996/02/05 11:44:28 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 static char *dpyName = NULL; static unsigned device = XkbUseCoreKbd; static unsigned mask = 0; static unsigned value = 0; static unsigned latch = 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,"-latch latch specified modifiers\n"); fprintf(stderr,"-lock lock specified modifiers (default)\n"); fprintf(stderr,"[+-][sS] set/clear shift\n"); fprintf(stderr,"[+-]C set/clear caps\n"); fprintf(stderr,"[+-]c set/clear control\n"); fprintf(stderr,"[+-][amAM1] set/clear mod1 (alt/meta)\n"); fprintf(stderr,"[+-]2 set/clear mod2\n"); fprintf(stderr,"[+-]3 set/clear mod3\n"); fprintf(stderr,"[+-]4 set/clear mod4\n"); fprintf(stderr,"[+-]5 set/clear mod5\n"); return 1; } if ( mask==0 ) { mask = LockMask; value = LockMask; } 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; } XSynchronize(dpy,1); if (XkbGetState(dpy,XkbUseCoreKbd,&state)!=Success) { fprintf(stderr,"XkbGetState failed\n"); exit(1); } printf(" ------- group -------- ------- modifiers -------------\n"); printf(" eff base latch lock eff base latch lock compat\n"); printf("before: %2d %2d %2d %2d 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n", state.group, state.base_group, state.latched_group, state.locked_group, state.mods, state.base_mods, state.latched_mods, state.locked_mods, state.compat_state); if (latch) XkbLatchModifiers(dpy,device,mask,value); else XkbLockModifiers(dpy,device,mask,value); bzero(&state,sizeof(state)); if (XkbGetState(dpy,XkbUseCoreKbd,&state)!=Success) { fprintf(stderr,"XkbGetState failed\n"); exit(1); } printf("after: %2d %2d %2d %2d 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n", state.group, state.base_group, state.latched_group, state.locked_group, state.mods, state.base_mods, state.latched_mods, state.locked_mods, state.compat_state); XCloseDisplay(dpy); return 0; }