Re: Using Gamepads..?

Ken Ferry <[email protected]>
Newsgroups gmane.comp.macosx.devel
Message-ID <[email protected]>
On Tue, Mar 9, 2010 at 2:05 PM, Aya Koshigaya <[email protected]> wrote:

> Hi,
>
> mhh... I still don't realy get it :(
>
> A few years ago when I was still developing for Windows, I used
> DirectInput.
> There any gamepad device was handled as the same, I didn't had to write
> some special code for every different device.
>
> And I didn't had to care about how the device is connected (Bluetooth,
> USB..).. I just got a list of devices and their buttons and axis-sticks..
>
> Isn't there something like this for MacOS..?
>

You might try DDHidLib.  I haven't used it, but it looks cool. :-)

http://www.dribin.org/dave/blog/archives/2007/03/19/ddhidlib_10/

-Ken


>
> Aya~
>
>
> On 05.03.2010, at 18:41, Mr. George Warner wrote:
>
> > On Mar 5, 2010, at 3:09 AM, Aya Koshigaya wrote:
> >
> >> Thanks a lot for the source! :)
> >>
> >>> I don't know where you get 1K lines of code… I can do all my HID
> communications in less that a half page of code.
> >>
> >> You example has more then a few thousand lines of code - even without
> the HID Utilities it's still about 1000 lines :)
> >> Sure a lot of printf etc, but... still ..
> >
> > Boiling it down to the essential (HID) stuff:
> >
> > In applicationDidFinishLaunching:
> >
> >    hidManagerRef = IOHIDManagerCreate(kCFAllocatorDefault,
> kIOHIDOptionsTypeNone);
> >    IOHIDManagerSetDeviceMatching(hidManagerRef, NULL);
> >    IOHIDManagerRegisterDeviceMatchingCallback(hidManagerRef,
> Handle_DeviceMatchingCallback, nil);
> >    IOHIDManagerRegisterDeviceRemovalCallback(hidManagerRef,
> Handle_DeviceRemovalCallback, nil);
> >    IOHIDManagerScheduleWithRunLoop(hidManagerRef, CFRunLoopGetCurrent(),
> kCFRunLoopDefaultMode);
> >    IOReturn ioReturn = IOHIDManagerOpen(hidManagerRef,
> kIOHIDOptionsTypeNone);
> >
> > In Handle_DeviceMatchingCallback:
> >
> >    I check the vendor & product ID using:
> >
> >    long vendorID = IOHIDDevice_GetVendorID(inIOHIDDeviceRef);
> >    long productID = IOHIDDevice_GetProductID(inIOHIDDeviceRef);
> >
> >    (note: if you know the exact device you're interested in you can pass
> a non-NULL dictionary to IOHIDManagerSetDeviceMatching above.)
> >
> >    and if it's the device I'm interested in I:
> >
> >    IOHIDDeviceRegisterInputReportCallback(inIOHIDDeviceRef, report,
> reportSize, Handle_IOHIDDeviceIOHIDReportCallback, nil);
> >
> > Then in Handle_IOHIDDeviceIOHIDReportCallback I can see my incoming
> reports.
> >
> > All the rest of that code is ether PS3 specific (like the bluetooth
> stuff) or has nothing to do with HID.
> >
> > That's about nine lines of code… ;-)
> >
> > All those APIs are documented in my technote at: <
> http://developer.apple.com/mac/library/technotes/tn2007/tn2187.html>.
> >
> > --
> > Enjoy,
> > George Warner, (408)974-0668
> > Schizophrenic Optimization Scientist
> > Apple Developer Technical Support (DTS)
> > <[email protected]>
> >
> >
> >
>
> _______________________________________________
> MacOSX-dev mailing list
> [email protected]
> http://www.omnigroup.com/mailman/listinfo/macosx-dev
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.