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);
        }
    }
예제 #2
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++;
        }
    }
    private void InputUser_onUnpairedDeviceUsed(InputControl control, UnityEngine.InputSystem.LowLevel.InputEventPtr arg2)
    {
        if (control.device is Gamepad)
        {
            for (var i = 0; i < _users.Length; i++)
            {
                // find a user without a paired device
                if (_users[i].pairedDevices.Count == 0)
                {
                    // pair the new Gamepad device to that user
                    _users[i] = InputUser.PerformPairingWithDevice(control.device, _users[i]);
                    Debug.Log("Paired a user");
                    registeredPlayers++;

                    if (registeredPlayers == 2)
                    {
                        SetupPlayers();
                    }

                    return;
                }
            }
        }
    }
예제 #4
0
 private void InputUser_onUnpairedDeviceUsed(UnityEngine.InputSystem.InputControl control, UnityEngine.InputSystem.LowLevel.InputEventPtr arg2)
 {
     Debug.Log($"using device {control.device.name}");
 }
예제 #5
0
 public static NativeArray <byte> FromDefaultStateFor(InputDevice device, out InputEventPtr eventPtr, Allocator allocator = Allocator.Temp)
 {
     return(From(device, out eventPtr, allocator, useDefaultState: true));
 }
예제 #6
0
 internal static StateEvent *FromUnchecked(InputEventPtr ptr)
 {
     return((StateEvent *)ptr.data);
 }
예제 #7
0
 /// <summary>
 /// Retrieve the state stored in the event.
 /// </summary>
 /// <typeparam name="TState">Type of state expected to be stored in the event. <see cref="IInputStateTypeInfo.format"/>
 /// must match <see cref="stateFormat"/>.</typeparam>
 /// <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>Copy of the state stored in the event.</returns>
 /// <remarks>
 /// The event may contain less or more data than what is found in the struct. Only the data found in the event
 /// is copied. The remainder of the struct is left at default values.
 /// </remarks>
 /// <exception cref="InvalidOperationException"><see cref="stateFormat"/> does not match <see cref="IInputStateTypeInfo.format"/>
 /// of <typeparamref name="TState"/>.</exception>
 /// <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>
 /// <seealso cref="GetState{T}()"/>
 public static TState GetState <TState>(InputEventPtr ptr)
     where TState : struct, IInputStateTypeInfo
 {
     return(From(ptr)->GetState <TState>());
 }