GlovePie is basically a device bridge. It takes input signals from one device and translates them into output signals from a different device. That means that you can take lots of VR and game controllers and use them to control software that does not have native support for that particular device - like using a Wiimote to control a FPS game.
GlovePie has an extensive list of natively supported input devices. But what do you do if you are developing your own input device and you want to bridge it through GlovePie? Well either by luck or by design, GlovePie has a generic interface that you can use to generate input signals. GlovePie supports a little-known interface called OSC (Open Sound Control) that was (stangely enough) created for controlling sound equipment - parallel to MIDI, but is generic enough that it can be co-opted for other uses. GlovePie uses a network version of OSC that is built on top of UDP so it's easy to implement, and you can find open-source implementations of OSC for many languages. This tutorial uses the Bespoke OSC library that is built for C#.
http://www.bespokesoftware.org/wordpress/?page_id=69
In OSC you pass data as messages that are identified by a particular URL-like name. The protocol is not picky about the names so you can define just about any name you want and assign a data packet to it. So for example I might define a data message called "/head/yaw" or "/move/speed" or whatever is appropriate for your device. Then you fill that message with a value. Values can have a variety of types like floats or integers or even strings. The Bespoke API takes care of all the data packaging so you don't need to know the protocol details. You just call a "send" function with a message name and some data and the library will transmit the OSC message.
Here is some sample code to transmit an OSC message to GlovePie on the same machine.
Code: Select all
using System.Net;
using Bespoke.Common.Osc;
static class Program {
static void Main() {
OscPacket.LittleEndianByteOrder = false; // crucial for correct Intel interpretation
// Set the local address. Since this is UDP we don't have to establish a connection.
IPEndPoint myapp = new IPEndPoint(IPAddress.Loopback, 1944);
IPEndPoint glovepie = new IPEndPoint(IPAddress.Loopback, 1945);
// Send our message to GlovePie. How simple is that !!
OscMessage msg = new OscMessage(myapp, "/move/speed", 10.0f);
msg.Send(glovepie);
}
}
Code: Select all
Osc1.ListenPort = 1945;
Osc1.listening = true;
var.move.speed = Osc1.move.speed;
Keyboard.W = (var.move.speed > 5);
That's about it. Hopefully some good head trackers or guns or free-motion controllers will come out of this. (anybody want to take a shot at the Sparkfun Razor? )