/// <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 ... */ } }
/// <inheritdoc /> public AuraSyncKeyboardDevice(AsusHandler asusHandler, IAuraSyncKeyboard device, int frameRate = 30) : base(asusHandler, device, frameRate) { keyboard = device; foreach (IAuraRgbKey key in device.Keys) { deviceKeyToKey[AsusLedIdMapper(key.Code)] = device.Key[key.Code]; } // These keys are selected by inspecting the lights 2D array // This is because the keycodes for a UK keyboard and American keyboard do not align for whatever reason // Hashtag Key deviceKeyToKey[DeviceKeys.HASHTAG] = keyboard.Lights[(int)(3 * keyboard.Width + 13)]; // BackSlash Key deviceKeyToKey[DeviceKeys.BACKSLASH_UK] = keyboard.Lights[(int)(4 * keyboard.Width + 1)]; if (Global.Configuration.keyboard_brand == Settings.PreferredKeyboard.Asus_Strix_Scope) { // Left Windows Key deviceKeyToKey[DeviceKeys.LEFT_WINDOWS] = keyboard.Lights[(int)(5 * keyboard.Width + 2)]; // Left Alt Key deviceKeyToKey[DeviceKeys.LEFT_ALT] = keyboard.Lights[(int)(5 * keyboard.Width + 3)]; } }