Skip to main content

One post tagged with "ps5"

View All Tags

· 5 min read
Schartier Isaac

In this post, I will guide you through a solution to detect your console controllers (using PS5 as an example) in your Unreal Engine project. We'll achieve this with the help of Unreal Engine's GameInput plugin and its integration with Common Input. I'll clarify how mapping and detection work, even beyond the GameInput plugin.

Overview

We'll explore how to set up controller detection and mapping using Unreal Engine's GameInput plugin. This tutorial will help you understand the underlying processes and how you can leverage these features effectively in your project.

What You'll Learn

  • Setting Up the GameInput Plugin: Learn how to configure and utilize the GameInput plugin to detect PS5 controllers.
  • Integrating with Common Input: Discover how to combine the GameInput plugin with Common Input for enhanced functionality.
  • Mapping and Detection: Gain insights into how controller mapping and detection operate, both within and outside of the GameInput plugin.

By the end of this guide, you'll have a clearer understanding of how to manage console controllers in Unreal Engine and how to make the most of these tools for your project.

Basic explain

I assume you are familiar with the basics of the Common Input plugin.

Here is a brief explanation of how CommonInputBaseControllerData works.

CommonInputBaseControllerData allows you to define the visual information for a controller (keyboard/mouse or gamepads). In theory, you will have one for each type of controller (Xbox, PS5, Switch, etc.).

There are three key pieces of information to remember about CommonInputBaseControllerData:

  • GamepadName: The name you assign to the device (XSX, PS5, PS4, etc.).
  • Activation Conditions: The conditions under which the CommonInputBaseControllerData will be activated.
  • InputBrushDataMap: The icons for the buttons of this device.

Activation Conditions

Each condition contains two pieces of information:

  • InputDeviceName: The internal interface in UE5 that will detect the device.
  • HardwareDeviceId: The ID of the device.

This information is emitted through interfaces that determine which device is currently in use, often through plugins such as WindowsDualShock or GameInput.

Screenshot

Condition example with PS5 gamepad

Screenshot

An quick view on the blueprint i named CommonInput_Gamepad_PS5

Screenshot

Of course, we assume that you have already configured Common UI and Common Input correctly. You can refer to the Lyra project to see the suggested setups.

For example, I have 3 controller data configurations in my game for Windows: Keyboard/Mouse, Xbox, and PS5:

Screenshot

Use GameInput plugin and GDK

We will see how to detect, for example, the PS5 DualSense controller using Epic Games' GameInput plugin, which has been available since UE5.4:

https://dev.epicgames.com/community/learning/tutorials/EpZ4/unreal-engine-game-input-for-windows-experimental-release-notes

Check the link I provided for more information on the feedback regarding this topic:

https://forums.unrealengine.com/t/tutorial-game-input-for-windows-experimental-release-notes/1763696

You need to install Windows GDK and Windows Game Input separately:

Windows Game Input

You can download the package and run GameInputRedist.msi.

Screenshot

Make UE5 detect the GDK

Unfortunately, UE5 installed from the launcher cannot detect if GDK is installed, as it looks for the GRDKLatest environment variable on your Windows system to determine the version of your GDK. This allows UE5 to enable its use only when the GameInput plugin is built. The relevant code can be found in GameInputBase.cs, which is part of the build files.

Screenshot

Screenshot

Otherwise, you will encounter the following error in the logs. :

LogGameInput: Error: [FGameInputWindowsModule] Failed to create a GameInput device! GAME_INPUT_SUPPORT is false!

  • Either you find a way to rebuild the plugin from the prebuilt version of the engine
  • Or you need to compile UE5 from the source, which requires several prerequisites and will take some time the first few times
Source Build

In any case, if you plan to compile console versions of your game, you'll need the source version of Unreal Engine anyway.

UE5 Game Input / Input Scope

Now in UE5, you need to add the necessary configuration so that GameInput can detect the PS5 DualSense controller. The configuration is provided on the site I shared with you:

https://dev.epicgames.com/community/learning/tutorials/EpZ4/unreal-engine-game-input-for-windows-experimental-release-notes

Screenshot

Visually, it looks like this configuration in Project Settings:

Screenshot

OverriddenHardwareId is very important because it allows us to link controller data in CommonInput, specifically the conditions.

In short, the GameInput plugin will notify:

  • InputDeviceName: GameInput, the plugin that notifies the activation of the device.
  • HardwareDeviceId: DualSense, the OverriddenHardwareId.

You can verify this by debugging the plugin; for example, when a button is pressed, you can see how it works in GameInputDeviceProcessor.

FInputDeviceScope InputScope(nullptr, UE::GameInput::InputClassName, DeviceMapper.GetUserIndexForPlatformUser(Params.PlatformUserId), GetHardwareDeviceIdentifierName(Params));

Another important point to remember is that, natively in UE5, it's FInputDeviceScope InputScope that allows notification of which type of controller is actively being used. The plugins utilize this structure.

Finally

So, ultimately, this is how the controller will work, and also, thanks to this information, we can display the correct buttons in the game (CommonInputControllerBaseData).

Screenshot

If it's not work

Obviously, there may be some issues, and you’ll need to troubleshoot if it doesn’t work. However, here are a few reminders:

  • Properly configure CommonInput
  • Avoid device conflicts
  • Configure or adjust platform options in GameInput according to your setup (the screenshot is just an example)

Screenshot

Bonus : Example in my game

For example, in my game, in the settings menu, I display certain button diagrams depending on the detected device.

Gamepad name : XSX

Screenshot

Gamepad name : PS5

Screenshot

Screenshot

Good luck!