How to use different devices for the individual players with the new input system?

I don’t use the input system via “Player Input Component”, but (as described here) with the “Actions Asset” workflow; so I have the wrapper class generated for the actions and reference them via code.

However: I have two player prefabs spawned via code which then “bind” the actions in their PlayerController script as follows:

// PlayerController.cs

private void Awake()
    {
        playerInputActions = new PlayerInput();
        playerInputActions.CharacterControls.Move.performed += OnMove;
        playerInputActions.CharacterControls.Move.canceled += OnMove;
        playerInputActions.CharacterControls.Jump.performed += OnJump;
        playerInputActions.CharacterControls.Jump.canceled += OnJump;

}

But now I control both players at the same time with the keyboard inputs. But I want to make sure that player 1 uses “Keyboard” or “Gamepad No. 1” and player 2 uses, for example, “Gamepad No. 2”.

How can I distinguish this in the code?

If you don’t use the PlayerInputComponent then you basically are DIY’ing everything the component does, and are getting into low-level API territory.

There’s some instructions on this here: User Management | Input System | 1.8.2

Tutorials on this probably exist too.