XboxCtrlrInput for Unity
Feel free to contribute. Requires at least Unity 5.3 (64-bit editor only) or greater. Unfortunately older versions of Unity are no longer supported (it may work or not, but your miliage will vary). 32-bit editor is no longer supported (but 32-bit game builds are still supported).
XboxCtrlrInput.cs includes a C# namespace called
XboxCtrlrInput. In that namespace there are three enumerations,
XboxAxis. Most importantly, there is a static class called
XCI that is used to get Xbox input.
The goals of
- To be able to make simple calls to Xbox controller input that works on Mac, Windows, and Linux (Ubuntu),
- And to be able to handle multiple Xbox controllers that works as you expect.
- Download the latest .unitypackage release.
- Import the package:
Assets ▶ Import Package ▶ Custom Package...
- Update InputManager.asset file (to configure Xbox 360 input axis and buttons):
Window ▶ XboxCtrlrInput ▶ Replace InputManager.asset...
How to Use
For any C# script where you want to use Xbox input, place
using XboxCtrlrInput;at the top of the script under
XboxCtrlrInputnamespace includes the class
XCI, which you will use to get Xbox input, such as:
bool didPressA = XCI.GetButton(XboxButton.A);
Note for macOS users: Be sure to install the latest stable version of the 360Controller 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. For best results, make sure all your Xbox controllers are connected before testing anything.
If you want to find out what currently works (such as button mappings), refer to the What Works page on the wiki. Compatability information can also be found there.
For documentation, including information about the included enumerations and methods, refer to the Coding References page on the wiki. A diagram showing all the labeled Xbox inputs can also be found there.
To see the latest bugs and limitations, refer to the repo's Issues section.
Everything in this repository is public domain, including the code and documentation art. I encourage everyone to use and even modify the code to your own specifications, and of course to contribute to this repo by forking the project. See
About the Example Project
XboxCtrlrInput includes a demo Unity project that requires Unity 4.3 or above. For more information about the demo, refer to the Example Unity Project page on the wiki.