R & D, Downloads, Source Code

bcchang.com / Research / VR / Downloads

JoystickNavigator YG Node

For simple Ygdrasil setups without 3D tracking, you don't need to run trackd at all. For input, you can use this YG Node as a Navigator to move around your scene. It behaves just like the regular caveNavigator node, but reads directly from the joystick port (/dev/js0). To make the buttons work, also include the DummyWand node. The wand node has to generate button events, which normally come from trackd - the DummyWand just broadcasts them from the JoystickNavigator.

JoystickNavigator.cxx9.76 KbJuly 10 2006 11:38:06 PMC++ Source file
JoystickNavigator.h1.51 KbJuly 10 2006 11:39:39 PMC++ header file
JoystickNavigator.so311.19 KbJuly 10 2006 11:37:40 PMprecompiled DSO
DummyWand.cxx1.66 KbJuly 11 2006 12:06:31 AMC++ Source file
DummyWand.h0.36 KbJuly 11 2006 12:06:30 AMC++ header file
DummyWand.so222.35 KbJuly 11 2006 12:06:30 AMprecompiled DSO

Usage

Open the User file. replace the caveNavigator node with the JoystickNavigator. Replace the caveWand node with a DummyWand.
user User0 () { JoystickNavigator navigatorUser0 ( acceleration(1), friction(.75), remapButton (1 1), remapButton(2 1), remapButton(3 1), remapButton(4 1) ) //caveHead headUser0 () caveTracker wandTrackerUser0 (sensor(1)) { DummyWand wandUser0 ( when(button1,print(button 1)), when(button2,print(button 2)), when(button3,print(button 3)), when(button4,print(button 4)) ) { light (position (0 0 0 1),diffuse(.6 .6 .6) ) } } }
The JoystickNavigator has a couple of extra messages:

  • acceleration(float) : control how fast you accelerate
  • rotAcceleration(float) : control how fast you rotate
  • friction(float) : control how fast you slow down
  • remapButton(from, to) : remap buttons on the gamepad. Use this, for instance, to make all buttons appear to be button 1.