Custom Platforms

If you need to support additional platforms that Rewired does not support natively, you can do so using the Custom Platform system.You can create custom input managers for joysticks, keyboard, and mouse, and pipe input in from any source.

Warning: Implementing a custom platform requires expert C# and Unity knowledge. Do not attempt to create a custom platform if you are not an expert or are not willing to read through C# code to understand the concepts. I will not provide any support on any C# or Unity concepts you do not understand.

The following is a brief overview of the concepts. The primary source of documentation for adding a Custom Platform is the code provided in the Custom Platform example included with Rewired. Refer to this to learn all the details of how to set up a custom platform.

Code

The namespace for all classes related to custom platforms is Rewired.Platforms.Custom. You should add a using statement with this namespace in your scripts.

Concepts

Custom Platform Input Source

Manages input devices, reads input from the low-level input API on the platform, pipes input into Rewired, and handles any output (vibration, etc.) if any.

Create an implementation that extends Rewired.Platforms.Custom.CustomPlatformInputSource.

Custom Platform Keyboard Input Source

(optional) Handles keyboard input. Reads low-level keyboard input and pipes input values into Rewired. If no keyboard input source is provided, Rewired will fall back to UnityEngine.Input keyboard handling.

Optionally create an implementation that extends Rewired.Platforms.Custom.CustomPlatformUnifiedKeyboardSource.

Additional features include supplying key labels which allows supporting keyboard layouts and localization.

Custom Platform Mouse Input Source

(optional) Handles mouse input. Reads low-level mouse input and pipes input values into Rewired. If no mouse input source is provided, Rewired will fall back to UnityEngine.Input mouse handling.

Optionally create an implementation that extends Rewired.Platforms.Custom.CustomPlatformUnifiedMouseSource.

Custom Platform Initializer

Initializes the platform input source on Rewired initialization.

Create a MonoBehaviour script that implements Rewired.Platforms.Custom.ICustomPlatformInitializer and add the component to the Rewired Input Manager GameObject or a child GameObject of the Rewired Input Manager. When Rewired initializes, the custom platform will be initialized and used as the source of input.

Custom Platform Hardware Joystick Map Platform Map Provider

Provides platform-specific, user-defined joystick element mappings for specific joysticks.

Create a class that implements Rewired.Platforms.Custom.IHardwareJoystickMapCustomPlatformMapProvider.

Hardware Joystick Map Platform Maps

User-defined mappings of low-level joystick elements to software Joystick buttons and axes. For each platform, you will need to create maps that map low-level controller elements to Rewired Controller axes and buttons.

For a basic implmentation (string device name matching only), you can use the built-in HardwareJoystickMapCustomPlatformMapSimpleSO class. Create an instance from the right-click menu:

  • Create -> Rewired -> Custom Platform -> Simple Joystick Platform Map

For more advanced features such as adding custom matching criteria properties, see the example code.

IMPORTANT: If there is ever any possibility on a platform that a controller could be connected that is not recognized, you must create a platform map for Unknown Controller. This is a definition that defines a long list of axes and buttons that should include enough of each to cover any device that might be used on the platform. It does not have to define all 128 supported buttons and 32 supported axes though. You can define however many elements as needed for the specific platform in question, or however many you want to support as a maximum.

Controller Extensions

If you need to provide platform-specific functionality, you can create a custom Controller Extension extending Rewired.ControllerExtensions.CustomControllerExtension to expose any functionality you want through the Controller Extension. You can also implement Rewired.Interfaces.IControllerVibrator to support standard Rewired Player and Controller vibration. You can also implement any of the device-specific interfaces such as IDualShock4Extension or IDualSenseExtension to allow you to use platform-agnostic code for these devices.