Skip to main content
Visitor II
January 14, 2021
Question

STM32 USB HID Keyboard implementation with Media key

  • January 14, 2021
  • 1 reply
  • 2074 views

Hi All,

I wanted to implement functionality for the volume up/ volume down/ mute etc.

I Got the keycodes for those buttons in USB HID Usage table .

volume up = 128

volume down = 129

mute = 127

but it wont works in My USB HID keyboard code

How to implement this functionality

Regards,

STAR

    This topic has been closed for replies.

    1 reply

    Visitor II
    January 17, 2021

    You will need https://github.com/IntergatedCircuits/HidReportDef

    then use this HID report descriptor:

    static const uint8_t DescPlayerReport[] =
    {
    /* Consumer device as input controller */
    HID_USAGE_PAGE_CONSUMER,
     HID_USAGE_CMR_CONSUMER_CTRL,
     HID_COLLECTION_APPLICATION(
     HID_USAGE_MIN_8(0),
     HID_USAGE_MAX_8(0xFF),
     HID_REPORT_SIZE(8),
     HID_REPORT_COUNT(1),
     HID_LOGICAL_MIN_8(0),
     HID_LOGICAL_MAX_8(0xFF),
     HID_INPUT(Data_Arr_Abs),
     ),
    };

    Then you just need to send one byte messages (e.g. 128 and 0 to simulate press and release of volume up).

    Graduate II
    March 22, 2025

    For Host keyboard implementation, what's needed to detect volume up/down, as these keys don't seem to generate a keypress, are they read like the shift and alt keys?