Page 1 of 1

Vendor type requests sent to custom HID class template

Posted: Mon Apr 20, 2009 11:43 pm
by psc
hi everyone,

after reading:
http://vusb.wikidot.com/usb-device-classes

i came to the conclusion that my project would benefit from using the following USB Device Class:
Vendor type requests sent to custom HID class device

i am looking for a template / project that use this method!

here's what i have discovered so far:

usbconfig.h

Code: Select all

#define USB_CFG_HAVE_INTRIN_ENDPOINT    1
#define USB_CFG_HAVE_INTRIN_ENDPOINT3   0
#define USB_CFG_EP3_NUMBER              3

#define USB_CFG_DEVICE_CLASS        0
#define USB_CFG_DEVICE_SUBCLASS     0

#define USB_CFG_INTERFACE_CLASS     0x03
#define USB_CFG_INTERFACE_SUBCLASS  0
#define USB_CFG_INTERFACE_PROTOCOL  0

#define USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH    33


usbHidReportDescriptor

Code: Select all

PROGMEM char usbHidReportDescriptor[33] = {
    0x06, 0x00, 0xff,              // USAGE_PAGE (Generic Desktop)
    0x09, 0x01,                    // USAGE (Vendor Usage 1)
    0xa1, 0x01,                    // COLLECTION (Application)
    0x15, 0x00,                    //   LOGICAL_MINIMUM (0)
    0x26, 0xff, 0x00,              //   LOGICAL_MAXIMUM (255)
    0x75, 0x08,                    //   REPORT_SIZE (8)

    0x85, 0x01,                    //   REPORT_ID (1)
    0x95, 0x06,                    //   REPORT_COUNT (6)
    0x09, 0x00,                    //   USAGE (Undefined)
    0xb2, 0x02, 0x01,              //   FEATURE (Data,Var,Abs,Buf)

    0x85, 0x02,                    //   REPORT_ID (2)
    0x95, 0x83,                    //   REPORT_COUNT (131)
    0x09, 0x00,                    //   USAGE (Undefined)
    0xb2, 0x02, 0x01,              //   FEATURE (Data,Var,Abs,Buf)
    0xc0                           // END_COLLECTION
};


it's working perfectly on Linux & Mac, but on Windows i still need to install libusb-win32. The device is not found if i don't install it. However, on V-USB wiki there's this line:
On Windows, you still must ship libusb-win32 with your code. However, it's sufficient to have it in the same directory as your application.


i am not sure what files or folders and where i need to copy them?

thank you very much,
patrick

Re: Vendor type requests sent to custom HID class template

Posted: Wed Apr 22, 2009 11:56 am
by christian
There are two versions of libusb-win32. The filter version, which must be installed in any case, and the dll version which must be associated with your device by means of a .inf file. So I'm afraid you need some kind of installation in any case, contrary to the claim on the wiki.

Re: Vendor type requests sent to custom HID class template

Posted: Wed Apr 22, 2009 4:26 pm
by psc
Thank you Christian.

Using a HID Descriptor with a custom class prevents the "New Device" dialog on Windows. However to access it as a custom class device, you need to install the driver. Here's how to do it with InnoSetup, taken from libusb-win32-device-bin-0.1.12.1/examples/driver_installer_template.iss:

Code: Select all

; - copy libusb's driver (libusb0.sys, libusb0.dll)
; - create an .inf and .cab file using libusb's 'inf-wiward.exe'
...
Source: "*.dll"; DestDir: "{win}\system32"; FLags: replacesameversion restartreplace uninsneveruninstall
Filename: "rundll32"; Parameters: "libusb0.dll,usb_install_driver_np_rundll {app}\driver\<your_inf_file.inf>"; StatusMsg: "Installing driver (this may take a few seconds) ..."