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