sharpdx / SharpDX-Samples

Official repository for all SharpDX Samples
346 stars 222 forks source link

Following the DirectInput example but joystickGUID stays empty #38

Open Schroedingers-Cat opened 8 years ago

Schroedingers-Cat commented 8 years ago

I've been following this script example: https://github.com/sharpdx/SharpDX-Samples/blob/master/Desktop/DirectInput/JoystickApp/Program.cs

I'm using SharpDX 2.6.3 for .NET 2.0 with Unity 5.3 on Windows 10. I had to copy the System.Windows.Forms.dll from mono 2.0 next to the SharpDX files for Unity to work with SharpDX.

I have two "Wireless Controllers" (DualShock 4 from the PS4, which is a DirectInput Controller) connected to Windows, one via bluetooth and one via usb. Both show up at the windows gamecontroller setup window and all their axes and buttons work. However, when my script calls this line

foreach (var deviceInstance in directInput.GetDevices(SharpDX.DirectInput.DeviceType.Gamepad, DeviceEnumerationFlags.AllDevices))
  joystickGuid = deviceInstance.InstanceGuid;

or this line

if (joystickGuid == Guid.Empty)
  foreach (var deviceInstance in directInput.GetDevices(SharpDX.DirectInput.DeviceType.Joystick, DeviceEnumerationFlags.AllDevices))
    joystickGuid = deviceInstance.InstanceGuid;

then I can see in MonoDevelops debugger that joystickGuid is still empty as it only holds one {00000000-0000-0000-0000-000000000000}.

What could be the problem?