Issue with recognising specific Gamepad controller at runtime (Hardware)

Hello,

We’ve recently discover an issue in our project regarding the display of our UI based on which controller we’re using.

We’re using Unreal Engine version 5.4.4.

We handle input symbols in our UI based on which gamepad controller we are using between Xbox, PS5 and NX, we’ve been using the RawInputFunction Library to get the registered device and check their PID to know which controller of which constructor is used, using URawInputFunctionLibrary::GetRegisteredDevices();

However, it seems that if the gamepad is not connected to the PC while the project (editor) or Build is starting, it will never be recognised by the plugin (never registered), and if we plug the controller and check URawInputFunctionLibrary::GetRegisteredDevices(); it will always return an empty array.

When encountering this issue, I tried to find other solutions, not using RawInputFunctionLibrary.

I’ve been running tests trying to use InputDeviceSubSystem, trying to get data from UInputDeviceSubsystem::Get(); or GetMostRecentlyUsedHardwareDevice(PlatformUserID); through HardwareDeviceIdentifier, but I haven’t been able to find a way to use the data properly to recognise which one of the gamepad controller is being used.

In short, I’m trying to find a solution to be able to know which Gamepad I am using between Xbox, PS5, NX on PC.

I’ll upload a repro project to show what we’ve been currently using for reference.

Thanks in advance for checking this issue!

Hi [mention removed],

Have you tried InputDeviceSubsystem::OnInputHardwareDeviceChanged? It provides a callback when the user’s active controller changes. From there, you can call UInputDeviceSubsystem::GetMostRecentlyUsedHardwareDevice(UserId) to retrieve the HardwareDeviceIdentifier.

UInputDeviceSubsystem* IDS = UInputDeviceSubsystem::Get();
IDS->OnInputHardwareDeviceChanged.AddDynamic(this, &MyClass::OnInputHardwareDeviceChanged);
 
 
void OnInputHardwareDeviceChanged(FPlatformUserId UserId, FInputDeviceId DeviceId)
{
 
    FHardwareDeviceIdentifier Info = IDS->GetMostRecentlyUsedHardwareDevice(UserId);
    Info.HardwareDeviceIdentifier;
    Info.PrimaryDeviceType;
}

I also recommend using the GameInput plugin. It’s the most modern way to query device info on Windows and integrates well with Unreal. In this plugin you can use FGameInputDeviceIdentifier to access fields like VendorId and ProductId.

References:

GameInput plugin documentation: Game Input for Windows - Experimental Release Notes | Tutorial

Setup guides and examples:

Schartier Isaac: https://somndus-studio.com/blog/ue5-game-input

DocsMod.io (glyph switching with CommonUI):https://docs.mod.io/unreal/component\-ui/gamepad\-glyph\-switching

With GameInput you can detect which controller is currently in use on Windows and wire that into CommonUI to drive your UI/state.

Let me know if that unblocks you or if you’d like a quick snippet to illustrate it.

Best,

Joan