Hi,
For dev testing purpose, we are trying to force-assign gamepads to multiple instances of PIE on one machine - not local split screen multiplayer but actual multiplayer in several windows - so that we can play test on one machine with several users at the same time. I was able to do that with the following approach in the Controller’s BeginPlay:
if (IsLocalController())
{
TArray<FInputDeviceId> InputDevices;
IPlatformInputDeviceMapper::Get().GetAllConnectedInputDevices(InputDevices);
const int32 PIEIndex = GEngine->GetWorldContextFromWorld(GetWorld())->PIEInstance;
const UInputDeviceSubsystem* InputDeviceSubsystem = UInputDeviceSubsystem::Get();
int32 NextGamePadIndex = 0;
for (const FInputDeviceId& InputDevice : InputDevices)
{
const FHardwareDeviceIdentifier DeviceIdentifier = InputDeviceSubsystem->GetInputDeviceHardwareIdentifier(InputDevice);
if (DeviceIdentifier.IsValid() && DeviceIdentifier.PrimaryDeviceType == EHardwareDevicePrimaryType::Gamepad)
{
if (PIEIndex == NextGamePadIndex)
{
const FPlatformUserId PlatformUserId = IPlatformInputDeviceMapper::Get().GetUserForInputDevice(InputDevice);
UGameplayStatics::SetPlayerPlatformUserId(this, PlatformUserId);
break;
}
NextGamePadIndex++;
}
}
}
However this prevents the KBM to be used in the window that has focus, which is not convenient if only for console commands. Is there a way to force the assignation of gamepads without preventing the KBM to replace the gamepad in the focused window?
Thanks,
Ben