• Stars
    star
    337
  • Rank 125,272 (Top 3 %)
  • Language
    C++
  • License
    MIT License
  • Created about 6 years ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

XInput library for USB capable Arduino boards

Arduino XInput Library

arduino-library-badge Build Status

This library lets you easily emulate an Xbox 360 controller using a USB-capable Arduino microcontroller.

Getting Started

void setup() {
	XInput.begin();
}

void loop() {
	XInput.press(BUTTON_A);
	delay(1000);
	
	XInput.release(BUTTON_A);
	delay(1000);
}

Before the library will work, you must install a compatible boards file that contains the XInput USB descriptors, otherwise the microcontroller won't behave like an XInput device. This is not optional. See the compatible boards section below for more information.

After installing a compatible boards package, you must then download and install the library. Once the XInput library is installed, open up the Arduino IDE and load an example sketch, located in File -> Examples -> XInput (I suggest trying the 'Blink' sketch first). Double-check that you have the correct XInput board and/or XInput USB type selected in the 'Tools' menu, then upload the sketch to your microcontroller.

On Windows, you can test that the sketch is working properly by opening up the joystick control panel (joy.cpl) or by using HTML5 Gamepad Tester. If you uploaded the XInput 'Blink' example, the #1 button ('A') should be slowly turning on and off.

Control Surfaces

The library gives you access to the following controls available on the Xbox 360 controller:

  • 10 + 1 Digital Buttons
  • 2 Analog Joysticks (16 bit)
  • 2 Analog Triggers (8 bit)
  • 1 Four-Way Directional Pad (D-Pad)

For the full list of control names as used in the library, see the source files.

The library also processes received data, so you can read the status of the controller's 2 rumble motors (8-bit), the assigned player number (1-4), and the index of the current LED animation. Data is sent and received automatically over USB.

Compatible Boards

To function as an XInput device, you must use a compatible boards package with XInput USB descriptors. This is not optional. Without these descriptors the library will only function in "debug" mode and the microcontroller will not behave as an XInput device.

The following boards packages are available:

  • Arduino AVR Core Boards

    Modifies the Arduino AVR core to emulate an XInput device. Includes support for the Arduino Leonardo, Micro, Yun, and more.

  • SparkFun AVR Boards

    Provides support for the MaKey MaKey, Pro Micro, Fio, Qduino Mini, and LilyPad USB Plus. Requires the XInput AVR Core boards.

  • Teensy Boards

    Includes an 'XInput' USB mode for the Teensy 3.1, 3.2, 3.5, 3.6, LC, 4.0, 4.1, and MicroMod. Requires a preexisting Teensyduino installation.

For a complete list of available packages and compatible boards see the 'supported boards' file. For information on how to add support for another Arduino-compatible board with native USB support, see the documentation on the USB API.

Console Support

Please be aware that none of the currently available board packages support connecting to the console itself. Genuine controllers use a dedicated hardware security chip that handshakes with the console. Arduinos do not have this chip, and its security method has not been (openly) broken.

License

This library is licensed under the terms of the MIT license. See the LICENSE file for more information.

More Repositories

1

Adalight-FastLED

Adalight with FastLED support
C++
356
star
2

LED-Segment-ASCII

Library of ASCII character representations using 7 segment, 14 segment, and 16 segment LED displays
131
star
3

NintendoExtensionCtrl

Arduino library for communicating with Nintendo extension controllers
C++
105
star
4

ArduinoXInput_AVR

AVR boards package for the ArduinoXInput project
C
70
star
5

Sim-Racing-Arduino

A library to connect sim racing peripherals to Arduino development boards
C++
53
star
6

OBS-ChatSpam

Python script for OBS Studio that posts messages in Twitch chat
Python
40
star
7

ArduinoXInput_Teensy

Teensy boards package for the ArduinoXInput project
C
29
star
8

Sim-Racing-Shields

Add-on circuit boards ("shields") for connecting Arduino development boards to sim racing equipment.
C
23
star
9

ServoInput

Interrupt-driven servo decoder library for Arduino
C++
21
star
10

HID_Buttons

Arduino library making it easier to use HID buttons
C++
20
star
11

Teensy40_Minimalist_USB_Host

A minimalist USB host shield for the Teensy 4.0 development board
20
star
12

FrameVis

A video visualizer / movie barcode generator
Python
15
star
13

OBS-Mute-Indicator

Python script for OBS Studio that sends the 'mute' state of an audio source over serial
C++
15
star
14

ArduinoXInput_Sparkfun

SparkFun boards package for the ArduinoXInput project
C
14
star
15

FastLED_NeoPixel

An Arduino library for using Adafruit NeoPixel library animations with FastLED
C++
14
star
16

Prismatik-iRacing

Prismatik plugin that maps data from the iRacing API
Python
12
star
17

DJHero-Lucio

Code and CAD files for the DJ Hero Lucio controller
C++
9
star
18

RC-Forza-Controller

Modified RC controller to play Forza Horizon 4.
C++
8
star
19

splitflap-youtube-stats

Script for fetching YouTube statistics from the API and sending them to a split-flap display
Python
8
star
20

Xbox360ControllerLEDs

Arduino library for emulating Xbox 360 controller LED animations
C++
7
star
21

McCree-Hammershot

Code and other files for the McCree Hammershot controller
Arduino
6
star
22

Pro_Micro_USB-A

ATMega32U4 Arduino board from SparkFun, modified to work with a USB-A connector
C++
5
star
23

MIDItoMoppy

Arduino library to convert MIDI notes to Moppy data
C++
5
star
24

DJHero-SpinRhythm

Code and CAD files for the DJ Hero modifications for Spin Rhythm XD
C++
5
star
25

AnalogSelector-Arduino

Arduino library for reading a potentiometer as a multi-selector switch
C++
3
star
26

CtrlUtil

Controller Utilities Library for Arduino
C++
2
star
27

OBS-Audio-Track-Hotkeys

Python script for OBS Studio that creates hotkeys for setting audio source track assignments.
Python
2
star
28

MediaFootswitch

Program files for the USB media footswitch controller https://www.partsnotincluded.com/diy-media-key-footswitch-for-pc/
C++
2
star