/// <inheritdoc /> protected override void Update(Dictionary <object, Color> dataSet) { try { if ((Device.Type == (uint)AsusDeviceType.KEYBOARD_RGB) || (Device.Type == (uint)AsusDeviceType.NB_KB_RGB)) { foreach (KeyValuePair <object, Color> data in dataSet) { AsusLedId index = (AsusLedId)data.Key; IAuraSyncKeyboard keyboard = (IAuraSyncKeyboard)Device; if (keyboard != null) { IAuraRgbLight light = index switch { //UK keyboard Layout AsusLedId.KEY_OEM_102 => keyboard.Lights[(int)((3 * keyboard.Width) + 13)], AsusLedId.UNDOCUMENTED_1 => keyboard.Lights[(int)((4 * keyboard.Width) + 1)], _ => keyboard.Key[(ushort)index] }; // Asus Strix Scope if (keyboard.Name == "Charm") { light = index switch { AsusLedId.KEY_LWIN => keyboard.Lights[(int)((5 * keyboard.Width) + 2)], AsusLedId.KEY_LMENU => keyboard.Lights[(int)((5 * keyboard.Width) + 3)], _ => light } } ; (_, byte r, byte g, byte b) = data.Value.GetRGBBytes(); light.Red = r; light.Green = g; light.Blue = b; } } } else { foreach (KeyValuePair <object, Color> data in dataSet) { int index = (int)data.Key; IAuraRgbLight light = Device.Lights[index]; (_, byte r, byte g, byte b) = data.Value.GetRGBBytes(); light.Red = r; light.Green = g; light.Blue = b; } } Device.Apply(); } catch { /* "The server threw an exception." seems to be a thing here ... */ } }
/// <summary> /// Tests whether the specified object is a <see cref="AsusLedId" /> and is equivalent to this <see cref="AsusLedId" />. /// </summary> /// <param name="obj">The object to test.</param> /// <returns><c>true</c> if <paramref name="obj" /> is a <see cref="AsusLedId" /> equivalent to this <see cref="AsusLedId" />; otherwise, <c>false</c>.</returns> public override bool Equals(object obj) { AsusLedId compareLedId = obj as AsusLedId; if (ReferenceEquals(compareLedId, null)) { return(false); } if (ReferenceEquals(this, compareLedId)) { return(true); } if (GetType() != compareLedId.GetType()) { return(false); } return(compareLedId.LedId == LedId); }