status_t
HIDReport::SendReport()
{
	size_t reportSize = ReportSize();
	uint8 *report = (uint8 *)malloc(reportSize);
	if (report == NULL)
		return B_NO_MEMORY;

	fCurrentReport = report;
	memset(fCurrentReport, 0, reportSize);

	for (uint32 i = 0; i < fItemsUsed; i++) {
		HIDReportItem *item = fItems[i];
		if (item == NULL)
			continue;

		item->Insert();
	}

	status_t result = fParser->Device()->SendReport(this);

	fCurrentReport = NULL;
	free(report);
	return result;
}
        Usage(USB_HID_POINTER),
        Collection(USB_HID_PHYSICAL),

            //
            // The buttons.
            //
            UsagePage(USB_HID_BUTTONS),
            UsageMinimum(1),
            UsageMaximum(3),
            LogicalMinimum(0),
            LogicalMaximum(1),

            //
            // 3 - 1 bit values for the buttons.
            //
            ReportSize(1),
            ReportCount(3),
            Input(USB_HID_INPUT_DATA | USB_HID_INPUT_VARIABLE |
                  USB_HID_INPUT_ABS),

            //
            // 1 - 5 bit unused constant value to fill the 8 bits.
            //
            ReportSize(5),
            ReportCount(1),
            Input(USB_HID_INPUT_CONSTANT | USB_HID_INPUT_ARRAY |
                  USB_HID_INPUT_ABS),

            //
            // The X and Y axis.
            //
Example #3
0
//
// The following is the HID report structure definition that is passed back
// to the host.
//
//*****************************************************************************
static const uint8_t g_pui8KeybReportDescriptor[] =
{
    UsagePage(USB_HID_GENERIC_DESKTOP),
    Usage(USB_HID_KEYBOARD),
    Collection(USB_HID_APPLICATION),

        //
        // Modifier keys.
        // 8 - 1 bit values indicating the modifier keys (ctrl, shift...)
        //
        ReportSize(1),
        ReportCount(8),
        UsagePage(USB_HID_USAGE_KEYCODES),
        UsageMinimum(224),
        UsageMaximum(231),
        LogicalMinimum(0),
        LogicalMaximum(1),
        Input(USB_HID_INPUT_DATA | USB_HID_INPUT_VARIABLE | USB_HID_INPUT_ABS),

        //
        // One byte of rsvd data required by HID spec.
        //
        ReportCount(1),
        ReportSize(8),
        Input(USB_HID_INPUT_CONSTANT),
{
		UsagePage(USB_HID_GENERIC_DESKTOP),
		    Usage(USB_HID_GAMEPAD),
		    Collection(USB_HID_APPLICATION),
		        Collection(USB_HID_PHYSICAL),

		    	ReportID(1),
				//
				// The X and Y (Will appear as two thumb controls).
				//
				UsagePage(USB_HID_GENERIC_DESKTOP),
				Usage(USB_HID_X),
				Usage(USB_HID_Y),
				LogicalMinimum(-1),
				LogicalMaximum(1),
				ReportSize(2),
				ReportCount(2),
				Input(USB_HID_INPUT_DATA | USB_HID_INPUT_VARIABLE | USB_HID_INPUT_ABS | USB_HID_INPUT_NONULL),

				ReportCount(4),
				ReportSize(1),
				Input(USB_HID_INPUT_CONSTANT | USB_HID_INPUT_ARRAY | USB_HID_INPUT_ABS),

				//
				// 12 - 1 bit values for the first set of buttons.
				//
				UsagePage(USB_HID_BUTTONS),
				UsageMinimum(1),
				UsageMaximum(12),
				LogicalMinimum(0),
				LogicalMaximum(1),
Example #5
0
    UsagePageVendor(0xff00),
    // 0x09, 0x01,
    // Arbitrary number as we are vendor specific
    Usage(0x01),
    // 0xa1, 0x01,
    Collection(USB_HID_APPLICATION),
        // 0x85, 0x3f,
        // Vendor specific. Appears arbitrary.
        // ID can be left undefined if only one report type is created

		// 0x95, 0x3f,
		// The number of items in the report
		ReportCount(HID_PACKET_SIZE),
		// 0x75, 0x08,
		// As this is just generic data, 8 bits in a byte
		ReportSize(0x08),
		0x26, 0xff, 0x00,
//		LogicalMaximum(0xff00),
		// 0x15, 0x01,
		LogicalMinimum(0),
		// 0x09, 0x80,
		// Arbitrary number as we are vendor specific
		Usage(0x01),
		// 0x81, 0x02, Input (Data,Var,Abs)
		// This shows we are describing the report that goes to the host
		Input(USB_HID_INPUT_DATA | USB_HID_INPUT_VARIABLE | USB_HID_INPUT_ABS),
		// Second report, same except it's output
		ReportCount(HID_PACKET_SIZE),
		ReportSize(0x08),
//		LogicalMaximum(127),
		0x26, 0xff, 0x00,
        // The axis for the controller.
        //
        UsagePage(USB_HID_GENERIC_DESKTOP),
        Usage (USB_HID_POINTER),
        Collection (USB_HID_PHYSICAL),

            //
            // The X, Y, RX, and RY values which are specified as 8-bit
            // absolute position values.
            //
            Usage(USB_HID_X),

            //
            // 4 8-bit absolute values.
            //
            ReportSize(10),
            ReportCount(1),
            Input(USB_HID_INPUT_DATA | USB_HID_INPUT_VARIABLE |
                  USB_HID_INPUT_ABS),

            ReportCount(1),
            ReportSize(6),
            Input(USB_HID_INPUT_CONSTANT),

            Usage (USB_HID_Y),
            ReportSize(10),
            ReportCount(1),
            Input(USB_HID_INPUT_DATA | USB_HID_INPUT_VARIABLE |
                  USB_HID_INPUT_ABS),

            ReportCount(1),
//*****************************************************************************
//
// The report descriptor for the volume class device. (Built off CustomHid example)
//
//*****************************************************************************
static const uint8_t g_pui8CustomHidReportDescriptor[] =
{
	    UsagePage(USB_HID_CONSUMER_DEVICE),
		Usage(USB_HID_USAGE_CONSUMER_CONTROL),
			Collection(USB_HID_APPLICATION),
				LogicalMinimum(0),
				LogicalMaximum(1),
				Usage(USB_HID_VOLUME_UP),
				Usage(USB_HID_VOLUME_DOWN),
				ReportSize(1),
				ReportCount(2),
				Input(USB_HID_INPUT_DATA | USB_HID_INPUT_VARIABLE | USB_HID_INPUT_RELATIVE),
				ReportCount(6),
				Input(USB_HID_INPUT_CONSTANT | USB_HID_INPUT_ARRAY | USB_HID_INPUT_ABS),
			EndCollection,
};

//*****************************************************************************
//
// The HID descriptor for the customhid device.
//
//*****************************************************************************
static const tHIDDescriptor g_sCustomHidHIDDescriptor =
{
    9,                              // bLength