inttest_haptic(SDL_Joystick*joystick){SDL_Haptic*haptic;SDL_HapticEffecteffect;inteffect_id;// Open the devicehaptic=SDL_HapticOpenFromJoystick(joystick);if(haptic==NULL)return-1;// Most likely joystick isn't haptic// See if it can do sine wavesif((SDL_HapticQuery(haptic)&SDL_HAPTIC_SINE)==0){SDL_HapticClose(haptic);// No sine effectreturn-1;}// Create the effectSDL_memset(&effect,0,sizeof(SDL_HapticEffect));// 0 is safe defaulteffect.type=SDL_HAPTIC_SINE;effect.periodic.direction.type=SDL_HAPTIC_POLAR;// Polar coordinateseffect.periodic.direction.dir[0]=18000;// Force comes from southeffect.periodic.period=1000;// 1000 mseffect.periodic.magnitude=20000;// 20000/32767 strengtheffect.periodic.length=5000;// 5 seconds longeffect.periodic.attack_length=1000;// Takes 1 second to get max strengtheffect.periodic.fade_length=1000;// Takes 1 second to fade away// Upload the effecteffect_id=SDL_HapticNewEffect(haptic,&effect);// Test the effectSDL_HapticRunEffect(haptic,effect_id,1);SDL_Delay(5000);// Wait for the effect to finish// We destroy the effect, although closing the device also does thisSDL_HapticDestroyEffect(haptic,effect_id);// Close the deviceSDL_HapticClose(haptic);return0;// Success}