コード例 #1
0
ファイル: AnalogReader.cs プロジェクト: evilC/Wooting.NET
        /// <summary>
        /// Get the analog value of a single key.
        /// This function returns an analog value of a single key.
        /// It is not necesarry to initialize the keyboard before reading, but if the keyboard is not connected this function will return 0.
        /// </summary>
        /// <param name="key">The key to be read</param>
        /// <returns>The current analog value</returns>
        public static byte ReadAnalog(WootingKey.Keys key)
        {
            if (WootingKey.KeyMap.TryGetValue(key, out (byte row, byte column)index))
            {
                return(ReadAnalog(index.row, index.column));
            }

            return(0);
        }
コード例 #2
0
ファイル: RGBControl.cs プロジェクト: evilC/Wooting.NET
        /// <summary>
        /// Set the colour of a key
        /// </summary>
        /// <param name="key">The key to be coloured</param>
        /// <param name="colour">The colour for the key</param>
        /// <param name="direct">Determines if this is set directly to the keyboard or if it is stored in the keyboard color array</param>
        /// <returns>This functions return true (1) if the colours are changed (optional: updated)</returns>
        public static bool SetKey(WootingKey.Keys key, KeyColour colour, bool direct = false)
        {
            if (WootingKey.KeyMap.TryGetValue(key, out (byte row, byte column)index))
            {
                return(SetKey(index.row, index.column, colour.r, colour.g, colour.b, direct));
            }

            return(false);
        }
コード例 #3
0
ファイル: RGBControl.cs プロジェクト: evilC/Wooting.NET
        /// <summary>
        /// Directly reset 1 key on the keyboard to the original color.
        /// This function will directly reset the color of 1 key on the keyboard.This will not influence the keyboard color array.
        /// Use this function for simple applifications, like a notification.Use the array functions if you want to change the entire keyboard.
        /// </summary>
        /// <param name="key">The key to be reset</param>
        /// <returns>This functions return true (1) if the colour is reset.</returns>
        public static bool ResetKey(WootingKey.Keys key)
        {
            if (WootingKey.KeyMap.TryGetValue(key, out (byte row, byte column)index))
            {
                return(ResetKey(index.row, index.column));
            }

            return(false);
        }
コード例 #4
0
ファイル: RGBControl.cs プロジェクト: evilC/Wooting.NET
        /// <summary>
        /// Set the colour of a key
        /// </summary>
        /// <param name="key">The key to be coloured</param>
        /// <param name="red">A 0-255 value of the red color</param>
        /// <param name="green">A 0-255 value of the green color</param>
        /// <param name="blue">A 0-255 value of the blue color</param>
        /// <param name="direct">Determines if this is set directly to the keyboard or if it is stored in the keyboard color array</param>
        /// <returns>This functions return true (1) if the colours are changed (optional: updated)</returns>
        public static bool SetKey(WootingKey.Keys key, byte red, byte green, byte blue, bool direct = false)
        {
            if (WootingKey.KeyMap.TryGetValue(key, out (byte row, byte column)index))
            {
                return(SetKey(index.row, index.column, red, green, blue, direct));
            }

            return(false);
        }
コード例 #5
0
        public bool UpdateDevice(Dictionary <DeviceKeys, Color> keyColors, DoWorkEventArgs e, bool forced = false)
        {
            try
            {
                //Do this to prevent setting lighting again after the keyboard has been shutdown and reset
                lock (action_lock)
                {
                    if (!this.isInitialized)
                    {
                        return(false);
                    }

                    foreach (KeyValuePair <DeviceKeys, Color> key in keyColors)
                    {
                        if (e.Cancel)
                        {
                            return(false);
                        }


                        Color           clr    = Color.FromArgb(255, Utils.ColorUtils.MultiplyColorByScalar(key.Value, key.Value.A / 255.0D));
                        WootingKey.Keys devKey = DeviceKeyToWootingKey(key.Key);
                        if (devKey == WootingKey.Keys.None)
                        {
                            continue;
                        }
                        //(byte row, byte column) coordinates = WootingRgbControl.KeyMap[devKey];
                        //colourMap[coordinates.row, coordinates.column] = new KeyColour(clr.red, clr.green, clr.blue);

                        RGBControl.SetKey(devKey, (byte)(clr.R * Global.Configuration.VarRegistry.GetVariable <int>($"{devicename}_scalar_r") / 100),
                                          (byte)(clr.G * Global.Configuration.VarRegistry.GetVariable <int>($"{devicename}_scalar_g") / 100),
                                          (byte)(clr.B * Global.Configuration.VarRegistry.GetVariable <int>($"{devicename}_scalar_b") / 100));
                    }
                    if (e.Cancel)
                    {
                        return(false);
                    }
                    //AlsoWootingRgbControl.SetFull(colourMap);
                    RGBControl.UpdateKeyboard();
                }
                return(true);
            }
            catch (Exception exc)
            {
                Global.logger.Error("Failed to Update Device" + exc.ToString());
                return(false);
            }
        }