AGXDynamics  2.31.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
agxSensor::JoystickListener Class Reference

#include <Joystick.h>

+ Inheritance diagram for agxSensor::JoystickListener:

Public Types

enum  CallbackMask {
  BUTTON = (1<<0), AXIS = (1<<1), POV = (1<<2), SLIDER = (1<<3),
  ALL
}
 

Public Member Functions

 JoystickListener ()
 Default constructor for a joystick listener. More...
 
 JoystickListener (int mask)
 Create joystick listener given a callback mask (default ALL). More...
 
virtual void addNotification ()
 Called when this listener has been added to a JoystickManager. More...
 
template<typename T >
T * as ()
 Subclass casting. More...
 
template<typename T >
const T * as () const
 
template<typename T >
T * asSafe ()
 Safe subclass casting, return nullptr if template type does not match. More...
 
template<typename T >
const T * asSafe () const
 
virtual bool axisUpdate (const agxSensor::JoystickState &state, int axis)
 Called when the manager has a new joystick state. More...
 
virtual bool buttonChanged (const agxSensor::JoystickState &state, int button, bool down)
 Called when button button changed state. More...
 
int getMask () const
 
int getReferenceCount () const
 
template<typename T >
bool is () const
 Subclass test. More...
 
virtual bool povMoved (const agxSensor::JoystickState &state, int pov)
 Called when POV button pov has changed state. More...
 
void reference (void *ptr=nullptr) const
 Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it. More...
 
virtual void removeNotification ()
 Called when this listener has been removed from a JoystickManager. More...
 
void setMask (int mask)
 Assign new callback mask to this listener. More...
 
virtual bool sliderMoved (const agxSensor::JoystickState &state, int slider)
 Called when slider slider has changed state. More...
 
void unreference (void *ptr=nullptr) const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
void unreference_nodelete () const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 

Static Public Member Functions

template<typename T >
static bool ValidateCast (const Referenced *object)
 

Protected Member Functions

virtual ~JoystickListener ()
 
void allocateObserverVector () const
 
void deleteUsingDeleteHandler () const
 
JoystickManager * getManager ()
 
const JoystickManager * getManager () const
 

Static Protected Member Functions

static DeleteHandler * getDeleteHandler ()
 
static void setDeleteHandler (DeleteHandler *handler)
 Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to. More...
 

Protected Attributes

Mutex m_mutex
 
ObserverContainer m_observers
 
AtomicValue m_refCount
 

Detailed Description

Definition at line 191 of file Joystick.h.

Member Enumeration Documentation

Enumerator
BUTTON 
AXIS 
POV 
SLIDER 
ALL 

Definition at line 194 of file Joystick.h.

Constructor & Destructor Documentation

agxSensor::JoystickListener::JoystickListener ( )
inline

Default constructor for a joystick listener.

Default listens to all.

Definition at line 211 of file Joystick.h.

agxSensor::JoystickListener::JoystickListener ( int  mask)
inline

Create joystick listener given a callback mask (default ALL).

Parameters
mask- callback mask (e.g., AXIS or (BUTTON | AXIS))

Definition at line 218 of file Joystick.h.

virtual agxSensor::JoystickListener::~JoystickListener ( )
inlineprotectedvirtual

Definition at line 285 of file Joystick.h.

Member Function Documentation

virtual void agxSensor::JoystickListener::addNotification ( )
inlinevirtual

Called when this listener has been added to a JoystickManager.

Definition at line 266 of file Joystick.h.

void agx::Referenced::allocateObserverVector ( ) const
protectedinherited
template<typename T >
T* agx::Referenced::as ( )
inherited

Subclass casting.

Template type must match actual type, dynamic_cast assertion will fail otherwise.

Referenced by agx::InternalData::get(), agxVehicle::Track::getNode(), and agx::InternalData::getOrCreate().

template<typename T >
const T* agx::Referenced::as ( ) const
inherited
template<typename T >
T* agx::Referenced::asSafe ( )
inherited

Safe subclass casting, return nullptr if template type does not match.

Referenced by agxUtil::CollectBodiesAndWiresVisitor::visit().

template<typename T >
const T* agx::Referenced::asSafe ( ) const
inherited
virtual bool agxSensor::JoystickListener::axisUpdate ( const agxSensor::JoystickState &  state,
int  axis 
)
virtual

Called when the manager has a new joystick state.

This means that the value of the axis could be identical between different calls.

Parameters
state- current state of the joystick
axis- axis to check
Returns
true if this listener used this axis value (no other listeners will receive this call) - otherwise false
virtual bool agxSensor::JoystickListener::buttonChanged ( const agxSensor::JoystickState &  state,
int  button,
bool  down 
)
virtual

Called when button button changed state.

Parameters
state- current state of the joystick
button- the button pressed or released
down- true if button is down, otherwise false
Returns
true if this listener used this button (no other listeners will receive this call) - otherwise false
void agx::Referenced::deleteUsingDeleteHandler ( ) const
protectedinherited
static DeleteHandler* agx::Referenced::getDeleteHandler ( )
staticprotectedinherited
Returns
a DeleteHandler.
JoystickManager* agxSensor::JoystickListener::getManager ( )
inlineprotected
Returns
the manager managing this listener

Definition at line 290 of file Joystick.h.

const JoystickManager* agxSensor::JoystickListener::getManager ( ) const
inlineprotected

Definition at line 291 of file Joystick.h.

int agxSensor::JoystickListener::getMask ( ) const
inline
Returns
current callback mask

Definition at line 282 of file Joystick.h.

int agx::Referenced::getReferenceCount ( ) const
inherited
Returns
the number pointers currently referencing this object.
template<typename T >
bool agx::Referenced::is ( ) const
inherited
virtual bool agxSensor::JoystickListener::povMoved ( const agxSensor::JoystickState &  state,
int  pov 
)
virtual

Called when POV button pov has changed state.

Parameters
state- current joystick state
pov- POV that has changed state (state.pov[pov])
Returns
true if this listener used this POV value (no other listeners will receive this call) - otherwise false
void agx::Referenced::reference ( void *  ptr = nullptr) const
inherited

Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it.

This method should be used with care, always balanced with the same number of calls to unreference.

Referenced by agxData::Val< UInt >::Val().

virtual void agxSensor::JoystickListener::removeNotification ( )
inlinevirtual

Called when this listener has been removed from a JoystickManager.

Definition at line 271 of file Joystick.h.

static void agx::Referenced::setDeleteHandler ( DeleteHandler *  handler)
staticprotectedinherited

Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to.

void agxSensor::JoystickListener::setMask ( int  mask)
inline

Assign new callback mask to this listener.

Parameters
mask- new callback mask

Definition at line 277 of file Joystick.h.

virtual bool agxSensor::JoystickListener::sliderMoved ( const agxSensor::JoystickState &  state,
int  slider 
)
virtual

Called when slider slider has changed state.

Parameters
state- current joystick state
slider- slider that has changed state (state.slider[pov])
Returns
true if this listener used this slider value (no other listeners will receive this call) - otherwise false
void agx::Referenced::unreference ( void *  ptr = nullptr) const
inherited

Decrement the reference count by one, indicating that a pointer to this object is referencing it.

If the reference count goes to zero, it is assumed that this object is no longer referenced and is automatically deleted.

This method should be used with care, always balanced with the same number of calls to reference.

void agx::Referenced::unreference_nodelete ( ) const
inherited

Decrement the reference count by one, indicating that a pointer to this object is referencing it.

However, do not delete it, even if ref count goes to 0. Warning, unref_nodelete() should only be called if the user knows exactly who will be responsible for, one should prefer unref() over unref_nodelete() as the later can lead to memory leaks.

template<typename T >
static bool agx::Referenced::ValidateCast ( const Referenced *  object)
staticinherited

Member Data Documentation

Mutex agx::Referenced::m_mutex
mutableprotectedinherited

Definition at line 240 of file Referenced.h.

ObserverContainer agx::Referenced::m_observers
mutableprotectedinherited

Definition at line 239 of file Referenced.h.

AtomicValue agx::Referenced::m_refCount
mutableprotectedinherited

Definition at line 241 of file Referenced.h.


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