94
110
if (ioctl(fd, EVIOCGEFFECTS, &n_effects) == -1) {
95
111
perror("Ioctl number of effects");
99
114
printf("%d\n", n_effects);
101
/* download a constant effect */
102
effects[1].type = FF_CONSTANT;
104
effects[1].u.constant.level = 0x2000; /* Strength : 25 % */
105
effects[1].u.constant.direction = 0x6000; /* 135 degrees */
106
effects[1].u.constant.shape.attack_length = 0x100;
107
effects[1].u.constant.shape.attack_level = 0;
108
effects[1].u.constant.shape.fade_length = 0x100;
109
effects[1].u.constant.shape.fade_level = 0;
110
effects[1].trigger.button = 0;
111
effects[1].trigger.interval = 0;
112
effects[1].replay.length = 0x1400; /* 20 seconds */
113
effects[1].replay.delay = 0;
115
if (ioctl(fd, EVIOCSFF, &effects[1]) == -1) {
116
perror("Upload effects[1]");
120
116
/* download a periodic sinusoidal effect */
121
117
effects[0].type = FF_PERIODIC;
122
118
effects[0].id = -1;
125
121
effects[0].u.periodic.magnitude = 0x4000; /* 0.5 * Maximum magnitude */
126
122
effects[0].u.periodic.offset = 0;
127
123
effects[0].u.periodic.phase = 0;
128
effects[0].u.periodic.direction = 0x4000; /* Along X axis */
129
effects[0].u.periodic.shape.attack_length = 0x100;
130
effects[0].u.periodic.shape.attack_level = 0;
131
effects[0].u.periodic.shape.fade_length = 0x100;
132
effects[0].u.periodic.shape.fade_level = 0;
124
effects[0].direction = 0x4000; /* Along X axis */
125
effects[0].u.periodic.envelope.attack_length = 0x100;
126
effects[0].u.periodic.envelope.attack_level = 0;
127
effects[0].u.periodic.envelope.fade_length = 0x100;
128
effects[0].u.periodic.envelope.fade_level = 0;
133
129
effects[0].trigger.button = 0;
134
130
effects[0].trigger.interval = 0;
135
effects[0].replay.length = 0x1400; /* 20 seconds */
131
effects[0].replay.length = 20000; /* 20 seconds */
136
132
effects[0].replay.delay = 0;
138
134
if (ioctl(fd, EVIOCSFF, &effects[0]) == -1) {
139
135
perror("Upload effects[0]");
143
/* download an interactive spring effect */
138
/* download a constant effect */
139
effects[1].type = FF_CONSTANT;
141
effects[1].u.constant.level = 0x2000; /* Strength : 25 % */
142
effects[1].direction = 0x6000; /* 135 degrees */
143
effects[1].u.constant.envelope.attack_length = 0x100;
144
effects[1].u.constant.envelope.attack_level = 0;
145
effects[1].u.constant.envelope.fade_length = 0x100;
146
effects[1].u.constant.envelope.fade_level = 0;
147
effects[1].trigger.button = 0;
148
effects[1].trigger.interval = 0;
149
effects[1].replay.length = 20000; /* 20 seconds */
150
effects[1].replay.delay = 0;
152
if (ioctl(fd, EVIOCSFF, &effects[1]) == -1) {
153
perror("Upload effects[1]");
156
/* download an condition spring effect */
144
157
effects[2].type = FF_SPRING;
145
158
effects[2].id = -1;
146
effects[2].u.interactive.axis = ABS_X;
147
effects[2].u.interactive.right_saturation = 0x7fff;
148
effects[2].u.interactive.left_saturation = 0x7fff;
149
effects[2].u.interactive.right_coeff = 0x2000;
150
effects[2].u.interactive.left_coeff = 0x2000;
151
effects[2].u.interactive.deadband = 0x0;
152
effects[2].u.interactive.center = 0x0;
159
effects[2].u.condition[0].right_saturation = 0x7fff;
160
effects[2].u.condition[0].left_saturation = 0x7fff;
161
effects[2].u.condition[0].right_coeff = 0x2000;
162
effects[2].u.condition[0].left_coeff = 0x2000;
163
effects[2].u.condition[0].deadband = 0x0;
164
effects[2].u.condition[0].center = 0x0;
165
effects[2].u.condition[1] = effects[2].u.condition[0];
153
166
effects[2].trigger.button = 0;
154
167
effects[2].trigger.interval = 0;
155
effects[2].replay.length = 0x1400; /* 20 seconds */
168
effects[2].replay.length = 20000; /* 20 seconds */
156
169
effects[2].replay.delay = 0;
158
171
if (ioctl(fd, EVIOCSFF, &effects[2]) == -1) {
159
172
perror("Upload effects[2]");
163
/* download an interactive damper effect */
164
effects[3].type = FF_FRICTION;
175
/* download an condition damper effect */
176
effects[3].type = FF_DAMPER;
165
177
effects[3].id = -1;
166
effects[3].u.interactive.axis = ABS_X;
167
effects[3].u.interactive.right_saturation = 0x7fff;
168
effects[3].u.interactive.left_saturation = 0x7fff;
169
effects[3].u.interactive.right_coeff = 0x2000;
170
effects[3].u.interactive.left_coeff = 0x2000;
171
effects[3].u.interactive.deadband = 0x0;
172
effects[3].u.interactive.center = 0x0;
178
effects[3].u.condition[0].right_saturation = 0x7fff;
179
effects[3].u.condition[0].left_saturation = 0x7fff;
180
effects[3].u.condition[0].right_coeff = 0x2000;
181
effects[3].u.condition[0].left_coeff = 0x2000;
182
effects[3].u.condition[0].deadband = 0x0;
183
effects[3].u.condition[0].center = 0x0;
184
effects[3].u.condition[1] = effects[3].u.condition[0];
173
185
effects[3].trigger.button = 0;
174
186
effects[3].trigger.interval = 0;
175
effects[3].replay.length = 0x1400; /* 20 seconds */
187
effects[3].replay.length = 20000; /* 20 seconds */
176
188
effects[3].replay.delay = 0;
178
190
if (ioctl(fd, EVIOCSFF, &effects[3]) == -1) {
179
191
perror("Upload effects[3]");
194
/* a strong rumbling effect */
195
effects[4].type = FF_RUMBLE;
197
effects[4].u.rumble.strong_magnitude = 0x8000;
198
effects[4].u.rumble.weak_magnitude = 0;
199
effects[4].replay.length = 5000;
200
effects[4].replay.delay = 1000;
202
if (ioctl(fd, EVIOCSFF, &effects[4]) == -1) {
203
perror("Upload effects[4]");
206
/* a weak rumbling effect */
207
effects[5].type = FF_RUMBLE;
209
effects[5].u.rumble.strong_magnitude = 0;
210
effects[5].u.rumble.weak_magnitude = 0xc000;
211
effects[5].replay.length = 5000;
212
effects[5].replay.delay = 0;
214
if (ioctl(fd, EVIOCSFF, &effects[5]) == -1) {
215
perror("Upload effects[5]");
183
219
/* Ask user what effects to play */