예제 #1
0
        public static List <string> GetAllDevices()
        {
            var ret = new List <string>();

            var candidates = HIDDevice.GetAllDevices(_VENDOR_ID, _PRODUCT_ID1);

            foreach (var c in HIDDevice.GetAllDevices(_VENDOR_ID, _PRODUCT_ID2))
            {
                candidates.Add(c);
            }

            foreach (var device in candidates)
            {
                var d = new WiiInputDevice(device, null);
                Thread.Sleep(1000);
                bool found = d.ExtensionType.HasValue && d.ExtensionType.Value == 0xFF00A4200112;
                d.Disconnect();
                d.Dispose();
                d = null;

                if (found)
                {
                    ret.Add(device);
                }
            }

            return(ret);
        }
예제 #2
0
        private unsafe void _Init(int vendorId, int productId, bool throwNotFoundError)
        {
            var devices = HIDDevice.GetAllDevices(vendorId, productId);

            if (devices != null && devices.Count > 0)
            {
                _Init(devices[0], throwNotFoundError);
            }
            else
            {
                if (throwNotFoundError)
                {
                    throw new InvalidOperationException("Device not found");
                }
            }
        }