March 30, 2012

This is my minimalist Open Sound Control program for the Sixense
TrueMotion/Razer Hydra controller. It has been compiled for Windows, but
Linux and Mac SDKs have recently been made available. I don't know if I'll
get around to compiling for those OSs. Currently, it sends UDP packets
over port 7022. This is the complete list of messages. The entire physical
state of both controllers is accessible at 250 Hz; prepend "/l" or "/r" to
the name of each message for left or right controller data respectively.

Name   Type   Meaning
----   ----   -------
/p/x   float  position along x axis
/p/y   float  position along y axis
/p/z   float  position along z axis
/j/x   int32  left/right joystick position
/j/y   int32  up/down joystick position
/t/t   int32  trigger position
/b/1   int32  button 1: 1 if pressed, 0 if not
/b/2   int32  button 2: 1 if pressed, 0 if not
/b/3   int32  button 3: 1 if pressed, 0 if not
/b/4   int32  button 4: 1 if pressed, 0 if not
/b/s   int32  start button: 1 if pressed, 0 if not
/b/b   int32  bumper: 1 if pressed, 0 if not
/b/j   int32  joystick button: 1 if pressed, 0 if not
/r/x   float  rotation around x axis   \
/r/y   float  rotation around y axis    \ rotation angles
/r/z   float  rotation around z axis    /(quaternion form)
/r/q   float  I think this is always 1 /
/0/0   float  x component of rotated x axis
/0/1   float  y component of rotated x axis
/0/2   float  z component of rotated x axis
/1/0   float  x component of rotated y axis
/1/1   float  y component of rotated y axis
/1/2   float  z component of rotated y axis
/2/0   float  x component of rotated z axis
/2/1   float  y component of rotated z axis
/2/2   float  z component of rotated z axis

Please refer to the SDK PDFs and OSCl+r.cpp for a better understanding.
Speaking of which, I compiled this using CodeBlocks with MinGW on Windows
7. If you wish to modify this, you need to tell the compiler to link with:

WS2_32.Lib (I found it somewhere deep in my computer already)
SDK\lib\win32\release_dll\sixense.lib
SDK\lib\win32\release_dll\sixense_utils.lib
libglfw.a
libopengl32.a

I had to make a few small modifications to the oscpkt library for it to
work with MinGW for me. If you want the original files, just Google it.
Credit goes to its author, of course. Also, you might find that you want to
disable the mouse emulation and motion filtering. You'll have to see the
Sixense forums about that. Sorry. I forget, and maybe the method's changed.

Hopefully, someone can figure out how the rotation axes are positioned
compared to the handle of the controller. /r/z in particular seems weird.
Lastly, please spread! The Hydra has huge musical potential. Obviously, it
can be difficult to play (like theremins), but it'd make great research.