Skip to main content
Denis Gottardello
Associate III
June 26, 2017
Solved

USB HID as keyboard emulation as keyboard emulation

  • June 26, 2017
  • 2 replies
  • 1872 views
Posted on June 26, 2017 at 15:25

This is my first experience with USB as virtual keyboard.

I have configured in CubeMX a Human Interface Device (HID). After that, to have someting written in my notepad I have written the following function:

      uint8_t USB_TX_Buffer[8];

      USB_TX_Buffer[0]= 'H';

      USB_TX_Buffer[1]= 'e';

      USB_TX_Buffer[2]= 'l';

      USB_TX_Buffer[3]= 'l';

      USB_TX_Buffer[4]= 'o';

      USB_TX_Buffer[5]= '\0';

      USBD_HID_SendReport(hUsbDeviceFS, USB_TX_Buffer, 6);

      HAL_Delay(1000);

But I obtain only the movement of the mouse! Can someone suggest me the right way?
    This topic has been closed for replies.
    Best answer by Denis Gottardello
    Posted on June 27, 2017 at 16:21

    Now it is working perfectly!

    I have only to understand how to manage the capital letters. The others are working perfectly!

    2 replies

    ST Technical Moderator
    June 27, 2017
    Posted on June 27, 2017 at 12:17

    Hi

    Gottardello.Deni

    ,

    You may find a HID example in the Cube firmware package relevant to the STM32 device you are using

    , as in this folder : STM32Cube_FW_F4_V1.0\Projects\STM324xG_EVAL\Applications\USB_Host\HID_Standalone.

    It is a typical application on how to use the STM32F4xx USB OTG Host peripheral to interact with an USB HID Device such as a Mouse or a Keyboard.

    You can look on this ST prese

    ntation labs described how to create the HID device with CubeMX:

    Hope this helps you.

    Regards

    Imen

    In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
    Denis Gottardello
    Denis GottardelloAuthorBest answer
    Associate III
    June 27, 2017
    Posted on June 27, 2017 at 16:21

    Now it is working perfectly!

    I have only to understand how to manage the capital letters. The others are working perfectly!