Esempio n. 1
0
        public override bool TryMatch(Dom.Node node)
        {
            if (node == null)
            {
                return(false);
            }

            // The element must be one of the active pointed ones or one of their parents:
            for (int i = 0; i < InputPointer.PointerCount; i++)
            {
                InputPointer pointer = InputPointer.AllRaw[i];

                if (pointer.ActiveOver == node)
                {
                    // Great, got it!
                    return(true);
                }
                else if (pointer.ActiveOver != null)
                {
                    // Is our node one of its parents?
                    if (node.isParentOf(pointer.ActiveOver))
                    {
                        return(true);
                    }
                }
            }

            // Nope!
            return(false);
        }
Esempio n. 2
0
        public static T DeserializePointerFB <T>(IntPtr data, int length)
        {
            var input  = new InputPointer(data, length);
            var reader = new FastBinaryReader <InputPointer>(input);

            return(Deserialize <T> .From(reader));
        }
Esempio n. 3
0
        /// <summary>Collects options and displays the menu at the pointers position.
        /// Run this on the 'root' option list only (don't call it on submenu's).</summary>
        public void display(InputPointer ip, bool instant)
        {
            // First, collect the options:
            ContextEvent ce = collectOptions(ip);

            if (instant)
            {
                // Won't actually display - just immediately run op 0:
                run();
                return;
            }

            // Even if it collected nothing, attempt to display it.
            // The event contains the position for us.

            // Get the widget manager:
            Widgets.Manager widgets = (ce.contextDocument as HtmlDocument).widgets;

            // Open a widget (closing an existing one):
            widget = widgets.get(ce.template, null);

            if (widget != null)
            {
                widget.close();
            }

            widget = widgets.open(ce.template, null, buildGlobals(ce));
        }
    Vector3 GetPointerRaycastPosition(InputPointer pointer)
    {
        Vector3 raycastPosition = pointer.Position;

        raycastPosition.z = raycastPosition.z - Camera.main.transform.position.z;
        raycastPosition   = Camera.main.ScreenToWorldPoint(raycastPosition);
        return(raycastPosition);
    }
Esempio n. 5
0
        protected override void OnUpdate(GameTime gameTime)
        {
            var pointerState = InputPointer.GetState();

            var metrics = graphicsMetricsProvider();

            mainLabel.Text = $"Draws: {metrics.DrawCount}\nTextures: {metrics.TextureCount}\nPrimitives: {metrics.PrimitiveCount}";
        }
Esempio n. 6
0
        public static To DeserializePointerSP <From, To>(IntPtr data, int length)
        {
            var input        = new InputPointer(data, length);
            var reader       = new SimpleBinaryReader <InputPointer>(input);
            var deserializer = new Deserializer <SimpleBinaryReader <InputPointer> >(typeof(To), Schema <From> .RuntimeSchema);

            return(deserializer.Deserialize <To>(reader));
        }
    void HandlePointerPressed(InputPointer[] pointers)
    {
        InputPointer primaryPointer = GetPrimaryPointer(pointers);

        if (primaryPointer != null)
        {
            GameObject objectPressedOn;
        }
    }
Esempio n. 8
0
        protected override void OnUpdate(GameTime gameTime)
        {
            var pointerState = InputPointer.GetState();

            var metrics = graphicsMetricsProvider();

            mainLabel.Text = "Input position: " + GuiManager.ScreenToWorld(pointerState.Position.ToVector2()) + "\nStats: " +
                             $"Draws: {metrics.DrawCount}\nTextures: {metrics.TextureCount}\nPrimitives: {metrics.PrimitiveCount}";
        }
Esempio n. 9
0
        public static unsafe TType[] ByteArrayToArray <TType>(byte[] InputArray)
        {
            var OutputArray = new TType[InputArray.Length / Marshal.SizeOf(typeof(TType))];

            GetArrayPointer(InputArray, (InputPointer) =>
            {
                GetArrayPointer(OutputArray, (OutputPointer) =>
                {
                    Memcpy((byte *)OutputPointer.ToPointer(), (byte *)InputPointer.ToPointer(), InputArray.Length);
                });
            });
            return(OutputArray);
        }
    public bool GetObjectFromPointer(InputPointer pointer, out GameObject hitObject)
    {
        RaycastHit hit;

        if (Physics.Raycast(GetPointerRaycastPosition(pointer), Vector3.forward, out hit))
        {
            hitObject = hit.collider.gameObject;
            return(true);
        }
        else
        {
            hitObject = null;
            return(false);
        }
    }
    public InputPointer[] GetPointers()
    {
        bool mouseIsDown = Input.GetMouseButton(0);

        InputPointer[] pointers = new InputPointer[Input.touchCount + (mouseIsDown ? 1 : 0)];
        int            index    = 0;

        foreach (Touch touch in Input.touches)
        {
            pointers[index++] = new InputPointer(touch.position, touch.fingerId, !mouseIsDown && touch.fingerId == 0);
        }
        if (mouseIsDown)
        {
            pointers[index] = GetMousePointer();
        }
        return(pointers);
    }
Esempio n. 12
0
        /// <summary>Collects options at the given pointer location.</summary>
        public ContextEvent collectOptions(InputPointer ip)
        {
            // Create an oncontextmenu event:
            ContextEvent ce = createEvent();

            ce.trigger = ip;
            ce.clientX = ip.DocumentX;
            ce.clientY = ip.DocumentY;

            // Collect from a 2D element:
            trigger = ip.ActiveOverTarget;

            if (trigger != null)
            {
                // Collect:
                trigger.dispatchEvent(ce);
                return(ce);
            }

            return(ce);
        }
Esempio n. 13
0
        public override bool TryMatch(Dom.Node node)
        {
            if (node == null)
            {
                return(false);
            }

            // First get a pointer over this element:
            InputPointer pointer = null;

            for (int i = 0; i < InputPointer.PointerCount; i++)
            {
                pointer = InputPointer.AllRaw[i];

                if (pointer.ActiveOver == node)
                {
                    // Great, got it!
                    break;
                }
                else if (pointer.ActiveOver != null)
                {
                    // Is our node one of its parents?
                    if (node.isParentOf(pointer.ActiveOver))
                    {
                        break;
                    }
                }

                pointer = null;
            }


            if (pointer != null)
            {
                // True if the pointer is 'down':
                return(pointer.IsDown);
            }

            return(false);
        }
Esempio n. 14
0
        /// <summary>Collects options at the given pointer location.</summary>
        public ContextEvent collectOptions(InputPointer ip)
        {
            // Create an oncontextmenu event:
            ContextEvent ce = createEvent();

            ce.trigger = ip;
            ce.clientX = ip.DocumentX;
            ce.clientY = ip.DocumentY;

            // Collect from a 2D element:
            triggerElement = ip.ActiveOver;
            trigger        = triggerElement;

            if (trigger != null)
            {
                // Collect:
                trigger.dispatchEvent(ce);

                triggerGameObject = null;
                return(ce);
            }

            // Collect from a 3D object:
            if (ip.LatestHitSuccess)
            {
                // Try to resolve the hit gameobject to an IEventTarget:
                triggerGameObject = ip.LatestHit.transform.gameObject;
                trigger           = ip.ResolveTarget();

                if (trigger != null)
                {
                    // Great - dispatch to it:
                    trigger.dispatchEvent(ce);
                }
            }

            return(ce);
        }
 void HandleInput()
 {
     InputPointer[] pointers = GetPointers();
     if (checkForZoom())
     {
         isZooming = true;
         handleZoom(pointers);
     }
     else if (isZooming)
     {
         handleZoomEnd();
     }
     if (HasPointersDown())
     {
         HandlePointersDown(pointers);
     }
     else
     {
         previousSwipingPointer = null;
         panSpeed = 0;
     }
     pointersInPreviousFrame = pointers;
 }
 void handleSwipe(InputPointer pointer)
 {
     if (!isDraggingObject)
     {
         if (previousSwipingPointer != null && pointer.ID == previousSwipingPointer.ID)
         {
             Vector3 deltaPosition = pointer.Position - previousSwipingPointer.Position;
             if (Math.Abs(Math.Sign(deltaPosition.x) - Math.Sign(swipeDirection.x)) == 0 &&
                 Math.Abs(Math.Sign(deltaPosition.y) - Math.Sign(swipeDirection.y)) == 0)
             {
                 panSpeed += PanAcceleration;
             }
             else
             {
                 panSpeed = 0;
             }
             swipeDirection = deltaPosition;
             panSpeed       = Mathf.Clamp(panSpeed, 0, MaxPanSpeed);
             deltaPosition *= -panSpeed;
             // TODO: Implement
         }
         previousSwipingPointer = pointer;
     }
 }
    bool isSwiping(InputPointer[] pointers, float swipeTolerance, out InputPointer swipingPointer)
    {
        if (pointersInPreviousFrame == null || pointersInPreviousFrame.Length == 0)
        {
            swipingPointer = null;
            return(false);
        }

        for (int i = 0; i < pointers.Length; i++)
        {
            if (pointersInPreviousFrame.Length <= i)
            {
                break;
            }
            if (pointers[i].ID == pointersInPreviousFrame[i].ID &&
                Vector3.Distance(pointers[i].Position, pointersInPreviousFrame[i].Position) > swipeTolerance)
            {
                swipingPointer = pointers[i];
                return(true);
            }
        }
        swipingPointer = null;
        return(false);
    }
Esempio n. 18
0
 void HandleOnInputPointer(int inputIndex, InputPointerParameters pointerParams, InputPointer sender)
 {
 }
Esempio n. 19
0
    void HandleOnInputPointerUp(int inputIndex, InputPointerParameters pointerParams, InputPointer sender)
    {
        IPointerUpHandler[] enterHandlers = pointerParams.target.GetComponents <IPointerUpHandler>();

        foreach (var handler in enterHandlers)
        {
            PointerEventData data = new PointerEventData(eventSystem);
            handler.OnPointerUp(data);
        }
    }
Esempio n. 20
0
 void HandleOnInputPointerUp(int inputIndex, InputPointerParameters pointerParams, InputPointer sender)
 {
     pointerParams.target.SendMessage("OnPress", false, SendMessageOptions.DontRequireReceiver);
 }