1e2be04c7SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2607ca46eSDavid Howells /* 3607ca46eSDavid Howells * Copyright (c) 1999-2002 Vojtech Pavlik 4607ca46eSDavid Howells * 5607ca46eSDavid Howells * This program is free software; you can redistribute it and/or modify it 6607ca46eSDavid Howells * under the terms of the GNU General Public License version 2 as published by 7607ca46eSDavid Howells * the Free Software Foundation. 8607ca46eSDavid Howells */ 9607ca46eSDavid Howells #ifndef _UAPI_INPUT_H 10607ca46eSDavid Howells #define _UAPI_INPUT_H 11607ca46eSDavid Howells 12607ca46eSDavid Howells 13607ca46eSDavid Howells #ifndef __KERNEL__ 14607ca46eSDavid Howells #include <sys/time.h> 15607ca46eSDavid Howells #include <sys/ioctl.h> 16607ca46eSDavid Howells #include <sys/types.h> 17607ca46eSDavid Howells #include <linux/types.h> 18607ca46eSDavid Howells #endif 19607ca46eSDavid Howells 20f902dd89SHans de Goede #include "input-event-codes.h" 21607ca46eSDavid Howells 22607ca46eSDavid Howells /* 23607ca46eSDavid Howells * The event structure itself 24152194feSDeepa Dinamani * Note that __USE_TIME_BITS64 is defined by libc based on 25152194feSDeepa Dinamani * application's request to use 64 bit time_t. 26607ca46eSDavid Howells */ 27607ca46eSDavid Howells 28607ca46eSDavid Howells struct input_event { 292e746942SDeepa Dinamani #if (__BITS_PER_LONG != 32 || !defined(__USE_TIME_BITS64)) && !defined(__KERNEL__) 30607ca46eSDavid Howells struct timeval time; 31152194feSDeepa Dinamani #define input_event_sec time.tv_sec 32152194feSDeepa Dinamani #define input_event_usec time.tv_usec 33152194feSDeepa Dinamani #else 34152194feSDeepa Dinamani __kernel_ulong_t __sec; 35141e5dcaSDeepa Dinamani #if defined(__sparc__) && defined(__arch64__) 362e746942SDeepa Dinamani unsigned int __usec; 37f729a1b0SArnd Bergmann unsigned int __pad; 382e746942SDeepa Dinamani #else 39152194feSDeepa Dinamani __kernel_ulong_t __usec; 402e746942SDeepa Dinamani #endif 41152194feSDeepa Dinamani #define input_event_sec __sec 42152194feSDeepa Dinamani #define input_event_usec __usec 43152194feSDeepa Dinamani #endif 44607ca46eSDavid Howells __u16 type; 45607ca46eSDavid Howells __u16 code; 46607ca46eSDavid Howells __s32 value; 47607ca46eSDavid Howells }; 48607ca46eSDavid Howells 49607ca46eSDavid Howells /* 50607ca46eSDavid Howells * Protocol version. 51607ca46eSDavid Howells */ 52607ca46eSDavid Howells 53607ca46eSDavid Howells #define EV_VERSION 0x010001 54607ca46eSDavid Howells 55607ca46eSDavid Howells /* 56607ca46eSDavid Howells * IOCTLs (0x00 - 0x7f) 57607ca46eSDavid Howells */ 58607ca46eSDavid Howells 59607ca46eSDavid Howells struct input_id { 60607ca46eSDavid Howells __u16 bustype; 61607ca46eSDavid Howells __u16 vendor; 62607ca46eSDavid Howells __u16 product; 63607ca46eSDavid Howells __u16 version; 64607ca46eSDavid Howells }; 65607ca46eSDavid Howells 66607ca46eSDavid Howells /** 67607ca46eSDavid Howells * struct input_absinfo - used by EVIOCGABS/EVIOCSABS ioctls 68607ca46eSDavid Howells * @value: latest reported value for the axis. 69607ca46eSDavid Howells * @minimum: specifies minimum value for the axis. 70607ca46eSDavid Howells * @maximum: specifies maximum value for the axis. 71607ca46eSDavid Howells * @fuzz: specifies fuzz value that is used to filter noise from 72607ca46eSDavid Howells * the event stream. 73607ca46eSDavid Howells * @flat: values that are within this value will be discarded by 74607ca46eSDavid Howells * joydev interface and reported as 0 instead. 75607ca46eSDavid Howells * @resolution: specifies resolution for the values reported for 76607ca46eSDavid Howells * the axis. 77607ca46eSDavid Howells * 78607ca46eSDavid Howells * Note that input core does not clamp reported values to the 79607ca46eSDavid Howells * [minimum, maximum] limits, such task is left to userspace. 80607ca46eSDavid Howells * 81*2a96271fSSiarhei Vishniakou * The default resolution for main axes (ABS_X, ABS_Y, ABS_Z, 82*2a96271fSSiarhei Vishniakou * ABS_MT_POSITION_X, ABS_MT_POSITION_Y) is reported in units 83*2a96271fSSiarhei Vishniakou * per millimeter (units/mm), resolution for rotational axes 84*2a96271fSSiarhei Vishniakou * (ABS_RX, ABS_RY, ABS_RZ) is reported in units per radian. 85*2a96271fSSiarhei Vishniakou * The resolution for the size axes (ABS_MT_TOUCH_MAJOR, 86*2a96271fSSiarhei Vishniakou * ABS_MT_TOUCH_MINOR, ABS_MT_WIDTH_MAJOR, ABS_MT_WIDTH_MINOR) 87*2a96271fSSiarhei Vishniakou * is reported in units per millimeter (units/mm). 88227c011bSRoderick Colenbrander * When INPUT_PROP_ACCELEROMETER is set the resolution changes. 89227c011bSRoderick Colenbrander * The main axes (ABS_X, ABS_Y, ABS_Z) are then reported in 90df54714fSRandy Dunlap * units per g (units/g) and in units per degree per second 91227c011bSRoderick Colenbrander * (units/deg/s) for rotational axes (ABS_RX, ABS_RY, ABS_RZ). 92607ca46eSDavid Howells */ 93607ca46eSDavid Howells struct input_absinfo { 94607ca46eSDavid Howells __s32 value; 95607ca46eSDavid Howells __s32 minimum; 96607ca46eSDavid Howells __s32 maximum; 97607ca46eSDavid Howells __s32 fuzz; 98607ca46eSDavid Howells __s32 flat; 99607ca46eSDavid Howells __s32 resolution; 100607ca46eSDavid Howells }; 101607ca46eSDavid Howells 102607ca46eSDavid Howells /** 103607ca46eSDavid Howells * struct input_keymap_entry - used by EVIOCGKEYCODE/EVIOCSKEYCODE ioctls 104607ca46eSDavid Howells * @scancode: scancode represented in machine-endian form. 105607ca46eSDavid Howells * @len: length of the scancode that resides in @scancode buffer. 106607ca46eSDavid Howells * @index: index in the keymap, may be used instead of scancode 107607ca46eSDavid Howells * @flags: allows to specify how kernel should handle the request. For 108607ca46eSDavid Howells * example, setting INPUT_KEYMAP_BY_INDEX flag indicates that kernel 109607ca46eSDavid Howells * should perform lookup in keymap by @index instead of @scancode 110607ca46eSDavid Howells * @keycode: key code assigned to this scancode 111607ca46eSDavid Howells * 112607ca46eSDavid Howells * The structure is used to retrieve and modify keymap data. Users have 113607ca46eSDavid Howells * option of performing lookup either by @scancode itself or by @index 114607ca46eSDavid Howells * in keymap entry. EVIOCGKEYCODE will also return scancode or index 115607ca46eSDavid Howells * (depending on which element was used to perform lookup). 116607ca46eSDavid Howells */ 117607ca46eSDavid Howells struct input_keymap_entry { 118607ca46eSDavid Howells #define INPUT_KEYMAP_BY_INDEX (1 << 0) 119607ca46eSDavid Howells __u8 flags; 120607ca46eSDavid Howells __u8 len; 121607ca46eSDavid Howells __u16 index; 122607ca46eSDavid Howells __u32 keycode; 123607ca46eSDavid Howells __u8 scancode[32]; 124607ca46eSDavid Howells }; 125607ca46eSDavid Howells 12606a16293SDavid Herrmann struct input_mask { 12706a16293SDavid Herrmann __u32 type; 12806a16293SDavid Herrmann __u32 codes_size; 12906a16293SDavid Herrmann __u64 codes_ptr; 13006a16293SDavid Herrmann }; 13106a16293SDavid Herrmann 132607ca46eSDavid Howells #define EVIOCGVERSION _IOR('E', 0x01, int) /* get driver version */ 133607ca46eSDavid Howells #define EVIOCGID _IOR('E', 0x02, struct input_id) /* get device ID */ 134607ca46eSDavid Howells #define EVIOCGREP _IOR('E', 0x03, unsigned int[2]) /* get repeat settings */ 135607ca46eSDavid Howells #define EVIOCSREP _IOW('E', 0x03, unsigned int[2]) /* set repeat settings */ 136607ca46eSDavid Howells 137607ca46eSDavid Howells #define EVIOCGKEYCODE _IOR('E', 0x04, unsigned int[2]) /* get keycode */ 138607ca46eSDavid Howells #define EVIOCGKEYCODE_V2 _IOR('E', 0x04, struct input_keymap_entry) 139607ca46eSDavid Howells #define EVIOCSKEYCODE _IOW('E', 0x04, unsigned int[2]) /* set keycode */ 140607ca46eSDavid Howells #define EVIOCSKEYCODE_V2 _IOW('E', 0x04, struct input_keymap_entry) 141607ca46eSDavid Howells 142607ca46eSDavid Howells #define EVIOCGNAME(len) _IOC(_IOC_READ, 'E', 0x06, len) /* get device name */ 143607ca46eSDavid Howells #define EVIOCGPHYS(len) _IOC(_IOC_READ, 'E', 0x07, len) /* get physical location */ 144607ca46eSDavid Howells #define EVIOCGUNIQ(len) _IOC(_IOC_READ, 'E', 0x08, len) /* get unique identifier */ 145607ca46eSDavid Howells #define EVIOCGPROP(len) _IOC(_IOC_READ, 'E', 0x09, len) /* get device properties */ 146607ca46eSDavid Howells 147607ca46eSDavid Howells /** 148607ca46eSDavid Howells * EVIOCGMTSLOTS(len) - get MT slot values 149607ca46eSDavid Howells * @len: size of the data buffer in bytes 150607ca46eSDavid Howells * 151607ca46eSDavid Howells * The ioctl buffer argument should be binary equivalent to 152607ca46eSDavid Howells * 153607ca46eSDavid Howells * struct input_mt_request_layout { 154607ca46eSDavid Howells * __u32 code; 155607ca46eSDavid Howells * __s32 values[num_slots]; 156607ca46eSDavid Howells * }; 157607ca46eSDavid Howells * 158607ca46eSDavid Howells * where num_slots is the (arbitrary) number of MT slots to extract. 159607ca46eSDavid Howells * 160607ca46eSDavid Howells * The ioctl size argument (len) is the size of the buffer, which 161607ca46eSDavid Howells * should satisfy len = (num_slots + 1) * sizeof(__s32). If len is 162607ca46eSDavid Howells * too small to fit all available slots, the first num_slots are 163607ca46eSDavid Howells * returned. 164607ca46eSDavid Howells * 165607ca46eSDavid Howells * Before the call, code is set to the wanted ABS_MT event type. On 166607ca46eSDavid Howells * return, values[] is filled with the slot values for the specified 167607ca46eSDavid Howells * ABS_MT code. 168607ca46eSDavid Howells * 169607ca46eSDavid Howells * If the request code is not an ABS_MT value, -EINVAL is returned. 170607ca46eSDavid Howells */ 171607ca46eSDavid Howells #define EVIOCGMTSLOTS(len) _IOC(_IOC_READ, 'E', 0x0a, len) 172607ca46eSDavid Howells 173607ca46eSDavid Howells #define EVIOCGKEY(len) _IOC(_IOC_READ, 'E', 0x18, len) /* get global key state */ 174607ca46eSDavid Howells #define EVIOCGLED(len) _IOC(_IOC_READ, 'E', 0x19, len) /* get all LEDs */ 175607ca46eSDavid Howells #define EVIOCGSND(len) _IOC(_IOC_READ, 'E', 0x1a, len) /* get all sounds status */ 176607ca46eSDavid Howells #define EVIOCGSW(len) _IOC(_IOC_READ, 'E', 0x1b, len) /* get all switch states */ 177607ca46eSDavid Howells 178607ca46eSDavid Howells #define EVIOCGBIT(ev,len) _IOC(_IOC_READ, 'E', 0x20 + (ev), len) /* get event bits */ 179607ca46eSDavid Howells #define EVIOCGABS(abs) _IOR('E', 0x40 + (abs), struct input_absinfo) /* get abs value/limits */ 180607ca46eSDavid Howells #define EVIOCSABS(abs) _IOW('E', 0xc0 + (abs), struct input_absinfo) /* set abs value/limits */ 181607ca46eSDavid Howells 18252a92667SElias Vanderstuyft #define EVIOCSFF _IOW('E', 0x80, struct ff_effect) /* send a force effect to a force feedback device */ 183607ca46eSDavid Howells #define EVIOCRMFF _IOW('E', 0x81, int) /* Erase a force effect */ 184607ca46eSDavid Howells #define EVIOCGEFFECTS _IOR('E', 0x84, int) /* Report number of effects playable at the same time */ 185607ca46eSDavid Howells 186607ca46eSDavid Howells #define EVIOCGRAB _IOW('E', 0x90, int) /* Grab/Release device */ 187c7dc6573SDavid Herrmann #define EVIOCREVOKE _IOW('E', 0x91, int) /* Revoke device access */ 188607ca46eSDavid Howells 18906a16293SDavid Herrmann /** 19006a16293SDavid Herrmann * EVIOCGMASK - Retrieve current event mask 19106a16293SDavid Herrmann * 19206a16293SDavid Herrmann * This ioctl allows user to retrieve the current event mask for specific 19306a16293SDavid Herrmann * event type. The argument must be of type "struct input_mask" and 19406a16293SDavid Herrmann * specifies the event type to query, the address of the receive buffer and 19506a16293SDavid Herrmann * the size of the receive buffer. 19606a16293SDavid Herrmann * 19706a16293SDavid Herrmann * The event mask is a per-client mask that specifies which events are 19806a16293SDavid Herrmann * forwarded to the client. Each event code is represented by a single bit 19906a16293SDavid Herrmann * in the event mask. If the bit is set, the event is passed to the client 20006a16293SDavid Herrmann * normally. Otherwise, the event is filtered and will never be queued on 20106a16293SDavid Herrmann * the client's receive buffer. 20206a16293SDavid Herrmann * 20306a16293SDavid Herrmann * Event masks do not affect global state of the input device. They only 20406a16293SDavid Herrmann * affect the file descriptor they are applied to. 20506a16293SDavid Herrmann * 20606a16293SDavid Herrmann * The default event mask for a client has all bits set, i.e. all events 20706a16293SDavid Herrmann * are forwarded to the client. If the kernel is queried for an unknown 20806a16293SDavid Herrmann * event type or if the receive buffer is larger than the number of 20906a16293SDavid Herrmann * event codes known to the kernel, the kernel returns all zeroes for those 21006a16293SDavid Herrmann * codes. 21106a16293SDavid Herrmann * 21206a16293SDavid Herrmann * At maximum, codes_size bytes are copied. 21306a16293SDavid Herrmann * 21406a16293SDavid Herrmann * This ioctl may fail with ENODEV in case the file is revoked, EFAULT 21506a16293SDavid Herrmann * if the receive-buffer points to invalid memory, or EINVAL if the kernel 21606a16293SDavid Herrmann * does not implement the ioctl. 21706a16293SDavid Herrmann */ 21806a16293SDavid Herrmann #define EVIOCGMASK _IOR('E', 0x92, struct input_mask) /* Get event-masks */ 21906a16293SDavid Herrmann 22006a16293SDavid Herrmann /** 22106a16293SDavid Herrmann * EVIOCSMASK - Set event mask 22206a16293SDavid Herrmann * 22306a16293SDavid Herrmann * This ioctl is the counterpart to EVIOCGMASK. Instead of receiving the 22406a16293SDavid Herrmann * current event mask, this changes the client's event mask for a specific 22506a16293SDavid Herrmann * type. See EVIOCGMASK for a description of event-masks and the 22606a16293SDavid Herrmann * argument-type. 22706a16293SDavid Herrmann * 22806a16293SDavid Herrmann * This ioctl provides full forward compatibility. If the passed event type 22906a16293SDavid Herrmann * is unknown to the kernel, or if the number of event codes specified in 23006a16293SDavid Herrmann * the mask is bigger than what is known to the kernel, the ioctl is still 23106a16293SDavid Herrmann * accepted and applied. However, any unknown codes are left untouched and 23206a16293SDavid Herrmann * stay cleared. That means, the kernel always filters unknown codes 23306a16293SDavid Herrmann * regardless of what the client requests. If the new mask doesn't cover 23406a16293SDavid Herrmann * all known event-codes, all remaining codes are automatically cleared and 23506a16293SDavid Herrmann * thus filtered. 23606a16293SDavid Herrmann * 23706a16293SDavid Herrmann * This ioctl may fail with ENODEV in case the file is revoked. EFAULT is 23806a16293SDavid Herrmann * returned if the receive-buffer points to invalid memory. EINVAL is returned 23906a16293SDavid Herrmann * if the kernel does not implement the ioctl. 24006a16293SDavid Herrmann */ 24106a16293SDavid Herrmann #define EVIOCSMASK _IOW('E', 0x93, struct input_mask) /* Set event-masks */ 24206a16293SDavid Herrmann 243607ca46eSDavid Howells #define EVIOCSCLOCKID _IOW('E', 0xa0, int) /* Set clockid to be used for timestamps */ 244607ca46eSDavid Howells 245607ca46eSDavid Howells /* 246607ca46eSDavid Howells * IDs. 247607ca46eSDavid Howells */ 248607ca46eSDavid Howells 249607ca46eSDavid Howells #define ID_BUS 0 250607ca46eSDavid Howells #define ID_VENDOR 1 251607ca46eSDavid Howells #define ID_PRODUCT 2 252607ca46eSDavid Howells #define ID_VERSION 3 253607ca46eSDavid Howells 254607ca46eSDavid Howells #define BUS_PCI 0x01 255607ca46eSDavid Howells #define BUS_ISAPNP 0x02 256607ca46eSDavid Howells #define BUS_USB 0x03 257607ca46eSDavid Howells #define BUS_HIL 0x04 258607ca46eSDavid Howells #define BUS_BLUETOOTH 0x05 259607ca46eSDavid Howells #define BUS_VIRTUAL 0x06 260607ca46eSDavid Howells 261607ca46eSDavid Howells #define BUS_ISA 0x10 262607ca46eSDavid Howells #define BUS_I8042 0x11 263607ca46eSDavid Howells #define BUS_XTKBD 0x12 264607ca46eSDavid Howells #define BUS_RS232 0x13 265607ca46eSDavid Howells #define BUS_GAMEPORT 0x14 266607ca46eSDavid Howells #define BUS_PARPORT 0x15 267607ca46eSDavid Howells #define BUS_AMIGA 0x16 268607ca46eSDavid Howells #define BUS_ADB 0x17 269607ca46eSDavid Howells #define BUS_I2C 0x18 270607ca46eSDavid Howells #define BUS_HOST 0x19 271607ca46eSDavid Howells #define BUS_GSC 0x1A 272607ca46eSDavid Howells #define BUS_ATARI 0x1B 273607ca46eSDavid Howells #define BUS_SPI 0x1C 2742b6a321dSAndrew Duggan #define BUS_RMI 0x1D 2753720b69bSHans Verkuil #define BUS_CEC 0x1E 2760b28cb4bSSrinivas Pandruvada #define BUS_INTEL_ISHTP 0x1F 277a8641d7dSBasavaraj Natikar #define BUS_AMD_SFH 0x20 278607ca46eSDavid Howells 279607ca46eSDavid Howells /* 280607ca46eSDavid Howells * MT_TOOL types 281607ca46eSDavid Howells */ 282b875a5a5SBenjamin Tissoires #define MT_TOOL_FINGER 0x00 283b875a5a5SBenjamin Tissoires #define MT_TOOL_PEN 0x01 284b875a5a5SBenjamin Tissoires #define MT_TOOL_PALM 0x02 285b875a5a5SBenjamin Tissoires #define MT_TOOL_DIAL 0x0a 286b875a5a5SBenjamin Tissoires #define MT_TOOL_MAX 0x0f 287607ca46eSDavid Howells 288607ca46eSDavid Howells /* 289607ca46eSDavid Howells * Values describing the status of a force-feedback effect 290607ca46eSDavid Howells */ 291607ca46eSDavid Howells #define FF_STATUS_STOPPED 0x00 292607ca46eSDavid Howells #define FF_STATUS_PLAYING 0x01 293607ca46eSDavid Howells #define FF_STATUS_MAX 0x01 294607ca46eSDavid Howells 295607ca46eSDavid Howells /* 296607ca46eSDavid Howells * Structures used in ioctls to upload effects to a device 297607ca46eSDavid Howells * They are pieces of a bigger structure (called ff_effect) 298607ca46eSDavid Howells */ 299607ca46eSDavid Howells 300607ca46eSDavid Howells /* 301607ca46eSDavid Howells * All duration values are expressed in ms. Values above 32767 ms (0x7fff) 302607ca46eSDavid Howells * should not be used and have unspecified results. 303607ca46eSDavid Howells */ 304607ca46eSDavid Howells 305607ca46eSDavid Howells /** 306607ca46eSDavid Howells * struct ff_replay - defines scheduling of the force-feedback effect 307607ca46eSDavid Howells * @length: duration of the effect 308607ca46eSDavid Howells * @delay: delay before effect should start playing 309607ca46eSDavid Howells */ 310607ca46eSDavid Howells struct ff_replay { 311607ca46eSDavid Howells __u16 length; 312607ca46eSDavid Howells __u16 delay; 313607ca46eSDavid Howells }; 314607ca46eSDavid Howells 315607ca46eSDavid Howells /** 316607ca46eSDavid Howells * struct ff_trigger - defines what triggers the force-feedback effect 317607ca46eSDavid Howells * @button: number of the button triggering the effect 318607ca46eSDavid Howells * @interval: controls how soon the effect can be re-triggered 319607ca46eSDavid Howells */ 320607ca46eSDavid Howells struct ff_trigger { 321607ca46eSDavid Howells __u16 button; 322607ca46eSDavid Howells __u16 interval; 323607ca46eSDavid Howells }; 324607ca46eSDavid Howells 325607ca46eSDavid Howells /** 326607ca46eSDavid Howells * struct ff_envelope - generic force-feedback effect envelope 327607ca46eSDavid Howells * @attack_length: duration of the attack (ms) 328607ca46eSDavid Howells * @attack_level: level at the beginning of the attack 329607ca46eSDavid Howells * @fade_length: duration of fade (ms) 330607ca46eSDavid Howells * @fade_level: level at the end of fade 331607ca46eSDavid Howells * 332607ca46eSDavid Howells * The @attack_level and @fade_level are absolute values; when applying 333607ca46eSDavid Howells * envelope force-feedback core will convert to positive/negative 334607ca46eSDavid Howells * value based on polarity of the default level of the effect. 335607ca46eSDavid Howells * Valid range for the attack and fade levels is 0x0000 - 0x7fff 336607ca46eSDavid Howells */ 337607ca46eSDavid Howells struct ff_envelope { 338607ca46eSDavid Howells __u16 attack_length; 339607ca46eSDavid Howells __u16 attack_level; 340607ca46eSDavid Howells __u16 fade_length; 341607ca46eSDavid Howells __u16 fade_level; 342607ca46eSDavid Howells }; 343607ca46eSDavid Howells 344607ca46eSDavid Howells /** 345607ca46eSDavid Howells * struct ff_constant_effect - defines parameters of a constant force-feedback effect 346607ca46eSDavid Howells * @level: strength of the effect; may be negative 347607ca46eSDavid Howells * @envelope: envelope data 348607ca46eSDavid Howells */ 349607ca46eSDavid Howells struct ff_constant_effect { 350607ca46eSDavid Howells __s16 level; 351607ca46eSDavid Howells struct ff_envelope envelope; 352607ca46eSDavid Howells }; 353607ca46eSDavid Howells 354607ca46eSDavid Howells /** 355607ca46eSDavid Howells * struct ff_ramp_effect - defines parameters of a ramp force-feedback effect 356607ca46eSDavid Howells * @start_level: beginning strength of the effect; may be negative 357607ca46eSDavid Howells * @end_level: final strength of the effect; may be negative 358607ca46eSDavid Howells * @envelope: envelope data 359607ca46eSDavid Howells */ 360607ca46eSDavid Howells struct ff_ramp_effect { 361607ca46eSDavid Howells __s16 start_level; 362607ca46eSDavid Howells __s16 end_level; 363607ca46eSDavid Howells struct ff_envelope envelope; 364607ca46eSDavid Howells }; 365607ca46eSDavid Howells 366607ca46eSDavid Howells /** 367607ca46eSDavid Howells * struct ff_condition_effect - defines a spring or friction force-feedback effect 368607ca46eSDavid Howells * @right_saturation: maximum level when joystick moved all way to the right 369607ca46eSDavid Howells * @left_saturation: same for the left side 370607ca46eSDavid Howells * @right_coeff: controls how fast the force grows when the joystick moves 371607ca46eSDavid Howells * to the right 372607ca46eSDavid Howells * @left_coeff: same for the left side 373607ca46eSDavid Howells * @deadband: size of the dead zone, where no force is produced 374607ca46eSDavid Howells * @center: position of the dead zone 375607ca46eSDavid Howells */ 376607ca46eSDavid Howells struct ff_condition_effect { 377607ca46eSDavid Howells __u16 right_saturation; 378607ca46eSDavid Howells __u16 left_saturation; 379607ca46eSDavid Howells 380607ca46eSDavid Howells __s16 right_coeff; 381607ca46eSDavid Howells __s16 left_coeff; 382607ca46eSDavid Howells 383607ca46eSDavid Howells __u16 deadband; 384607ca46eSDavid Howells __s16 center; 385607ca46eSDavid Howells }; 386607ca46eSDavid Howells 387607ca46eSDavid Howells /** 388607ca46eSDavid Howells * struct ff_periodic_effect - defines parameters of a periodic force-feedback effect 389607ca46eSDavid Howells * @waveform: kind of the effect (wave) 390607ca46eSDavid Howells * @period: period of the wave (ms) 391607ca46eSDavid Howells * @magnitude: peak value 392607ca46eSDavid Howells * @offset: mean value of the wave (roughly) 393607ca46eSDavid Howells * @phase: 'horizontal' shift 394607ca46eSDavid Howells * @envelope: envelope data 395607ca46eSDavid Howells * @custom_len: number of samples (FF_CUSTOM only) 396607ca46eSDavid Howells * @custom_data: buffer of samples (FF_CUSTOM only) 397607ca46eSDavid Howells * 398607ca46eSDavid Howells * Known waveforms - FF_SQUARE, FF_TRIANGLE, FF_SINE, FF_SAW_UP, 399607ca46eSDavid Howells * FF_SAW_DOWN, FF_CUSTOM. The exact syntax FF_CUSTOM is undefined 400607ca46eSDavid Howells * for the time being as no driver supports it yet. 401607ca46eSDavid Howells * 402607ca46eSDavid Howells * Note: the data pointed by custom_data is copied by the driver. 403607ca46eSDavid Howells * You can therefore dispose of the memory after the upload/update. 404607ca46eSDavid Howells */ 405607ca46eSDavid Howells struct ff_periodic_effect { 406607ca46eSDavid Howells __u16 waveform; 407607ca46eSDavid Howells __u16 period; 408607ca46eSDavid Howells __s16 magnitude; 409607ca46eSDavid Howells __s16 offset; 410607ca46eSDavid Howells __u16 phase; 411607ca46eSDavid Howells 412607ca46eSDavid Howells struct ff_envelope envelope; 413607ca46eSDavid Howells 414607ca46eSDavid Howells __u32 custom_len; 415607ca46eSDavid Howells __s16 __user *custom_data; 416607ca46eSDavid Howells }; 417607ca46eSDavid Howells 418607ca46eSDavid Howells /** 419607ca46eSDavid Howells * struct ff_rumble_effect - defines parameters of a periodic force-feedback effect 420607ca46eSDavid Howells * @strong_magnitude: magnitude of the heavy motor 421607ca46eSDavid Howells * @weak_magnitude: magnitude of the light one 422607ca46eSDavid Howells * 423607ca46eSDavid Howells * Some rumble pads have two motors of different weight. Strong_magnitude 424607ca46eSDavid Howells * represents the magnitude of the vibration generated by the heavy one. 425607ca46eSDavid Howells */ 426607ca46eSDavid Howells struct ff_rumble_effect { 427607ca46eSDavid Howells __u16 strong_magnitude; 428607ca46eSDavid Howells __u16 weak_magnitude; 429607ca46eSDavid Howells }; 430607ca46eSDavid Howells 431607ca46eSDavid Howells /** 432607ca46eSDavid Howells * struct ff_effect - defines force feedback effect 433607ca46eSDavid Howells * @type: type of the effect (FF_CONSTANT, FF_PERIODIC, FF_RAMP, FF_SPRING, 434607ca46eSDavid Howells * FF_FRICTION, FF_DAMPER, FF_RUMBLE, FF_INERTIA, or FF_CUSTOM) 435607ca46eSDavid Howells * @id: an unique id assigned to an effect 436607ca46eSDavid Howells * @direction: direction of the effect 437607ca46eSDavid Howells * @trigger: trigger conditions (struct ff_trigger) 438607ca46eSDavid Howells * @replay: scheduling of the effect (struct ff_replay) 439607ca46eSDavid Howells * @u: effect-specific structure (one of ff_constant_effect, ff_ramp_effect, 440607ca46eSDavid Howells * ff_periodic_effect, ff_condition_effect, ff_rumble_effect) further 441607ca46eSDavid Howells * defining effect parameters 442607ca46eSDavid Howells * 443607ca46eSDavid Howells * This structure is sent through ioctl from the application to the driver. 444607ca46eSDavid Howells * To create a new effect application should set its @id to -1; the kernel 445607ca46eSDavid Howells * will return assigned @id which can later be used to update or delete 446607ca46eSDavid Howells * this effect. 447607ca46eSDavid Howells * 448607ca46eSDavid Howells * Direction of the effect is encoded as follows: 449607ca46eSDavid Howells * 0 deg -> 0x0000 (down) 450607ca46eSDavid Howells * 90 deg -> 0x4000 (left) 451607ca46eSDavid Howells * 180 deg -> 0x8000 (up) 452607ca46eSDavid Howells * 270 deg -> 0xC000 (right) 453607ca46eSDavid Howells */ 454607ca46eSDavid Howells struct ff_effect { 455607ca46eSDavid Howells __u16 type; 456607ca46eSDavid Howells __s16 id; 457607ca46eSDavid Howells __u16 direction; 458607ca46eSDavid Howells struct ff_trigger trigger; 459607ca46eSDavid Howells struct ff_replay replay; 460607ca46eSDavid Howells 461607ca46eSDavid Howells union { 462607ca46eSDavid Howells struct ff_constant_effect constant; 463607ca46eSDavid Howells struct ff_ramp_effect ramp; 464607ca46eSDavid Howells struct ff_periodic_effect periodic; 465607ca46eSDavid Howells struct ff_condition_effect condition[2]; /* One for each axis */ 466607ca46eSDavid Howells struct ff_rumble_effect rumble; 467607ca46eSDavid Howells } u; 468607ca46eSDavid Howells }; 469607ca46eSDavid Howells 470607ca46eSDavid Howells /* 471607ca46eSDavid Howells * Force feedback effect types 472607ca46eSDavid Howells */ 473607ca46eSDavid Howells 474607ca46eSDavid Howells #define FF_RUMBLE 0x50 475607ca46eSDavid Howells #define FF_PERIODIC 0x51 476607ca46eSDavid Howells #define FF_CONSTANT 0x52 477607ca46eSDavid Howells #define FF_SPRING 0x53 478607ca46eSDavid Howells #define FF_FRICTION 0x54 479607ca46eSDavid Howells #define FF_DAMPER 0x55 480607ca46eSDavid Howells #define FF_INERTIA 0x56 481607ca46eSDavid Howells #define FF_RAMP 0x57 482607ca46eSDavid Howells 483607ca46eSDavid Howells #define FF_EFFECT_MIN FF_RUMBLE 484607ca46eSDavid Howells #define FF_EFFECT_MAX FF_RAMP 485607ca46eSDavid Howells 486607ca46eSDavid Howells /* 487607ca46eSDavid Howells * Force feedback periodic effect types 488607ca46eSDavid Howells */ 489607ca46eSDavid Howells 490607ca46eSDavid Howells #define FF_SQUARE 0x58 491607ca46eSDavid Howells #define FF_TRIANGLE 0x59 492607ca46eSDavid Howells #define FF_SINE 0x5a 493607ca46eSDavid Howells #define FF_SAW_UP 0x5b 494607ca46eSDavid Howells #define FF_SAW_DOWN 0x5c 495607ca46eSDavid Howells #define FF_CUSTOM 0x5d 496607ca46eSDavid Howells 497607ca46eSDavid Howells #define FF_WAVEFORM_MIN FF_SQUARE 498607ca46eSDavid Howells #define FF_WAVEFORM_MAX FF_CUSTOM 499607ca46eSDavid Howells 500607ca46eSDavid Howells /* 501607ca46eSDavid Howells * Set ff device properties 502607ca46eSDavid Howells */ 503607ca46eSDavid Howells 504607ca46eSDavid Howells #define FF_GAIN 0x60 505607ca46eSDavid Howells #define FF_AUTOCENTER 0x61 506607ca46eSDavid Howells 50733b96d93SElias Vanderstuyft /* 50833b96d93SElias Vanderstuyft * ff->playback(effect_id = FF_GAIN) is the first effect_id to 50933b96d93SElias Vanderstuyft * cause a collision with another ff method, in this case ff->set_gain(). 51033b96d93SElias Vanderstuyft * Therefore the greatest safe value for effect_id is FF_GAIN - 1, 51133b96d93SElias Vanderstuyft * and thus the total number of effects should never exceed FF_GAIN. 51233b96d93SElias Vanderstuyft */ 51333b96d93SElias Vanderstuyft #define FF_MAX_EFFECTS FF_GAIN 51433b96d93SElias Vanderstuyft 515607ca46eSDavid Howells #define FF_MAX 0x7f 516607ca46eSDavid Howells #define FF_CNT (FF_MAX+1) 517607ca46eSDavid Howells 518607ca46eSDavid Howells #endif /* _UAPI_INPUT_H */ 519