An open-source Game Controller-Bridge App that allows you to use an Xbox/Ps4/Joycon or any controller that works with your phone to control most micro-controllers such as Arduino/Esp8266/Raspberry Pi over WiFi. I have also made a Car controllered by this app.
Note: This app is a bridge between your controller and the microcontroller; the controller is not directly connected to the microcontroller. For direct connection, you will need to use a microcontroller with Bluetooth and have knowledge of writing custom Bluetooth Stacks.
Slick and fast UI | Dozens of Themes | Quick Reactions using UDP protocol |
---|---|---|
This new video below demonstrates and explains how it works:
Works with any controller that can connect to your phone. They are called HID/Bluetooth controller devices.
Note: For Wii U/Switch, you must use the Mayflash Adapter(Because Nintendo hates open-source)
The Phone is the most powerful device that we all carry in our pockets, It can perform stuff on its screen while doing some magic in the background. So how does it work?
For my app, the game controller connects via bluetooth or USB to your phone.
The Android IDE(aka Android Studio) has built-in functions to handle keyEvents like a button press or joystick
movement. It can even detect keyboard presses and mouse clicks.
Well, my app takes these controller inputs and sends them to the ESP8266 (aka best WiFi microcontroller) by
the network SSID: "ESPTest". The way I programmed the Esp8266 is based on my MusicWithoutDelay library.
This means we will use the Char-by-Char or Streaming method to evaluate each byte in the order it came. For example,
the phone sends a UDP packet containing two values that I made up. So, if I press the A
button on my Xbox controller,
my phone will send a1
to the esp8266. So a1
means the A button was pressed, and a0
vias versa. I'm pretty sure this
techinque is used a lot in the industries.
The Esp8266 acts as the server, while my phone is the client. Fortunately, you don't have to connect to this server manually. My app immediately starts searching for WiFi devices with the name "ESPTest" within your area. I tried to mimic Google Chromecast's method, but its hard to decipher :/
Next, after the phone connects to your esp8266, it will enable streaming mode. This mode allows you to send UDP packets to your esp8266 quickly. Of course, there are many problems that arose. Because UDP is so fast, it caused my esp8266 to Crash XD.
The solution I found was to pause the UDP stream if the game controller sent the same stuff before. Essentially, I'm muting extra repeating data. This idea/method is very similar with my SensorToButton library. You can check that out, as it's very simple to use.
The only downside is that some packets can be lost, but since this is game data, we don't care because the Human button press only takes around 10-20 ms which is hardly noticeable when streaming :) But you could try and clicking faster and see a few hiccups, but let's just be honest that this looks cool; it's just so satisfying to see an LED fade when its being controlled by a Xbox controller's joystick.
Submit an Issue and we'll fix it. :)
Things I plan to do:
yield()
when using the controller data.GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Rest of License found here: https://github.com/nathanRamaNoodles/Tinker-Controller/blob/master/LICENSE