Skip to content
This repository has been archived by the owner on Jan 5, 2022. It is now read-only.
Jibran Syed edited this page Sep 9, 2013 · 46 revisions

XboxCtrlrInput Documentation

Description

XboxCtrlrInput is a wrapper written in C# for Unity3D that handles Xbox 360 controller input. It's used in the same way as Unity's Input class. The goals of XboxCtrlrInput are:

  1. To be able to make simple calls to Xbox controller input that works on Mac, Windows, and Linux (Ubuntu),
  2. And to be able to handle multiple Xbox controllers that works as you expect.

XboxCtrlrInput.cs itself is not a Unity script and thus does not need to be attached to any GameObject, since it contains no MonoBehaviors. Unity's Input class works in a similar way. XboxCtrlrInput should work on older versions of Unity that support joystick input.

How to Use

Note for Mac users: Be sure to install the latest version of the Tattie Bogle drivers.

Note for Linux users: All of my Linux testing was done on Ubuntu 13.04 64-bit. To test 32-bit Unity builds on a 64-bit OS, I ran sudo apt-get install ia32-libs in a terminal. I am using the default Xbox controller driver that came with Ubuntu, which is known as xpad. I could not get Unity builds to cooperate with xboxdrv. Your milage may vary.

  1. Download the XboxCtrlrInput C# file (Right Click -> Save As...) and then put it into your Unity project under the Assets/ folder. It can be anywhere in that folder.

  2. Next, take the a copy of Unity's Input Manager (either as a text asset or as a binary asset ) (Right Click -> Save As...). Place that copy into your project's /ProjectSettings folder. Then rename it InputManager.asset, this will replace the original file that was there.

  3. For any C# script where you want to Xbox input, place using XboxCtrlrInput; at the top of the script under using UnityEngine;.

  4. The XboxCtrlrInput namespace includes the class XCI, which you will use to get Xbox input, such as:

bool didPressA = XCI.GetButton(XboxButton.A);

Software Compatibility

  • The code in XboxCtrlrInput.cs should work in Unity 4.x and above.
  • It might work in previous versions as long as they support joystick input.
  • The example project requires Unity 4.2 or above (mostly due to the free text asset serialization).
  • This class was mostly designed for desktop OS games in mind (Mac/Windows/Linux). This probably won't work for console or mobile development.

What Works?

If you want to find out what currently works (such as button mappings), refer to the What Works page.

Issues

Please refer to the Issues page for the latest issues.

About the Example Unity Project

The XboxCtrlrInput repo includes the necessary files to get Xbox input in Unity, as mentioned in "How To Use" section above. It also includes an example Unity project for demoing the capabilities. The project requires Unity 4.2 or above because it makes use of features that became free in Unity 4.2, including text serialization and shadow rendering.

Get comprehensive information about what's in the demo the Example Unity Project page.

Coding Reference

For code documentation, including information about the included enumerations and methods, check out the Coding Reference page.

Clone this wiki locally