i'm trying to use a ps3 controller for a game i'm creating. I downloaded the sharpDX.DirectInput extension into my visual studio XNA solution, and used the seemingly simple code from Valdemar's answer in Taking input from a joystick with C# .NET. I already narrowed the problem down to the fact that he cant find the guid of the controller, nor the guid of other USB connected devices such as a keyboard. It does works for the integrated keyboard of my laptop though. Here is my code:
directInput = new DirectInput();
// Find a Joystick Guid
foreach (var deviceInstance in directInput.GetDevices(DeviceType.Gamepad, DeviceEnumerationFlags.AllDevices))
guid = deviceInstance.InstanceGuid;
//create joystick
if (guid!=Guid.Empty)
controller = new Joystick(directInput, guid);
The problem is that controller remains null, which means that the guid remains empty, which means that the GetDevices method doesn't find a gamepad. Which is strange because the controller is perfectly working in windows 7 and visible in device manager as HID and as Microsoft common controller for windows class.
btw, I got the same problem using Microsoft.DirectX.directInput.
Thanks for reading :)