Gainput  v1.0.0
GainputDoubleClickGesture.h
1 
2 #ifndef GAINPUTDOUBLECLICKGESTURE_H_
3 #define GAINPUTDOUBLECLICKGESTURE_H_
4 
5 #ifdef GAINPUT_ENABLE_DOUBLE_CLICK_GESTURE
6 
7 namespace gainput
8 {
9 
12 {
14 };
15 
17 
32 class GAINPUT_LIBEXPORT DoubleClickGesture : public InputGesture
33 {
34 public:
36  DoubleClickGesture(InputManager& manager, DeviceId device, unsigned index, DeviceVariant variant);
39 
41 
46  void Initialize(DeviceId actionButtonDevice, DeviceButtonId actionButton, uint64_t timeSpan = 300);
48 
59  void Initialize(DeviceId actionButtonDevice, DeviceButtonId actionButton,
60  DeviceId xAxisDevice, DeviceButtonId xAxis, float xTolerance,
61  DeviceId yAxisDevice, DeviceButtonId yAxis, float yTolerance,
62  uint64_t timeSpan = 300);
63 
65 
68  void SetClicksTargetCount(unsigned count) { clicksTargetCount_ = count; }
69 
70  bool IsValidButtonId(DeviceButtonId deviceButton) const { return deviceButton == DoubleClickTriggered; }
71 
72  ButtonType GetButtonType(DeviceButtonId deviceButton) const { GAINPUT_UNUSED(deviceButton); GAINPUT_ASSERT(IsValidButtonId(deviceButton)); return BT_BOOL; }
73 
74 protected:
75  void InternalUpdate(InputDeltaState* delta);
76 
77 private:
78  DeviceButtonSpec actionButton_;
79  DeviceButtonSpec xAxis_;
80  float xTolerance_;
81  DeviceButtonSpec yAxis_;
82  float yTolerance_;
83 
84  uint64_t timeSpan_;
85  uint64_t firstClickTime_;
86 
87  float firstClickX_;
88  float firstClickY_;
89 
90  unsigned clicksRegistered_;
91  unsigned clicksTargetCount_;
92 };
93 
94 }
95 
96 #endif
97 
98 #endif
99 
void SetClicksTargetCount(unsigned count)
Sets the number of clicks to trigger an action.
Definition: GainputDoubleClickGesture.h:68
DoubleClickAction
Buttons provided by the DoubleClickGesture.
Definition: GainputDoubleClickGesture.h:11
bool IsValidButtonId(DeviceButtonId deviceButton) const
Returns if the given button is valid for this device.
Definition: GainputDoubleClickGesture.h:70
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
Stores a list of input state changes.
Definition: GainputInputDeltaState.h:9
Describes a device button on a specific device.
Definition: gainput.h:112
A double-click gesture.
Definition: GainputDoubleClickGesture.h:32
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: GainputDoubleClickGesture.h:72
The button triggered by double-clicking.
Definition: GainputDoubleClickGesture.h:13
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