1
/* $Xorg: XKBleds.c,v 1.3 2000/08/17 19:45:03 cpqbld Exp $ */
2
/************************************************************
3
Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
5
Permission to use, copy, modify, and distribute this
6
software and its documentation for any purpose and without
7
fee is hereby granted, provided that the above copyright
8
notice appear in all copies and that both that copyright
9
notice and this permission notice appear in supporting
10
documentation, and that the name of Silicon Graphics not be
11
used in advertising or publicity pertaining to distribution
12
of the software without specific prior written permission.
13
Silicon Graphics makes no representation about the suitability
14
of this software for any purpose. It is provided "as is"
15
without any express or implied warranty.
17
SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
18
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
19
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
20
GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
21
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
22
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
23
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
24
THE USE OR PERFORMANCE OF THIS SOFTWARE.
26
********************************************************/
27
/* $XFree86: xc/lib/X11/XKBleds.c,v 1.3 2001/02/21 15:18:03 tsi Exp $ */
32
#include <X11/extensions/XKBproto.h>
33
#include "XKBlibint.h"
36
#if NeedFunctionPrototypes
37
XkbGetIndicatorState(Display *dpy,unsigned deviceSpec,unsigned *pStateRtrn)
39
XkbGetIndicatorState(dpy,deviceSpec,pStateRtrn)
41
unsigned int deviceSpec;
42
unsigned int * pStateRtrn;
45
register xkbGetIndicatorStateReq *req;
46
xkbGetIndicatorStateReply rep;
50
if ((dpy->flags & XlibDisplayNoXkb) ||
51
(!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
55
GetReq(kbGetIndicatorState, req);
56
req->reqType = xkbi->codes->major_opcode;
57
req->xkbReqType = X_kbGetIndicatorState;
58
req->deviceSpec = deviceSpec;
59
ok=_XReply(dpy, (xReply *)&rep, 0, xFalse);
60
if (ok && (pStateRtrn!=NULL))
61
*pStateRtrn= rep.state;
64
return (ok?Success:BadImplementation);
68
#if NeedFunctionPrototypes
69
_XkbReadGetIndicatorMapReply( Display * dpy,
70
xkbGetIndicatorMapReply * rep,
74
_XkbReadGetIndicatorMapReply(dpy,rep,xkb,nread_rtrn)
76
xkbGetIndicatorMapReply * rep;
84
if ((!xkb->indicators)&&(XkbAllocIndicatorMaps(xkb)!=Success))
86
leds= xkb->indicators;
88
leds->phys_indicators = rep->realIndicators;
91
if (!_XkbInitReadBuffer(dpy,&buf,(int)rep->length*4))
94
*nread_rtrn= (int)rep->length*4;
97
left= (int)rep->which;
98
for (i=0,bit=1;(i<XkbNumIndicators)&&(left);i++,bit<<=1) {
100
xkbIndicatorMapWireDesc *wire;
101
wire= (xkbIndicatorMapWireDesc *)
102
_XkbGetReadBufferPtr(&buf,
103
SIZEOF(xkbIndicatorMapWireDesc));
105
_XkbFreeReadBuffer(&buf);
108
leds->maps[i].flags= wire->flags;
109
leds->maps[i].which_groups= wire->whichGroups;
110
leds->maps[i].groups= wire->groups;
111
leds->maps[i].which_mods= wire->whichMods;
112
leds->maps[i].mods.mask= wire->mods;
113
leds->maps[i].mods.real_mods= wire->realMods;
114
leds->maps[i].mods.vmods= wire->virtualMods;
115
leds->maps[i].ctrls= wire->ctrls;
120
left= _XkbFreeReadBuffer(&buf);
126
#if NeedFunctionPrototypes
127
XkbGetIndicatorMap(Display *dpy,unsigned long which,XkbDescPtr xkb)
129
XkbGetIndicatorMap(dpy,which,xkb)
135
register xkbGetIndicatorMapReq * req;
136
xkbGetIndicatorMapReply rep;
140
if ((dpy->flags & XlibDisplayNoXkb) ||
141
(!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
143
if ((!which)||(!xkb))
147
xkbi = dpy->xkb_info;
148
if (!xkb->indicators) {
149
xkb->indicators = _XkbTypedCalloc(1,XkbIndicatorRec);
150
if (!xkb->indicators) {
156
GetReq(kbGetIndicatorMap, req);
157
req->reqType = xkbi->codes->major_opcode;
158
req->xkbReqType = X_kbGetIndicatorMap;
159
req->deviceSpec = xkb->device_spec;
160
req->which = (CARD32)which;
161
if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
166
status= _XkbReadGetIndicatorMapReply(dpy,&rep,xkb,NULL);
173
#if NeedFunctionPrototypes
174
XkbSetIndicatorMap(Display *dpy,unsigned long which,XkbDescPtr xkb)
176
XkbSetIndicatorMap(dpy,which,xkb)
182
register xkbSetIndicatorMapReq *req;
185
xkbIndicatorMapWireDesc *wire;
188
if ((dpy->flags & XlibDisplayNoXkb) ||
189
(!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
191
if ((!xkb)||(!which)||(!xkb->indicators))
194
xkbi = dpy->xkb_info;
195
GetReq(kbSetIndicatorMap, req);
196
req->reqType = xkbi->codes->major_opcode;
197
req->xkbReqType = X_kbSetIndicatorMap;
198
req->deviceSpec = xkb->device_spec;
199
req->which = (CARD32)which;
200
for (i=nMaps=0,bit=1;i<32;i++,bit<<=1) {
204
req->length+= (nMaps*sizeof(XkbIndicatorMapRec))/4;
205
BufAlloc(xkbIndicatorMapWireDesc *,wire,
206
(nMaps*SIZEOF(xkbIndicatorMapWireDesc)));
207
for (i=0,bit=1;i<32;i++,bit<<=1) {
209
wire->flags= xkb->indicators->maps[i].flags;
210
wire->whichGroups= xkb->indicators->maps[i].which_groups;
211
wire->groups= xkb->indicators->maps[i].groups;
212
wire->whichMods= xkb->indicators->maps[i].which_mods;
213
wire->mods= xkb->indicators->maps[i].mods.real_mods;
214
wire->virtualMods= xkb->indicators->maps[i].mods.vmods;
215
wire->ctrls= xkb->indicators->maps[i].ctrls;
225
#if NeedFunctionPrototypes
226
XkbGetNamedDeviceIndicator( Display * dpy,
233
XkbIndicatorMapPtr pMapRtrn,
236
XkbGetNamedDeviceIndicator(dpy,device,class,id,name,pNdxRtrn,pStateRtrn,
245
XkbIndicatorMapPtr pMapRtrn;
249
register xkbGetNamedIndicatorReq *req;
250
xkbGetNamedIndicatorReply rep;
253
if ((dpy->flags & XlibDisplayNoXkb) || (name==None) ||
254
(!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
257
xkbi = dpy->xkb_info;
258
GetReq(kbGetNamedIndicator, req);
259
req->reqType = xkbi->codes->major_opcode;
260
req->xkbReqType = X_kbGetNamedIndicator;
261
req->deviceSpec = device;
262
req->ledClass = class;
264
req->indicator = (CARD32)name;
265
if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
270
if ((!rep.found)||(!rep.supported))
274
if (pStateRtrn!=NULL)
276
if (pMapRtrn!=NULL) {
277
pMapRtrn->flags= rep.flags;
278
pMapRtrn->which_groups= rep.whichGroups;
279
pMapRtrn->groups= rep.groups;
280
pMapRtrn->which_mods= rep.whichMods;
281
pMapRtrn->mods.mask= rep.mods;
282
pMapRtrn->mods.real_mods= rep.realMods;
283
pMapRtrn->mods.vmods= rep.virtualMods;
284
pMapRtrn->ctrls= rep.ctrls;
287
*pRealRtrn= rep.realIndicator;
292
#if NeedFunctionPrototypes
293
XkbGetNamedIndicator( Display * dpy,
297
XkbIndicatorMapPtr pMapRtrn,
300
XkbGetNamedIndicator(dpy,name,pNdxRtrn,pStateRtrn,pMapRtrn,pRealRtrn)
305
XkbIndicatorMapPtr pMapRtrn;
309
return XkbGetNamedDeviceIndicator(dpy,XkbUseCoreKbd,
310
XkbDfltXIClass,XkbDfltXIId,
311
name,pNdxRtrn,pStateRtrn,
316
#if NeedFunctionPrototypes
317
XkbSetNamedDeviceIndicator( Display * dpy,
325
XkbIndicatorMapPtr pMap)
327
XkbSetNamedDeviceIndicator(dpy,device,class,id,name,changeState,
328
state,createNewMap,pMap)
337
XkbIndicatorMapPtr pMap;
340
register xkbSetNamedIndicatorReq *req;
343
if ((dpy->flags & XlibDisplayNoXkb) || (name==None) ||
344
(!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
347
xkbi = dpy->xkb_info;
348
GetReq(kbSetNamedIndicator, req);
349
req->reqType = xkbi->codes->major_opcode;
350
req->xkbReqType = X_kbSetNamedIndicator;
351
req->deviceSpec = device;
352
req->ledClass = class;
354
req->indicator= (CARD32)name;
355
req->setState= changeState;
361
req->createMap= createNewMap;
362
req->flags= pMap->flags;
363
req->whichGroups= pMap->which_groups;
364
req->groups= pMap->groups;
365
req->whichMods= pMap->which_mods;
366
req->realMods= pMap->mods.real_mods;
367
req->virtualMods= pMap->mods.vmods;
368
req->ctrls= pMap->ctrls;
372
req->createMap= False;
387
#if NeedFunctionPrototypes
388
XkbSetNamedIndicator( Display * dpy,
393
XkbIndicatorMapPtr pMap)
395
XkbSetNamedIndicator(dpy,name,changeState,state,createNewMap,pMap)
401
XkbIndicatorMapPtr pMap;
404
return XkbSetNamedDeviceIndicator(dpy,XkbUseCoreKbd,
405
XkbDfltXIClass,XkbDfltXIId,
406
name,changeState,state,