![]() |
Plasma Engine
2.0
|
A Virtual Thumb-stick is an input device that transforms certain types of input (mouse / touch) into input similar to a thumb-stick on a controller. More...
#include <VirtualThumbStick.h>
Classes | |
struct | CenterMode |
Defines whether the thumb-stick center position is locked or relative to where the user started touching it. More... | |
struct | Input |
This enum allows to select either some default input mapping or to select 'Custom'. More... | |
struct | Output |
Specifies which type of output the thumb-stick shall generate. More... | |
Public Member Functions | |
plVirtualThumbStick () | |
Constructor. | |
~plVirtualThumbStick () | |
Destructor. | |
void | SetInputArea (const plVec2 &vLowerLeft, const plVec2 &vUpperRight, float fThumbstickRadius, float fPriority, CenterMode::Enum center=CenterMode::ActivationPoint) |
Defines the area on screen where the thumb-stick is located and accepts input. | |
void | GetInputArea (plVec2 &out_vLowerLeft, plVec2 &out_vUpperRight) |
Returns the input area of the virtual thumb-stick. | |
void | SetTriggerInputSlot (Input::Enum input, const plInputActionConfig *pCustomConfig=nullptr) |
Specifies from which input slots the thumb-stick is activated. | |
void | SetThumbstickOutput (Output::Enum output, plStringView sOutputLeft={}, plStringView sOutputRight={}, plStringView sOutputUp={}, plStringView sOutputDown={}) |
Specifies which output the thumb-stick generates. | |
void | SetAreaFocusMode (plInputActionConfig::OnEnterArea onEnter, plInputActionConfig::OnLeaveArea onLeave) |
Specifies what happens when the input slots that trigger the thumb-stick are active while entering or leaving the input area. | |
void | SetEnabled (bool bEnabled) |
Allows to enable or disable the entire thumb-stick temporarily. | |
bool | IsEnabled () const |
Returns whether the thumb-stick is currently enabled. | |
bool | IsActive () const |
Returns whether the thumb-stick is currently active (ie. triggered) and generates output. | |
![]() | |
plInputDevice () | |
Default Constructor. | |
float | GetInputSlotState (plStringView sSlot) const |
Allows to query current input values for the given slot. | |
bool | HasDeviceBeenUsedLastFrame () const |
Returns true, if the device was 'used' during the last frame, ie. when it generated input due to some user interaction. | |
![]() | |
virtual const plRTTI * | GetDynamicRTTI () const |
bool | IsInstanceOf (const plRTTI *pType) const |
Returns whether the type of this instance is of the given type or derived from it. | |
template<typename T > | |
PL_ALWAYS_INLINE bool | IsInstanceOf () const |
Returns whether the type of this instance is of the given type or derived from it. | |
Protected Member Functions | |
void | UpdateActionMapping () |
![]() | |
virtual void | ResetInputSlotValues () |
Override this, if you need to reset certain input slot values to zero, after the plInputManager is finished with the current frame update. | |
virtual void | UpdateHardwareState (plTime tTimeDifference) |
This function is called once after plInputManager::Update with the same time delta value. It allows to update hardware state, such as the vibration of gamepad motors. | |
Protected Attributes | |
plVec2 | m_vLowerLeft |
plVec2 | m_vUpperRight |
float | m_fRadius |
plInputActionConfig | m_ActionConfig |
plStringView | m_sOutputLeft |
plStringView | m_sOutputRight |
plStringView | m_sOutputUp |
plStringView | m_sOutputDown |
bool | m_bEnabled |
bool | m_bConfigChanged |
bool | m_bIsActive |
plString | m_sName |
plVec2 | m_vCenter |
CenterMode::Enum | m_CenterMode |
![]() | |
plMap< plString, float > | m_InputSlotValues |
Stores all the values for all input slots that this device handles. | |
plUInt32 | m_uiLastCharacter |
If this input device type handles character input, it should write the last typed character into this variable. The plInputManager calls RetrieveLastCharacter() to query what the user typed last. | |
![]() | |
plEnumerable * | m_pNextInstance |
Static Protected Attributes | |
static plInt32 | s_iThumbsticks = 0 |
Private Member Functions | |
virtual void | InitializeDevice () override |
Override this if you need to do device specific initialization before the first use. | |
virtual void | UpdateInputSlotValues () override |
Override this, if you need to query the state of the hardware to update the input slots. | |
virtual void | RegisterInputSlots () override |
Override this to register all the input slots that this device exposes. | |
Additional Inherited Members | |
![]() | |
static const plRTTI * | GetStaticRTTI () |
![]() | |
static void | RegisterInputSlot (plStringView sName, plStringView sDefaultDisplayName, plBitflags< plInputSlotFlags > SlotFlags) |
Calls RegisterInputSlot() on the plInputManager and passes the parameters through. | |
A Virtual Thumb-stick is an input device that transforms certain types of input (mouse / touch) into input similar to a thumb-stick on a controller.
A virtual thumb-stick can be used to provide an 'input device' on a touch screen, that acts like a controller thumb-stick and thus allows easier control over a game. The virtual thumb-stick takes input inside a certain screen area. It tracks the users finger movements inside this area and translates those into input from a controller thumb-stick, which it then feeds back into the input system. That makes it then possible to be mapped to input actions again. This way a game controller type of input is emulated.
|
inlineoverrideprivatevirtual |
Override this if you need to do device specific initialization before the first use.
Implements plInputDevice.
|
overrideprivatevirtual |
Override this to register all the input slots that this device exposes.
This is called once during initialization. It needs to call RegisterInputSlot() once for every input slot that this device exposes to the system.
Implements plInputDevice.
void plVirtualThumbStick::SetInputArea | ( | const plVec2 & | vLowerLeft, |
const plVec2 & | vUpperRight, | ||
float | fThumbstickRadius, | ||
float | fPriority, | ||
CenterMode::Enum | center = CenterMode::ActivationPoint ) |
Defines the area on screen where the thumb-stick is located and accepts input.
vLowerLeft | The lower left corner of the input area. Coordinates are in [0; 1] range. |
vUpperRight | The upper right corner of the input area. Coordinates are in [0; 1] range. |
fPriority | The priority of the input area. Defines which thumb-stick or other input action gets priority, if they overlap. |
center |
void plVirtualThumbStick::SetThumbstickOutput | ( | Output::Enum | output, |
plStringView | sOutputLeft = {}, | ||
plStringView | sOutputRight = {}, | ||
plStringView | sOutputUp = {}, | ||
plStringView | sOutputDown = {} ) |
Specifies which output the thumb-stick generates.
If Output is 'Custom' the remaining parameters define which input slots the thumb-stick triggers for which direction. Otherwise the remaining parameters are ignored.
void plVirtualThumbStick::SetTriggerInputSlot | ( | Input::Enum | input, |
const plInputActionConfig * | pCustomConfig = nullptr ) |
Specifies from which input slots the thumb-stick is activated.
If Input is 'Custom' the remaining parameters define the filter axes and up to three input slots that trigger the thumb-stick. Otherwise the remaining parameters are ignored.
|
overrideprivatevirtual |
Override this, if you need to query the state of the hardware to update the input slots.
Implements plInputDevice.