Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm trying to learn a bit of SDL, and have been bouncing between Windows and Mac platforms, but am noticing that an SDL program running on my Macbook doesn't recognize the presence of the Xbox controller I have plugged in. I haven't been able to find anything concrete that says one won't work with the other, which is why I'm here.

For reference, here's the code that I'm using to check for the existence of a joystick via SDL:

bool hasJoystick = false;
hasJoystick = (SDL_NumJoysticks() >= 1) ? true : false;
if(hasJoystick) {
    for(int i = 0; i < SDL_NumJoysticks(); i++)
        std::cout << "Joystick " << i+1 << "   " << SDL_JoystickName(i) << std::endl;
} else {
    std::cout << "Yo. No joystick here, kid." << std::endl;
}

I consistently see the "Yo. No joystick here, kid." message in my console. I'm using SDL 1.2 with, and have copied the framework folder to all the appropriate locations. Also, the controller I'm using is 3rd party, but I'm not sure whether that's relevant.

share|improve this question

1 Answer 1

Xbox 360 controllers do not conform to USB HID game controller standards. Even Windows computers require installation of a special, custom driver in order to use them.

Mac computers do not ship with support for Xbox 360 controllers (though they do ship with native support for USB HID game controllers). To use one, you'll need to install a driver for it. Microsoft does not offer such a driver for OSX (at the time of writing), but there are a couple of open source ones (most notably the Tattiebogle one), which Google can locate for you. These drivers sort-of work (again, at the time of writing), but I've had severe enough side-effects from installing them that I've ended up uninstalling them again. And since these drivers don't come with uninstallers or instructions about what files need to be removed, the uninstallation process isn't easy or automatic.

But if you do install a driver for the XBox 360 controller, then they'll show up as regular USB controllers, and the SDL code you've listed above will detect them successfully.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.