#include <tb_input_action.hpp>
Public Member Functions | |
InputAction (void) | |
InputAction (const tbApplication::Key &keyBinding) | |
InputAction (const InputAction &other) | |
~InputAction (void) | |
bool | IsDown (void) const |
bool | IsPressed (void) const |
bool | IsReleased (void) const |
float | GetAnalogValue (void) const |
bool | IsAnalog (void) const |
bool | IsDigital (void) const |
void | ClearBindings (void) |
void | AddBinding (const tbApplication::Key &keyBinding) |
void | AddBinding (const tbSystem::Unstable::DeviceHandle &deviceHandle, const tbSystem::Unstable::ButtonIdentifier &button) |
void | AddAnalogBinding (const tbSystem::Unstable::DeviceHandle &deviceHandle, const tbSystem::Unstable::AxisIdentifier &axis, bool inverted=false) |
void | RemoveBinding (const tbApplication::Key &keyBinding) |
void | RemoveBinding (const tbSystem::Unstable::DeviceHandle &deviceHandle, const tbSystem::Unstable::ButtonIdentifier &button) |
void | RemoveAnalogBinding (const tbSystem::Unstable::DeviceHandle &deviceHandle, const tbSystem::Unstable::AxisIdentifier &axis) |
void | SetInputSignalConverter (InputSignalConverterInterface *signalConverter) |
InputAction & | operator= (const InputAction &other) |
An object to manage watching one-many keys to perform game actions and hide details about the bound keys from code using the action. Internally the InputAction separates Simulate step polling from Update step polling, this is to make IsPressed() or IsReleased() work for a single Simulate step vs all Simulate steps during a frame.
TurtleBrains::Game::InputAction::InputAction | ( | void | ) |
Constructs an InputAction that contains no bindings and registers the action in a tracked list.
|
explicit |
Constructs an InputAction that binds to the Key given, and registers the action in a tracked list.
keyBinding | The Key to bind to the InputAction object during construction. |
TurtleBrains::Game::InputAction::InputAction | ( | const InputAction & | other | ) |
Copies the contents of one InputAction into this one.
other | The action to copy. |
TurtleBrains::Game::InputAction::~InputAction | ( | void | ) |
Destroys the InputAction object and any data it contained while unregistering it from the tracked actions list.
void TurtleBrains::Game::InputAction::AddAnalogBinding | ( | const tbSystem::Unstable::DeviceHandle & | deviceHandle, |
const tbSystem::Unstable::AxisIdentifier & | axis, | ||
bool | inverted = false |
||
) |
Adds an analog axis from a controller device to the InputAction so that it will get tracked for Down, Pressed or Released events.
deviceHandle | is the handle to the controller of the axis that should be used for the action. |
axis | is the axis id on the controller. |
inverted | should be true if the analog signal should be converted/inverted by/with the attached InputSignalConverterInterface::InvertAnalogValue(). |
void TurtleBrains::Game::InputAction::AddBinding | ( | const tbApplication::Key & | keyBinding | ) |
Adds a Key binding to the InputAction so that it will get tracked for Down, Pressed or Released events.
keyBinding | The Key to bind to the InputAction. |
void TurtleBrains::Game::InputAction::AddBinding | ( | const tbSystem::Unstable::DeviceHandle & | deviceHandle, |
const tbSystem::Unstable::ButtonIdentifier & | button | ||
) |
Adds a button from a controller device to the InputAction so that it will get tracked for Down, Pressed or Released events.
deviceHandle | is the handle to the controller of the button that should be used for the action. |
button | is the button id on the controller. |
void TurtleBrains::Game::InputAction::ClearBindings | ( | void | ) |
Removes ALL bindings from the input action so there are no keys, not controller devices or button/axis or any inputs that will trigger any of the Down, Pressed or Released events.
float TurtleBrains::Game::InputAction::GetAnalogValue | ( | void | ) | const |
Returns an analog value from 0 to 1, or some other range if custom converters change it. This value is created from digital inputs by running through DigitalToAnalogConverted() in the attached InputSignalConverterInterface().
bool TurtleBrains::Game::InputAction::IsAnalog | ( | void | ) | const |
Checks the last/most recently used binding to see if it was an axis/analog type.
bool TurtleBrains::Game::InputAction::IsDigital | ( | void | ) | const |
Checks the last/most recently used binding to see if it was a Key/Butoon digital type control.
bool TurtleBrains::Game::InputAction::IsDown | ( | void | ) | const |
This will check each of the Keys or Buttons bound to the InputAction to see if ANY are currently down, returning true if any are, or false if none are. Analog/Axis controls are also checked after running through a AnalogToDigital converter, if that was the last used binding.
bool TurtleBrains::Game::InputAction::IsPressed | ( | void | ) | const |
This will check if the previous state of the action was up from the previous polling (Simulate and Update polling are separated) and if IsDown() now returns true then IsPressed() will return true.
bool TurtleBrains::Game::InputAction::IsReleased | ( | void | ) | const |
This will check if the previous state of the action was already down from previous polling and is currently that IsDown() now returns false. If that is met, this will return true.
InputAction& TurtleBrains::Game::InputAction::operator= | ( | const InputAction & | other | ) |
Copies the contents of one InputAction into this one.
other | The action to copy. |
void TurtleBrains::Game::InputAction::RemoveAnalogBinding | ( | const tbSystem::Unstable::DeviceHandle & | deviceHandle, |
const tbSystem::Unstable::AxisIdentifier & | axis | ||
) |
Removes a specific controller button from the InputAction while keeping any other bindings as they were.
deviceHandle | is the handle to the controller of the button that should be used for the action. |
axis | is the axis id on the controller that should get removed from the InputAction. |
void TurtleBrains::Game::InputAction::RemoveBinding | ( | const tbApplication::Key & | keyBinding | ) |
Removes a specific Key from the InputAction while keeping any other bindings as they were.
keyBinding | The Key binding to remove from the InputAction. |
void TurtleBrains::Game::InputAction::RemoveBinding | ( | const tbSystem::Unstable::DeviceHandle & | deviceHandle, |
const tbSystem::Unstable::ButtonIdentifier & | button | ||
) |
Removes a specific controller button from the InputAction while keeping any other bindings as they were.
deviceHandle | is the handle to the controller of the button that should be used for the action. |
button | is the button id on the controller that should get removed from the InputAction. |
void TurtleBrains::Game::InputAction::SetInputSignalConverter | ( | InputSignalConverterInterface * | signalConverter | ) |
Allows for customized InputSignalConverter's to be used to convert from digital to analog, analog to digital or analog to analog conversions (including custom inversion). Typically one would use a custom signal converter to add deadzones or thresholds to analog controls, or create specific digital to analog routines.
signalConverter | is a pointer to the InputSignalConverterInterface object that should be used and it MUST remain in project scope until it is removed from the InputAction or it must outlive the InputAction. |