Beispiel #1
0
    private void OnKeyboard(VREvent_t ev)
    {
        if (minimalMode)
        {
            VREvent_Keyboard_t keyboard   = ev.data.keyboard;
            byte[]             inputBytes = new byte[] {
                keyboard.cNewInput0,
                keyboard.cNewInput1,
                keyboard.cNewInput2,
                keyboard.cNewInput3,
                keyboard.cNewInput4,
                keyboard.cNewInput5,
                keyboard.cNewInput6,
                keyboard.cNewInput7
            };
            int len = 0;
            for (; inputBytes [len] != 0 && len < 7; len++)
            {
                ;
            }
            string input = System.Text.Encoding.UTF8.GetString(inputBytes, 0, len);

            //Backspace button
            if (input == "\b")
            {
                if (text.Length > 0)
                {
                    text = text.Substring(0, text.Length - 1);
                }
            }
            else if (input == "\x1b")
            {
                var vr = SteamVR.instance;
                vr.overlay.HideKeyboard();
            }
            else
            {
                text += input;
            }

            Debug.Log(text);
        }
        else
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            SteamVR.instance.overlay.GetKeyboardText(sb, 1024);
            text = sb.ToString();
        }
    }
Beispiel #2
0
    private void OnKeyboard(object[] args)
    {
        if (activeKeyboard != this)
        {
            return;
        }
        Valve.VR.VREvent_t ev       = (Valve.VR.VREvent_t)args[0];
        VREvent_Keyboard_t keyboard = ev.data.keyboard;

        byte[] inputBytes = new byte[] { keyboard.cNewInput0, keyboard.cNewInput1, keyboard.cNewInput2, keyboard.cNewInput3, keyboard.cNewInput4, keyboard.cNewInput5, keyboard.cNewInput6, keyboard.cNewInput7 };
        int    len        = 0;

        for (; inputBytes[len] != 0 && len < 7; len++)
        {
            ;
        }
        string input = System.Text.Encoding.UTF8.GetString(inputBytes, 0, len);

        if (minimalMode)
        {
            if (input == "\b")
            {
                if (text.Length > 0)
                {
                    text = text.Substring(0, text.Length - 1);
                }
            }
            else if (input == "\x1b")
            {
                // Close the keyboard
                var vr = SteamVR.instance;
                vr.overlay.HideKeyboard();
                keyboardShowing = false;
            }
            else
            {
                text += input;
            }
            textEntry.text = text;
        }
        else
        {
            System.Text.StringBuilder textBuilder = new System.Text.StringBuilder(1024);
            uint size = SteamVR.instance.overlay.GetKeyboardText(textBuilder, 1024);
            text           = textBuilder.ToString();
            textEntry.text = text;
        }
    }
Beispiel #3
0
        private void OnKeyboardInput(VREvent_t ev)
        {
            VREvent_Keyboard_t keyboard = ev.data.keyboard;

            byte[] inputBytes = new byte[] { keyboard.cNewInput0, keyboard.cNewInput1, keyboard.cNewInput2, keyboard.cNewInput3, keyboard.cNewInput4, keyboard.cNewInput5, keyboard.cNewInput6, keyboard.cNewInput7 };
            int    len        = 0;

            for (; inputBytes[len] != 0 && len < 7; len++)
            {
                ;
            }
            string input = System.Text.Encoding.UTF8.GetString(inputBytes, 0, len);

            input = HandleSpecialConversionAndShortcuts(input);

            currentFrameInput = input;
        }
Beispiel #4
0
        private void OnKeyboardInput(VREvent_t ev)
        {
            string input = "";

            if (!m_chatMode)
            {
                VREvent_Keyboard_t keyboard   = ev.data.keyboard;
                byte[]             inputBytes = new byte[] { keyboard.cNewInput0, keyboard.cNewInput1, keyboard.cNewInput2, keyboard.cNewInput3, keyboard.cNewInput4, keyboard.cNewInput5, keyboard.cNewInput6, keyboard.cNewInput7 };
                int len = 0;
                for (; inputBytes[len] != 0 && len < 7; len++)
                {
                    ;
                }
                input             = Encoding.UTF8.GetString(inputBytes, 0, len);
                input             = HandleSpecialConversionAndShortcuts(input);
                CurrentFrameInput = input;
            }
            else
            {
                StringBuilder textBuilder = new StringBuilder(256);
                SteamVR.instance.overlay.GetKeyboardText(textBuilder, 256);
                input             = textBuilder.ToString();
                CurrentTotalInput = input;
                if (KeyboardClosedThisFrame || input.Contains("\r") || input.Contains("\n"))
                {
                    input = input.Replace("\r", "").Replace("\n", "");
                    if (PlayerChatManager.Current != null && PlayerChatManager.InChatMode)
                    {
                        if (input.Length < 1)
                        {
                            PlayerChatManager.Current.ExitChatMode();
                        }
                        else
                        {
                            PlayerChatManager.Current.m_currentValue = input;
                            PlayerChatManager.Current.PostMessage();
                            Log.Debug(input);
                        }
                    }
                }
            }
        }