Example #1
0
        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);
                        }
                    }
                });
            }
        }
Example #2
0
        public static LightingColor FromColor(Color c)
        {
            LightingColor lc = new LightingColor()
            {
                r = c.R,
                g = c.G,
                b = c.B
            };

            return(lc);
        }
Example #3
0
        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);
                        }
                    }
                });
            }
        }
Example #4
0
 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);
                 }
             }
         });
     }
 }
Example #5
0
 static extern int OmenLighting_Mouse_SetStatic(IntPtr hMouse, int zone, LightingColor color, IntPtr property);
Example #6
0
 static extern int OmenLighting_Speaker_SetStatic(IntPtr hSpeaker, LightingColor color, IntPtr property);
Example #7
0
 public StaticKeyEffect(KeyValuePair <DeviceKeys, Color> key)
 {
     lightingColor = LightingColor.FromColor(key.Value);
     this.key      = OmenKeys.GetKey(key.Key);
 }
Example #8
0
 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);
                 }
             }
         });
     }
 }
Example #9
0
 static extern int OmenLighting_Chassis_SetStatic(IntPtr hChassis, int zone, LightingColor color, IntPtr property);