Ejemplo n.º 1
0
        private void Init()
        {
            if (_init)
            {
                return;
            }

            lastPlayer = 0;
            _users     = new InputUser[4];
            _gamepads  = new Gamepad[4];

            Debug.Log("On input singleton enabled");

            InputUser.listenForUnpairedDeviceActivity = 4;

            InputUser.onChange             += OnControlsChanged;
            InputUser.onUnpairedDeviceUsed += InputUser_onUnpairedDeviceUsed;

            for (var i = 0; i < _users.Length; i++)
            {
                _users[i] = InputUser.CreateUserWithoutPairedDevices();
            }

            _init = true;
        }
Ejemplo n.º 2
0
    public void Users_CanCreateUserWithoutPairingDevices()
    {
        var user = InputUser.CreateUserWithoutPairedDevices();

        Assert.That(user.valid, Is.True);
        Assert.That(InputUser.all, Is.EquivalentTo(new[] { user }));
        Assert.That(user.pairedDevices, Is.Empty);

        user.UnpairDevicesAndRemoveUser();

        Assert.That(user.valid, Is.False);
        Assert.That(InputUser.all, Is.Empty);
    }
Ejemplo n.º 3
0
        public static RemoteInput Create()
        {
            InputUser user = InputUser.CreateUserWithoutPairedDevices();

            user = InputUser.PerformPairingWithDevice(InputSystem.AddDevice <Mouse>(), user);
            user = InputUser.PerformPairingWithDevice(InputSystem.AddDevice <Keyboard>(), user);
            user = InputUser.PerformPairingWithDevice(InputSystem.AddDevice <Gamepad>(), user);
            user = InputUser.PerformPairingWithDevice(InputSystem.AddDevice <Touchscreen>(), user);
            RemoteInput remoteInput = new RemoteInput(ref user);

            s_mapRemoteInputAndInputUserId.Add(remoteInput, user.id);
            s_listRemoteInput.Add(remoteInput);

            return(remoteInput);
        }
    void Start()
    {
        _users    = new InputUser[playerCount];
        _gamepads = new Gamepad[playerCount];

        InputUser.listenForUnpairedDeviceActivity = playerCount;

        InputUser.onChange             += OnControlsChanged;
        InputUser.onUnpairedDeviceUsed += InputUser_onUnpairedDeviceUsed;

        for (var i = 0; i < _users.Length; i++)
        {
            _users[i] = InputUser.CreateUserWithoutPairedDevices();
        }
    }
Ejemplo n.º 5
0
    private void Start()
    {
        Debug.Log("Starting input management");
        players     = new InputUser[4];
        controllers = new Controllers[4];


        InputUser.listenForUnpairedDeviceActivity = 4;

        InputUser.onChange             += OnControlsChanged;
        InputUser.onUnpairedDeviceUsed += ListenForUnpairedDevices;

        for (var i = 0; i < players.Length; i++)
        {
            players[i] = InputUser.CreateUserWithoutPairedDevices();
        }
    }
Ejemplo n.º 6
0
 private void Start()
 {
     InputUser.CreateUserWithoutPairedDevices();
     if (MenuManager)
     {
         MenuManager.gameObject.SetActive(false);
     }
     m_IS_PlayerCharacterController = GetComponent <IS_PlayerCharacterController>();
     DebugUtility.HandleErrorIfNullGetComponent <IS_PlayerCharacterController, IS_PlayerInputHandler>(m_IS_PlayerCharacterController, this, gameObject);
     m_GameFlowManager = FindObjectOfType <GameFlowManager>();
     DebugUtility.HandleErrorIfNullFindObject <GameFlowManager, IS_PlayerInputHandler>(m_GameFlowManager, this);
     if (currentKeyboard != null)
     {
         Cursor.lockState = CursorLockMode.Locked;
         Cursor.visible   = false;
     }
     ToggleGameplayInput(true);
 }
Ejemplo n.º 7
0
    // Start is called before the first frame update
    IEnumerator Start()
    {
        yield return(null);

        foreach (PlayerInput playerInput in PlayerInput.all)
        {
            if (playerInput.user.valid == false)
            {
                InputUser user = InputUser.CreateUserWithoutPairedDevices();
            }
        }

        Assign();

        if (gamepadassigned < players.Length)
        {
            InputSystem.onDeviceChange += DeviceChangedHandler;
        }
    }
Ejemplo n.º 8
0
 public UserDevice(int deviceIndex, InputDevice device, string schemeName)
 {
     if (device is Keyboard)
     {
         deviceType = DeviceType.Keyboard;
     }
     else if (device is Gamepad)
     {
         deviceType = DeviceType.Gamepad;
     }
     else
     {
         deviceType = DeviceType.Unknown;
     }
     this.deviceIndex   = deviceIndex;
     this.user          = InputUser.CreateUserWithoutPairedDevices();
     this.gameplayInput = new CharacterInput();
     //user.AssociateActionsWithUser(gameplayInput);
     this.uiInput = new UIInput();
     //user.AssociateActionsWithUser(uiInput);
     SetDevice(device, schemeName);
 }
Ejemplo n.º 9
0
 public InputState(IInputActionCollection actions, InputControlScheme controlScheme)
 {
     User = InputUser.CreateUserWithoutPairedDevices();
     User.AssociateActionsWithUser(actions);
     SwitchControlScheme(controlScheme);
 }
Ejemplo n.º 10
0
    //  private InputActionTrace _testTrace;

    private void Start()
    {
//        foreach (var device in playerInput.devices)
//        {
//            Debug.LogFormat("device: {0},{1}", device.id, device.name);
//            foreach (var control in device.allControls)
//            {
//                Debug.LogFormat("control: {0}, {1}, {2}", control.name, control.valueType, control.layout);
//            }
//        }

        //  _gamepad = InputSystem.GetDevice<Gamepad>();

//        playerInput.deviceLostEvent.AddListener(OnDeviceLost);
//        playerInput.deviceRegainedEvent.AddListener(OnDeviceRegained);
//        _inputDevice = playerInput.devices[0];

        //  InputUser.listenForUnpairedDeviceActivity = 4;
        //  InputUser.onUnpairedDeviceUsed += OnInputUserOnOnUnpairedDeviceUsed;
        return;

        InputUser.onChange += InputUserOnOnChange;

        const int players = 2;

        _users       = new InputUser[players];
        _userActions = new InputActionAsset[players];

        var keyboard = InputDevice.all.FirstOrDefault(d => d is Keyboard);

        if (keyboard != null)
        {
            Debug.Log("found keyboard!!");
        }

        for (var i = 0; i < _users.Length; i++)
        {
            _users[i]       = InputUser.CreateUserWithoutPairedDevices();
            _userActions[i] = ScriptableObject.Instantiate(_inputActions);
            _users[i].AssociateActionsWithUser(_userActions[i]);

            var actionName = string.Format("Player{0}/Movement", i);

            var action = _userActions[i].FindAction(actionName);
            action.Enable();

            var userIndex = i;

            action.performed += delegate(InputAction.CallbackContext context)
            {
                var direction = context.ReadValue <Vector2>();
                Debug.LogFormat("User: {0}.movement!, {1}", _users[userIndex].id, direction);
            };

            if (keyboard != null)
            {
                InputUser.PerformPairingWithDevice(keyboard, _users[i]);
            }
        }

        //   _testTrace.SubscribeTo(_userActions[0].FindAction("Player0/Movement"));
    }