TurtleBrains  0.3.5
High quality, portable, C++ framework for rapid 2D game development.
TurtleBrains::Game::InputSignalConverterInterface Class Referenceabstract

#include <tb_input_action.hpp>

Public Member Functions

 InputSignalConverterInterface (void)
 
virtual ~InputSignalConverterInterface (void)
 
virtual float DigitalToAnalogConverter (bool digitalValue, float deltaTime)=0
 
virtual bool AnalogToDigitalConverter (float analogValue, float deltaTime)=0
 
virtual float AnalogToAnalogConverter (float analogValue, float deltaTime)=0
 
virtual float InvertAnalogValue (float analogValue)
 

Detailed Description

Provides an abstract interface for converting a signal from analog to digital, digital to analog, or playing with analog to analog for custom thresholds, deadzones ranges or interpolation methods. Just derive from the base and set in the InputAction::SetInputSignalConverter().

Constructor & Destructor Documentation

◆ InputSignalConverterInterface()

TurtleBrains::Game::InputSignalConverterInterface::InputSignalConverterInterface ( void  )
inline

Constructs a SignalConverter abstract object, does nothing.

◆ ~InputSignalConverterInterface()

virtual TurtleBrains::Game::InputSignalConverterInterface::~InputSignalConverterInterface ( void  )
inlinevirtual

Destroys the SignalConverter object, does nothing.

Member Function Documentation

◆ AnalogToAnalogConverter()

virtual float TurtleBrains::Game::InputSignalConverterInterface::AnalogToAnalogConverter ( float  analogValue,
float  deltaTime 
)
pure virtual

Convert an analog; 0-1 signal into a analog; 0-1 signal. Typically this would be used to set deadzones, ranges or thresholds - and or change interpolation from linear to something different.

Parameters
analogValueis a number from 0 to 1 representing the axis of a controller device.
deltaTimeis the amount of time that is passing during this frame or timestep which depends what stage the InputAction poll is running, Simulate (fixedTime) or Update (deltaTime).

◆ AnalogToDigitalConverter()

virtual bool TurtleBrains::Game::InputSignalConverterInterface::AnalogToDigitalConverter ( float  analogValue,
float  deltaTime 
)
pure virtual

Convert a analog; 0-1 signal into a digital; on/off signal. Typically there would be some threshold value to turn the digital signal on/off.

Parameters
analogValueis a number from 0 to 1 representing the axis of a controller device.
deltaTimeis the amount of time that is passing during this frame or timestep which depends what stage the InputAction poll is running, Simulate (fixedTime) or Update (deltaTime).

◆ DigitalToAnalogConverter()

virtual float TurtleBrains::Game::InputSignalConverterInterface::DigitalToAnalogConverter ( bool  digitalValue,
float  deltaTime 
)
pure virtual

Convert a digital; on/off signal into an analog 0-1 signal.

Parameters
digitalValueis true if the digital button is pressed/down, otherwise false.
deltaTimeis the amount of time that is passing during this frame or timestep which depends what stage the InputAction poll is running, Simulate (fixedTime) or Update (deltaTime).
Note
This API may change in the future to include an addition float parameter for currentAnalog value since there could be a subtle bug/issue when using an InputAction that adjusts / holds a current value during each timestep. Much like a common/default press/release rate. Consider that the current value held in the child object is X, then Simulate::Poll is called (internally), now we have X+1, then Update::Poll is called and it will get to X+2 instead of X+1 there.

◆ InvertAnalogValue()

virtual float TurtleBrains::Game::InputSignalConverterInterface::InvertAnalogValue ( float  analogValue)
inlinevirtual

Called when an axis / analog signal should be inverted. The default implementation does a simple ONE_MINUS_VALUE inversion. This will be called only if/when the axis is bound with inverted set to true.