Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Starfox

macrumors 6502
Original poster
Apr 7, 2011
256
9
What API do people use to access gamepads on OS X? I'm looking for an analog to DirectInput8 / XInput. I need to be able to support at least a wireless gamepad with console-like layout, since I'm working on a cross-platform demo. It'd be ideal if I could use a PS3 gamepad since it uses bluetooth and I won't need to carry an extra dongle around, but other wireless gamepads would be OK too.
 

Madd the Sane

macrumors 6502a
Nov 8, 2010
534
73
Utah
Wirelessly posted (Mozilla/5.0 (iPod; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3)

The best solution would be to use SDL to set up the interface. If you want to go lower, you would have to use IOKit's HID interface.
 

Starfox

macrumors 6502
Original poster
Apr 7, 2011
256
9
I'd rather be stabbed in the crotch than use SDL. Aren't there any other options?..
 

geowar

macrumors newbie
Dec 19, 2001
5
0
IOKit? Really? Has no one read my technote on the HID Manager we introduced in 10.5? (Yes really, two major OS releases ago!):
http://developer.apple.com/library/mac/#technotes/tn2187/_index.html

In addition, the PlayStation™ controllers (including the new Move & Nav) "Just Work!" (™Apple Inc.): Plug them in via USB and their BlueTooth™ addresses are married; disconnect and VOLA! you've got wireless controller! ;-)
 
Last edited by a moderator:

chown33

Moderator
Staff member
Aug 9, 2009
10,747
8,421
A sea of green
IOKit? Really? Has no one read my technote on the HID Manager we introduced in 10.5? (Yes really, two major OS releases ago!):
http://developer.apple.com/library/mac/#technotes/tn2187/_index.html

In addition, the PlayStation™ controllers (including the new Move & Nav) "Just Work!" (™Apple Inc.): Plug them in via USB and their BlueTooth™ addresses are married; disconnect and VOLA! you've got wireless controller! ;-)

Probably no one recognized the "Just Works" capability. It's not like TN2187 is titled "BLUT00F G4M3P4DS FTW!!!1!!".
 

Starfox

macrumors 6502
Original poster
Apr 7, 2011
256
9
IOKit? Really? Has no one read my technote on the HID Manager we introduced in 10.5? (Yes really, two major OS releases ago!):
http://developer.apple.com/library/mac/#technotes/tn2187/_index.html

In addition, the PlayStation™ controllers (including the new Move & Nav) "Just Work!" (™Apple Inc.): Plug them in via USB and their BlueTooth™ addresses are married; disconnect and VOLA! you've got wireless controller! ;-)

What do you mean by "just work"? They'll show up using the standard HIDManager API?
 

chown33

Moderator
Staff member
Aug 9, 2009
10,747
8,421
A sea of green
What do you mean by "just work"? They'll show up using the standard HIDManager API?
Try it. See what happens. Post your results.

Although the instructions are simple, the quoted post seems to provide enough information to attempt something. If it fails, then you can post that the simple instructions don't work. Perhaps you'll even venture further, and discover something that does work.
 

Starfox

macrumors 6502
Original poster
Apr 7, 2011
256
9
I came across DDHidLib - its HIDBrowser seems to discover my PS3 controller and receive input from it, but the library itself seems to be painfully undocumented. Does anyone know of a decent tutorial somewhere? I googled and all the ones I found were extremely poor.
 

Starfox

macrumors 6502
Original poster
Apr 7, 2011
256
9
Latest update: The HID API documentation is less-than-stellar, but the API is extremely solid and simple to use. Don't believe people who claim otherwise.

Also, DDHidLib is one of the crappiest pieces of code I have ever had to deal with.

I now have the PS3 Controller working perfectly, input-wise, including all the pressure sensitive buttons.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.