Mercurial > sdl-ios-xcode
comparison src/haptic/linux/SDL_syshaptic.c @ 2487:4c8e25ef2d97 gsoc2008_force_feedback
Merged seperate waveforms into types to be more compatible.
author | Edgar Simo <bobbens@gmail.com> |
---|---|
date | Tue, 01 Jul 2008 16:42:12 +0000 |
parents | 24dd8b8669fa |
children | 8e2bdbccf7ff |
comparison
equal
deleted
inserted
replaced
2486:24dd8b8669fa | 2487:4c8e25ef2d97 |
---|---|
86 ret = 0; | 86 ret = 0; |
87 | 87 |
88 ioctl(fd, EVIOCGBIT(EV_FF, sizeof(unsigned long) * 4), features); | 88 ioctl(fd, EVIOCGBIT(EV_FF, sizeof(unsigned long) * 4), features); |
89 | 89 |
90 EV_TEST(FF_CONSTANT, SDL_HAPTIC_CONSTANT); | 90 EV_TEST(FF_CONSTANT, SDL_HAPTIC_CONSTANT); |
91 EV_TEST(FF_PERIODIC, SDL_HAPTIC_PERIODIC); | 91 EV_TEST(FF_PERIODIC, SDL_HAPTIC_SINE | |
92 SDL_HAPTIC_SQUARE | | |
93 SDL_HAPTIC_TRIANGLE | | |
94 SDL_HAPTIC_SAWTOOTHUP | | |
95 SDL_HAPTIC_SAWTOOTHDOWN); | |
92 EV_TEST(FF_RAMP, SDL_HAPTIC_RAMP); | 96 EV_TEST(FF_RAMP, SDL_HAPTIC_RAMP); |
93 EV_TEST(FF_SPRING, SDL_HAPTIC_SPRING); | 97 EV_TEST(FF_SPRING, SDL_HAPTIC_SPRING); |
94 EV_TEST(FF_FRICTION, SDL_HAPTIC_FRICTION); | 98 EV_TEST(FF_FRICTION, SDL_HAPTIC_FRICTION); |
95 EV_TEST(FF_DAMPER, SDL_HAPTIC_DAMPER); | 99 EV_TEST(FF_DAMPER, SDL_HAPTIC_DAMPER); |
96 EV_TEST(FF_INERTIA, SDL_HAPTIC_INERTIA); | 100 EV_TEST(FF_INERTIA, SDL_HAPTIC_INERTIA); |
315 dest->u.constant.envelope.fade_length = CLAMP(constant->fade_length); | 319 dest->u.constant.envelope.fade_length = CLAMP(constant->fade_length); |
316 dest->u.constant.envelope.fade_level = CLAMP(constant->fade_level); | 320 dest->u.constant.envelope.fade_level = CLAMP(constant->fade_level); |
317 | 321 |
318 break; | 322 break; |
319 | 323 |
320 case SDL_HAPTIC_PERIODIC: | 324 case SDL_HAPTIC_SINE: |
325 case SDL_HAPTIC_SQUARE: | |
326 case SDL_HAPTIC_TRIANGLE: | |
327 case SDL_HAPTIC_SAWTOOTHUP: | |
328 case SDL_HAPTIC_SAWTOOTHDOWN: | |
321 periodic = &src->periodic; | 329 periodic = &src->periodic; |
322 | 330 |
323 /* Header */ | 331 /* Header */ |
324 dest->type = FF_PERIODIC; | 332 dest->type = FF_PERIODIC; |
325 dest->direction = CLAMP(periodic->direction); | 333 dest->direction = CLAMP(periodic->direction); |
330 | 338 |
331 /* Trigger */ | 339 /* Trigger */ |
332 dest->trigger.button = CLAMP(periodic->button); | 340 dest->trigger.button = CLAMP(periodic->button); |
333 dest->trigger.interval = CLAMP(periodic->interval); | 341 dest->trigger.interval = CLAMP(periodic->interval); |
334 | 342 |
335 /* Constant */ | 343 /* Periodic */ |
336 switch (periodic->waveform) { | 344 if (periodic->type == SDL_HAPTIC_SINE) |
337 case SDL_WAVEFORM_SINE: | 345 dest->u.periodic.waveform = FF_SINE; |
338 dest->u.periodic.waveform = FF_SINE; | 346 else if (periodic->type == SDL_HAPTIC_SQUARE) |
339 break; | 347 dest->u.periodic.waveform = FF_SQUARE; |
340 case SDL_WAVEFORM_SQUARE: | 348 else if (periodic->type == SDL_HAPTIC_TRIANGLE) |
341 dest->u.periodic.waveform = FF_SQUARE; | 349 dest->u.periodic.waveform = FF_TRIANGLE; |
342 break; | 350 else if (periodic->type == SDL_HAPTIC_SAWTOOTHUP) |
343 case SDL_WAVEFORM_TRIANGLE: | 351 dest->u.periodic.waveform = FF_SAW_UP; |
344 dest->u.periodic.waveform = FF_TRIANGLE; | 352 else if (periodic->type == SDL_HAPTIC_SAWTOOTHDOWN) |
345 break; | 353 dest->u.periodic.waveform = FF_SAW_DOWN; |
346 case SDL_WAVEFORM_SAWTOOTHUP: | |
347 dest->u.periodic.waveform = FF_SAW_UP; | |
348 break; | |
349 case SDL_WAVEFORM_SAWTOOTHDOWN: | |
350 dest->u.periodic.waveform = FF_SAW_DOWN; | |
351 break; | |
352 | |
353 default: | |
354 SDL_SetError("Unknown waveform."); | |
355 return -1; | |
356 } | |
357 dest->u.periodic.period = CLAMP(periodic->period); | 354 dest->u.periodic.period = CLAMP(periodic->period); |
358 dest->u.periodic.magnitude = periodic->magnitude; | 355 dest->u.periodic.magnitude = periodic->magnitude; |
359 dest->u.periodic.offset = periodic->offset; | 356 dest->u.periodic.offset = periodic->offset; |
360 dest->u.periodic.phase = CLAMP(periodic->phase); | 357 dest->u.periodic.phase = CLAMP(periodic->phase); |
361 | 358 |
515 return 0; | 512 return 0; |
516 } | 513 } |
517 | 514 |
518 | 515 |
519 /* | 516 /* |
520 * Frees the effect | 517 * Frees the effect. |
521 */ | 518 */ |
522 void | 519 void |
523 SDL_SYS_HapticDestroyEffect(SDL_Haptic * haptic, struct haptic_effect * effect) | 520 SDL_SYS_HapticDestroyEffect(SDL_Haptic * haptic, struct haptic_effect * effect) |
524 { | 521 { |
525 if (ioctl(haptic->hwdata->fd, EVIOCRMFF, effect->hweffect->effect.id) < 0) { | 522 if (ioctl(haptic->hwdata->fd, EVIOCRMFF, effect->hweffect->effect.id) < 0) { |