2

I'm working on a game that will use SDL 2.0.3 for most of the back-end code (rendering, events, game controllers, etc...). So far I've been able to figure out most of my problems, but this issue doesn't seem to have much information on it.

So my problem is that I'm trying to open an Xbox 360 controller for input and vibration feedback. I've gotten the input to work properly, but when I try to use SDL_HapticOpenFromJoystick() to open the device for vibration, it fails and SDL_GetError() says "Haptic: There are 0 haptic devices availible". Both SDL_NumHaptics() and SDL_JoystickIsHaptic() return 0. I'm using SDL_Init(SDL_INIT_EVERYTHING); to initialize.

I know the Xbox 360 controller itself is able to vibrate, as I have games (not written with SDL) on my Windows 8 laptop that can use the force feedback feature in the controller without issues.

If any more information is needed, I would be glad to provide it.

Relavant Code:

SDL_GameController *myController = NULL;
SDL_Haptic *myHaptic = NULL;

...
[Begin Basic SDL Event Loop]
...

        case SDL_CONTROLLERDEVICEADDED:
            if(!myController)
            {
                myController = SDL_GameControllerOpen(e.cdevice.which);
                debugOut("Controller Connected");
                myHaptic = SDL_HapticOpenFromJoystick(SDL_GameControllerGetJoystick(myController));
                if(myHaptic)
                {
                    debugOut("Haptic Device (i.e. Rumble) Opened");
                }
                else
                {
                    debugOut("Error in opening Haptic Device (i.e. Rumble)");
                    debugOut(SDL_GetError());
                    std::cout << "Number of Haptic Devices: " << SDL_NumHaptics() << std::endl;
                    std::cout << "Controller is Haptic?: " << SDL_JoystickIsHaptic(SDL_GameControllerGetJoystick(myController)) << std::endl;
                }
            }
            else
            {
                debugOut("There is already a controller connected, only one allowed right now...");
            }
            break;

EDIT: I should probably add that I'm using Visual Studio Express 2012...

QubicGames
  • 63
  • 1
  • 7
  • I've posted a bug report to the guys at SDL a while ago: [libsdl bugzilla post](https://bugzilla.libsdl.org/show_bug.cgi?id=2612). They do not seem to be fast about bugs though but they might just reply one day. I will add that this bug only seems to happen on Xbox 360 controllers (wired and wireless) as I've had several friends test the rumble with different controllers and they replied it worked just fine. – Villermen Jul 07 '14 at 20:36
  • They did fix it in their dev build now, so you can either build that yourself or wait for the next version which will definitely support it. – Villermen Jul 08 '14 at 21:35

0 Answers0