17 #ifndef AGXSENSOR_JOYSTICK_H
18 #define AGXSENSOR_JOYSTICK_H
53 CENTERED = 0x00000000,
58 NORTHEAST = 0x00000101,
59 SOUTHEAST = 0x00000110,
60 NORTHWEST = 0x00001001,
61 SOUTHWEST = 0x00001010
80 State(
const OIS::JoyStickState& oisState );
137 OIS::JoyStick* m_oisJoystick;
140 bool m_forceFeedbackFound;
152 CENTERED = 0x00000000,
157 NORTHEAST = 0x00000101,
158 SOUTHEAST = 0x00000110,
159 NORTHWEST = 0x00001001,
160 SOUTHWEST = 0x00001010
211 : m_mask( ALL ), m_manager( nullptr ) {}
218 : m_mask( mask ), m_manager( nullptr ) {}
331 bool valid()
const {
return m_initialized; }
383 OIS::JoyStick* m_oisJoystick;
Simulation * getSimulation()
Derive from this class to implement a listener for simulation step events.
JoystickListener()
Default constructor for a joystick listener.
virtual bool axisUpdate(const agxSensor::JoystickState &state, int axis)
Called when the manager has a new joystick state.
virtual bool buttonChanged(const agxSensor::JoystickState &state, int button, bool down)
Called when button button changed state.
virtual void removeNotification()
Called when this listener has been removed from a JoystickManager.
virtual bool sliderMoved(const agxSensor::JoystickState &state, int slider)
Called when slider slider has changed state.
virtual void addNotification()
Called when this listener has been added to a JoystickManager.
void setMask(int mask)
Assign new callback mask to this listener.
virtual bool povMoved(const agxSensor::JoystickState &state, int pov)
Called when POV button pov has changed state.
const JoystickManager * getManager() const
virtual ~JoystickListener()
JoystickListener(int mask)
Create joystick listener given a callback mask (default ALL).
JoystickManager * getManager()
virtual void pre(const agx::TimeStamp &)
Makes a capture of the joystick and fires callbacks.
virtual void addNotification()
Creates the device if not already created.
bool inSimulation() const
virtual void povCallback(const agxSensor::JoystickState &state, int pov)
Internal method.
virtual void buttonCallback(const agxSensor::JoystickState &state, int button, bool down)
Internal method.
JoystickManager(intptr_t hwnd)
virtual void removeNotification()
Destroys the device and all listeners.
virtual ~JoystickManager()
bool remove(JoystickListener *listener)
Remove joystick listener.
agx::Real normalize(int axisValue) const
Normalizes axis value [-1, 1].
JoystickState getState() const
bool add(JoystickListener *listener)
Add new joystick listener.
Pov
Bit masks indicating the state of the POV button.
agx::Int32Vector axes
Contains the values for all axes.
JoystickState(const OIS::JoyStickState &oisState)
Contains the values for all vector3s.
agx::BoolVector buttons
Contains the state (in/out) of all buttons.
Class for storing a Joystick state.
agx::BoolVector buttons
Contains the state (in/out) of all buttons.
Pov
Bitmasks indicating the state of the POV button.
agx::Int32Vector axes
Contains the values for all axes.
State(const OIS::JoyStickState &oisState)
Copies state from device driver.
Joystick interface for gamepads etc.
agx::Real normalize(int axisValue) const
Normalizes axis value [-1, 1].
virtual bool povMoved(const State &arg, int pov)=0
Called whenever an POV button is moved.
virtual bool sliderMoved(const State &arg, int index)=0
Called whenever an slider is moved.
virtual void pre(const agx::TimeStamp &)
Called before a step is taken in the simulation Implement this method in the derived class to get cal...
virtual bool axisMoved(const State &arg, int axis)=0
Called whenever an axis control is moved.
virtual void addNotification()
Called when this listener is added to the simulation.
bool init()
Initializes the joystick.
virtual void removeNotification()
Called when this listener is removed from the simulation.
virtual bool buttonChanged(const State &arg, int button, bool down)=0
Called whenever a button is pressed or released on a Joystick.
Base class providing referencing counted objects.
Vector containing 'raw' data.
Smart pointer for handling referenced counted objects.
#define DOXYGEN_END_INTERNAL_BLOCK()
#define DOXYGEN_START_INTERNAL_BLOCK()
The agxSensor namespace contains drivers for reading for devices such as Gamepad.
agx::HashVector< JoystickListener *, JoystickListenerRef > JoystickListenerContainer
agx::ref_ptr< JoystickManager > JoystickManagerRef
agx::ref_ptr< JoystickListener > JoystickListenerRef