|
VR-Engage
2.2
|
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>
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 | |
| DtInputDevice & | operator= (const DtInputDevice &)=delete |
Protected Attributes | |
| DtVreInputManager * | myManager |
| std::vector< int > | myControllers |
| std::map< int, DtInputData > | myControllerData |
| std::map< int, std::map< int, float > > | myHatPosition |
Protected Attributes inherited from makVre::DtInputDevice | |
| DtVreInputManager * | myManager |
| makVre::DtSDLGameControllerDevice::DtSDLGameControllerDevice | ( | ) |
Default constructor.
Initializes the joystick input device
|
overridevirtual |
Virtual destructor.
Cleans up resources owned by the joystick input device
|
overridevirtual |
Initialize the joystick input device.
Sets up the joystick device with the input manager and initializes controller tracking structures.
| mgr | Reference to the input manager that owns this device |
Implements makVre::DtInputDevice.
|
overridevirtual |
Shut down the joystick input device.
Releases resources and disconnects from any connected controllers
Implements makVre::DtInputDevice.
|
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.
|
overridevirtual |
Update method called each frame.
Polls connected controllers for input changes and updates internal state
| dt | Delta time in seconds since the last frame |
Implements makVre::DtInputDevice.
|
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
| index | The index of the controller to add |
|
virtual |
Remove a controller from being tracked.
Unregisters a controller and removes its tracking data
| id | The ID of the controller to remove |
|
virtual |
Process input from a controller.
Processes input data from a controller and forwards it to the input manager
| controller | The index of the controller generating the input |
| type | The type of input (axis, button, hat, etc.) |
| id | The specific input ID (button number, axis index, etc.) |
| value | The input value |
| flags | Optional flags specific to the input type |
|
virtual |
Process axis input from a controller.
Specialized handling for axis inputs, with additional processing for state tracking and dead zones
| controller | The index of the controller generating the input |
| id | The axis index |
| value | The axis value |
|
inlinevirtual |
References myControllerData.
|
protected |
Pointer to the input manager that owns this device.
|
protected |
List of indices for currently connected controllers.
|
protected |
Map of controller indices to their corresponding input data.
Referenced by getControllerData().
|
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