1

我正在尝试将 ps3 控制器用于我正在创建的游戏。我将sharpDX.DirectInput 扩展下载到我的Visual Studio XNA 解决方案中,并使用了Valdemar 在使用C# .NET 从操纵杆中输入的答案中看似简单的代码。我已经将问题缩小到他找不到控制器的 guid,也找不到其他 USB 连接设备(如键盘)的 guid。不过,它确实适用于我笔记本电脑的集成键盘。这是我的代码:

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);

问题是控制器保持为空,这意味着 guid 保持为空,这意味着 GetDevices 方法没有找到游戏手柄。这很奇怪,因为控制器在 Windows 7 中完美运行,并且在设备管理器中作为 HID 和 Windows 类的 Microsoft 通用控制器可见。

顺便说一句,我在使用 Microsoft.DirectX.directInput 时遇到了同样的问题。

谢谢阅读 :)

4

2 回答 2

1

一种可能的解决方案是将 DeviceType.Gamepad 更改为 DeviceType.Joystick

于 2019-01-01T04:10:11.540 回答
0

I still don't know why it didn't work. But I tried something better. with a tutorial on youtube i installed a driver which "converted" the DS3 controller into an xbox controller. In other words, windows now thinks there is a xbox controller connected.

Now I can use the GamePad class of the xna library which is designed for xbox 360 controllers.

http://steamcommunity.com/app/258970/discussions/0/613937306592303709/?l=dutch read the comments of this link for more updated drivers.

于 2015-11-25T12:25:32.280 回答