usb hid media keys (volume +/-)

Hello, How send media keys like volume to host using usb hid protocol?  For example I using usbd_hid_composite example. I add this code
#define APP_USBD_HID_MEDIA_REPORT_DSC() { \
        0x05, 0x0C,                     /* Usage Page (Consumer)                        */\
        0x09, 0x01,                     /* Usage (Consumer Control)                     */\
        0x15, 0x00,                     /*     Logical minimum (0)                      */\
        0x25, 0x01,                     /*     Logical maximum (1)                      */\
        0x75, 0x01,                     /*     Report Size (1)                          */\
        0x95, 0x01,                     /*     Report Count (1)                         */\                                       
        0x09, 0xCD,                     /*     Usage (PlayPause)                        */\
        0x81, 0x02,                     /*     Input (Data,Value,Relative,Bit Field)    */\
        0x0A, 0x83, 0x01,               /*     Usage (AL Consumer Control Configuration)*/\
        0x81, 0x02,                     /*     Input (Data,Value,Relative,Bit Field)    */\
        0x09, 0xB5,                     /*     Usage (Scan Next Track)                  */\
        0x81, 0x02,                     /*     Input (Data,Value,Relative,Bit Field)    */\
        0x09, 0xB6,                     /*     Usage (Scan Previous Track)              */\
        0x81, 0x02,                     /*     Input (Data,Value,Relative,Bit Field)    */\                                                                                    
        0x09, 0xEA,                     /*     Usage (Volume Down)                      */\
        0x81, 0x02,                     /*     Input (Data,Value,Relative,Bit Field)    */\
        0x09, 0xE9,                     /*     Usage (Volume Up)                        */\
        0x81, 0x02,                     /*     Input (Data,Value,Relative,Bit Field)    */\
        0x0A, 0x25, 0x02,               /*     Usage (AC Forward)                       */\
        0x81, 0x02,                     /*     Input (Data,Value,Relative,Bit Field)    */\
        0x0A, 0x24, 0x02,               /*     Usage (AC Back)                          */\
        0x81, 0x02,                     /*     Input (Data,Value,Relative,Bit Field)    */\
        0xC0                            /* End Collection                               */\
}

in file app_usbd_hid_kbd_desc.h and change APP_USBD_HID_KBD_GLOBAL_DEF

to this
#define APP_USBD_HID_KBD_GLOBAL_DEF(instance_name, interface_number, endpoint, user_ev_handler, subclass_boot)  \
        APP_USBD_HID_GENERIC_SUBCLASS_REPORT_DESC(keyboard_desc, APP_USBD_HID_KBD_REPORT_DSC());                \
        APP_USBD_HID_GENERIC_SUBCLASS_REPORT_DESC(media_desc, APP_USBD_HID_MEDIA_REPORT_DSC());                \
        static const app_usbd_hid_subclass_desc_t * keyboard_descs[] = {&keyboard_desc,&media_desc};                        \
        APP_USBD_HID_KBD_GLOBAL_DEF_INTERNAL(instance_name,                                                     \
                                             interface_number,                                                  \
                                             endpoint,                                                          \
                                             user_ev_handler,                                                   \
                                             subclass_boot)

Tell me please how to chose report descriptor and how to setup data for transfer media keys?

Best regards, Anatolii

Parents Reply Children
Related