The controls of a player ship: arrows move it and Space fires, or a gamepad's D-pad or left stick and its South button (A, Cross) or right trigger.
More...
#include <aegis2d/shmup/ship_controls.hpp>
|
| | ShipControls () |
| | Declares the ship's actions with their default keys, auto-fire off.
|
| |
| platform::ActionMap & | actions () noexcept |
| | The ship's actions, to rebind them or show them (platform::control_lines()).
|
| |
| const platform::ActionMap & | actions () const noexcept |
| | The ship's actions, to rebind them or show them (platform::control_lines()).
|
| |
| platform::ActionId | id (ecs::Action action) const noexcept |
| | Identifier of one of the ship's actions in actions().
|
| |
| platform::LatchedAction & | auto_fire () noexcept |
| | The auto-fire option of the fire action.
|
| |
| const platform::LatchedAction & | auto_fire () const noexcept |
| | The auto-fire option of the fire action.
|
| |
| std::uint8_t | update (const platform::Keyboard &keyboard) |
| | Reads the frame and tells which actions are held.
|
| |
| std::uint8_t | update (const platform::Keyboard &keyboard, const platform::Gamepad &gamepad) |
| | Reads the frame on the keyboard and the gamepad, and tells which actions are held on either.
|
| |
| std::uint8_t | held () const noexcept |
| | The result of the last update().
|
| |
| void | load (const core::Config &settings, std::string_view input, std::string_view auto_fire, std::string_view gamepad={}) |
| | Reads the player's key and button bindings and auto-fire option.
|
| |
| void | save (core::Config &settings, std::string_view input, std::string_view auto_fire, std::string_view gamepad={}) const |
| | Writes the key and button bindings and the auto-fire option into the player's settings.
|
| |
The controls of a player ship: arrows move it and Space fires, or a gamepad's D-pad or left stick and its South button (A, Cross) or right trigger.
Declares the actions "up", "down", "left", "right" and "fire" with the subject's default keys and gamepad buttons; the player can rebind them (platform::ActionMap, platform::KeyCapture) and turn auto-fire on (platform::LatchedAction). Each frame, update() gives the held actions as the byte the client sends to the server, the keyboard and the gamepad together:
controls.
load(settings,
"input",
"accessibility.auto_fire",
"gamepad");
...
window.poll_events();
controls.
update(window.keyboard(), window.gamepad());
The controls of a player ship: arrows move it and Space fires, or a gamepad's D-pad or left stick and...
Definition ship_controls.hpp:40
void load(const core::Config &settings, std::string_view input, std::string_view auto_fire, std::string_view gamepad={})
Reads the player's key and button bindings and auto-fire option.
Definition ship_controls.hpp:104
std::uint8_t update(const platform::Keyboard &keyboard)
Reads the frame and tells which actions are held.
Definition ship_controls.hpp:72
std::uint8_t held() const noexcept
The result of the last update().
Definition ship_controls.hpp:95
◆ ShipControls()
| aegis2d::shmup::ShipControls::ShipControls |
( |
| ) |
|
|
inline |
Declares the ship's actions with their default keys, auto-fire off.
◆ actions() [1/2]
◆ actions() [2/2]
◆ auto_fire() [1/2]
The auto-fire option of the fire action.
- Returns
- The latch that holds fire without its key when the option is on.
◆ auto_fire() [2/2]
The auto-fire option of the fire action.
- Returns
- The latch that holds fire without its key when the option is on.
◆ held()
| std::uint8_t aegis2d::shmup::ShipControls::held |
( |
| ) |
const |
|
inlinenoexcept |
The result of the last update().
- Returns
- The held actions as
ecs::Action bits; 0 before the first update.
◆ id()
Identifier of one of the ship's actions in actions().
- Parameters
-
| action | Action of the ship. |
- Returns
- Its ActionId.
◆ load()
| void aegis2d::shmup::ShipControls::load |
( |
const core::Config & |
settings, |
|
|
std::string_view |
input, |
|
|
std::string_view |
auto_fire, |
|
|
std::string_view |
gamepad = {} |
|
) |
| |
|
inline |
Reads the player's key and button bindings and auto-fire option.
- Parameters
-
◆ save()
| void aegis2d::shmup::ShipControls::save |
( |
core::Config & |
settings, |
|
|
std::string_view |
input, |
|
|
std::string_view |
auto_fire, |
|
|
std::string_view |
gamepad = {} |
|
) |
| const |
|
inline |
Writes the key and button bindings and the auto-fire option into the player's settings.
- Parameters
-
| settings | Settings to update, then saved with core::Config::save(). |
| input | Section of the key bindings. |
| auto_fire | Path of the auto-fire option. |
| gamepad | Section of the gamepad bindings; empty not to write them. |
◆ update() [1/2]
Reads the frame and tells which actions are held.
Call it once per frame, after Window::poll_events().
- Parameters
-
| keyboard | State of the keyboard, usually Window::keyboard(). |
- Returns
- The held actions, one
ecs::Action bit each: the value of ecs::PlayerInput::held.
◆ update() [2/2]
Reads the frame on the keyboard and the gamepad, and tells which actions are held on either.
Call it once per frame, after Window::poll_events().
- Parameters
-
| keyboard | State of the keyboard, usually Window::keyboard(). |
| gamepad | State of the gamepads, usually Window::gamepad(). |
- Returns
- The held actions, one
ecs::Action bit each.
The documentation for this class was generated from the following file: