private static void FftCalculated(object sender, FftEventArgs e)
        {
            int CanvasWidth = Program.MyCanvasWidth;

            byte[]         fftData   = new byte[fftLength];
            KeyboardWriter KeyWriter = keyWriter;

            for (int i = 0; i < fftLength; i++)
            {
                double fftmag = Math.Sqrt((e.Result[i].Real * e.Result[i].Real) + (e.Result[i].Imaginary * e.Result[i].Imaginary));
                fftData[i] = (byte)(fftmag);
            }
            keyWriter.Write(1, fftData, Program.StaticKeyColorsBytes, CanvasWidth);
            if (Program.LogLevel == 5)
            {
                UpdateStatusMessage.ShowStatusMessage(10, "Loop Time: " + sw.ElapsedMilliseconds);
                sw.Restart();
            }
            ;
            if (Program.RefreshDelay > 0)
            {
                Thread.Sleep(Program.RefreshDelay);
            }
            ;
        }
示例#2
0
        public void KeyboardControl()
        {
            if (Program.RunKeyboardThread != 11)
            {
                return;
            }
            ;

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

            // Raw Input Hook
            // http://www.codeproject.com/Articles/558413/Minimal-Key-Logger-Using-RAWINPUT
            //Program.InputHook = new RawInputHook();
            Program.InputHook.OnRawInputFromKeyboard += InputFromKeyboard_Heatmap;

            KeyboardWriter keyWriter = new KeyboardWriter();

            int sR = 0; int sG = 0; int sB = 0;
            int eR = 0; int eG = 0; int eB = 0;

            sR = Program.HeatmapColors.StartR;
            sG = Program.HeatmapColors.StartG;
            sB = Program.HeatmapColors.StartB;

            eR = Program.HeatmapColors.EndR;
            eG = Program.HeatmapColors.EndG;
            eB = Program.HeatmapColors.EndB;

            for (int i = 0; i < 144; i++)
            {
                keyMatrix[i] = new HeatmapKey(
                    (byte)sR,
                    (byte)sG,
                    (byte)sB,
                    (byte)eR,
                    (byte)eG,
                    (byte)eB);
                sendMatrix[i] = new StaticColorCollection();
            }


            while (Program.RunKeyboardThread == 11)
            {
                for (int i = 0; i < 144; i++)
                {
                    sendMatrix[i].SetD(keyMatrix[i].KeyColor);
                }

                keyWriter.Write(sendMatrix, true);

                Thread.Sleep(100);
            }

            Program.InputHook.OnRawInputFromKeyboard -= InputFromKeyboard_Heatmap;

            UpdateStatusMessage.ShowStatusMessage(2, "Stopping Heatmap");
        }
示例#3
0
        public void KeyboardControl()
        {
            if (Program.RunKeyboardThread != 10)
            {
                return;
            }
            ;

            UpdateStatusMessage.ShowStatusMessage(2, "Starting Reactive Typing");

            // Raw Input Hook
            // http://www.codeproject.com/Articles/558413/Minimal-Key-Logger-Using-RAWINPUT
            //Program.InputHook = new RawInputHook();
            Program.InputHook.OnRawInputFromKeyboard += InputFromKeyboard_SingleLight;

            KeyboardWriter keyWriter = new KeyboardWriter();

            InitiateReactiveBackground();

            while (Program.RunKeyboardThread == 10)
            {
                for (int i = 0; i < 144; i++)
                {
                    sendMatrix[i].SetD(keyMatrix[i].KeyColor);
                    keyMatrix[i].IncrementStep();
                }

                keyWriter.Write(sendMatrix, true);

                Thread.Sleep(Program.ReactSettings.Frequency);
            }

            //Program.InputHook.OnRawInputFromKeyboard -= InputFromKeyboard_SingleLight;

            UpdateStatusMessage.ShowStatusMessage(2, "Stopping Reactive Typing");
        }
示例#4
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");
        }
        public static void KeyboardControl(int captureType, MMDevice captureDevice)
        {
            if (Program.RunKeyboardThread == 1)
            {
                keyWriter = new KeyboardWriter();
                while (Program.RunKeyboardThread == 1)
                {
                    keyWriter.Write(-1, null, Program.StaticKeyColorsBytes, Program.TestLed);
                    Thread.Sleep(20);
                }
            }
            else
            {
                Program.CSCore_CaptureStarted = false;

                switch (captureType)
                {
                case 0:
                    capture = new WasapiLoopbackCapture();
                    break;

                case 1:
                    capture        = new WasapiCapture();
                    capture.Device = captureDevice;
                    break;

                default:
                    capture = new WasapiLoopbackCapture();
                    break;
                }

                capture.Initialize();
                int captureSampleRate = capture.WaveFormat.SampleRate;
                switch (captureSampleRate)
                {
                case 48000:
                    fftLength = 1024;
                    break;

                case 96000:
                    fftLength = 2048;
                    break;

                case 192000:
                    fftLength = 4096;
                    break;

                default:
                    fftLength = 1024;
                    break;
                }

                sampleAggregator = new SampleAggregator(fftLength);

                CreateDeviceHandles();
                Program.CSCore_NewDevice = false;

                keyWriter = new KeyboardWriter();

                sw = new Stopwatch();
                sw.Start(); // Start loop counting stopwatch

                if (Program.RunKeyboardThread != 0)
                {
                    UpdateStatusMessage.ShowStatusMessage(2, "Starting Capture");
                    capture.Start();
                }
                Program.CSCore_FirstStart = false;

                while (Program.CSCore_CaptureStarted == false)
                {
                    if (Program.RunKeyboardThread != 2)
                    {
                        CSCore_StopCapture();
                        break;
                    }
                    ;
                }
            }
        }