The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
Some controllers are doubled on mac, how is this handled?
morgan1879


Joined: 05 Sep 2014
Posts: 3
First post!
Greetings...

I've started recently with SDL, and have had success implementing the joystick and gamecontroller bits.

My development macbook has 2 USB ports. The controllers I have in-hand are Xbox 360, Logitech F310, Playstation 3 DualShock; these are standard controllers all contained in the database of controller button mappings.

Xbox 360 didn't show up on the system so I used the tattiebogle software for it and was pleased to find it successful.

However, after pairing the Playstation 3 using bluetooth and having all 3 controllers plugged in at the same time, every time I launch and run, the Xbox 360 controller appears twice. It is sent as twice via JoystickDeviceWasAddedCallback in /Library Source/joystick/darwin/SDL_sysjoystick.c/ConfigHIDManager()

All 3 of these are loaned controllers from friends, I have zero computer game controllers, so I bought one, just found an Afterglow PS3 controller in a store, and made sure they'd take it back if I couldn't get it to work.

I got it to work, but it requires a USB port (not bluetooth, thanks to Sony) so the Logitech was swapped out, and I had Xbox 360, PS3 Dual Shock, Afterglow PS3.

Run the test, 4 controllers detected.
Removed Xbox 360 controller
Relaunch test, 3 controllers detected... what?! The Afterglow is being sent twice by JoystickDeviceWasAddedCallback, on launch.

I thought this was an underlying flaw in the tattiebogle software for Xbox 360, maybe. So I uninstalled that software, and now the xbox 360 controller doesn't work again (no big deal) but the Afterglow still appears twice...

This issue ONLY occurs with the Afterglow, and Xbox controllers. If I have Logitech F310 + Afterglow + PS3 Dual Shock, Afterglow is the only one that gets doubled.

But... the Afterglow does not appear twice, if it is the only controller plugged in. It appears just once, and this is some underlying system quirk or bug that I cannot figure out.

Has this happened to others? Xbox 360 doubled on mac when using one-or-more other controllers?

This happened out-of-the-box with SDL using the test Xcode project.
morgan1879


Joined: 05 Sep 2014
Posts: 3
I did resolve this by adding code to SDL in joystick/Darwin/SDL_sysjoystick.c:

Within GetDeviceInfo(), after this block:

if ((pDevice->usage != kHIDUsage_GD_Joystick &&
pDevice->usage != kHIDUsage_GD_GamePad &&
pDevice->usage != kHIDUsage_GD_MultiAxisController)) {
return SDL_FALSE; /* Filter device list to non-keyboard/mouse stuff */
}

I placed this code to fix the problem:

recDevice *curdevice = gpDeviceList;
while (curdevice)
{
if ( curdevice->deviceRef == hidDevice)
return SDL_FALSE;

curdevice = curdevice->pNext;
};

The better solution would be find out why IOKit is sending the specific controllers twice.
mbabuskov


Joined: 08 Feb 2015
Posts: 29
morgan1879 wrote:

I placed this code to fix the problem:

recDevice *curdevice = gpDeviceList;
while (curdevice)
{
if ( curdevice->deviceRef == hidDevice)
return SDL_FALSE;

curdevice = curdevice->pNext;
};

The better solution would be find out why IOKit is sending the specific controllers twice.


Hi,

I have the same problem with 360 controller. Are you sure this fix will work if you have two identical controllers? I don't have two 360 controllers to test but is "deviceRef" going to be unique?

P.S. If I unplug the controller while the game is running, it reports two controller being removed, and if I plug it back, it only reports one properly.
Ball


Joined: 18 May 2015
Posts: 1
Is this somehow related to why SDL apps see two PS3 controllers even though I only have one paired? I've been trying to delete all my bluetooth prefs, but now I think this is a bug in SDL.

If so, this bug is what is preventing me from being able to use Mupen64. Also, in SDl apps only the second PS3 controller works. the first one does nothing.