private IEnumerator WhileTouchingTouchpadAxis0(uint deviceIndex, Hand hand, short coroutineId) { var vr = OpenVR.System; var state = new VRControllerState_t(); var size = (uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(VRControllerState_t)); bool started = false; Vector2 anchorPos = Vector2.zero; while (vr.GetControllerState(deviceIndex, ref state, size)) { var pos = ControllerAxisToVector2(state.rAxis0); if (started) { var deltaPos = pos - anchorPos; float magnitude = 0; Direction dir = GetLargestVectorDirection(deltaPos, ref magnitude); if (magnitude >= trackpadDirectionInterval) { anchorPos = pos; var btn = new DirectionActionsPress(hand, DirectionAction.D2, dir, true); DirectionActionPress.Send(btn); // Wait long enough for ED to recieve any keypresses yield return(KeyboardInterface.WaitForKeySent()); new DirectionActionsPress(hand, DirectionAction.D2, dir, false); DirectionActionUnpress.Send(btn); } } else { started = true; anchorPos = pos; } yield return(null); if (trackpadTouchingCoroutineId[hand] != coroutineId) { yield break; } } Debug.LogWarningFormat("Failed to get controller state for device {0}", deviceIndex); }
public WaitForSecondsRealtime WaitForKeySent() { return(KeyboardInterface.WaitForKeySent()); }