ezEngine  Milestone 7
ezVirtualThumbStick Class Reference

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>

Inheritance diagram for ezVirtualThumbStick:

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

 ezVirtualThumbStick ()
 Constructor.
 
 ~ezVirtualThumbStick ()
 Destructor.
 
void SetInputArea (const ezVec2 &vLowerLeft, const ezVec2 &vUpperRight, float fThumbstickRadius, float fPriority, CenterMode::Enum center=CenterMode::ActivationPoint)
 Defines the area on screen where the thumb-stick is located and accepts input. More...
 
void GetInputArea (ezVec2 &out_vLowerLeft, ezVec2 &out_vUpperRight)
 Returns the input area of the virtual thumb-stick.
 
void SetTriggerInputSlot (Input::Enum Input, const ezInputActionConfig *pCustomConfig=nullptr)
 Specifies from which input slots the thumb-stick is activated. More...
 
void SetThumbstickOutput (Output::Enum Output, const char *szOutputLeft=nullptr, const char *szOutputRight=nullptr, const char *szOutputUp=nullptr, const char *szOutputDown=nullptr)
 Specifies which output the thumb-stick generates. More...
 
void SetAreaFocusMode (ezInputActionConfig::OnEnterArea OnEnter, ezInputActionConfig::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.
 
- Public Member Functions inherited from ezInputDevice
 ezInputDevice ()
 Default Constructor.
 

Protected Member Functions

void UpdateActionMapping ()
 

Protected Attributes

ezVec2 m_vLowerLeft
 
ezVec2 m_vUpperRight
 
float m_fRadius
 
ezInputActionConfig m_ActionConfig
 
const char * m_szOutputLeft
 
const char * m_szOutputRight
 
const char * m_szOutputUp
 
const char * m_szOutputDown
 
bool m_bEnabled
 
bool m_bConfigChanged
 
bool m_bIsActive
 
ezString m_sName
 
ezVec2 m_vCenter
 
CenterMode::Enum m_CenterMode
 
- Protected Attributes inherited from ezInputDevice
ezMap< ezString, float > m_InputSlotValues
 Stores all the values for all input slots that this device handles. More...
 
ezUInt32 m_LastCharacter
 If this input device type handles character input, it should write the last typed character into this variable. The ezInputManager calls RetrieveLastCharacter() to query what the user typed last.
 
- Protected Attributes inherited from ezEnumerable< ezInputDevice, ezReflectedClass >
ezEnumerablem_pNextInstance
 

Static Protected Attributes

static ezInt32 s_iThumbsticks = 0
 

Private Member Functions

 EZ_ADD_DYNAMIC_REFLECTION (ezVirtualThumbStick)
 
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. More...
 
virtual void RegisterInputSlots () override
 Override this to register all the input slots that this device exposes. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from ezNoBase
static const ezRTTIGetStaticRTTI ()
 
- Static Protected Member Functions inherited from ezInputDevice
static void RegisterInputSlot (const char *szName, const char *szDefaultDisplayName, ezBitflags< ezInputSlotFlags > SlotFlags)
 Calls RegisterInputSlot() on the ezInputManager and passes the parameters through.
 

Detailed Description

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.

Member Function Documentation

void ezVirtualThumbStick::RegisterInputSlots ( )
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 ezInputDevice.

void ezVirtualThumbStick::SetInputArea ( const ezVec2 vLowerLeft,
const ezVec2 vUpperRight,
float  fThumbstickRadius,
float  fPriority,
CenterMode::Enum  center = CenterMode::ActivationPoint 
)

Defines the area on screen where the thumb-stick is located and accepts input.

Parameters
vLowerLeftThe lower left corner of the input area. Coordinates are in [0; 1] range.
vUpperRightThe upper right corner of the input area. Coordinates are in [0; 1] range.
fPriorityThe priority of the input area. Defines which thumb-stick or other input action gets priority, if they overlap.
center
See Also
CenterMode.
void ezVirtualThumbStick::SetThumbstickOutput ( Output::Enum  Output,
const char *  szOutputLeft = nullptr,
const char *  szOutputRight = nullptr,
const char *  szOutputUp = nullptr,
const char *  szOutputDown = nullptr 
)

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 ezVirtualThumbStick::SetTriggerInputSlot ( Input::Enum  Input,
const ezInputActionConfig 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.

void ezVirtualThumbStick::UpdateInputSlotValues ( )
overrideprivatevirtual

Override this, if you need to query the state of the hardware to update the input slots.

Note
This function might be called multiple times before ResetInputSlotValues() is called. This will be the case when ezInputManager::PollHardware is used to make more frequent hardware updates than input is actually processed. Just make sure to always accumulate delta values (such as mouse move values) and don't expect ResetInputSlotValues() to be called in tandem with this function and it will be fine.

Implements ezInputDevice.


The documentation for this class was generated from the following files: