示例#1
0
        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);
        }
示例#2
0
        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));
        }
示例#3
0
        private void Restoregeneric()
        {
            //Workaround
            //Global.logger.LogLine("restore Roccat generic");
            System.Drawing.Color restore_fallback = Global.Configuration.VarRegistry.GetVariable <Aurora.Utils.RealColor>($"{devicename}_restore_fallback").GetDrawingColor();
            restore_fallback = System.Drawing.Color.FromArgb(255, Utils.ColorUtils.MultiplyColorByScalar(restore_fallback, restore_fallback.A / 255.0D));

            //Global.logger.LogLine("restore Roccat generic" + restore_fallback + restore_fallback.R + restore_fallback.G + restore_fallback.B);
            talkFX.SetLedRgb(Zone.Event, KeyEffect.On, Speed.Fast, new Color(restore_fallback.R, restore_fallback.G, restore_fallback.B));

            previous_peripheral_Color = System.Drawing.Color.FromArgb(restore_fallback.R, restore_fallback.G, restore_fallback.B);

            //.RestoreLedRgb() Does not work
            talkFX.RestoreLedRgb();
        }
示例#4
0
        public override bool UpdateDevice(Dictionary <DeviceKeys, Color> keyColors, DoWorkEventArgs e, bool forced = false)
        {
            if (!isInitialized)
            {
                return(false);
            }

            if (enable_ryos)
            {
                foreach (var key in keyColors)
                {
                    if (KeyMap.DeviceKeysMap.TryGetValue(KeyMap.LocalizeKey(key.Key), out var k))
                    {
                        colorStruct[k] = ToRoccatColor(key.Value);
                        stateStruct[k] = IsLedOn(key.Value);
                    }
                }
                ryosTalkFx.SetMkFxKeyboardState(stateStruct, colorStruct, (byte)KeyMap.GetLayout());
            }

            //Set 1 color devices
            if (enable_generic && keyColors.TryGetValue(device_key, out var clr))
            {
                talkFx.SetLedRgb(Zone.Event, KeyEffect.On, Speed.Fast, ToRoccatColor(clr));
            }

            return(true);
        }
示例#5
0
        private static void TalkFxTEst()
        {
            WriteAndWaitForEnter("TalkFX test, press enter to begin");

            using (var connection = new TalkFxConnection())
            {
                connection.SetLedRgb(Zone.Event, KeyEffect.Blinking, Speed.Normal, new Color(255, 105, 180));
                WriteAndWaitForEnter("The keys should now be blinking in a fairly pink color, press enter to continue");

                connection.SetLedRgb(Zone.Event, KeyEffect.On, Speed.Normal, new Color(255, 255, 255));
                WriteAndWaitForEnter("The keys should now be ON and have a white color, press enter to continue");

                connection.SetLedRgb(Zone.Event, KeyEffect.On, Speed.Normal, new Color(0, 0, 0));
                WriteAndWaitForEnter("The keys should now be OFF, press enter to continue");

                connection.SetLedRgb(Zone.Event, KeyEffect.Breathing, Speed.Normal, new Color(255, 0, 0));
                WriteAndWaitForEnter("The keys should now be 'breathing' in a red color, press enter to continue");

                connection.RestoreLedRgb();
            }

            WriteAndWaitForEnter("TalkFX test now finished, press enter to continue");
        }
示例#6
0
        public override void Shutdown()
        {
            //Shutdown 1 color devices.
            var restoreColor = ToRoccatColor(GlobalVarRegistry.GetVariable <RealColor>($"{DeviceName}_restore_fallback"));

            talkFx?.SetLedRgb(Zone.Event, KeyEffect.On, Speed.Fast, restoreColor); //Workaround because "RestoreLedRgb()" doesn't seam to work.
            talkFx?.RestoreLedRgb();
            talkFx?.Dispose();

            //Shutdown per key keyboards.
            ryosTalkFx?.ExitSdkMode();
            ryosTalkFx?.Dispose();

            isInitialized = false;
        }