Gainput  v1.0.0
GainputHoldGesture.h
1 
2 #ifndef GAINPUTHOLDGESTURE_H_
3 #define GAINPUTHOLDGESTURE_H_
4 
5 #ifdef GAINPUT_ENABLE_HOLD_GESTURE
6 
7 namespace gainput
8 {
9 
12 {
14 };
15 
17 
31 class GAINPUT_LIBEXPORT HoldGesture : public InputGesture
32 {
33 public:
35  HoldGesture(InputManager& manager, DeviceId device, unsigned index, DeviceVariant variant);
37  ~HoldGesture();
38 
40 
46  void Initialize(DeviceId actionButtonDevice, DeviceButtonId actionButton, bool oneShot = true, uint64_t timeSpan = 800);
48 
60  void Initialize(DeviceId actionButtonDevice, DeviceButtonId actionButton,
61  DeviceId xAxisDevice, DeviceButtonId xAxis, float xTolerance,
62  DeviceId yAxisDevice, DeviceButtonId yAxis, float yTolerance,
63  bool oneShot = true,
64  uint64_t timeSpan = 800);
65 
66  bool IsValidButtonId(DeviceButtonId deviceButton) const { return deviceButton == HoldTriggered; }
67 
68  ButtonType GetButtonType(DeviceButtonId deviceButton) const { GAINPUT_UNUSED(deviceButton); GAINPUT_ASSERT(IsValidButtonId(deviceButton)); return BT_BOOL; }
69 
70 protected:
71  void InternalUpdate(InputDeltaState* delta);
72 
73 private:
74  DeviceButtonSpec actionButton_;
75  DeviceButtonSpec xAxis_;
76  float xTolerance_;
77  DeviceButtonSpec yAxis_;
78  float yTolerance_;
79 
80  bool oneShot_;
81  bool oneShotReset_;
82  uint64_t timeSpan_;
83  uint64_t firstDownTime_;
84 
85  float firstDownX_;
86  float firstDownY_;
87 };
88 
89 }
90 
91 #endif
92 
93 #endif
94 
bool IsValidButtonId(DeviceButtonId deviceButton) const
Returns if the given button is valid for this device.
Definition: GainputHoldGesture.h:66
The button that triggers after holding for the given time.
Definition: GainputHoldGesture.h:13
Manages all input devices and some other helpful stuff.
Definition: GainputInputManager.h:24
A boolean value button, either down (true) or up (false).
Definition: GainputInputDevice.h:12
ButtonType
Type of an input device button.
Definition: GainputInputDevice.h:10
A hold-to-trigger gesture.
Definition: GainputHoldGesture.h:31
Stores a list of input state changes.
Definition: GainputInputDeltaState.h:9
Describes a device button on a specific device.
Definition: gainput.h:112
HoldAction
Buttons provided by the HoldGesture.
Definition: GainputHoldGesture.h:11
unsigned int DeviceId
ID of an input device.
Definition: gainput.h:107
DeviceVariant
Variant of an input device type.
Definition: GainputInputDevice.h:51
Base class for all input gestures.
Definition: GainputGestures.h:41
ButtonType GetButtonType(DeviceButtonId deviceButton) const
Returns the type of the given button.
Definition: GainputHoldGesture.h:68
unsigned int DeviceButtonId
ID of a specific button unique to an input device.
Definition: gainput.h:109
Contains all Gainput related classes, types, and functions.
Definition: gainput.h:103