Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot create custom effect #2670

Closed
SDLBugzilla opened this issue Feb 11, 2021 · 1 comment
Closed

Cannot create custom effect #2670

SDLBugzilla opened this issue Feb 11, 2021 · 1 comment
Labels
abandoned Bug has been abandoned for various reasons

Comments

@SDLBugzilla
Copy link
Collaborator

SDLBugzilla commented Feb 11, 2021

This bug report was migrated from our old Bugzilla tracker.

Reported in version: 2.0.6
Reported for operating system, platform: Windows 10, x86

Comments on the original bug report:

On 2017-10-16 07:59:30 +0000, Laban wrote:

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"

@slouken slouken removed the bug label May 11, 2022
@slouken slouken added the abandoned Bug has been abandoned for various reasons label Nov 5, 2023
@slouken
Copy link
Collaborator

slouken commented Nov 5, 2023

SDL 2.0 is now in maintenance mode, and all inactive issues are being closed. If this issue is impacting you, please feel free to reopen it with additional information.

@slouken slouken closed this as not planned Won't fix, can't repro, duplicate, stale Nov 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
abandoned Bug has been abandoned for various reasons
Projects
None yet
Development

No branches or pull requests

2 participants