| Summary: | Cannot create custom effect | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Laban <laban.kallgren> |
| Component: | haptic | Assignee: | Ryan C. Gordon <icculus> |
| Status: | NEW --- | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | ||
| Version: | 2.0.6 | ||
| Hardware: | x86 | ||
| OS: | Windows 10 | ||
Trying to create effect of type SDL_HAPTIC_CUSTOM, returns failure code (-1) and message “Haptic error Unable to create effect”. Is SDL_HapticCustom.data (Uint16*) really supposed to be unsigned if it is a custom signal? Should be able to have negative values as well? Trying with gaming wheel 'Thrustmaster T300RS Racing Wheel', windows 10. Call chain is: [My code]-> int SDL_HapticNewEffect(SDL_Haptic * haptic, SDL_HapticEffect * effect); int SDL_SYS_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SDL_HapticEffect * base); int SDL_DINPUT_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SDL_HapticEffect * base) --> DI_SetError("Unable to create effect", ret); [My code in effective] SDL_InitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC); int device_index = 0; SDL_Joystick* joystick = SDL_JoystickOpen(device_index); assert(SDL_JoystickIsHaptic(joystick)); SDL_Haptic* haptic = SDL_HapticOpen(device_index); SDL_HapticEffect* effect = new SDL_HapticEffect; SDL_memset(effect , 0, sizeof(SDL_HapticEffect)); effect->type = SDL_HAPTIC_CUSTOM; effect->custom.direction.type = SDL_HAPTIC_CARTESIAN; effect->custom.direction.dir[0] = 1; effect->custom.length = 5000; effect->custom.period = 1000; const int nof_samples = 1000; effect->custom.channels = 1; effect->custom.samples = nof_samples; effect->custom.data = new Uint16[nof_samples]; for(int i = 0; i < nof_samples; ++i) { effect->custom.data[i] = Uint16(0); //Or some generated signal } assert(SDL_HapticEffectSupported(haptic, effect)); //All ok! std::cout << SDL_HapticNewEffect(haptic, effect) << std::endl; //Returns -1 std::cout << SDL_GetError() << std::endl; //prints "Haptic error Unable to create effect"