June 2025 | ||||||
Mo | Tu | We | Th | Fr | Sa | Su |
26 | 27 | 28 | 29 | 30 | 31 | 1 |
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 1 | 2 | 3 | 4 | 5 | 6 |
001: #ifndef __UINPUT_H_ 002: #define __UINPUT_H_ 003: /* 004: * User level driver support for input subsystem 005: * 006: * Heavily based on evdev.c by Vojtech Pavlik 007: * 008: * This program is free software; you can redistribute it and/or modify 009: * it under the terms of the GNU General Public License as published by 010: * the Free Software Foundation; either version 2 of the License, or 011: * (at your option) any later version. 012: * 013: * This program is distributed in the hope that it will be useful, 014: * but WITHOUT ANY WARRANTY; without even the implied warranty of 015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 016: * GNU General Public License for more details. 017: * 018: * You should have received a copy of the GNU General Public License 019: * along with this program; if not, write to the Free Software 020: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 021: * 022: * Author: Aristeu Sergio Rozanski Filho <aris@cathedrallabs.org> 023: * 024: * Changes/Revisions: 025: * 0.3 24/05/2006 (Anssi Hannula <anssi.hannulagmail.com>) 026: * - update ff support for the changes in kernel interface 027: * - add UINPUT_VERSION 028: * 0.2 16/10/2004 (Micah Dowty <micah@navi.cx>) 029: * - added force feedback support 030: * - added UI_SET_PHYS 031: * 0.1 20/06/2002 032: * - first public version 033: */ 034: 035: #include <linux/input.h> 036: 037: #define UINPUT_VERSION 3 038: 039: 040: struct uinput_ff_upload { 041: int request_id; 042: int retval; 043: struct ff_effect effect; 044: struct ff_effect old; 045: }; 046: 047: struct uinput_ff_erase { 048: int request_id; 049: int retval; 050: int effect_id; 051: }; 052: 053: /* ioctl */ 054: #define UINPUT_IOCTL_BASE 'U' 055: #define UI_DEV_CREATE _IO(UINPUT_IOCTL_BASE, 1) 056: #define UI_DEV_DESTROY _IO(UINPUT_IOCTL_BASE, 2) 057: 058: #define UI_SET_EVBIT _IOW(UINPUT_IOCTL_BASE, 100, int) 059: #define UI_SET_KEYBIT _IOW(UINPUT_IOCTL_BASE, 101, int) 060: #define UI_SET_RELBIT _IOW(UINPUT_IOCTL_BASE, 102, int) 061: #define UI_SET_ABSBIT _IOW(UINPUT_IOCTL_BASE, 103, int) 062: #define UI_SET_MSCBIT _IOW(UINPUT_IOCTL_BASE, 104, int) 063: #define UI_SET_LEDBIT _IOW(UINPUT_IOCTL_BASE, 105, int) 064: #define UI_SET_SNDBIT _IOW(UINPUT_IOCTL_BASE, 106, int) 065: #define UI_SET_FFBIT _IOW(UINPUT_IOCTL_BASE, 107, int) 066: #define UI_SET_PHYS _IOW(UINPUT_IOCTL_BASE, 108, char*) 067: #define UI_SET_SWBIT _IOW(UINPUT_IOCTL_BASE, 109, int) 068: #define UI_SET_PROPBIT _IOW(UINPUT_IOCTL_BASE, 110, int) 069: 070: #define UI_BEGIN_FF_UPLOAD _IOWR(UINPUT_IOCTL_BASE, 200, struct uinput_ff_upload) 071: #define UI_END_FF_UPLOAD _IOW(UINPUT_IOCTL_BASE, 201, struct uinput_ff_upload) 072: #define UI_BEGIN_FF_ERASE _IOWR(UINPUT_IOCTL_BASE, 202, struct uinput_ff_erase) 073: #define UI_END_FF_ERASE _IOW(UINPUT_IOCTL_BASE, 203, struct uinput_ff_erase) 074: 075: /* 076: * To write a force-feedback-capable driver, the upload_effect 077: * and erase_effect callbacks in input_dev must be implemented. 078: * The uinput driver will generate a fake input event when one of 079: * these callbacks are invoked. The userspace code then uses 080: * ioctls to retrieve additional parameters and send the return code. 081: * The callback blocks until this return code is sent. 082: * 083: * The described callback mechanism is only used if ff_effects_max 084: * is set. 085: * 086: * To implement upload_effect(): 087: * 1. Wait for an event with type == EV_UINPUT and code == UI_FF_UPLOAD. 088: * A request ID will be given in 'value'. 089: * 2. Allocate a uinput_ff_upload struct, fill in request_id with 090: * the 'value' from the EV_UINPUT event. 091: * 3. Issue a UI_BEGIN_FF_UPLOAD ioctl, giving it the 092: * uinput_ff_upload struct. It will be filled in with the 093: * ff_effects passed to upload_effect(). 094: * 4. Perform the effect upload, and place a return code back into 095: the uinput_ff_upload struct. 096: * 5. Issue a UI_END_FF_UPLOAD ioctl, also giving it the 097: * uinput_ff_upload_effect struct. This will complete execution 098: * of our upload_effect() handler. 099: * 100: * To implement erase_effect(): 101: * 1. Wait for an event with type == EV_UINPUT and code == UI_FF_ERASE. 102: * A request ID will be given in 'value'. 103: * 2. Allocate a uinput_ff_erase struct, fill in request_id with 104: * the 'value' from the EV_UINPUT event. 105: * 3. Issue a UI_BEGIN_FF_ERASE ioctl, giving it the 106: * uinput_ff_erase struct. It will be filled in with the 107: * effect ID passed to erase_effect(). 108: * 4. Perform the effect erasure, and place a return code back 109: * into the uinput_ff_erase struct. 110: * 5. Issue a UI_END_FF_ERASE ioctl, also giving it the 111: * uinput_ff_erase_effect struct. This will complete execution 112: * of our erase_effect() handler. 113: */ 114: 115: /* 116: * This is the new event type, used only by uinput. 117: * 'code' is UI_FF_UPLOAD or UI_FF_ERASE, and 'value' 118: * is the unique request ID. This number was picked 119: * arbitrarily, above EV_MAX (since the input system 120: * never sees it) but in the range of a 16-bit int. 121: */ 122: #define EV_UINPUT 0x0101 123: #define UI_FF_UPLOAD 1 124: #define UI_FF_ERASE 2 125: 126: #define UINPUT_MAX_NAME_SIZE 80 127: struct uinput_user_dev { 128: char name[UINPUT_MAX_NAME_SIZE]; 129: struct input_id id; 130: int ff_effects_max; 131: int absmax[ABS_CNT]; 132: int absmin[ABS_CNT]; 133: int absfuzz[ABS_CNT]; 134: int absflat[ABS_CNT]; 135: }; 136: #endif /* __UINPUT_H_ */ 137: 138: