Can't get SDL to recognize controllers on Mac working Window

Hi.

I’ve been trying to get this to work for some time with no success. I added some code to detect gamepads on SDL. It’s working in Windows, whenever I plug/unplug the cable it detects, all buttons detected and properly mapped.
But that same code is not working on Mac. I’ve tried using a wired xbox 360 controller and a PS4 one via Blutooth. Both these controllers are being detected (and usable) on other games and some emulators so it’s not a matter of not being properly connected to the OS itself.

I’m using Yosimite and SDL 2.0.3

I’m initing like this

Code:

if ( SDL_Init(SDL_INIT_VIDEO|SDL_INIT_GAMECONTROLLER) != 0 ){

}

Then detecting the controller like this

Code:

while ( SDL_PollEvent( &event ) )
{
switch ( event.type )
{
case SDL_CONTROLLERDEVICEADDED:
// Do stuff
case SDL_CONTROLLERDEVICEREMOVED:
// Do stuff
}
}

SDL_NumJoysticks returns 0 also.
On windows this code works properly and SDL_NumJoysticks returns 1 if connected at start.

Can anyone shed some light on this, kind of lost here------------------------
@DJ_Link

www.david-amador.com

Is there any estimated time when 2.0.4 will be released in a stable state ? :smiley:

Ryan C. Gordon wrote:

I think we fixed something related to this since 2.0.3 shipped.

–ryan.

I just grabbed the source from the repo. Built it (the 2.0.4) same thing happens :(------------------------
@DJ_Link

www.david-amador.com

I’m using Yosimite and SDL 2.0.3

I think we fixed something related to this since 2.0.3 shipped.

–ryan.

Eric Wing wrote:

Also, if you are codesigning and enabling App Sandboxing, you need to
add the USB entitlement for a USB gamepad. Presumably, you’ll need the
Bluetooth entitlement for the Bluetooth gamepad, unless there is a
special one for gamepads now that Apple has their official Bluetooth
controller support (which I have not tried).

You sir are my saviour. I feed stupid, totally forgot about sandboxing mode. Controller started working right away after activating USB. Even the PS4 one via blutooth.
Sorry for all the trouble for something that wasn’t even SDL related. Maybe this can help other people too------------------------
@DJ_Link

www.david-amador.com

Gamepad support has worked for me in Yosemite on the 2.0.3 branch.

Try this binary. It has basic gamepad support.
http://playcontrol.net/tempdownload/BlurrrBinaries/FlappyBlurrrCMac.zip

I have an old wired USB Gravis Xterminator (1990’s era DirectInput
gamepad). I have not tried Xbox 360 or PS4 on Mac, nor Bluetooth.

I did need to add my Xterminator to the optional gamecontroller.txt
mapping file because this is not in the standard database.

(Aside: How do I submit this game controller to the database for
official inclusion?)

Also, if you are codesigning and enabling App Sandboxing, you need to
add the USB entitlement for a USB gamepad. Presumably, you’ll need the
Bluetooth entitlement for the Bluetooth gamepad, unless there is a
special one for gamepads now that Apple has their official Bluetooth
controller support (which I have not tried).

Thanks,
EricOn 12/11/14, ^DJ_Link^ <david.djlink at gmail.com> wrote:

Hi.

I’ve been trying to get this to work for some time with no success. I added
some code to detect gamepads on SDL. It’s working in Windows, whenever I
plug/unplug the cable it detects, all buttons detected and properly mapped.
But that same code is not working on Mac. I’ve tried using a wired xbox 360
controller and a PS4 one via Blutooth. Both these controllers are being
detected (and usable) on other games and some emulators so it’s not a matter
of not being properly connected to the OS itself.

I’m using Yosimite and SDL 2.0.3


Beginning iPhone Games Development
http://playcontrol.net/iphonegamebook/