Let’s get up-and-running in three simple steps.
1. Enable the plugin
First of all make sure the plugin is enabled in the Edit ➜ Plugins panel:
If you plan to use the plugin from C++, don’t forget to list it in your build dependencies:
2. Enable input detection
Then turn on input detection using the
Enable Input Detection node or the equivalent C++ function. You can do this anywhere you like: inside a Level Blueprint, inside an Actor, in a UMG widget, etc.
3. React to input device changes
Switcheroo will fire-off an event each time the input device used by the player changes. You can react to this event by using the
Bind Detected Input Device Changed node or the equivalent C++ function.
An example project that shows how to use the plugin is available for download for Unreal Engine 4.18 and up. A standalone demo version of the example project is also available for download, so that you can try out Switcheroo before you buy.
The project implements a complete menu system demonstrating how Switcheroo can be used to show the appropriate UI controls to the player and show/hide the mouse cursor. It also implements a simple game mode to demonstrate usage during gameplay.
Switcheroo provides a simple set of options to customize its behavior. These can be changed in the editor by navigating to the Plugins / Switcheroo section of the Edit ➜ Project Settings menu. It’s also possible to modify them at runtime using either C++ or Blueprint (for more information head over to the API Reference section).
A description of each setting is available below, as well as by hovering over a setting inside the editor.
|Default Input Device
|Default input device to use when no input has been detected yet. Can be used to select an appropriate default on different platforms (e.g. keyboard on PCs, gamepad on consoles).
|Mouse Move Threshold
The minimum movement that the mouse should perform in order for it to be considered valid input. Useful to filter out involuntary, minimal mouse movements.
Resolution independent, defined in Slate units. Set to zero to disable.
|Determines which analog stick should be watched for input.
|Dead Zone Mode
|Determines which type of dead zone should be applied to the input provided by gamepad analog sticks. Useful to filter out involuntary, minimal stick movements which can happen i.e. with loose analog sticks.
|Dead Zone Size
|Size of the dead zone applied to the input provided by gamepad analog sticks.
There are some issues of which I’m aware of that are unfortunately out of my control.
1. Only input from the first player will be detected
As such, scenarios that involve multiple local players aren’t supported out-of-the-box. This is due to the fact that only the primary player can be bound to the keyboard/mouse combo in Unreal Engine. Although there are some ways to work around that, they usually involve some gimmicks that would make the plugin unnecessarily complicated for most users and hard to maintain.
2. Switcheroo won’t respect the Skip Assigning Gamepad to Player 1 option
This is by design and is due to the way that option is implemented (at the viewport level, rather than at the Slate level). Fortunately there’s a simple workaround: in case you’re using that option, simply turn off input detection. Since Unreal Engine only routes keyboard input to the first player, and you know gamepad input will always be routed to the second player, you won’t need it anyway. 😉
3. Input detection doesn’t work correctly in multi-window PIE
Due to the way Slate users are mapped to each single window in multi-window Play in Editor (PIE), input detection will run on all the windows at the same time. This results in input detection events being fired in all the PIE instances at the same time.