Using gamepads

Discussion in 'Mac Programming' started by Starfox, Oct 26, 2011.

  1. Starfox macrumors 6502

    Starfox

    Joined:
    Apr 7, 2011
    #1
    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.
     
  2. Madd the Sane macrumors 6502a

    Madd the Sane

    Joined:
    Nov 8, 2010
    Location:
    Utah
    #2
    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.
     
  3. Starfox thread starter macrumors 6502

    Starfox

    Joined:
    Apr 7, 2011
    #3
    I'd rather be stabbed in the crotch than use SDL. Aren't there any other options?..
     
  4. geowar, Oct 27, 2011
    Last edited by a moderator: Oct 27, 2011

    geowar macrumors newbie

    Joined:
    Dec 19, 2001
    #4
    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! ;-)
     
  5. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    Location:
    Sailing beyond the sunset
    #5
    Probably no one recognized the "Just Works" capability. It's not like TN2187 is titled "BLUT00F G4M3P4DS FTW!!!1!!".
     
  6. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #6
  7. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    Location:
    Sailing beyond the sunset
    #7
    From the poster's history, posts are allowed only once every ten years. May be the Brigadoon clause in the employment contract.
     
  8. Starfox thread starter macrumors 6502

    Starfox

    Joined:
    Apr 7, 2011
    #8
    What do you mean by "just work"? They'll show up using the standard HIDManager API?
     
  9. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    Location:
    Sailing beyond the sunset
    #9
    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.
     
  10. Starfox thread starter macrumors 6502

    Starfox

    Joined:
    Apr 7, 2011
    #10
    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.
     
  11. Starfox thread starter macrumors 6502

    Starfox

    Joined:
    Apr 7, 2011
    #11
    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.
     

Share This Page