Add Xbox One Controller to Android/Nexus 5

A week an a half ago I bought an Xbox One controller to use with a FireTV 2. I’ve heard wonderful things about the Moonlight app for android and I wanted to play PC games from my couch. I loaded it up, and promptly found that there is a bug in Amazon’s FireTV 2 that doesn’t allow the USB Host Permission prompt to appear. Well, I know that the Linux Xpad Kernel module has been recently updated to support the Xbox One controller, so I figured that could just add native support for the Xbox One controller through the kernel itself. Since root on the FireTV2 has only been recently achieved, I need to wait for a custom recovery so that I can build and flash a kernel. Until then, I decided to build the kernel for my Nexus 5 to make sure my theory was working.

Install Kernel with Xbox One controller support on a Nexus 5

Note: I take no responsibility for the steps below and what they may do to your devices. If you don’t know what you’re doing, you’ll probably brick your device. My kernel only works with Android 6.0.1 on a Nexus 5.

Quick Steps:

  1. Update to Android 6.0.1
  2. Unlock bootloader and install TWRP recovery using the Nexus Root Kit.
  3. Download Kernel file (stock/root) and Keylayout file and copy them to the sdcard.
  4. Boot to TWRP recovery.
  5. Flash the Kernel Img file.
  6. Flash the Keylayout Zip file.
  7. Profit!

DIY/Detailed method:

This method is built for linux, but you should be able to adapt it to work with windows or mac if you know what you’re doing.

  1. Update to Android 6.0.1. You can find the Nexus factory images files here.
  2. Unlock bootloader and install TWRP recovery using the Nexus Root Kit.
  3. Clone the git repository to your local machine.

    git clone

  4. Checkout the Kernel commit found on your device.

    git checkout 7717f76

    You can find the commit hash by looking at the string after the ‘g’ in the Kernel version.

    kernel version

    • Edit the Xpad Module in your source, found in:


      Replace it with the file found in the current Linux Kernel on github.

      • Setup your build environment.

        Google has some great documentation on that.

      • Build your kernel config.

        make hammerhead_defconfig

      • Build your kernel.


        When it’s finished, your kernel should be built and can be found at:

      • Now that we have the kernel, we need to create a .img file for us to flash with. We need to download a working boot.img (Stock boot.img, Rooted boot.img) to inject our kernel with.

      • Use Android-AIK to unpack the img.

      • Replace the kernel with our kernel, and repack.

      • You can now flash this to your device using TWRP. Install Img in TWRP

      • Now, go ahead and download this Keylayout file and flash it as well.

        If you don’t want to use the Flashable Zip, you can just mount /system in TWRP and copy