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.cxx | 9.76 Kb | July 10 2006 11:38:06 PM | C++ Source file |
| JoystickNavigator.h | 1.51 Kb | July 10 2006 11:39:39 PM | C++ header file |
| JoystickNavigator.so | 311.19 Kb | July 10 2006 11:37:40 PM | precompiled DSO |
| DummyWand.cxx | 1.66 Kb | July 11 2006 12:06:31 AM | C++ Source file |
| DummyWand.h | 0.36 Kb | July 11 2006 12:06:30 AM | C++ header file |
| DummyWand.so | 222.35 Kb | July 11 2006 12:06:30 AM | precompiled 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.