(I cross-posted this to the USB list, but I suspect the traffic it'll see here is much greater. Sorry!)

I'm pretty new to USB-related programming, so I'm sure I'm doing something dumb here. I'm trying to write a listener that listens for keypresses from a connected USB button board. The button board is totally unsupported, and its functions don't even appear in ControllerMate, however, I used a piece of software called Joystick and Gamepad Tester to verify that the board is sending signals that can be "caught" by applications that know how to look for the raw data. As Joystick and Gamepad Tester doesn't do what I need beyond verifying that the board works, and it's closed-source, I'm trying to replicate what it does to recognize these signals so that I can write a program that allows users to bind the buttons to specific actions.

I've found the device in the IORegistry by matching against its vendor and product IDs, but I'm having trouble getting a plugin for it. My kern_return_t is being set to "0xE00002C7" when I try to call IOCreatePlugInInterfaceForService() on it. Also, I suspect that my approach is wrong, because this seems really hard. Any ideas?



int foundTheDevice (io_object_t hidDevice)
{
printf("\nFound the %s - Vendor ID #%X (%d) Product ID #%X (%d)\n \n", DEVICE_NAME, VENDOR_ID, VENDOR_ID, PRODUCT_ID, PRODUCT_ID);
        
        kern_return_t                   kr = 0;
        IOCFPlugInInterface             **plugInInterface = NULL;
        IOUSBDeviceInterface245 **dev = NULL;
        HRESULT                         res;
        SInt32                                  score = 0;
        UInt16                                  vendor = 0;
        UInt16                                  product = 0;
        UInt16                                  release = 0;
        
        
        // get the device interface
        printf("kern_return_t is: %d\n", kr);
kr = IOCreatePlugInInterfaceForService(hidDevice, kIOUSBDeviceUserClientTypeID, kIOCFPlugInInterfaceID, &plugInInterface, &score);
        printf("Trying to create the plugin...\n");
        printf("kern_return_t is: %d\n\n", kr);
        
        
        // we're done with the device object now that we've got the plugin
        kr = IOObjectRelease(hidDevice);
        if ((kIOReturnSuccess != kr) || !plugInInterface)
        {
// this always gets called, since kern_return_t isn't being correctly set
                printf("unable to create a plugin (%08x)\n", kr);
                exit(1);
        }

        //... etc
}
_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to