我试图实现与非托管代码和c#的互操作。
我决定为此使用winmm.dll。
需要获得操纵杆唯一的guid并识别设计状态(连接与否)。
经过一番调查,我认为找到了应该做它的函数,(joyGetDevCapsA).但尚不清楚作为int id参数应传递哪些值。
public static class InputControllerInteroperator
{
private const string WINMM_NATIVE_LIBRARY = "winmm.dll";
private const CallingConvention CALLING_CONVENTION = CallingConvention.StdCall;
[DllImport(WINMM_NATIVE_LIBRARY, CallingConvention = CALLING_CONVENTION), SuppressUnmanagedCodeSecurity]
public static extern int joyGetPosEx(int uJoyID, ref JOYINFOEX pji);
[DllImport(WINMM_NATIVE_LIBRARY, CallingConvention = CALLING_CONVENTION), SuppressUnmanagedCodeSecurity]
public static extern int joyGetPos(int uJoyID, ref JOYINFO pji);
[DllImport(WINMM_NATIVE_LIBRARY, CallingConvention = CALLING_CONVENTION), SuppressUnmanagedCodeSecurity]
public static extern int joyGetNumDevs();
[DllImport(WINMM_NATIVE_LIBRARY, CallingConvention = CALLING_CONVENTION, EntryPoint = "joyGetDevCaps"), SuppressUnmanagedCodeSecurity]
public static extern int joyGetDevCapsA(int id, ref JOYCAPS lpCaps, int uSize);
}对于C#思想的互联网,没有很多关于winmm的信息,所以如果有人有经验,请分享。
Q::如何在当前时刻检测到附加或不附操纵杆,得到设备唯一的Guid?
发布于 2019-11-17 05:10:06
根据@Hans (https://stackoverflow.com/users/17034/hans-passant)的评论,问题如下:
没有guid,没有连接状态。特定的操纵杆被识别为一个简单的uint。0是第一个操纵杆,1是第二个操纵杆等等。
对我来说很管用
https://stackoverflow.com/questions/58654817
复制相似问题