cusbstm32stm32f1usb-hid

How to send ALT Codes from STM32F103 USB Device Application?


I have modified the STM32F1 USB HID Device Example generated by STM32CubMX from Mouse to a Keyboard and I am able to send characters to the host by sending the scan codes in the USB Reports.

Now I want some special characters to be sent from the keyboard on the press of a specific button.

They way I see it is to send the scan codes for the keys that comprise the Unicode for the character.

For Example to send a smiley with Unicode U+1F601 (Decimal 128513) to a windows machine I will have to send scan codes for 1,2,8,5,1,3. What I don't understand is how to send this with the ALT Key modifier ?

All the scan codes should be sent in a single report with the ALT Modifier set or in different reports ?

I have a Ubuntu machine and sending CTRL+SHIFT+u in the report then the scan codes followed by an Enter key works fine.


Solution

  • As far as I know you send the ALT key modifier first and then the scan codes of the keys. That should work just fine. You need to keep in mind the key-down and key-up event so when you don't need the ALT modification you need to send the key-up.