コード例 #1
0
        /// <summary>
        /// Check if the given keyCode is pressed in this frame. Must be called in Update() functions.
        /// </summary>
        public bool GetKeyDown(HoloKitKeyCode keyCode, out HoloKitInputType inputType)
        {
            inputType = HoloKitInputType.Unknown;

            updateChars(keyCode);
            for (int i = 0; i < chars.Count; i++)
            {
                if (RemoteKeyboardReceiver.Instance.GetKeyDown(chars[i]))
                {
                    inputType = HoloKitInputType.RemoteKeyboard;
                    return(true);
                }
                else if (RemoteControllerReceiver.Instance.GetKeyDown(chars[i]))
                {
                    inputType = HoloKitInputType.RemotePhone;
                    return(true);
                }
            }

            updateUnityKeyCodes(keyCode);
            for (int i = 0; i < keyCodes.Count; i++)
            {
                if (Input.GetKeyDown(keyCodes[i]))
                {
                    inputType = HoloKitInputType.UnityInput;
                    return(true);
                }
            }

            return(false);
        }
コード例 #2
0
    private IEnumerator keyDownCoroutine(HoloKitKeyCode KeyCode)
    {
        Color color;

        // Note that only keys that registered in "Keys to listen on gaze" can trigger KeyDownOnGaze event
        switch (KeyCode)
        {
        case HoloKitKeyCode.Z:
            color = Color.blue;
            break;

        case HoloKitKeyCode.X:
            color = Color.yellow;
            break;

        case HoloKitKeyCode.U:
            color = Color.cyan;
            break;

        default:
            color = Color.black;
            break;
        }

        GetComponent <Renderer>().material.color = color;
        yield return(new WaitForSeconds(0.2f));

        GetComponent <Renderer>().material.color = Color.red;
    }
コード例 #3
0
 void Update()
 {
     if (currentTarget != null &&
         currentTarget.KeysToListenOnGaze != null &&
         currentTarget.KeyDownOnGaze != null)
     {
         for (int i = 0; i < currentTarget.KeysToListenOnGaze.Length; i++)
         {
             HoloKitKeyCode keyCode = currentTarget.KeysToListenOnGaze[i];
             if (HoloKitInputManager.Instance.GetKeyDown(keyCode))
             {
                 currentTarget.KeyDownOnGaze.Invoke(keyCode);
             }
         }
     }
 }
コード例 #4
0
        private void updateChars(HoloKitKeyCode keyCode)
        {
            chars.Clear();
            if (keyCode == HoloKitKeyCode.None)
            {
                return;
            }

            if ((int)keyCode <= (int)(HoloKitKeyCode.Num9))
            {
                chars.Add((char)((int)keyCode - (int)(HoloKitKeyCode.Num9) + '0'));
            }
            else
            {
                chars.Add((char)((int)keyCode - (int)(HoloKitKeyCode.A) + 'A'));
                chars.Add((char)((int)keyCode - (int)(HoloKitKeyCode.A) + 'a'));
            }
        }
コード例 #5
0
        private void updateUnityKeyCodes(HoloKitKeyCode keyCode)
        {
            keyCodes.Clear();
            if (keyCode == HoloKitKeyCode.None)
            {
                return;
            }

            if ((int)keyCode <= (int)(HoloKitKeyCode.Num9))
            {
                int num = (int)keyCode - (int)(HoloKitKeyCode.Num9);
                keyCodes.Add((KeyCode)((int)KeyCode.Alpha0 + num));
                keyCodes.Add((KeyCode)((int)KeyCode.Keypad0 + num));
            }
            else
            {
                keyCodes.Add((KeyCode)(int)(keyCode) - (int)(HoloKitKeyCode.A) + (int)KeyCode.A);
            }
        }
コード例 #6
0
 public void KeyDownOnGaze(HoloKitKeyCode KeyCode)
 {
     Debug.Log(KeyCode.ToString() + " KeyDown while gazing on " + gameObject.name);
 }
コード例 #7
0
        public bool GetKeyDown(HoloKitKeyCode keyCode)
        {
            HoloKitInputType inputType;

            return(GetKeyDown(keyCode, out inputType));
        }
コード例 #8
0
    public void KeyDownOnGaze(HoloKitKeyCode KeyCode)
    {
        Debug.Log(KeyCode.ToString() + " KeyDown while gazing on " + gameObject.name);
//        StartCoroutine(keyDownCoroutine(KeyCode));
    }