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