![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ 0002 /* 0003 * User level driver support for input subsystem 0004 * 0005 * Heavily based on evdev.c by Vojtech Pavlik 0006 * 0007 * This program is free software; you can redistribute it and/or modify 0008 * it under the terms of the GNU General Public License as published by 0009 * the Free Software Foundation; either version 2 of the License, or 0010 * (at your option) any later version. 0011 * 0012 * This program is distributed in the hope that it will be useful, 0013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0015 * GNU General Public License for more details. 0016 * 0017 * You should have received a copy of the GNU General Public License 0018 * along with this program; if not, write to the Free Software 0019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 0020 * 0021 * Author: Aristeu Sergio Rozanski Filho <aris@cathedrallabs.org> 0022 * 0023 * Changes/Revisions: 0024 * 0.5 08/13/2015 (David Herrmann <dh.herrmann@gmail.com> & 0025 * Benjamin Tissoires <benjamin.tissoires@redhat.com>) 0026 * - add UI_DEV_SETUP ioctl 0027 * - add UI_ABS_SETUP ioctl 0028 * - add UI_GET_VERSION ioctl 0029 * 0.4 01/09/2014 (Benjamin Tissoires <benjamin.tissoires@redhat.com>) 0030 * - add UI_GET_SYSNAME ioctl 0031 * 0.3 24/05/2006 (Anssi Hannula <anssi.hannulagmail.com>) 0032 * - update ff support for the changes in kernel interface 0033 * - add UINPUT_VERSION 0034 * 0.2 16/10/2004 (Micah Dowty <micah@navi.cx>) 0035 * - added force feedback support 0036 * - added UI_SET_PHYS 0037 * 0.1 20/06/2002 0038 * - first public version 0039 */ 0040 #ifndef _UAPI__UINPUT_H_ 0041 #define _UAPI__UINPUT_H_ 0042 0043 #include <linux/types.h> 0044 #include <linux/input.h> 0045 0046 #define UINPUT_VERSION 5 0047 #define UINPUT_MAX_NAME_SIZE 80 0048 0049 struct uinput_ff_upload { 0050 __u32 request_id; 0051 __s32 retval; 0052 struct ff_effect effect; 0053 struct ff_effect old; 0054 }; 0055 0056 struct uinput_ff_erase { 0057 __u32 request_id; 0058 __s32 retval; 0059 __u32 effect_id; 0060 }; 0061 0062 /* ioctl */ 0063 #define UINPUT_IOCTL_BASE 'U' 0064 #define UI_DEV_CREATE _IO(UINPUT_IOCTL_BASE, 1) 0065 #define UI_DEV_DESTROY _IO(UINPUT_IOCTL_BASE, 2) 0066 0067 struct uinput_setup { 0068 struct input_id id; 0069 char name[UINPUT_MAX_NAME_SIZE]; 0070 __u32 ff_effects_max; 0071 }; 0072 0073 /** 0074 * UI_DEV_SETUP - Set device parameters for setup 0075 * 0076 * This ioctl sets parameters for the input device to be created. It 0077 * supersedes the old "struct uinput_user_dev" method, which wrote this data 0078 * via write(). To actually set the absolute axes UI_ABS_SETUP should be 0079 * used. 0080 * 0081 * The ioctl takes a "struct uinput_setup" object as argument. The fields of 0082 * this object are as follows: 0083 * id: See the description of "struct input_id". This field is 0084 * copied unchanged into the new device. 0085 * name: This is used unchanged as name for the new device. 0086 * ff_effects_max: This limits the maximum numbers of force-feedback effects. 0087 * See below for a description of FF with uinput. 0088 * 0089 * This ioctl can be called multiple times and will overwrite previous values. 0090 * If this ioctl fails with -EINVAL, it is recommended to use the old 0091 * "uinput_user_dev" method via write() as a fallback, in case you run on an 0092 * old kernel that does not support this ioctl. 0093 * 0094 * This ioctl may fail with -EINVAL if it is not supported or if you passed 0095 * incorrect values, -ENOMEM if the kernel runs out of memory or -EFAULT if the 0096 * passed uinput_setup object cannot be read/written. 0097 * If this call fails, partial data may have already been applied to the 0098 * internal device. 0099 */ 0100 #define UI_DEV_SETUP _IOW(UINPUT_IOCTL_BASE, 3, struct uinput_setup) 0101 0102 struct uinput_abs_setup { 0103 __u16 code; /* axis code */ 0104 /* __u16 filler; */ 0105 struct input_absinfo absinfo; 0106 }; 0107 0108 /** 0109 * UI_ABS_SETUP - Set absolute axis information for the device to setup 0110 * 0111 * This ioctl sets one absolute axis information for the input device to be 0112 * created. It supersedes the old "struct uinput_user_dev" method, which wrote 0113 * part of this data and the content of UI_DEV_SETUP via write(). 0114 * 0115 * The ioctl takes a "struct uinput_abs_setup" object as argument. The fields 0116 * of this object are as follows: 0117 * code: The corresponding input code associated with this axis 0118 * (ABS_X, ABS_Y, etc...) 0119 * absinfo: See "struct input_absinfo" for a description of this field. 0120 * This field is copied unchanged into the kernel for the 0121 * specified axis. If the axis is not enabled via 0122 * UI_SET_ABSBIT, this ioctl will enable it. 0123 * 0124 * This ioctl can be called multiple times and will overwrite previous values. 0125 * If this ioctl fails with -EINVAL, it is recommended to use the old 0126 * "uinput_user_dev" method via write() as a fallback, in case you run on an 0127 * old kernel that does not support this ioctl. 0128 * 0129 * This ioctl may fail with -EINVAL if it is not supported or if you passed 0130 * incorrect values, -ENOMEM if the kernel runs out of memory or -EFAULT if the 0131 * passed uinput_setup object cannot be read/written. 0132 * If this call fails, partial data may have already been applied to the 0133 * internal device. 0134 */ 0135 #define UI_ABS_SETUP _IOW(UINPUT_IOCTL_BASE, 4, struct uinput_abs_setup) 0136 0137 #define UI_SET_EVBIT _IOW(UINPUT_IOCTL_BASE, 100, int) 0138 #define UI_SET_KEYBIT _IOW(UINPUT_IOCTL_BASE, 101, int) 0139 #define UI_SET_RELBIT _IOW(UINPUT_IOCTL_BASE, 102, int) 0140 #define UI_SET_ABSBIT _IOW(UINPUT_IOCTL_BASE, 103, int) 0141 #define UI_SET_MSCBIT _IOW(UINPUT_IOCTL_BASE, 104, int) 0142 #define UI_SET_LEDBIT _IOW(UINPUT_IOCTL_BASE, 105, int) 0143 #define UI_SET_SNDBIT _IOW(UINPUT_IOCTL_BASE, 106, int) 0144 #define UI_SET_FFBIT _IOW(UINPUT_IOCTL_BASE, 107, int) 0145 #define UI_SET_PHYS _IOW(UINPUT_IOCTL_BASE, 108, char*) 0146 #define UI_SET_SWBIT _IOW(UINPUT_IOCTL_BASE, 109, int) 0147 #define UI_SET_PROPBIT _IOW(UINPUT_IOCTL_BASE, 110, int) 0148 0149 #define UI_BEGIN_FF_UPLOAD _IOWR(UINPUT_IOCTL_BASE, 200, struct uinput_ff_upload) 0150 #define UI_END_FF_UPLOAD _IOW(UINPUT_IOCTL_BASE, 201, struct uinput_ff_upload) 0151 #define UI_BEGIN_FF_ERASE _IOWR(UINPUT_IOCTL_BASE, 202, struct uinput_ff_erase) 0152 #define UI_END_FF_ERASE _IOW(UINPUT_IOCTL_BASE, 203, struct uinput_ff_erase) 0153 0154 /** 0155 * UI_GET_SYSNAME - get the sysfs name of the created uinput device 0156 * 0157 * @return the sysfs name of the created virtual input device. 0158 * The complete sysfs path is then /sys/devices/virtual/input/--NAME-- 0159 * Usually, it is in the form "inputN" 0160 */ 0161 #define UI_GET_SYSNAME(len) _IOC(_IOC_READ, UINPUT_IOCTL_BASE, 44, len) 0162 0163 /** 0164 * UI_GET_VERSION - Return version of uinput protocol 0165 * 0166 * This writes uinput protocol version implemented by the kernel into 0167 * the integer pointed to by the ioctl argument. The protocol version 0168 * is hard-coded in the kernel and is independent of the uinput device. 0169 */ 0170 #define UI_GET_VERSION _IOR(UINPUT_IOCTL_BASE, 45, unsigned int) 0171 0172 /* 0173 * To write a force-feedback-capable driver, the upload_effect 0174 * and erase_effect callbacks in input_dev must be implemented. 0175 * The uinput driver will generate a fake input event when one of 0176 * these callbacks are invoked. The userspace code then uses 0177 * ioctls to retrieve additional parameters and send the return code. 0178 * The callback blocks until this return code is sent. 0179 * 0180 * The described callback mechanism is only used if ff_effects_max 0181 * is set. 0182 * 0183 * To implement upload_effect(): 0184 * 1. Wait for an event with type == EV_UINPUT and code == UI_FF_UPLOAD. 0185 * A request ID will be given in 'value'. 0186 * 2. Allocate a uinput_ff_upload struct, fill in request_id with 0187 * the 'value' from the EV_UINPUT event. 0188 * 3. Issue a UI_BEGIN_FF_UPLOAD ioctl, giving it the 0189 * uinput_ff_upload struct. It will be filled in with the 0190 * ff_effects passed to upload_effect(). 0191 * 4. Perform the effect upload, and place a return code back into 0192 the uinput_ff_upload struct. 0193 * 5. Issue a UI_END_FF_UPLOAD ioctl, also giving it the 0194 * uinput_ff_upload_effect struct. This will complete execution 0195 * of our upload_effect() handler. 0196 * 0197 * To implement erase_effect(): 0198 * 1. Wait for an event with type == EV_UINPUT and code == UI_FF_ERASE. 0199 * A request ID will be given in 'value'. 0200 * 2. Allocate a uinput_ff_erase struct, fill in request_id with 0201 * the 'value' from the EV_UINPUT event. 0202 * 3. Issue a UI_BEGIN_FF_ERASE ioctl, giving it the 0203 * uinput_ff_erase struct. It will be filled in with the 0204 * effect ID passed to erase_effect(). 0205 * 4. Perform the effect erasure, and place a return code back 0206 * into the uinput_ff_erase struct. 0207 * 5. Issue a UI_END_FF_ERASE ioctl, also giving it the 0208 * uinput_ff_erase_effect struct. This will complete execution 0209 * of our erase_effect() handler. 0210 */ 0211 0212 /* 0213 * This is the new event type, used only by uinput. 0214 * 'code' is UI_FF_UPLOAD or UI_FF_ERASE, and 'value' 0215 * is the unique request ID. This number was picked 0216 * arbitrarily, above EV_MAX (since the input system 0217 * never sees it) but in the range of a 16-bit int. 0218 */ 0219 #define EV_UINPUT 0x0101 0220 #define UI_FF_UPLOAD 1 0221 #define UI_FF_ERASE 2 0222 0223 struct uinput_user_dev { 0224 char name[UINPUT_MAX_NAME_SIZE]; 0225 struct input_id id; 0226 __u32 ff_effects_max; 0227 __s32 absmax[ABS_CNT]; 0228 __s32 absmin[ABS_CNT]; 0229 __s32 absfuzz[ABS_CNT]; 0230 __s32 absflat[ABS_CNT]; 0231 }; 0232 #endif /* _UAPI__UINPUT_H_ */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |