|
coastline 0.0.4
|
Open every gamepad in the order it connects, and drive the first two ports with the devices the Player1 and Player2 keys of the Controls section choose. More...
#include <input.h>
Public Member Functions | |
| InputBindings () | |
| Open connected gamepads and register default controls for the active input context. | |
| InputBindings (const GameConfig &config) | |
| Open connected gamepads and register configured controls for the active input context. | |
| ~InputBindings () | |
| Close gamepads and unregister this input context. | |
| InputBindings (const InputBindings &)=delete | |
| Copying is disabled because SDL events address one active input context. | |
| InputBindings & | operator= (const InputBindings &)=delete |
| Assignment is disabled because the active input context has a stable address. | |
| ControlBindings & | Controls () |
| const ControlBindings & | Controls () const |
| PlayerDevices | AssignedDevices (std::size_t player, std::size_t players) const |
| Resolve the Player1 and Player2 keys of the Controls section against the open gamepads. | |
| void | SetScriptedKeys (std::vector< int > scancodes) |
| Add simulated key presses alongside physical keyboard input, for tests. | |
| bool | IsKeyDown (SDL_Scancode scancode) |
| void | IgnoreKeyUntilReleased (SDL_Scancode scancode) |
| Report a key as up to IsKeyDown() until it is released, for a key a shortcut of the window consumed, such as Enter of Alt and Enter. | |
| void | SetSecondControllerState (const ControllerState &state) |
| Set the state of the second controller the race reads for its second player, until the next call. | |
| ControllerState | SecondControllerState () const |
| int | TakeMouseWheel () |
| void | ClearMouseWheel () |
| Discard accumulated mouse-wheel movement. | |
| void | HandleEvent (const SDL_Event &event) |
| Open or close a gamepad for a connection event, and log the devices of the players. | |
| std::array< ControllerState, CONTROLLER_PORTS > | Poll (std::size_t players, bool race) const |
Static Public Member Functions | |
| static InputBindings * | Active () |
Open every gamepad in the order it connects, and drive the first two ports with the devices the Player1 and Player2 keys of the Controls section choose.
One instance exists at a time.
| coastline::InputBindings::InputBindings | ( | ) |
Open connected gamepads and register default controls for the active input context.
|
explicit |
Open connected gamepads and register configured controls for the active input context.
| config | The initial keyboard, gamepad, and player-assignment settings. |
| coastline::InputBindings::~InputBindings | ( | ) |
Close gamepads and unregister this input context.
|
delete |
Copying is disabled because SDL events address one active input context.
|
delete |
Assignment is disabled because the active input context has a stable address.
|
static |
|
inline |
|
inline |
| PlayerDevices coastline::InputBindings::AssignedDevices | ( | std::size_t | player, |
| std::size_t | players ) const |
Resolve the Player1 and Player2 keys of the Controls section against the open gamepads.
A key that is auto takes the gamepads no other key chooses, one each in the order of the players and the rest by the first player that is auto, and the keyboard goes to the first player that is auto with no gamepad, else to the first player that is auto.
| player | The player, 0 for the first. |
| players | The number of players, 1 or 2. One player takes the devices of both. |
| void coastline::InputBindings::SetScriptedKeys | ( | std::vector< int > | scancodes | ) |
Add simulated key presses alongside physical keyboard input, for tests.
| scancodes | The SDL scancodes to report as down, replacing the previous list. |
| bool coastline::InputBindings::IsKeyDown | ( | SDL_Scancode | scancode | ) |
| scancode | The key. |
| void coastline::InputBindings::IgnoreKeyUntilReleased | ( | SDL_Scancode | scancode | ) |
Report a key as up to IsKeyDown() until it is released, for a key a shortcut of the window consumed, such as Enter of Alt and Enter.
| scancode | The key. |
| void coastline::InputBindings::SetSecondControllerState | ( | const ControllerState & | state | ) |
Set the state of the second controller the race reads for its second player, until the next call.
| state | The state of the second port. |
| ControllerState coastline::InputBindings::SecondControllerState | ( | ) | const |
| int coastline::InputBindings::TakeMouseWheel | ( | ) |
| void coastline::InputBindings::ClearMouseWheel | ( | ) |
Discard accumulated mouse-wheel movement.
| void coastline::InputBindings::HandleEvent | ( | const SDL_Event & | event | ) |
Open or close a gamepad for a connection event, and log the devices of the players.
A wheel event of the mouse adds to the wheel TakeMouseWheel() reads. Other events are ignored.
| event | The SDL event. |
| std::array< ControllerState, CONTROLLER_PORTS > coastline::InputBindings::Poll | ( | std::size_t | players, |
| bool | race ) const |
| players | The number of players the screen reads, 1 or 2. In single-player mode, devices assigned to either player drive the first port. |
| race | Whether a race reads the second port, through the race actions of the Controls section for a gamepad and the keyboard bindings of the PC release for the keyboard. |