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