public InputControl AddControl(InputTarget inputTarget, string handle) { var inputControl = new InputControl(handle, inputTarget); Controls[(int)inputTarget] = inputControl; return(inputControl); }
static void OnNextBeginDown(InputTarget target, InputArgs args) { if (target.IsBeginDownAvailable()) { target.BeginDown(args); } }
private void HandlePointerPressed(PointerPressedEventArgs e) { var properties = e.GetCurrentPoint(RelativeTo).Properties; if (properties.IsLeftButtonPressed) { if (InputTarget != null) { var point = AdjustGetPosition(e.GetPosition(RelativeTo)); var args = new InputArgs(point.X, point.Y, GetModifier(e.KeyModifiers)); if (InputTarget.IsLeftDownAvailable()) { InputTarget.LeftDown(args); } } } else if (properties.IsRightButtonPressed) { if (InputTarget != null) { var point = AdjustGetPosition(e.GetPosition(RelativeTo)); var args = new InputArgs(point.X, point.Y, GetModifier(e.KeyModifiers)); if (InputTarget.IsRightDownAvailable()) { InputTarget.RightDown(args); } } } }
public void FocusOn(InputTarget t) { if (t is GreatGrand) { UI.SetGrandUI(t as GreatGrand); } }
private void HandlePointerReleased(PointerReleasedEventArgs e) { if (e.MouseButton == MouseButton.Left) { if (InputTarget != null) { var point = AdjustGetPosition(e.GetPosition(RelativeTo)); var args = new InputArgs(point.X, point.Y, GetModifier(e.InputModifiers)); if (InputTarget.IsLeftUpAvailable()) { InputTarget.LeftUp(args); } } } else if (e.MouseButton == MouseButton.Right) { if (InputTarget != null) { var point = AdjustGetPosition(e.GetPosition(RelativeTo)); var args = new InputArgs(point.X, point.Y, GetModifier(e.InputModifiers)); if (InputTarget.IsRightUpAvailable()) { InputTarget.RightUp(args); } } } }
public void FocusOn(InputTarget t) { if (t is GreatGrand) { GameManager.UI.SetGrandUI(t as GreatGrand); } }
void SendMessage <T>(InputTarget targetControl, GameObject target, ExecuteEvents.EventFunction <T> handler) where T : IEventSystemHandler { if (HInput.Devices.Any(device => device[targetControl].WasPressed)) { ExecuteEvents.Execute(target, GetBaseEventData(), handler); } }
public InputControl(string handle, InputTarget target) { Handle = handle; Target = target; IsButton = (target >= InputTarget.Action1 && target <= InputTarget.Action4) || (target >= InputTarget.Button0 && target <= InputTarget.Button19); }
private void HoldCompleteEvent() { if (focus != null) { InputTarget target = focus.GetComponent <InputTarget>(); if (target != null) { target.SendMessage_HoldComplete(); } } }
private void HandlePointerMoved(PointerEventArgs e) { if (InputTarget != null) { var point = AdjustGetPosition(e.GetPosition(RelativeTo)); var args = new InputArgs(point.X, point.Y, GetModifier(e.InputModifiers)); if (InputTarget.IsMoveAvailable()) { InputTarget.Move(args); } } }
private void TapEvent() { cursorInfo.CursorMat.SetColor("_Color", cursorInfo.SelectColor); if (focus != null) { InputTarget target = focus.GetComponent <InputTarget>(); if (target != null) { target.SendMessage_Tap(); } } StartCoroutine("AfterTap"); }
/// <summary> /// User click+hold+move /// </summary> /// <param name="relativePosition"> relative offset position of hand in normalized units (within a 1m cube). Where you click start is the origin of the 1m cube boundaries.</param> private void NavigationUpdatedEvent(Vector3 relativePosition) { #if UNITY_EDITOR relativePosition = relativePosition / 200f; #endif if (focusCache) { InputTarget target = focusCache.GetComponent <InputTarget>(); if (target != null) { target.SendMessage_NavigationUpdated(relativePosition); } } }
private void NavigationCompletedEvent(Vector3 relativePosition) { cursorInfo.CursorMat.SetColor("_Color", cursorInfo.IdleColor); if (focusCache) { InputTarget target = focusCache.GetComponent <InputTarget>(); if (target != null) { target.SendMessage_NavigationCompleted(relativePosition); } focusCache = null; } }
private void NavigationStartedEvent(Vector3 relativePosition) { if (focus != null) { focusCache = focus; #if UNITY_EDITOR VHandStartPos = Input.mousePosition; relativePosition = VHandStartPos; #endif cursorInfo.CursorMat.SetColor("_Color", cursorInfo.HoldColor); InputTarget target = focus.GetComponent <InputTarget>(); if (target != null) { target.SendMessage_NavigationStarted(relativePosition); } } }
public InputArgsObserver(InputTarget target, Action <InputTarget, InputArgs> onNext) { _target = target; _onNext = onNext; }
private static IDisposable?ConnectBeginDown(InputSource source, InputTarget target) { var observer = new InputArgsObserver(target, OnNextBeginDown); return(source.BeginDown?.Subscribe(observer));
public InputControl GetControl(InputTarget inputTarget) { return(Controls[(int)inputTarget] ?? InputControl.Null); }
public static IEnumerable <InputControl> GetControl(this IEnumerable <InputDevice> devices, InputTarget target) { return(devices.Select(d => d[target])); }
internal void Stop() { stopTime = DateTime.Now; InputTarget.ReleaseMouseCapture(); }
public InputControl this[InputTarget target] { get { return(GetControl(target)); } }
public InputControl GetControl(InputTarget inputTarget) { InputControl control = Controls[(int)inputTarget]; return(control ?? InputControl.Null); }
// Update is called once per frame void Update() { #if UNITY_EDITOR #region virtual hand if (Input.GetMouseButtonDown(0)) { startTime = Time.time; VHandClickStarted = true; } if (Input.GetMouseButtonUp(0)) { VHandClickStarted = false; if (!VHandHolding) { TapEvent(); } else { //HoldCompleteEvent(); NavigationCompletedEvent(Input.mousePosition); VHandHolding = false; } } if (VHandClickStarted) { if (Time.time - startTime >= VHandHoldTime) { VHandHolding = true; VHandClickStarted = false; NavigationStartedEvent(Input.mousePosition); } } if (VHandHolding) { NavigationUpdatedEvent(Input.mousePosition - VHandStartPos); } #endregion #endif headPosition = Camera.main.transform.position; gazeDirection = Camera.main.transform.forward; if (Physics.Raycast(headPosition, gazeDirection, out hitInfo, 30)) { HitInfo = hitInfo; focus = HitInfo.collider.gameObject; } else { focus = null; } if (oldFocus != focus) { //Is the new focus on an object? if (focus != null) { InputTarget target = focus.GetComponent <InputTarget>(); //Is this object targetable? if (target != null) { target.SendMessage_GazeEnter(); } } //Was the old focus on an object? if (oldFocus != null) { InputTarget target = oldFocus.GetComponent <InputTarget>(); //targetable? if (target != null) { target.SendMessage_GazeExit(); } } oldFocus = focus; } }
// Warning: this is not efficient. Don't use it unless you have to, m'kay? public InputControl GetControlByName(string inputControlName) { InputTarget inputType = GetInputControlTypeByName(inputControlName); return(GetControl(inputType)); }
public void UpdateWithState(InputTarget inputTarget, bool state, ulong updateTick) { GetControl(inputTarget).UpdateWithState(state, updateTick); }
public void UpdateWithValue(InputTarget inputTarget, float value, ulong updateTick) { GetControl(inputTarget).UpdateWithValue(value, updateTick); }