paint-brush
How I hacked Google Daydream controller (Part II)by@matteopisani91
2,621 reads
2,621 reads

How I hacked Google Daydream controller (Part II)

by Matteo P.December 27th, 2016
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Developing compatibility across multiple platforms.

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - How I hacked Google Daydream controller (Part II)
Matteo P. HackerNoon profile picture

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 (github.com/sandeepmistry/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:

#!/bin/shapt-get update  # To get the latest package listscurl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -apt-get install -y nodejs 

# Cleaningsapt-get cleanapt-get autocleanapt-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).