private unsafe void InputSystem_onEvent(UnityEngine.InputSystem.LowLevel.InputEventPtr eventPtr, InputDevice device)
    {
        if (m_State == State.Idle || m_EventReceiveType != EventReceiveType.NewInputViaCallbacks)
        {
            return;
        }

        var touchScreenDevice = device as Touchscreen;

        if (touchScreenDevice == null)
        {
            return;
        }

        if (!eventPtr.IsA <StateEvent>())
        {
            return;
        }
        var stateEvent = StateEvent.From(eventPtr);

        if (stateEvent->stateFormat != TouchState.Format)
        {
            return;
        }
        var touchState = (TouchState *)stateEvent->state;

        if (touchState->phase == UnityEngine.InputSystem.TouchPhase.Began)
        {
            HandleEventReceive((int)touchState->position.y);
        }
    }
        public static DeltaStateEvent *From(InputEventPtr ptr)
        {
            if (!ptr.valid)
            {
                throw new ArgumentNullException(nameof(ptr));
            }
            if (!ptr.IsA <DeltaStateEvent>())
            {
                throw new InvalidCastException($"Cannot cast event with type '{ptr.type}' into DeltaStateEvent");
            }

            return((DeltaStateEvent *)ptr.data);
        }
Пример #3
0
        /// <summary>
        /// Return the given <see cref="InputEventPtr"/> as a StateEvent pointer.
        /// </summary>
        /// <param name="ptr">A pointer to an input event. The pointer is checked for <c>null</c> and
        /// for whether the type of event it refers to is indeed a StateEvent.</param>
        /// <returns>Pointer <paramref name="ptr"/> converted to a StateEvent pointer.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="ptr"/> is <c>default(InputEventPtr)</c>.</exception>
        /// <exception cref="InvalidCastException"><paramref name="ptr"/> does not refer to a StateEvent.</exception>
        public static StateEvent *From(InputEventPtr ptr)
        {
            if (!ptr.valid)
            {
                throw new ArgumentNullException(nameof(ptr));
            }
            if (!ptr.IsA <StateEvent>())
            {
                throw new InvalidCastException($"Cannot cast event with type '{ptr.type}' into StateEvent");
            }

            return(FromUnchecked(ptr));
        }
Пример #4
0
        public static unsafe TextEvent *From(InputEventPtr eventPtr)
        {
            if (!eventPtr.valid)
            {
                throw new ArgumentNullException("ptr");
            }
            if (!eventPtr.IsA <TextEvent>())
            {
                throw new InvalidCastException(string.Format("Cannot cast event with type '{0}' into TextEvent",
                                                             eventPtr.type));
            }

            return((TextEvent *)eventPtr.data);
        }
Пример #5
0
        public static StateEvent *From(InputEventPtr ptr)
        {
            if (!ptr.valid)
            {
                throw new ArgumentNullException("ptr");
            }
            if (!ptr.IsA <StateEvent>())
            {
                throw new InvalidCastException(string.Format("Cannot cast event with type '{0}' into StateEvent",
                                                             ptr.type));
            }

            return((StateEvent *)ptr.data);
        }
Пример #6
0
    private unsafe void InputSystem_onEvent(UnityEngine.InputSystem.LowLevel.InputEventPtr eventPtr, InputDevice device)
    {
        var touchScreenDevice = device as Touchscreen;

        if (touchScreenDevice == null)
        {
            return;
        }

        if (!eventPtr.IsA <StateEvent>())
        {
            return;
        }
        var stateEvent = StateEvent.From(eventPtr);

        if (stateEvent->stateFormat != TouchState.Format)
        {
            return;
        }
        var touchState = (TouchState *)stateEvent->state;

        var data = GetData(TouchProcessType.ViaNewInputEventTrace);

        if (touchState->phase == UnityEngine.InputSystem.TouchPhase.Began)
        {
            data.beginPhaseTimeMS = GetTimeMS();
            data.endPhaseTimeMS   = -1;
            data.beginPhaseCount++;
        }

        if (touchState->phase == UnityEngine.InputSystem.TouchPhase.Ended)
        {
            data.endPhaseTimeMS = GetTimeMS();
            data.endPhaseCount++;
        }
    }