12fe7c318SGerd Hoffmann /* 22fe7c318SGerd Hoffmann * Copyright (c) 1999-2002 Vojtech Pavlik 32fe7c318SGerd Hoffmann * 42fe7c318SGerd Hoffmann * This program is free software; you can redistribute it and/or modify it 52fe7c318SGerd Hoffmann * under the terms of the GNU General Public License version 2 as published by 62fe7c318SGerd Hoffmann * the Free Software Foundation. 72fe7c318SGerd Hoffmann */ 82fe7c318SGerd Hoffmann #ifndef _INPUT_H 92fe7c318SGerd Hoffmann #define _INPUT_H 102fe7c318SGerd Hoffmann 112fe7c318SGerd Hoffmann 122fe7c318SGerd Hoffmann #include <sys/time.h> 132fe7c318SGerd Hoffmann #include <sys/types.h> 142fe7c318SGerd Hoffmann #include "standard-headers/linux/types.h" 152fe7c318SGerd Hoffmann 16fff02bc0SPaolo Bonzini #include "standard-headers/linux/input-event-codes.h" 172fe7c318SGerd Hoffmann 182fe7c318SGerd Hoffmann /* 192fe7c318SGerd Hoffmann * The event structure itself 202fe7c318SGerd Hoffmann */ 212fe7c318SGerd Hoffmann 222fe7c318SGerd Hoffmann struct input_event { 232fe7c318SGerd Hoffmann struct timeval time; 242fe7c318SGerd Hoffmann uint16_t type; 252fe7c318SGerd Hoffmann uint16_t code; 262fe7c318SGerd Hoffmann int32_t value; 272fe7c318SGerd Hoffmann }; 282fe7c318SGerd Hoffmann 292fe7c318SGerd Hoffmann /* 302fe7c318SGerd Hoffmann * Protocol version. 312fe7c318SGerd Hoffmann */ 322fe7c318SGerd Hoffmann 332fe7c318SGerd Hoffmann #define EV_VERSION 0x010001 342fe7c318SGerd Hoffmann 352fe7c318SGerd Hoffmann /* 362fe7c318SGerd Hoffmann * IOCTLs (0x00 - 0x7f) 372fe7c318SGerd Hoffmann */ 382fe7c318SGerd Hoffmann 392fe7c318SGerd Hoffmann struct input_id { 402fe7c318SGerd Hoffmann uint16_t bustype; 412fe7c318SGerd Hoffmann uint16_t vendor; 422fe7c318SGerd Hoffmann uint16_t product; 432fe7c318SGerd Hoffmann uint16_t version; 442fe7c318SGerd Hoffmann }; 452fe7c318SGerd Hoffmann 462fe7c318SGerd Hoffmann /** 472fe7c318SGerd Hoffmann * struct input_absinfo - used by EVIOCGABS/EVIOCSABS ioctls 482fe7c318SGerd Hoffmann * @value: latest reported value for the axis. 492fe7c318SGerd Hoffmann * @minimum: specifies minimum value for the axis. 502fe7c318SGerd Hoffmann * @maximum: specifies maximum value for the axis. 512fe7c318SGerd Hoffmann * @fuzz: specifies fuzz value that is used to filter noise from 522fe7c318SGerd Hoffmann * the event stream. 532fe7c318SGerd Hoffmann * @flat: values that are within this value will be discarded by 542fe7c318SGerd Hoffmann * joydev interface and reported as 0 instead. 552fe7c318SGerd Hoffmann * @resolution: specifies resolution for the values reported for 562fe7c318SGerd Hoffmann * the axis. 572fe7c318SGerd Hoffmann * 582fe7c318SGerd Hoffmann * Note that input core does not clamp reported values to the 592fe7c318SGerd Hoffmann * [minimum, maximum] limits, such task is left to userspace. 602fe7c318SGerd Hoffmann * 61*74c98e20SCornelia Huck * The default resolution for main axes (ABS_X, ABS_Y, ABS_Z) 62*74c98e20SCornelia Huck * is reported in units per millimeter (units/mm), resolution 63*74c98e20SCornelia Huck * for rotational axes (ABS_RX, ABS_RY, ABS_RZ) is reported 64*74c98e20SCornelia Huck * in units per radian. 65*74c98e20SCornelia Huck * When INPUT_PROP_ACCELEROMETER is set the resolution changes. 66*74c98e20SCornelia Huck * The main axes (ABS_X, ABS_Y, ABS_Z) are then reported in 67*74c98e20SCornelia Huck * in units per g (units/g) and in units per degree per second 68*74c98e20SCornelia Huck * (units/deg/s) for rotational axes (ABS_RX, ABS_RY, ABS_RZ). 692fe7c318SGerd Hoffmann */ 702fe7c318SGerd Hoffmann struct input_absinfo { 712fe7c318SGerd Hoffmann int32_t value; 722fe7c318SGerd Hoffmann int32_t minimum; 732fe7c318SGerd Hoffmann int32_t maximum; 742fe7c318SGerd Hoffmann int32_t fuzz; 752fe7c318SGerd Hoffmann int32_t flat; 762fe7c318SGerd Hoffmann int32_t resolution; 772fe7c318SGerd Hoffmann }; 782fe7c318SGerd Hoffmann 792fe7c318SGerd Hoffmann /** 802fe7c318SGerd Hoffmann * struct input_keymap_entry - used by EVIOCGKEYCODE/EVIOCSKEYCODE ioctls 812fe7c318SGerd Hoffmann * @scancode: scancode represented in machine-endian form. 822fe7c318SGerd Hoffmann * @len: length of the scancode that resides in @scancode buffer. 832fe7c318SGerd Hoffmann * @index: index in the keymap, may be used instead of scancode 842fe7c318SGerd Hoffmann * @flags: allows to specify how kernel should handle the request. For 852fe7c318SGerd Hoffmann * example, setting INPUT_KEYMAP_BY_INDEX flag indicates that kernel 862fe7c318SGerd Hoffmann * should perform lookup in keymap by @index instead of @scancode 872fe7c318SGerd Hoffmann * @keycode: key code assigned to this scancode 882fe7c318SGerd Hoffmann * 892fe7c318SGerd Hoffmann * The structure is used to retrieve and modify keymap data. Users have 902fe7c318SGerd Hoffmann * option of performing lookup either by @scancode itself or by @index 912fe7c318SGerd Hoffmann * in keymap entry. EVIOCGKEYCODE will also return scancode or index 922fe7c318SGerd Hoffmann * (depending on which element was used to perform lookup). 932fe7c318SGerd Hoffmann */ 942fe7c318SGerd Hoffmann struct input_keymap_entry { 952fe7c318SGerd Hoffmann #define INPUT_KEYMAP_BY_INDEX (1 << 0) 962fe7c318SGerd Hoffmann uint8_t flags; 972fe7c318SGerd Hoffmann uint8_t len; 982fe7c318SGerd Hoffmann uint16_t index; 992fe7c318SGerd Hoffmann uint32_t keycode; 1002fe7c318SGerd Hoffmann uint8_t scancode[32]; 1012fe7c318SGerd Hoffmann }; 1022fe7c318SGerd Hoffmann 103fff02bc0SPaolo Bonzini struct input_mask { 104fff02bc0SPaolo Bonzini uint32_t type; 105fff02bc0SPaolo Bonzini uint32_t codes_size; 106fff02bc0SPaolo Bonzini uint64_t codes_ptr; 107fff02bc0SPaolo Bonzini }; 108fff02bc0SPaolo Bonzini 1092fe7c318SGerd Hoffmann #define EVIOCGVERSION _IOR('E', 0x01, int) /* get driver version */ 1102fe7c318SGerd Hoffmann #define EVIOCGID _IOR('E', 0x02, struct input_id) /* get device ID */ 1112fe7c318SGerd Hoffmann #define EVIOCGREP _IOR('E', 0x03, unsigned int[2]) /* get repeat settings */ 1122fe7c318SGerd Hoffmann #define EVIOCSREP _IOW('E', 0x03, unsigned int[2]) /* set repeat settings */ 1132fe7c318SGerd Hoffmann 1142fe7c318SGerd Hoffmann #define EVIOCGKEYCODE _IOR('E', 0x04, unsigned int[2]) /* get keycode */ 1152fe7c318SGerd Hoffmann #define EVIOCGKEYCODE_V2 _IOR('E', 0x04, struct input_keymap_entry) 1162fe7c318SGerd Hoffmann #define EVIOCSKEYCODE _IOW('E', 0x04, unsigned int[2]) /* set keycode */ 1172fe7c318SGerd Hoffmann #define EVIOCSKEYCODE_V2 _IOW('E', 0x04, struct input_keymap_entry) 1182fe7c318SGerd Hoffmann 1192fe7c318SGerd Hoffmann #define EVIOCGNAME(len) _IOC(_IOC_READ, 'E', 0x06, len) /* get device name */ 1202fe7c318SGerd Hoffmann #define EVIOCGPHYS(len) _IOC(_IOC_READ, 'E', 0x07, len) /* get physical location */ 1212fe7c318SGerd Hoffmann #define EVIOCGUNIQ(len) _IOC(_IOC_READ, 'E', 0x08, len) /* get unique identifier */ 1222fe7c318SGerd Hoffmann #define EVIOCGPROP(len) _IOC(_IOC_READ, 'E', 0x09, len) /* get device properties */ 1232fe7c318SGerd Hoffmann 1242fe7c318SGerd Hoffmann /** 1252fe7c318SGerd Hoffmann * EVIOCGMTSLOTS(len) - get MT slot values 1262fe7c318SGerd Hoffmann * @len: size of the data buffer in bytes 1272fe7c318SGerd Hoffmann * 1282fe7c318SGerd Hoffmann * The ioctl buffer argument should be binary equivalent to 1292fe7c318SGerd Hoffmann * 1302fe7c318SGerd Hoffmann * struct input_mt_request_layout { 1312fe7c318SGerd Hoffmann * uint32_t code; 1322fe7c318SGerd Hoffmann * int32_t values[num_slots]; 1332fe7c318SGerd Hoffmann * }; 1342fe7c318SGerd Hoffmann * 1352fe7c318SGerd Hoffmann * where num_slots is the (arbitrary) number of MT slots to extract. 1362fe7c318SGerd Hoffmann * 1372fe7c318SGerd Hoffmann * The ioctl size argument (len) is the size of the buffer, which 1382fe7c318SGerd Hoffmann * should satisfy len = (num_slots + 1) * sizeof(int32_t). If len is 1392fe7c318SGerd Hoffmann * too small to fit all available slots, the first num_slots are 1402fe7c318SGerd Hoffmann * returned. 1412fe7c318SGerd Hoffmann * 1422fe7c318SGerd Hoffmann * Before the call, code is set to the wanted ABS_MT event type. On 1432fe7c318SGerd Hoffmann * return, values[] is filled with the slot values for the specified 1442fe7c318SGerd Hoffmann * ABS_MT code. 1452fe7c318SGerd Hoffmann * 1462fe7c318SGerd Hoffmann * If the request code is not an ABS_MT value, -EINVAL is returned. 1472fe7c318SGerd Hoffmann */ 1482fe7c318SGerd Hoffmann #define EVIOCGMTSLOTS(len) _IOC(_IOC_READ, 'E', 0x0a, len) 1492fe7c318SGerd Hoffmann 1502fe7c318SGerd Hoffmann #define EVIOCGKEY(len) _IOC(_IOC_READ, 'E', 0x18, len) /* get global key state */ 1512fe7c318SGerd Hoffmann #define EVIOCGLED(len) _IOC(_IOC_READ, 'E', 0x19, len) /* get all LEDs */ 1522fe7c318SGerd Hoffmann #define EVIOCGSND(len) _IOC(_IOC_READ, 'E', 0x1a, len) /* get all sounds status */ 1532fe7c318SGerd Hoffmann #define EVIOCGSW(len) _IOC(_IOC_READ, 'E', 0x1b, len) /* get all switch states */ 1542fe7c318SGerd Hoffmann 1552fe7c318SGerd Hoffmann #define EVIOCGBIT(ev,len) _IOC(_IOC_READ, 'E', 0x20 + (ev), len) /* get event bits */ 1562fe7c318SGerd Hoffmann #define EVIOCGABS(abs) _IOR('E', 0x40 + (abs), struct input_absinfo) /* get abs value/limits */ 1572fe7c318SGerd Hoffmann #define EVIOCSABS(abs) _IOW('E', 0xc0 + (abs), struct input_absinfo) /* set abs value/limits */ 1582fe7c318SGerd Hoffmann 159fff02bc0SPaolo Bonzini #define EVIOCSFF _IOW('E', 0x80, struct ff_effect) /* send a force effect to a force feedback device */ 1602fe7c318SGerd Hoffmann #define EVIOCRMFF _IOW('E', 0x81, int) /* Erase a force effect */ 1612fe7c318SGerd Hoffmann #define EVIOCGEFFECTS _IOR('E', 0x84, int) /* Report number of effects playable at the same time */ 1622fe7c318SGerd Hoffmann 1632fe7c318SGerd Hoffmann #define EVIOCGRAB _IOW('E', 0x90, int) /* Grab/Release device */ 1642fe7c318SGerd Hoffmann #define EVIOCREVOKE _IOW('E', 0x91, int) /* Revoke device access */ 1652fe7c318SGerd Hoffmann 166fff02bc0SPaolo Bonzini /** 167fff02bc0SPaolo Bonzini * EVIOCGMASK - Retrieve current event mask 1682fe7c318SGerd Hoffmann * 169fff02bc0SPaolo Bonzini * This ioctl allows user to retrieve the current event mask for specific 170fff02bc0SPaolo Bonzini * event type. The argument must be of type "struct input_mask" and 171fff02bc0SPaolo Bonzini * specifies the event type to query, the address of the receive buffer and 172fff02bc0SPaolo Bonzini * the size of the receive buffer. 173fff02bc0SPaolo Bonzini * 174fff02bc0SPaolo Bonzini * The event mask is a per-client mask that specifies which events are 175fff02bc0SPaolo Bonzini * forwarded to the client. Each event code is represented by a single bit 176fff02bc0SPaolo Bonzini * in the event mask. If the bit is set, the event is passed to the client 177fff02bc0SPaolo Bonzini * normally. Otherwise, the event is filtered and will never be queued on 178fff02bc0SPaolo Bonzini * the client's receive buffer. 179fff02bc0SPaolo Bonzini * 180fff02bc0SPaolo Bonzini * Event masks do not affect global state of the input device. They only 181fff02bc0SPaolo Bonzini * affect the file descriptor they are applied to. 182fff02bc0SPaolo Bonzini * 183fff02bc0SPaolo Bonzini * The default event mask for a client has all bits set, i.e. all events 184fff02bc0SPaolo Bonzini * are forwarded to the client. If the kernel is queried for an unknown 185fff02bc0SPaolo Bonzini * event type or if the receive buffer is larger than the number of 186fff02bc0SPaolo Bonzini * event codes known to the kernel, the kernel returns all zeroes for those 187fff02bc0SPaolo Bonzini * codes. 188fff02bc0SPaolo Bonzini * 189fff02bc0SPaolo Bonzini * At maximum, codes_size bytes are copied. 190fff02bc0SPaolo Bonzini * 191fff02bc0SPaolo Bonzini * This ioctl may fail with ENODEV in case the file is revoked, EFAULT 192fff02bc0SPaolo Bonzini * if the receive-buffer points to invalid memory, or EINVAL if the kernel 193fff02bc0SPaolo Bonzini * does not implement the ioctl. 1942fe7c318SGerd Hoffmann */ 195fff02bc0SPaolo Bonzini #define EVIOCGMASK _IOR('E', 0x92, struct input_mask) /* Get event-masks */ 1962fe7c318SGerd Hoffmann 197fff02bc0SPaolo Bonzini /** 198fff02bc0SPaolo Bonzini * EVIOCSMASK - Set event mask 199fff02bc0SPaolo Bonzini * 200fff02bc0SPaolo Bonzini * This ioctl is the counterpart to EVIOCGMASK. Instead of receiving the 201fff02bc0SPaolo Bonzini * current event mask, this changes the client's event mask for a specific 202fff02bc0SPaolo Bonzini * type. See EVIOCGMASK for a description of event-masks and the 203fff02bc0SPaolo Bonzini * argument-type. 204fff02bc0SPaolo Bonzini * 205fff02bc0SPaolo Bonzini * This ioctl provides full forward compatibility. If the passed event type 206fff02bc0SPaolo Bonzini * is unknown to the kernel, or if the number of event codes specified in 207fff02bc0SPaolo Bonzini * the mask is bigger than what is known to the kernel, the ioctl is still 208fff02bc0SPaolo Bonzini * accepted and applied. However, any unknown codes are left untouched and 209fff02bc0SPaolo Bonzini * stay cleared. That means, the kernel always filters unknown codes 210fff02bc0SPaolo Bonzini * regardless of what the client requests. If the new mask doesn't cover 211fff02bc0SPaolo Bonzini * all known event-codes, all remaining codes are automatically cleared and 212fff02bc0SPaolo Bonzini * thus filtered. 213fff02bc0SPaolo Bonzini * 214fff02bc0SPaolo Bonzini * This ioctl may fail with ENODEV in case the file is revoked. EFAULT is 215fff02bc0SPaolo Bonzini * returned if the receive-buffer points to invalid memory. EINVAL is returned 216fff02bc0SPaolo Bonzini * if the kernel does not implement the ioctl. 2172fe7c318SGerd Hoffmann */ 218fff02bc0SPaolo Bonzini #define EVIOCSMASK _IOW('E', 0x93, struct input_mask) /* Set event-masks */ 2192fe7c318SGerd Hoffmann 220fff02bc0SPaolo Bonzini #define EVIOCSCLOCKID _IOW('E', 0xa0, int) /* Set clockid to be used for timestamps */ 2212fe7c318SGerd Hoffmann 2222fe7c318SGerd Hoffmann /* 2232fe7c318SGerd Hoffmann * IDs. 2242fe7c318SGerd Hoffmann */ 2252fe7c318SGerd Hoffmann 2262fe7c318SGerd Hoffmann #define ID_BUS 0 2272fe7c318SGerd Hoffmann #define ID_VENDOR 1 2282fe7c318SGerd Hoffmann #define ID_PRODUCT 2 2292fe7c318SGerd Hoffmann #define ID_VERSION 3 2302fe7c318SGerd Hoffmann 2312fe7c318SGerd Hoffmann #define BUS_PCI 0x01 2322fe7c318SGerd Hoffmann #define BUS_ISAPNP 0x02 2332fe7c318SGerd Hoffmann #define BUS_USB 0x03 2342fe7c318SGerd Hoffmann #define BUS_HIL 0x04 2352fe7c318SGerd Hoffmann #define BUS_BLUETOOTH 0x05 2362fe7c318SGerd Hoffmann #define BUS_VIRTUAL 0x06 2372fe7c318SGerd Hoffmann 2382fe7c318SGerd Hoffmann #define BUS_ISA 0x10 2392fe7c318SGerd Hoffmann #define BUS_I8042 0x11 2402fe7c318SGerd Hoffmann #define BUS_XTKBD 0x12 2412fe7c318SGerd Hoffmann #define BUS_RS232 0x13 2422fe7c318SGerd Hoffmann #define BUS_GAMEPORT 0x14 2432fe7c318SGerd Hoffmann #define BUS_PARPORT 0x15 2442fe7c318SGerd Hoffmann #define BUS_AMIGA 0x16 2452fe7c318SGerd Hoffmann #define BUS_ADB 0x17 2462fe7c318SGerd Hoffmann #define BUS_I2C 0x18 2472fe7c318SGerd Hoffmann #define BUS_HOST 0x19 2482fe7c318SGerd Hoffmann #define BUS_GSC 0x1A 2492fe7c318SGerd Hoffmann #define BUS_ATARI 0x1B 2502fe7c318SGerd Hoffmann #define BUS_SPI 0x1C 251b89485a5SPaolo Bonzini #define BUS_RMI 0x1D 252dbdfea92SCornelia Huck #define BUS_CEC 0x1E 253bc204035SMarcelo Tosatti #define BUS_INTEL_ISHTP 0x1F 2542fe7c318SGerd Hoffmann 2552fe7c318SGerd Hoffmann /* 2562fe7c318SGerd Hoffmann * MT_TOOL types 2572fe7c318SGerd Hoffmann */ 2582fe7c318SGerd Hoffmann #define MT_TOOL_FINGER 0 2592fe7c318SGerd Hoffmann #define MT_TOOL_PEN 1 26025b8b39bSAlexey Kardashevskiy #define MT_TOOL_PALM 2 26125b8b39bSAlexey Kardashevskiy #define MT_TOOL_MAX 2 2622fe7c318SGerd Hoffmann 2632fe7c318SGerd Hoffmann /* 2642fe7c318SGerd Hoffmann * Values describing the status of a force-feedback effect 2652fe7c318SGerd Hoffmann */ 2662fe7c318SGerd Hoffmann #define FF_STATUS_STOPPED 0x00 2672fe7c318SGerd Hoffmann #define FF_STATUS_PLAYING 0x01 2682fe7c318SGerd Hoffmann #define FF_STATUS_MAX 0x01 2692fe7c318SGerd Hoffmann 2702fe7c318SGerd Hoffmann /* 2712fe7c318SGerd Hoffmann * Structures used in ioctls to upload effects to a device 2722fe7c318SGerd Hoffmann * They are pieces of a bigger structure (called ff_effect) 2732fe7c318SGerd Hoffmann */ 2742fe7c318SGerd Hoffmann 2752fe7c318SGerd Hoffmann /* 2762fe7c318SGerd Hoffmann * All duration values are expressed in ms. Values above 32767 ms (0x7fff) 2772fe7c318SGerd Hoffmann * should not be used and have unspecified results. 2782fe7c318SGerd Hoffmann */ 2792fe7c318SGerd Hoffmann 2802fe7c318SGerd Hoffmann /** 2812fe7c318SGerd Hoffmann * struct ff_replay - defines scheduling of the force-feedback effect 2822fe7c318SGerd Hoffmann * @length: duration of the effect 2832fe7c318SGerd Hoffmann * @delay: delay before effect should start playing 2842fe7c318SGerd Hoffmann */ 2852fe7c318SGerd Hoffmann struct ff_replay { 2862fe7c318SGerd Hoffmann uint16_t length; 2872fe7c318SGerd Hoffmann uint16_t delay; 2882fe7c318SGerd Hoffmann }; 2892fe7c318SGerd Hoffmann 2902fe7c318SGerd Hoffmann /** 2912fe7c318SGerd Hoffmann * struct ff_trigger - defines what triggers the force-feedback effect 2922fe7c318SGerd Hoffmann * @button: number of the button triggering the effect 2932fe7c318SGerd Hoffmann * @interval: controls how soon the effect can be re-triggered 2942fe7c318SGerd Hoffmann */ 2952fe7c318SGerd Hoffmann struct ff_trigger { 2962fe7c318SGerd Hoffmann uint16_t button; 2972fe7c318SGerd Hoffmann uint16_t interval; 2982fe7c318SGerd Hoffmann }; 2992fe7c318SGerd Hoffmann 3002fe7c318SGerd Hoffmann /** 3012fe7c318SGerd Hoffmann * struct ff_envelope - generic force-feedback effect envelope 3022fe7c318SGerd Hoffmann * @attack_length: duration of the attack (ms) 3032fe7c318SGerd Hoffmann * @attack_level: level at the beginning of the attack 3042fe7c318SGerd Hoffmann * @fade_length: duration of fade (ms) 3052fe7c318SGerd Hoffmann * @fade_level: level at the end of fade 3062fe7c318SGerd Hoffmann * 3072fe7c318SGerd Hoffmann * The @attack_level and @fade_level are absolute values; when applying 3082fe7c318SGerd Hoffmann * envelope force-feedback core will convert to positive/negative 3092fe7c318SGerd Hoffmann * value based on polarity of the default level of the effect. 3102fe7c318SGerd Hoffmann * Valid range for the attack and fade levels is 0x0000 - 0x7fff 3112fe7c318SGerd Hoffmann */ 3122fe7c318SGerd Hoffmann struct ff_envelope { 3132fe7c318SGerd Hoffmann uint16_t attack_length; 3142fe7c318SGerd Hoffmann uint16_t attack_level; 3152fe7c318SGerd Hoffmann uint16_t fade_length; 3162fe7c318SGerd Hoffmann uint16_t fade_level; 3172fe7c318SGerd Hoffmann }; 3182fe7c318SGerd Hoffmann 3192fe7c318SGerd Hoffmann /** 3202fe7c318SGerd Hoffmann * struct ff_constant_effect - defines parameters of a constant force-feedback effect 3212fe7c318SGerd Hoffmann * @level: strength of the effect; may be negative 3222fe7c318SGerd Hoffmann * @envelope: envelope data 3232fe7c318SGerd Hoffmann */ 3242fe7c318SGerd Hoffmann struct ff_constant_effect { 3252fe7c318SGerd Hoffmann int16_t level; 3262fe7c318SGerd Hoffmann struct ff_envelope envelope; 3272fe7c318SGerd Hoffmann }; 3282fe7c318SGerd Hoffmann 3292fe7c318SGerd Hoffmann /** 3302fe7c318SGerd Hoffmann * struct ff_ramp_effect - defines parameters of a ramp force-feedback effect 3312fe7c318SGerd Hoffmann * @start_level: beginning strength of the effect; may be negative 3322fe7c318SGerd Hoffmann * @end_level: final strength of the effect; may be negative 3332fe7c318SGerd Hoffmann * @envelope: envelope data 3342fe7c318SGerd Hoffmann */ 3352fe7c318SGerd Hoffmann struct ff_ramp_effect { 3362fe7c318SGerd Hoffmann int16_t start_level; 3372fe7c318SGerd Hoffmann int16_t end_level; 3382fe7c318SGerd Hoffmann struct ff_envelope envelope; 3392fe7c318SGerd Hoffmann }; 3402fe7c318SGerd Hoffmann 3412fe7c318SGerd Hoffmann /** 3422fe7c318SGerd Hoffmann * struct ff_condition_effect - defines a spring or friction force-feedback effect 3432fe7c318SGerd Hoffmann * @right_saturation: maximum level when joystick moved all way to the right 3442fe7c318SGerd Hoffmann * @left_saturation: same for the left side 3452fe7c318SGerd Hoffmann * @right_coeff: controls how fast the force grows when the joystick moves 3462fe7c318SGerd Hoffmann * to the right 3472fe7c318SGerd Hoffmann * @left_coeff: same for the left side 3482fe7c318SGerd Hoffmann * @deadband: size of the dead zone, where no force is produced 3492fe7c318SGerd Hoffmann * @center: position of the dead zone 3502fe7c318SGerd Hoffmann */ 3512fe7c318SGerd Hoffmann struct ff_condition_effect { 3522fe7c318SGerd Hoffmann uint16_t right_saturation; 3532fe7c318SGerd Hoffmann uint16_t left_saturation; 3542fe7c318SGerd Hoffmann 3552fe7c318SGerd Hoffmann int16_t right_coeff; 3562fe7c318SGerd Hoffmann int16_t left_coeff; 3572fe7c318SGerd Hoffmann 3582fe7c318SGerd Hoffmann uint16_t deadband; 3592fe7c318SGerd Hoffmann int16_t center; 3602fe7c318SGerd Hoffmann }; 3612fe7c318SGerd Hoffmann 3622fe7c318SGerd Hoffmann /** 3632fe7c318SGerd Hoffmann * struct ff_periodic_effect - defines parameters of a periodic force-feedback effect 3642fe7c318SGerd Hoffmann * @waveform: kind of the effect (wave) 3652fe7c318SGerd Hoffmann * @period: period of the wave (ms) 3662fe7c318SGerd Hoffmann * @magnitude: peak value 3672fe7c318SGerd Hoffmann * @offset: mean value of the wave (roughly) 3682fe7c318SGerd Hoffmann * @phase: 'horizontal' shift 3692fe7c318SGerd Hoffmann * @envelope: envelope data 3702fe7c318SGerd Hoffmann * @custom_len: number of samples (FF_CUSTOM only) 3712fe7c318SGerd Hoffmann * @custom_data: buffer of samples (FF_CUSTOM only) 3722fe7c318SGerd Hoffmann * 3732fe7c318SGerd Hoffmann * Known waveforms - FF_SQUARE, FF_TRIANGLE, FF_SINE, FF_SAW_UP, 3742fe7c318SGerd Hoffmann * FF_SAW_DOWN, FF_CUSTOM. The exact syntax FF_CUSTOM is undefined 3752fe7c318SGerd Hoffmann * for the time being as no driver supports it yet. 3762fe7c318SGerd Hoffmann * 3772fe7c318SGerd Hoffmann * Note: the data pointed by custom_data is copied by the driver. 3782fe7c318SGerd Hoffmann * You can therefore dispose of the memory after the upload/update. 3792fe7c318SGerd Hoffmann */ 3802fe7c318SGerd Hoffmann struct ff_periodic_effect { 3812fe7c318SGerd Hoffmann uint16_t waveform; 3822fe7c318SGerd Hoffmann uint16_t period; 3832fe7c318SGerd Hoffmann int16_t magnitude; 3842fe7c318SGerd Hoffmann int16_t offset; 3852fe7c318SGerd Hoffmann uint16_t phase; 3862fe7c318SGerd Hoffmann 3872fe7c318SGerd Hoffmann struct ff_envelope envelope; 3882fe7c318SGerd Hoffmann 3892fe7c318SGerd Hoffmann uint32_t custom_len; 3902fe7c318SGerd Hoffmann int16_t *custom_data; 3912fe7c318SGerd Hoffmann }; 3922fe7c318SGerd Hoffmann 3932fe7c318SGerd Hoffmann /** 3942fe7c318SGerd Hoffmann * struct ff_rumble_effect - defines parameters of a periodic force-feedback effect 3952fe7c318SGerd Hoffmann * @strong_magnitude: magnitude of the heavy motor 3962fe7c318SGerd Hoffmann * @weak_magnitude: magnitude of the light one 3972fe7c318SGerd Hoffmann * 3982fe7c318SGerd Hoffmann * Some rumble pads have two motors of different weight. Strong_magnitude 3992fe7c318SGerd Hoffmann * represents the magnitude of the vibration generated by the heavy one. 4002fe7c318SGerd Hoffmann */ 4012fe7c318SGerd Hoffmann struct ff_rumble_effect { 4022fe7c318SGerd Hoffmann uint16_t strong_magnitude; 4032fe7c318SGerd Hoffmann uint16_t weak_magnitude; 4042fe7c318SGerd Hoffmann }; 4052fe7c318SGerd Hoffmann 4062fe7c318SGerd Hoffmann /** 4072fe7c318SGerd Hoffmann * struct ff_effect - defines force feedback effect 4082fe7c318SGerd Hoffmann * @type: type of the effect (FF_CONSTANT, FF_PERIODIC, FF_RAMP, FF_SPRING, 4092fe7c318SGerd Hoffmann * FF_FRICTION, FF_DAMPER, FF_RUMBLE, FF_INERTIA, or FF_CUSTOM) 4102fe7c318SGerd Hoffmann * @id: an unique id assigned to an effect 4112fe7c318SGerd Hoffmann * @direction: direction of the effect 4122fe7c318SGerd Hoffmann * @trigger: trigger conditions (struct ff_trigger) 4132fe7c318SGerd Hoffmann * @replay: scheduling of the effect (struct ff_replay) 4142fe7c318SGerd Hoffmann * @u: effect-specific structure (one of ff_constant_effect, ff_ramp_effect, 4152fe7c318SGerd Hoffmann * ff_periodic_effect, ff_condition_effect, ff_rumble_effect) further 4162fe7c318SGerd Hoffmann * defining effect parameters 4172fe7c318SGerd Hoffmann * 4182fe7c318SGerd Hoffmann * This structure is sent through ioctl from the application to the driver. 4192fe7c318SGerd Hoffmann * To create a new effect application should set its @id to -1; the kernel 4202fe7c318SGerd Hoffmann * will return assigned @id which can later be used to update or delete 4212fe7c318SGerd Hoffmann * this effect. 4222fe7c318SGerd Hoffmann * 4232fe7c318SGerd Hoffmann * Direction of the effect is encoded as follows: 4242fe7c318SGerd Hoffmann * 0 deg -> 0x0000 (down) 4252fe7c318SGerd Hoffmann * 90 deg -> 0x4000 (left) 4262fe7c318SGerd Hoffmann * 180 deg -> 0x8000 (up) 4272fe7c318SGerd Hoffmann * 270 deg -> 0xC000 (right) 4282fe7c318SGerd Hoffmann */ 4292fe7c318SGerd Hoffmann struct ff_effect { 4302fe7c318SGerd Hoffmann uint16_t type; 4312fe7c318SGerd Hoffmann int16_t id; 4322fe7c318SGerd Hoffmann uint16_t direction; 4332fe7c318SGerd Hoffmann struct ff_trigger trigger; 4342fe7c318SGerd Hoffmann struct ff_replay replay; 4352fe7c318SGerd Hoffmann 4362fe7c318SGerd Hoffmann union { 4372fe7c318SGerd Hoffmann struct ff_constant_effect constant; 4382fe7c318SGerd Hoffmann struct ff_ramp_effect ramp; 4392fe7c318SGerd Hoffmann struct ff_periodic_effect periodic; 4402fe7c318SGerd Hoffmann struct ff_condition_effect condition[2]; /* One for each axis */ 4412fe7c318SGerd Hoffmann struct ff_rumble_effect rumble; 4422fe7c318SGerd Hoffmann } u; 4432fe7c318SGerd Hoffmann }; 4442fe7c318SGerd Hoffmann 4452fe7c318SGerd Hoffmann /* 4462fe7c318SGerd Hoffmann * Force feedback effect types 4472fe7c318SGerd Hoffmann */ 4482fe7c318SGerd Hoffmann 4492fe7c318SGerd Hoffmann #define FF_RUMBLE 0x50 4502fe7c318SGerd Hoffmann #define FF_PERIODIC 0x51 4512fe7c318SGerd Hoffmann #define FF_CONSTANT 0x52 4522fe7c318SGerd Hoffmann #define FF_SPRING 0x53 4532fe7c318SGerd Hoffmann #define FF_FRICTION 0x54 4542fe7c318SGerd Hoffmann #define FF_DAMPER 0x55 4552fe7c318SGerd Hoffmann #define FF_INERTIA 0x56 4562fe7c318SGerd Hoffmann #define FF_RAMP 0x57 4572fe7c318SGerd Hoffmann 4582fe7c318SGerd Hoffmann #define FF_EFFECT_MIN FF_RUMBLE 4592fe7c318SGerd Hoffmann #define FF_EFFECT_MAX FF_RAMP 4602fe7c318SGerd Hoffmann 4612fe7c318SGerd Hoffmann /* 4622fe7c318SGerd Hoffmann * Force feedback periodic effect types 4632fe7c318SGerd Hoffmann */ 4642fe7c318SGerd Hoffmann 4652fe7c318SGerd Hoffmann #define FF_SQUARE 0x58 4662fe7c318SGerd Hoffmann #define FF_TRIANGLE 0x59 4672fe7c318SGerd Hoffmann #define FF_SINE 0x5a 4682fe7c318SGerd Hoffmann #define FF_SAW_UP 0x5b 4692fe7c318SGerd Hoffmann #define FF_SAW_DOWN 0x5c 4702fe7c318SGerd Hoffmann #define FF_CUSTOM 0x5d 4712fe7c318SGerd Hoffmann 4722fe7c318SGerd Hoffmann #define FF_WAVEFORM_MIN FF_SQUARE 4732fe7c318SGerd Hoffmann #define FF_WAVEFORM_MAX FF_CUSTOM 4742fe7c318SGerd Hoffmann 4752fe7c318SGerd Hoffmann /* 4762fe7c318SGerd Hoffmann * Set ff device properties 4772fe7c318SGerd Hoffmann */ 4782fe7c318SGerd Hoffmann 4792fe7c318SGerd Hoffmann #define FF_GAIN 0x60 4802fe7c318SGerd Hoffmann #define FF_AUTOCENTER 0x61 4812fe7c318SGerd Hoffmann 482fff02bc0SPaolo Bonzini /* 483fff02bc0SPaolo Bonzini * ff->playback(effect_id = FF_GAIN) is the first effect_id to 484fff02bc0SPaolo Bonzini * cause a collision with another ff method, in this case ff->set_gain(). 485fff02bc0SPaolo Bonzini * Therefore the greatest safe value for effect_id is FF_GAIN - 1, 486fff02bc0SPaolo Bonzini * and thus the total number of effects should never exceed FF_GAIN. 487fff02bc0SPaolo Bonzini */ 488fff02bc0SPaolo Bonzini #define FF_MAX_EFFECTS FF_GAIN 489fff02bc0SPaolo Bonzini 4902fe7c318SGerd Hoffmann #define FF_MAX 0x7f 4912fe7c318SGerd Hoffmann #define FF_CNT (FF_MAX+1) 4922fe7c318SGerd Hoffmann 4932fe7c318SGerd Hoffmann #endif /* _INPUT_H */ 494