public bool UpdateDevice(DeviceColorComposition colorComposition, bool forced = false) { watch.Restart(); // Connect if needed if (!isConnected) { Connect(); } // Reduce sending based on user config if (!sw.IsRunning) { sw.Start(); } if (sw.ElapsedMilliseconds > Global.Configuration.VarRegistry.GetVariable <int>($"{devicename}_send_delay")) { Color averageColor = Utils.BitmapUtils.GetRegionColor( colorComposition.keyBitmap, new BitmapRectangle(0, 0, colorComposition.keyBitmap.Width, colorComposition.keyBitmap.Height) ); SendColorsToOrb(averageColor.R, averageColor.G, averageColor.B); sw.Restart(); } watch.Stop(); lastUpdateTime = watch.ElapsedMilliseconds; return(true); }
public bool UpdateDevice(DeviceColorComposition colorComposition, CancellationToken token, bool forced = false) { watch.Restart(); if (token.IsCancellationRequested) { return(false); } System.Drawing.Color averageColor; lock (colorComposition.bitmapLock) { averageColor = Utils.BitmapUtils.GetRegionColor( colorComposition.keyBitmap, new BitmapRectangle(0, 0, colorComposition.keyBitmap.Width, colorComposition.keyBitmap.Height) ); } talkFX.SetLedRgb(Zone.Event, KeyEffect.On, Speed.Normal, ConvertToRoccatColor(averageColor)); talkFX.SetLedRgb(Zone.Ambient, KeyEffect.On, Speed.Normal, ConvertToRoccatColor(averageColor)); if (token.IsCancellationRequested) { return(false); } bool update_result = UpdateDevice(colorComposition.keyColors, token, forced); watch.Stop(); lastUpdateTime = watch.ElapsedMilliseconds; return(update_result); }
public bool UpdateDevice(DeviceColorComposition colorComposition, bool forced = false) { Color averageColor = Utils.BitmapUtils.GetRegionColor( colorComposition.keyBitmap, new BitmapRectangle(0, 0, colorComposition.keyBitmap.Width, colorComposition.keyBitmap.Height) ); SendColorsToOrb(averageColor.R, averageColor.G, averageColor.B); return(true); }
public bool UpdateDevice(DeviceColorComposition colorComposition, DoWorkEventArgs e, bool forced = false) { watch.Restart(); bool update_result = UpdateDevice(colorComposition.keyColors, e, forced); watch.Stop(); lastUpdateTime = watch.ElapsedMilliseconds; return(update_result); }
public bool UpdateDevice(DeviceColorComposition colorComposition, CancellationToken token, bool forced = false) { watch.Restart(); bool update_result = UpdateDevice(colorComposition.keyColors, token, forced); watch.Stop(); lastUpdateTime = watch.ElapsedMilliseconds; return(update_result); }
public bool UpdateDevice(DeviceColorComposition colorComposition, DoWorkEventArgs e, bool forced = false) { if (e.Cancel) { return(false); } watch.Restart(); // Connect if needed if (!isConnected) { Connect(IPAddress.Parse(Global.Configuration.VarRegistry.GetVariable <string>($"{devicename}_IP")), e); } if (e.Cancel) { return(false); } // Reduce sending based on user config if (!sw.IsRunning) { sw.Start(); } if (e.Cancel) { return(false); } if (sw.ElapsedMilliseconds > Global.Configuration.VarRegistry.GetVariable <int>($"{devicename}_send_delay")) { Color targetColor = colorComposition.keyColors.FirstOrDefault(pair => { return(pair.Key == Global.Configuration.VarRegistry.GetVariable <DeviceKeys>($"{devicename}_devicekey")); }).Value; light.SetColor(targetColor.R, targetColor.G, targetColor.B); sw.Restart(); } if (e.Cancel) { return(false); } watch.Stop(); lastUpdateTime = watch.ElapsedMilliseconds; return(true); }
public bool UpdateDevice(DeviceColorComposition colorComposition, bool forced = false) { System.Drawing.Color averageColor = Utils.BitmapUtils.GetRegionColor( colorComposition.keyBitmap, new BitmapRectangle(0, 0, colorComposition.keyBitmap.Width, colorComposition.keyBitmap.Height) ); talkFX.SetLedRgb(Zone.Event, KeyEffect.On, Speed.Normal, ConvertToRoccatColor(averageColor)); talkFX.SetLedRgb(Zone.Ambient, KeyEffect.On, Speed.Normal, ConvertToRoccatColor(averageColor)); return(UpdateDevice(colorComposition.keyColors, forced)); }
public bool UpdateDevice(DeviceColorComposition colorComposition, DoWorkEventArgs e, bool forced = false) { watch.Restart(); bool update_result = UpdateDevice(colorComposition.keyColors, e, forced); watch.Stop(); lastUpdateTime = watch.ElapsedMilliseconds; Global.logger.Info($"OMEN device, Update cost {lastUpdateTime} ms "); return(update_result); }
public bool UpdateDevice(DeviceColorComposition colorComposition, DoWorkEventArgs e, bool forced = false) { if (e.Cancel) { return(false); } updatePerfStopwatch.Restart(); // Reduce sending based on user config if (!updateDelayStopWatch.IsRunning) { updateDelayStopWatch.Start(); } if (updateDelayStopWatch.ElapsedMilliseconds > Global.Configuration.VarRegistry.GetVariable <int>($"{devicename}_send_delay")) { var targetKey = Global.Configuration.VarRegistry.GetVariable <DeviceKeys>($"{devicename}_devicekey"); if (!colorComposition.keyColors.TryGetValue(targetKey, out var targetColor)) { return(false); } if ((targetColor.R + targetColor.G + targetColor.B) > 0) { light.SetColor(targetColor.R, targetColor.G, targetColor.B); } updatePerfStopwatch.Stop(); lastUpdateTime = updatePerfStopwatch.ElapsedMilliseconds + updateDelayStopWatch.ElapsedMilliseconds; updateDelayStopWatch.Restart(); if (e.Cancel) { return(false); } } return(true); }
public void PushFrame(EffectFrame frame) { var watch = System.Diagnostics.Stopwatch.StartNew(); lock (bitmap_lock) { EffectLayer background = new EffectLayer("Global Background", Color.FromArgb(0, 0, 0)); EffectLayer[] over_layers_array = frame.GetOverlayLayers().ToArray(); EffectLayer[] layers_array = frame.GetLayers().ToArray(); foreach (EffectLayer layer in layers_array) { background += layer; } foreach (EffectLayer layer in over_layers_array) { background += layer; } //Apply Brightness Dictionary <DeviceKeys, Color> peripehralColors = new Dictionary <DeviceKeys, Color>(); foreach (Devices.DeviceKeys key in possible_peripheral_keys) { if (!peripehralColors.ContainsKey(key)) { peripehralColors.Add(key, background.Get(key)); } } foreach (Devices.DeviceKeys key in possible_peripheral_keys) { background.Set(key, Utils.ColorUtils.BlendColors(peripehralColors[key], Color.Black, (1.0f - Global.Configuration.PeripheralBrightness))); } background.Fill(Color.FromArgb((int)(255.0f * (1.0f - Global.Configuration.KeyboardBrightness)), Color.Black)); if (Global.Configuration.use_volume_as_brightness) { background *= Global.Configuration.GlobalBrightness; } if (_forcedFrame != null) { using (Graphics g = background.GetGraphics()) { g.Clear(Color.Black); g.DrawImage(_forcedFrame, 0, 0, canvas_width, canvas_height); } } Dictionary <DeviceKeys, Color> keyColors = new Dictionary <DeviceKeys, Color>(); Devices.DeviceKeys[] allKeys = bitmap_map.Keys.ToArray(); foreach (Devices.DeviceKeys key in allKeys) { keyColors[key] = background.Get(key); } Effects.keyColors = new Dictionary <DeviceKeys, Color>(keyColors); pushedframes++; DeviceColorComposition dcc = new DeviceColorComposition() { keyColors = new Dictionary <DeviceKeys, Color>(keyColors), keyBitmap = background.GetBitmap() }; Global.dev_manager.UpdateDevices(dcc); var hander = NewLayerRender; if (hander != null) { hander.Invoke(background.GetBitmap()); } if (isrecording) { EffectLayer pizelated_render = new EffectLayer(); foreach (Devices.DeviceKeys key in allKeys) { pizelated_render.Set(key, background.Get(key)); } using (Bitmap map = pizelated_render.GetBitmap()) { previousframe = new Bitmap(map); } } frame.Dispose(); } watch.Stop(); var elapsedMs = watch.ElapsedMilliseconds; }
/// <inheritdoc /> public bool UpdateDevice(DeviceColorComposition colorComposition, DoWorkEventArgs e, bool forced = false) { asusHandler.UpdateColors(colorComposition.keyColors); return(true); }
public bool UpdateDevice(DeviceColorComposition colorComposition, DoWorkEventArgs e, bool forced = false) { return(UpdateDevice(colorComposition.keyColors, e, forced)); }
public bool UpdateDevice(DeviceColorComposition colorComposition, DoWorkEventArgs e, bool forced = false) { if (e.Cancel) { return(false); } watch.Restart(); // Connect if needed if (!isConnected) { Connect(e); } if (e.Cancel) { return(false); } // Reduce sending based on user config if (!sw.IsRunning) { sw.Start(); } if (e.Cancel) { return(false); } if (sw.ElapsedMilliseconds > Global.Configuration.VarRegistry.GetVariable <int>($"{devicename}_send_delay")) { Color averageColor; lock (colorComposition.bitmapLock) { //Fix conflict with debug bitmap lock (colorComposition.keyBitmap) { averageColor = Utils.BitmapUtils.GetRegionColor( (Bitmap)colorComposition.keyBitmap, new BitmapRectangle(0, 0, colorComposition.keyBitmap.Width, colorComposition.keyBitmap.Height) ); } } SendColorsToOrb(averageColor.R, averageColor.G, averageColor.B, e); sw.Restart(); } if (e.Cancel) { return(false); } watch.Stop(); lastUpdateTime = watch.ElapsedMilliseconds; return(true); }
public bool UpdateDevice(DeviceColorComposition colorComposition, bool forced = false) { return(UpdateDevice(colorComposition.keyColors, forced)); }
public bool UpdateDevice(DeviceColorComposition colorComposition, bool forced = false) { Dictionary <DeviceKeys, Color> keyColors = colorComposition.keyColors; try { foreach (KeyValuePair <DeviceKeys, Color> pair in keyColors) { if (useGlobalPeriphericColors) { if (pair.Key == DeviceKeys.Peripheral) // This is not working anymore. Was working in MASTER { ColorKBLeft = pair.Value; ColorKBCenter = pair.Value; ColorKBRight = pair.Value; ColorTouchpad = pair.Value; ColorUpdated = true; } } else { // TouchPad (It would be nice to have a Touchpad Peripheral) if (pair.Key == DeviceKeys.Peripheral) { ColorTouchpad = pair.Value; ColorUpdated = true; } } } if (!useGlobalPeriphericColors) // Clevo 3 region keyboard // Left Side (From ESC to Half Spacebar) { BitmapRectangle keymap_esc = Effects.GetBitmappingFromDeviceKey(DeviceKeys.ESC); BitmapRectangle keymap_space = Effects.GetBitmappingFromDeviceKey(DeviceKeys.SPACE); PointF spacebar_center = keymap_space.Center; // Key Center int spacebar_x = (int)spacebar_center.X - keymap_esc.Left; int height = (int)spacebar_center.Y - keymap_esc.Top; BitmapRectangle region_left = new BitmapRectangle(keymap_esc.Left, keymap_esc.Top, spacebar_x, height); Color RegionLeftColor = Utils.BitmapUtils.GetRegionColor(colorComposition.keyBitmap, region_left); if (!ColorKBLeft.Equals(RegionLeftColor)) { ColorKBLeft = RegionLeftColor; ColorUpdated = true; } // Center (Other Half of Spacebar to F11) - Clevo keyboards are very compact and the right side color bleeds over to the up/left/right/down keys) BitmapRectangle keymap_f11 = Effects.GetBitmappingFromDeviceKey(DeviceKeys.F11); int f11_x_width = Convert.ToInt32(keymap_f11.Center.X - spacebar_x); BitmapRectangle region_center = new BitmapRectangle(spacebar_x, keymap_esc.Top, f11_x_width, height); Color RegionCenterColor = Utils.BitmapUtils.GetRegionColor(colorComposition.keyBitmap, region_center); if (!ColorKBCenter.Equals(RegionCenterColor)) { ColorKBCenter = RegionCenterColor; ColorUpdated = true; } // Right Side BitmapRectangle keymap_numenter = Effects.GetBitmappingFromDeviceKey(DeviceKeys.NUM_ENTER); BitmapRectangle region_right = new BitmapRectangle(Convert.ToInt32(keymap_f11.Center.X), keymap_esc.Top, Convert.ToInt32(keymap_numenter.Center.X - keymap_f11.Center.X), height); Color RegionRightColor = Utils.BitmapUtils.GetRegionColor(colorComposition.keyBitmap, region_right); if (!ColorKBRight.Equals(RegionRightColor)) { ColorKBRight = RegionRightColor; ColorUpdated = true; } } SendColorsToKeyboard(forced); return(true); } catch (Exception exception) { Global.logger.LogLine("Clevo device, error when updating device. Error: " + exception, Logging_Level.Error, true); Console.WriteLine(exception); return(false); } }