How I hacked Google Daydream controller (Part II)

Developing compatibility across multiple platforms.

If you randomly stumbled upon this, most likely you will like to discover how it all started: How I hacked Google Daydream controller (Part I).

In the last weeks I continued to develop my hack, on a mission to liberate the Google Daydream controller from its chains. My goal was now to extend its compatibility from iOS to other platforms.

Firstly, it was essential for me to inherit as much Bluetooth LE stuff as possible from the previous chapter of my work. Hence, I kept on using JavaScript as the main programming language to move forward quickly. Having JS in mind, I came across noble ( an amazing Node.js module that facilitates the implementation of BLE (Bluetooth Low Energy) peripherals.

Next, I set up a fresh Ubuntu 14.04 LTS (Long Time Support) machine, opened a shell and ran as sudo the installation script that I wrote for the occasion:

apt-get update # To get the latest package lists
curl -sL | sudo -E bash -
apt-get install -y nodejs
bluetooth bluez libbluetooth-dev libudev-dev npm
ln -s /usr/bin/nodejs /usr/bin/node # Symlink
# Cleanings
apt-get clean
apt-get autoclean
apt-get autoremove

The code above installs everything you need to get you started. However, keep in mind that to work with BLE devices you also need a Bluetooth LE 4.x USB Dongle (as below) in case your machine does not run it natively.

Bluetooth LE 4.x USB Dongle

Then I started creating a new Node.js script and installing the noble library through npm (node package manager):

npm install noble --save

Once finished, I managed to edit the script adding the main reference to noble:

var noble = require('noble');

so I started to implement the required code to make Google Daydream controller talk with Node.js.

The diagram represented below make clear the whole flow I followed to achieve Daydream controller data reading via Bluetooth LE:

This is how it looks like when converted in executable code:

NOTE: don’t forget to run the Node.js script as sudo, on some systems the hardware interfaces aren’t accessible to not-sudoer users.

I reused the A-Frame based sandbox inherited from my previous hack. In this way, I was able to shape the Google Daydream controller packets on the Ubuntu Desktop quite easily.

(Google Daydream Controller Desktop Driver Stack)

As soon as I started to receive the data, I filtered and exposed it on-the-fly through a local http server: imagine how powerful it can be to manipulate things with architecture.

Google Daydream Controller Hacked (Running on Linux | Ubuntu 14.04 LTS)

As you may have noticed, the prospects of this interaction are countless. Thanks to the cross-platform nature of Node.js and its versatility, soon we will be able to run Google Daydream controller on any kind of device.

Stay tuned.

Did you miss the beginning? Check this out: How I hacked Google Daydream controller (Part I)
Or… Maybe you are interested in watching two Google Daydream controllers running at the same time: How I hacked Google Daydream controller (Part III).

Hacker Noon is how hackers start their afternoons. We’re a part of the @AMI family. We are now accepting submissions and happy to discuss advertising & sponsorship opportunities.
If you enjoyed this story, we recommend reading our latest tech stories and trending tech stories. Until next time, don’t take the realities of the world for granted!