示例#1
0
        /// <summary>
        /// Called from a PlayerInputListener when spawned to connect to the next available ControllerID
        /// </summary>
        /// <param name="playerInput"> New player input listener </param>
        /// <returns> Assigned ControllerID </returns>
        public EControllerID OnNewDeviceJoined(PlayerInputListener playerInputListener)
        {
            IS_NOT_NULL(playerInputListener);
            // Assign a ControllerID
            EControllerID controllerID = GetNextFreeDeviceControllerID();

            if (controllerID != EControllerID.NONE)
            {
                // Connect controller on Input Manager
                if (InputManager.Instance.ConnectController(controllerID) == true)
                {
                    connectedDeviceControllers.Add(controllerID, playerInputListener);

                    // Bind Input events
                    playerInputListener.ButtonPressed  += On_PlayerInputListener_ButtonPressed;
                    playerInputListener.ButtonReleased += On_PlayerInputListener_ButtonReleased;
                }
                else
                {
                    return(EControllerID.NONE);
                }
            }
            else
            {
                LogConsoleWarning("No free Controller ID found for new connected device : " + playerInputListener.DeviceName);
            }

            return(controllerID);
        }
示例#2
0
        protected override void FixedUpdate()
        {
            base.FixedUpdate();

            foreach (EControllerID controllerID in connectedDeviceControllers.Keys)
            {
                PlayerInputListener playerInputListener = connectedDeviceControllers[controllerID];
                On_PlayerInputListener_AxisUpdated(controllerID, EInputAxis.MOVEMENT, playerInputListener.MoveAxis);
                On_PlayerInputListener_AxisUpdated(controllerID, EInputAxis.ROTATION, playerInputListener.RotateAxis);
                On_PlayerInputListener_AxisUpdated(controllerID, EInputAxis.TRIGGER_AXIS_L, playerInputListener.RotateAxis);
                On_PlayerInputListener_AxisUpdated(controllerID, EInputAxis.TRIGGER_AXIS_R, playerInputListener.RotateAxis);
            }
        }
示例#3
0
        // TODO
        public void OnDeviceHasLeft(EControllerID controllerID, PlayerInputListener playerInputListener)
        {
            //IS_VALID(playerInputListener);

            //if ((connectedControllers.ContainsKey(controllerID)
            //    && (connectedControllers[controllerID] == playerInputListener))
            //{

            //}
            //else
            //{
            //    LogConsoleWarning("An invalid device has left : " + playerInputListener.DeviceName);
            //}
        }