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.
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.
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.