1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2*4882a593Smuzhiyun /* 3*4882a593Smuzhiyun * Copyright (c) 1999-2002 Vojtech Pavlik 4*4882a593Smuzhiyun * 5*4882a593Smuzhiyun * This program is free software; you can redistribute it and/or modify it 6*4882a593Smuzhiyun * under the terms of the GNU General Public License version 2 as published by 7*4882a593Smuzhiyun * the Free Software Foundation. 8*4882a593Smuzhiyun */ 9*4882a593Smuzhiyun #ifndef _UAPI_INPUT_H 10*4882a593Smuzhiyun #define _UAPI_INPUT_H 11*4882a593Smuzhiyun 12*4882a593Smuzhiyun 13*4882a593Smuzhiyun #ifndef __KERNEL__ 14*4882a593Smuzhiyun #include <sys/time.h> 15*4882a593Smuzhiyun #include <sys/ioctl.h> 16*4882a593Smuzhiyun #include <sys/types.h> 17*4882a593Smuzhiyun #include <linux/types.h> 18*4882a593Smuzhiyun #endif 19*4882a593Smuzhiyun 20*4882a593Smuzhiyun #include "input-event-codes.h" 21*4882a593Smuzhiyun 22*4882a593Smuzhiyun /* 23*4882a593Smuzhiyun * The event structure itself 24*4882a593Smuzhiyun * Note that __USE_TIME_BITS64 is defined by libc based on 25*4882a593Smuzhiyun * application's request to use 64 bit time_t. 26*4882a593Smuzhiyun */ 27*4882a593Smuzhiyun 28*4882a593Smuzhiyun struct input_event { 29*4882a593Smuzhiyun #if (__BITS_PER_LONG != 32 || !defined(__USE_TIME_BITS64)) && !defined(__KERNEL__) 30*4882a593Smuzhiyun struct timeval time; 31*4882a593Smuzhiyun #define input_event_sec time.tv_sec 32*4882a593Smuzhiyun #define input_event_usec time.tv_usec 33*4882a593Smuzhiyun #else 34*4882a593Smuzhiyun __kernel_ulong_t __sec; 35*4882a593Smuzhiyun #if defined(__sparc__) && defined(__arch64__) 36*4882a593Smuzhiyun unsigned int __usec; 37*4882a593Smuzhiyun unsigned int __pad; 38*4882a593Smuzhiyun #else 39*4882a593Smuzhiyun __kernel_ulong_t __usec; 40*4882a593Smuzhiyun #endif 41*4882a593Smuzhiyun #define input_event_sec __sec 42*4882a593Smuzhiyun #define input_event_usec __usec 43*4882a593Smuzhiyun #endif 44*4882a593Smuzhiyun __u16 type; 45*4882a593Smuzhiyun __u16 code; 46*4882a593Smuzhiyun __s32 value; 47*4882a593Smuzhiyun }; 48*4882a593Smuzhiyun 49*4882a593Smuzhiyun /* 50*4882a593Smuzhiyun * Protocol version. 51*4882a593Smuzhiyun */ 52*4882a593Smuzhiyun 53*4882a593Smuzhiyun #define EV_VERSION 0x010001 54*4882a593Smuzhiyun 55*4882a593Smuzhiyun /* 56*4882a593Smuzhiyun * IOCTLs (0x00 - 0x7f) 57*4882a593Smuzhiyun */ 58*4882a593Smuzhiyun 59*4882a593Smuzhiyun struct input_id { 60*4882a593Smuzhiyun __u16 bustype; 61*4882a593Smuzhiyun __u16 vendor; 62*4882a593Smuzhiyun __u16 product; 63*4882a593Smuzhiyun __u16 version; 64*4882a593Smuzhiyun }; 65*4882a593Smuzhiyun 66*4882a593Smuzhiyun /** 67*4882a593Smuzhiyun * struct input_absinfo - used by EVIOCGABS/EVIOCSABS ioctls 68*4882a593Smuzhiyun * @value: latest reported value for the axis. 69*4882a593Smuzhiyun * @minimum: specifies minimum value for the axis. 70*4882a593Smuzhiyun * @maximum: specifies maximum value for the axis. 71*4882a593Smuzhiyun * @fuzz: specifies fuzz value that is used to filter noise from 72*4882a593Smuzhiyun * the event stream. 73*4882a593Smuzhiyun * @flat: values that are within this value will be discarded by 74*4882a593Smuzhiyun * joydev interface and reported as 0 instead. 75*4882a593Smuzhiyun * @resolution: specifies resolution for the values reported for 76*4882a593Smuzhiyun * the axis. 77*4882a593Smuzhiyun * 78*4882a593Smuzhiyun * Note that input core does not clamp reported values to the 79*4882a593Smuzhiyun * [minimum, maximum] limits, such task is left to userspace. 80*4882a593Smuzhiyun * 81*4882a593Smuzhiyun * The default resolution for main axes (ABS_X, ABS_Y, ABS_Z) 82*4882a593Smuzhiyun * is reported in units per millimeter (units/mm), resolution 83*4882a593Smuzhiyun * for rotational axes (ABS_RX, ABS_RY, ABS_RZ) is reported 84*4882a593Smuzhiyun * in units per radian. 85*4882a593Smuzhiyun * When INPUT_PROP_ACCELEROMETER is set the resolution changes. 86*4882a593Smuzhiyun * The main axes (ABS_X, ABS_Y, ABS_Z) are then reported in 87*4882a593Smuzhiyun * in units per g (units/g) and in units per degree per second 88*4882a593Smuzhiyun * (units/deg/s) for rotational axes (ABS_RX, ABS_RY, ABS_RZ). 89*4882a593Smuzhiyun */ 90*4882a593Smuzhiyun struct input_absinfo { 91*4882a593Smuzhiyun __s32 value; 92*4882a593Smuzhiyun __s32 minimum; 93*4882a593Smuzhiyun __s32 maximum; 94*4882a593Smuzhiyun __s32 fuzz; 95*4882a593Smuzhiyun __s32 flat; 96*4882a593Smuzhiyun __s32 resolution; 97*4882a593Smuzhiyun }; 98*4882a593Smuzhiyun 99*4882a593Smuzhiyun /** 100*4882a593Smuzhiyun * struct input_keymap_entry - used by EVIOCGKEYCODE/EVIOCSKEYCODE ioctls 101*4882a593Smuzhiyun * @scancode: scancode represented in machine-endian form. 102*4882a593Smuzhiyun * @len: length of the scancode that resides in @scancode buffer. 103*4882a593Smuzhiyun * @index: index in the keymap, may be used instead of scancode 104*4882a593Smuzhiyun * @flags: allows to specify how kernel should handle the request. For 105*4882a593Smuzhiyun * example, setting INPUT_KEYMAP_BY_INDEX flag indicates that kernel 106*4882a593Smuzhiyun * should perform lookup in keymap by @index instead of @scancode 107*4882a593Smuzhiyun * @keycode: key code assigned to this scancode 108*4882a593Smuzhiyun * 109*4882a593Smuzhiyun * The structure is used to retrieve and modify keymap data. Users have 110*4882a593Smuzhiyun * option of performing lookup either by @scancode itself or by @index 111*4882a593Smuzhiyun * in keymap entry. EVIOCGKEYCODE will also return scancode or index 112*4882a593Smuzhiyun * (depending on which element was used to perform lookup). 113*4882a593Smuzhiyun */ 114*4882a593Smuzhiyun struct input_keymap_entry { 115*4882a593Smuzhiyun #define INPUT_KEYMAP_BY_INDEX (1 << 0) 116*4882a593Smuzhiyun __u8 flags; 117*4882a593Smuzhiyun __u8 len; 118*4882a593Smuzhiyun __u16 index; 119*4882a593Smuzhiyun __u32 keycode; 120*4882a593Smuzhiyun __u8 scancode[32]; 121*4882a593Smuzhiyun }; 122*4882a593Smuzhiyun 123*4882a593Smuzhiyun struct input_mask { 124*4882a593Smuzhiyun __u32 type; 125*4882a593Smuzhiyun __u32 codes_size; 126*4882a593Smuzhiyun __u64 codes_ptr; 127*4882a593Smuzhiyun }; 128*4882a593Smuzhiyun 129*4882a593Smuzhiyun #define EVIOCGVERSION _IOR('E', 0x01, int) /* get driver version */ 130*4882a593Smuzhiyun #define EVIOCGID _IOR('E', 0x02, struct input_id) /* get device ID */ 131*4882a593Smuzhiyun #define EVIOCGREP _IOR('E', 0x03, unsigned int[2]) /* get repeat settings */ 132*4882a593Smuzhiyun #define EVIOCSREP _IOW('E', 0x03, unsigned int[2]) /* set repeat settings */ 133*4882a593Smuzhiyun 134*4882a593Smuzhiyun #define EVIOCGKEYCODE _IOR('E', 0x04, unsigned int[2]) /* get keycode */ 135*4882a593Smuzhiyun #define EVIOCGKEYCODE_V2 _IOR('E', 0x04, struct input_keymap_entry) 136*4882a593Smuzhiyun #define EVIOCSKEYCODE _IOW('E', 0x04, unsigned int[2]) /* set keycode */ 137*4882a593Smuzhiyun #define EVIOCSKEYCODE_V2 _IOW('E', 0x04, struct input_keymap_entry) 138*4882a593Smuzhiyun 139*4882a593Smuzhiyun #define EVIOCGNAME(len) _IOC(_IOC_READ, 'E', 0x06, len) /* get device name */ 140*4882a593Smuzhiyun #define EVIOCGPHYS(len) _IOC(_IOC_READ, 'E', 0x07, len) /* get physical location */ 141*4882a593Smuzhiyun #define EVIOCGUNIQ(len) _IOC(_IOC_READ, 'E', 0x08, len) /* get unique identifier */ 142*4882a593Smuzhiyun #define EVIOCGPROP(len) _IOC(_IOC_READ, 'E', 0x09, len) /* get device properties */ 143*4882a593Smuzhiyun 144*4882a593Smuzhiyun /** 145*4882a593Smuzhiyun * EVIOCGMTSLOTS(len) - get MT slot values 146*4882a593Smuzhiyun * @len: size of the data buffer in bytes 147*4882a593Smuzhiyun * 148*4882a593Smuzhiyun * The ioctl buffer argument should be binary equivalent to 149*4882a593Smuzhiyun * 150*4882a593Smuzhiyun * struct input_mt_request_layout { 151*4882a593Smuzhiyun * __u32 code; 152*4882a593Smuzhiyun * __s32 values[num_slots]; 153*4882a593Smuzhiyun * }; 154*4882a593Smuzhiyun * 155*4882a593Smuzhiyun * where num_slots is the (arbitrary) number of MT slots to extract. 156*4882a593Smuzhiyun * 157*4882a593Smuzhiyun * The ioctl size argument (len) is the size of the buffer, which 158*4882a593Smuzhiyun * should satisfy len = (num_slots + 1) * sizeof(__s32). If len is 159*4882a593Smuzhiyun * too small to fit all available slots, the first num_slots are 160*4882a593Smuzhiyun * returned. 161*4882a593Smuzhiyun * 162*4882a593Smuzhiyun * Before the call, code is set to the wanted ABS_MT event type. On 163*4882a593Smuzhiyun * return, values[] is filled with the slot values for the specified 164*4882a593Smuzhiyun * ABS_MT code. 165*4882a593Smuzhiyun * 166*4882a593Smuzhiyun * If the request code is not an ABS_MT value, -EINVAL is returned. 167*4882a593Smuzhiyun */ 168*4882a593Smuzhiyun #define EVIOCGMTSLOTS(len) _IOC(_IOC_READ, 'E', 0x0a, len) 169*4882a593Smuzhiyun 170*4882a593Smuzhiyun #define EVIOCGKEY(len) _IOC(_IOC_READ, 'E', 0x18, len) /* get global key state */ 171*4882a593Smuzhiyun #define EVIOCGLED(len) _IOC(_IOC_READ, 'E', 0x19, len) /* get all LEDs */ 172*4882a593Smuzhiyun #define EVIOCGSND(len) _IOC(_IOC_READ, 'E', 0x1a, len) /* get all sounds status */ 173*4882a593Smuzhiyun #define EVIOCGSW(len) _IOC(_IOC_READ, 'E', 0x1b, len) /* get all switch states */ 174*4882a593Smuzhiyun 175*4882a593Smuzhiyun #define EVIOCGBIT(ev,len) _IOC(_IOC_READ, 'E', 0x20 + (ev), len) /* get event bits */ 176*4882a593Smuzhiyun #define EVIOCGABS(abs) _IOR('E', 0x40 + (abs), struct input_absinfo) /* get abs value/limits */ 177*4882a593Smuzhiyun #define EVIOCSABS(abs) _IOW('E', 0xc0 + (abs), struct input_absinfo) /* set abs value/limits */ 178*4882a593Smuzhiyun 179*4882a593Smuzhiyun #define EVIOCSFF _IOW('E', 0x80, struct ff_effect) /* send a force effect to a force feedback device */ 180*4882a593Smuzhiyun #define EVIOCRMFF _IOW('E', 0x81, int) /* Erase a force effect */ 181*4882a593Smuzhiyun #define EVIOCGEFFECTS _IOR('E', 0x84, int) /* Report number of effects playable at the same time */ 182*4882a593Smuzhiyun 183*4882a593Smuzhiyun #define EVIOCGRAB _IOW('E', 0x90, int) /* Grab/Release device */ 184*4882a593Smuzhiyun #define EVIOCREVOKE _IOW('E', 0x91, int) /* Revoke device access */ 185*4882a593Smuzhiyun 186*4882a593Smuzhiyun /** 187*4882a593Smuzhiyun * EVIOCGMASK - Retrieve current event mask 188*4882a593Smuzhiyun * 189*4882a593Smuzhiyun * This ioctl allows user to retrieve the current event mask for specific 190*4882a593Smuzhiyun * event type. The argument must be of type "struct input_mask" and 191*4882a593Smuzhiyun * specifies the event type to query, the address of the receive buffer and 192*4882a593Smuzhiyun * the size of the receive buffer. 193*4882a593Smuzhiyun * 194*4882a593Smuzhiyun * The event mask is a per-client mask that specifies which events are 195*4882a593Smuzhiyun * forwarded to the client. Each event code is represented by a single bit 196*4882a593Smuzhiyun * in the event mask. If the bit is set, the event is passed to the client 197*4882a593Smuzhiyun * normally. Otherwise, the event is filtered and will never be queued on 198*4882a593Smuzhiyun * the client's receive buffer. 199*4882a593Smuzhiyun * 200*4882a593Smuzhiyun * Event masks do not affect global state of the input device. They only 201*4882a593Smuzhiyun * affect the file descriptor they are applied to. 202*4882a593Smuzhiyun * 203*4882a593Smuzhiyun * The default event mask for a client has all bits set, i.e. all events 204*4882a593Smuzhiyun * are forwarded to the client. If the kernel is queried for an unknown 205*4882a593Smuzhiyun * event type or if the receive buffer is larger than the number of 206*4882a593Smuzhiyun * event codes known to the kernel, the kernel returns all zeroes for those 207*4882a593Smuzhiyun * codes. 208*4882a593Smuzhiyun * 209*4882a593Smuzhiyun * At maximum, codes_size bytes are copied. 210*4882a593Smuzhiyun * 211*4882a593Smuzhiyun * This ioctl may fail with ENODEV in case the file is revoked, EFAULT 212*4882a593Smuzhiyun * if the receive-buffer points to invalid memory, or EINVAL if the kernel 213*4882a593Smuzhiyun * does not implement the ioctl. 214*4882a593Smuzhiyun */ 215*4882a593Smuzhiyun #define EVIOCGMASK _IOR('E', 0x92, struct input_mask) /* Get event-masks */ 216*4882a593Smuzhiyun 217*4882a593Smuzhiyun /** 218*4882a593Smuzhiyun * EVIOCSMASK - Set event mask 219*4882a593Smuzhiyun * 220*4882a593Smuzhiyun * This ioctl is the counterpart to EVIOCGMASK. Instead of receiving the 221*4882a593Smuzhiyun * current event mask, this changes the client's event mask for a specific 222*4882a593Smuzhiyun * type. See EVIOCGMASK for a description of event-masks and the 223*4882a593Smuzhiyun * argument-type. 224*4882a593Smuzhiyun * 225*4882a593Smuzhiyun * This ioctl provides full forward compatibility. If the passed event type 226*4882a593Smuzhiyun * is unknown to the kernel, or if the number of event codes specified in 227*4882a593Smuzhiyun * the mask is bigger than what is known to the kernel, the ioctl is still 228*4882a593Smuzhiyun * accepted and applied. However, any unknown codes are left untouched and 229*4882a593Smuzhiyun * stay cleared. That means, the kernel always filters unknown codes 230*4882a593Smuzhiyun * regardless of what the client requests. If the new mask doesn't cover 231*4882a593Smuzhiyun * all known event-codes, all remaining codes are automatically cleared and 232*4882a593Smuzhiyun * thus filtered. 233*4882a593Smuzhiyun * 234*4882a593Smuzhiyun * This ioctl may fail with ENODEV in case the file is revoked. EFAULT is 235*4882a593Smuzhiyun * returned if the receive-buffer points to invalid memory. EINVAL is returned 236*4882a593Smuzhiyun * if the kernel does not implement the ioctl. 237*4882a593Smuzhiyun */ 238*4882a593Smuzhiyun #define EVIOCSMASK _IOW('E', 0x93, struct input_mask) /* Set event-masks */ 239*4882a593Smuzhiyun 240*4882a593Smuzhiyun #define EVIOCSCLOCKID _IOW('E', 0xa0, int) /* Set clockid to be used for timestamps */ 241*4882a593Smuzhiyun 242*4882a593Smuzhiyun /* 243*4882a593Smuzhiyun * IDs. 244*4882a593Smuzhiyun */ 245*4882a593Smuzhiyun 246*4882a593Smuzhiyun #define ID_BUS 0 247*4882a593Smuzhiyun #define ID_VENDOR 1 248*4882a593Smuzhiyun #define ID_PRODUCT 2 249*4882a593Smuzhiyun #define ID_VERSION 3 250*4882a593Smuzhiyun 251*4882a593Smuzhiyun #define BUS_PCI 0x01 252*4882a593Smuzhiyun #define BUS_ISAPNP 0x02 253*4882a593Smuzhiyun #define BUS_USB 0x03 254*4882a593Smuzhiyun #define BUS_HIL 0x04 255*4882a593Smuzhiyun #define BUS_BLUETOOTH 0x05 256*4882a593Smuzhiyun #define BUS_VIRTUAL 0x06 257*4882a593Smuzhiyun 258*4882a593Smuzhiyun #define BUS_ISA 0x10 259*4882a593Smuzhiyun #define BUS_I8042 0x11 260*4882a593Smuzhiyun #define BUS_XTKBD 0x12 261*4882a593Smuzhiyun #define BUS_RS232 0x13 262*4882a593Smuzhiyun #define BUS_GAMEPORT 0x14 263*4882a593Smuzhiyun #define BUS_PARPORT 0x15 264*4882a593Smuzhiyun #define BUS_AMIGA 0x16 265*4882a593Smuzhiyun #define BUS_ADB 0x17 266*4882a593Smuzhiyun #define BUS_I2C 0x18 267*4882a593Smuzhiyun #define BUS_HOST 0x19 268*4882a593Smuzhiyun #define BUS_GSC 0x1A 269*4882a593Smuzhiyun #define BUS_ATARI 0x1B 270*4882a593Smuzhiyun #define BUS_SPI 0x1C 271*4882a593Smuzhiyun #define BUS_RMI 0x1D 272*4882a593Smuzhiyun #define BUS_CEC 0x1E 273*4882a593Smuzhiyun #define BUS_INTEL_ISHTP 0x1F 274*4882a593Smuzhiyun 275*4882a593Smuzhiyun /* 276*4882a593Smuzhiyun * MT_TOOL types 277*4882a593Smuzhiyun */ 278*4882a593Smuzhiyun #define MT_TOOL_FINGER 0x00 279*4882a593Smuzhiyun #define MT_TOOL_PEN 0x01 280*4882a593Smuzhiyun #define MT_TOOL_PALM 0x02 281*4882a593Smuzhiyun #define MT_TOOL_DIAL 0x0a 282*4882a593Smuzhiyun #define MT_TOOL_MAX 0x0f 283*4882a593Smuzhiyun 284*4882a593Smuzhiyun /* 285*4882a593Smuzhiyun * Values describing the status of a force-feedback effect 286*4882a593Smuzhiyun */ 287*4882a593Smuzhiyun #define FF_STATUS_STOPPED 0x00 288*4882a593Smuzhiyun #define FF_STATUS_PLAYING 0x01 289*4882a593Smuzhiyun #define FF_STATUS_MAX 0x01 290*4882a593Smuzhiyun 291*4882a593Smuzhiyun /* 292*4882a593Smuzhiyun * Structures used in ioctls to upload effects to a device 293*4882a593Smuzhiyun * They are pieces of a bigger structure (called ff_effect) 294*4882a593Smuzhiyun */ 295*4882a593Smuzhiyun 296*4882a593Smuzhiyun /* 297*4882a593Smuzhiyun * All duration values are expressed in ms. Values above 32767 ms (0x7fff) 298*4882a593Smuzhiyun * should not be used and have unspecified results. 299*4882a593Smuzhiyun */ 300*4882a593Smuzhiyun 301*4882a593Smuzhiyun /** 302*4882a593Smuzhiyun * struct ff_replay - defines scheduling of the force-feedback effect 303*4882a593Smuzhiyun * @length: duration of the effect 304*4882a593Smuzhiyun * @delay: delay before effect should start playing 305*4882a593Smuzhiyun */ 306*4882a593Smuzhiyun struct ff_replay { 307*4882a593Smuzhiyun __u16 length; 308*4882a593Smuzhiyun __u16 delay; 309*4882a593Smuzhiyun }; 310*4882a593Smuzhiyun 311*4882a593Smuzhiyun /** 312*4882a593Smuzhiyun * struct ff_trigger - defines what triggers the force-feedback effect 313*4882a593Smuzhiyun * @button: number of the button triggering the effect 314*4882a593Smuzhiyun * @interval: controls how soon the effect can be re-triggered 315*4882a593Smuzhiyun */ 316*4882a593Smuzhiyun struct ff_trigger { 317*4882a593Smuzhiyun __u16 button; 318*4882a593Smuzhiyun __u16 interval; 319*4882a593Smuzhiyun }; 320*4882a593Smuzhiyun 321*4882a593Smuzhiyun /** 322*4882a593Smuzhiyun * struct ff_envelope - generic force-feedback effect envelope 323*4882a593Smuzhiyun * @attack_length: duration of the attack (ms) 324*4882a593Smuzhiyun * @attack_level: level at the beginning of the attack 325*4882a593Smuzhiyun * @fade_length: duration of fade (ms) 326*4882a593Smuzhiyun * @fade_level: level at the end of fade 327*4882a593Smuzhiyun * 328*4882a593Smuzhiyun * The @attack_level and @fade_level are absolute values; when applying 329*4882a593Smuzhiyun * envelope force-feedback core will convert to positive/negative 330*4882a593Smuzhiyun * value based on polarity of the default level of the effect. 331*4882a593Smuzhiyun * Valid range for the attack and fade levels is 0x0000 - 0x7fff 332*4882a593Smuzhiyun */ 333*4882a593Smuzhiyun struct ff_envelope { 334*4882a593Smuzhiyun __u16 attack_length; 335*4882a593Smuzhiyun __u16 attack_level; 336*4882a593Smuzhiyun __u16 fade_length; 337*4882a593Smuzhiyun __u16 fade_level; 338*4882a593Smuzhiyun }; 339*4882a593Smuzhiyun 340*4882a593Smuzhiyun /** 341*4882a593Smuzhiyun * struct ff_constant_effect - defines parameters of a constant force-feedback effect 342*4882a593Smuzhiyun * @level: strength of the effect; may be negative 343*4882a593Smuzhiyun * @envelope: envelope data 344*4882a593Smuzhiyun */ 345*4882a593Smuzhiyun struct ff_constant_effect { 346*4882a593Smuzhiyun __s16 level; 347*4882a593Smuzhiyun struct ff_envelope envelope; 348*4882a593Smuzhiyun }; 349*4882a593Smuzhiyun 350*4882a593Smuzhiyun /** 351*4882a593Smuzhiyun * struct ff_ramp_effect - defines parameters of a ramp force-feedback effect 352*4882a593Smuzhiyun * @start_level: beginning strength of the effect; may be negative 353*4882a593Smuzhiyun * @end_level: final strength of the effect; may be negative 354*4882a593Smuzhiyun * @envelope: envelope data 355*4882a593Smuzhiyun */ 356*4882a593Smuzhiyun struct ff_ramp_effect { 357*4882a593Smuzhiyun __s16 start_level; 358*4882a593Smuzhiyun __s16 end_level; 359*4882a593Smuzhiyun struct ff_envelope envelope; 360*4882a593Smuzhiyun }; 361*4882a593Smuzhiyun 362*4882a593Smuzhiyun /** 363*4882a593Smuzhiyun * struct ff_condition_effect - defines a spring or friction force-feedback effect 364*4882a593Smuzhiyun * @right_saturation: maximum level when joystick moved all way to the right 365*4882a593Smuzhiyun * @left_saturation: same for the left side 366*4882a593Smuzhiyun * @right_coeff: controls how fast the force grows when the joystick moves 367*4882a593Smuzhiyun * to the right 368*4882a593Smuzhiyun * @left_coeff: same for the left side 369*4882a593Smuzhiyun * @deadband: size of the dead zone, where no force is produced 370*4882a593Smuzhiyun * @center: position of the dead zone 371*4882a593Smuzhiyun */ 372*4882a593Smuzhiyun struct ff_condition_effect { 373*4882a593Smuzhiyun __u16 right_saturation; 374*4882a593Smuzhiyun __u16 left_saturation; 375*4882a593Smuzhiyun 376*4882a593Smuzhiyun __s16 right_coeff; 377*4882a593Smuzhiyun __s16 left_coeff; 378*4882a593Smuzhiyun 379*4882a593Smuzhiyun __u16 deadband; 380*4882a593Smuzhiyun __s16 center; 381*4882a593Smuzhiyun }; 382*4882a593Smuzhiyun 383*4882a593Smuzhiyun /** 384*4882a593Smuzhiyun * struct ff_periodic_effect - defines parameters of a periodic force-feedback effect 385*4882a593Smuzhiyun * @waveform: kind of the effect (wave) 386*4882a593Smuzhiyun * @period: period of the wave (ms) 387*4882a593Smuzhiyun * @magnitude: peak value 388*4882a593Smuzhiyun * @offset: mean value of the wave (roughly) 389*4882a593Smuzhiyun * @phase: 'horizontal' shift 390*4882a593Smuzhiyun * @envelope: envelope data 391*4882a593Smuzhiyun * @custom_len: number of samples (FF_CUSTOM only) 392*4882a593Smuzhiyun * @custom_data: buffer of samples (FF_CUSTOM only) 393*4882a593Smuzhiyun * 394*4882a593Smuzhiyun * Known waveforms - FF_SQUARE, FF_TRIANGLE, FF_SINE, FF_SAW_UP, 395*4882a593Smuzhiyun * FF_SAW_DOWN, FF_CUSTOM. The exact syntax FF_CUSTOM is undefined 396*4882a593Smuzhiyun * for the time being as no driver supports it yet. 397*4882a593Smuzhiyun * 398*4882a593Smuzhiyun * Note: the data pointed by custom_data is copied by the driver. 399*4882a593Smuzhiyun * You can therefore dispose of the memory after the upload/update. 400*4882a593Smuzhiyun */ 401*4882a593Smuzhiyun struct ff_periodic_effect { 402*4882a593Smuzhiyun __u16 waveform; 403*4882a593Smuzhiyun __u16 period; 404*4882a593Smuzhiyun __s16 magnitude; 405*4882a593Smuzhiyun __s16 offset; 406*4882a593Smuzhiyun __u16 phase; 407*4882a593Smuzhiyun 408*4882a593Smuzhiyun struct ff_envelope envelope; 409*4882a593Smuzhiyun 410*4882a593Smuzhiyun __u32 custom_len; 411*4882a593Smuzhiyun __s16 __user *custom_data; 412*4882a593Smuzhiyun }; 413*4882a593Smuzhiyun 414*4882a593Smuzhiyun /** 415*4882a593Smuzhiyun * struct ff_rumble_effect - defines parameters of a periodic force-feedback effect 416*4882a593Smuzhiyun * @strong_magnitude: magnitude of the heavy motor 417*4882a593Smuzhiyun * @weak_magnitude: magnitude of the light one 418*4882a593Smuzhiyun * 419*4882a593Smuzhiyun * Some rumble pads have two motors of different weight. Strong_magnitude 420*4882a593Smuzhiyun * represents the magnitude of the vibration generated by the heavy one. 421*4882a593Smuzhiyun */ 422*4882a593Smuzhiyun struct ff_rumble_effect { 423*4882a593Smuzhiyun __u16 strong_magnitude; 424*4882a593Smuzhiyun __u16 weak_magnitude; 425*4882a593Smuzhiyun }; 426*4882a593Smuzhiyun 427*4882a593Smuzhiyun /** 428*4882a593Smuzhiyun * struct ff_effect - defines force feedback effect 429*4882a593Smuzhiyun * @type: type of the effect (FF_CONSTANT, FF_PERIODIC, FF_RAMP, FF_SPRING, 430*4882a593Smuzhiyun * FF_FRICTION, FF_DAMPER, FF_RUMBLE, FF_INERTIA, or FF_CUSTOM) 431*4882a593Smuzhiyun * @id: an unique id assigned to an effect 432*4882a593Smuzhiyun * @direction: direction of the effect 433*4882a593Smuzhiyun * @trigger: trigger conditions (struct ff_trigger) 434*4882a593Smuzhiyun * @replay: scheduling of the effect (struct ff_replay) 435*4882a593Smuzhiyun * @u: effect-specific structure (one of ff_constant_effect, ff_ramp_effect, 436*4882a593Smuzhiyun * ff_periodic_effect, ff_condition_effect, ff_rumble_effect) further 437*4882a593Smuzhiyun * defining effect parameters 438*4882a593Smuzhiyun * 439*4882a593Smuzhiyun * This structure is sent through ioctl from the application to the driver. 440*4882a593Smuzhiyun * To create a new effect application should set its @id to -1; the kernel 441*4882a593Smuzhiyun * will return assigned @id which can later be used to update or delete 442*4882a593Smuzhiyun * this effect. 443*4882a593Smuzhiyun * 444*4882a593Smuzhiyun * Direction of the effect is encoded as follows: 445*4882a593Smuzhiyun * 0 deg -> 0x0000 (down) 446*4882a593Smuzhiyun * 90 deg -> 0x4000 (left) 447*4882a593Smuzhiyun * 180 deg -> 0x8000 (up) 448*4882a593Smuzhiyun * 270 deg -> 0xC000 (right) 449*4882a593Smuzhiyun */ 450*4882a593Smuzhiyun struct ff_effect { 451*4882a593Smuzhiyun __u16 type; 452*4882a593Smuzhiyun __s16 id; 453*4882a593Smuzhiyun __u16 direction; 454*4882a593Smuzhiyun struct ff_trigger trigger; 455*4882a593Smuzhiyun struct ff_replay replay; 456*4882a593Smuzhiyun 457*4882a593Smuzhiyun union { 458*4882a593Smuzhiyun struct ff_constant_effect constant; 459*4882a593Smuzhiyun struct ff_ramp_effect ramp; 460*4882a593Smuzhiyun struct ff_periodic_effect periodic; 461*4882a593Smuzhiyun struct ff_condition_effect condition[2]; /* One for each axis */ 462*4882a593Smuzhiyun struct ff_rumble_effect rumble; 463*4882a593Smuzhiyun } u; 464*4882a593Smuzhiyun }; 465*4882a593Smuzhiyun 466*4882a593Smuzhiyun /* 467*4882a593Smuzhiyun * Force feedback effect types 468*4882a593Smuzhiyun */ 469*4882a593Smuzhiyun 470*4882a593Smuzhiyun #define FF_RUMBLE 0x50 471*4882a593Smuzhiyun #define FF_PERIODIC 0x51 472*4882a593Smuzhiyun #define FF_CONSTANT 0x52 473*4882a593Smuzhiyun #define FF_SPRING 0x53 474*4882a593Smuzhiyun #define FF_FRICTION 0x54 475*4882a593Smuzhiyun #define FF_DAMPER 0x55 476*4882a593Smuzhiyun #define FF_INERTIA 0x56 477*4882a593Smuzhiyun #define FF_RAMP 0x57 478*4882a593Smuzhiyun 479*4882a593Smuzhiyun #define FF_EFFECT_MIN FF_RUMBLE 480*4882a593Smuzhiyun #define FF_EFFECT_MAX FF_RAMP 481*4882a593Smuzhiyun 482*4882a593Smuzhiyun /* 483*4882a593Smuzhiyun * Force feedback periodic effect types 484*4882a593Smuzhiyun */ 485*4882a593Smuzhiyun 486*4882a593Smuzhiyun #define FF_SQUARE 0x58 487*4882a593Smuzhiyun #define FF_TRIANGLE 0x59 488*4882a593Smuzhiyun #define FF_SINE 0x5a 489*4882a593Smuzhiyun #define FF_SAW_UP 0x5b 490*4882a593Smuzhiyun #define FF_SAW_DOWN 0x5c 491*4882a593Smuzhiyun #define FF_CUSTOM 0x5d 492*4882a593Smuzhiyun 493*4882a593Smuzhiyun #define FF_WAVEFORM_MIN FF_SQUARE 494*4882a593Smuzhiyun #define FF_WAVEFORM_MAX FF_CUSTOM 495*4882a593Smuzhiyun 496*4882a593Smuzhiyun /* 497*4882a593Smuzhiyun * Set ff device properties 498*4882a593Smuzhiyun */ 499*4882a593Smuzhiyun 500*4882a593Smuzhiyun #define FF_GAIN 0x60 501*4882a593Smuzhiyun #define FF_AUTOCENTER 0x61 502*4882a593Smuzhiyun 503*4882a593Smuzhiyun /* 504*4882a593Smuzhiyun * ff->playback(effect_id = FF_GAIN) is the first effect_id to 505*4882a593Smuzhiyun * cause a collision with another ff method, in this case ff->set_gain(). 506*4882a593Smuzhiyun * Therefore the greatest safe value for effect_id is FF_GAIN - 1, 507*4882a593Smuzhiyun * and thus the total number of effects should never exceed FF_GAIN. 508*4882a593Smuzhiyun */ 509*4882a593Smuzhiyun #define FF_MAX_EFFECTS FF_GAIN 510*4882a593Smuzhiyun 511*4882a593Smuzhiyun #define FF_MAX 0x7f 512*4882a593Smuzhiyun #define FF_CNT (FF_MAX+1) 513*4882a593Smuzhiyun 514*4882a593Smuzhiyun #endif /* _UAPI_INPUT_H */ 515