|
libmx2 2.2.1
C++20 multimedia and game-engine library (SDL2 / OpenGL / Vulkan)
|
Convenience wrapper that queries controller buttons by logical name. More...
#include <input.hpp>
Public Member Functions | |
| Input ()=default | |
| Default constructor. | |
| ~Input ()=default | |
| Input (const Input &)=delete | |
| Input & | operator= (const Input &)=delete |
| Input (Input &&)=delete | |
| Input & | operator= (Input &&)=delete |
| bool | getButton (Input_Button b) |
| Query whether a logical gamepad button is currently pressed. | |
| Public Member Functions inherited from mx::Controller | |
| Controller () | |
| Default constructor — device not yet opened. | |
| ~Controller () | |
| Destructor — closes the controller if open. | |
| Controller (const Controller &)=delete | |
| Controller & | operator= (const Controller &)=delete |
| Controller (Controller &&)=delete | |
| Controller & | operator= (Controller &&)=delete |
| bool | open (int index) |
| Open a game controller by device index. | |
| bool | connectEvent (SDL_Event &e) |
| Handle a device-added/removed event to maintain connection state. | |
| std::string | name () const |
| Return the controller's name as reported by SDL. | |
| void | close () |
| Close the controller handle if open. | |
| std::optional< SDL_GameController * > | handle () |
| Return the underlying SDL_GameController handle as an optional. | |
| SDL_GameController * | unwrap () const |
| Unwrap the SDL_GameController pointer, asserting it is open. | |
| int | controllerIndex () const |
| Return the device index this controller was opened with. | |
| bool | getButton (SDL_GameControllerButton button) |
| Test whether a mapped button is currently pressed. | |
| Uint8 | getHat (int hat) |
| Read the position of a POV hat. | |
| Sint16 | getAxis (SDL_GameControllerAxis axis) |
| Read the current axis value. | |
| mx::Wrapper< SDL_GameController * > | wrapper () const |
| Return a Wrapper around the SDL_GameController handle. | |
| bool | active () const |
| Check whether the controller is currently usable. | |
Additional Inherited Members | |
| Static Public Member Functions inherited from mx::Controller | |
| static int | joysticks () |
| Return the number of connected joysticks/controllers. | |
| Protected Attributes inherited from mx::Controller | |
| SDL_GameController * | stick = nullptr |
| Underlying SDL game controller handle. | |
| int | index = -1 |
| Device index (-1 if not open). | |
Convenience wrapper that queries controller buttons by logical name.
Inherits Controller, adding getButton(Input_Button) to allow polling gamepad input without knowing the underlying SDL button codes.
|
default |
Default constructor.
Referenced by Input(), Input(), operator=(), and operator=().
|
default |
|
delete |
References Input().
|
delete |
References Input().
| bool mx::Input::getButton | ( | Input_Button | b | ) |
Query whether a logical gamepad button is currently pressed.
| b | Logical button identifier. |
true if the button is held down. Definition at line 22 of file input.cpp.
References mx::Controller::active(), mx::ctrl, mx::Controller::getButton(), and mx::keys.