Exemplo n.º 1
0
        // Internal
        public void _MalletStruckKeyboardKey(KeyboardMallet mallet, KeyboardKey key)
        {
            // Did we hit the key for another keyboard?
            if (key._keyboard != this)
            {
                return;
            }

            // Trigger key press animation
            key.KeyPressed();

            // Fire key press event
            if (keyPressed != null)
            {
                string keyPress = key.GetCharacter();

                bool shouldFireKeyPressEvent = true;

                if (keyPress == "\\s")
                {
                    // Shift
                    shift = !shift;
                    shouldFireKeyPressEvent = false;
                }
                else if (keyPress == "\\l")
                {
                    // Layout swap
                    if (layout == Layout.Letters)
                    {
                        layout = Layout.Numbers;
                    }
                    else if (layout == Layout.Numbers)
                    {
                        layout = Layout.Letters;
                    }

                    shouldFireKeyPressEvent = false;
                }
                else if (keyPress == "\\b")
                {
                    // Backspace
                    keyPress = "\b";
                }
                else
                {
                    // Turn off shift after typing a letter
                    if (shift && layout == Layout.Letters)
                    {
                        shift = false;
                    }
                }

                if (shouldFireKeyPressEvent)
                {
                    keyPressed(this, keyPress);
                }
            }
        }
Exemplo n.º 2
0
        // Internal
        public void _MalletStruckKeyboardKey(KeyboardMallet mallet, KeyboardKey key)
        {
            // Did we hit the key for another keyboard?
            if (key._keyboard != this)
            {
                return;
            }

            GameObject grandparent = key.transform.parent.gameObject.transform.parent.gameObject;
            bool       isLetter    = grandparent == _letters;

            if (isLetter)
            {
                // Gesture Mode: Don't trigger the same key twice
                if (key == prevKey)
                {
                    return;
                }
                prevKey = key;

                // log keys
                KeySequence += key.character;
            }

            // Trigger key press animation
            key.KeyPressed();

            // Fire key press event
            if (keyPressed != null)
            {
                string keyPress = key.GetCharacter();

                bool shouldFireKeyPressEvent = true;

                if (keyPress == "\\s")
                {
                    // Shift
                    shift = !shift;
                    shouldFireKeyPressEvent = false;
                }
                else if (keyPress == "\\l")
                {
                    // Layout swap
                    if (layout == Layout.Letters)
                    {
                        layout = Layout.Numbers;
                    }
                    else if (layout == Layout.Numbers)
                    {
                        layout = Layout.Letters;
                    }

                    shouldFireKeyPressEvent = false;
                }
                else if (keyPress == "\\b")
                {
                    // Backspace
                    keyPress = "\b";
                }
                else
                {
                    // Turn off shift after typing a letter
                    if (shift && layout == Layout.Letters)
                    {
                        shift = false;
                    }
                }

                if (shouldFireKeyPressEvent)
                {
                    keyPressed(this, keyPress);
                }
            }
        }