1
/* $Xorg: XKBExtDev.c,v 1.3 2000/08/17 19:45:01 cpqbld Exp $ */
2
/************************************************************
3
Copyright (c) 1995 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/XKBExtDev.c,v 3.4 2001/10/28 03:32:33 tsi Exp $ */
32
#define NEED_MAP_READERS
34
#include <X11/extensions/XKBproto.h>
35
#include "XKBlibint.h"
36
#include <X11/extensions/XI.h>
38
/***====================================================================***/
41
#if NeedFunctionPrototypes
42
XkbNoteDeviceChanges( XkbDeviceChangesPtr old,
43
XkbExtensionDeviceNotifyEvent * new,
46
XkbNoteDeviceChanges(old,new,wanted)
47
XkbDeviceChangesPtr old;
48
XkbExtensionDeviceNotifyEvent * new;
52
if ((!old)||(!new)||(!wanted)||((new->reason&wanted)==0))
54
if ((wanted&new->reason)&XkbXI_ButtonActionsMask) {
55
if (old->changed&XkbXI_ButtonActionsMask) {
56
int first,last,newLast;
57
if (new->first_btn<old->first_btn)
58
first= new->first_btn;
59
else first= old->first_btn;
60
last= old->first_btn+old->num_btns-1;
61
newLast= new->first_btn+new->num_btns-1;
64
old->first_btn= first;
65
old->num_btns= (last-first)+1;
68
old->changed|= XkbXI_ButtonActionsMask;
69
old->first_btn= new->first_btn;
70
old->num_btns= new->num_btns;
73
if ((wanted&new->reason)&XkbXI_IndicatorsMask) {
74
XkbDeviceLedChangesPtr this;
75
if (old->changed&XkbXI_IndicatorsMask) {
76
XkbDeviceLedChangesPtr found;
78
for (this= &old->leds;this&&(!found);this=this->next) {
79
if ((this->led_class==new->led_class)&&
80
(this->led_id==new->led_id)) {
85
found= _XkbTypedCalloc(1,XkbDeviceLedChangesRec);
88
found->next= old->leds.next;
89
found->led_class= new->led_class;
90
found->led_id= new->led_id;
91
old->leds.next= found;
93
if ((wanted&new->reason)&XkbXI_IndicatorNamesMask)
94
found->defined= new->leds_defined;
97
old->changed|= ((wanted&new->reason)&XkbXI_IndicatorsMask);
98
old->leds.led_class= new->led_class;
99
old->leds.led_id= new->led_id;
100
old->leds.defined= new->leds_defined;
101
if (old->leds.next) {
102
XkbDeviceLedChangesPtr next;
103
for (this=old->leds.next;this;this=next) {
107
old->leds.next= NULL;
114
/***====================================================================***/
117
#if NeedFunctionPrototypes
118
_XkbReadDeviceLedInfo( XkbReadBufferPtr buf,
120
XkbDeviceInfoPtr devi)
122
_XkbReadDeviceLedInfo(buf,present,devi)
123
XkbReadBufferPtr buf;
125
XkbDeviceInfoPtr devi;
128
register unsigned i,bit;
129
XkbDeviceLedInfoPtr devli;
130
xkbDeviceLedsWireDesc * wireli;
132
wireli= _XkbGetTypedRdBufPtr(buf,1,xkbDeviceLedsWireDesc);
135
devli= XkbAddDeviceLedInfo(devi,wireli->ledClass,wireli->ledID);
138
devli->phys_indicators= wireli->physIndicators;
140
if (present&XkbXI_IndicatorStateMask)
141
devli->state= wireli->state;
143
if (present&XkbXI_IndicatorNamesMask) {
144
devli->names_present= wireli->namesPresent;
145
if (devli->names_present) {
146
for (i=0,bit=1;i<XkbNumIndicators;i++,bit<<=1) {
147
if (wireli->namesPresent&bit) {
148
if (!_XkbCopyFromReadBuffer(buf,(char *)&devli->names[i],4))
155
if (present&XkbXI_IndicatorMapsMask) {
156
devli->maps_present= wireli->mapsPresent;
157
if (devli->maps_present) {
158
XkbIndicatorMapPtr im;
159
xkbIndicatorMapWireDesc * wireim;
160
for (i=0,bit=1;i<XkbNumIndicators;i++,bit<<=1) {
161
if (wireli->mapsPresent&bit) {
162
wireim= _XkbGetTypedRdBufPtr(buf,1,xkbIndicatorMapWireDesc);
166
im->flags= wireim->flags;
167
im->which_groups= wireim->whichGroups;
168
im->groups= wireim->groups;
169
im->which_mods= wireim->whichMods;
170
im->mods.mask= wireim->mods;
171
im->mods.real_mods= wireim->realMods;
172
im->mods.vmods= wireim->virtualMods;
173
im->ctrls= wireim->ctrls;
182
#if NeedFunctionPrototypes
183
_XkbReadGetDeviceInfoReply( Display * dpy,
184
xkbGetDeviceInfoReply * rep,
185
XkbDeviceInfoPtr devi)
187
_XkbReadGetDeviceInfoReply(dpy,rep,devi)
189
xkbGetDeviceInfoReply * rep;
190
XkbDeviceInfoPtr devi;
193
XkbReadBufferRec buf;
197
if (!_XkbInitReadBuffer(dpy,&buf,(int)rep->length*4))
200
if ((rep->totalBtns>0)&&(rep->totalBtns!=devi->num_btns)) {
201
tmp= XkbResizeDeviceButtonActions(devi,rep->totalBtns);
205
if (rep->nBtnsWanted>0) {
206
act= &devi->btn_acts[rep->firstBtnWanted];
207
bzero((char *)act,(rep->nBtnsWanted*sizeof(XkbAction)));
209
if (devi->name!=NULL)
210
_XkbFree(devi->name);
211
if (!_XkbGetReadBufferCountedString(&buf,&devi->name))
213
if (rep->nBtnsRtrn>0) {
215
act= &devi->btn_acts[rep->firstBtnRtrn];
216
size= rep->nBtnsRtrn*SIZEOF(xkbActionWireDesc);
217
if (!_XkbCopyFromReadBuffer(&buf,(char *)act,size))
220
if (rep->nDeviceLedFBs>0) {
222
for (i=0;i<rep->nDeviceLedFBs;i++) {
223
if ((tmp= _XkbReadDeviceLedInfo(&buf,rep->present,devi))!=Success)
227
tmp= _XkbFreeReadBuffer(&buf);
229
fprintf(stderr,"GetDeviceInfo! Bad length (%d extra bytes)\n",tmp);
230
if (tmp || buf.error)
234
_XkbFreeReadBuffer(&buf);
239
#if NeedFunctionPrototypes
240
XkbGetDeviceInfo( Display * dpy,
246
XkbGetDeviceInfo(dpy,which,deviceSpec,class,id)
254
register xkbGetDeviceInfoReq * req;
255
xkbGetDeviceInfoReply rep;
257
XkbDeviceInfoPtr devi;
259
if ((dpy->flags & XlibDisplayNoXkb) ||
260
(!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
263
GetReq(kbGetDeviceInfo, req);
264
req->reqType = dpy->xkb_info->codes->major_opcode;
265
req->xkbReqType = X_kbGetDeviceInfo;
266
req->deviceSpec = deviceSpec;
268
req->allBtns= ((which&XkbXI_ButtonActionsMask)!=0);
269
req->firstBtn= req->nBtns= 0;
270
req->ledClass= class;
272
if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
277
devi= XkbAllocDeviceInfo(rep.deviceID,rep.totalBtns,rep.nDeviceLedFBs);
279
devi->supported= rep.supported;
280
devi->unsupported= rep.unsupported;
281
devi->type= rep.devType;
282
devi->has_own_state= rep.hasOwnState;
283
devi->dflt_kbd_fb = rep.dfltKbdFB;
284
devi->dflt_led_fb = rep.dfltLedFB;
285
status= _XkbReadGetDeviceInfoReply(dpy,&rep,devi);
286
if (status!=Success) {
287
XkbFreeDeviceInfo(devi,XkbXI_AllDeviceFeaturesMask,True);
297
#if NeedFunctionPrototypes
298
XkbGetDeviceInfoChanges( Display * dpy,
299
XkbDeviceInfoPtr devi,
300
XkbDeviceChangesPtr changes)
302
XkbGetDeviceInfoChanges(dpy,devi,changes)
304
XkbDeviceInfoPtr devi;
305
XkbDeviceChangesPtr changes;
308
register xkbGetDeviceInfoReq * req;
309
xkbGetDeviceInfoReply rep;
312
if ((dpy->flags & XlibDisplayNoXkb) ||
313
(!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
315
if ((changes->changed&XkbXI_AllDeviceFeaturesMask)==0)
317
changes->changed&= ~XkbXI_AllDeviceFeaturesMask;
320
while ((changes->changed)&&(status==Success)) {
321
GetReq(kbGetDeviceInfo, req);
322
req->reqType = dpy->xkb_info->codes->major_opcode;
323
req->xkbReqType = X_kbGetDeviceInfo;
324
req->deviceSpec = devi->device_spec;
325
req->wanted= changes->changed;
327
if (changes->changed&XkbXI_ButtonActionsMask) {
328
req->firstBtn= changes->first_btn;
329
req->nBtns= changes->num_btns;
330
changes->changed&= ~XkbXI_ButtonActionsMask;
332
else req->firstBtn= req->nBtns= 0;
333
if (changes->changed&XkbXI_IndicatorsMask) {
334
req->ledClass= changes->leds.led_class;
335
req->ledID= changes->leds.led_id;
336
if (changes->leds.next==NULL)
337
changes->changed&= ~XkbXI_IndicatorsMask;
339
XkbDeviceLedChangesPtr next;
340
next= changes->leds.next;
341
changes->leds= *next;
346
req->ledClass= XkbDfltXIClass;
347
req->ledID= XkbDfltXIId;
349
if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
353
devi->supported|= rep.supported;
354
devi->unsupported|= rep.unsupported;
355
devi->type= rep.devType;
356
status= _XkbReadGetDeviceInfoReply(dpy,&rep,devi);
364
#if NeedFunctionPrototypes
365
XkbGetDeviceButtonActions( Display * dpy,
366
XkbDeviceInfoPtr devi,
371
XkbGetDeviceButtonActions(dpy,devi,all,first,num)
373
XkbDeviceInfoPtr devi;
379
register xkbGetDeviceInfoReq * req;
380
xkbGetDeviceInfoReply rep;
383
if ((dpy->flags & XlibDisplayNoXkb) ||
384
(!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
389
GetReq(kbGetDeviceInfo, req);
390
req->reqType = dpy->xkb_info->codes->major_opcode;
391
req->xkbReqType = X_kbGetDeviceInfo;
392
req->deviceSpec = devi->device_spec;
393
req->wanted= XkbXI_ButtonActionsMask;
395
req->firstBtn= first;
397
req->ledClass= XkbDfltXIClass;
398
req->ledID= XkbDfltXIId;
399
if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
404
devi->type= rep.devType;
405
devi->supported= rep.supported;
406
devi->unsupported= rep.unsupported;
407
status= _XkbReadGetDeviceInfoReply(dpy,&rep,devi);
414
#if NeedFunctionPrototypes
415
XkbGetDeviceLedInfo( Display * dpy,
416
XkbDeviceInfoPtr devi,
417
unsigned int ledClass,
421
XkbGetDeviceLedInfo(dpy,devi,ledClass,ledId,which)
423
XkbDeviceInfoPtr devi;
424
unsigned int ledClass;
429
register xkbGetDeviceInfoReq * req;
430
xkbGetDeviceInfoReply rep;
433
if ((dpy->flags & XlibDisplayNoXkb) ||
434
(!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
436
if (((which&XkbXI_IndicatorsMask)==0)||(which&(~XkbXI_IndicatorsMask)))
441
GetReq(kbGetDeviceInfo, req);
442
req->reqType = dpy->xkb_info->codes->major_opcode;
443
req->xkbReqType = X_kbGetDeviceInfo;
444
req->deviceSpec = devi->device_spec;
447
req->firstBtn= req->nBtns= 0;
448
req->ledClass= ledClass;
450
if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
455
devi->type= rep.devType;
456
devi->supported= rep.supported;
457
devi->unsupported= rep.unsupported;
458
status= _XkbReadGetDeviceInfoReply(dpy,&rep,devi);
464
/***====================================================================***/
466
typedef struct _LedInfoStuff {
468
XkbDeviceLedInfoPtr devli;
471
typedef struct _SetLedStuff {
475
LedInfoStuff * dflt_kbd_fb;
476
LedInfoStuff * dflt_led_fb;
481
#if NeedFunctionPrototypes
482
_InitLedStuff(SetLedStuff *stuff,unsigned wanted,XkbDeviceInfoPtr devi)
484
_InitLedStuff(stuff,wanted,devi)
487
XkbDeviceInfoPtr devi;
491
register XkbDeviceLedInfoPtr devli;
493
bzero(stuff,sizeof(SetLedStuff));
494
stuff->wanted= wanted;
495
stuff->dflt_class= XkbXINone;
496
if ((devi->num_leds<1)||((wanted&XkbXI_IndicatorsMask)==0))
498
stuff->info= _XkbTypedCalloc(devi->num_leds,LedInfoStuff);
501
stuff->num_info= devi->num_leds;
502
for (devli=&devi->leds[0],i=0;i<devi->num_leds;i++,devli++) {
503
stuff->info[i].devli= devli;
504
if (devli->led_class==KbdFeedbackClass) {
505
stuff->dflt_class= KbdFeedbackClass;
506
if (stuff->dflt_kbd_fb==NULL)
507
stuff->dflt_kbd_fb= &stuff->info[i];
509
else if (devli->led_class==LedFeedbackClass) {
510
if (stuff->dflt_class==XkbXINone)
511
stuff->dflt_class= LedFeedbackClass;
512
if (stuff->dflt_led_fb==NULL)
513
stuff->dflt_led_fb= &stuff->info[i];
520
#if NeedFunctionPrototypes
521
_FreeLedStuff(SetLedStuff *stuff)
527
if ((stuff->num_info>0)&&(stuff->info!=NULL))
528
_XkbFree(stuff->info);
529
bzero(stuff,sizeof(SetLedStuff));
534
#if NeedFunctionPrototypes
535
_XkbSizeLedInfo(unsigned changed,XkbDeviceLedInfoPtr devli)
537
_XkbSizeLedInfo(changed,devli)
539
XkbDeviceLedInfoPtr devli;
543
register unsigned bit,namesNeeded,mapsNeeded;
545
size= SIZEOF(xkbDeviceLedsWireDesc);
546
namesNeeded= mapsNeeded= 0;
547
if (changed&XkbXI_IndicatorNamesMask)
548
namesNeeded= devli->names_present;
549
if (changed&XkbXI_IndicatorMapsMask)
550
mapsNeeded= devli->maps_present;
551
if ((namesNeeded)||(mapsNeeded)) {
552
for (i=0,bit=1;i<XkbNumIndicators;i++,bit<<=1) {
554
size+= 4; /* atoms are 4 bytes on the wire */
556
size+= SIZEOF(xkbIndicatorMapWireDesc);
563
#if NeedFunctionPrototypes
564
_SizeMatches( SetLedStuff * stuff,
565
XkbDeviceLedChangesPtr changes,
569
_SizeMatches(stuff,changes,sz_rtrn,nleds_rtrn)
571
XkbDeviceLedChangesPtr changes;
576
int i,nMatch,class,id;
577
LedInfoStuff * linfo;
581
class= changes->led_class;
583
if (class==XkbDfltXIClass)
584
class= stuff->dflt_class;
585
for (i=0,linfo=&stuff->info[0];i<stuff->num_info;i++,linfo++) {
586
XkbDeviceLedInfoPtr devli;
590
match= ((class==devli->led_class)||(class==XkbAllXIClasses));
591
if (devli->led_class==KbdFeedbackClass) dflt= stuff->dflt_kbd_fb;
592
else dflt= stuff->dflt_led_fb;
593
match = (match && (id == devli->led_id)) ||
594
(id == XkbAllXIIds) ||
595
((id == XkbDfltXIId) &&
599
*sz_rtrn+= _XkbSizeLedInfo(stuff->wanted,devli);
602
if ((class!=XkbAllXIClasses)&&(id!=XkbAllXIIds))
612
/***====================================================================***/
616
#if NeedFunctionPrototypes
617
_XkbSetDeviceInfoSize( XkbDeviceInfoPtr devi,
618
XkbDeviceChangesPtr changes,
623
_XkbSetDeviceInfoSize(devi,changes,stuff,sz_rtrn,num_leds_rtrn)
624
XkbDeviceInfoPtr devi;
625
XkbDeviceChangesPtr changes;
632
if ((changes->changed&XkbXI_ButtonActionsMask)&&(changes->num_btns>0)) {
633
if (!XkbXI_LegalDevBtn(devi,(changes->first_btn+changes->num_btns-1)))
635
*sz_rtrn+= changes->num_btns*SIZEOF(xkbActionWireDesc);
638
changes->changed&= ~XkbXI_ButtonActionsMask;
639
changes->first_btn= changes->num_btns= 0;
641
if ((changes->changed&XkbXI_IndicatorsMask)&&
642
XkbLegalXILedClass(changes->leds.led_class)) {
643
XkbDeviceLedChangesPtr leds;
645
for (leds=&changes->leds;leds!=NULL;leds= leds->next) {
646
if (!_SizeMatches(stuff,leds,sz_rtrn,num_leds_rtrn))
651
changes->changed&= ~XkbXI_IndicatorsMask;
658
#if NeedFunctionPrototypes
659
_XkbWriteLedInfo(char *wire,unsigned changed,XkbDeviceLedInfoPtr devli)
661
_XkbWriteLedInfo(wire,changed,devli)
664
XkbDeviceLedInfoPtr devli;
668
register unsigned bit,namesNeeded,mapsNeeded;
669
xkbDeviceLedsWireDesc * lwire;
671
namesNeeded= mapsNeeded= 0;
672
if (changed&XkbXI_IndicatorNamesMask)
673
namesNeeded= devli->names_present;
674
if (changed&XkbXI_IndicatorMapsMask)
675
mapsNeeded= devli->maps_present;
677
lwire= (xkbDeviceLedsWireDesc *)wire;
678
lwire->ledClass= devli->led_class;
679
lwire->ledID= devli->led_id;
680
lwire->namesPresent= namesNeeded;
681
lwire->mapsPresent= mapsNeeded;
682
lwire->physIndicators= devli->phys_indicators;
683
lwire->state= devli->state;
684
wire= (char *)&lwire[1];
687
awire= (CARD32 *)wire;
688
for (i=0,bit=1;i<XkbNumIndicators;i++,bit<<=1) {
689
if (namesNeeded&bit) {
690
*awire= (CARD32)devli->names[i];
697
xkbIndicatorMapWireDesc *mwire;
699
mwire= (xkbIndicatorMapWireDesc *)wire;
700
for (i=0,bit=1;i<XkbNumIndicators;i++,bit<<=1) {
701
if (mapsNeeded&bit) {
702
XkbIndicatorMapPtr map;
703
map= &devli->maps[i];
704
mwire->flags= map->flags;
705
mwire->whichGroups= map->which_groups;
706
mwire->groups= map->groups;
707
mwire->whichMods= map->which_mods;
708
mwire->mods= map->mods.mask;
709
mwire->realMods= map->mods.real_mods;
710
mwire->virtualMods= map->mods.vmods;
711
mwire->ctrls= map->ctrls;
722
#if NeedFunctionPrototypes
723
_XkbWriteSetDeviceInfo( char * wire,
724
XkbDeviceChangesPtr changes,
726
XkbDeviceInfoPtr devi)
728
_XkbWriteSetDeviceInfo(wire,changes,stuff,devi)
730
XkbDeviceChangesPtr changes;
732
XkbDeviceInfoPtr devi;
738
if (changes->changed&XkbXI_ButtonActionsMask) {
740
size= changes->num_btns*SIZEOF(xkbActionWireDesc);
741
memcpy(wire,(char *)&devi->btn_acts[changes->first_btn],size);
744
if (changes->changed&XkbXI_IndicatorsMask) {
746
register LedInfoStuff *linfo;
748
for (i=0,linfo=&stuff->info[0];i<stuff->num_info;i++,linfo++) {
750
register char *new_wire;
751
new_wire= _XkbWriteLedInfo(wire,stuff->wanted,linfo->devli);
762
#if NeedFunctionPrototypes
763
XkbSetDeviceInfo( Display * dpy,
765
XkbDeviceInfoPtr devi)
767
XkbSetDeviceInfo(dpy,which,devi)
770
XkbDeviceInfoPtr devi;
773
register xkbSetDeviceInfoReq *req;
777
XkbDeviceChangesRec changes;
780
if ((dpy->flags & XlibDisplayNoXkb) ||
781
(!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
783
if ((!devi) || (which&(~XkbXI_AllDeviceFeaturesMask)) ||
784
((which&XkbXI_ButtonActionsMask)&&(!XkbXI_DevHasBtnActs(devi)))||
785
((which&XkbXI_IndicatorsMask)&&(!XkbXI_DevHasLeds(devi))))
788
bzero((char *)&changes,sizeof(XkbDeviceChangesRec));
789
changes.changed= which;
790
changes.first_btn= 0;
791
changes.num_btns= devi->num_btns;
792
changes.leds.led_class= XkbAllXIClasses;
793
changes.leds.led_id= XkbAllXIIds;
794
changes.leds.defined= 0;
796
_InitLedStuff(&lstuff,changes.changed,devi);
797
if (_XkbSetDeviceInfoSize(devi,&changes,&lstuff,&size,&nLeds)!=Success)
800
xkbi = dpy->xkb_info;
801
GetReq(kbSetDeviceInfo, req);
802
req->length+= size/4;
803
req->reqType= xkbi->codes->major_opcode;
804
req->xkbReqType= X_kbSetDeviceInfo;
805
req->deviceSpec= devi->device_spec;
806
req->firstBtn= changes.first_btn;
807
req->nBtns= changes.num_btns;
808
req->change= changes.changed;
809
req->nDeviceLedFBs= nLeds;
812
BufAlloc(char *,wire,size);
814
(_XkbWriteSetDeviceInfo(wire,&changes,&lstuff,devi)==size);
818
_FreeLedStuff(&lstuff);
819
/* 12/11/95 (ef) -- XXX!! should clear changes here */
824
#if NeedFunctionPrototypes
825
XkbChangeDeviceInfo( Display * dpy,
826
XkbDeviceInfoPtr devi,
827
XkbDeviceChangesPtr changes)
829
XkbChangeDeviceInfo(dpy,devi,changes)
831
XkbDeviceInfoPtr devi;
832
XkbDeviceChangesPtr changes;
835
register xkbSetDeviceInfoReq *req;
841
if ((dpy->flags & XlibDisplayNoXkb) ||
842
(!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
844
if ((!devi) || (changes->changed&(~XkbXI_AllDeviceFeaturesMask)) ||
845
((changes->changed&XkbXI_ButtonActionsMask)&&
846
(!XkbXI_DevHasBtnActs(devi)))||
847
((changes->changed&XkbXI_IndicatorsMask)&&(!XkbXI_DevHasLeds(devi))))
851
_InitLedStuff(&lstuff,changes->changed,devi);
852
if (_XkbSetDeviceInfoSize(devi,changes,&lstuff,&size,&nLeds)!=Success)
855
xkbi = dpy->xkb_info;
856
GetReq(kbSetDeviceInfo, req);
857
req->length+= size/4;
858
req->reqType= xkbi->codes->major_opcode;
859
req->xkbReqType= X_kbSetDeviceInfo;
860
req->deviceSpec= devi->device_spec;
861
req->firstBtn= changes->first_btn;
862
req->nBtns= changes->num_btns;
863
req->change= changes->changed;
864
req->nDeviceLedFBs= nLeds;
867
BufAlloc(char *,wire,size);
869
(_XkbWriteSetDeviceInfo(wire,changes,&lstuff,devi)==size);
873
_FreeLedStuff(&lstuff);
874
/* 12/11/95 (ef) -- XXX!! should clear changes here */
879
#if NeedFunctionPrototypes
880
XkbSetDeviceLedInfo( Display * dpy,
881
XkbDeviceInfoPtr devi,
886
XkbSetDeviceLedInfo(dpy,devi,ledClass,ledID,which)
888
XkbDeviceInfoPtr devi;
898
#if NeedFunctionPrototypes
899
XkbSetDeviceButtonActions( Display * dpy,
900
XkbDeviceInfoPtr devi,
904
XkbSetDeviceButtonActions(dpy,devi,first,nBtns)
906
XkbDeviceInfoPtr devi;
911
register xkbSetDeviceInfoReq *req;
915
XkbDeviceChangesRec changes;
918
if ((dpy->flags & XlibDisplayNoXkb) ||
919
(!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
921
if ((!devi)||(!XkbXI_DevHasBtnActs(devi))||(first+nBtns>devi->num_btns))
926
bzero((char *)&changes,sizeof(XkbDeviceChangesRec));
927
changes.changed= XkbXI_ButtonActionsMask;
928
changes.first_btn= first;
929
changes.num_btns= nBtns;
930
changes.leds.led_class= XkbXINone;
931
changes.leds.led_id= XkbXINone;
932
changes.leds.defined= 0;
934
if (_XkbSetDeviceInfoSize(devi,&changes,NULL,&size,&nLeds)!=Success)
937
xkbi = dpy->xkb_info;
938
GetReq(kbSetDeviceInfo, req);
939
req->length+= size/4;
940
req->reqType= xkbi->codes->major_opcode;
941
req->xkbReqType= X_kbSetDeviceInfo;
942
req->deviceSpec= devi->device_spec;
943
req->firstBtn= changes.first_btn;
944
req->nBtns= changes.num_btns;
945
req->change= changes.changed;
946
req->nDeviceLedFBs= nLeds;
949
BufAlloc(char *,wire,size);
951
(_XkbWriteSetDeviceInfo(wire,&changes,&lstuff,devi)==size);