vendor-specific HID combine with USBMouseKeyboard

02 Oct 2012

Hi,

I've add the USBHID report descriptor to the tail of USBMouseKeyboard report descriptor with additional report id equal to 4. hidapi's hid_open_path can open, and the output report length of the opened handle is correct, but can not write to mbed. Could anyone help?

Thank you,

Cid

03 Oct 2012

Sounds very simmilar to what i first bought my MBED for !

Please keep me up to date.

Cheers

Lex

04 Oct 2012

Hi,

I remember having done the same composite device as yours. The difference is that I did not mix the report descriptors but it was a device with two interfaces.

Quote:

I've add the USBHID report descriptor to the tail of USBMouseKeyboard report descriptor with additional report id equal to 4. hidapi's hid_open_path can open, and the output report length of the opened handle is correct, but can not write to mbed

  • Do you have the mouse/keyboard device working ?
  • Are you able to send data from the mbed to the host (over HID) ?

Can you test (I don't have any hardware right now to test) a HID report descriptor where there are two different report ID for input/output reports:

        0x06, 0x00, 0xff,   // usage page (vendor defined)
        0x09, 0x01,         // usage (vendor page 1)
        0xA1, 0x01,         // Collection application
            0x09, 0x01,         // usage (vendor page 1)
        
            0x85, 0x04,         //report id 4
            0x95, input_length, // report count
            0x75, 0x08,         // report size = 8 bits
            0x26, 0xFF, 0x00,   // logical maximum = 255
            0x15, 0x00,         // logical minimum = 0
            0x09, 0x01,         // usage (vendor page 1)
            0x81, 0x02,         // Input (array)
            
            0x85, 0x05,         //report id 5
            0x95, output_length,// report count
            0x75, 0x08,         // report size = 8 bits
            0x26, 0xFF, 0x00,   // logical maximum = 255
            0x15, 0x00,         // logical minimum = 0
            0x09, 0x01,         // usage (vendor page 1)
            0x91, 0x02,         // Output (array)
        0xC0                // end collection

Cheers, Sam

04 Oct 2012

Hi,

Thank you Sam.

With the author of hidapi, I've successfully combine vender-specific hid report descriptor and mouse keyboard report descriptor, and can read/write data through that with hidapi.

After solving the strange phenomenon and successfully demo the prototype, I would share the experience.

Thank you,

Cid

04 Oct 2012

Can you share your code pleas,

I would realy like to se this working,

Cheers

Ceri.

12 Oct 2012

I use this:

            USAGE_PAGE(2), LSB(DEFAULT_VENDOR_USAGE_PAGE), MSB(DEFAULT_VENDOR_USAGE_PAGE),
            USAGE(1), 0x04,
            COLLECTION(1), 0x01,                                        // Collection 0x01

                REPORT_ID(1), 0x04,
                REPORT_SIZE(1), 0x08,                                       // report size = 8 bits
                LOGICAL_MINIMUM(1), 0x00,                                   // logical minimum = 0
                LOGICAL_MAXIMUM(2), 0xFF, 0x00,                             // logical maximum = 255

                REPORT_COUNT(1), INPUT_LENGTH,					// report count
                USAGE(1), 0x01,                                             // usage
                INPUT(1), 0x02,                                             // Input (array)

                REPORT_COUNT(1), OUTPUT_LENGTH,					// report count
                USAGE(1), 0x02,                                             // usage
                OUTPUT(1), 0x02,                                            // Output (array)

            END_COLLECTION(0),                                           // end collection

There is a GUI test tool in hidapi named testgui can successful r/w to mbed, the buffer[0] must be ReportID, hence buffer length should add 1.

Cheers,

Cid

21 May 2013

Hi:

I have a few questions

a) Do you have any good recommended URL or book on understanding HID report descriptor format?

b) What is the format and meaning for HID_REPORT in USBKeyboard?

bool USBKeyboard::keyCode(uint8_t key, uint8_t modifier) {
    // Send a simulated keyboard keypress. Returns true if successful.
    HID_REPORT report;

    report.data[0] = REPORT_ID_KEYBOARD;
    report.data[1] = modifier;
    report.data[2] = 0;
    report.data[3] = keymap[key].usage;
    report.data[4] = 0;
    report.data[5] = 0;
    report.data[6] = 0;
    report.data[7] = 0;
    report.data[8] = 0;

    report.length = 9;

    if (!send(&report)) {
        return false;
    }

    report.data[1] = 0;
    report.data[3] = 0;

    if (!send(&report)) {
        return false;
    }

    return true;
}

The reason is that I discovered that: Holding a button to trigger mbed to send a character to a program in PC is different from holding a button on a keyboard to the same program. Text editors do not tell the difference.

I am wondering if there is a method to send a continuous key within a report?