/// <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); }
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; }
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); } } } }
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')); } }
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); } }
public void KeyDownOnGaze(HoloKitKeyCode KeyCode) { Debug.Log(KeyCode.ToString() + " KeyDown while gazing on " + gameObject.name); }
public bool GetKeyDown(HoloKitKeyCode keyCode) { HoloKitInputType inputType; return(GetKeyDown(keyCode, out inputType)); }
public void KeyDownOnGaze(HoloKitKeyCode KeyCode) { Debug.Log(KeyCode.ToString() + " KeyDown while gazing on " + gameObject.name); // StartCoroutine(keyDownCoroutine(KeyCode)); }