Rebel Fork Framework
Urho3D::ButtonCommand Struct Reference

#include <Urho3D/XR/VRUtils.h>

Public Member Functions

 ButtonCommand (int targetCode, float holdDuration=3.0f, float shortPressWindow=1.0f)
 
void Reset ()
 Necessary to reset anytime you intend to change your mechanism of use.
 
bool CheckDown (int newCode)
 Check for only caring about whether down or not, ie. this is a modal toggle that affects something else.
 
bool CheckStrict (int newCode)
 Check for a strict once activation.
 
bool CheckClick (int newCode)
 Check for activate on release, time down is irrelevant.
 
bool CheckLongPress (int newCode, float deltaTime)
 Check for a long press.
 
int CheckShortOrLongPress (int newCode, float deltaTime)
 Check for a dual input that is short or long pressed.
 
int CheckTapOrHold (int newCode, float deltaTime)
 Check for a quick tap or a steady hold.
 

Public Attributes

int targetCode_
 Target code we're looking for.
 
float shortPressWindow_
 Time length after which short-press is forbidden.
 
float holdDuration_
 Time length to constitute a long-press.
 
int currentCode_ = { 0 }
 State, current action code received from input.
 
float time_ = { 0.0f }
 State, current time in hold.
 
bool alreadyDone_ = { false }
 State, flag for not to respond.
 
float fraction_ = { 0.0f }
 State, current hold duration fraction. If zero then holding is not active.
 

Detailed Description

Helper struct to manage variables for making calls to the above functions to manage variable coded button presses, reduces boiler-plate involving state variables. Not intended for varying usage, only one of the check methods should be used for a given ButtonCommand instance. Changing the method that will be called requires calling Reset() to flush the state. To use for a real button, set targetCode_ to true and use bool to int conversion in the check functions.


The documentation for this struct was generated from the following file: