Gainput  v1.0.0
GainputPinchGesture.h
1 
2 #ifndef GAINPUTPINCHGESTURE_H_
3 #define GAINPUTPINCHGESTURE_H_
4 
5 #ifdef GAINPUT_ENABLE_PINCH_GESTURE
6 
7 namespace gainput
8 {
9 
12 {
15 };
16 
18 
32 class GAINPUT_LIBEXPORT PinchGesture : public InputGesture
33 {
34 public:
36  PinchGesture(InputManager& manager, DeviceId device, unsigned index, DeviceVariant variant);
38  ~PinchGesture();
39 
41 
55  void Initialize(DeviceId downDevice, DeviceButtonId downButton,
56  DeviceId xAxisDevice, DeviceButtonId xAxis,
57  DeviceId yAxisDevice, DeviceButtonId yAxis,
58  DeviceId down2Device, DeviceButtonId downButton2,
59  DeviceId xAxis2Device, DeviceButtonId xAxis2,
60  DeviceId yAxis2Device, DeviceButtonId yAxis2);
61 
62  bool IsValidButtonId(DeviceButtonId deviceButton) const { return deviceButton == PinchTriggered || deviceButton == PinchScale; }
63 
64  ButtonType GetButtonType(DeviceButtonId deviceButton) const { GAINPUT_ASSERT(IsValidButtonId(deviceButton)); return deviceButton == PinchTriggered ? BT_BOOL : BT_FLOAT; }
65 
66 protected:
67  void InternalUpdate(InputDeltaState* delta);
68 
69 private:
70  DeviceButtonSpec downButton_;
71  DeviceButtonSpec xAxis_;
72  DeviceButtonSpec yAxis_;
73  DeviceButtonSpec downButton2_;
74  DeviceButtonSpec xAxis2_;
75  DeviceButtonSpec yAxis2_;
76 
77  bool pinching_;
78  float initialDistance_;
79 };
80 
81 }
82 
83 #endif
84 
85 #endif
86 
The current pinch scale value if pinching is active.
Definition: GainputPinchGesture.h:14
PinchAction
Buttons provided by the PinchGesture.
Definition: GainputPinchGesture.h:11
Manages all input devices and some other helpful stuff.
Definition: GainputInputManager.h:24
A multi-touch pinch-to-scale gesture.
Definition: GainputPinchGesture.h:32
The button that triggers when both pinch buttons are down.
Definition: GainputPinchGesture.h:13
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
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
A floating-point value button, between -1.0f and 1.0f or 0.0f and 1.0f.
Definition: GainputInputDevice.h:13
ButtonType GetButtonType(DeviceButtonId deviceButton) const
Returns the type of the given button.
Definition: GainputPinchGesture.h:64
bool IsValidButtonId(DeviceButtonId deviceButton) const
Returns if the given button is valid for this device.
Definition: GainputPinchGesture.h:62
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