]>
diplodocus.org Git - xorg-xinput/blob - src/buttonmap.c
1875ec138a2651cc75119741b070dd0f63376192
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 Frederic Lepied not be used in
9 * advertising or publicity pertaining to distribution of the software without
10 * specific, written prior permission. Frederic Lepied makes no
11 * representations about the suitability of this software for any purpose. It
12 * is provided "as is" without express or implied warranty.
14 * FREDERIC LEPIED DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL FREDERIC LEPIED 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.
26 static const char rcs_id
[] = "$Id: buttonmap.c,v 1.1.1.2 1997/06/09 16:00:47 fred Exp $";
29 set_button_map(Display
*display
,
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 ip
= (XAnyClassPtr
) info
->inputclassinfo
;
56 /* try to find the number of buttons */
57 for(i
=0; i
<info
->num_classes
; i
++) {
58 if (ip
->class == ButtonClass
) {
59 nbuttons
= ((XButtonInfoPtr
)ip
)->num_buttons
;
62 ip
= (XAnyClassPtr
) ((char *) ip
+ ip
->length
);
65 fprintf(stderr
, "device has no buttons\n");
69 device
= XOpenDevice(display
, info
->id
);
75 map
= (unsigned char *) malloc(sizeof(unsigned char) * nbuttons
);
77 XGetDeviceButtonMapping(display
, device
, map
, nbuttons
);
79 min
= (argc
> nbuttons
+ 1) ? nbuttons
+ 1 : argc
;
81 for(idx
=1; idx
< min
; idx
++) {
82 map
[idx
- 1] = atoi(argv
[idx
]);
84 XSetDeviceButtonMapping(display
, device
, map
, nbuttons
);
85 XCloseDevice(display
, device
);
88 fprintf(stderr
, "Unable to open device\n");