Exemple #1
0
 private void OnInputDeviceChange(InputUser user, InputUserChange change, InputDevice device)
 {
     if (change == InputUserChange.ControlSchemeChanged)
     {
         _uiInstance.ToggleInputIcon(playerInputVar.currentControlScheme);
     }
 }
Exemple #2
0
 private static void Notify(IInputUser user, InputUserChange change)
 {
     for (var i = 0; i < s_OnChange.length; ++i)
     {
         s_OnChange[i](user, change);
     }
 }
 private void OnChange(InputUser user, InputUserChange change, InputDevice device)
 {
     if (change == InputUserChange.DevicePaired)
     {
         UpdateDevice(device);
     }
 }
Exemple #4
0
 void onInputDeviceChange(InputUser user, InputUserChange change, InputDevice device)
 {
     // user changed devices, set new sprite for advance icon
     if (change == InputUserChange.ControlSchemeChanged)
     {
         SetIconsForCurrentControlScheme(playerInput.currentControlScheme);
     }
 }
 void onInputDeviceChange(InputUser user, InputUserChange change, InputDevice device)
 {
     if (change == InputUserChange.ControlSchemeChanged)
     {
         controlScheme = (InputControlScheme)user.controlScheme;
         Debug.Log("Scheme changed to " + controlScheme.name);
     }
 }
Exemple #6
0
 private void OnInputUserChanged(InputUser arg1, InputUserChange arg2, InputDevice arg3)
 {
     if (arg2 == InputUserChange.ControlsChanged)
     {
         CurrentInputDevice = arg1.controlScheme.Value.name == "Gamepad" ? InputDeviceType.GAMEPAD : InputDeviceType.KEYBOARD;
         OnInputDeviceChanged?.Invoke(obj: CurrentInputDevice);
     }
 }
 internal void DeviceChanged(InputUser user, InputUserChange change, InputDevice device)
 {
     // print($"DeviceChanged event triggered: {change}");
     if (change == InputUserChange.ControlsChanged || change == InputUserChange.ControlSchemeChanged || change == InputUserChange.DevicePaired)
     {
         InputHintManager.textMeshes.ForEach((textMesh) => textMesh.Refresh());
     }
 }
Exemple #8
0
 private void OnDeviceChanged(InputUser user, InputUserChange change, InputDevice device)
 {
     if (change.ToString() == "DevicePaired" && device != null)
     {
         _deviceUsing = device.name;
         Debug.Log("USING: " + _deviceUsing);
     }
     //PS4 "DualShock4GamepadHID"
     //PC: "Keyboard" or "Mouse"
 }
Exemple #9
0
 private void OnControlsChanged(InputUser user, InputUserChange change, InputDevice device)
 {
     if (change == InputUserChange.DevicePaired)
     {
         var playerId = _users.ToList().IndexOf(user);
         _gamepads[playerId] = device as Gamepad;
     }
     else if (change == InputUserChange.DeviceUnpaired)
     {
         var playerId = _users.ToList().IndexOf(user);
         _gamepads[playerId] = null;
     }
 }
Exemple #10
0
    private void InputUserOnOnChange(InputUser user, InputUserChange change, InputDevice device)
    {
        Debug.LogFormat("Input changed: event:{0}, device:{1}", change, device != null ? device.name : "null");

        if (change == InputUserChange.DevicePaired)
        {
            // var player = _users.ToList().IndexOf(user);
            Debug.LogFormat("Device paired, user: {0}", user.id);
        }
        else if (change == InputUserChange.DeviceUnpaired)
        {
            Debug.LogFormat("Device unpaired for user: {0}", user.id);
        }
    }
Exemple #11
0
    private void onInputDeviceChange(InputUser user, InputUserChange change, InputDevice device)
    {
        if (change == InputUserChange.ControlSchemeChanged)
        {
            Debug.Log(user.controlScheme.Value.name.ToString());
            switch (user.controlScheme.Value.name)
            {
            case "Keyboard+Mouse":
                InputSettings.Instance.Scheme = InputSettings.ControlScheme.KeyboardMouse;
                Cursor.lockState = CursorLockMode.Confined;
                break;

            case "Gamepad":
                InputSettings.Instance.Scheme = InputSettings.ControlScheme.Gamepad;
                Cursor.lockState = CursorLockMode.Locked;
                break;
            }
        }
    }
Exemple #12
0
 public void OnControlsChanged(InputUser user, InputUserChange change, InputDevice device)
 {
     /*if (change == InputUserChange.DevicePaired)
      * {
      *  var playerId = players.ToList().IndexOf(user);
      *  Debug.Log(playerId);
      *  if (device is Gamepad)
      *  {
      *      controllers[playerId].pad = device as Gamepad;
      *  }
      *  else if (device is Keyboard)
      *  {
      *      controllers[playerId].key = device as Keyboard;
      *  }
      * }
      * else if (change == InputUserChange.DeviceUnpaired)
      * {
      *  var playerId = players.ToList().IndexOf(user);
      *  controllers[playerId].key = null;
      *  controllers[playerId].pad = null;
      * }*/
 }
Exemple #13
0
    static void OnInputDeviceChange(InputUser user, InputUserChange change, InputDevice device)
    {
        if (device is null || change != InputUserChange.DevicePaired || LockDeviceSwap)
        {
            return;
        }

        SetDeviceName(device.name);

        if (IsPCDevice(device.name))
        {
            if (!PCLayout) //No need to call unnecessary events if the layout still the same
            {
                PCLayout = true;
                onInputDeviceChangedDelegate?.Invoke();
            }

            return;
        }

        PCLayout = false;
        onInputDeviceChangedDelegate?.Invoke();
    }
Exemple #14
0
 public UserChange(InputUser user, InputUserChange change, InputDevice device = null)
 {
     this.user   = user;
     this.change = change;
     this.device = device;
 }
Exemple #15
0
 private void OnUserChange(InputUser user, InputUserChange change, InputDevice device)
 {
     Repaint();
 }
Exemple #16
0
    /// <summary>
    /// Called when there's a change in the input user setup in the system.
    /// </summary>
    /// <param name="user"></param>
    /// <param name="change"></param>
    /// <param name="device"></param>
    private void OnUserChange(InputUser user, InputUserChange change, InputDevice device)
    {
        var player = FindPlayerControllerForUser(user);

        switch (change)
        {
        // A player has switched accounts. This will only happen on platforms that have user account
        // management (PS4, Xbox, Switch). On PS4, for example, this can happen at any time by the
        // player pressing the PS4 button and switching accounts. We simply update the information
        // we display for the player's active user account.
        case InputUserChange.AccountChanged:
        {
            if (player != null)
            {
                player.OnUserAccountChanged();
            }
            break;
        }

        // If the user has canceled account selection, we remove the user if there's no devices
        // already paired to it. This usually happens when a player initiates a join on a device on
        // Xbox or Switch, has the account picker come up, but then cancels instead of making an
        // account selection. In this case, we want to cancel the join.
        // NOTE: We are only adding DemoPlayerControllers once device pairing is complete
        case InputUserChange.AccountSelectionCanceled:
        {
            if (user.pairedDevices.Count == 0)
            {
                Debug.Assert(FindPlayerControllerForUser(user) == null);
                user.UnpairDevicesAndRemoveUser();
            }
            break;
        }

        // An InputUser gained a new device. If we're in the lobby and don't yet have a player
        // for the user, it means a new player has joined. We don't join players until they have
        // a device paired to them which is why we ignore InputUserChange.Added and only react
        // to InputUserChange.DevicePaired instead.
        case InputUserChange.DevicePaired:
        {
            if (state == State.InLobby && player == null)
            {
                OnPlayerJoins(user);
            }
            else if (player != null)
            {
                player.OnDevicesOrBindingsHaveChanged();
            }
            break;
        }

        // Some player ran out of battery or unplugged a wired device.
        case InputUserChange.DeviceLost:
        {
            Debug.Assert(player != null);
            player.OnDeviceLost();

            ////REVIEW: should we unjoin a user when losing devices in the lobby?
            ////TODO: we need a way for other players to be able to resolve the situation

            // If we're currently in-game, we pause the game until the player has re-gained control.
            if (isInGame)
            {
                PauseGame();
            }

            break;
        }

        // Some player has customized controls or had previously customized controls loaded.
        case InputUserChange.BindingsChanged:
        {
            player.OnDevicesOrBindingsHaveChanged();
            break;
        }
        }
    }