I have a USB (1.1) audio project using a microcontroller 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 application's volume on Windows?
Specific like a media player, or a browser playing YouTube music, or a Skype phone call volume, so you can set every single volume via Windows.
Sound Mixer
The following 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
There is a 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) |
As far as I know, that is what we got out of the box on Windows.
"15 Consumer Page (0x0C)" chapter of the HID Usage Tables specification 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 the "per-application volume" thing, then you can report your volume knobs in the 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:
enumerate audio sessions via IAudioSessionEnumerator
call ISimpleAudioVolume::SetMasterVolume method to set per-application (AudioSession) volume.