none
Is it possible to fire the event in c# when the botton of usb audio device is pushed? RRS feed

  • Question

  • Hi. I'm using c# in visual studio 2013(Windows7 64bits).

    Is it possible to fire the event(or interrupt) in c# when the botton of usb audio(like a earphone, headset) is pushed?

    If it is possible, how can I take that event?

    I want to write a code when the something like a button of ear phone or headset is pushed.

    Wednesday, January 30, 2019 8:22 AM

All replies

  • Hi Hajun,

    Thank you for posting here.

    For your question, as I know, we could use C# to monitor whether the USB port connected or not. But based on my search, there is no event or Win32 function to fire the button of the usb audio device is pressed directly.

    You could try to use Process Monitor to monitor the device activities. Maybe it could capture the button the of usb audio device.

    I found a Core Audio API. It provides the means for audio applications to access audio endpoint devices such as headphones and microphones. You could try. 

    https://docs.microsoft.com/en-us/windows/desktop/coreaudio/about-the-windows-core-audio-apis

    Please check the link below. It provides a lightweight set of .NET wrappers around each section of the Windows Core Audio APIs.

    https://archive.codeplex.com/?p=netcoreaudio

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, February 1, 2019 6:06 AM
    Moderator
  • It depends.  Sometimes, those buttons just have a local effect, like muting the signal, without notifying the host at all.  For a USB audio device, sometimes those devices will have a separate HID interface (like a mouse) that exposes the button events.  In that case, the system is intercepting those events and converting them to audio actions, and if the system has claimed the interface, you can't see it.

    Tim Roberts | Driver MVP Emeritus | Providenza & Boekelheide, Inc.

    Friday, February 1, 2019 11:05 PM