cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 USB HID Keyboard implementation with Media key

STAR
Associate II

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

1 REPLY 1
Ben K
Senior III

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).