xref: /freebsd/sys/dev/evdev/uinput.h (revision 95ee2897)
1 /*-
2  * Copyright (c) 2016 Oleksandr Tymoshenko <gonzo@FreeBSD.org>
3  * Copyright (c) 2015-2016 Vladimir Kondratyev <wulf@FreeBSD.org>
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25  * SUCH DAMAGE.
26  */
27 
28 #ifndef _EVDEV_UINPUT_H_
29 #define	_EVDEV_UINPUT_H_
30 
31 #include <sys/types.h>
32 #include <dev/evdev/input.h>
33 
34 #define UINPUT_VERSION		5
35 #define	UINPUT_MAX_NAME_SIZE	80
36 
37 struct uinput_ff_upload {
38 	uint32_t		request_id;
39 	int32_t			retval;
40 	struct ff_effect	effect;
41 	struct ff_effect	old;
42 };
43 
44 struct uinput_ff_erase {
45 	uint32_t		request_id;
46 	int32_t			retval;
47 	uint32_t		effect_id;
48 };
49 
50 /* ioctl */
51 #define UINPUT_IOCTL_BASE	'U'
52 
53 #define UI_DEV_CREATE		_IO(UINPUT_IOCTL_BASE, 1)
54 #define UI_DEV_DESTROY		_IO(UINPUT_IOCTL_BASE, 2)
55 
56 struct uinput_setup {
57 	struct input_id	id;
58 	char		name[UINPUT_MAX_NAME_SIZE];
59 	uint32_t	ff_effects_max;
60 };
61 
62 #define UI_DEV_SETUP _IOW(UINPUT_IOCTL_BASE, 3, struct uinput_setup)
63 
64 struct uinput_abs_setup {
65 	uint16_t		code; /* axis code */
66 	struct input_absinfo	absinfo;
67 };
68 
69 #define UI_ABS_SETUP		_IOW(UINPUT_IOCTL_BASE, 4, struct uinput_abs_setup)
70 
71 #define UI_GET_SYSNAME(len)	_IOC(IOC_OUT, UINPUT_IOCTL_BASE, 44, len)
72 #define UI_GET_VERSION		_IOR(UINPUT_IOCTL_BASE, 45, unsigned int)
73 
74 #define UI_SET_EVBIT		_IOWINT(UINPUT_IOCTL_BASE, 100)
75 #define UI_SET_KEYBIT		_IOWINT(UINPUT_IOCTL_BASE, 101)
76 #define UI_SET_RELBIT		_IOWINT(UINPUT_IOCTL_BASE, 102)
77 #define UI_SET_ABSBIT		_IOWINT(UINPUT_IOCTL_BASE, 103)
78 #define UI_SET_MSCBIT		_IOWINT(UINPUT_IOCTL_BASE, 104)
79 #define UI_SET_LEDBIT		_IOWINT(UINPUT_IOCTL_BASE, 105)
80 #define UI_SET_SNDBIT		_IOWINT(UINPUT_IOCTL_BASE, 106)
81 #define UI_SET_FFBIT		_IOWINT(UINPUT_IOCTL_BASE, 107)
82 #define UI_SET_PHYS		_IO(UINPUT_IOCTL_BASE, 108)
83 #define UI_SET_SWBIT		_IOWINT(UINPUT_IOCTL_BASE, 109)
84 #define UI_SET_PROPBIT		_IOWINT(UINPUT_IOCTL_BASE, 110)
85 
86 #define UI_BEGIN_FF_UPLOAD	_IOWR(UINPUT_IOCTL_BASE, 200, struct uinput_ff_upload)
87 #define UI_END_FF_UPLOAD	_IOW(UINPUT_IOCTL_BASE, 201, struct uinput_ff_upload)
88 #define UI_BEGIN_FF_ERASE	_IOWR(UINPUT_IOCTL_BASE, 202, struct uinput_ff_erase)
89 #define UI_END_FF_ERASE		_IOW(UINPUT_IOCTL_BASE, 203, struct uinput_ff_erase)
90 
91 /*
92  * FreeBSD specific. Set unique identifier of input device.
93  * Name and magic are chosen to reduce chances of clashing
94  * with possible future Linux extensions.
95  */
96 #define UI_SET_BSDUNIQ		_IO(UINPUT_IOCTL_BASE, 109)
97 
98 #define EV_UINPUT		0x0101
99 #define UI_FF_UPLOAD		1
100 #define UI_FF_ERASE		2
101 
102 struct uinput_user_dev {
103 	char		name[UINPUT_MAX_NAME_SIZE];
104 	struct input_id	id;
105 	uint32_t	ff_effects_max;
106 	int32_t		absmax[ABS_CNT];
107 	int32_t		absmin[ABS_CNT];
108 	int32_t		absfuzz[ABS_CNT];
109 	int32_t		absflat[ABS_CNT];
110 };
111 
112 #endif /* _EVDEV_UINPUT_H_ */
113