1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
|
/* $XConsortium: xkbtest.c,v 1.2 93/09/28 23:51:37 rws Exp $ */
/************************************************************
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 <stdio.h>
#include <X11/Xproto.h>
#include <X11/Xlib.h>
#include <X11/X.h>
#include <X11/XKBlib.h>
static char *dpyName = NULL;
static int changes = 0;
static int synch = 0;
static int verbose = 0;
char *
stateText(state)
CARD8 state;
{
static char buf[12];
char *str;
if ( state == 0 ) {
strcpy(buf,"none");
return buf;
}
str= buf;
if ( state&ShiftMask ) *str++ = 'S';
if ( state&ControlMask ) *str++ = 'C';
if ( state&LockMask ) *str++ = 'L';
if ( state&Mod1Mask ) *str++ = '1';
if ( state&Mod2Mask ) *str++ = '2';
if ( state&Mod3Mask ) *str++ = '3';
if ( state&Mod4Mask ) *str++ = '4';
if ( state&Mod5Mask ) *str++ = '5';
*str++ = '\0';
return buf;
}
char *
actText(sa)
XkbAction sa;
{
static char buf[60];
switch (sa.type) {
case XkbSA_NoAction:
strcpy(buf,"NO_ACTION");
break;
case XkbSA_SetMods:
sprintf(buf,"SET_MODS(%s)",stateText(sa.mods.mask));
break;
case XkbSA_ISOLock:
sprintf(buf,"ISO_LOCK(%s)",stateText(sa.iso.mask));
break;
case XkbSA_LockMods:
sprintf(buf,"LOCK_MODS(%s)",stateText(sa.mods.mask));
break;
case XkbSA_LatchMods:
sprintf(buf,"LATCH_MODS(%s)",stateText(sa.mods.mask));
break;
case XkbSA_SetGroup:
sprintf(buf,"SET_GROUP(%s=%d)",
(sa.group.flags&XkbSA_GroupAbsolute?"absolute":"relative"),
XkbSAGroup(&sa.group));
break;
case XkbSA_LatchGroup:
sprintf(buf,"LATCH_GROUP(%s=%d)",
(sa.group.flags&XkbSA_GroupAbsolute?"absolute":"relative"),
XkbSAGroup(&sa.group));
break;
case XkbSA_LockGroup:
sprintf(buf,"LOCK_GROUP(%s=%d)",
(sa.group.flags&XkbSA_GroupAbsolute?"absolute":"relative"),
XkbSAGroup(&sa.group));
break;
case XkbSA_MovePtr:
sprintf(buf,"MOVE_POINTER=(%d,%d)",XkbPtrActionX(&sa.ptr),
XkbPtrActionY(&sa.ptr));
break;
case XkbSA_AccelPtr:
sprintf(buf,"ACCEL_POINTER=(%d,%d)",XkbPtrActionX(&sa.ptr),
XkbPtrActionY(&sa.ptr));
break;
case XkbSA_PtrBtn:
sprintf(buf,"POINTER_BUTTON(%d)",sa.btn.button);
break;
case XkbSA_ClickPtrBtn:
sprintf(buf,"CLICK_POINTER_BUTTON(%d,%d)",
sa.btn.count,sa.btn.button);
break;
case XkbSA_LockPtrBtn:
sprintf(buf,"LOCK_POINTER_BUTTON(%d)",sa.btn.button);
break;
case XkbSA_SetPtrDflt:
sprintf(buf,"SET_POINTER_DFLT(%d,%d)",sa.dflt.affect,
XkbSAPtrDfltValue(&sa.dflt));
break;
case XkbSA_Terminate:
sprintf(buf,"TERMINATE_SERVER");
break;
case XkbSA_SwitchScreen:
sprintf(buf,"SWITCH_TO_SCREEN(0x%x,%d)",sa.screen.flags,
XkbSAScreen(&sa.screen));
break;
case XkbSA_SetControls:
sprintf(buf,"SET_CONTROLS(0x%x)",XkbActionCtrls(&sa.ctrls));
break;
case XkbSA_LockControls:
sprintf(buf,"LOCK_CONTROLS(0x%x)",XkbActionCtrls(&sa.ctrls));
break;
default:
sprintf(buf,"UNKNOWN(0x%x)",sa);
break;
}
return buf;
}
static char *
SIMatchTypeText(match)
unsigned match;
{
static char buf[20];
buf[0]='\0';
switch (match) {
case XkbSI_NoneOf:
strcpy(buf,"NoneOf");
break;
case XkbSI_AnyOfOrNone:
strcpy(buf,"AnyOfOrNone");
break;
case XkbSI_AnyOf:
strcpy(buf,"AnyOf");
break;
case XkbSI_AllOf:
strcpy(buf,"AllOf");
break;
case XkbSI_Exactly:
strcpy(buf,"Exactly");
break;
}
return buf;
}
static void
PrintCompatMap(file,xkb)
FILE *file;
XkbDescPtr xkb;
{
register int i;
XkbSymInterpretPtr si;
fprintf(file,"%d symbol interpretations\n",xkb->compat->num_si);
si= xkb->compat->sym_interpret;
for (i=0;i<xkb->compat->num_si;i++,si++) {
register char *name= XKeysymToString(si->sym);
if (name) fprintf(file,"%s+",name);
else if (si->sym==NoSymbol)
fprintf(file,"Any+");
else fprintf(file,"0x%x+",si->sym);
fprintf(file,"%s(%s) = {\n",SIMatchTypeText(si->match),
stateText(si->mods));
fprintf(file," act = %s\n",actText(si->act));
if (si->flags&XkbSI_Autorepeat)
fprintf(file," repeats\n");
if (si->virtual_mod!=XkbNoModifier)
fprintf(file," virtual modifier= %d\n",si->virtual_mod);
fprintf(file,"}\n");
}
fprintf(file,"Modifier: mods groups\n");
for (i=0;i<XkbNumModifiers;i++) {
fprintf(file," %2d 0x%02x 0x%02x\n",
i,
xkb->compat->real_mod_compat[i].mods,
xkb->compat->real_mod_compat[i].groups);
}
fprintf(file,"Virtual Mod mods groups\n");
for (i=0;i<XkbNumVirtualMods;i++) {
fprintf(file," %2d 0x%02x 0x%02x\n",
i,
xkb->compat->vmod_compat[i].mods,
xkb->compat->vmod_compat[i].groups);
}
}
int
parseArgs(argc,argv)
int argc;
char *argv[];
{
int i;
for (i=1;i<argc;i++) {
if ( strcmp(argv[i],"-display")==0 ) {
if ( ++i<argc ) dpyName= argv[i];
else {
fprintf(stderr,"Must specify a display with -display option\n");
return 0;
}
}
else if ( strcmp(argv[i],"-synch")==0 ) {
synch= 1;
}
else if ((strcmp(argv[i],"-v")==0) || (strcmp(argv[i],"-verbose")==0)) {
verbose= 1;
}
else if (strcmp(argv[i],"-help")==0) {
return 0;
}
else {
fprintf(stderr,"Unknown option %s\n",argv[i]);
return 0;
}
}
return 1;
}
int
main(argc,argv)
int argc;
char *argv[];
{
Display *dpy;
int i1,i2,i3,i4,i5;
unsigned query;
unsigned int rtrnFlags;
XkbDescPtr xkb;
if (!parseArgs(argc,argv)) {
fprintf(stderr,"Usage: %s [<options>] \n",argv[0]);
fprintf(stderr," %s {start,end} [ <flags> [ <message> ] ]\n",
argv[0]);
fprintf(stderr,"Where legal options are:\n");
fprintf(stderr,"-display <dpy> specifies display to use\n");
fprintf(stderr,"-synch force synchronization\n");
fprintf(stderr,"-verbose display resulting compat map\n");
fprintf(stderr,"If no changes are indicated, %s simply reports\n",
argv[0]);
fprintf(stderr,"the current state of all compatbility mappings.\n");
return 1;
}
dpy = XOpenDisplay(dpyName);
if ( !dpy )
return 1;
if (synch)
XSynchronize(dpy,1);
if ( !XkbQueryExtension(dpy,&i1,&i2,&i3,&i4,&i5)>0 ) {
fprintf(stderr,"query failed\n");
goto BAIL;
}
if ( !XkbUseExtension(dpy) ) {
fprintf(stderr,"use extension failed (%d,%d)\n",i4,i5);
goto BAIL;
}
xkb= XkbGetMap(dpy,0,XkbUseCoreKbd);
if (!xkb) {
fprintf(stderr,"Couldn't get keyboard map.\n");
goto BAIL;
}
if (!XkbGetCompatMap(dpy,XkbAllCompatMask,xkb)) {
fprintf(stderr,"Couldn't get compatibility map.\n");
goto BAIL;
}
if (changes) {
/* apply changes to compatibility map here */
}
if ((!changes)||verbose)
PrintCompatMap(stdout,xkb);
XCloseDisplay(dpy);
return 0;
BAIL:
XCloseDisplay(dpy);
return 0;
}
|