aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/input/ff.txt
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /Documentation/input/ff.txt
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'Documentation/input/ff.txt')
-rw-r--r--Documentation/input/ff.txt227
1 files changed, 227 insertions, 0 deletions
diff --git a/Documentation/input/ff.txt b/Documentation/input/ff.txt
new file mode 100644
index 000000000000..efa7dd6751f3
--- /dev/null
+++ b/Documentation/input/ff.txt
@@ -0,0 +1,227 @@
1Force feedback for Linux.
2By Johann Deneux <deneux@ifrance.com> on 2001/04/22.
3You may redistribute this file. Please remember to include shape.fig and
4interactive.fig as well.
5----------------------------------------------------------------------------
6
70. Introduction
8~~~~~~~~~~~~~~~
9This document describes how to use force feedback devices under Linux. The
10goal is not to support these devices as if they were simple input-only devices
11(as it is already the case), but to really enable the rendering of force
12effects.
13At the moment, only I-Force devices are supported, and not officially. That
14means I had to find out how the protocol works on my own. Of course, the
15information I managed to grasp is far from being complete, and I can not
16guarranty that this driver will work for you.
17This document only describes the force feedback part of the driver for I-Force
18devices. Please read joystick.txt before reading further this document.
19
202. Instructions to the user
21~~~~~~~~~~~~~~~~~~~~~~~~~~~
22Here are instructions on how to compile and use the driver. In fact, this
23driver is the normal iforce, input and evdev drivers written by Vojtech
24Pavlik, plus additions to support force feedback.
25
26Before you start, let me WARN you that some devices shake violently during the
27initialisation phase. This happens for example with my "AVB Top Shot Pegasus".
28To stop this annoying behaviour, move you joystick to its limits. Anyway, you
29should keep a hand on your device, in order to avoid it to brake down if
30something goes wrong.
31
32At the kernel's compilation:
33 - Enable IForce/Serial
34 - Enable Event interface
35
36Compile the modules, install them.
37
38You also need inputattach.
39
40You then need to insert the modules into the following order:
41% modprobe joydev
42% modprobe serport # Only for serial
43% modprobe iforce
44% modprobe evdev
45% ./inputattach -ifor $2 & # Only for serial
46If you are using USB, you don't need the inputattach step.
47
48Please check that you have all the /dev/input entries needed:
49cd /dev
50rm js*
51mkdir input
52mknod input/js0 c 13 0
53mknod input/js1 c 13 1
54mknod input/js2 c 13 2
55mknod input/js3 c 13 3
56ln -s input/js0 js0
57ln -s input/js1 js1
58ln -s input/js2 js2
59ln -s input/js3 js3
60
61mknod input/event0 c 13 64
62mknod input/event1 c 13 65
63mknod input/event2 c 13 66
64mknod input/event3 c 13 67
65
662.1 Does it work ?
67~~~~~~~~~~~~~~~~~~
68There is an utility called fftest that will allow you to test the driver.
69% fftest /dev/input/eventXX
70
713. Instructions to the developper
72~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
73 All interactions are done using the event API. That is, you can use ioctl()
74and write() on /dev/input/eventXX.
75 This information is subject to change.
76
773.1 Querying device capabilities
78~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
79#include <linux/input.h>
80#include <sys/ioctl.h>
81
82unsigned long features[1 + FF_MAX/sizeof(unsigned long)];
83int ioctl(int file_descriptor, int request, unsigned long *features);
84
85"request" must be EVIOCGBIT(EV_FF, size of features array in bytes )
86
87Returns the features supported by the device. features is a bitfield with the
88following bits:
89- FF_X has an X axis (usually joysticks)
90- FF_Y has an Y axis (usually joysticks)
91- FF_WHEEL has a wheel (usually sterring wheels)
92- FF_CONSTANT can render constant force effects
93- FF_PERIODIC can render periodic effects (sine, triangle, square...)
94- FF_RAMP can render ramp effects
95- FF_SPRING can simulate the presence of a spring
96- FF_FRICTION can simulate friction
97- FF_DAMPER can simulate damper effects
98- FF_RUMBLE rumble effects (normally the only effect supported by rumble
99 pads)
100- FF_INERTIA can simulate inertia
101
102
103int ioctl(int fd, EVIOCGEFFECTS, int *n);
104
105Returns the number of effects the device can keep in its memory.
106
1073.2 Uploading effects to the device
108~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
109#include <linux/input.h>
110#include <sys/ioctl.h>
111
112int ioctl(int file_descriptor, int request, struct ff_effect *effect);
113
114"request" must be EVIOCSFF.
115
116"effect" points to a structure describing the effect to upload. The effect is
117uploaded, but not played.
118The content of effect may be modified. In particular, its field "id" is set
119to the unique id assigned by the driver. This data is required for performing
120some operations (removing an effect, controlling the playback).
121This if field must be set to -1 by the user in order to tell the driver to
122allocate a new effect.
123See <linux/input.h> for a description of the ff_effect stuct. You should also
124find help in a few sketches, contained in files shape.fig and interactive.fig.
125You need xfig to visualize these files.
126
1273.3 Removing an effect from the device
128~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
129int ioctl(int fd, EVIOCRMFF, effect.id);
130
131This makes room for new effects in the device's memory. Please note this won't
132stop the effect if it was playing.
133
1343.4 Controlling the playback of effects
135~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
136Control of playing is done with write(). Below is an example:
137
138#include <linux/input.h>
139#include <unistd.h>
140
141 struct input_event play;
142 struct input_event stop;
143 struct ff_effect effect;
144 int fd;
145...
146 fd = open("/dev/input/eventXX", O_RDWR);
147...
148 /* Play three times */
149 play.type = EV_FF;
150 play.code = effect.id;
151 play.value = 3;
152
153 write(fd, (const void*) &play, sizeof(play));
154...
155 /* Stop an effect */
156 stop.type = EV_FF;
157 stop.code = effect.id;
158 stop.value = 0;
159
160 write(fd, (const void*) &play, sizeof(stop));
161
1623.5 Setting the gain
163~~~~~~~~~~~~~~~~~~~~
164Not all devices have the same strength. Therefore, users should set a gain
165factor depending on how strong they want effects to be. This setting is
166persistent across access to the driver, so you should not care about it if
167you are writing games, as another utility probably already set this for you.
168
169/* Set the gain of the device
170int gain; /* between 0 and 100 */
171struct input_event ie; /* structure used to communicate with the driver */
172
173ie.type = EV_FF;
174ie.code = FF_GAIN;
175ie.value = 0xFFFFUL * gain / 100;
176
177if (write(fd, &ie, sizeof(ie)) == -1)
178 perror("set gain");
179
1803.6 Enabling/Disabling autocenter
181~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
182The autocenter feature quite disturbs the rendering of effects in my opinion,
183and I think it should be an effect, which computation depends on the game
184type. But you can enable it if you want.
185
186int autocenter; /* between 0 and 100 */
187struct input_event ie;
188
189ie.type = EV_FF;
190ie.code = FF_AUTOCENTER;
191ie.value = 0xFFFFUL * autocenter / 100;
192
193if (write(fd, &ie, sizeof(ie)) == -1)
194 perror("set auto-center");
195
196A value of 0 means "no auto-center".
197
1983.7 Dynamic update of an effect
199~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
200Proceed as if you wanted to upload a new effect, except that instead of
201setting the id field to -1, you set it to the wanted effect id.
202Normally, the effect is not stopped and restarted. However, depending on the
203type of device, not all parameters can be dynamically updated. For example,
204the direction of an effect cannot be updated with iforce devices. In this
205case, the driver stops the effect, up-load it, and restart it.
206
207
2083.8 Information about the status of effects
209~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
210Every time the status of an effect is changed, an event is sent. The values
211and meanings of the fields of the event are as follows:
212struct input_event {
213/* When the status of the effect changed */
214 struct timeval time;
215
216/* Set to EV_FF_STATUS */
217 unsigned short type;
218
219/* Contains the id of the effect */
220 unsigned short code;
221
222/* Indicates the status */
223 unsigned int value;
224};
225
226FF_STATUS_STOPPED The effect stopped playing
227FF_STATUS_PLAYING The effect started to play