示例#1
0
        public static IEnumerable <IDeviceInfo> GetAllDevices()
        {
            foreach (string devicePath in MsHidHelper.GetDevicePaths())
            {
                SafeFileHandle fileHandle = MsHidHelper.CreateFileHandle(devicePath);

                int vendorId, productId;
                if (MsHidHelper.TryGetHidInfo(fileHandle, out vendorId, out productId) && vendorId == VID && productId == PID)
                {
                    fileHandle.Close();
                    yield return(new MsHidDeviceInfo(devicePath));
                }
            }
        }
示例#2
0
        public static IEnumerable <KeyValuePair <string, SafeFileHandle> > GetWiiDeviceHandles()
        {
            foreach (string devicePath in MsHidHelper.GetDevicePaths())
            {
                SafeFileHandle fileHandle = MsHidHelper.CreateFileHandle(devicePath);

                int vendorId, productId;
                if (MsHidHelper.TryGetHidInfo(fileHandle, out vendorId, out productId))
                {
                    if (IsDevicePathConnected(devicePath))
                    {
                        continue;
                    }
                    yield return(new KeyValuePair <string, SafeFileHandle>(devicePath, fileHandle));
                }
            }
        }