Mercurial > sdl-ios-xcode
comparison src/haptic/linux/SDL_syshaptic.c @ 2482:b51ad78812d5 gsoc2008_force_feedback
Removed the linux only SDL_HAPTIC_RUMBLE (use PERIODIC instead).
Added and partially implemented CONDITION and RAMP effects.
author | Edgar Simo <bobbens@gmail.com> |
---|---|
date | Tue, 01 Jul 2008 11:21:36 +0000 |
parents | 5d0ea4576f20 |
children | 9d52368ebcf5 |
comparison
equal
deleted
inserted
replaced
2481:5d0ea4576f20 | 2482:b51ad78812d5 |
---|---|
92 EV_TEST(FF_PERIODIC, SDL_HAPTIC_PERIODIC); | 92 EV_TEST(FF_PERIODIC, SDL_HAPTIC_PERIODIC); |
93 EV_TEST(FF_RAMP, SDL_HAPTIC_RAMP); | 93 EV_TEST(FF_RAMP, SDL_HAPTIC_RAMP); |
94 EV_TEST(FF_SPRING, SDL_HAPTIC_SPRING); | 94 EV_TEST(FF_SPRING, SDL_HAPTIC_SPRING); |
95 EV_TEST(FF_FRICTION, SDL_HAPTIC_FRICTION); | 95 EV_TEST(FF_FRICTION, SDL_HAPTIC_FRICTION); |
96 EV_TEST(FF_DAMPER, SDL_HAPTIC_DAMPER); | 96 EV_TEST(FF_DAMPER, SDL_HAPTIC_DAMPER); |
97 EV_TEST(FF_RUMBLE, SDL_HAPTIC_RUMBLE); | |
98 EV_TEST(FF_INERTIA, SDL_HAPTIC_INERTIA); | 97 EV_TEST(FF_INERTIA, SDL_HAPTIC_INERTIA); |
99 EV_TEST(FF_GAIN, SDL_HAPTIC_GAIN); | 98 EV_TEST(FF_GAIN, SDL_HAPTIC_GAIN); |
100 EV_TEST(FF_AUTOCENTER, SDL_HAPTIC_AUTOCENTER); | 99 EV_TEST(FF_AUTOCENTER, SDL_HAPTIC_AUTOCENTER); |
101 | 100 |
102 return ret; | 101 return ret; |
277 * Values above 32767 (for unsigned) are unspecified so we must clamp. | 276 * Values above 32767 (for unsigned) are unspecified so we must clamp. |
278 */ | 277 */ |
279 static int | 278 static int |
280 SDL_SYS_ToFFEffect( struct ff_effect * dest, SDL_HapticEffect * src ) | 279 SDL_SYS_ToFFEffect( struct ff_effect * dest, SDL_HapticEffect * src ) |
281 { | 280 { |
281 int i; | |
282 SDL_HapticConstant *constant; | 282 SDL_HapticConstant *constant; |
283 SDL_HapticPeriodic *periodic; | 283 SDL_HapticPeriodic *periodic; |
284 SDL_HapticCondition *condition; | |
285 SDL_HapticRamp *ramp; | |
284 | 286 |
285 /* Clear up */ | 287 /* Clear up */ |
286 SDL_memset(dest, 0, sizeof(struct ff_effect)); | 288 SDL_memset(dest, 0, sizeof(struct ff_effect)); |
287 | 289 |
288 switch (src->type) { | 290 switch (src->type) { |
360 dest->u.periodic.envelope.fade_length = CLAMP(periodic->fade_length); | 362 dest->u.periodic.envelope.fade_length = CLAMP(periodic->fade_length); |
361 dest->u.periodic.envelope.fade_level = CLAMP(periodic->fade_level); | 363 dest->u.periodic.envelope.fade_level = CLAMP(periodic->fade_level); |
362 | 364 |
363 break; | 365 break; |
364 | 366 |
367 case SDL_HAPTIC_SPRING: | |
368 case SDL_HAPTIC_DAMPER: | |
369 case SDL_HAPTIC_INERTIA: | |
370 case SDL_HAPTIC_FRICTION: | |
371 condition = &src->condition; | |
372 | |
373 /* Header */ | |
374 if (dest->type == SDL_HAPTIC_SPRING) | |
375 dest->type = FF_SPRING; | |
376 else if (dest->type == SDL_HAPTIC_DAMPER) | |
377 dest->type = FF_DAMPER; | |
378 else if (dest->type == SDL_HAPTIC_INERTIA) | |
379 dest->type = FF_INERTIA; | |
380 else if (dest->type == SDL_HAPTIC_FRICTION) | |
381 dest->type = FF_FRICTION; | |
382 dest->direction = CLAMP(condition->direction); | |
383 | |
384 /* Replay */ | |
385 dest->replay.length = CLAMP(condition->length); | |
386 dest->replay.delay = CLAMP(condition->delay); | |
387 | |
388 /* Trigger */ | |
389 dest->trigger.button = CLAMP(condition->button); | |
390 dest->trigger.interval = CLAMP(condition->interval); | |
391 | |
392 /* Condition - TODO handle axes */ | |
393 dest->u.condition[0].right_saturation = CLAMP(condition->right_sat); | |
394 dest->u.condition[0].left_saturation = CLAMP(condition->left_sat); | |
395 dest->u.condition[0].right_coeff = condition->right_coeff; | |
396 dest->u.condition[0].left_coeff = condition->left_coeff; | |
397 dest->u.condition[0].deadband = CLAMP(condition->deadband); | |
398 dest->u.condition[0].center = condition->center; | |
399 | |
400 break; | |
401 | |
402 case SDL_HAPTIC_RAMP: | |
403 ramp = &src->ramp; | |
404 | |
405 /* Header */ | |
406 dest->type = FF_RAMP; | |
407 dest->direction = CLAMP(ramp->direction); | |
408 | |
409 /* Replay */ | |
410 dest->replay.length = CLAMP(ramp->length); | |
411 dest->replay.delay = CLAMP(ramp->delay); | |
412 | |
413 /* Trigger */ | |
414 dest->trigger.button = CLAMP(ramp->button); | |
415 dest->trigger.interval = CLAMP(ramp->interval); | |
416 | |
417 /* Ramp */ | |
418 dest->u.ramp.start_level = ramp->start; | |
419 dest->u.ramp.end_level = ramp->end; | |
420 | |
421 /* Envelope */ | |
422 dest->u.ramp.envelope.attack_length = CLAMP(ramp->attack_length); | |
423 dest->u.ramp.envelope.attack_level = CLAMP(ramp->attack_level); | |
424 dest->u.ramp.envelope.fade_length = CLAMP(ramp->fade_length); | |
425 dest->u.ramp.envelope.fade_level = CLAMP(ramp->fade_level); | |
426 | |
427 break; | |
428 | |
429 | |
365 default: | 430 default: |
366 SDL_SetError("Unknown haptic effect type."); | 431 SDL_SetError("Unknown haptic effect type."); |
367 return -1; | 432 return -1; |
368 } | 433 } |
369 | 434 |