Search code examples
usbuachid

Is there a way to use the USB HID to control the specific GUI volume on Windows?


I have a USB(1.1) audio project using a MCU with the USB HID to control the Host(Windows 10)

volume, this project combine with a UAC class and HID class.

I have successfully used the consumer page(0x09) to control Windows volume up/down, but now

I need to control specific Windows applications volume, Is there a way to use the USB HID to

control the specific applications volume on Windows ?

specific like a media play, or a brower playing yourbe music, or a

skype phone call volume, you can set every single volume via Windows

Sound Mixer

the follow is part of my hid report descriptor

0x05, 0x0C,      // Usage Page (Consumer)
0x09, 0x01,      // Usage(Consumer Control)
0xA1, 0x01,      // Collection(Application )
0x85, 0x01,      // Report ID (1)
0x15, 0x00,      // Logical Minimum(0x0 )
0x25, 0x01,      // Logical Maximum(0x1 )
0x09, 0xE2,      // Usage(play back Mute)       //1
0x09, 0xE9,      // Usage(Volume Increment)     //2
0x09, 0xB5,      // Usage(Scan Next Track)      //4
0x09, 0xEA,      // Usage(Volume Decrement)     //8
0x09, 0xB6,      // Usage(Scan Previous Track)  //10
0x09, 0xCD,      // Usage(Play/Pause)           //20 

thank you


Solution

  • There is document available that lists HID Usages from Consumer Page (0x0C) that are supported in Windows 8. Regarding volume controls it lists:

    Usage Usage name Usage type
    0xE0 Volume Linear Control (LC)
    0xE2 Mute On/Off Control (OOC)
    0xE3 Bass Linear Control (LC)
    0xE4 Treble Linear Control (LC)
    0xE5 Bass Boost On/Off Control (OOC)
    0xE9 Volume Increment Re-trigger Control (RTC)
    0xEA Volume Decrement Re-trigger Control (RTC)
    0x0152 Bass Increment Re-trigger Control (RTC)
    0x0153 Bass Decrement Re-trigger Control (RTC)
    0x0154 Treble Increment Re-trigger Control (RTC)
    0x0155 Treble Decrement Re-trigger Control (RTC)

    AFAIK that is what we got out of the box on Windows.

    "15 Consumer Page (0x0C)" chapter of the HID Usage Tables spec has some additional audio usages that seems not handled by Windows:

    Usage ID Usage Name Usage Types
    0xE1 Balance LC
    0xE6 Surround Mode OSC
    0xE7 Loudness OOC
    0xE8 MPX OOC
    0x0150 Balance Right RTC
    0x0151 Balance Left RTC

    If you really want to do "per-application volume" thing then you can report your volume knobs in Vendor-Defined Usage Page (any value in 0xFF00-0xFFFF range) and write a custom user-mode tool (or HID event filter driver for your VID/PID) that will read that data and do what you want: