Xbox Controller Raspberry Pi

How to Use an Xbox One Controller on the Raspberry Pi

Get a grip and control your Pi!
Ash Ash (166)
Total time: 5 minutes 

The Raspberry Pi works with many controllers—Xbox controllers are no exception. From wireless Xbox 360 controllers to Bluetooth Xbox One controllers, if you've got an Xbox controller it will most likely work with a Raspberry Pi.

This guide focuses on how to set up an Xbox controller with Raspbian. RetroPie is a little bit different—most of these steps will work, but be sure to check out our Ultimate RetroPie Controller Guide for details on setting up a controller with RetroPie.

Here's everything you'll need to complete this guide:

Raspberry Pi 4 Model BRaspberry Pi 4 Model B×1
Xbox One controller×1
Micro SD Card×1

Before we begin, be sure you've got the latest version of Raspbian installed on your Pi. Visit our guide on how to update Raspbian for details on this process.

xboxdrv install

Xpad drivers are included with the latest version of Raspbian—so this step is technically optional. We still recommend installing it in case you come across an application built around the old xboxdrv driver.

Run the following command to install it:

sudo apt-get install xboxdrv
Wireless Xbox Controller

Wireless Xbox controllers use a USB wireless adapter. Connect the USB adapter to the Raspberry Pi. It should recognize and respond to the input as a normal USB controller.

Xbox Controller USB

If you're using a wired USB controller, plug the controller into a USB port on the Raspberry Pi. The Pi should detect the controller as a usable device.

Bluetooth Xbox controller Raspberry Pi

To connect an Xbox controller using Bluetooth, you'll need a terminal window. Open one on Raspbian or remote into the Pi using a terminal application of your choice.

1. Disable Enhanced Re-Transmission Mode (ERTM)

If ERTM is enabled, the controller won't pair with the Pi. To disable the ERTM, run the following command:

echo 'options bluetooth disable_ertm=Y' | sudo tee -a /etc/modprobe.d/bluetooth.conf

Restart the Pi.

2. Start Bluetooth Tools

After the Pi reboots, start Bluetooth Tools with the following command:

sudo bluetoothctl

3. Search for the Xbox controller

Now we need to search for the Xbox controller. Don't put the controller into pairing mode just yet. We have a few settings to adjust first. Enable agent with the following commands:

agent on
default-agent

Next, we'll start scanning for available Bluetooth devices. Run this command to start scanning:

scan on

4. Connect to the Xbox controller

Put the Xbox controller into Pairing mode. It should appear in the list of devices with a unique MAC address and the words "wireless controller" at the end. Take note of the MAC address, we'll need it to connect the controller. In the terminal window, enter the following command, replacing MAC_ADDRESS with the Xbox controller MAC address.

connect MAC_ADDRESS

After connecting the controller, make sure it's listed as a trusted device with this command—again replacing MAC_ADDRESS with the one for the Xbox.

trust MAC_ADDRESS

Close the bluetoothctl application by typing quit

5. Test the connection

We'll use the joystick toolset to make sure everything is working. Install it with this command:

sudo apt-get install joystick

When it finishes installing, run this command to start the test:

sudo jstest /dev/input/js0

You will see a screen of numbers. If everything is working properly, pressing buttons on the controller will cause them to change.

Use Xbox Controller as Cursor

Now that your controller is connected, you may want to use it in place of a mouse. Run the following command in a terminal window to enable this feature:

sudo xboxdrv --detach-kernel-driver --silent --mouse

If you need a specific mouse button, check the chart below for a corresponding button on the Xbox controller. It also includes a few keyboard functions.

Function Xbox Controller Button
Move Cursor Left Joystick
Scroll Wheel Right Joystick
Left Click A
Right Click B
Middle Click X
Enter Y
Arrow Keys D-Pad
Page Up LB
Page Down RB
Forward Start
Back Back