コード例 #1
0
ファイル: WootingDevice.cs プロジェクト: gitmacer/Aurora
        public override bool UpdateDevice(Dictionary <DeviceKeys, Color> keyColors, DoWorkEventArgs e, bool forced = false)
        {
            if (!IsInitialized)
            {
                return(false);
            }

            double rScalar = Global.Configuration.VarRegistry.GetVariable <int>($"{DeviceName}_scalar_r") / 100.0;
            double gScalar = Global.Configuration.VarRegistry.GetVariable <int>($"{DeviceName}_scalar_g") / 100.0;
            double bScalar = Global.Configuration.VarRegistry.GetVariable <int>($"{DeviceName}_scalar_b") / 100.0;

            try
            {
                foreach (var key in keyColors)
                {
                    if (WootingKeyMap.KeyMap.TryGetValue(key.Key, out var wootKey))
                    {
                        var clr = ColorUtils.CorrectWithAlpha(key.Value);
                        RGBControl.SetKey(wootKey, (byte)(clr.R * rScalar),
                                          (byte)(clr.G * gScalar),
                                          (byte)(clr.B * bScalar));
                    }
                }
                RGBControl.UpdateKeyboard();
                return(true);
            }
            catch (Exception exc)
            {
                LogError("Failed to Update Device" + exc.ToString());
                return(false);
            }
        }
コード例 #2
0
ファイル: WootingDevice.cs プロジェクト: gitmacer/Aurora
        public override bool Initialize()
        {
            if (IsInitialized)
            {
                return(IsInitialized);
            }

            try
            {
                if (RGBControl.IsConnected())
                {
                    IsInitialized = true;
                    _deviceInfo   = RGBControl.GetDeviceInfo().Model;
                    cb            = new DisconnectedCallback(OnDisconnect);
                    RGBControl.SetDisconnectedCallback(cb);
                }
                else
                {
                    IsInitialized = false;
                    _deviceInfo   = "";
                }
            }
            catch (Exception exc)
            {
                LogError("There was an error initializing Wooting SDK.\r\n" + exc.Message);

                IsInitialized = false;
            }

            return(IsInitialized);
        }
コード例 #3
0
        public bool Initialize()
        {
            lock (action_lock)
            {
                if (!isInitialized)
                {
                    try
                    {
                        if (RGBControl.IsConnected())
                        {
                            isInitialized = true;
                        }
                    }
                    catch (Exception exc)
                    {
                        Global.logger.Error("There was an error initializing Wooting SDK.\r\n" + exc.Message);

                        return(false);
                    }
                }

                if (!isInitialized)
                {
                    Global.logger.Info("No Wooting devices successfully Initialized!");
                }

                return(isInitialized);
            }
        }
コード例 #4
0
ファイル: WootingDevice.cs プロジェクト: XevianLight/Aurora
        public override bool UpdateDevice(Dictionary <DeviceKeys, System.Drawing.Color> keyColors, DoWorkEventArgs e, bool forced = false)
        {
            if (!isInitialized)
            {
                return(false);
            }

            try
            {
                foreach (var key in keyColors)
                {
                    if (WootingMapping.KeyMap.TryGetValue(key.Key, out var wootKey))
                    {
                        var clr = CorrectAlpha(key.Value);
                        RGBControl.SetKey(wootKey, (byte)(clr.R * GlobalVarRegistry.GetVariable <int>($"{DeviceName}_scalar_r") / 100),
                                          (byte)(clr.G * GlobalVarRegistry.GetVariable <int>($"{DeviceName}_scalar_g") / 100),
                                          (byte)(clr.B * GlobalVarRegistry.GetVariable <int>($"{DeviceName}_scalar_b") / 100));
                    }
                }

                return(RGBControl.UpdateKeyboard());
            }
            catch (Exception exc)
            {
                LogError("Failed to update device" + exc.ToString());
                return(false);
            }
        }
コード例 #5
0
        /// <summary>
        /// Updates the devices used in ZipatoDevices.
        /// </summary>
        public void Update()
        {
            for (int i = 0; i < Switches.Count; ++i)
            {
                var uuid = Switches[i].Uuid;
                Switches[i] = new Switch(_zipato, uuid);
            }

            for (int i = 0; i < OnOffSwitches.Count; ++i)
            {
                var uuid = OnOffSwitches[i].Uuid;
                OnOffSwitches[i] = new OnOff(_zipato, uuid);
            }

            for (int i = 0; i < Wallplugs.Count; ++i)
            {
                var uuid = Wallplugs[i].Uuid;
                Wallplugs[i] = new Plug(_zipato, uuid);
            }

            for (int i = 0; i < Dimmers.Count; ++i)
            {
                var uuid = Dimmers[i].Uuid;
                Dimmers[i] = new Dimmer(_zipato, uuid);
            }

            for (int i = 0; i < RGBControls.Count; ++i)
            {
                var uuid = RGBControls[i].Uuid;
                RGBControls[i] = new RGBControl(_zipato, uuid);
            }

            Status = _zipato?.Data?.Status ?? Uncertain;
        }
コード例 #6
0
ファイル: WootingDevice.cs プロジェクト: XevianLight/Aurora
        public override void Shutdown()
        {
            if (!isInitialized)
            {
                return;
            }

            RGBControl.Reset();
            isInitialized = false;
        }
コード例 #7
0
        static void TestRGB()
        {
            Console.WriteLine("Wooting Rgb Control testing!");
            Console.WriteLine($"wooting_rgb_kbd_connected: {RGBControl.IsConnected()}");
            //RGBControl.wooting_rgb_direct_set_key(0, 0, 255, 0, 0);
            //Console.WriteLine("Turning on auto-update!");
            //RGBControl.wooting_rgb_array_auto_update(true);
            Console.WriteLine("Set disconnected cb");
            RGBControl.SetDisconnectedCallback((DisconnectedCallback)dc_cb);
            Console.WriteLine("Setting some keys directly!");
            Console.WriteLine($"Setting ESC green: {RGBControl.SetKey(WootingKey.Keys.Esc, 0, 255, 0)}");
            RGBControl.UpdateKeyboard();
            Console.WriteLine("Setting Enter Red");
            RGBControl.SetKey(WootingKey.Keys.Enter, 255, 0, 0, true);
            Console.WriteLine("Setting G blue");
            RGBControl.SetKey(WootingKey.Keys.G, 0, 0, 255, true);
            Console.WriteLine("Setting Mode/Scroll Lock green");
            RGBControl.SetKey(WootingKey.Keys.Mode_ScrollLock, 0, 255, 0, true);
            Thread.Sleep(5000);

            Console.WriteLine("Setting the keyboard blank!");
            KeyColour[,] keys = new KeyColour[RGBControl.MaxRGBRows, RGBControl.MaxRGBCols];
            for (byte i = 0; i < RGBControl.MaxRGBCols; i++)
            {
                for (byte j = 0; j < RGBControl.MaxRGBRows; j++)
                {
                    keys[j, i] = new KeyColour(0, 0, 0);
                }
            }
            RGBControl.SetFull(keys);
            RGBControl.UpdateKeyboard();
            Thread.Sleep(1000);

            //RGBControl.woo(true);

            for (byte i = 0; i < RGBControl.MaxRGBCols; i++)
            {
                for (byte j = 0; j < RGBControl.MaxRGBRows; j++)
                {
                    Console.WriteLine($"Setting the key, ROW:{j}, COL:{i}");
                    keys[j, i] = new KeyColour(255, 255, 0);
                    //RGBControl.SetKey(j, i, 255, 0, 0, true);
                    //RGBControl.SetFull(keys);
                    //RGBControl.UpdateKeyboard();
                    RGBControl.SetFull(keys);
                    RGBControl.UpdateKeyboard();
                    Thread.Sleep(100);
                }
                //Thread.Sleep(1000);
            }
            //Console.WriteLine($"wooting_rgb_kbd_connected: {RGBControl.wooting_rgb_kbd_connected()}");
            Console.ReadKey();
            RGBControl.Reset();
            Console.ReadKey();
        }
コード例 #8
0
ファイル: WootingDevice.cs プロジェクト: gitmacer/Aurora
        public override void Shutdown()
        {
            if (!IsInitialized)
            {
                return;
            }

            RGBControl.Close();
            _deviceInfo   = "";
            IsInitialized = false;
        }
コード例 #9
0
 public void Shutdown()
 {
     lock (action_lock)
     {
         if (isInitialized)
         {
             RGBControl.Reset();
             isInitialized = false;
         }
     }
 }
コード例 #10
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);
            }
        }
コード例 #11
0
ファイル: WootingDevice.cs プロジェクト: XevianLight/Aurora
        public override bool Initialize()
        {
            if (!isInitialized)
            {
                try
                {
                    if (RGBControl.IsConnected())
                    {
                        isInitialized = true;
                    }
                }
                catch (Exception exc)
                {
                    LogError("There was an error initializing Wooting SDK.\r\n" + exc.Message);

                    return(false);
                }
            }

            return(isInitialized);
        }
コード例 #12
0
        static void TestRGB()
        {
            Console.WriteLine("Wooting Rgb Control testing!");
            RGBDeviceInfo device = RGBControl.GetDeviceInfo();

            Console.WriteLine($"Initial Device Info has got: Connected: {device.Connected}, Model: {device.Model}, Type: {device.DeviceType}, Max Rows: {device.MaxRows}, Max Cols: {device.MaxColumns}, Max Keycode: {device.KeycodeLimit}");

            bool connected = RGBControl.IsConnected();

            Console.WriteLine($"wooting_rgb_kbd_connected: {connected}");


            if (!connected)
            {
                return;
            }

            device = RGBControl.GetDeviceInfo();
            Console.WriteLine($"Device Info has got: Connected: {device.Connected}, Model: {device.Model}, Type: {device.DeviceType}, Max Rows: {device.MaxRows}, Max Cols: {device.MaxColumns}, Max Keycode: {device.KeycodeLimit}");

            //Console.WriteLine("Turning on auto-update!");
            //RGBControl.wooting_rgb_array_auto_update(true);
            Console.WriteLine("Set disconnected cb");
            RGBControl.SetDisconnectedCallback((DisconnectedCallback)dc_cb);
            Console.WriteLine("Setting some keys directly!");
            Console.WriteLine($"Setting ESC green: {RGBControl.SetKey(WootingKey.Keys.Esc, 0, 255, 0, true)}");
            // RGBControl.UpdateKeyboard();
            Console.WriteLine("Setting Enter Red");
            RGBControl.SetKey(WootingKey.Keys.Enter, 255, 0, 0, true);
            Console.WriteLine("Setting G blue");
            RGBControl.SetKey(WootingKey.Keys.G, 0, 0, 255, true);
            Console.WriteLine("Setting Mode/Scroll Lock green");
            RGBControl.SetKey(WootingKey.Keys.Mode_ScrollLock, 0, 255, 0, true);
            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();

            Console.WriteLine("Setting the keyboard blank!");
            KeyColour[,] keys = new KeyColour[RGBControl.MaxRGBRows, RGBControl.MaxRGBCols];
            for (byte i = 0; i < device.MaxColumns; i++)
            {
                for (byte j = 0; j < device.MaxRows; j++)
                {
                    keys[j, i] = new KeyColour(0, 0, 0);
                }
            }
            RGBControl.SetFull(keys);
            RGBControl.UpdateKeyboard();
            RGBControl.ResetRGB();
            Thread.Sleep(1000);
            RGBControl.Close();

            for (byte i = 0; i < device.MaxColumns; i++)
            {
                for (byte j = 0; j < device.MaxRows; j++)
                {
                    Console.WriteLine($"Setting the key, ROW:{j}, COL:{i}");
                    keys[j, i] = new KeyColour(255, 255, 0);
                    RGBControl.SetFull(keys);
                    RGBControl.UpdateKeyboard();
                    Thread.Sleep(100);
                }
            }
            Console.WriteLine("Press any key to reset all colors to default...");
            Console.ReadKey();
            RGBControl.Close();
        }