16
\$\begingroup\$

I've managed to find a USB driver to connect to the PS3 controller in OSX, and as reported here, can connect to the controller via Bluetooth.

I've verified that the input is working properly via Snes9x.

Anyway, that's just background for my actual question. Is there any way to access the PS3 HID, via C++, on the Mac? I'm relatively new to C++ development on Mac using XCode, and the internet has been disappointing in my search for a possibly library to use.

Does anybody have any ideas on how I could access the controller button/axis states in code, so I can transfer them to my input maps?

\$\endgroup\$
1
  • 2
    \$\begingroup\$ Neither closing or deleting are really appropriate as it's a decent question; you should be able to post an answer to it and accept it a little while later. I'm surprised there is a reputation gate on that. If not, just plan to come back to this question when you have a bit more reputation I suppose. \$\endgroup\$
    – user1430
    Commented Aug 5, 2011 at 14:52

1 Answer 1

4
\$\begingroup\$

So, an hour or so of fiddling and trying different libraries, and it seems OIS (and SDL) just recognises the controller as a joystick and provides me with everything I need.

If you install OIS from the link above, and make/run the 'ConsoleTest' project, you can see the output from the controller in the debug window.


Additionally, here's enums i've been using that match to the axes/button numbers produced by SDL (note not OIS, which i've now decided not to use, numberings could well be the same). Notice that the trigger buttons are not classified as an axis, which i'm pretty sure they should be (0-255 from memory):

//Values SDL attributes to individual PS3 axes
enum EPS3RawAxesIndex
{
    EPS3RawAxesIndex_LeftX = 0,
    EPS3RawAxesIndex_LeftY = 1,
    EPS3RawAxesIndex_RightX = 2,
    EPS3RawAxesIndex_RightY = 3
};

//Values SDL attributes to individual PS3 controller buttons
enum EPS3RawButtonIndex
{
    EPS3RawButtonIndex_Select           = 0,

    EPS3RawButtonIndex_JoyClickLeft     = 1,
    EPS3RawButtonIndex_JoyClickRight    = 2,

    EPS3RawButtonIndex_Start            = 3,

    EPS3RawButtonIndex_DpadUp           = 4,
    EPS3RawButtonIndex_DpadRight        = 5,
    EPS3RawButtonIndex_DpadDown         = 6,
    EPS3RawButtonIndex_DpadLeft         = 7,

    EPS3RawButtonIndex_TriggerLeft      = 8,
    EPS3RawButtonIndex_TriggerRight     = 9,

    EPS3RawButtonIndex_ShoulderLeft     = 10,
    EPS3RawButtonIndex_ShoulderRight    = 11,

    EPS3RawButtonIndex_Triangle         = 12,
    EPS3RawButtonIndex_Circle           = 13,
    EPS3RawButtonIndex_Cross            = 14,
    EPS3RawButtonIndex_Square           = 15,

    EPS3RawButtonIndex_PSButton         = 16
};
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .