SDL_HapticOpen & SDL_HapticOpenFromJoystick producing differnet results

I have a generic Chinese made game controller which works well, but I’m having issues getting rumble working.

When I use SDL_HapticOpenFromJoystick, I get a valid SDL_Haptic pointer, but a call to SDL_HapticRumbleInit gives error “Haptic error Unable to create effect”, and so then SDL_HapticRumblePlay gives an error also.

However, if I use SDL_HapticOpen, then SDL_HapticRumbleInit, then SDL_HapticRumblePlay works.

Possible bug?

If I use SDL_HapticOpen, the device index I pass is not the the same index I used for SDL_JoystickOpen, so how can I know which haptic index is related to which joystick index?

I just wanted to bump this because I’m seeing the same with genuine Microsoft Xbox One controllers under Windows 10, with SDL 2.0.14.

When I try SDL_HapticOpenFromJoystick(), I get a nullptr back (different from AntTheAlchemist). This is consistent with the fact that SDL_JoystickIsHaptic() returns false.

The controllers are haptic, of course, and SDL_NumHaptics() returns the correct amount of Xbox controllers connected via Bluetooth.
I can successfully open the haptic device with SDL_HapticOpen(index) and also successfully play the rumble effect, but the indices are not the same as the joystick indices.

Is there a way to either get SDL_HapticOpenFromJoystick() to work, or find out a way to link the indices?

Some more information. I built SDL from source and am currently debugging this. The interesting observation so far is that having 4 connected Xbox One controllers gives me hwdata->userid and instance_id’s which are “opposite”. So the first Joystick has instance_id=3 and hwdata->userid=0, the second has instance_id=2 and hwdata->userid=1, etc. If I match the controllers on instance_id rather than hwdata->userid in SDL_XINPUT_HapticOpenFromJoystick(), then the correct haptic device is coupled to the correct joystick…

I’ve opened an issue on GitHub