1 #ifndef MSP_INPUT_GESTUREDETECTOR_H_
2 #define MSP_INPUT_GESTUREDETECTOR_H_
25 Interprets events from a Touchscreen as high-level gestures. One button is
26 provided for each type of gesture. Axes 0 and 1 indicate the starting position
27 of the gesture; axes 2 and 3 track its progress. The progress axis may exhibit
28 absolute values greater than one.
30 class GestureDetector: public Device
33 static constexpr size_t MAX_POINTS = 3;
42 bool threshold_exceeded;
47 Touchscreen &touchscreen;
48 TouchPoint points[MAX_POINTS];
49 Gesture current_gesture = GESTURE_NONE;
50 Gesture pending_tap = GESTURE_NONE;
51 bool invalid_gesture = false;
52 float threshold_x_sq = 1.0f;
53 float threshold_y_sq = 1.0f;
56 GestureDetector(Touchscreen &);
58 std::string get_button_name(unsigned) const override;
59 std::string get_axis_name(unsigned) const override;
62 void touch_down(unsigned);
63 void touch_up(unsigned);
64 void touch_move(unsigned, float, float);
66 void set_gesture_location(unsigned);
67 void set_gesture_delta(unsigned);
68 void update_progress();
70 void window_resized(unsigned, unsigned);
74 unsigned gesture_points(Gesture);