Wednesday 2 October 2013

Step One - Will it work?


Before I spend too much time on this project I wanted to test out some unknowns to see if the whole thing is possible. My first concern, will the HDMI output on the iPhone work without too much latency? To test this I quickly fired up real racing 3 and connected the Oculus to the HDMI lightning adapter on the phone.  I put on the oculus, closed one eye (to stop going cross-eyed), and did a lap. I'm pleased to say that it worked better than expected! The framerate was great, the iPhone was outputting at full 1080p (downscaled by the rift) so pixelation wasn't bad. The control latency was the same as playing on the iPhone screen. Real racing is controlled by the accelerometer so I find there is some latency there, probably due to averaging/filtering. The important thing was it seemed the same as the native screen. So I can tick that off as working.
Next I wanted to see If I can power all the kit from a cheap USB battery extender I have. I plugged everything in, apart from the iPhone (it has its own battery), and for a second it seemed to work. Then everything went dead! Dam I've bricked my Oculus dev kit! Or so I thought! Turns out that the battery extender turns itself off if it doesn't detect enough load on the USB ports! So the kit was drawing so little power it just turned itself off. I presume this is to save power when it thinks devices are charged. I simply plugged in the iPhone and that tipped the balance to keep it on. I left it for 45mins running off the battery extender, it dropped from 3/4 full to half. Could that mean I will have three hours of mobile playtime! Thats great for such a cheap extender. So I think we're looking good on the power front.


Here comes my first development step. I decided to get data from a PS3 move navigation controller into an iPhone app. Why not an xbox controller you ask? Well I really want to use the iPhone itself as part of the control mechanism, so the navigation controller is a perfect partner to that. I will post more about using the iPhone as a controller later (I have big plans for this). But why do the controller first? Get on and do the Oculus you say? Since their both USB HID (human interface device) they have quite a lot in common. After quickly downloading some PS3 controller sample code, I was able to hack together something that worked. Drum roll please.... I give you a USB controller to iPhone bridge... This is exciting in itself, imagine being able to plug in any USB controller to your iPhone, making a non-wireless controller wireless at the same time. Combine this with Apple TV or the HDMI adaptor and you have a mini games console! I think I'll write an iPhone controller SDK for this.
Here comes the bad news.. The datarate I'm getting via the Bluetooth LE transfer is pretty low. It doesn't look like I will be able to send the full dataset from the oculus rift. There maybe other work I can do to improve the rates but that will require some work on a lower level. For now I will do the sensor fusion on the Arduino and just send the roll pitch and yaw. I should be able to send that at 30-60 frames per second along with the controller data. Now we're cooking.

Monday 30 September 2013

The Plan - Sensor Fusion Hardware

Apple guard their hardware closely, to build accessories for the iPhone you need to join the Made For iPhone (MFI) program. This helps keep the quality up to scratch but is a pain for the hobbyist! Enter the wonderful world of bluetooth low energy (Bluetooth 4.0 LE). The library needed to communicate with Bluetooth LE devices is part of the standard Apple SDK. No need to join the Apple MFI, this is my way in...
So the Plan is to develop a Bluetooth LE device that can plug into the Oculus rift and act as a bridge to send the data to the iPhone. Since the Rift is a HID USB device, I might as well make this bridge generic enough to support controllers as well. This will handle the data connection, the next thing I need is a power source. Lucky the Oculus is a relatively low powered device, this will allow me to use a simple USB battery power extender from ebay. If all goes well I should have a few hours of wireless rifting between charges. Stay tuned for more detail.  

Friday 13 September 2013

Oculus Rift for the iPhone


I've had my Oculus Rift for a few days now, I must say I'm blown away. This is the next step in gaming for sure. This provides a problem for me, I am an iPhone developer by day and I have a strong belief in "The one device". That is, a device that can do everything, be my laptop, be my media player, be my TV.... you get the idea. The usage that now presents a problem is I want my "one device" to be my games console. So if the rift is the future, my one device has to support it. Here comes the bad news, my "one device" is my iPhone and the iPhone has zero support for the oculus rift. It seems Oculus VR are concentrating on desktop support so they are not going to add support for it anytime soon. Now by zero support I mean zero, the rift has a USB connection (requiring USB host) for the head tracking data, and an HDMI connection for the image, neither of which the iPhone supports. Now I could go out and buy an Android device which has both of these features, however as much as I've tried to use Android, its just not as good at my everyday tasks. So now I get to the point of this blog. I am going to add iPhone support to the Oculus Rift.