// Description: creates a wand that detects CAVE wand button events
//
//notes:
//
//- derived nodes inherit all messages from their base classes
//
- see reset method for default settings
//
- this node can also be created with the alias: CAVEWand
//
- this node should be a child of a ygCAVETracker node
//
- this node is required for wandTrigger node detection
//
- when pressed this node generates buttonX events where X is the button number
//
- when released this node generates buttonUpX events where X is the button number
//
//
// Category: User
// Author: Dave Pape
// Revision: 11/01/01
//
#include
#include "DummyWand.h"
extern "C" ygNode* construct_DummyWand(const char* name,bool master) { return new DummyWand(name,master); }
struct _DummyWandPrivateData
{
int prevState[CAVE_MAX_BUTTONS];
};
DummyWand::DummyWand(const char* name,bool master) : ygWand(name,master)
{
int i;
setClassName("DummyWand");
p_ = new struct _DummyWandPrivateData;
for (i=0; i < CAVE_MAX_BUTTONS; i++)
p_->prevState[i] = 0;
}
void DummyWand::reset(void)
{
int i;
//for each CAVE button set the previous state to zero
for (i=0; i < CAVE_MAX_BUTTONS; i++)
p_->prevState[i] = 0;
ygWand::reset();
}
void DummyWand::setButton (int button,int value)
{
char flagName[16];
if (value && !p_->prevState[button])
{
sprintf (flagName,"button%d",button+1);
setFlag(flagName);
}
else if (!value && p_->prevState[button])
{
sprintf(flagName,"buttonUp%d",button+1);
setFlag(flagName);
}
p_->prevState[button] = value;
}
void DummyWand::app(void)
{
ygWand::app();
}