VR-Engage  2.2
Loading...
Searching...
No Matches
makVre::DtSDLGameControllerDevice Class Reference

Detailed Description

This class provides support for joystick and gamepad devices, handling axis movement, button presses, and hat switch inputs. It can manage multiple controllers simultaneously, differentiating them by index.

#include <sdlGameControllerDevice.h>

Inheritance diagram for makVre::DtSDLGameControllerDevice:
[legend]

Public Member Functions

 DtSDLGameControllerDevice ()
 
virtual ~DtSDLGameControllerDevice () override
 
virtual bool init (DtVreInputManager &mgr) override
 
virtual void shutdown () override
 
virtual void reportCurrentState () override
 
virtual void tick (double dt) override
 
virtual void addController (int index)
 
virtual void removeController (int id)
 
virtual void processInput (int controller, DtInputType type, int id, float value, int flags=0)
 
virtual void processAxisInput (int controller, int id, int value)
 
virtual const std::map< int, DtInputData > & getControllerData () const
 
- Public Member Functions inherited from makVre::DtInputDevice
 DtInputDevice ()
 
virtual ~DtInputDevice ()
 
 DtInputDevice (const DtInputDevice &mapping)=delete
 
DtInputDeviceoperator= (const DtInputDevice &)=delete
 

Protected Attributes

DtVreInputManagermyManager
 
std::vector< int > myControllers
 
std::map< int, DtInputDatamyControllerData
 
std::map< int, std::map< int, float > > myHatPosition
 
- Protected Attributes inherited from makVre::DtInputDevice
DtVreInputManagermyManager
 

Constructor & Destructor Documentation

◆ DtSDLGameControllerDevice()

makVre::DtSDLGameControllerDevice::DtSDLGameControllerDevice ( )

Default constructor.

Initializes the joystick input device

◆ ~DtSDLGameControllerDevice()

virtual makVre::DtSDLGameControllerDevice::~DtSDLGameControllerDevice ( )
overridevirtual

Virtual destructor.

Cleans up resources owned by the joystick input device

Member Function Documentation

◆ init()

virtual bool makVre::DtSDLGameControllerDevice::init ( DtVreInputManager & mgr)
overridevirtual

Initialize the joystick input device.

Sets up the joystick device with the input manager and initializes controller tracking structures.

Parameters
mgrReference to the input manager that owns this device
Returns
True if initialization succeeded, false otherwise

Implements makVre::DtInputDevice.

◆ shutdown()

virtual void makVre::DtSDLGameControllerDevice::shutdown ( )
overridevirtual

Shut down the joystick input device.

Releases resources and disconnects from any connected controllers

Implements makVre::DtInputDevice.

◆ reportCurrentState()

virtual void makVre::DtSDLGameControllerDevice::reportCurrentState ( )
overridevirtual

Report the current state of all controller inputs.

Sends input events for the current state of all connected controllers' axes, buttons, and hat switches to initialize the input system with current values

Implements makVre::DtInputDevice.

◆ tick()

virtual void makVre::DtSDLGameControllerDevice::tick ( double dt)
overridevirtual

Update method called each frame.

Polls connected controllers for input changes and updates internal state

Parameters
dtDelta time in seconds since the last frame

Implements makVre::DtInputDevice.

◆ addController()

virtual void makVre::DtSDLGameControllerDevice::addController ( int index)
virtual

Add a controller to be tracked by this device.

Registers a new controller with the specified index and initializes data structures to track its state

Parameters
indexThe index of the controller to add

◆ removeController()

virtual void makVre::DtSDLGameControllerDevice::removeController ( int id)
virtual

Remove a controller from being tracked.

Unregisters a controller and removes its tracking data

Parameters
idThe ID of the controller to remove

◆ processInput()

virtual void makVre::DtSDLGameControllerDevice::processInput ( int controller,
DtInputType type,
int id,
float value,
int flags = 0 )
virtual

Process input from a controller.

Processes input data from a controller and forwards it to the input manager

Parameters
controllerThe index of the controller generating the input
typeThe type of input (axis, button, hat, etc.)
idThe specific input ID (button number, axis index, etc.)
valueThe input value
flagsOptional flags specific to the input type

◆ processAxisInput()

virtual void makVre::DtSDLGameControllerDevice::processAxisInput ( int controller,
int id,
int value )
virtual

Process axis input from a controller.

Specialized handling for axis inputs, with additional processing for state tracking and dead zones

Parameters
controllerThe index of the controller generating the input
idThe axis index
valueThe axis value

◆ getControllerData()

virtual const std::map< int, DtInputData > & makVre::DtSDLGameControllerDevice::getControllerData ( ) const
inlinevirtual

References myControllerData.

Member Data Documentation

◆ myManager

DtVreInputManager* makVre::DtSDLGameControllerDevice::myManager
protected

Pointer to the input manager that owns this device.

◆ myControllers

std::vector<int> makVre::DtSDLGameControllerDevice::myControllers
protected

List of indices for currently connected controllers.

◆ myControllerData

std::map<int, DtInputData> makVre::DtSDLGameControllerDevice::myControllerData
protected

Map of controller indices to their corresponding input data.

Referenced by getControllerData().

◆ myHatPosition

std::map<int, std::map<int, float> > makVre::DtSDLGameControllerDevice::myHatPosition
protected

Map tracking current position of each hat switch for each controller.

First key is controller index, second key is hat ID, value is position


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