예제 #1
0
        public static void UpdateSerial(object sender, EventArgs e)
        {
            lock (Devices)
            {
                DS4Device device = (DS4Device)sender;
                if (device != null)
                {
                    string devPath = device.HidDevice.DevicePath;
                    string serial  = device.MacAddress;
                    if (Devices.ContainsKey(devPath))
                    {
                        DeviceSerials.Remove(serial);
                        device.UpdateSerial();
                        serial = device.MacAddress;
                        if (DS4Device.IsValidSerial(serial))
                        {
                            DeviceSerials.Add(serial);
                        }

                        if (device.ShouldRunCalib)
                        {
                            device.RefreshCalibration();
                        }
                    }
                }
            }
        }
예제 #2
0
        private static void EvalHid(HidDevice hDevice)
        {
            if (IgnoreDevice(hDevice))
            {
                return;
            }

            if (!hDevice.IsOpen)
            {
                OpenDevice(hDevice);
            }

            if (!hDevice.IsOpen)
            {
                return;
            }

            string serial = hDevice.ReadSerial();

            if (DS4Device.IsValidSerial(serial))
            {
                if (DeviceSerials.Contains(serial))
                {
                    OnSerialExists(hDevice);
                }
                else
                {
                    try
                    {
                        VidPidInfo metainfo = KnownDevices.Single(x =>
                                                                  x.Vid == hDevice.Attributes.VendorId &&
                                                                  x.Pid == hDevice.Attributes.ProductId);

                        if (metainfo != null)
                        {
                            OnAddSerial(hDevice, metainfo, serial);
                        }
                    }
                    catch
                    {
                        // Single() may throw an exception
                    }
                }
            }
        }