AGX Dynamics 2.42.3.1
Loading...
Searching...
No Matches
agxIO::JoystickListener Class Reference

Class that can be used to listen to events generated by a GamePad or Joystick. More...

#include <Joystick.h>

+ Inheritance diagram for agxIO::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.
 
 JoystickListener (int mask)
 Create joystick listener given a callback mask (default ALL).
 
virtual void addNotification ()
 Called when this listener has been added to a JoystickManager.
 
virtual bool axisUpdate (const agxIO::JoystickState &state, int axis)
 Called when the manager has a new joystick state.
 
virtual bool buttonChanged (const agxIO::JoystickState &state, int button, bool down)
 Called when button button changed state.
 
int getMask () const
 
virtual bool povMoved (const agxIO::JoystickState &state, int pov)
 Called when POV button pov has changed state.
 
virtual void removeNotification ()
 Called when this listener has been removed from a JoystickManager.
 
void setMask (int mask)
 Assign new callback mask to this listener.
 
virtual bool sliderMoved (const agxIO::JoystickState &state, int slider)
 Called when slider slider has changed state.
 
- Public Member Functions inherited from agx::Referenced
 Referenced ()
 Default constructor.
 
 Referenced (const Referenced &)
 
template<typename T >
T * as ()
 Subclass casting.
 
template<typename T >
const T * as () const
 
template<typename T >
T * asSafe ()
 Safe subclass casting, return nullptr if template type does not match.
 
template<typename T >
const T * asSafe () const
 
int getReferenceCount () const
 
template<typename T >
bool is () const
 Subclass test.
 
Referenced & operator= (const Referenced &)
 Assignment operator. Will increment the number of references to the referenced object.
 
void reference (void *ptr=nullptr) const
 Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it.
 
void unreference (void *ptr=nullptr) const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it.
 
void unreference_nodelete () const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it.
 

Protected Member Functions

virtual ~JoystickListener ()
 
JoystickManager * getManager ()
 
const JoystickManager * getManager () const
 
- Protected Member Functions inherited from agx::Referenced
virtual ~Referenced ()
 Destructor.
 
void allocateObserverVector () const
 
void deleteUsingDeleteHandler () const
 

Additional Inherited Members

- Static Public Member Functions inherited from agx::Referenced
template<typename T >
static bool ValidateCast (const Referenced *object)
 
- Static Protected Member Functions inherited from agx::Referenced
static DeleteHandler * getDeleteHandler ()
 
static void setDeleteHandler (DeleteHandler *handler)
 Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to.
 
- Protected Attributes inherited from agx::Referenced
Mutex m_mutex
 
ObserverContainer m_observers
 
AtomicValue m_refCount
 

Detailed Description

Class that can be used to listen to events generated by a GamePad or Joystick.

Override the virtual methods to receive events with the current state of the device.

Definition at line 203 of file Joystick.h.

Member Enumeration Documentation

◆ CallbackMask

Enumerator
BUTTON 
AXIS 
POV 
SLIDER 
ALL 

Definition at line 206 of file Joystick.h.

Constructor & Destructor Documentation

◆ JoystickListener() [1/2]

agxIO::JoystickListener::JoystickListener ( )
inline

Default constructor for a joystick listener.

Default listens to all.

Definition at line 221 of file Joystick.h.

◆ JoystickListener() [2/2]

agxIO::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 228 of file Joystick.h.

◆ ~JoystickListener()

virtual agxIO::JoystickListener::~JoystickListener ( )
inlineprotectedvirtual

Definition at line 287 of file Joystick.h.

Member Function Documentation

◆ addNotification()

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

Called when this listener has been added to a JoystickManager.

Definition at line 268 of file Joystick.h.

◆ axisUpdate()

virtual bool agxIO::JoystickListener::axisUpdate ( const agxIO::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

◆ buttonChanged()

virtual bool agxIO::JoystickListener::buttonChanged ( const agxIO::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

◆ getManager() [1/2]

JoystickManager * agxIO::JoystickListener::getManager ( )
inlineprotected
Returns
the manager managing this listener

Definition at line 292 of file Joystick.h.

◆ getManager() [2/2]

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

Definition at line 293 of file Joystick.h.

◆ getMask()

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

Definition at line 284 of file Joystick.h.

References agxSDK::EventListener::m_mask.

◆ povMoved()

virtual bool agxIO::JoystickListener::povMoved ( const agxIO::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

◆ removeNotification()

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

Called when this listener has been removed from a JoystickManager.

Definition at line 273 of file Joystick.h.

◆ setMask()

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

Assign new callback mask to this listener.

Parameters
mask- new callback mask

Definition at line 279 of file Joystick.h.

◆ sliderMoved()

virtual bool agxIO::JoystickListener::sliderMoved ( const agxIO::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

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