XInputGetAudioDeviceIds

OSVBNET 1,386 Reputation points
2025-04-08T15:02:53.8266667+00:00

Hi all,

I've converted this code to VB.net and it works fine:

https://www.codeproject.com/Articles/492473/Using-XInput-to-access-an-Xbox-360-Controller-in-M

But XInputGetAudioDeviceIds is missing from it:

https://learn.microsoft.com/en-us/gaming/gdk/_content/gc/reference/input/xinputongameinput/functions/xinputgetaudiodeviceids

On the above page:

Getting Audio Device Identifiers

The headset for a controller has these functions:

Record sound using a microphone

Play back sound using a headphone

Use this code to obtain the device identifiers for the headset...

It's C++, no C# or VB.net sample, and nowhere can be found.

I use XboxController.RetrieveController(0/1/2/3) to select a controller but need to play a sample audio into the headset connected to the selected controller!

Anyone can help please?

Thanks in advance.

  • Update: I've found these 2, but not sure which one to use, they're different in data types and byval/byref, and anyway, how to use it finally:
    <DllImport("xinput1_4.dll")>
    Public Function XInputGetAudioDeviceIds(ByVal dwUserIndex As Integer, ByVal pRenderDeviceId As IntPtr, ByVal pRenderCount As IntPtr, ByVal pCaptureDeviceId As IntPtr, ByVal pCaptureCount As IntPtr) As Integer
    End Function

vs

    <DllImport("xinput1_4.dll", SetLastError:=True)>
    Public Function XInputGetAudioDeviceIds(ByVal dwUserIndex As UInteger, ByVal pRenderDeviceId As StringBuilder, ByRef pRenderCount As UInteger, ByVal pCaptureDeviceId As StringBuilder, ByRef pCaptureCount As UInteger) As UInteger
    End Function
VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,827 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.