xref: /linux/include/uapi/linux/input.h (revision 227c011b2e046dd4d36d9e00e3d9c88097b2a4c3)
1607ca46eSDavid Howells /*
2607ca46eSDavid Howells  * Copyright (c) 1999-2002 Vojtech Pavlik
3607ca46eSDavid Howells  *
4607ca46eSDavid Howells  * This program is free software; you can redistribute it and/or modify it
5607ca46eSDavid Howells  * under the terms of the GNU General Public License version 2 as published by
6607ca46eSDavid Howells  * the Free Software Foundation.
7607ca46eSDavid Howells  */
8607ca46eSDavid Howells #ifndef _UAPI_INPUT_H
9607ca46eSDavid Howells #define _UAPI_INPUT_H
10607ca46eSDavid Howells 
11607ca46eSDavid Howells 
12607ca46eSDavid Howells #ifndef __KERNEL__
13607ca46eSDavid Howells #include <sys/time.h>
14607ca46eSDavid Howells #include <sys/ioctl.h>
15607ca46eSDavid Howells #include <sys/types.h>
16607ca46eSDavid Howells #include <linux/types.h>
17607ca46eSDavid Howells #endif
18607ca46eSDavid Howells 
19f902dd89SHans de Goede #include "input-event-codes.h"
20607ca46eSDavid Howells 
21607ca46eSDavid Howells /*
22607ca46eSDavid Howells  * The event structure itself
23607ca46eSDavid Howells  */
24607ca46eSDavid Howells 
25607ca46eSDavid Howells struct input_event {
26607ca46eSDavid Howells 	struct timeval time;
27607ca46eSDavid Howells 	__u16 type;
28607ca46eSDavid Howells 	__u16 code;
29607ca46eSDavid Howells 	__s32 value;
30607ca46eSDavid Howells };
31607ca46eSDavid Howells 
32607ca46eSDavid Howells /*
33607ca46eSDavid Howells  * Protocol version.
34607ca46eSDavid Howells  */
35607ca46eSDavid Howells 
36607ca46eSDavid Howells #define EV_VERSION		0x010001
37607ca46eSDavid Howells 
38607ca46eSDavid Howells /*
39607ca46eSDavid Howells  * IOCTLs (0x00 - 0x7f)
40607ca46eSDavid Howells  */
41607ca46eSDavid Howells 
42607ca46eSDavid Howells struct input_id {
43607ca46eSDavid Howells 	__u16 bustype;
44607ca46eSDavid Howells 	__u16 vendor;
45607ca46eSDavid Howells 	__u16 product;
46607ca46eSDavid Howells 	__u16 version;
47607ca46eSDavid Howells };
48607ca46eSDavid Howells 
49607ca46eSDavid Howells /**
50607ca46eSDavid Howells  * struct input_absinfo - used by EVIOCGABS/EVIOCSABS ioctls
51607ca46eSDavid Howells  * @value: latest reported value for the axis.
52607ca46eSDavid Howells  * @minimum: specifies minimum value for the axis.
53607ca46eSDavid Howells  * @maximum: specifies maximum value for the axis.
54607ca46eSDavid Howells  * @fuzz: specifies fuzz value that is used to filter noise from
55607ca46eSDavid Howells  *	the event stream.
56607ca46eSDavid Howells  * @flat: values that are within this value will be discarded by
57607ca46eSDavid Howells  *	joydev interface and reported as 0 instead.
58607ca46eSDavid Howells  * @resolution: specifies resolution for the values reported for
59607ca46eSDavid Howells  *	the axis.
60607ca46eSDavid Howells  *
61607ca46eSDavid Howells  * Note that input core does not clamp reported values to the
62607ca46eSDavid Howells  * [minimum, maximum] limits, such task is left to userspace.
63607ca46eSDavid Howells  *
64*227c011bSRoderick Colenbrander  * The default resolution for main axes (ABS_X, ABS_Y, ABS_Z)
65*227c011bSRoderick Colenbrander  * is reported in units per millimeter (units/mm), resolution
66*227c011bSRoderick Colenbrander  * for rotational axes (ABS_RX, ABS_RY, ABS_RZ) is reported
67*227c011bSRoderick Colenbrander  * in units per radian.
68*227c011bSRoderick Colenbrander  * When INPUT_PROP_ACCELEROMETER is set the resolution changes.
69*227c011bSRoderick Colenbrander  * The main axes (ABS_X, ABS_Y, ABS_Z) are then reported in
70*227c011bSRoderick Colenbrander  * in units per g (units/g) and in units per degree per second
71*227c011bSRoderick Colenbrander  * (units/deg/s) for rotational axes (ABS_RX, ABS_RY, ABS_RZ).
72607ca46eSDavid Howells  */
73607ca46eSDavid Howells struct input_absinfo {
74607ca46eSDavid Howells 	__s32 value;
75607ca46eSDavid Howells 	__s32 minimum;
76607ca46eSDavid Howells 	__s32 maximum;
77607ca46eSDavid Howells 	__s32 fuzz;
78607ca46eSDavid Howells 	__s32 flat;
79607ca46eSDavid Howells 	__s32 resolution;
80607ca46eSDavid Howells };
81607ca46eSDavid Howells 
82607ca46eSDavid Howells /**
83607ca46eSDavid Howells  * struct input_keymap_entry - used by EVIOCGKEYCODE/EVIOCSKEYCODE ioctls
84607ca46eSDavid Howells  * @scancode: scancode represented in machine-endian form.
85607ca46eSDavid Howells  * @len: length of the scancode that resides in @scancode buffer.
86607ca46eSDavid Howells  * @index: index in the keymap, may be used instead of scancode
87607ca46eSDavid Howells  * @flags: allows to specify how kernel should handle the request. For
88607ca46eSDavid Howells  *	example, setting INPUT_KEYMAP_BY_INDEX flag indicates that kernel
89607ca46eSDavid Howells  *	should perform lookup in keymap by @index instead of @scancode
90607ca46eSDavid Howells  * @keycode: key code assigned to this scancode
91607ca46eSDavid Howells  *
92607ca46eSDavid Howells  * The structure is used to retrieve and modify keymap data. Users have
93607ca46eSDavid Howells  * option of performing lookup either by @scancode itself or by @index
94607ca46eSDavid Howells  * in keymap entry. EVIOCGKEYCODE will also return scancode or index
95607ca46eSDavid Howells  * (depending on which element was used to perform lookup).
96607ca46eSDavid Howells  */
97607ca46eSDavid Howells struct input_keymap_entry {
98607ca46eSDavid Howells #define INPUT_KEYMAP_BY_INDEX	(1 << 0)
99607ca46eSDavid Howells 	__u8  flags;
100607ca46eSDavid Howells 	__u8  len;
101607ca46eSDavid Howells 	__u16 index;
102607ca46eSDavid Howells 	__u32 keycode;
103607ca46eSDavid Howells 	__u8  scancode[32];
104607ca46eSDavid Howells };
105607ca46eSDavid Howells 
10606a16293SDavid Herrmann struct input_mask {
10706a16293SDavid Herrmann 	__u32 type;
10806a16293SDavid Herrmann 	__u32 codes_size;
10906a16293SDavid Herrmann 	__u64 codes_ptr;
11006a16293SDavid Herrmann };
11106a16293SDavid Herrmann 
112607ca46eSDavid Howells #define EVIOCGVERSION		_IOR('E', 0x01, int)			/* get driver version */
113607ca46eSDavid Howells #define EVIOCGID		_IOR('E', 0x02, struct input_id)	/* get device ID */
114607ca46eSDavid Howells #define EVIOCGREP		_IOR('E', 0x03, unsigned int[2])	/* get repeat settings */
115607ca46eSDavid Howells #define EVIOCSREP		_IOW('E', 0x03, unsigned int[2])	/* set repeat settings */
116607ca46eSDavid Howells 
117607ca46eSDavid Howells #define EVIOCGKEYCODE		_IOR('E', 0x04, unsigned int[2])        /* get keycode */
118607ca46eSDavid Howells #define EVIOCGKEYCODE_V2	_IOR('E', 0x04, struct input_keymap_entry)
119607ca46eSDavid Howells #define EVIOCSKEYCODE		_IOW('E', 0x04, unsigned int[2])        /* set keycode */
120607ca46eSDavid Howells #define EVIOCSKEYCODE_V2	_IOW('E', 0x04, struct input_keymap_entry)
121607ca46eSDavid Howells 
122607ca46eSDavid Howells #define EVIOCGNAME(len)		_IOC(_IOC_READ, 'E', 0x06, len)		/* get device name */
123607ca46eSDavid Howells #define EVIOCGPHYS(len)		_IOC(_IOC_READ, 'E', 0x07, len)		/* get physical location */
124607ca46eSDavid Howells #define EVIOCGUNIQ(len)		_IOC(_IOC_READ, 'E', 0x08, len)		/* get unique identifier */
125607ca46eSDavid Howells #define EVIOCGPROP(len)		_IOC(_IOC_READ, 'E', 0x09, len)		/* get device properties */
126607ca46eSDavid Howells 
127607ca46eSDavid Howells /**
128607ca46eSDavid Howells  * EVIOCGMTSLOTS(len) - get MT slot values
129607ca46eSDavid Howells  * @len: size of the data buffer in bytes
130607ca46eSDavid Howells  *
131607ca46eSDavid Howells  * The ioctl buffer argument should be binary equivalent to
132607ca46eSDavid Howells  *
133607ca46eSDavid Howells  * struct input_mt_request_layout {
134607ca46eSDavid Howells  *	__u32 code;
135607ca46eSDavid Howells  *	__s32 values[num_slots];
136607ca46eSDavid Howells  * };
137607ca46eSDavid Howells  *
138607ca46eSDavid Howells  * where num_slots is the (arbitrary) number of MT slots to extract.
139607ca46eSDavid Howells  *
140607ca46eSDavid Howells  * The ioctl size argument (len) is the size of the buffer, which
141607ca46eSDavid Howells  * should satisfy len = (num_slots + 1) * sizeof(__s32).  If len is
142607ca46eSDavid Howells  * too small to fit all available slots, the first num_slots are
143607ca46eSDavid Howells  * returned.
144607ca46eSDavid Howells  *
145607ca46eSDavid Howells  * Before the call, code is set to the wanted ABS_MT event type. On
146607ca46eSDavid Howells  * return, values[] is filled with the slot values for the specified
147607ca46eSDavid Howells  * ABS_MT code.
148607ca46eSDavid Howells  *
149607ca46eSDavid Howells  * If the request code is not an ABS_MT value, -EINVAL is returned.
150607ca46eSDavid Howells  */
151607ca46eSDavid Howells #define EVIOCGMTSLOTS(len)	_IOC(_IOC_READ, 'E', 0x0a, len)
152607ca46eSDavid Howells 
153607ca46eSDavid Howells #define EVIOCGKEY(len)		_IOC(_IOC_READ, 'E', 0x18, len)		/* get global key state */
154607ca46eSDavid Howells #define EVIOCGLED(len)		_IOC(_IOC_READ, 'E', 0x19, len)		/* get all LEDs */
155607ca46eSDavid Howells #define EVIOCGSND(len)		_IOC(_IOC_READ, 'E', 0x1a, len)		/* get all sounds status */
156607ca46eSDavid Howells #define EVIOCGSW(len)		_IOC(_IOC_READ, 'E', 0x1b, len)		/* get all switch states */
157607ca46eSDavid Howells 
158607ca46eSDavid Howells #define EVIOCGBIT(ev,len)	_IOC(_IOC_READ, 'E', 0x20 + (ev), len)	/* get event bits */
159607ca46eSDavid Howells #define EVIOCGABS(abs)		_IOR('E', 0x40 + (abs), struct input_absinfo)	/* get abs value/limits */
160607ca46eSDavid Howells #define EVIOCSABS(abs)		_IOW('E', 0xc0 + (abs), struct input_absinfo)	/* set abs value/limits */
161607ca46eSDavid Howells 
16252a92667SElias Vanderstuyft #define EVIOCSFF		_IOW('E', 0x80, struct ff_effect)	/* send a force effect to a force feedback device */
163607ca46eSDavid Howells #define EVIOCRMFF		_IOW('E', 0x81, int)			/* Erase a force effect */
164607ca46eSDavid Howells #define EVIOCGEFFECTS		_IOR('E', 0x84, int)			/* Report number of effects playable at the same time */
165607ca46eSDavid Howells 
166607ca46eSDavid Howells #define EVIOCGRAB		_IOW('E', 0x90, int)			/* Grab/Release device */
167c7dc6573SDavid Herrmann #define EVIOCREVOKE		_IOW('E', 0x91, int)			/* Revoke device access */
168607ca46eSDavid Howells 
16906a16293SDavid Herrmann /**
17006a16293SDavid Herrmann  * EVIOCGMASK - Retrieve current event mask
17106a16293SDavid Herrmann  *
17206a16293SDavid Herrmann  * This ioctl allows user to retrieve the current event mask for specific
17306a16293SDavid Herrmann  * event type. The argument must be of type "struct input_mask" and
17406a16293SDavid Herrmann  * specifies the event type to query, the address of the receive buffer and
17506a16293SDavid Herrmann  * the size of the receive buffer.
17606a16293SDavid Herrmann  *
17706a16293SDavid Herrmann  * The event mask is a per-client mask that specifies which events are
17806a16293SDavid Herrmann  * forwarded to the client. Each event code is represented by a single bit
17906a16293SDavid Herrmann  * in the event mask. If the bit is set, the event is passed to the client
18006a16293SDavid Herrmann  * normally. Otherwise, the event is filtered and will never be queued on
18106a16293SDavid Herrmann  * the client's receive buffer.
18206a16293SDavid Herrmann  *
18306a16293SDavid Herrmann  * Event masks do not affect global state of the input device. They only
18406a16293SDavid Herrmann  * affect the file descriptor they are applied to.
18506a16293SDavid Herrmann  *
18606a16293SDavid Herrmann  * The default event mask for a client has all bits set, i.e. all events
18706a16293SDavid Herrmann  * are forwarded to the client. If the kernel is queried for an unknown
18806a16293SDavid Herrmann  * event type or if the receive buffer is larger than the number of
18906a16293SDavid Herrmann  * event codes known to the kernel, the kernel returns all zeroes for those
19006a16293SDavid Herrmann  * codes.
19106a16293SDavid Herrmann  *
19206a16293SDavid Herrmann  * At maximum, codes_size bytes are copied.
19306a16293SDavid Herrmann  *
19406a16293SDavid Herrmann  * This ioctl may fail with ENODEV in case the file is revoked, EFAULT
19506a16293SDavid Herrmann  * if the receive-buffer points to invalid memory, or EINVAL if the kernel
19606a16293SDavid Herrmann  * does not implement the ioctl.
19706a16293SDavid Herrmann  */
19806a16293SDavid Herrmann #define EVIOCGMASK		_IOR('E', 0x92, struct input_mask)	/* Get event-masks */
19906a16293SDavid Herrmann 
20006a16293SDavid Herrmann /**
20106a16293SDavid Herrmann  * EVIOCSMASK - Set event mask
20206a16293SDavid Herrmann  *
20306a16293SDavid Herrmann  * This ioctl is the counterpart to EVIOCGMASK. Instead of receiving the
20406a16293SDavid Herrmann  * current event mask, this changes the client's event mask for a specific
20506a16293SDavid Herrmann  * type.  See EVIOCGMASK for a description of event-masks and the
20606a16293SDavid Herrmann  * argument-type.
20706a16293SDavid Herrmann  *
20806a16293SDavid Herrmann  * This ioctl provides full forward compatibility. If the passed event type
20906a16293SDavid Herrmann  * is unknown to the kernel, or if the number of event codes specified in
21006a16293SDavid Herrmann  * the mask is bigger than what is known to the kernel, the ioctl is still
21106a16293SDavid Herrmann  * accepted and applied. However, any unknown codes are left untouched and
21206a16293SDavid Herrmann  * stay cleared. That means, the kernel always filters unknown codes
21306a16293SDavid Herrmann  * regardless of what the client requests.  If the new mask doesn't cover
21406a16293SDavid Herrmann  * all known event-codes, all remaining codes are automatically cleared and
21506a16293SDavid Herrmann  * thus filtered.
21606a16293SDavid Herrmann  *
21706a16293SDavid Herrmann  * This ioctl may fail with ENODEV in case the file is revoked. EFAULT is
21806a16293SDavid Herrmann  * returned if the receive-buffer points to invalid memory. EINVAL is returned
21906a16293SDavid Herrmann  * if the kernel does not implement the ioctl.
22006a16293SDavid Herrmann  */
22106a16293SDavid Herrmann #define EVIOCSMASK		_IOW('E', 0x93, struct input_mask)	/* Set event-masks */
22206a16293SDavid Herrmann 
223607ca46eSDavid Howells #define EVIOCSCLOCKID		_IOW('E', 0xa0, int)			/* Set clockid to be used for timestamps */
224607ca46eSDavid Howells 
225607ca46eSDavid Howells /*
226607ca46eSDavid Howells  * IDs.
227607ca46eSDavid Howells  */
228607ca46eSDavid Howells 
229607ca46eSDavid Howells #define ID_BUS			0
230607ca46eSDavid Howells #define ID_VENDOR		1
231607ca46eSDavid Howells #define ID_PRODUCT		2
232607ca46eSDavid Howells #define ID_VERSION		3
233607ca46eSDavid Howells 
234607ca46eSDavid Howells #define BUS_PCI			0x01
235607ca46eSDavid Howells #define BUS_ISAPNP		0x02
236607ca46eSDavid Howells #define BUS_USB			0x03
237607ca46eSDavid Howells #define BUS_HIL			0x04
238607ca46eSDavid Howells #define BUS_BLUETOOTH		0x05
239607ca46eSDavid Howells #define BUS_VIRTUAL		0x06
240607ca46eSDavid Howells 
241607ca46eSDavid Howells #define BUS_ISA			0x10
242607ca46eSDavid Howells #define BUS_I8042		0x11
243607ca46eSDavid Howells #define BUS_XTKBD		0x12
244607ca46eSDavid Howells #define BUS_RS232		0x13
245607ca46eSDavid Howells #define BUS_GAMEPORT		0x14
246607ca46eSDavid Howells #define BUS_PARPORT		0x15
247607ca46eSDavid Howells #define BUS_AMIGA		0x16
248607ca46eSDavid Howells #define BUS_ADB			0x17
249607ca46eSDavid Howells #define BUS_I2C			0x18
250607ca46eSDavid Howells #define BUS_HOST		0x19
251607ca46eSDavid Howells #define BUS_GSC			0x1A
252607ca46eSDavid Howells #define BUS_ATARI		0x1B
253607ca46eSDavid Howells #define BUS_SPI			0x1C
2542b6a321dSAndrew Duggan #define BUS_RMI			0x1D
2553720b69bSHans Verkuil #define BUS_CEC			0x1E
2560b28cb4bSSrinivas Pandruvada #define BUS_INTEL_ISHTP		0x1F
257607ca46eSDavid Howells 
258607ca46eSDavid Howells /*
259607ca46eSDavid Howells  * MT_TOOL types
260607ca46eSDavid Howells  */
261607ca46eSDavid Howells #define MT_TOOL_FINGER		0
262607ca46eSDavid Howells #define MT_TOOL_PEN		1
263a736775dSCharlie Mooney #define MT_TOOL_PALM		2
264a736775dSCharlie Mooney #define MT_TOOL_MAX		2
265607ca46eSDavid Howells 
266607ca46eSDavid Howells /*
267607ca46eSDavid Howells  * Values describing the status of a force-feedback effect
268607ca46eSDavid Howells  */
269607ca46eSDavid Howells #define FF_STATUS_STOPPED	0x00
270607ca46eSDavid Howells #define FF_STATUS_PLAYING	0x01
271607ca46eSDavid Howells #define FF_STATUS_MAX		0x01
272607ca46eSDavid Howells 
273607ca46eSDavid Howells /*
274607ca46eSDavid Howells  * Structures used in ioctls to upload effects to a device
275607ca46eSDavid Howells  * They are pieces of a bigger structure (called ff_effect)
276607ca46eSDavid Howells  */
277607ca46eSDavid Howells 
278607ca46eSDavid Howells /*
279607ca46eSDavid Howells  * All duration values are expressed in ms. Values above 32767 ms (0x7fff)
280607ca46eSDavid Howells  * should not be used and have unspecified results.
281607ca46eSDavid Howells  */
282607ca46eSDavid Howells 
283607ca46eSDavid Howells /**
284607ca46eSDavid Howells  * struct ff_replay - defines scheduling of the force-feedback effect
285607ca46eSDavid Howells  * @length: duration of the effect
286607ca46eSDavid Howells  * @delay: delay before effect should start playing
287607ca46eSDavid Howells  */
288607ca46eSDavid Howells struct ff_replay {
289607ca46eSDavid Howells 	__u16 length;
290607ca46eSDavid Howells 	__u16 delay;
291607ca46eSDavid Howells };
292607ca46eSDavid Howells 
293607ca46eSDavid Howells /**
294607ca46eSDavid Howells  * struct ff_trigger - defines what triggers the force-feedback effect
295607ca46eSDavid Howells  * @button: number of the button triggering the effect
296607ca46eSDavid Howells  * @interval: controls how soon the effect can be re-triggered
297607ca46eSDavid Howells  */
298607ca46eSDavid Howells struct ff_trigger {
299607ca46eSDavid Howells 	__u16 button;
300607ca46eSDavid Howells 	__u16 interval;
301607ca46eSDavid Howells };
302607ca46eSDavid Howells 
303607ca46eSDavid Howells /**
304607ca46eSDavid Howells  * struct ff_envelope - generic force-feedback effect envelope
305607ca46eSDavid Howells  * @attack_length: duration of the attack (ms)
306607ca46eSDavid Howells  * @attack_level: level at the beginning of the attack
307607ca46eSDavid Howells  * @fade_length: duration of fade (ms)
308607ca46eSDavid Howells  * @fade_level: level at the end of fade
309607ca46eSDavid Howells  *
310607ca46eSDavid Howells  * The @attack_level and @fade_level are absolute values; when applying
311607ca46eSDavid Howells  * envelope force-feedback core will convert to positive/negative
312607ca46eSDavid Howells  * value based on polarity of the default level of the effect.
313607ca46eSDavid Howells  * Valid range for the attack and fade levels is 0x0000 - 0x7fff
314607ca46eSDavid Howells  */
315607ca46eSDavid Howells struct ff_envelope {
316607ca46eSDavid Howells 	__u16 attack_length;
317607ca46eSDavid Howells 	__u16 attack_level;
318607ca46eSDavid Howells 	__u16 fade_length;
319607ca46eSDavid Howells 	__u16 fade_level;
320607ca46eSDavid Howells };
321607ca46eSDavid Howells 
322607ca46eSDavid Howells /**
323607ca46eSDavid Howells  * struct ff_constant_effect - defines parameters of a constant force-feedback effect
324607ca46eSDavid Howells  * @level: strength of the effect; may be negative
325607ca46eSDavid Howells  * @envelope: envelope data
326607ca46eSDavid Howells  */
327607ca46eSDavid Howells struct ff_constant_effect {
328607ca46eSDavid Howells 	__s16 level;
329607ca46eSDavid Howells 	struct ff_envelope envelope;
330607ca46eSDavid Howells };
331607ca46eSDavid Howells 
332607ca46eSDavid Howells /**
333607ca46eSDavid Howells  * struct ff_ramp_effect - defines parameters of a ramp force-feedback effect
334607ca46eSDavid Howells  * @start_level: beginning strength of the effect; may be negative
335607ca46eSDavid Howells  * @end_level: final strength of the effect; may be negative
336607ca46eSDavid Howells  * @envelope: envelope data
337607ca46eSDavid Howells  */
338607ca46eSDavid Howells struct ff_ramp_effect {
339607ca46eSDavid Howells 	__s16 start_level;
340607ca46eSDavid Howells 	__s16 end_level;
341607ca46eSDavid Howells 	struct ff_envelope envelope;
342607ca46eSDavid Howells };
343607ca46eSDavid Howells 
344607ca46eSDavid Howells /**
345607ca46eSDavid Howells  * struct ff_condition_effect - defines a spring or friction force-feedback effect
346607ca46eSDavid Howells  * @right_saturation: maximum level when joystick moved all way to the right
347607ca46eSDavid Howells  * @left_saturation: same for the left side
348607ca46eSDavid Howells  * @right_coeff: controls how fast the force grows when the joystick moves
349607ca46eSDavid Howells  *	to the right
350607ca46eSDavid Howells  * @left_coeff: same for the left side
351607ca46eSDavid Howells  * @deadband: size of the dead zone, where no force is produced
352607ca46eSDavid Howells  * @center: position of the dead zone
353607ca46eSDavid Howells  */
354607ca46eSDavid Howells struct ff_condition_effect {
355607ca46eSDavid Howells 	__u16 right_saturation;
356607ca46eSDavid Howells 	__u16 left_saturation;
357607ca46eSDavid Howells 
358607ca46eSDavid Howells 	__s16 right_coeff;
359607ca46eSDavid Howells 	__s16 left_coeff;
360607ca46eSDavid Howells 
361607ca46eSDavid Howells 	__u16 deadband;
362607ca46eSDavid Howells 	__s16 center;
363607ca46eSDavid Howells };
364607ca46eSDavid Howells 
365607ca46eSDavid Howells /**
366607ca46eSDavid Howells  * struct ff_periodic_effect - defines parameters of a periodic force-feedback effect
367607ca46eSDavid Howells  * @waveform: kind of the effect (wave)
368607ca46eSDavid Howells  * @period: period of the wave (ms)
369607ca46eSDavid Howells  * @magnitude: peak value
370607ca46eSDavid Howells  * @offset: mean value of the wave (roughly)
371607ca46eSDavid Howells  * @phase: 'horizontal' shift
372607ca46eSDavid Howells  * @envelope: envelope data
373607ca46eSDavid Howells  * @custom_len: number of samples (FF_CUSTOM only)
374607ca46eSDavid Howells  * @custom_data: buffer of samples (FF_CUSTOM only)
375607ca46eSDavid Howells  *
376607ca46eSDavid Howells  * Known waveforms - FF_SQUARE, FF_TRIANGLE, FF_SINE, FF_SAW_UP,
377607ca46eSDavid Howells  * FF_SAW_DOWN, FF_CUSTOM. The exact syntax FF_CUSTOM is undefined
378607ca46eSDavid Howells  * for the time being as no driver supports it yet.
379607ca46eSDavid Howells  *
380607ca46eSDavid Howells  * Note: the data pointed by custom_data is copied by the driver.
381607ca46eSDavid Howells  * You can therefore dispose of the memory after the upload/update.
382607ca46eSDavid Howells  */
383607ca46eSDavid Howells struct ff_periodic_effect {
384607ca46eSDavid Howells 	__u16 waveform;
385607ca46eSDavid Howells 	__u16 period;
386607ca46eSDavid Howells 	__s16 magnitude;
387607ca46eSDavid Howells 	__s16 offset;
388607ca46eSDavid Howells 	__u16 phase;
389607ca46eSDavid Howells 
390607ca46eSDavid Howells 	struct ff_envelope envelope;
391607ca46eSDavid Howells 
392607ca46eSDavid Howells 	__u32 custom_len;
393607ca46eSDavid Howells 	__s16 __user *custom_data;
394607ca46eSDavid Howells };
395607ca46eSDavid Howells 
396607ca46eSDavid Howells /**
397607ca46eSDavid Howells  * struct ff_rumble_effect - defines parameters of a periodic force-feedback effect
398607ca46eSDavid Howells  * @strong_magnitude: magnitude of the heavy motor
399607ca46eSDavid Howells  * @weak_magnitude: magnitude of the light one
400607ca46eSDavid Howells  *
401607ca46eSDavid Howells  * Some rumble pads have two motors of different weight. Strong_magnitude
402607ca46eSDavid Howells  * represents the magnitude of the vibration generated by the heavy one.
403607ca46eSDavid Howells  */
404607ca46eSDavid Howells struct ff_rumble_effect {
405607ca46eSDavid Howells 	__u16 strong_magnitude;
406607ca46eSDavid Howells 	__u16 weak_magnitude;
407607ca46eSDavid Howells };
408607ca46eSDavid Howells 
409607ca46eSDavid Howells /**
410607ca46eSDavid Howells  * struct ff_effect - defines force feedback effect
411607ca46eSDavid Howells  * @type: type of the effect (FF_CONSTANT, FF_PERIODIC, FF_RAMP, FF_SPRING,
412607ca46eSDavid Howells  *	FF_FRICTION, FF_DAMPER, FF_RUMBLE, FF_INERTIA, or FF_CUSTOM)
413607ca46eSDavid Howells  * @id: an unique id assigned to an effect
414607ca46eSDavid Howells  * @direction: direction of the effect
415607ca46eSDavid Howells  * @trigger: trigger conditions (struct ff_trigger)
416607ca46eSDavid Howells  * @replay: scheduling of the effect (struct ff_replay)
417607ca46eSDavid Howells  * @u: effect-specific structure (one of ff_constant_effect, ff_ramp_effect,
418607ca46eSDavid Howells  *	ff_periodic_effect, ff_condition_effect, ff_rumble_effect) further
419607ca46eSDavid Howells  *	defining effect parameters
420607ca46eSDavid Howells  *
421607ca46eSDavid Howells  * This structure is sent through ioctl from the application to the driver.
422607ca46eSDavid Howells  * To create a new effect application should set its @id to -1; the kernel
423607ca46eSDavid Howells  * will return assigned @id which can later be used to update or delete
424607ca46eSDavid Howells  * this effect.
425607ca46eSDavid Howells  *
426607ca46eSDavid Howells  * Direction of the effect is encoded as follows:
427607ca46eSDavid Howells  *	0 deg -> 0x0000 (down)
428607ca46eSDavid Howells  *	90 deg -> 0x4000 (left)
429607ca46eSDavid Howells  *	180 deg -> 0x8000 (up)
430607ca46eSDavid Howells  *	270 deg -> 0xC000 (right)
431607ca46eSDavid Howells  */
432607ca46eSDavid Howells struct ff_effect {
433607ca46eSDavid Howells 	__u16 type;
434607ca46eSDavid Howells 	__s16 id;
435607ca46eSDavid Howells 	__u16 direction;
436607ca46eSDavid Howells 	struct ff_trigger trigger;
437607ca46eSDavid Howells 	struct ff_replay replay;
438607ca46eSDavid Howells 
439607ca46eSDavid Howells 	union {
440607ca46eSDavid Howells 		struct ff_constant_effect constant;
441607ca46eSDavid Howells 		struct ff_ramp_effect ramp;
442607ca46eSDavid Howells 		struct ff_periodic_effect periodic;
443607ca46eSDavid Howells 		struct ff_condition_effect condition[2]; /* One for each axis */
444607ca46eSDavid Howells 		struct ff_rumble_effect rumble;
445607ca46eSDavid Howells 	} u;
446607ca46eSDavid Howells };
447607ca46eSDavid Howells 
448607ca46eSDavid Howells /*
449607ca46eSDavid Howells  * Force feedback effect types
450607ca46eSDavid Howells  */
451607ca46eSDavid Howells 
452607ca46eSDavid Howells #define FF_RUMBLE	0x50
453607ca46eSDavid Howells #define FF_PERIODIC	0x51
454607ca46eSDavid Howells #define FF_CONSTANT	0x52
455607ca46eSDavid Howells #define FF_SPRING	0x53
456607ca46eSDavid Howells #define FF_FRICTION	0x54
457607ca46eSDavid Howells #define FF_DAMPER	0x55
458607ca46eSDavid Howells #define FF_INERTIA	0x56
459607ca46eSDavid Howells #define FF_RAMP		0x57
460607ca46eSDavid Howells 
461607ca46eSDavid Howells #define FF_EFFECT_MIN	FF_RUMBLE
462607ca46eSDavid Howells #define FF_EFFECT_MAX	FF_RAMP
463607ca46eSDavid Howells 
464607ca46eSDavid Howells /*
465607ca46eSDavid Howells  * Force feedback periodic effect types
466607ca46eSDavid Howells  */
467607ca46eSDavid Howells 
468607ca46eSDavid Howells #define FF_SQUARE	0x58
469607ca46eSDavid Howells #define FF_TRIANGLE	0x59
470607ca46eSDavid Howells #define FF_SINE		0x5a
471607ca46eSDavid Howells #define FF_SAW_UP	0x5b
472607ca46eSDavid Howells #define FF_SAW_DOWN	0x5c
473607ca46eSDavid Howells #define FF_CUSTOM	0x5d
474607ca46eSDavid Howells 
475607ca46eSDavid Howells #define FF_WAVEFORM_MIN	FF_SQUARE
476607ca46eSDavid Howells #define FF_WAVEFORM_MAX	FF_CUSTOM
477607ca46eSDavid Howells 
478607ca46eSDavid Howells /*
479607ca46eSDavid Howells  * Set ff device properties
480607ca46eSDavid Howells  */
481607ca46eSDavid Howells 
482607ca46eSDavid Howells #define FF_GAIN		0x60
483607ca46eSDavid Howells #define FF_AUTOCENTER	0x61
484607ca46eSDavid Howells 
48533b96d93SElias Vanderstuyft /*
48633b96d93SElias Vanderstuyft  * ff->playback(effect_id = FF_GAIN) is the first effect_id to
48733b96d93SElias Vanderstuyft  * cause a collision with another ff method, in this case ff->set_gain().
48833b96d93SElias Vanderstuyft  * Therefore the greatest safe value for effect_id is FF_GAIN - 1,
48933b96d93SElias Vanderstuyft  * and thus the total number of effects should never exceed FF_GAIN.
49033b96d93SElias Vanderstuyft  */
49133b96d93SElias Vanderstuyft #define FF_MAX_EFFECTS	FF_GAIN
49233b96d93SElias Vanderstuyft 
493607ca46eSDavid Howells #define FF_MAX		0x7f
494607ca46eSDavid Howells #define FF_CNT		(FF_MAX+1)
495607ca46eSDavid Howells 
496607ca46eSDavid Howells #endif /* _UAPI_INPUT_H */
497