This feature is in an Experimental state so you can try it out, provide feedback, and see what we are planning. You cannot publish a project that uses Player Input Device Info API at this time. Please keep in mind that we do not guarantee backward compatibility for assets created at the experimental stage. The APIs for these features are subject to change, and we may remove entire Experimental features or specific functionality at our discretion.
Build adaptive gameplay and UI by reading the input capabilities and context of each player's device. The Player Input Device Info API extends the player_input class with two new properties that let you understand not just which inputs exist, but how a player is physically interacting with the game.
Many devices support multiple input types at the same time. For example, a Nintendo Switch supports both gamepad and touch simultaneously. PreferredInputMethod gives you a single high-level category useful for decisions like whether to show a touch-centric or gamepad-centric UI.
About Input Methods
An input method is a high-level category representing how a player is primarily interacting with the game. Even when a device supports multiple input types, PreferredInputMethod resolves to a single value so your code can make straightforward branching decisions.
What the Player Input Device Info API Does
Identifies a player's preferred input category through
PreferredInputMethod.
What You Can Do
You can use the Player Input Device Info API to:
Show the correct button prompts (gamepad icons, touch icons, or keyboard shortcuts) based on how the player is actually playing.
Build UI layouts that adapt to the player's form factor; such as compact mobile layouts, large-text TV layouts, and so on.
Support platforms that use multiple input types simultaneously by querying all available devices rather than relying on a single assumed input.
Input Method
The input_method enum is a high-level categorization of how a player is primarily interacting with the game. Import it with:
using { /Verse.org/Input }.| Value | Description |
|---|---|
KeyboardAndMouse | The player is primarily using a keyboard and mouse. |
Gamepad | The player is primarily using a gamepad. |
Touch | The player is primarily using touch input. |
Using Player Input Device Info in Verse
The following walks through how to import the module, retrieve a player's input data, and branch your logic based on their preferred input method or available hardware.
Import the Module
using { /Verse.org/Input }
using { /Verse.org/Simulation }
using { /Fortnite.com/Devices }Get Player Input and Read Properties
GetPlayerInput is a failable function and must be called within a failure context. Once you have the player_input instance, read the device info properties directly:
if (PlayerInput := GetPlayerInput[Player]):
Method := PlayerInput.PreferredInputMethod
Branch on Preferred Input Method
Use PreferredInputMethod to decide which UI style to present:
if (PlayerInput := GetPlayerInput[Player]):
case (PlayerInput.PreferredInputMethod):
input_method.Gamepad => ShowGamepadUI()
input_method.Touch => ShowTouchUI()
input_method.KeyboardAndMouse => ShowKeyboardMouseUI()
_=>Complete Example
The following example demonstrates a device that reads each player's input device info on join and adapts its UI and features accordingly.
using { /Fortnite.com/Devices }
using { /Verse.org/Input }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
input_device_info_example := class(creative_device):
OnBegin<override>()<suspends> : void =
for (Player : GetPlayspace().GetPlayers()):
AdaptToPlayer(Player)
Tips for Using Player Input Device Info
The following tips can help you work effectively with the Player Input Device Info API:
Use
PreferredInputMethodfor most UI decisions. It resolves to a single value even on platforms that support multiple input types simultaneously, keeping your branching logic simple.Read device info properties at player join time, and again if the player's device context may change, such as when a player switches from keyboard and mouse to gamepad.