Ejemplo n.º 1
0
        // -------------------------
        // Key Down (Global)
        // -------------------------
        void KListener_KeyDown(object sender, RawKeyEventArgs args)
        {
            // Note: Threading causes Crash

            Sound.KeyPressed(args);
        }
Ejemplo n.º 2
0
        // -------------------------
        // Key Pressed
        // -------------------------
        public static void KeyPressed(RawKeyEventArgs args)
        {
            // -------------------------
            // Letters
            // -------------------------
            if (args.Key >= Key.A && args.Key <= Key.Z)
            {
                // randomize
                wavKey = arrWavChar[App.rnd.Next(arrWavChar.Length)];

                if (args.Key == Key.A)
                {
                    PlaySound(wavKey6);
                }
                else if (args.Key == Key.B)
                {
                    PlaySound(wavKey1);
                }
                else if (args.Key == Key.C)
                {
                    PlaySound(wavKey3);
                }
                else if (args.Key == Key.D)
                {
                    PlaySound(wavKey4);
                }
                else if (args.Key == Key.E)
                {
                    PlaySound(wavKey5);
                }
                else if (args.Key == Key.F)
                {
                    PlaySound(wavKey6);
                }
                else if (args.Key == Key.G)
                {
                    PlaySound(wavKey7);
                }
                else if (args.Key == Key.H)
                {
                    PlaySound(wavKey8);
                }
                else if (args.Key == Key.I)
                {
                    PlaySound(wavKey10);
                }
                else if (args.Key == Key.J)
                {
                    PlaySound(wavKey16);
                }
                else if (args.Key == Key.K)
                {
                    PlaySound(wavKey11);
                }
                else if (args.Key == Key.L)
                {
                    PlaySound(wavKey12);
                }
                else if (args.Key == Key.M)
                {
                    PlaySound(wavKey13);
                }
                else if (args.Key == Key.N)
                {
                    PlaySound(wavKey14);
                }
                else if (args.Key == Key.O)
                {
                    PlaySound(wavKey15);
                }
                else if (args.Key == Key.P)
                {
                    PlaySound(wavKey16);
                }
                else if (args.Key == Key.Q)
                {
                    PlaySound(wavKey4);
                }
                else if (args.Key == Key.R)
                {
                    PlaySound(wavKey5);
                }
                else if (args.Key == Key.S)
                {
                    PlaySound(wavKey1);
                }
                else if (args.Key == Key.T)
                {
                    PlaySound(wavKey18);
                }
                else if (args.Key == Key.U)
                {
                    PlaySound(wavKey17);
                }
                else if (args.Key == Key.V)
                {
                    PlaySound(wavKey10);
                }
                else if (args.Key == Key.W)
                {
                    PlaySound(wavKey9);
                }
                else if (args.Key == Key.X)
                {
                    PlaySound(wavKey11);
                }
                else if (args.Key == Key.Y)
                {
                    PlaySound(wavKey12);
                }
                else if (args.Key == Key.Z)
                {
                    PlaySound(wavKey13);
                }
                else
                {
                    PlaySound(wavKey);
                }
            }
            // -------------------------
            // Numbers
            // -------------------------
            else if (args.Key >= Key.D0 && args.Key <= Key.D9)
            {
                // randomize
                wavKey = arrWavChar[App.rnd.Next(arrWavChar.Length)];

                if (args.Key == Key.D1)
                {
                    PlaySound(wavKey6);
                }
                else if (args.Key == Key.D2)
                {
                    PlaySound(wavKey2);
                }
                else if (args.Key == Key.D3)
                {
                    PlaySound(wavKey3);
                }
                else if (args.Key == Key.D4)
                {
                    PlaySound(wavKey4);
                }
                else if (args.Key == Key.D5)
                {
                    PlaySound(wavKey5);
                }
                else if (args.Key == Key.D6)
                {
                    PlaySound(wavKey6);
                }
                else if (args.Key == Key.D7)
                {
                    PlaySound(wavKey7);
                }
                else if (args.Key == Key.D8)
                {
                    PlaySound(wavKey1);
                }
                else if (args.Key == Key.D9)
                {
                    PlaySound(wavKey14);
                }
                else if (args.Key == Key.D0)
                {
                    PlaySound(wavKey13);
                }
                else
                {
                    PlaySound(wavKey);
                }
            }

            // -------------------------
            // Numpad
            // -------------------------
            else if (args.Key >= Key.NumPad0 && args.Key <= Key.NumPad9)
            {
                // randomize
                wavKey = arrWavChar[App.rnd.Next(arrWavChar.Length)];

                PlaySound(wavKey);
            }

            // -------------------------
            // Math Operators
            // -------------------------
            else if (args.Key == Key.Subtract ||
                     args.Key == Key.Add ||
                     args.Key == Key.Decimal ||
                     args.Key == Key.Divide ||
                     args.Key == Key.Multiply)
            {
                // randomize
                wavKey = arrWavChar[App.rnd.Next(arrWavChar.Length)];

                PlaySound(wavKey);
            }

            // -------------------------
            // Punctuation
            // -------------------------
            else if (args.Key == Key.OemPlus ||
                     args.Key == Key.OemMinus ||
                     args.Key == Key.OemQuestion ||
                     args.Key == Key.OemComma ||
                     args.Key == Key.OemPeriod ||
                     args.Key == Key.OemOpenBrackets ||
                     args.Key == Key.OemQuotes ||
                     args.Key == Key.Oem1 ||
                     args.Key == Key.Oem3 ||
                     args.Key == Key.Oem5 ||
                     args.Key == Key.Oem6)
            {
                // randomize
                wavKey = arrWavChar[App.rnd.Next(arrWavChar.Length)];

                PlaySound(wavKey);
            }

            // -------------------------
            // Space
            // -------------------------
            else if (args.Key == Key.Space)
            {
                // randomize
                wavSpace = arrWavSpace[App.rnd.Next(arrWavSpace.Length)];

                PlaySound(wavSpace);
            }

            // -------------------------
            // Modifiers
            // -------------------------
            // Shift (Strike Hold)
            else if (args.Key == Key.LeftShift ||
                     args.Key == Key.RightShift ||
                     args.Key == Key.CapsLock)
            {
                while (App.strikeHold == false)
                {
                    // randomize
                    wavMod = arrWavMod[App.rnd.Next(arrWavMod.Length)];

                    PlaySound(wavMod);

                    App.strikeHold = true;
                }
            }

            // -------------------------
            // Tab
            // -------------------------
            else if (args.Key == Key.Tab)
            {
                PlaySound(wavTab);
            }

            // -------------------------
            // Backspace
            // -------------------------
            else if (args.Key == Key.Back)
            {
                // randomize
                wavMod = arrWavMod[App.rnd.Next(arrWavMod.Length)];

                PlaySound(wavMod);
            }
            // -------------------------
            // Enter
            // -------------------------
            else if (args.Key == Key.Enter)
            {
                // randomize
                wavEnter = arrWavEnter[App.rnd.Next(arrWavEnter.Length)];

                PlaySound(wavEnter);
            }

            // -------------------------
            // Escape
            // -------------------------
            else if (args.Key == Key.Escape)
            {
                while (App.strikeHold == false)
                {
                    // randomize
                    wavEscape = arrWavEscape[App.rnd.Next(arrWavEscape.Length)];

                    PlaySound(wavEscape);

                    App.strikeHold = true;
                }
            }
        }
Ejemplo n.º 3
0
 // -------------------------
 // Key Up (Global)
 // -------------------------
 void KListener_KeyUp(object sender, RawKeyEventArgs args)
 {
     // Used for keys that don't repeat when held down
     // Shift Caps Lock, Esc
     App.strikeHold = false;
 }