1 #ifndef MSP_INPUT_GESTUREDETECTOR_H_
2 #define MSP_INPUT_GESTUREDETECTOR_H_
4 #include <msp/graphics/mspgui_api.h>
26 Interprets events from a Touchscreen as high-level gestures. One button is
27 provided for each type of gesture. Axes 0 and 1 indicate the starting position
28 of the gesture; axes 2 and 3 track its progress. The progress axis may exhibit
29 absolute values greater than one.
31 class MSPGUI_API GestureDetector: public Device
34 static constexpr size_t MAX_POINTS = 3;
43 bool threshold_exceeded;
48 Touchscreen &touchscreen;
49 TouchPoint points[MAX_POINTS];
50 Gesture current_gesture = GESTURE_NONE;
51 Gesture pending_tap = GESTURE_NONE;
52 bool invalid_gesture = false;
53 float threshold_x_sq = 1.0f;
54 float threshold_y_sq = 1.0f;
57 GestureDetector(Touchscreen &);
59 std::string get_button_name(unsigned) const override;
60 std::string get_axis_name(unsigned) const override;
63 void touch_down(unsigned);
64 void touch_up(unsigned);
65 void touch_move(unsigned, float, float);
67 void set_gesture_location(unsigned);
68 void set_gesture_delta(unsigned);
69 void update_progress();
71 void window_resized(unsigned, unsigned);
75 MSPGUI_API unsigned gesture_points(Gesture);