cancel
Showing results for 
Search instead for 
Did you mean: 

USB HID Device: how to send Unicode?

smoothmanifolds
Associate III

I have a USB HID Device STM32CubeIDE project with the following USB HID Report Descriptor

 

 

	0x05,0x01,       // Usage Page: Generic Desktop Page (0x01), page HID Usage Tables 1.4
	0x09,0x06,       // Usage:      Keyboard (0x06)
	0xa1,0x01,       // Collection: Application
		0x05,0x07,       // Usage Page:      Keyboard/Keypad Page (0x07)
		0x19,0xe0,       // Usage Minimum:   0xe0: kbd lctrl
		0x29,0xe7,       // Usage Maximum:   0xe7: kbd rgui
		0x15,0x00,       // Logical Minimum: 0
		0x25,0x01,       // Logical Maximum: 1

		0x95,0x08,       // Report Count:    8  // 8 keys? mod mask
		0x75,0x01,       // Report Size:     1  // 1 bit each?
		0x81,0x02,       // Input:           Data,Var, Abs,No Wrap,Linear,Preferred State,No Null Position

		0x95,0x01,       // Report Count:    1  // 1 key? pad
		0x75,0x08,       // Report Size:     8  // 8 bits each?
		0x81,0x03,       // Input:           Const,Var, Abs,No Wrap,Linear,Preferred State,No Null Position

		0x05,0x07,       // Usage Page:      Kbrd/Keypad
		0x19,0x00,       // Usage Minimum
		0x29,0xff,       // Usage Maximum  // 0x65 is the max for a boot device?
		0x15,0x00,       // Logical Minimum
		0x26,0xff,0x00,  // Logical Maximum  // 0x65 is the max for a boot device?  // 0x25: int8? 0x26: int16?

		0x95,0x06,       // Report Count:    6  // 6 keys? 6 keys (6KRO)
		0x75,0x08,       // Report Size:     8  // 8 bits each?
		0x81,0x00,       // Input:           Data,Array, Abs,No Wrap,Linear,Preferred State,No Null Position
	0xc0,            // End Collection

 

 
and I can send (say) an "a" key press/release with the following USB HID Report:
 

 

uint8_t hid_report[0x08] = {0x00};

hid_report[0x00] = 0b0000000;
hid_report[0x02] = 0x04;
USBD_HID_SendReport(&hUsbDeviceFS, (uint8_t*)&hid_report,sizeof(hid_report));
HAL_Delay(50);

hid_report[0x00] = 0b0000000;
hid_report[0x02] = 0x00;
USBD_HID_SendReport(&hUsbDeviceFS, (uint8_t*)&hid_report,sizeof(hid_report));
HAL_Delay(1000);

 

 

Now the USB HID Usage Tables 1.4 document has a Usage Page dedicated to Unicode (Usage Page 0x10) that says that one can send Unicode encoded as UCS-2. But it's unclear to me how the HID Report should look like in that case.

 

So, how exactly does the HID Report look like (for one, or several) Unicode characters?

5 REPLIES 5
smoothmanifolds
Associate III

Anyone?

Isn't UNICODE just sending two bytes for one character?

Why should it be related to the USB channel for communication?

Even, there would be a descriptor in USB Enumeration, telling the host, now all is sent as UNICODE - how do you know the FW (the USB drivers) would change into UNICODE mode (able to send uint16_t now as data word)?

Could you try by sending two bytes as UNICODE word?
I think, the USB Enumeration does not care. And if the USB driver does not support UNICODE (what I would assume), you have "emulate" UNICODE with your own code.

Error: babble detected ))

 

Pavel A.
Evangelist III

This is interesting. Have you tried to connect a device with this report descriptor to Windows or Mac (not sending any data yet)? Is it recognized at all?

It works on Linux. I haven't tested on Windows or Mac.