The Unreal Engine 4 Input Framework

Player input is what separates video games from television: it gives viewers the ability to interact with the fictional world they are watching. But player input devices have been evolving for as long as video games have been around. From the simple dials of Pong, to the revolutionary handheld of the SNES, to the debauchery that was the Xbox Kinect, people have reimagined the way they interact with the digital world time and again. And now with the advent of virtual reality gear, input hardware shows no signs of slowing down any time soon. This creates a world of new possibilities, but also creates a dilemma to match: as a game developer, how can you keep your game updated to handle input in so many different ways? If you try to handle only a select few inputs, you may be limiting your game to one platform. But on the other hand, if you try to handle every type of input (gamepad, keyboard, joystick, Ouya) you'll be stuck in a cycle of having to update input handling every time the platform changes. Fortunately, UE4 provides an elegant, cross-platform solution to this problem. The UE4 input framework is made up of two parts: mapping and binding.

Mapping Mapping is the process of connecting raw hardware inputs to abstract delegates. Those delegates can have arbitrary names like Jump or MoveForward or Interact. UE4 accommodates a wide variety of hardware inputs, including keyboards, console controllers, virtual reality inputs, and even virtual joysticks (like those used in mobile games). You can map any number of hardware inputs to a single delegate. So, for example, we can map the keys Spacebar, ControllerX, and Up to the delegate Jump. Binding Binding is the process of routing input events to game-specific events. Again, those events can have arbitrary names, and any number of events can bind to a single delegate. Continuing our example, we can bind a Jump() function in our Character or PlayerController to our Jump delegate. To make things simple, the delegate is the abstraction that allows the framework to work cross-platform - it acts as the middleman. You bind all of your game functions to one delegate, which represents some action that you want your player to be able to take, like move, or talk, or explode. Then you map as many hardware inputs as you want to that delegate, to allow the player to take that action on a desktop, or a PS4, or an Oculus Rift.

UE4 gives developers the option to map and bind using only code. Check out the articles below for more details. Mapping Input Using C++ Binding Input Using C++ And you can find advanced uses for input mapping, such as rebinding and resetting, here. UE4 Input Framework: Advanced Uses (coming soon)