Now compiles cleanly (has yet to work though). gsoc2008_force_feedback
authorEdgar Simo <bobbens@gmail.com>
Tue, 15 Jul 2008 17:35:06 +0000
branchgsoc2008_force_feedback
changeset 25220877146be013
parent 2521 7aa91c21ce5f
child 2523 366d84fdf8d1
Now compiles cleanly (has yet to work though).
src/haptic/darwin/SDL_syshaptic.c
     1.1 --- a/src/haptic/darwin/SDL_syshaptic.c	Tue Jul 15 17:03:34 2008 +0000
     1.2 +++ b/src/haptic/darwin/SDL_syshaptic.c	Tue Jul 15 17:35:06 2008 +0000
     1.3 @@ -29,7 +29,8 @@
     1.4  #include "../../joystick/SDL_sysjoystick.h" /* For the real SDL_Joystick */
     1.5  /*#include "../../joystick/dawrin/SDL_sysjoystick_c.h"*/ /* For joystick hwdata */ 
     1.6  
     1.7 -#include <IOKit/IOTypes.h>
     1.8 +#include <IOKit/IOKitLib.h>
     1.9 +#include <IOKit/hid/IOHIDKeys.h>
    1.10  #include <ForceFeedback/ForceFeedback.h>
    1.11  #include <ForceFeedback/ForceFeedbackConstants.h>
    1.12  
    1.13 @@ -165,7 +166,7 @@
    1.14  
    1.15     /* Check if supports gain. */
    1.16     ret = FFDeviceGetForceFeedbackProperty(device, FFPROP_FFGAIN,
    1.17 -                                          val, sizeof(val));
    1.18 +                                          &val, sizeof(val));
    1.19     if (ret == FF_OK) supported |= SDL_HAPTIC_GAIN;
    1.20     else if (ret != FFERR_UNSUPPORTED) {
    1.21        SDL_SetError("Haptic: Unable to get if device supports gain.");
    1.22 @@ -174,7 +175,7 @@
    1.23  
    1.24     /* Checks if supports autocenter. */
    1.25     ret = FFDeviceGetForceFeedbackProperty(device, FFPROP_AUTOCENTER,
    1.26 -                                          val, sizeof(val));
    1.27 +                                          &val, sizeof(val));
    1.28     if (ret == FF_OK) supported |= SDL_HAPTIC_AUTOCENTER;
    1.29     else if (ret != FFERR_UNSUPPORTED) {
    1.30        SDL_SetError("Haptic: Unable to get if device supports autocenter.");
    1.31 @@ -203,7 +204,7 @@
    1.32     SDL_memset(haptic->hwdata, 0, sizeof(*haptic->hwdata));
    1.33    
    1.34     /* Open the device */
    1.35 -   if (FFCreateDevice( &service, &haptic->hwdata->device ) != FF_OK) {
    1.36 +   if (FFCreateDevice( service, &haptic->hwdata->device ) != FF_OK) {
    1.37        SDL_SetError("Haptic: Unable to create device from service.");
    1.38        goto creat_err;
    1.39     }
    1.40 @@ -246,7 +247,7 @@
    1.41  SDL_SYS_HapticOpen(SDL_Haptic * haptic)
    1.42  {
    1.43     return SDL_SYS_HapticOpenFromService(haptic,
    1.44 -                SDL_hapticlist[haptic->index].device);
    1.45 +                SDL_hapticlist[haptic->index].dev);
    1.46  }
    1.47  
    1.48  
    1.49 @@ -355,13 +356,13 @@
    1.50           rglDir[0] = dir->dir[0];
    1.51           return 0;
    1.52        case SDL_HAPTIC_CARTESIAN:
    1.53 -         effects->dwFlags |= FFEFF_CARTESIAN;
    1.54 +         effect->dwFlags |= FFEFF_CARTESIAN;
    1.55           rglDir[0] = dir->dir[0];
    1.56           rglDir[1] = dir->dir[1];
    1.57           rglDir[2] = dir->dir[2];
    1.58           return 0;
    1.59        case SDL_HAPTIC_SPHERICAL:
    1.60 -         effects->dwFlags |= FFEFF_SPHERICAL;
    1.61 +         effect->dwFlags |= FFEFF_SPHERICAL;
    1.62           rglDir[0] = dir->dir[0];
    1.63           rglDir[1] = dir->dir[1];
    1.64           rglDir[2] = dir->dir[2];
    1.65 @@ -385,6 +386,7 @@
    1.66     FFCONDITION *condition;
    1.67     FFRAMPFORCE *ramp;
    1.68     FFCUSTOMFORCE *custom;
    1.69 +   FFENVELOPE *envelope;
    1.70     SDL_HapticConstant *hap_constant;
    1.71     SDL_HapticPeriodic *hap_periodic;
    1.72     SDL_HapticCondition *hap_condition;
    1.73 @@ -395,7 +397,16 @@
    1.74     dest->dwSize = sizeof(FFEFFECT); /* Set the structure size. */
    1.75     dest->dwSamplePeriod = 0; /* Not used by us. */
    1.76     dest->dwGain = 10000; /* Gain is set globally, not locally. */
    1.77 -   dest->lpEnvelope.dwSize = sizeof(FFENVELOPE); /* Always should be this. */
    1.78 +
    1.79 +   /* Envelope. */
    1.80 +   envelope = SDL_malloc( sizeof(FFENVELOPE) );
    1.81 +   if (envelope == NULL) {
    1.82 +      SDL_OutOfMemory();
    1.83 +      return -1;
    1.84 +   }
    1.85 +   SDL_memset(envelope, 0, sizeof(FFENVELOPE));
    1.86 +   dest->lpEnvelope = envelope;
    1.87 +   envelope->dwSize = sizeof(FFENVELOPE); /* Always should be this. */
    1.88  
    1.89     switch (src->type) {
    1.90        case SDL_HAPTIC_CONSTANT:
    1.91 @@ -418,15 +429,15 @@
    1.92           dest->rgdwAxes = 0;
    1.93  
    1.94           /* Direction. */
    1.95 -         if (SDL_SYS_SetDirection(dest, hap_constant->direction, dest->cAxes) < 0) {
    1.96 +         if (SDL_SYS_SetDirection(dest, &hap_constant->direction, dest->cAxes) < 0) {
    1.97              return -1;
    1.98           }
    1.99           
   1.100           /* Envelope */
   1.101 -         dest->lpEnvelope.dwAttackLevel = CONVERT(hap_constant->attack_level);
   1.102 -         dest->lpEnvelope.dwAttackTime = hap_constant->attack_length * 1000;
   1.103 -         dest->lpEnvelope.dwFadeLevel = CONVERT(hap_constant->fade_level);
   1.104 -         dest->lpEnvelope.dwFadeTime = hap_constant->fade_length * 1000;
   1.105 +         envelope->dwAttackLevel = CONVERT(hap_constant->attack_level);
   1.106 +         envelope->dwAttackTime = hap_constant->attack_length * 1000;
   1.107 +         envelope->dwFadeLevel = CONVERT(hap_constant->fade_level);
   1.108 +         envelope->dwFadeTime = hap_constant->fade_length * 1000;
   1.109  
   1.110           break;
   1.111  
   1.112 @@ -437,7 +448,7 @@
   1.113        case SDL_HAPTIC_TRIANGLE:
   1.114        case SDL_HAPTIC_SAWTOOTHUP:
   1.115        case SDL_HAPTIC_SAWTOOTHDOWN:
   1.116 -         periodic = &src->periodic;
   1.117 +         hap_periodic = &src->periodic;
   1.118  
   1.119           break;
   1.120  
   1.121 @@ -445,12 +456,12 @@
   1.122        case SDL_HAPTIC_DAMPER:
   1.123        case SDL_HAPTIC_INERTIA:
   1.124        case SDL_HAPTIC_FRICTION:
   1.125 -         condition = &src->condition;
   1.126 +         hap_condition = &src->condition;
   1.127  
   1.128           break;
   1.129  
   1.130        case SDL_HAPTIC_RAMP:
   1.131 -         ramp = &src->ramp;
   1.132 +         hap_ramp = &src->ramp;
   1.133  
   1.134           break;
   1.135