1b1297603Smrg/*
2b1297603Smrg * Copyright 1996 by Frederic Lepied, France. <Frederic.Lepied@sugix.frmug.org>
3b1297603Smrg *
4b1297603Smrg * Permission to use, copy, modify, distribute, and sell this software and its
5b1297603Smrg * documentation for any purpose is  hereby granted without fee, provided that
6b1297603Smrg * the  above copyright   notice appear  in   all  copies and  that both  that
7b1297603Smrg * copyright  notice   and   this  permission   notice  appear  in  supporting
85b944e2aSmrg * documentation, and that   the  name of  the authors  not  be  used  in
9b1297603Smrg * advertising or publicity pertaining to distribution of the software without
105b944e2aSmrg * specific,  written      prior  permission.     The authors  make  no
11b1297603Smrg * representations about the suitability of this software for any purpose.  It
12b1297603Smrg * is provided "as is" without express or implied warranty.
13b1297603Smrg *
145b944e2aSmrg * THE AUTHORS DISCLAIM ALL   WARRANTIES WITH REGARD  TO  THIS SOFTWARE,
15b1297603Smrg * INCLUDING ALL IMPLIED   WARRANTIES OF MERCHANTABILITY  AND   FITNESS, IN NO
165b944e2aSmrg * EVENT  SHALL THE AUTHORS  BE   LIABLE   FOR ANY  SPECIAL, INDIRECT   OR
17b1297603Smrg * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18b1297603Smrg * DATA  OR PROFITS, WHETHER  IN  AN ACTION OF  CONTRACT,  NEGLIGENCE OR OTHER
19b1297603Smrg * TORTIOUS  ACTION, ARISING    OUT OF OR   IN  CONNECTION  WITH THE USE    OR
20b1297603Smrg * PERFORMANCE OF THIS SOFTWARE.
21b1297603Smrg *
22b1297603Smrg */
23b1297603Smrg
24b1297603Smrg#include "xinput.h"
25b1297603Smrg
26b1297603Smrgint
27b1297603Smrgset_integer_feedback(Display	*display,
28b1297603Smrg		     int	argc,
29b1297603Smrg		     char	*argv[],
30b1297603Smrg		     char	*name,
31b1297603Smrg		     char	*desc)
32b1297603Smrg{
33b1297603Smrg    XDeviceInfo			*info;
34b1297603Smrg    XDevice			*device;
35b1297603Smrg    XIntegerFeedbackControl	control;
36b1297603Smrg
37b1297603Smrg    if (argc != 3) {
38b1297603Smrg	fprintf(stderr, "usage: xinput %s %s\n", name, desc);
39b1297603Smrg	return EXIT_FAILURE;
40b1297603Smrg    }
41b1297603Smrg
42b1297603Smrg    control.class = IntegerFeedbackClass;
43b1297603Smrg    control.length = sizeof(XIntegerFeedbackControl);
44b1297603Smrg    control.id = atoi(argv[1]);
45b1297603Smrg    control.int_to_display = atoi(argv[2]);
46b1297603Smrg
47b1297603Smrg    info = find_device_info(display, argv[0], True);
48b1297603Smrg
49b1297603Smrg    if (!info) {
500309d3b3Smrg	fprintf(stderr, "unable to find device '%s'\n", argv[0]);
51b1297603Smrg	return EXIT_FAILURE;
52b1297603Smrg    }
53b1297603Smrg
54b1297603Smrg    device = XOpenDevice(display, info->id);
55b1297603Smrg
56b1297603Smrg    if (device) {
57b1297603Smrg	XChangeFeedbackControl(display, device, DvInteger, (XFeedbackControl *) &control);
58b1297603Smrg
59b1297603Smrg	return EXIT_SUCCESS;
60b1297603Smrg    } else {
61b1297603Smrg	fprintf(stderr, "Unable to open device\n");
62b1297603Smrg	return EXIT_FAILURE;
63b1297603Smrg    }
64b1297603Smrg}
65b1297603Smrg
66b1297603Smrg/* end of setint.c */
67