2 * Copyright 1996 by Frederic Lepied, France. <Frederic.Lepied@sugix.frmug.org>
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name of the authors not be used in
9 * advertising or publicity pertaining to distribution of the software without
10 * specific, written prior permission. The authors make no
11 * representations about the suitability of this software for any purpose. It
12 * is provided "as is" without express or implied warranty.
14 * THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20 * PERFORMANCE OF THIS SOFTWARE.
27 set_ptr_feedback(Display
*display
,
35 XPtrFeedbackControl feedback
;
36 XFeedbackState
*state
;
42 fprintf(stderr
, "usage: xinput %s %s\n", name
, desc
);
46 info
= find_device_info(display
, argv
[0], True
);
49 fprintf(stderr
, "unable to find device %s\n", argv
[0]);
53 device
= XOpenDevice(display
, info
->id
);
56 fprintf(stderr
, "unable to open device %s\n", argv
[0]);
60 /* We will match the first Ptr Feedback class. Can there be more? */
62 state
= XGetFeedbackControl(display
, device
, &num_feedbacks
);
63 for(loop
=0; loop
<num_feedbacks
; loop
++) {
64 if (state
->class == PtrFeedbackClass
) {
67 state
= (XFeedbackState
*) ((char*) state
+ state
->length
);
71 fprintf(stderr
, "unable to find PtrFeedbackClass for %s\n", argv
[0]);
75 feedback
.class = PtrFeedbackClass
;
76 feedback
.length
= sizeof(XPtrFeedbackControl
);
78 feedback
.threshold
= atoi(argv
[1]);
79 feedback
.accelNum
= atoi(argv
[2]);
80 feedback
.accelDenom
= atoi(argv
[3]);
82 XChangeFeedbackControl(display
, device
, DvAccelNum
|DvAccelDenom
|DvThreshold
,
83 (XFeedbackControl
*) &feedback
);
89 get_feedbacks(Display
*display
,
97 XFeedbackState
*state
;
100 XPtrFeedbackState
*p
;
101 XKbdFeedbackState
*k
;
102 XBellFeedbackState
*b
;
103 XLedFeedbackState
*l
;
104 XIntegerFeedbackState
*i
;
105 XStringFeedbackState
*s
;
108 fprintf(stderr
, "usage: xinput %s %s\n", name
, desc
);
112 info
= find_device_info(display
, argv
[0], True
);
115 fprintf(stderr
, "unable to find device %s\n", argv
[0]);
119 device
= XOpenDevice(display
, info
->id
);
122 fprintf(stderr
, "unable to open device %s\n", argv
[0]);
126 state
= XGetFeedbackControl(display
, device
, &num_feedbacks
);
128 printf("%d feedback class%s\n", num_feedbacks
,
129 (num_feedbacks
> 1) ? "es" : "");
131 for(loop
=0; loop
<num_feedbacks
; loop
++) {
132 switch (state
->class) {
133 case KbdFeedbackClass
:
134 k
= (XKbdFeedbackState
*) state
;
135 printf("KbdFeedbackClass id=%ld\n", state
->id
);
136 printf("\tclick is %d\n", k
->click
);
137 printf("\tpercent is %d\n", k
->percent
);
138 printf("\tpitch is %d\n", k
->pitch
);
139 printf("\tduration is %d\n", k
->duration
);
140 printf("\tled_mask is %d\n", k
->led_mask
);
141 printf("\tglobal_auto_repeat is %d\n", k
->global_auto_repeat
);
144 case PtrFeedbackClass
:
145 p
= (XPtrFeedbackState
*) state
;
146 printf("PtrFeedbackClass id=%ld\n", state
->id
);
147 printf("\taccelNum is %d\n", p
->accelNum
);
148 printf("\taccelDenom is %d\n", p
->accelDenom
);
149 printf("\tthreshold is %d\n", p
->threshold
);
152 case StringFeedbackClass
:
153 s
= (XStringFeedbackState
*) state
;
154 printf("XStringFeedbackControl id=%ld\n", state
->id
);
155 printf("\tmax_symbols is %d\n", s
->max_symbols
);
156 printf("\tnum_syms_supported is %d\n", s
->num_syms_supported
);
159 case IntegerFeedbackClass
:
160 i
= (XIntegerFeedbackState
*) state
;
161 printf("XIntegerFeedbackControl id=%ld\n", state
->id
);
162 printf("\tresolution is %d\n", i
->resolution
);
163 printf("\tminVal is %d\n", i
->minVal
);
164 printf("\tmaxVal is %d\n", i
->maxVal
);
167 case LedFeedbackClass
:
168 l
= (XLedFeedbackState
*) state
;
169 printf("XLedFeedbackState id=%ld\n", state
->id
);
170 printf("\tled_values is %d\n", l
->led_values
);
173 case BellFeedbackClass
:
174 b
= (XBellFeedbackState
*) state
;
175 printf("XBellFeedbackControl id=%ld\n", state
->id
);
176 printf("\tpercent is %d\n", b
->percent
);
177 printf("\tpitch is %d\n", b
->pitch
);
178 printf("\tduration is %d\n", b
->duration
);
181 state
= (XFeedbackState
*) ((char*) state
+ state
->length
);
186 /* end of ptrfdbk.c */