Controller Class Reference

#include <Controller.h>

Inherits ControllerInterface.

Collaboration diagram for Controller:

List of all members.


Public Member Functions

virtual ~Controller ()
int getNumberOfButtons ()
int getNumberOfAxes ()
int getNumberOfSensors ()
int getButtonValue (int idx)
float getAxisValue (int idx)
SensorData getSensorValue (int idx)
void setPhysicalToWorldScale (float scaleValue)
float getPhysicalToWorldScale ()
void update ()
bool registerButtonChangeCallback (AbstractControllerButtonChangeCB *callback)
bool unregisterButtonChangeCallback (AbstractControllerButtonChangeCB *callback)
InputDevicegetInputDevice (unsigned int index)
bool setButtonMapping (int buttonIndex, const DeviceIndexMapping &mapping)
bool setAxisMapping (int axisIndex, const DeviceIndexMapping &mapping)
bool setSensorMapping (int sensorIndex, const DeviceIndexMapping &mapping)
bool setButtonCorrection (int buttonIndex, const ButtonCorrection &correction)
bool setAxisCorrection (int axisIndex, const AxisCorrection &correction)
bool setSensorCorrection (int sensorIndex, const SensorCorrection &correction)
const DeviceIndexMappinggetButtonMapping (int buttonIndex) const
const DeviceIndexMappinggetAxisMapping (int axisIndex) const
const DeviceIndexMappinggetSensorMapping (int sensorIndex) const
const ButtonCorrectiongetButtonCorrection (int buttonIndex) const
const AxisCorrectiongetAxisCorrection (int axisIndex) const
const SensorCorrectiongetSensorCorrection (int sensorIndex) const

Private Types

typedef std::pair< int, int > ButtonState

Private Member Functions

 Controller ()
Controlleroperator= (const Controller &src)
 Controller (const Controller &src)
void init (int numButtons, int numAxes, int numSensors)
void addDevice (InputDevice *dev)
void swap (const std::auto_ptr< Controller > &rhs)
void deviceButtonChangeNotification (int deviceIndex, int buttonIndex, int newButtonValue)
void executeDelayedCallbacks ()
void executeButtonChangeCallbacks (int buttonIndex, int newButtonValue)
int findControllerButtonIndex (const DeviceIndexMapping &deviceButton)

Private Attributes

bool inUpdate
int nButtons
int nAxes
int nSensors
std::map< unsigned int,
DeviceIndexMapping
buttonMapping
std::map< unsigned int,
DeviceIndexMapping
axisMapping
std::map< unsigned int,
DeviceIndexMapping
sensorMapping
std::map< unsigned int,
ButtonCorrection
buttonCorrections
std::map< unsigned int,
AxisCorrection
axisCorrections
std::map< unsigned int,
SensorCorrection
sensorCorrections
float physicalToWorldScale
std::vector< InputDevice * > devices
OSG::Lock * inputDataLock
OSG::Lock * callbackLock
std::vector
< AbstractControllerButtonChangeCB * > 
buttonChangeCallbacks
std::vector< ButtonStatedelayedButtonChangeCallbacks

Friends

class ControllerManager
class InputDevice

Member Typedef Documentation

typedef std::pair<int, int> Controller::ButtonState [private]


Constructor & Destructor Documentation

Controller::~Controller (  )  [virtual]

Destructor

OSG_USING_NAMESPACE Controller::Controller (  )  [private]

Default constructor

Controller::Controller ( const Controller src  )  [private]


Member Function Documentation

void Controller::addDevice ( InputDevice dev  )  [private]

Adds a new inputDevice to the controller

void Controller::deviceButtonChangeNotification ( int  deviceIndex,
int  buttonIndex,
int  newButtonValue 
) [private]

Is called by InputDevice as soon as a button has changed its value. The method then checks if the button is part of the controller and if so it invokes all registered buttonChangeCallbacks.

void Controller::executeButtonChangeCallbacks ( int  buttonIndex,
int  newButtonValue 
) [private]

Invokes all registered button change callbacks.

void Controller::executeDelayedCallbacks (  )  [private]

This method is called after the update method has finished in order to execute callbacks which had to be delayed because of deadlock prevention

int Controller::findControllerButtonIndex ( const DeviceIndexMapping deviceButton  )  [private]

Returns the index of the passed device button in the controller. If the device button is not mapped to a controller button the method returns -1

const AxisCorrection & Controller::getAxisCorrection ( int  axisIndex  )  const

Returns the correction for the controller axis with the passed index

const DeviceIndexMapping & Controller::getAxisMapping ( int  axisIndex  )  const

Returns the mapping for the controller axis with the passed index

float Controller::getAxisValue ( int  idx  )  [virtual]

Returns the value of the axis with the passed index. If no axis with the passed index exists the method returns 0

Implements ControllerInterface.

const ButtonCorrection & Controller::getButtonCorrection ( int  buttonIndex  )  const

Returns the correction for the controller button with the passed index

const DeviceIndexMapping & Controller::getButtonMapping ( int  buttonIndex  )  const

Returns the mapping for the controller button with the passed index

int Controller::getButtonValue ( int  idx  )  [virtual]

Returns the value of the button with the passed index. If no button with the passed index exists the method returns 0

Implements ControllerInterface.

InputDevice* Controller::getInputDevice ( unsigned int  index  ) 

Returns the InputDevice with the passed index

int Controller::getNumberOfAxes (  )  [virtual]

Returns the number of axes provided by the controller

Implements ControllerInterface.

int Controller::getNumberOfButtons (  )  [virtual]

Returns the number of buttons provided by the controller

Implements ControllerInterface.

int Controller::getNumberOfSensors (  )  [virtual]

Returns the number of sensors provided by the controller

Implements ControllerInterface.

float Controller::getPhysicalToWorldScale (  )  [virtual]

Returns the scale factor for sensor values from physical units (e.g. centimeters) to world units (units used by the application).

Implements ControllerInterface.

const SensorCorrection & Controller::getSensorCorrection ( int  sensorIndex  )  const

Returns the correction for the controller sensor with the passed index

const DeviceIndexMapping & Controller::getSensorMapping ( int  sensorIndex  )  const

Returns the mapping for the controller sensor with the passed index

SensorData Controller::getSensorValue ( int  idx  )  [virtual]

Returns the value of the sensor with the passed index. If no sensor with the passed index exists the method returns the identity transformation

Implements ControllerInterface.

void Controller::init ( int  numButtons,
int  numAxes,
int  numSensors 
) [private]

Define the number of buttons, axes and sensors for the controller

Controller& Controller::operator= ( const Controller src  )  [private]

bool Controller::registerButtonChangeCallback ( AbstractControllerButtonChangeCB callback  )  [virtual]

Registers a callback-function for changes on the controller buttons

Implements ControllerInterface.

bool Controller::setAxisCorrection ( int  axisIndex,
const AxisCorrection correction 
)

Sets the correction for the axis with the passed index

bool Controller::setAxisMapping ( int  axisIndex,
const DeviceIndexMapping mapping 
)

Sets the mapping for the controller axis with the passed index to the according device axis

bool Controller::setButtonCorrection ( int  buttonIndex,
const ButtonCorrection correction 
)

Sets the correction for the button with the passed index

bool Controller::setButtonMapping ( int  buttonIndex,
const DeviceIndexMapping mapping 
)

Sets the mapping for the controller button with the passed index to the according device button

void Controller::setPhysicalToWorldScale ( float  scaleValue  )  [virtual]

Sets the scale factor for sensor values (obtained from tracking systems) from physical units (e.g. centimeters) to world units (units used by the application).

Implements ControllerInterface.

bool Controller::setSensorCorrection ( int  sensorIndex,
const SensorCorrection correction 
)

Sets the correction for the sensor with the passed index

bool Controller::setSensorMapping ( int  sensorIndex,
const DeviceIndexMapping mapping 
)

Sets the mapping for the controller sensor with the passed index to the according device sensor

void Controller::swap ( const std::auto_ptr< Controller > &  rhs  )  [private]

Swaps the data between the passed controller and the current one

bool Controller::unregisterButtonChangeCallback ( AbstractControllerButtonChangeCB callback  )  [virtual]

Unregisters a callback-function for changes on the controller buttons

Implements ControllerInterface.

void Controller::update (  )  [virtual]

Calls the update method on all input devices. This method can be used by input devices which are based on polling mechanisms to update their internal state.

Implements ControllerInterface.


Friends And Related Function Documentation

friend class ControllerManager [friend]

friend class InputDevice [friend]


Member Data Documentation

std::map<unsigned int, AxisCorrection> Controller::axisCorrections [private]

std::map<unsigned int, DeviceIndexMapping> Controller::axisMapping [private]

std::map<unsigned int, ButtonCorrection> Controller::buttonCorrections [private]

std::map<unsigned int, DeviceIndexMapping> Controller::buttonMapping [private]

OSG::Lock* Controller::callbackLock [private]

std::vector<InputDevice*> Controller::devices [private]

OSG::Lock* Controller::inputDataLock [private]

bool Controller::inUpdate [private]

int Controller::nAxes [private]

int Controller::nButtons [private]

int Controller::nSensors [private]

std::map<unsigned int, SensorCorrection> Controller::sensorCorrections [private]

std::map<unsigned int, DeviceIndexMapping> Controller::sensorMapping [private]


The documentation for this class was generated from the following files:

Generated on Wed Oct 20 16:11:55 2010 for inVRs by doxygen 1.5.8