]>
diplodocus.org Git - xorg-xinput/blob - src/xinput.c
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.
29 #if NeedFunctionPrototypes
30 Display
* display
, int argc
, char *argv
[],
31 char *prog_name
, char *prog_desc
42 static entry drivers
[] =
49 "<device name> <threshold> <num> <denom>",
52 {"set-integer-feedback",
53 "<device name> <feedback id> <value>",
61 "<device name> <map button 1> [<map button 2> [...]]",
65 "<device name> [<x index> <y index>]",
69 "<device name> ABSOLUTE|RELATIVE",
73 "[--loop || --short || <device name>...]",
81 "[-proximity] <device name>",
90 "<id> [sendCore (dflt:1)] [enable (dflt:1)]",
94 "<id> [returnMode (dflt:Floating)] [returnPointer] [returnKeyboard]",
111 "<device> [<device> ...]",
115 "<device> <property> <format (8, 16, 32)> <val> [<val> ...]",
119 "<device> <property> <val> [<val> ...]",
123 "<device> <property> <val> [<val> ...]",
131 "<device> <property>",
139 is_xinput_present(Display
*display
)
141 XExtensionVersion
*version
;
145 version
= XQueryInputVersion(display
, XI_2_Major
, XI_2_Minor
);
147 version
= XGetExtensionVersion(display
, INAME
);
150 if (version
&& (version
!= (XExtensionVersion
*) NoSuchExtension
)) {
151 present
= version
->present
;
160 find_device_info(Display
*display
,
164 XDeviceInfo
*devices
;
165 XDeviceInfo
*found
= NULL
;
168 int len
= strlen(name
);
172 for(loop
=0; loop
<len
; loop
++) {
173 if (!isdigit(name
[loop
])) {
183 devices
= XListInputDevices(display
, &num_devices
);
185 for(loop
=0; loop
<num_devices
; loop
++) {
186 if ((!only_extended
|| (devices
[loop
].use
>= IsXExtensionDevice
)) &&
187 ((!is_id
&& strcmp(devices
[loop
].name
, name
) == 0) ||
188 (is_id
&& devices
[loop
].id
== id
))) {
191 "Warning: There are multiple devices named \"%s\".\n"
192 "To ensure the correct one is selected, please use "
193 "the device ID instead.\n\n", name
);
195 found
= &devices
[loop
];
205 entry
*pdriver
= drivers
;
207 fprintf(stderr
, "usage :\n");
209 while(pdriver
->func_name
) {
210 fprintf(stderr
, "\txinput %s %s\n", pdriver
->func_name
,
217 main(int argc
, char * argv
[])
220 entry
*driver
= drivers
;
228 display
= XOpenDisplay(NULL
);
230 if (display
== NULL
) {
231 fprintf(stderr
, "Unable to connect to X server\n");
236 while((*func
) == '-') func
++;
238 if (!is_xinput_present(display
)) {
239 fprintf(stderr
, "%s extension not available\n", INAME
);
243 while(driver
->func_name
) {
244 if (strcmp(driver
->func_name
, func
) == 0) {
245 int r
= (*driver
->func
)(display
, argc
-2, argv
+2,
246 driver
->func_name
, driver
->arg_desc
);
247 XSync(display
, False
);
258 /* end of xinput.c */