2
* Copyright © 2008 Red Hat, Inc.
4
* Permission to use, copy, modify, distribute, and sell this software
5
* and its documentation for any purpose is hereby granted without
6
* fee, provided that the above copyright notice appear in all copies
7
* and that both that copyright notice and this permission notice
8
* appear in supporting documentation, and that the name of Red Hat
9
* not be used in advertising or publicity pertaining to distribution
10
* of the software without specific, written prior permission. Red
11
* Hat makes no representations about the suitability of this software
12
* for any purpose. It is provided "as is" without express or implied
15
* THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
17
* NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
19
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
20
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
21
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
24
* Peter Hutterer (peter.hutterer@redhat.com)
27
/* Creates a device that has REL_X REL_Y BTN_0 BTN_1 BTN_2
29
* Moves the device around in a 10px square and clicks after each completed
35
#include <linux/input.h>
36
#include <linux/uinput.h>
40
int btn0_setup(struct uinput_user_dev *dev, int fd)
42
if (ioctl(fd, UI_SET_EVBIT, EV_KEY) == -1) goto error;
43
if (ioctl(fd, UI_SET_EVBIT, EV_REL) == -1) goto error;
44
if (ioctl(fd, UI_SET_EVBIT, EV_SYN) == -1) goto error;
47
if (ioctl(fd, UI_SET_KEYBIT, BTN_0) == -1) goto error;
48
if (ioctl(fd, UI_SET_KEYBIT, BTN_1) == -1) goto error;
49
if (ioctl(fd, UI_SET_KEYBIT, BTN_2) == -1) goto error;
52
if (ioctl(fd, UI_SET_RELBIT, REL_X) == -1) goto error;
53
if (ioctl(fd, UI_SET_RELBIT, REL_Y) == -1) goto error;
57
perror("ioctl failed.");
77
struct test_device btn0_dev = {
78
.name = "BTN_0 test device",
84
struct test_device* get_device()