Example #1
0
        private void Poll(InputPlayer player, InputEventPollingType pollingType)
        {
            InputReceiver receiver = _receivers[player];

            if (receiver == null)
            {
                return;
            }

            Rewired.Player rePlayer = ReInput.players.GetPlayer((int)receiver.InputPlayer);
            foreach (var action in ReInput.mapping.Actions)
            {
                if (rePlayer.GetButtonDown(action.id))
                {
                    _receivers[player]?.ReceiveButtonEvent(new InputActionEvent(action.id, pollingType, InputEventType.Down));
                }
                if (rePlayer.GetButtonUp(action.id))
                {
                    _receivers[player]?.ReceiveButtonEvent(new InputActionEvent(action.id, pollingType, InputEventType.Up));
                }
                if (rePlayer.GetButton(action.id))
                {
                    _receivers[player]?.ReceiveButtonEvent(new InputActionEvent(action.id, pollingType, InputEventType.Hold));
                }

                _receivers[player]?.ReceiveAxisEvent(rePlayer.GetAxis(action.id), new InputAxisEvent(action.id, pollingType));
            }
        }
Example #2
0
        public void BindAxis(int actionId, InputEventPollingType inputEventPollingType,
                             InputAxisEventDelegate handler)
        {
            InputAxisEvent inputAxisEvent = new InputAxisEvent(actionId, inputEventPollingType);

            Debug.AssertFormat(!_axisEvents.ContainsKey(inputAxisEvent), $"Axis binding for '{actionId}' with the same parameters already bound");
            _axisEvents.Add(inputAxisEvent, handler);
        }
Example #3
0
 public InputActionEvent(int actionId, InputEventPollingType inputEventPollingType, InputEventType inputEventType)
 {
     this.InputEventPollingType = inputEventPollingType;
     this.InputEventType        = inputEventType;
     this.ActionId = actionId;
 }