我一直在尝试使用 SharpDX.DirectInput dll 将 DirectInput 实现为统一,但是当我创建操纵杆时,它给了我一个错误:
SharpDXException: HRESULT: [0x80070057], Module: [General], ApiCode: [E_INVALIDARG/Invalid Arguments], Message: The parameter is incorrect.
这是我的代码:
using System;
using UnityEngine;
using SharpDX.DirectInput;
namespace KurdifyEngine.Input
{
static class Direct
{
public static DirectInput directInput;
public static Guid directGuid;
public static Joystick directGamepad ;
internal static void Initialize()
{
// Initialize DirectInput
directInput = new DirectInput();
directGuid = Guid.Empty;
DirectUpdate();
}
internal static void DirectUpdate()
{
// search for Gamepad
foreach (var deviceInstance in directInput.GetDevices(SharpDX.DirectInput.DeviceType.Gamepad, DeviceEnumerationFlags.AttachedOnly))
directGuid = deviceInstance.InstanceGuid;
}
if (directGuid != Guid.Empty)
{
directGamepad = new Joystick(directInput, directGuid);
}
}
}
}
当我创建操纵杆时发生错误:
directGamepad = new Joystick(directInput, directGuid);