2 * Copyright (c) 1999-2002 Vojtech Pavlik
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 as published by
6 * the Free Software Foundation.
14 #include <sys/ioctl.h>
15 #include <sys/types.h>
16 #include <linux/types.h>
19 #include "input-event-codes.h"
22 * The event structure itself
36 #define EV_VERSION 0x010001
39 * IOCTLs (0x00 - 0x7f)
50 * struct input_absinfo - used by EVIOCGABS/EVIOCSABS ioctls
51 * @value: latest reported value for the axis.
52 * @minimum: specifies minimum value for the axis.
53 * @maximum: specifies maximum value for the axis.
54 * @fuzz: specifies fuzz value that is used to filter noise from
56 * @flat: values that are within this value will be discarded by
57 * joydev interface and reported as 0 instead.
58 * @resolution: specifies resolution for the values reported for
61 * Note that input core does not clamp reported values to the
62 * [minimum, maximum] limits, such task is left to userspace.
64 * Resolution for main axes (ABS_X, ABS_Y, ABS_Z) is reported in
65 * units per millimeter (units/mm), resolution for rotational axes
66 * (ABS_RX, ABS_RY, ABS_RZ) is reported in units per radian.
68 struct input_absinfo {
78 * struct input_keymap_entry - used by EVIOCGKEYCODE/EVIOCSKEYCODE ioctls
79 * @scancode: scancode represented in machine-endian form.
80 * @len: length of the scancode that resides in @scancode buffer.
81 * @index: index in the keymap, may be used instead of scancode
82 * @flags: allows to specify how kernel should handle the request. For
83 * example, setting INPUT_KEYMAP_BY_INDEX flag indicates that kernel
84 * should perform lookup in keymap by @index instead of @scancode
85 * @keycode: key code assigned to this scancode
87 * The structure is used to retrieve and modify keymap data. Users have
88 * option of performing lookup either by @scancode itself or by @index
89 * in keymap entry. EVIOCGKEYCODE will also return scancode or index
90 * (depending on which element was used to perform lookup).
92 struct input_keymap_entry {
93 #define INPUT_KEYMAP_BY_INDEX (1 << 0)
101 #define EVIOCGVERSION _IOR('E', 0x01, int) /* get driver version */
102 #define EVIOCGID _IOR('E', 0x02, struct input_id) /* get device ID */
103 #define EVIOCGREP _IOR('E', 0x03, unsigned int[2]) /* get repeat settings */
104 #define EVIOCSREP _IOW('E', 0x03, unsigned int[2]) /* set repeat settings */
106 #define EVIOCGKEYCODE _IOR('E', 0x04, unsigned int[2]) /* get keycode */
107 #define EVIOCGKEYCODE_V2 _IOR('E', 0x04, struct input_keymap_entry)
108 #define EVIOCSKEYCODE _IOW('E', 0x04, unsigned int[2]) /* set keycode */
109 #define EVIOCSKEYCODE_V2 _IOW('E', 0x04, struct input_keymap_entry)
111 #define EVIOCGNAME(len) _IOC(_IOC_READ, 'E', 0x06, len) /* get device name */
112 #define EVIOCGPHYS(len) _IOC(_IOC_READ, 'E', 0x07, len) /* get physical location */
113 #define EVIOCGUNIQ(len) _IOC(_IOC_READ, 'E', 0x08, len) /* get unique identifier */
114 #define EVIOCGPROP(len) _IOC(_IOC_READ, 'E', 0x09, len) /* get device properties */
117 * EVIOCGMTSLOTS(len) - get MT slot values
118 * @len: size of the data buffer in bytes
120 * The ioctl buffer argument should be binary equivalent to
122 * struct input_mt_request_layout {
124 * __s32 values[num_slots];
127 * where num_slots is the (arbitrary) number of MT slots to extract.
129 * The ioctl size argument (len) is the size of the buffer, which
130 * should satisfy len = (num_slots + 1) * sizeof(__s32). If len is
131 * too small to fit all available slots, the first num_slots are
134 * Before the call, code is set to the wanted ABS_MT event type. On
135 * return, values[] is filled with the slot values for the specified
138 * If the request code is not an ABS_MT value, -EINVAL is returned.
140 #define EVIOCGMTSLOTS(len) _IOC(_IOC_READ, 'E', 0x0a, len)
142 #define EVIOCGKEY(len) _IOC(_IOC_READ, 'E', 0x18, len) /* get global key state */
143 #define EVIOCGLED(len) _IOC(_IOC_READ, 'E', 0x19, len) /* get all LEDs */
144 #define EVIOCGSND(len) _IOC(_IOC_READ, 'E', 0x1a, len) /* get all sounds status */
145 #define EVIOCGSW(len) _IOC(_IOC_READ, 'E', 0x1b, len) /* get all switch states */
147 #define EVIOCGBIT(ev,len) _IOC(_IOC_READ, 'E', 0x20 + (ev), len) /* get event bits */
148 #define EVIOCGABS(abs) _IOR('E', 0x40 + (abs), struct input_absinfo) /* get abs value/limits */
149 #define EVIOCSABS(abs) _IOW('E', 0xc0 + (abs), struct input_absinfo) /* set abs value/limits */
151 #define EVIOCSFF _IOC(_IOC_WRITE, 'E', 0x80, sizeof(struct ff_effect)) /* send a force effect to a force feedback device */
152 #define EVIOCRMFF _IOW('E', 0x81, int) /* Erase a force effect */
153 #define EVIOCGEFFECTS _IOR('E', 0x84, int) /* Report number of effects playable at the same time */
155 #define EVIOCGRAB _IOW('E', 0x90, int) /* Grab/Release device */
156 #define EVIOCREVOKE _IOW('E', 0x91, int) /* Revoke device access */
158 #define EVIOCSCLOCKID _IOW('E', 0xa0, int) /* Set clockid to be used for timestamps */
170 #define BUS_ISAPNP 0x02
173 #define BUS_BLUETOOTH 0x05
174 #define BUS_VIRTUAL 0x06
177 #define BUS_I8042 0x11
178 #define BUS_XTKBD 0x12
179 #define BUS_RS232 0x13
180 #define BUS_GAMEPORT 0x14
181 #define BUS_PARPORT 0x15
182 #define BUS_AMIGA 0x16
185 #define BUS_HOST 0x19
187 #define BUS_ATARI 0x1B
193 #define MT_TOOL_FINGER 0
194 #define MT_TOOL_PEN 1
195 #define MT_TOOL_PALM 2
196 #define MT_TOOL_MAX 2
199 * Values describing the status of a force-feedback effect
201 #define FF_STATUS_STOPPED 0x00
202 #define FF_STATUS_PLAYING 0x01
203 #define FF_STATUS_MAX 0x01
206 * Structures used in ioctls to upload effects to a device
207 * They are pieces of a bigger structure (called ff_effect)
211 * All duration values are expressed in ms. Values above 32767 ms (0x7fff)
212 * should not be used and have unspecified results.
216 * struct ff_replay - defines scheduling of the force-feedback effect
217 * @length: duration of the effect
218 * @delay: delay before effect should start playing
226 * struct ff_trigger - defines what triggers the force-feedback effect
227 * @button: number of the button triggering the effect
228 * @interval: controls how soon the effect can be re-triggered
236 * struct ff_envelope - generic force-feedback effect envelope
237 * @attack_length: duration of the attack (ms)
238 * @attack_level: level at the beginning of the attack
239 * @fade_length: duration of fade (ms)
240 * @fade_level: level at the end of fade
242 * The @attack_level and @fade_level are absolute values; when applying
243 * envelope force-feedback core will convert to positive/negative
244 * value based on polarity of the default level of the effect.
245 * Valid range for the attack and fade levels is 0x0000 - 0x7fff
255 * struct ff_constant_effect - defines parameters of a constant force-feedback effect
256 * @level: strength of the effect; may be negative
257 * @envelope: envelope data
259 struct ff_constant_effect {
261 struct ff_envelope envelope;
265 * struct ff_ramp_effect - defines parameters of a ramp force-feedback effect
266 * @start_level: beginning strength of the effect; may be negative
267 * @end_level: final strength of the effect; may be negative
268 * @envelope: envelope data
270 struct ff_ramp_effect {
273 struct ff_envelope envelope;
277 * struct ff_condition_effect - defines a spring or friction force-feedback effect
278 * @right_saturation: maximum level when joystick moved all way to the right
279 * @left_saturation: same for the left side
280 * @right_coeff: controls how fast the force grows when the joystick moves
282 * @left_coeff: same for the left side
283 * @deadband: size of the dead zone, where no force is produced
284 * @center: position of the dead zone
286 struct ff_condition_effect {
287 __u16 right_saturation;
288 __u16 left_saturation;
298 * struct ff_periodic_effect - defines parameters of a periodic force-feedback effect
299 * @waveform: kind of the effect (wave)
300 * @period: period of the wave (ms)
301 * @magnitude: peak value
302 * @offset: mean value of the wave (roughly)
303 * @phase: 'horizontal' shift
304 * @envelope: envelope data
305 * @custom_len: number of samples (FF_CUSTOM only)
306 * @custom_data: buffer of samples (FF_CUSTOM only)
308 * Known waveforms - FF_SQUARE, FF_TRIANGLE, FF_SINE, FF_SAW_UP,
309 * FF_SAW_DOWN, FF_CUSTOM. The exact syntax FF_CUSTOM is undefined
310 * for the time being as no driver supports it yet.
312 * Note: the data pointed by custom_data is copied by the driver.
313 * You can therefore dispose of the memory after the upload/update.
315 struct ff_periodic_effect {
322 struct ff_envelope envelope;
325 __s16 __user *custom_data;
329 * struct ff_rumble_effect - defines parameters of a periodic force-feedback effect
330 * @strong_magnitude: magnitude of the heavy motor
331 * @weak_magnitude: magnitude of the light one
333 * Some rumble pads have two motors of different weight. Strong_magnitude
334 * represents the magnitude of the vibration generated by the heavy one.
336 struct ff_rumble_effect {
337 __u16 strong_magnitude;
338 __u16 weak_magnitude;
342 * struct ff_effect - defines force feedback effect
343 * @type: type of the effect (FF_CONSTANT, FF_PERIODIC, FF_RAMP, FF_SPRING,
344 * FF_FRICTION, FF_DAMPER, FF_RUMBLE, FF_INERTIA, or FF_CUSTOM)
345 * @id: an unique id assigned to an effect
346 * @direction: direction of the effect
347 * @trigger: trigger conditions (struct ff_trigger)
348 * @replay: scheduling of the effect (struct ff_replay)
349 * @u: effect-specific structure (one of ff_constant_effect, ff_ramp_effect,
350 * ff_periodic_effect, ff_condition_effect, ff_rumble_effect) further
351 * defining effect parameters
353 * This structure is sent through ioctl from the application to the driver.
354 * To create a new effect application should set its @id to -1; the kernel
355 * will return assigned @id which can later be used to update or delete
358 * Direction of the effect is encoded as follows:
359 * 0 deg -> 0x0000 (down)
360 * 90 deg -> 0x4000 (left)
361 * 180 deg -> 0x8000 (up)
362 * 270 deg -> 0xC000 (right)
368 struct ff_trigger trigger;
369 struct ff_replay replay;
372 struct ff_constant_effect constant;
373 struct ff_ramp_effect ramp;
374 struct ff_periodic_effect periodic;
375 struct ff_condition_effect condition[2]; /* One for each axis */
376 struct ff_rumble_effect rumble;
381 * Force feedback effect types
384 #define FF_RUMBLE 0x50
385 #define FF_PERIODIC 0x51
386 #define FF_CONSTANT 0x52
387 #define FF_SPRING 0x53
388 #define FF_FRICTION 0x54
389 #define FF_DAMPER 0x55
390 #define FF_INERTIA 0x56
393 #define FF_EFFECT_MIN FF_RUMBLE
394 #define FF_EFFECT_MAX FF_RAMP
397 * Force feedback periodic effect types
400 #define FF_SQUARE 0x58
401 #define FF_TRIANGLE 0x59
403 #define FF_SAW_UP 0x5b
404 #define FF_SAW_DOWN 0x5c
405 #define FF_CUSTOM 0x5d
407 #define FF_WAVEFORM_MIN FF_SQUARE
408 #define FF_WAVEFORM_MAX FF_CUSTOM
411 * Set ff device properties
415 #define FF_AUTOCENTER 0x61
418 #define FF_CNT (FF_MAX+1)
420 #endif /* _UAPI_INPUT_H */