Gainput  v1.0.0
Public Member Functions | Protected Member Functions | List of all members
gainput::DoubleClickGesture Class Reference

A double-click gesture. More...

#include <GainputDoubleClickGesture.h>

Inheritance diagram for gainput::DoubleClickGesture:
gainput::InputGesture gainput::InputDevice

Public Member Functions

 DoubleClickGesture (InputManager &manager, DeviceId device, unsigned index, DeviceVariant variant)
 Initializes the gesture.
 
 ~DoubleClickGesture ()
 Uninitializes the gesture.
 
void Initialize (DeviceId actionButtonDevice, DeviceButtonId actionButton, uint64_t timeSpan=300)
 Sets up the gesture for operation without position checking. More...
 
void Initialize (DeviceId actionButtonDevice, DeviceButtonId actionButton, DeviceId xAxisDevice, DeviceButtonId xAxis, float xTolerance, DeviceId yAxisDevice, DeviceButtonId yAxis, float yTolerance, uint64_t timeSpan=300)
 Sets up the gesture for operation with position checking, i.e. the user may not move the mouse too far between clicks. More...
 
void SetClicksTargetCount (unsigned count)
 Sets the number of clicks to trigger an action. More...
 
bool IsValidButtonId (DeviceButtonId deviceButton) const
 Returns if the given button is valid for this device.
 
ButtonType GetButtonType (DeviceButtonId deviceButton) const
 Returns the type of the given button.
 
- Public Member Functions inherited from gainput::InputGesture
DeviceType GetType () const
 Returns DT_GESTURE.
 
const char * GetTypeName () const
 Returns the device type's name.
 
bool IsLateUpdate () const
 Returns if this device should be updated after other devices.
 
- Public Member Functions inherited from gainput::InputDevice
 InputDevice (InputManager &manager, DeviceId device, unsigned index)
 Initializes the input device. More...
 
virtual ~InputDevice ()
 Empty virtual destructor.
 
void Update (InputDeltaState *delta)
 Update this device, internally called by InputManager. More...
 
DeviceId GetDeviceId () const
 Returns this device's ID.
 
unsigned GetIndex () const
 Returns the device's index among devices of the same type.
 
virtual DeviceVariant GetVariant () const
 Returns the device variant.
 
DeviceState GetState () const
 Returns the device state.
 
virtual bool IsAvailable () const
 Returns if this device is available.
 
bool GetBool (DeviceButtonId deviceButton) const
 Returns the current state of the given button.
 
bool GetBoolPrevious (DeviceButtonId deviceButton) const
 Returns the previous state of the given button.
 
float GetFloat (DeviceButtonId deviceButton) const
 Returns the current state of the given button.
 
float GetFloatPrevious (DeviceButtonId deviceButton) const
 Returns the previous state of the given button.
 
virtual size_t GetAnyButtonDown (DeviceButtonSpec *outButtons, size_t maxButtonCount) const
 Checks if any button on this device is down. More...
 
virtual size_t GetButtonName (DeviceButtonId deviceButton, char *buffer, size_t bufferLength) const
 Gets the name of the given button. More...
 
virtual DeviceButtonId GetButtonByName (const char *name) const
 Returns the button's ID if the name is of this device's buttons. More...
 
InputStateGetInputState ()
 Returns the device's state, probably best if only used internally.
 
const InputStateGetInputState () const
 Returns the device's state, probably best if only used internally.
 
InputStateGetPreviousInputState ()
 Returns the device's previous state, probably best if only used internally.
 
virtual InputStateGetNextInputState ()
 Returns the device's state that is currently being determined, may be 0 if not available.
 
float GetDeadZone (DeviceButtonId buttonId) const
 Returns the previously set dead zone for the given button or 0.0f if none was set yet.
 
void SetDeadZone (DeviceButtonId buttonId, float value)
 Sets the dead zone for the given button.
 
void SetDebugRenderingEnabled (bool enabled)
 Enable/disable debug rendering of this device.
 
bool IsDebugRenderingEnabled () const
 Returns true if debug rendering is enabled, false otherwise.
 
bool IsSynced () const
 
void SetSynced (bool synced)
 Sets if this device is being controlled remotely or from a recording. More...
 

Protected Member Functions

void InternalUpdate (InputDeltaState *delta)
 Implementation of the device's Update function. More...
 
- Protected Member Functions inherited from gainput::InputGesture
 InputGesture (InputManager &manager, DeviceId device, unsigned index)
 Gesture base constructor.
 
DeviceState InternalGetState () const
 Implementation of the device's GetState function. More...
 
- Protected Member Functions inherited from gainput::InputDevice
size_t CheckAllButtonsDown (DeviceButtonSpec *outButtons, size_t maxButtonCount, unsigned start, unsigned end) const
 Checks which buttons are down. More...
 

Additional Inherited Members

- Public Types inherited from gainput::InputDevice
enum  DeviceType {
  DT_MOUSE, DT_KEYBOARD, DT_PAD, DT_TOUCH,
  DT_BUILTIN, DT_REMOTE, DT_GESTURE, DT_CUSTOM,
  DT_COUNT
}
 Type of an input device. More...
 
enum  DeviceVariant { DV_STANDARD, DV_RAW, DV_NULL }
 Variant of an input device type. More...
 
enum  DeviceState { DS_OK, DS_LOW_BATTERY, DS_UNAVAILABLE }
 State of an input device. More...
 
- Static Public Attributes inherited from gainput::InputDevice
static const unsigned AutoIndex = unsigned(-1)
 
- Protected Attributes inherited from gainput::InputDevice
InputManagermanager_
 The manager this device belongs to.
 
DeviceId deviceId_
 The ID of this device.
 
unsigned index_
 Index of this device among devices of the same type.
 
InputStatestate_
 The current state of this device.
 
InputStatepreviousState_
 The previous state of this device.
 
float * deadZones_
 
bool debugRenderingEnabled_
 Specifies if this device is currently rendering debug information.
 
bool synced_
 

Detailed Description

A double-click gesture.

This gesture implements the classic double-click functionality. Its only device button DoubleClickTriggered is true for one frame after the specified button has been active for a specified number of times in a given time frame. It's also possible to disallow the pointer from travelling too far between and during clicks.

After instantiating the gesture like any other input device, call one of the Initialize() functions to properly set it up.

In order for this gesture to be available, Gainput must be built with GAINPUT_ENABLE_ALL_GESTURES or GAINPUT_ENABLE_DOUBLE_CLICK_GESTURE defined.

See also
Initialize
SetClicksTargetCount
InputManager::CreateDevice
Examples:
/samples/gesture/gesturesample.cpp.

Member Function Documentation

◆ Initialize() [1/2]

void gainput::DoubleClickGesture::Initialize ( DeviceId  actionButtonDevice,
DeviceButtonId  actionButton,
uint64_t  timeSpan = 300 
)

Sets up the gesture for operation without position checking.

Parameters
actionButtonDeviceID of the input device containing the action button.
actionButtonID of the device button to be used as the action button.
timeSpanAllowed time between clicks in milliseconds.
Examples:
/samples/gesture/gesturesample.cpp.

◆ Initialize() [2/2]

void gainput::DoubleClickGesture::Initialize ( DeviceId  actionButtonDevice,
DeviceButtonId  actionButton,
DeviceId  xAxisDevice,
DeviceButtonId  xAxis,
float  xTolerance,
DeviceId  yAxisDevice,
DeviceButtonId  yAxis,
float  yTolerance,
uint64_t  timeSpan = 300 
)

Sets up the gesture for operation with position checking, i.e. the user may not move the mouse too far between clicks.

Parameters
actionButtonDeviceID of the input device containing the action button.
actionButtonID of the device button to be used as the action button.
xAxisDeviceID of the input device containing the X coordinate of the pointer.
xAxisID of the device button/axis to be used for the X coordinate of the pointer.
xToleranceThe amount the pointer may travel in the X coordinate to still be valid.
yAxisDeviceID of the input device containing the Y coordinate of the pointer.
yAxisID of the device button/axis to be used for the Y coordinate of the pointer.
yToleranceThe amount the pointer may travel in the Y coordinate to still be valid.
timeSpanAllowed time between clicks in milliseconds.

◆ InternalUpdate()

void gainput::DoubleClickGesture::InternalUpdate ( InputDeltaState delta)
protectedvirtual

Implementation of the device's Update function.

Parameters
deltaThe delta state to add changes to. May be 0.

Implements gainput::InputDevice.

◆ SetClicksTargetCount()

void gainput::DoubleClickGesture::SetClicksTargetCount ( unsigned  count)
inline

Sets the number of clicks to trigger an action.

Parameters
countThe number of clicks that will trigger this gesture; the default is 2, i.e. double-click.

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