private void SetLight(DeviceKeys key, Color color) { if (hMousePad != IntPtr.Zero) { int zone = GetZone(key); cachedColors.AddOrUpdate(zone, color, (_, oldValue) => color); Task.Run(() => { if (Monitor.TryEnter(this)) { try { foreach (var item in cachedColors) { LightingColor c = LightingColor.FromColor(item.Value); int res = OmenLighting_MousePad_SetStatic(hMousePad, item.Key, c, IntPtr.Zero); if (res != 0) { Global.logger.Error("OMEN MousePad, Set static effect fail: " + res); } Color outColor; cachedColors.TryRemove(item.Key, out outColor); } } finally { Monitor.Exit(this); } } }); } }
public static LightingColor FromColor(Color c) { LightingColor lc = new LightingColor() { r = c.R, g = c.G, b = c.B }; return(lc); }
public void SetLight(DeviceKeys key, Color color) { if (hMouse != IntPtr.Zero) { int zone = (int)GetMouseLightingZone(key); cachedColors.AddOrUpdate(zone, color, (_, oldValue) => color); Task.Run(() => { if (Monitor.TryEnter(this)) { try { foreach (var item in cachedColors) { LightingColor c = LightingColor.FromColor(item.Value); int res = OmenLighting_Mouse_SetStatic(hMouse, item.Key, c, IntPtr.Zero); if (res != 0) { Global.logger.Error("OMEN Mouse, Set static effect fail: " + res); } Color outColor; cachedColors.TryRemove(item.Key, out outColor); } } catch (Exception exc) { Global.logger.Error("OMEN Mouse, exception during set lights: " + exc); } finally { Monitor.Exit(this); } } }); } }
private void SetLight(DeviceKeys keys, Color color) { if (hSpeaker != IntPtr.Zero) { Task.Run(() => { if (Monitor.TryEnter(this)) { try { int res = OmenLighting_Speaker_SetStatic(hSpeaker, LightingColor.FromColor(color), IntPtr.Zero); if (res != 0) { Global.logger.Error("OMEN Speaker, Set static effect fail: " + res); } } finally { Monitor.Exit(this); } } }); } }
static extern int OmenLighting_Mouse_SetStatic(IntPtr hMouse, int zone, LightingColor color, IntPtr property);
static extern int OmenLighting_Speaker_SetStatic(IntPtr hSpeaker, LightingColor color, IntPtr property);
public StaticKeyEffect(KeyValuePair <DeviceKeys, Color> key) { lightingColor = LightingColor.FromColor(key.Value); this.key = OmenKeys.GetKey(key.Key); }
private void SetLight(DeviceKeys key, Color color) { if (hChassis != IntPtr.Zero) { Task.Run(() => { if (Monitor.TryEnter(this)) { try { int res = OmenLighting_Chassis_SetStatic(hChassis, (int)GetZone(key), LightingColor.FromColor(color), IntPtr.Zero); if (res != 0) { Global.logger.Error("OMEN Chassis, Set static effect fail: " + res); } } finally { Monitor.Exit(this); } } }); } }
static extern int OmenLighting_Chassis_SetStatic(IntPtr hChassis, int zone, LightingColor color, IntPtr property);