Represents a joystick or any additional controller.
More...
#include <Controller.hpp>
|
| enum | Input {
ButtonX
, ButtonY
, ButtonA
, ButtonB
,
BumperL1
, TriggerL2
, ButtonL3
, BumperR1
,
TriggerR2
, ButtonR3
, ButtonUp
, ButtonLeft
,
ButtonDown
, ButtonRight
, ButtonLogo
, ButtonMenu
,
ButtonView
, PadLeftX
, PadLeftY
, PadRightX
,
PadRightY
, InputCount
} |
| | Controller inputs, based on the Xbox controller layout.
|
| |
|
| static void | saveConfiguration (const std::string &outputPath, const std::string &guid, const std::string &name, const std::vector< int > &axesMapping, const std::vector< int > &buttonsMapping) |
| |
| static bool | parseConfiguration (const std::string &settingsContent, std::vector< int > &axesMapping, std::vector< int > &buttonsMapping) |
| |
|
|
ControllerButton | _buttons [Controller::Input::InputCount] |
| | States of all possible buttons.
|
| |
|
float | _axes [Controller::Input::InputCount] |
| | States of all possible axis.
|
| |
|
int | _id = -1 |
| | Joystick ID (or -1 if no joystick is connected).
|
| |
|
std::string | _name = "Unknown" |
| | Name of the joystick.
|
| |
|
std::string | _guid = "0x0" |
| | GUID of the joystick.
|
| |
Represents a joystick or any additional controller.
Inherited by GamepadController, and RawController.
◆ Controller() [1/2]
◆ Controller() [2/2]
◆ activate()
| virtual bool Controller::activate |
( |
int |
id | ) |
|
|
pure virtual |
Enable the controller.
- Parameters
-
| id | the ID of the controller. |
- Returns
- true if the controller was correctly setup
Implemented in GamepadController, and RawController.
◆ axis()
Query the amount of displacement along a given axis (for joysticks and triggers).
- Parameters
-
- Returns
- the current amount of displacement
◆ deactivate()
| virtual void Controller::deactivate |
( |
| ) |
|
|
pure virtual |
◆ guid()
| std::string Controller::guid |
( |
| ) |
const |
|
inline |
Query the SDL/GLFW GUID of the controller.
- Returns
- the guid
◆ id()
| int Controller::id |
( |
| ) |
const |
|
inline |
Query the controller ID.
- Returns
- the id
◆ name()
| std::string Controller::name |
( |
| ) |
const |
|
inline |
Query the name of the controller.
- Returns
- the name
◆ operator=() [1/2]
Copy assignment.
- Returns
- a reference to the object assigned to
◆ operator=() [2/2]
Move assignment.
- Returns
- a reference to the object assigned to
◆ parseConfiguration()
| bool Controller::parseConfiguration |
( |
const std::string & |
settingsContent, |
|
|
std::vector< int > & |
axesMapping, |
|
|
std::vector< int > & |
buttonsMapping |
|
) |
| |
|
static |
Parse a buttons/axes mapping configuration from the given string.
- Parameters
-
| settingsContent | the string containing the configuration to parse |
| axesMapping | the axes mapping to populate |
| buttonsMapping | the buttons mapping to populate |
- Returns
- true if the configuration was properly parsed
◆ pressed()
Query if a given button is currently held.
- Parameters
-
- Returns
- true if the button is pressed
◆ reset()
| void Controller::reset |
( |
| ) |
|
|
protected |
Reset the controller state and mark it as disconnected.
◆ saveConfiguration()
| void Controller::saveConfiguration |
( |
const std::string & |
outputPath, |
|
|
const std::string & |
guid, |
|
|
const std::string & |
name, |
|
|
const std::vector< int > & |
axesMapping, |
|
|
const std::vector< int > & |
buttonsMapping |
|
) |
| |
|
static |
Save a configuration to a file on disk.
- Parameters
-
| outputPath | the file to write the configuration to |
| guid | the GLFW/SDL GUID |
| name | the user-readable name |
| axesMapping | the axes mapping to save |
| buttonsMapping | the buttons mapping to save |
◆ triggered()
Query if a given button was pressed at this frame precisely.
- Parameters
-
| input | the button |
| absorb | should the press event be hidden from future queries during the current frame |
- Returns
- true if the button was triggered at this frame.
◆ update()
| virtual void Controller::update |
( |
| ) |
|
|
pure virtual |
The documentation for this class was generated from the following files:
- src/engine/input/controller/Controller.hpp
- src/engine/input/controller/Controller.cpp