Exemple #1
0
 public void InitiateReactiveBackground()
 {
     for (int i = 0; i < 144; i++)
     {
         if (Program.StaticKeyColors[i] == Color.Transparent)
         {
             keyMatrix[i] = new SingleKeyFade(
                 20,
                 (byte)0,
                 (byte)0,
                 (byte)0,
                 (byte)0,
                 (byte)0,
                 (byte)0);
         }
         else
         {
             keyMatrix[i] = new SingleKeyFade(
                 20,
                 (byte)0,
                 (byte)0,
                 (byte)0,
                 (byte)Program.StaticKeyColors[i].R,
                 (byte)Program.StaticKeyColors[i].G,
                 (byte)Program.StaticKeyColors[i].B);
         }
         sendMatrix[i] = new StaticColorCollection();
     }
 }
Exemple #2
0
        public static void KeyboardControl()
        {
            if (Program.RunKeyboardThread != 3)
            {
                return;
            }
            ;

            UpdateStatusMessage.ShowStatusMessage(2, "Starting Effects");

            KeyboardWriter keyWriter = new KeyboardWriter();

            SingleKeyFade[]         keyMatrix  = new SingleKeyFade[148];
            StaticColorCollection[] sendMatrix = new StaticColorCollection[144];

            MouseWriter mouseWriter = new MouseWriter();

            MouseColorCollection[] mouseMatrix = new MouseColorCollection[4];

            Random rnd = new Random();

            for (int i = 0; i < 144; i++)
            {
                keyMatrix[i]  = new SingleKeyFade(Program.EfSettings.Duration, 0, 0, 0);
                sendMatrix[i] = new StaticColorCollection();
            }
            for (int i = 144; i < 148; i++)
            {
                keyMatrix[i]         = new SingleKeyFade(Program.EfSettings.Duration, 0, 0, 0);
                mouseMatrix[i - 144] = new MouseColorCollection();
            }

            while (Program.RunKeyboardThread == 3)
            {
                int keyToLight = rnd.Next(0, 148);

                // Try 20 times to find a key that is finished its animation.
                // If a key can't be found, give up and run another cycle.
                for (int r = 0; r < 20; r++)
                {
                    if (keyMatrix[keyToLight].EffectInProgress == false)
                    {
                        switch (Program.EfColors.Mode)
                        {
                        case 1:
                            keyMatrix[keyToLight] = new SingleKeyFade(
                                Program.EfSettings.Duration,
                                (byte)Program.EfColors.StartR,
                                (byte)Program.EfColors.StartG,
                                (byte)Program.EfColors.StartB,
                                (byte)Program.EfColors.EndR,
                                (byte)Program.EfColors.EndG,
                                (byte)Program.EfColors.EndB);
                            break;

                        case 2:
                            keyMatrix[keyToLight] = new SingleKeyFade(
                                Program.EfSettings.Duration,
                                (byte)rnd.Next(Program.EfColors.SRandRLow, Program.EfColors.SRandRHigh),
                                (byte)rnd.Next(Program.EfColors.SRandGLow, Program.EfColors.SRandGHigh),
                                (byte)rnd.Next(Program.EfColors.SRandBLow, Program.EfColors.SRandBHigh),
                                (byte)Program.EfColors.EndR,
                                (byte)Program.EfColors.EndG,
                                (byte)Program.EfColors.EndB);
                            break;

                        case 3:
                            keyMatrix[keyToLight] = new SingleKeyFade(
                                Program.EfSettings.Duration,
                                (byte)Program.EfColors.StartR,
                                (byte)Program.EfColors.StartG,
                                (byte)Program.EfColors.StartB,
                                (byte)rnd.Next(Program.EfColors.ERandRLow, Program.EfColors.ERandRHigh),
                                (byte)rnd.Next(Program.EfColors.ERandGLow, Program.EfColors.ERandGHigh),
                                (byte)rnd.Next(Program.EfColors.ERandBLow, Program.EfColors.ERandBHigh));
                            break;

                        case 4:
                            keyMatrix[keyToLight] = new SingleKeyFade(
                                Program.EfSettings.Duration,
                                (byte)rnd.Next(Program.EfColors.SRandRLow, Program.EfColors.SRandRHigh),
                                (byte)rnd.Next(Program.EfColors.SRandGLow, Program.EfColors.SRandGHigh),
                                (byte)rnd.Next(Program.EfColors.SRandBLow, Program.EfColors.SRandBHigh),
                                (byte)rnd.Next(Program.EfColors.ERandRLow, Program.EfColors.ERandRHigh),
                                (byte)rnd.Next(Program.EfColors.ERandGLow, Program.EfColors.ERandGHigh),
                                (byte)rnd.Next(Program.EfColors.ERandBLow, Program.EfColors.ERandBHigh));
                            break;
                        }
                        break;
                    }
                }

                for (int i = 0; i < 144; i++)
                {
                    if (Program.AnimationsUseStaticKeys == true && Program.StaticKeyColorsBytes[i].Transparent == false)
                    {
                        sendMatrix[i].Set(Program.StaticKeyColorsBytes[i].KeyColor);
                    }
                    else
                    {
                        sendMatrix[i].SetD(keyMatrix[i].KeyColor);
                    }
                    keyMatrix[i].IncrementStep();
                }

                for (int i = 144; i < 148; i++)
                {
                    mouseMatrix[i - 144].Set(keyMatrix[i].KeyColor);
                    keyMatrix[i].IncrementStep();
                }

                keyWriter.Write(sendMatrix, true);
                if (Program.IncludeMouseInEffects)
                {
                    if (!Program.AnimationsUseStaticKeys)
                    {
                        mouseWriter.Write(mouseMatrix, true);
                    }
                    else
                    {
                        mouseWriter.Write(Program.MouseColors, true);
                    };
                }
                ;
                Thread.Sleep(Program.EfSettings.Frequency);
            }

            UpdateStatusMessage.ShowStatusMessage(2, "Stopping Effects");
        }
Exemple #3
0
        public void InputFromKeyboard_SingleLight(RAWINPUTHEADER riHeader, RAWKEYBOARD riKeyboard)
        {
            if (riKeyboard.Flags == 0x0)
            {
                return;
            }
            ;
            if (riKeyboard.Flags == 0x2 && Control.IsKeyLocked(Keys.NumLock))
            {
                return;
            }
            ;


            string s = "";

            s = s + "0x" + riKeyboard.MakeCode.ToString("X4");
            s = s + "  0x" + riKeyboard.VKey.ToString("X4");
            //            s = s + "  Mssg: 0x" + riKeyboard.Message.ToString("X4");
            s = s + "  0x" + riKeyboard.Flags.ToString("X4");
            //            s = s + "   Rsrvd: 0x" + riKeyboard.Reserved.ToString("X4");
            //            s = s + "   ExInf: 0x" + riKeyboard.ExtraInformation.ToString("X4");
            //            s = s + "  Devc: 0x" + riHeader.hDevice.ToString("X4");
            //            s = s + "   .Size: 0x" + riHeader.dwSize.ToString("X4");
            //            s = s + "   .Type: 0x" + riHeader.dwType.ToString("X4");
            //            s = s + "   wPara: 0x" + riHeader.wParam.ToString("X4");
            System.Diagnostics.Debug.Write(s);
            UpdateStatusMessage.ShowStatusMessage(5, s);


            int currentKey = keys.GetKeyCode(riKeyboard.MakeCode, riKeyboard.VKey, riKeyboard.Flags, Control.IsKeyLocked(Keys.NumLock));
            int sR = 0; int sG = 0; int sB = 0;
            int eR = 0; int eG = 0; int eB = 0;

            switch (Program.ReactTypeStart)
            {
            case 0:
                sR = Program.ReactColors.StartR;
                sG = Program.ReactColors.StartG;
                sB = Program.ReactColors.StartB;
                break;

            case 1:
                //Figure out how to make a rainbow here, probably going to need to rewrite SingleKeyFade classs
                break;

            case 2:
                sR = rnd.Next(Program.ReactColors.SRandRLow, Program.ReactColors.SRandRHigh);
                sG = rnd.Next(Program.ReactColors.SRandGLow, Program.ReactColors.SRandGHigh);
                sB = rnd.Next(Program.ReactColors.SRandBLow, Program.ReactColors.SRandBHigh);
                break;

            default:
                break;
            }

            switch (Program.ReactTypeEnd)
            {
            case 0:
                eR = Program.ReactColors.EndR;
                eG = Program.ReactColors.EndG;
                eB = Program.ReactColors.EndB;
                break;

            case 1:
                if (Program.StaticKeyColors[currentKey] != Color.Transparent)
                {
                    eR = Program.StaticKeyColors[currentKey].R;
                    eG = Program.StaticKeyColors[currentKey].G;
                    eB = Program.StaticKeyColors[currentKey].B;
                }
                break;

            case 2:
                eR = rnd.Next(Program.ReactColors.ERandRLow, Program.ReactColors.ERandRHigh);
                eG = rnd.Next(Program.ReactColors.ERandGLow, Program.ReactColors.ERandGHigh);
                eB = rnd.Next(Program.ReactColors.ERandBLow, Program.ReactColors.ERandBHigh);
                break;

            default:
                break;
            }

            keyMatrix[currentKey] = new SingleKeyFade(
                Program.ReactSettings.Duration,
                (byte)sR,
                (byte)sG,
                (byte)sB,
                (byte)eR,
                (byte)eG,
                (byte)eB);
        }