/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ /* * Copyright (c) 1999-2002 Vojtech Pavlik * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published by * the Free Software Foundation. */ #ifndef _UAPI_INPUT_H #define _UAPI_INPUT_H #ifndef __KERNEL__ #include <sys/time.h> #include <sys/ioctl.h> #include <sys/types.h> #include <linux/types.h> #endif #include "input-event-codes.h" /* * The event structure itself * Note that __USE_TIME_BITS64 is defined by libc based on * application's request to use 64 bit time_t. */ struct input_event { … }; /* * Protocol version. */ #define EV_VERSION … /* * IOCTLs (0x00 - 0x7f) */ struct input_id { … }; /** * struct input_absinfo - used by EVIOCGABS/EVIOCSABS ioctls * @value: latest reported value for the axis. * @minimum: specifies minimum value for the axis. * @maximum: specifies maximum value for the axis. * @fuzz: specifies fuzz value that is used to filter noise from * the event stream. * @flat: values that are within this value will be discarded by * joydev interface and reported as 0 instead. * @resolution: specifies resolution for the values reported for * the axis. * * Note that input core does not clamp reported values to the * [minimum, maximum] limits, such task is left to userspace. * * The default resolution for main axes (ABS_X, ABS_Y, ABS_Z, * ABS_MT_POSITION_X, ABS_MT_POSITION_Y) is reported in units * per millimeter (units/mm), resolution for rotational axes * (ABS_RX, ABS_RY, ABS_RZ) is reported in units per radian. * The resolution for the size axes (ABS_MT_TOUCH_MAJOR, * ABS_MT_TOUCH_MINOR, ABS_MT_WIDTH_MAJOR, ABS_MT_WIDTH_MINOR) * is reported in units per millimeter (units/mm). * When INPUT_PROP_ACCELEROMETER is set the resolution changes. * The main axes (ABS_X, ABS_Y, ABS_Z) are then reported in * units per g (units/g) and in units per degree per second * (units/deg/s) for rotational axes (ABS_RX, ABS_RY, ABS_RZ). */ struct input_absinfo { … }; /** * struct input_keymap_entry - used by EVIOCGKEYCODE/EVIOCSKEYCODE ioctls * @scancode: scancode represented in machine-endian form. * @len: length of the scancode that resides in @scancode buffer. * @index: index in the keymap, may be used instead of scancode * @flags: allows to specify how kernel should handle the request. For * example, setting INPUT_KEYMAP_BY_INDEX flag indicates that kernel * should perform lookup in keymap by @index instead of @scancode * @keycode: key code assigned to this scancode * * The structure is used to retrieve and modify keymap data. Users have * option of performing lookup either by @scancode itself or by @index * in keymap entry. EVIOCGKEYCODE will also return scancode or index * (depending on which element was used to perform lookup). */ struct input_keymap_entry { … }; struct input_mask { … }; #define EVIOCGVERSION … #define EVIOCGID … #define EVIOCGREP … #define EVIOCSREP … #define EVIOCGKEYCODE … #define EVIOCGKEYCODE_V2 … #define EVIOCSKEYCODE … #define EVIOCSKEYCODE_V2 … #define EVIOCGNAME(len) … #define EVIOCGPHYS(len) … #define EVIOCGUNIQ(len) … #define EVIOCGPROP(len) … /** * EVIOCGMTSLOTS(len) - get MT slot values * @len: size of the data buffer in bytes * * The ioctl buffer argument should be binary equivalent to * * struct input_mt_request_layout { * __u32 code; * __s32 values[num_slots]; * }; * * where num_slots is the (arbitrary) number of MT slots to extract. * * The ioctl size argument (len) is the size of the buffer, which * should satisfy len = (num_slots + 1) * sizeof(__s32). If len is * too small to fit all available slots, the first num_slots are * returned. * * Before the call, code is set to the wanted ABS_MT event type. On * return, values[] is filled with the slot values for the specified * ABS_MT code. * * If the request code is not an ABS_MT value, -EINVAL is returned. */ #define EVIOCGMTSLOTS(len) … #define EVIOCGKEY(len) … #define EVIOCGLED(len) … #define EVIOCGSND(len) … #define EVIOCGSW(len) … #define EVIOCGBIT(ev,len) … #define EVIOCGABS(abs) … #define EVIOCSABS(abs) … #define EVIOCSFF … #define EVIOCRMFF … #define EVIOCGEFFECTS … #define EVIOCGRAB … #define EVIOCREVOKE … /** * EVIOCGMASK - Retrieve current event mask * * This ioctl allows user to retrieve the current event mask for specific * event type. The argument must be of type "struct input_mask" and * specifies the event type to query, the address of the receive buffer and * the size of the receive buffer. * * The event mask is a per-client mask that specifies which events are * forwarded to the client. Each event code is represented by a single bit * in the event mask. If the bit is set, the event is passed to the client * normally. Otherwise, the event is filtered and will never be queued on * the client's receive buffer. * * Event masks do not affect global state of the input device. They only * affect the file descriptor they are applied to. * * The default event mask for a client has all bits set, i.e. all events * are forwarded to the client. If the kernel is queried for an unknown * event type or if the receive buffer is larger than the number of * event codes known to the kernel, the kernel returns all zeroes for those * codes. * * At maximum, codes_size bytes are copied. * * This ioctl may fail with ENODEV in case the file is revoked, EFAULT * if the receive-buffer points to invalid memory, or EINVAL if the kernel * does not implement the ioctl. */ #define EVIOCGMASK … /** * EVIOCSMASK - Set event mask * * This ioctl is the counterpart to EVIOCGMASK. Instead of receiving the * current event mask, this changes the client's event mask for a specific * type. See EVIOCGMASK for a description of event-masks and the * argument-type. * * This ioctl provides full forward compatibility. If the passed event type * is unknown to the kernel, or if the number of event codes specified in * the mask is bigger than what is known to the kernel, the ioctl is still * accepted and applied. However, any unknown codes are left untouched and * stay cleared. That means, the kernel always filters unknown codes * regardless of what the client requests. If the new mask doesn't cover * all known event-codes, all remaining codes are automatically cleared and * thus filtered. * * This ioctl may fail with ENODEV in case the file is revoked. EFAULT is * returned if the receive-buffer points to invalid memory. EINVAL is returned * if the kernel does not implement the ioctl. */ #define EVIOCSMASK … #define EVIOCSCLOCKID … /* * IDs. */ #define ID_BUS … #define ID_VENDOR … #define ID_PRODUCT … #define ID_VERSION … #define BUS_PCI … #define BUS_ISAPNP … #define BUS_USB … #define BUS_HIL … #define BUS_BLUETOOTH … #define BUS_VIRTUAL … #define BUS_ISA … #define BUS_I8042 … #define BUS_XTKBD … #define BUS_RS232 … #define BUS_GAMEPORT … #define BUS_PARPORT … #define BUS_AMIGA … #define BUS_ADB … #define BUS_I2C … #define BUS_HOST … #define BUS_GSC … #define BUS_ATARI … #define BUS_SPI … #define BUS_RMI … #define BUS_CEC … #define BUS_INTEL_ISHTP … #define BUS_AMD_SFH … /* * MT_TOOL types */ #define MT_TOOL_FINGER … #define MT_TOOL_PEN … #define MT_TOOL_PALM … #define MT_TOOL_DIAL … #define MT_TOOL_MAX … /* * Values describing the status of a force-feedback effect */ #define FF_STATUS_STOPPED … #define FF_STATUS_PLAYING … #define FF_STATUS_MAX … /* * Structures used in ioctls to upload effects to a device * They are pieces of a bigger structure (called ff_effect) */ /* * All duration values are expressed in ms. Values above 32767 ms (0x7fff) * should not be used and have unspecified results. */ /** * struct ff_replay - defines scheduling of the force-feedback effect * @length: duration of the effect * @delay: delay before effect should start playing */ struct ff_replay { … }; /** * struct ff_trigger - defines what triggers the force-feedback effect * @button: number of the button triggering the effect * @interval: controls how soon the effect can be re-triggered */ struct ff_trigger { … }; /** * struct ff_envelope - generic force-feedback effect envelope * @attack_length: duration of the attack (ms) * @attack_level: level at the beginning of the attack * @fade_length: duration of fade (ms) * @fade_level: level at the end of fade * * The @attack_level and @fade_level are absolute values; when applying * envelope force-feedback core will convert to positive/negative * value based on polarity of the default level of the effect. * Valid range for the attack and fade levels is 0x0000 - 0x7fff */ struct ff_envelope { … }; /** * struct ff_constant_effect - defines parameters of a constant force-feedback effect * @level: strength of the effect; may be negative * @envelope: envelope data */ struct ff_constant_effect { … }; /** * struct ff_ramp_effect - defines parameters of a ramp force-feedback effect * @start_level: beginning strength of the effect; may be negative * @end_level: final strength of the effect; may be negative * @envelope: envelope data */ struct ff_ramp_effect { … }; /** * struct ff_condition_effect - defines a spring or friction force-feedback effect * @right_saturation: maximum level when joystick moved all way to the right * @left_saturation: same for the left side * @right_coeff: controls how fast the force grows when the joystick moves * to the right * @left_coeff: same for the left side * @deadband: size of the dead zone, where no force is produced * @center: position of the dead zone */ struct ff_condition_effect { … }; /** * struct ff_periodic_effect - defines parameters of a periodic force-feedback effect * @waveform: kind of the effect (wave) * @period: period of the wave (ms) * @magnitude: peak value * @offset: mean value of the wave (roughly) * @phase: 'horizontal' shift * @envelope: envelope data * @custom_len: number of samples (FF_CUSTOM only) * @custom_data: buffer of samples (FF_CUSTOM only) * * Known waveforms - FF_SQUARE, FF_TRIANGLE, FF_SINE, FF_SAW_UP, * FF_SAW_DOWN, FF_CUSTOM. The exact syntax FF_CUSTOM is undefined * for the time being as no driver supports it yet. * * Note: the data pointed by custom_data is copied by the driver. * You can therefore dispose of the memory after the upload/update. */ struct ff_periodic_effect { … }; /** * struct ff_rumble_effect - defines parameters of a periodic force-feedback effect * @strong_magnitude: magnitude of the heavy motor * @weak_magnitude: magnitude of the light one * * Some rumble pads have two motors of different weight. Strong_magnitude * represents the magnitude of the vibration generated by the heavy one. */ struct ff_rumble_effect { … }; /** * struct ff_effect - defines force feedback effect * @type: type of the effect (FF_CONSTANT, FF_PERIODIC, FF_RAMP, FF_SPRING, * FF_FRICTION, FF_DAMPER, FF_RUMBLE, FF_INERTIA, or FF_CUSTOM) * @id: an unique id assigned to an effect * @direction: direction of the effect * @trigger: trigger conditions (struct ff_trigger) * @replay: scheduling of the effect (struct ff_replay) * @u: effect-specific structure (one of ff_constant_effect, ff_ramp_effect, * ff_periodic_effect, ff_condition_effect, ff_rumble_effect) further * defining effect parameters * * This structure is sent through ioctl from the application to the driver. * To create a new effect application should set its @id to -1; the kernel * will return assigned @id which can later be used to update or delete * this effect. * * Direction of the effect is encoded as follows: * 0 deg -> 0x0000 (down) * 90 deg -> 0x4000 (left) * 180 deg -> 0x8000 (up) * 270 deg -> 0xC000 (right) */ struct ff_effect { … }; /* * Force feedback effect types */ #define FF_RUMBLE … #define FF_PERIODIC … #define FF_CONSTANT … #define FF_SPRING … #define FF_FRICTION … #define FF_DAMPER … #define FF_INERTIA … #define FF_RAMP … #define FF_EFFECT_MIN … #define FF_EFFECT_MAX … /* * Force feedback periodic effect types */ #define FF_SQUARE … #define FF_TRIANGLE … #define FF_SINE … #define FF_SAW_UP … #define FF_SAW_DOWN … #define FF_CUSTOM … #define FF_WAVEFORM_MIN … #define FF_WAVEFORM_MAX … /* * Set ff device properties */ #define FF_GAIN … #define FF_AUTOCENTER … /* * ff->playback(effect_id = FF_GAIN) is the first effect_id to * cause a collision with another ff method, in this case ff->set_gain(). * Therefore the greatest safe value for effect_id is FF_GAIN - 1, * and thus the total number of effects should never exceed FF_GAIN. */ #define FF_MAX_EFFECTS … #define FF_MAX … #define FF_CNT … #endif /* _UAPI_INPUT_H */