1dd873966SEric Auger /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 22fe7c318SGerd Hoffmann /* 32fe7c318SGerd Hoffmann * Copyright (c) 1999-2002 Vojtech Pavlik 42fe7c318SGerd Hoffmann * 52fe7c318SGerd Hoffmann * This program is free software; you can redistribute it and/or modify it 62fe7c318SGerd Hoffmann * under the terms of the GNU General Public License version 2 as published by 72fe7c318SGerd Hoffmann * the Free Software Foundation. 82fe7c318SGerd Hoffmann */ 92fe7c318SGerd Hoffmann #ifndef _INPUT_H 102fe7c318SGerd Hoffmann #define _INPUT_H 112fe7c318SGerd Hoffmann 122fe7c318SGerd Hoffmann 132fe7c318SGerd Hoffmann #include <sys/time.h> 142fe7c318SGerd Hoffmann #include <sys/types.h> 152fe7c318SGerd Hoffmann #include "standard-headers/linux/types.h" 162fe7c318SGerd Hoffmann 17fff02bc0SPaolo Bonzini #include "standard-headers/linux/input-event-codes.h" 182fe7c318SGerd Hoffmann 192fe7c318SGerd Hoffmann /* 202fe7c318SGerd Hoffmann * The event structure itself 219f2d175dSPaolo Bonzini * Note that __USE_TIME_BITS64 is defined by libc based on 229f2d175dSPaolo Bonzini * application's request to use 64 bit time_t. 232fe7c318SGerd Hoffmann */ 242fe7c318SGerd Hoffmann 252fe7c318SGerd Hoffmann struct input_event { 26d9cb4336SCornelia Huck #if (HOST_LONG_BITS != 32 || !defined(__USE_TIME_BITS64)) && !defined(__KERNEL__) 272fe7c318SGerd Hoffmann struct timeval time; 289f2d175dSPaolo Bonzini #define input_event_sec time.tv_sec 299f2d175dSPaolo Bonzini #define input_event_usec time.tv_usec 309f2d175dSPaolo Bonzini #else 3165a6d8ddSPeter Maydell unsigned long __sec; 32d9cb4336SCornelia Huck #if defined(__sparc__) && defined(__arch64__) 33d9cb4336SCornelia Huck unsigned int __usec; 34ddda3748SCornelia Huck unsigned int __pad; 35d9cb4336SCornelia Huck #else 3665a6d8ddSPeter Maydell unsigned long __usec; 37d9cb4336SCornelia Huck #endif 389f2d175dSPaolo Bonzini #define input_event_sec __sec 399f2d175dSPaolo Bonzini #define input_event_usec __usec 409f2d175dSPaolo Bonzini #endif 412fe7c318SGerd Hoffmann uint16_t type; 422fe7c318SGerd Hoffmann uint16_t code; 432fe7c318SGerd Hoffmann int32_t value; 442fe7c318SGerd Hoffmann }; 452fe7c318SGerd Hoffmann 462fe7c318SGerd Hoffmann /* 472fe7c318SGerd Hoffmann * Protocol version. 482fe7c318SGerd Hoffmann */ 492fe7c318SGerd Hoffmann 502fe7c318SGerd Hoffmann #define EV_VERSION 0x010001 512fe7c318SGerd Hoffmann 522fe7c318SGerd Hoffmann /* 532fe7c318SGerd Hoffmann * IOCTLs (0x00 - 0x7f) 542fe7c318SGerd Hoffmann */ 552fe7c318SGerd Hoffmann 562fe7c318SGerd Hoffmann struct input_id { 572fe7c318SGerd Hoffmann uint16_t bustype; 582fe7c318SGerd Hoffmann uint16_t vendor; 592fe7c318SGerd Hoffmann uint16_t product; 602fe7c318SGerd Hoffmann uint16_t version; 612fe7c318SGerd Hoffmann }; 622fe7c318SGerd Hoffmann 632fe7c318SGerd Hoffmann /** 642fe7c318SGerd Hoffmann * struct input_absinfo - used by EVIOCGABS/EVIOCSABS ioctls 652fe7c318SGerd Hoffmann * @value: latest reported value for the axis. 662fe7c318SGerd Hoffmann * @minimum: specifies minimum value for the axis. 672fe7c318SGerd Hoffmann * @maximum: specifies maximum value for the axis. 682fe7c318SGerd Hoffmann * @fuzz: specifies fuzz value that is used to filter noise from 692fe7c318SGerd Hoffmann * the event stream. 702fe7c318SGerd Hoffmann * @flat: values that are within this value will be discarded by 712fe7c318SGerd Hoffmann * joydev interface and reported as 0 instead. 722fe7c318SGerd Hoffmann * @resolution: specifies resolution for the values reported for 732fe7c318SGerd Hoffmann * the axis. 742fe7c318SGerd Hoffmann * 752fe7c318SGerd Hoffmann * Note that input core does not clamp reported values to the 762fe7c318SGerd Hoffmann * [minimum, maximum] limits, such task is left to userspace. 772fe7c318SGerd Hoffmann * 78*d525f73fSChenyi Qiang * The default resolution for main axes (ABS_X, ABS_Y, ABS_Z, 79*d525f73fSChenyi Qiang * ABS_MT_POSITION_X, ABS_MT_POSITION_Y) is reported in units 80*d525f73fSChenyi Qiang * per millimeter (units/mm), resolution for rotational axes 81*d525f73fSChenyi Qiang * (ABS_RX, ABS_RY, ABS_RZ) is reported in units per radian. 82*d525f73fSChenyi Qiang * The resolution for the size axes (ABS_MT_TOUCH_MAJOR, 83*d525f73fSChenyi Qiang * ABS_MT_TOUCH_MINOR, ABS_MT_WIDTH_MAJOR, ABS_MT_WIDTH_MINOR) 84*d525f73fSChenyi Qiang * is reported in units per millimeter (units/mm). 8574c98e20SCornelia Huck * When INPUT_PROP_ACCELEROMETER is set the resolution changes. 8674c98e20SCornelia Huck * The main axes (ABS_X, ABS_Y, ABS_Z) are then reported in 87278f064eSEduardo Habkost * units per g (units/g) and in units per degree per second 8874c98e20SCornelia Huck * (units/deg/s) for rotational axes (ABS_RX, ABS_RY, ABS_RZ). 892fe7c318SGerd Hoffmann */ 902fe7c318SGerd Hoffmann struct input_absinfo { 912fe7c318SGerd Hoffmann int32_t value; 922fe7c318SGerd Hoffmann int32_t minimum; 932fe7c318SGerd Hoffmann int32_t maximum; 942fe7c318SGerd Hoffmann int32_t fuzz; 952fe7c318SGerd Hoffmann int32_t flat; 962fe7c318SGerd Hoffmann int32_t resolution; 972fe7c318SGerd Hoffmann }; 982fe7c318SGerd Hoffmann 992fe7c318SGerd Hoffmann /** 1002fe7c318SGerd Hoffmann * struct input_keymap_entry - used by EVIOCGKEYCODE/EVIOCSKEYCODE ioctls 1012fe7c318SGerd Hoffmann * @scancode: scancode represented in machine-endian form. 1022fe7c318SGerd Hoffmann * @len: length of the scancode that resides in @scancode buffer. 1032fe7c318SGerd Hoffmann * @index: index in the keymap, may be used instead of scancode 1042fe7c318SGerd Hoffmann * @flags: allows to specify how kernel should handle the request. For 1052fe7c318SGerd Hoffmann * example, setting INPUT_KEYMAP_BY_INDEX flag indicates that kernel 1062fe7c318SGerd Hoffmann * should perform lookup in keymap by @index instead of @scancode 1072fe7c318SGerd Hoffmann * @keycode: key code assigned to this scancode 1082fe7c318SGerd Hoffmann * 1092fe7c318SGerd Hoffmann * The structure is used to retrieve and modify keymap data. Users have 1102fe7c318SGerd Hoffmann * option of performing lookup either by @scancode itself or by @index 1112fe7c318SGerd Hoffmann * in keymap entry. EVIOCGKEYCODE will also return scancode or index 1122fe7c318SGerd Hoffmann * (depending on which element was used to perform lookup). 1132fe7c318SGerd Hoffmann */ 1142fe7c318SGerd Hoffmann struct input_keymap_entry { 1152fe7c318SGerd Hoffmann #define INPUT_KEYMAP_BY_INDEX (1 << 0) 1162fe7c318SGerd Hoffmann uint8_t flags; 1172fe7c318SGerd Hoffmann uint8_t len; 1182fe7c318SGerd Hoffmann uint16_t index; 1192fe7c318SGerd Hoffmann uint32_t keycode; 1202fe7c318SGerd Hoffmann uint8_t scancode[32]; 1212fe7c318SGerd Hoffmann }; 1222fe7c318SGerd Hoffmann 123fff02bc0SPaolo Bonzini struct input_mask { 124fff02bc0SPaolo Bonzini uint32_t type; 125fff02bc0SPaolo Bonzini uint32_t codes_size; 126fff02bc0SPaolo Bonzini uint64_t codes_ptr; 127fff02bc0SPaolo Bonzini }; 128fff02bc0SPaolo Bonzini 1292fe7c318SGerd Hoffmann #define EVIOCGVERSION _IOR('E', 0x01, int) /* get driver version */ 1302fe7c318SGerd Hoffmann #define EVIOCGID _IOR('E', 0x02, struct input_id) /* get device ID */ 1312fe7c318SGerd Hoffmann #define EVIOCGREP _IOR('E', 0x03, unsigned int[2]) /* get repeat settings */ 1322fe7c318SGerd Hoffmann #define EVIOCSREP _IOW('E', 0x03, unsigned int[2]) /* set repeat settings */ 1332fe7c318SGerd Hoffmann 1342fe7c318SGerd Hoffmann #define EVIOCGKEYCODE _IOR('E', 0x04, unsigned int[2]) /* get keycode */ 1352fe7c318SGerd Hoffmann #define EVIOCGKEYCODE_V2 _IOR('E', 0x04, struct input_keymap_entry) 1362fe7c318SGerd Hoffmann #define EVIOCSKEYCODE _IOW('E', 0x04, unsigned int[2]) /* set keycode */ 1372fe7c318SGerd Hoffmann #define EVIOCSKEYCODE_V2 _IOW('E', 0x04, struct input_keymap_entry) 1382fe7c318SGerd Hoffmann 1392fe7c318SGerd Hoffmann #define EVIOCGNAME(len) _IOC(_IOC_READ, 'E', 0x06, len) /* get device name */ 1402fe7c318SGerd Hoffmann #define EVIOCGPHYS(len) _IOC(_IOC_READ, 'E', 0x07, len) /* get physical location */ 1412fe7c318SGerd Hoffmann #define EVIOCGUNIQ(len) _IOC(_IOC_READ, 'E', 0x08, len) /* get unique identifier */ 1422fe7c318SGerd Hoffmann #define EVIOCGPROP(len) _IOC(_IOC_READ, 'E', 0x09, len) /* get device properties */ 1432fe7c318SGerd Hoffmann 1442fe7c318SGerd Hoffmann /** 1452fe7c318SGerd Hoffmann * EVIOCGMTSLOTS(len) - get MT slot values 1462fe7c318SGerd Hoffmann * @len: size of the data buffer in bytes 1472fe7c318SGerd Hoffmann * 1482fe7c318SGerd Hoffmann * The ioctl buffer argument should be binary equivalent to 1492fe7c318SGerd Hoffmann * 1502fe7c318SGerd Hoffmann * struct input_mt_request_layout { 1512fe7c318SGerd Hoffmann * uint32_t code; 1522fe7c318SGerd Hoffmann * int32_t values[num_slots]; 1532fe7c318SGerd Hoffmann * }; 1542fe7c318SGerd Hoffmann * 1552fe7c318SGerd Hoffmann * where num_slots is the (arbitrary) number of MT slots to extract. 1562fe7c318SGerd Hoffmann * 1572fe7c318SGerd Hoffmann * The ioctl size argument (len) is the size of the buffer, which 1582fe7c318SGerd Hoffmann * should satisfy len = (num_slots + 1) * sizeof(int32_t). If len is 1592fe7c318SGerd Hoffmann * too small to fit all available slots, the first num_slots are 1602fe7c318SGerd Hoffmann * returned. 1612fe7c318SGerd Hoffmann * 1622fe7c318SGerd Hoffmann * Before the call, code is set to the wanted ABS_MT event type. On 1632fe7c318SGerd Hoffmann * return, values[] is filled with the slot values for the specified 1642fe7c318SGerd Hoffmann * ABS_MT code. 1652fe7c318SGerd Hoffmann * 1662fe7c318SGerd Hoffmann * If the request code is not an ABS_MT value, -EINVAL is returned. 1672fe7c318SGerd Hoffmann */ 1682fe7c318SGerd Hoffmann #define EVIOCGMTSLOTS(len) _IOC(_IOC_READ, 'E', 0x0a, len) 1692fe7c318SGerd Hoffmann 1702fe7c318SGerd Hoffmann #define EVIOCGKEY(len) _IOC(_IOC_READ, 'E', 0x18, len) /* get global key state */ 1712fe7c318SGerd Hoffmann #define EVIOCGLED(len) _IOC(_IOC_READ, 'E', 0x19, len) /* get all LEDs */ 1722fe7c318SGerd Hoffmann #define EVIOCGSND(len) _IOC(_IOC_READ, 'E', 0x1a, len) /* get all sounds status */ 1732fe7c318SGerd Hoffmann #define EVIOCGSW(len) _IOC(_IOC_READ, 'E', 0x1b, len) /* get all switch states */ 1742fe7c318SGerd Hoffmann 1752fe7c318SGerd Hoffmann #define EVIOCGBIT(ev,len) _IOC(_IOC_READ, 'E', 0x20 + (ev), len) /* get event bits */ 1762fe7c318SGerd Hoffmann #define EVIOCGABS(abs) _IOR('E', 0x40 + (abs), struct input_absinfo) /* get abs value/limits */ 1772fe7c318SGerd Hoffmann #define EVIOCSABS(abs) _IOW('E', 0xc0 + (abs), struct input_absinfo) /* set abs value/limits */ 1782fe7c318SGerd Hoffmann 179fff02bc0SPaolo Bonzini #define EVIOCSFF _IOW('E', 0x80, struct ff_effect) /* send a force effect to a force feedback device */ 1802fe7c318SGerd Hoffmann #define EVIOCRMFF _IOW('E', 0x81, int) /* Erase a force effect */ 1812fe7c318SGerd Hoffmann #define EVIOCGEFFECTS _IOR('E', 0x84, int) /* Report number of effects playable at the same time */ 1822fe7c318SGerd Hoffmann 1832fe7c318SGerd Hoffmann #define EVIOCGRAB _IOW('E', 0x90, int) /* Grab/Release device */ 1842fe7c318SGerd Hoffmann #define EVIOCREVOKE _IOW('E', 0x91, int) /* Revoke device access */ 1852fe7c318SGerd Hoffmann 186fff02bc0SPaolo Bonzini /** 187fff02bc0SPaolo Bonzini * EVIOCGMASK - Retrieve current event mask 1882fe7c318SGerd Hoffmann * 189fff02bc0SPaolo Bonzini * This ioctl allows user to retrieve the current event mask for specific 190fff02bc0SPaolo Bonzini * event type. The argument must be of type "struct input_mask" and 191fff02bc0SPaolo Bonzini * specifies the event type to query, the address of the receive buffer and 192fff02bc0SPaolo Bonzini * the size of the receive buffer. 193fff02bc0SPaolo Bonzini * 194fff02bc0SPaolo Bonzini * The event mask is a per-client mask that specifies which events are 195fff02bc0SPaolo Bonzini * forwarded to the client. Each event code is represented by a single bit 196fff02bc0SPaolo Bonzini * in the event mask. If the bit is set, the event is passed to the client 197fff02bc0SPaolo Bonzini * normally. Otherwise, the event is filtered and will never be queued on 198fff02bc0SPaolo Bonzini * the client's receive buffer. 199fff02bc0SPaolo Bonzini * 200fff02bc0SPaolo Bonzini * Event masks do not affect global state of the input device. They only 201fff02bc0SPaolo Bonzini * affect the file descriptor they are applied to. 202fff02bc0SPaolo Bonzini * 203fff02bc0SPaolo Bonzini * The default event mask for a client has all bits set, i.e. all events 204fff02bc0SPaolo Bonzini * are forwarded to the client. If the kernel is queried for an unknown 205fff02bc0SPaolo Bonzini * event type or if the receive buffer is larger than the number of 206fff02bc0SPaolo Bonzini * event codes known to the kernel, the kernel returns all zeroes for those 207fff02bc0SPaolo Bonzini * codes. 208fff02bc0SPaolo Bonzini * 209fff02bc0SPaolo Bonzini * At maximum, codes_size bytes are copied. 210fff02bc0SPaolo Bonzini * 211fff02bc0SPaolo Bonzini * This ioctl may fail with ENODEV in case the file is revoked, EFAULT 212fff02bc0SPaolo Bonzini * if the receive-buffer points to invalid memory, or EINVAL if the kernel 213fff02bc0SPaolo Bonzini * does not implement the ioctl. 2142fe7c318SGerd Hoffmann */ 215fff02bc0SPaolo Bonzini #define EVIOCGMASK _IOR('E', 0x92, struct input_mask) /* Get event-masks */ 2162fe7c318SGerd Hoffmann 217fff02bc0SPaolo Bonzini /** 218fff02bc0SPaolo Bonzini * EVIOCSMASK - Set event mask 219fff02bc0SPaolo Bonzini * 220fff02bc0SPaolo Bonzini * This ioctl is the counterpart to EVIOCGMASK. Instead of receiving the 221fff02bc0SPaolo Bonzini * current event mask, this changes the client's event mask for a specific 222fff02bc0SPaolo Bonzini * type. See EVIOCGMASK for a description of event-masks and the 223fff02bc0SPaolo Bonzini * argument-type. 224fff02bc0SPaolo Bonzini * 225fff02bc0SPaolo Bonzini * This ioctl provides full forward compatibility. If the passed event type 226fff02bc0SPaolo Bonzini * is unknown to the kernel, or if the number of event codes specified in 227fff02bc0SPaolo Bonzini * the mask is bigger than what is known to the kernel, the ioctl is still 228fff02bc0SPaolo Bonzini * accepted and applied. However, any unknown codes are left untouched and 229fff02bc0SPaolo Bonzini * stay cleared. That means, the kernel always filters unknown codes 230fff02bc0SPaolo Bonzini * regardless of what the client requests. If the new mask doesn't cover 231fff02bc0SPaolo Bonzini * all known event-codes, all remaining codes are automatically cleared and 232fff02bc0SPaolo Bonzini * thus filtered. 233fff02bc0SPaolo Bonzini * 234fff02bc0SPaolo Bonzini * This ioctl may fail with ENODEV in case the file is revoked. EFAULT is 235fff02bc0SPaolo Bonzini * returned if the receive-buffer points to invalid memory. EINVAL is returned 236fff02bc0SPaolo Bonzini * if the kernel does not implement the ioctl. 2372fe7c318SGerd Hoffmann */ 238fff02bc0SPaolo Bonzini #define EVIOCSMASK _IOW('E', 0x93, struct input_mask) /* Set event-masks */ 2392fe7c318SGerd Hoffmann 240fff02bc0SPaolo Bonzini #define EVIOCSCLOCKID _IOW('E', 0xa0, int) /* Set clockid to be used for timestamps */ 2412fe7c318SGerd Hoffmann 2422fe7c318SGerd Hoffmann /* 2432fe7c318SGerd Hoffmann * IDs. 2442fe7c318SGerd Hoffmann */ 2452fe7c318SGerd Hoffmann 2462fe7c318SGerd Hoffmann #define ID_BUS 0 2472fe7c318SGerd Hoffmann #define ID_VENDOR 1 2482fe7c318SGerd Hoffmann #define ID_PRODUCT 2 2492fe7c318SGerd Hoffmann #define ID_VERSION 3 2502fe7c318SGerd Hoffmann 2512fe7c318SGerd Hoffmann #define BUS_PCI 0x01 2522fe7c318SGerd Hoffmann #define BUS_ISAPNP 0x02 2532fe7c318SGerd Hoffmann #define BUS_USB 0x03 2542fe7c318SGerd Hoffmann #define BUS_HIL 0x04 2552fe7c318SGerd Hoffmann #define BUS_BLUETOOTH 0x05 2562fe7c318SGerd Hoffmann #define BUS_VIRTUAL 0x06 2572fe7c318SGerd Hoffmann 2582fe7c318SGerd Hoffmann #define BUS_ISA 0x10 2592fe7c318SGerd Hoffmann #define BUS_I8042 0x11 2602fe7c318SGerd Hoffmann #define BUS_XTKBD 0x12 2612fe7c318SGerd Hoffmann #define BUS_RS232 0x13 2622fe7c318SGerd Hoffmann #define BUS_GAMEPORT 0x14 2632fe7c318SGerd Hoffmann #define BUS_PARPORT 0x15 2642fe7c318SGerd Hoffmann #define BUS_AMIGA 0x16 2652fe7c318SGerd Hoffmann #define BUS_ADB 0x17 2662fe7c318SGerd Hoffmann #define BUS_I2C 0x18 2672fe7c318SGerd Hoffmann #define BUS_HOST 0x19 2682fe7c318SGerd Hoffmann #define BUS_GSC 0x1A 2692fe7c318SGerd Hoffmann #define BUS_ATARI 0x1B 2702fe7c318SGerd Hoffmann #define BUS_SPI 0x1C 271b89485a5SPaolo Bonzini #define BUS_RMI 0x1D 272dbdfea92SCornelia Huck #define BUS_CEC 0x1E 273bc204035SMarcelo Tosatti #define BUS_INTEL_ISHTP 0x1F 274*d525f73fSChenyi Qiang #define BUS_AMD_SFH 0x20 2752fe7c318SGerd Hoffmann 2762fe7c318SGerd Hoffmann /* 2772fe7c318SGerd Hoffmann * MT_TOOL types 2782fe7c318SGerd Hoffmann */ 2798f3cd250SCornelia Huck #define MT_TOOL_FINGER 0x00 2808f3cd250SCornelia Huck #define MT_TOOL_PEN 0x01 2818f3cd250SCornelia Huck #define MT_TOOL_PALM 0x02 2828f3cd250SCornelia Huck #define MT_TOOL_DIAL 0x0a 2838f3cd250SCornelia Huck #define MT_TOOL_MAX 0x0f 2842fe7c318SGerd Hoffmann 2852fe7c318SGerd Hoffmann /* 2862fe7c318SGerd Hoffmann * Values describing the status of a force-feedback effect 2872fe7c318SGerd Hoffmann */ 2882fe7c318SGerd Hoffmann #define FF_STATUS_STOPPED 0x00 2892fe7c318SGerd Hoffmann #define FF_STATUS_PLAYING 0x01 2902fe7c318SGerd Hoffmann #define FF_STATUS_MAX 0x01 2912fe7c318SGerd Hoffmann 2922fe7c318SGerd Hoffmann /* 2932fe7c318SGerd Hoffmann * Structures used in ioctls to upload effects to a device 2942fe7c318SGerd Hoffmann * They are pieces of a bigger structure (called ff_effect) 2952fe7c318SGerd Hoffmann */ 2962fe7c318SGerd Hoffmann 2972fe7c318SGerd Hoffmann /* 2982fe7c318SGerd Hoffmann * All duration values are expressed in ms. Values above 32767 ms (0x7fff) 2992fe7c318SGerd Hoffmann * should not be used and have unspecified results. 3002fe7c318SGerd Hoffmann */ 3012fe7c318SGerd Hoffmann 3022fe7c318SGerd Hoffmann /** 3032fe7c318SGerd Hoffmann * struct ff_replay - defines scheduling of the force-feedback effect 3042fe7c318SGerd Hoffmann * @length: duration of the effect 3052fe7c318SGerd Hoffmann * @delay: delay before effect should start playing 3062fe7c318SGerd Hoffmann */ 3072fe7c318SGerd Hoffmann struct ff_replay { 3082fe7c318SGerd Hoffmann uint16_t length; 3092fe7c318SGerd Hoffmann uint16_t delay; 3102fe7c318SGerd Hoffmann }; 3112fe7c318SGerd Hoffmann 3122fe7c318SGerd Hoffmann /** 3132fe7c318SGerd Hoffmann * struct ff_trigger - defines what triggers the force-feedback effect 3142fe7c318SGerd Hoffmann * @button: number of the button triggering the effect 3152fe7c318SGerd Hoffmann * @interval: controls how soon the effect can be re-triggered 3162fe7c318SGerd Hoffmann */ 3172fe7c318SGerd Hoffmann struct ff_trigger { 3182fe7c318SGerd Hoffmann uint16_t button; 3192fe7c318SGerd Hoffmann uint16_t interval; 3202fe7c318SGerd Hoffmann }; 3212fe7c318SGerd Hoffmann 3222fe7c318SGerd Hoffmann /** 3232fe7c318SGerd Hoffmann * struct ff_envelope - generic force-feedback effect envelope 3242fe7c318SGerd Hoffmann * @attack_length: duration of the attack (ms) 3252fe7c318SGerd Hoffmann * @attack_level: level at the beginning of the attack 3262fe7c318SGerd Hoffmann * @fade_length: duration of fade (ms) 3272fe7c318SGerd Hoffmann * @fade_level: level at the end of fade 3282fe7c318SGerd Hoffmann * 3292fe7c318SGerd Hoffmann * The @attack_level and @fade_level are absolute values; when applying 3302fe7c318SGerd Hoffmann * envelope force-feedback core will convert to positive/negative 3312fe7c318SGerd Hoffmann * value based on polarity of the default level of the effect. 3322fe7c318SGerd Hoffmann * Valid range for the attack and fade levels is 0x0000 - 0x7fff 3332fe7c318SGerd Hoffmann */ 3342fe7c318SGerd Hoffmann struct ff_envelope { 3352fe7c318SGerd Hoffmann uint16_t attack_length; 3362fe7c318SGerd Hoffmann uint16_t attack_level; 3372fe7c318SGerd Hoffmann uint16_t fade_length; 3382fe7c318SGerd Hoffmann uint16_t fade_level; 3392fe7c318SGerd Hoffmann }; 3402fe7c318SGerd Hoffmann 3412fe7c318SGerd Hoffmann /** 3422fe7c318SGerd Hoffmann * struct ff_constant_effect - defines parameters of a constant force-feedback effect 3432fe7c318SGerd Hoffmann * @level: strength of the effect; may be negative 3442fe7c318SGerd Hoffmann * @envelope: envelope data 3452fe7c318SGerd Hoffmann */ 3462fe7c318SGerd Hoffmann struct ff_constant_effect { 3472fe7c318SGerd Hoffmann int16_t level; 3482fe7c318SGerd Hoffmann struct ff_envelope envelope; 3492fe7c318SGerd Hoffmann }; 3502fe7c318SGerd Hoffmann 3512fe7c318SGerd Hoffmann /** 3522fe7c318SGerd Hoffmann * struct ff_ramp_effect - defines parameters of a ramp force-feedback effect 3532fe7c318SGerd Hoffmann * @start_level: beginning strength of the effect; may be negative 3542fe7c318SGerd Hoffmann * @end_level: final strength of the effect; may be negative 3552fe7c318SGerd Hoffmann * @envelope: envelope data 3562fe7c318SGerd Hoffmann */ 3572fe7c318SGerd Hoffmann struct ff_ramp_effect { 3582fe7c318SGerd Hoffmann int16_t start_level; 3592fe7c318SGerd Hoffmann int16_t end_level; 3602fe7c318SGerd Hoffmann struct ff_envelope envelope; 3612fe7c318SGerd Hoffmann }; 3622fe7c318SGerd Hoffmann 3632fe7c318SGerd Hoffmann /** 3642fe7c318SGerd Hoffmann * struct ff_condition_effect - defines a spring or friction force-feedback effect 3652fe7c318SGerd Hoffmann * @right_saturation: maximum level when joystick moved all way to the right 3662fe7c318SGerd Hoffmann * @left_saturation: same for the left side 3672fe7c318SGerd Hoffmann * @right_coeff: controls how fast the force grows when the joystick moves 3682fe7c318SGerd Hoffmann * to the right 3692fe7c318SGerd Hoffmann * @left_coeff: same for the left side 3702fe7c318SGerd Hoffmann * @deadband: size of the dead zone, where no force is produced 3712fe7c318SGerd Hoffmann * @center: position of the dead zone 3722fe7c318SGerd Hoffmann */ 3732fe7c318SGerd Hoffmann struct ff_condition_effect { 3742fe7c318SGerd Hoffmann uint16_t right_saturation; 3752fe7c318SGerd Hoffmann uint16_t left_saturation; 3762fe7c318SGerd Hoffmann 3772fe7c318SGerd Hoffmann int16_t right_coeff; 3782fe7c318SGerd Hoffmann int16_t left_coeff; 3792fe7c318SGerd Hoffmann 3802fe7c318SGerd Hoffmann uint16_t deadband; 3812fe7c318SGerd Hoffmann int16_t center; 3822fe7c318SGerd Hoffmann }; 3832fe7c318SGerd Hoffmann 3842fe7c318SGerd Hoffmann /** 3852fe7c318SGerd Hoffmann * struct ff_periodic_effect - defines parameters of a periodic force-feedback effect 3862fe7c318SGerd Hoffmann * @waveform: kind of the effect (wave) 3872fe7c318SGerd Hoffmann * @period: period of the wave (ms) 3882fe7c318SGerd Hoffmann * @magnitude: peak value 3892fe7c318SGerd Hoffmann * @offset: mean value of the wave (roughly) 3902fe7c318SGerd Hoffmann * @phase: 'horizontal' shift 3912fe7c318SGerd Hoffmann * @envelope: envelope data 3922fe7c318SGerd Hoffmann * @custom_len: number of samples (FF_CUSTOM only) 3932fe7c318SGerd Hoffmann * @custom_data: buffer of samples (FF_CUSTOM only) 3942fe7c318SGerd Hoffmann * 3952fe7c318SGerd Hoffmann * Known waveforms - FF_SQUARE, FF_TRIANGLE, FF_SINE, FF_SAW_UP, 3962fe7c318SGerd Hoffmann * FF_SAW_DOWN, FF_CUSTOM. The exact syntax FF_CUSTOM is undefined 3972fe7c318SGerd Hoffmann * for the time being as no driver supports it yet. 3982fe7c318SGerd Hoffmann * 3992fe7c318SGerd Hoffmann * Note: the data pointed by custom_data is copied by the driver. 4002fe7c318SGerd Hoffmann * You can therefore dispose of the memory after the upload/update. 4012fe7c318SGerd Hoffmann */ 4022fe7c318SGerd Hoffmann struct ff_periodic_effect { 4032fe7c318SGerd Hoffmann uint16_t waveform; 4042fe7c318SGerd Hoffmann uint16_t period; 4052fe7c318SGerd Hoffmann int16_t magnitude; 4062fe7c318SGerd Hoffmann int16_t offset; 4072fe7c318SGerd Hoffmann uint16_t phase; 4082fe7c318SGerd Hoffmann 4092fe7c318SGerd Hoffmann struct ff_envelope envelope; 4102fe7c318SGerd Hoffmann 4112fe7c318SGerd Hoffmann uint32_t custom_len; 4122fe7c318SGerd Hoffmann int16_t *custom_data; 4132fe7c318SGerd Hoffmann }; 4142fe7c318SGerd Hoffmann 4152fe7c318SGerd Hoffmann /** 4162fe7c318SGerd Hoffmann * struct ff_rumble_effect - defines parameters of a periodic force-feedback effect 4172fe7c318SGerd Hoffmann * @strong_magnitude: magnitude of the heavy motor 4182fe7c318SGerd Hoffmann * @weak_magnitude: magnitude of the light one 4192fe7c318SGerd Hoffmann * 4202fe7c318SGerd Hoffmann * Some rumble pads have two motors of different weight. Strong_magnitude 4212fe7c318SGerd Hoffmann * represents the magnitude of the vibration generated by the heavy one. 4222fe7c318SGerd Hoffmann */ 4232fe7c318SGerd Hoffmann struct ff_rumble_effect { 4242fe7c318SGerd Hoffmann uint16_t strong_magnitude; 4252fe7c318SGerd Hoffmann uint16_t weak_magnitude; 4262fe7c318SGerd Hoffmann }; 4272fe7c318SGerd Hoffmann 4282fe7c318SGerd Hoffmann /** 4292fe7c318SGerd Hoffmann * struct ff_effect - defines force feedback effect 4302fe7c318SGerd Hoffmann * @type: type of the effect (FF_CONSTANT, FF_PERIODIC, FF_RAMP, FF_SPRING, 4312fe7c318SGerd Hoffmann * FF_FRICTION, FF_DAMPER, FF_RUMBLE, FF_INERTIA, or FF_CUSTOM) 4322fe7c318SGerd Hoffmann * @id: an unique id assigned to an effect 4332fe7c318SGerd Hoffmann * @direction: direction of the effect 4342fe7c318SGerd Hoffmann * @trigger: trigger conditions (struct ff_trigger) 4352fe7c318SGerd Hoffmann * @replay: scheduling of the effect (struct ff_replay) 4362fe7c318SGerd Hoffmann * @u: effect-specific structure (one of ff_constant_effect, ff_ramp_effect, 4372fe7c318SGerd Hoffmann * ff_periodic_effect, ff_condition_effect, ff_rumble_effect) further 4382fe7c318SGerd Hoffmann * defining effect parameters 4392fe7c318SGerd Hoffmann * 4402fe7c318SGerd Hoffmann * This structure is sent through ioctl from the application to the driver. 4412fe7c318SGerd Hoffmann * To create a new effect application should set its @id to -1; the kernel 4422fe7c318SGerd Hoffmann * will return assigned @id which can later be used to update or delete 4432fe7c318SGerd Hoffmann * this effect. 4442fe7c318SGerd Hoffmann * 4452fe7c318SGerd Hoffmann * Direction of the effect is encoded as follows: 4462fe7c318SGerd Hoffmann * 0 deg -> 0x0000 (down) 4472fe7c318SGerd Hoffmann * 90 deg -> 0x4000 (left) 4482fe7c318SGerd Hoffmann * 180 deg -> 0x8000 (up) 4492fe7c318SGerd Hoffmann * 270 deg -> 0xC000 (right) 4502fe7c318SGerd Hoffmann */ 4512fe7c318SGerd Hoffmann struct ff_effect { 4522fe7c318SGerd Hoffmann uint16_t type; 4532fe7c318SGerd Hoffmann int16_t id; 4542fe7c318SGerd Hoffmann uint16_t direction; 4552fe7c318SGerd Hoffmann struct ff_trigger trigger; 4562fe7c318SGerd Hoffmann struct ff_replay replay; 4572fe7c318SGerd Hoffmann 4582fe7c318SGerd Hoffmann union { 4592fe7c318SGerd Hoffmann struct ff_constant_effect constant; 4602fe7c318SGerd Hoffmann struct ff_ramp_effect ramp; 4612fe7c318SGerd Hoffmann struct ff_periodic_effect periodic; 4622fe7c318SGerd Hoffmann struct ff_condition_effect condition[2]; /* One for each axis */ 4632fe7c318SGerd Hoffmann struct ff_rumble_effect rumble; 4642fe7c318SGerd Hoffmann } u; 4652fe7c318SGerd Hoffmann }; 4662fe7c318SGerd Hoffmann 4672fe7c318SGerd Hoffmann /* 4682fe7c318SGerd Hoffmann * Force feedback effect types 4692fe7c318SGerd Hoffmann */ 4702fe7c318SGerd Hoffmann 4712fe7c318SGerd Hoffmann #define FF_RUMBLE 0x50 4722fe7c318SGerd Hoffmann #define FF_PERIODIC 0x51 4732fe7c318SGerd Hoffmann #define FF_CONSTANT 0x52 4742fe7c318SGerd Hoffmann #define FF_SPRING 0x53 4752fe7c318SGerd Hoffmann #define FF_FRICTION 0x54 4762fe7c318SGerd Hoffmann #define FF_DAMPER 0x55 4772fe7c318SGerd Hoffmann #define FF_INERTIA 0x56 4782fe7c318SGerd Hoffmann #define FF_RAMP 0x57 4792fe7c318SGerd Hoffmann 4802fe7c318SGerd Hoffmann #define FF_EFFECT_MIN FF_RUMBLE 4812fe7c318SGerd Hoffmann #define FF_EFFECT_MAX FF_RAMP 4822fe7c318SGerd Hoffmann 4832fe7c318SGerd Hoffmann /* 4842fe7c318SGerd Hoffmann * Force feedback periodic effect types 4852fe7c318SGerd Hoffmann */ 4862fe7c318SGerd Hoffmann 4872fe7c318SGerd Hoffmann #define FF_SQUARE 0x58 4882fe7c318SGerd Hoffmann #define FF_TRIANGLE 0x59 4892fe7c318SGerd Hoffmann #define FF_SINE 0x5a 4902fe7c318SGerd Hoffmann #define FF_SAW_UP 0x5b 4912fe7c318SGerd Hoffmann #define FF_SAW_DOWN 0x5c 4922fe7c318SGerd Hoffmann #define FF_CUSTOM 0x5d 4932fe7c318SGerd Hoffmann 4942fe7c318SGerd Hoffmann #define FF_WAVEFORM_MIN FF_SQUARE 4952fe7c318SGerd Hoffmann #define FF_WAVEFORM_MAX FF_CUSTOM 4962fe7c318SGerd Hoffmann 4972fe7c318SGerd Hoffmann /* 4982fe7c318SGerd Hoffmann * Set ff device properties 4992fe7c318SGerd Hoffmann */ 5002fe7c318SGerd Hoffmann 5012fe7c318SGerd Hoffmann #define FF_GAIN 0x60 5022fe7c318SGerd Hoffmann #define FF_AUTOCENTER 0x61 5032fe7c318SGerd Hoffmann 504fff02bc0SPaolo Bonzini /* 505fff02bc0SPaolo Bonzini * ff->playback(effect_id = FF_GAIN) is the first effect_id to 506fff02bc0SPaolo Bonzini * cause a collision with another ff method, in this case ff->set_gain(). 507fff02bc0SPaolo Bonzini * Therefore the greatest safe value for effect_id is FF_GAIN - 1, 508fff02bc0SPaolo Bonzini * and thus the total number of effects should never exceed FF_GAIN. 509fff02bc0SPaolo Bonzini */ 510fff02bc0SPaolo Bonzini #define FF_MAX_EFFECTS FF_GAIN 511fff02bc0SPaolo Bonzini 5122fe7c318SGerd Hoffmann #define FF_MAX 0x7f 5132fe7c318SGerd Hoffmann #define FF_CNT (FF_MAX+1) 5142fe7c318SGerd Hoffmann 5152fe7c318SGerd Hoffmann #endif /* _INPUT_H */ 516