How to get IPlatformInputDeviceMapper?

I changed from version 5.0 to 5.1 and now i get this “Warning: C4996 ‘FCoreDelegates::OnControllerConnectionChange’: OnControllerConnectionChange, use IPlatformInputDeviceMapper::GetOnInputDeviceConnectionChange()” and i have no idea how to get this IPlatformInputDeviceMapper.

1 Like

Same problem for me :sweat_smile:

IPlatformInputDeviceMapper::Get() would work.
ex) ((IPlatformInputDeviceMapper::Get()).GetOnInputDeviceConnectionChange()).AddRaw(this, &YOURFUNCTION);

You should

  1. add PublicDependencyModuleNames.AddRange(new string[] { “ApplicationCore” }); in your module (~.build.cs)
  2. include “GenericPlatform/GenericPlatformInputDeviceMapper.h”
5 Likes

Thanks so much! This worked well for me. Note also the signature changed a bit but it’s not hard to figure out. bools change to enums and the controller and player ids/indices change to structs with member functions.

1 Like

I ran into this issue today.

To expand on this a bit more, add this to your header file:

UFUNCTION()
		void OnControllerChanged(EInputDeviceConnectionState connectionState, FPlatformUserId userID, FInputDeviceId inputDeviceID);

Connect to the delegate:

void SOMEFILE::BeginPlay()
{
	Super::BeginPlay();	

IPlatformInputDeviceMapper::Get().GetOnInputDeviceConnectionChange().AddUObject(this, &SOMEFILE::OnControllerChanged);	
}

Function that gets called:

void SOMEFILE::OnControllerChanged(EInputDeviceConnectionState connectionState, FPlatformUserId userID, FInputDeviceId inputDeviceID)
{
	UE_LOG(LogTemp, Warning, TEXT("Controller changed!"));

	if (connectionState == EInputDeviceConnectionState::Disconnected)
	{
		UE_LOG(LogTemp, Warning, TEXT("Controller disconnected!"));
	}
}
5 Likes

Thank you.

thank you, i had logic writen already, just didn’t know where to bind it in new version.

1 Like