Would DriverKit work for custom USB device to control mic volume (no stream)?

219 Views Asked by At

I would like to ask for guidance on how to ideally communicate with a custom USB HID device on MacOS.

Use case Modify a microphone volume via an external USB HID device.

Question Can I use DriverKit (HIDDriverKit) for that or I need to use IOKit? I have read something here about audio limitation, but not sure what exactly is not supported.

DriverKit doesn’t support USB devices that manipulate audio or that communicate wirelessly over Bluetooth or Wi-Fi. For those types of devices, create a kernel extension using IOKit. — Source

Would DriverKit still work in my case as I am not sending audio streams but controlling volume only?

Many thanks! Cheers, Tom

1

There are 1 best solutions below

3
On

If I understand you correctly, you wouldn't even need to use DriverKit. (from experience: avoid it if you can!)

You can communicate with HID-compliant devices directly from user space processes. User space processes can generally also control the volume on audio devices.

So by far the easiest option would be to have a launch agent which uses IOKit matching as its launch condition so it starts up when your device is connected. Your agent can communicate with the device using the IOHIDManager API to receive events when your buttons are pressed, and then use the regular Core Audio APIs to control volume.

It doesn't have to be a launch agent, incidentally: a regular Cocoa app with a UI can do all of this as well. (And indeed, you may want to show some form of UI as feedback to the user pressing the buttons.)