1 /* $XFree86: xc/programs/xsetmode/xsetmode.c,v 3.5tsi Exp $ */
4 * Copyright 1995 by Frederic Lepied, France. <fred@sugix.frmug.fr.net>
6 * Permission to use, copy, modify, distribute, and sell this software and its
7 * documentation for any purpose is hereby granted without fee, provided that
8 * the above copyright notice appear in all copies and that both that
9 * copyright notice and this permission notice appear in supporting
10 * documentation, and that the name of Frederic Lepied not be used in
11 * advertising or publicity pertaining to distribution of the software without
12 * specific, written prior permission. Frederic Lepied makes no
13 * representations about the suitability of this software for any purpose. It
14 * is provided "as is" without express or implied warranty.
16 * FREDERIC LEPIED DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
18 * EVENT SHALL FREDERIC LEPIED BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
20 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
21 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
22 * PERFORMANCE OF THIS SOFTWARE.
30 #include <X11/Xproto.h>
31 #include <X11/extensions/XInput.h>
35 static int StrCaseCmp(char *s1, char *s2)
45 c1 = (isupper(*s1) ? tolower(*s1) : *s1);
46 c2 = (isupper(*s2) ? tolower(*s2) : *s2);
52 c1 = (isupper(*s1) ? tolower(*s1) : *s1);
53 c2 = (isupper(*s2) ? tolower(*s2) : *s2);
59 main(int argc, char * argv[])
61 int loop, num_extensions, num_devices;
68 fprintf(stderr, "usage : %s <device name> (ABSOLUTE|RELATIVE)\n", argv[0]);
72 if (strcmp(argv[1], "-l") == 0) {
76 dpy = XOpenDisplay(NULL);
79 printf("unable to connect to X Server try to set the DISPLAY variable\n");
84 printf("connected to %s\n", XDisplayString(dpy));
87 extensions = XListExtensions(dpy, &num_extensions);
88 for (loop = 0; loop < num_extensions &&
89 (strcmp(extensions[loop], "XInputExtension") != 0); loop++);
90 XFreeExtensionList(extensions);
91 if (loop != num_extensions)
93 devices = XListInputDevices(dpy, &num_devices);
94 for(loop=0; loop<num_devices; loop++)
96 if (devices[loop].name &&
97 (StrCaseCmp(devices[loop].name, argv[1]) == 0))
98 if (devices[loop].use == IsXExtensionDevice)
103 fprintf(stderr, "opening device %s\n",
104 devices[loop].name ? devices[loop].name : "<noname>");
106 device = XOpenDevice(dpy, devices[loop].id);
109 XSetDeviceMode(dpy, device, (strcmp("ABSOLUTE", argv[2]) == 0) ? Absolute
115 fprintf(stderr, "error opening device\n");
120 XFreeDeviceList(devices);
124 fprintf(stderr, "No XInput extension available\n");
132 fprintf(stderr, "Extended device %s not found\n", argv[1]);