Skip to content

Gamepad Support

Cristian Geambasu edited this page Apr 17, 2019 · 9 revisions

Standardized Gamepad Input

In order to make gamepads easier to manage the plugin comes with a system that allows you to map various gamepads to a single, standardized, set of buttons and axes(modeled after the Xbox controller). The mapping of an arbitrary gamepad layout to the standard layout is done through a script that implements the IGamepadStateAdapter interface. At the moment the plugin ships with three gamepad adapters which can be enabled by adding the respective component on the Input Manager game-object.

Standard Layout

The standard layout is modeled after the Xbox controller and contains the following buttons and axes:

  • LeftThumbstickX & LeftThumbstickY - Left analog stick.
  • RightThumbstickX & RightThumbstickY - Right analog stick.
  • DPadX & DPadX - DPad axes. For gamepads where the DPad is a series of buttons the axes are simulated from the button input, same as Digital Axis bindings.
  • LeftTrigger & RightTrigger - Trigger axes. For gamepads with buttons instead of analog triggers the triggers are simulated from the button input, same as Digital Axis bindings.
  • LeftStick & RightStick - The buttons that work by pressing down on the analog sticks.
  • LeftBumper & RightBumper
  • DPadUp, DPadDown, DPadRight, DPadLeft - DPad buttons. If the gamepad uses axes instead of buttons for the DPad the buttons will be simulated, same as Analog Button bindings.
  • Back & Start
  • ActionBottom, ActionRight, ActionLeft, ActionTop - These buttons map to A, B, X and Y respectively on the Xbox controller.

All these values are available in the input editor if you set the binding type to Gamepad Button, Gamepad Analog Button or Gamepad Axis.

XInputDotNet Gamepad Adapter

This adapter uses the XInput library for gamepad input instead of Unity’s input system. The advantage of this adapter is that you will support any XInput compatible gamepad(including Xbox 360 and Xbox One controllers) and you have access to the vibration feature of these gamepads. This adapter is available only in Standalone Windows builds.

Installation

  • Make sure you imported the XInput addon. It should be in “Assets/InputManager/Addons/XInput”.
  • Select your input manager game-object and add the XInputDotNetAdapter component.
  • Go to “Project Settings -> Player -> Other Settings -> Scripting Define Symbols” and add the ENABLE_X_INPUT symbol. The adapter will not work if you skip this step.

Properties

  • DPad Gravity - The speed at which the simulated DPad axis falls towards neutral.
  • DPad Sensitivity - The speed at which the simulated DPad axis moves towards positive or negative value.
  • DPad Snap - If enabled, the DPad axis will snap to neutral when you switch direction.
  • Ignore Timescale - If enabled, the DPad axes will be simulated using unscaled delta time. Generally you want this to be true otherwise your axes will stop updating when you pause the game.

UWP Gamepad Adapter

This adapter uses the Universal Windows Platform libraries for gamepad input instead of Unity’s input system and has support for vibration. This is the recommended solution when you’re building games for Windows Store or Xbox using UWP.

Installation

  • Make sure you imported the XInput addon. It should be in “Assets/InputManager/Addons/XInput”.
  • Select your input manager game-object and add the UWPGamepadAdapter component.
  • Go to “Project Settings -> Player -> Other Settings -> Scripting Define Symbols” and add the ENABLE_X_INPUT symbol. The adapter will not work if you skip this step.

Properties

  • DPad Gravity - The speed at which the simulated DPad axis falls towards neutral.
  • DPad Sensitivity - The speed at which the simulated DPad axis moves towards positive or negative value.
  • DPad Snap - If enabled, the DPad axis will snap to neutral when you switch direction.
  • Ignore Timescale - If enabled, the DPad axes will be simulated using unscaled delta time. Generally you want this to be true otherwise your axes will stop updating when you pause the game.

Clone this wiki locally