private static void DeviceAdded(object sender, DeviceEventArgs args) { HidDevice hidDevice = HidDevice.Open(args.DevicePath); // We can be sure a hid device was be returned, // since we only registered device notifications // for hid devices. if (vendorId == hidDevice.VendorId && productIds.Contains(hidDevice.ProductId)) { // The device added appears to be a backlight device. devices.Add(args.DevicePath.ToUpper(), hidDevice); } else { // Not a backlight device, dispose! hidDevice.Dispose(); } }
private static void DeviceAdded(object sender, DeviceEventArgs args) { HidDevice hidDevice = HidDevice.Open(args.DevicePath); // We can be sure a hid device was be returned, // since we only registered device notifications // for hid devices. if (VENDOR_ID == hidDevice.VendorId && KeyboardsToListenFor.Any(d => d.ProductID == hidDevice.ProductId)) { // The device added appears to be a backlight device. LogitechKeyboard keyboard = new LogitechKeyboard(hidDevice, KeyboardsToListenFor.Where(k => k.ProductID == hidDevice.ProductId).First()); devices.Add(keyboard); if (KeyboardConnected != null) { KeyboardConnected(null, new LogitechKeyboardEventArgs(keyboard)); } } else { // Not a backlight device, dispose! hidDevice.Dispose(); } }