예제 #1
0
        public InputControl AddControl(InputTarget inputTarget, string handle)
        {
            var inputControl = new InputControl(handle, inputTarget);

            Controls[(int)inputTarget] = inputControl;
            return(inputControl);
        }
예제 #2
0
 static void OnNextBeginDown(InputTarget target, InputArgs args)
 {
     if (target.IsBeginDownAvailable())
     {
         target.BeginDown(args);
     }
 }
예제 #3
0
        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);
                    }
                }
            }
        }
예제 #4
0
 public void FocusOn(InputTarget t)
 {
     if (t is GreatGrand)
     {
         UI.SetGrandUI(t as GreatGrand);
     }
 }
예제 #5
0
 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);
             }
         }
     }
 }
예제 #6
0
 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);
     }
 }
예제 #8
0
        public InputControl(string handle, InputTarget target)
        {
            Handle = handle;
            Target = target;

            IsButton = (target >= InputTarget.Action1 && target <= InputTarget.Action4) ||
                       (target >= InputTarget.Button0 && target <= InputTarget.Button19);
        }
예제 #9
0
    private void HoldCompleteEvent()
    {
        if (focus != null)
        {
            InputTarget target = focus.GetComponent <InputTarget>();

            if (target != null)
            {
                target.SendMessage_HoldComplete();
            }
        }
    }
예제 #10
0
 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);
         }
     }
 }
예제 #11
0
    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");
    }
예제 #12
0
    /// <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);
            }
        }
    }
예제 #13
0
    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;
        }
    }
예제 #14
0
    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);
            }
        }
    }
예제 #15
0
 public InputArgsObserver(InputTarget target, Action <InputTarget, InputArgs> onNext)
 {
     _target = target;
     _onNext = onNext;
 }
예제 #16
0
    private static IDisposable?ConnectBeginDown(InputSource source, InputTarget target)
    {
        var observer = new InputArgsObserver(target, OnNextBeginDown);

        return(source.BeginDown?.Subscribe(observer));
예제 #17
0
 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]));
 }
예제 #19
0
파일: DragData.cs 프로젝트: sunfom/DeXign
        internal void Stop()
        {
            stopTime = DateTime.Now;

            InputTarget.ReleaseMouseCapture();
        }
예제 #20
0
 public InputControl this[InputTarget target] {
     get { return(GetControl(target)); }
 }
예제 #21
0
        public InputControl GetControl(InputTarget inputTarget)
        {
            InputControl control = Controls[(int)inputTarget];

            return(control ?? InputControl.Null);
        }
예제 #22
0
    // 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;
        }
    }
예제 #23
0
        // 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));
        }
예제 #24
0
 public void UpdateWithState(InputTarget inputTarget, bool state, ulong updateTick)
 {
     GetControl(inputTarget).UpdateWithState(state, updateTick);
 }
예제 #25
0
 public void UpdateWithValue(InputTarget inputTarget, float value, ulong updateTick)
 {
     GetControl(inputTarget).UpdateWithValue(value, updateTick);
 }