--- /dev/null
+#ifndef MSP_INPUT_GESTUREDETECTOR_H_
+#define MSP_INPUT_GESTUREDETECTOR_H_
+
+#include "device.h"
+
+namespace Msp {
+namespace Input {
+
+class Touchscreen;
+
+enum Gesture
+{
+ GESTURE_NONE,
+ GESTURE_SWIPE_DOWN,
+ GESTURE_SWIPE_UP,
+ GESTURE_SWIPE_LEFT,
+ GESTURE_SWIPE_RIGHT,
+ GESTURE_PINCH
+};
+
+/**
+Interprets events from a Touchscreen as high-level gestures. One button is
+provided for each type of gesture. Axes 0 and 1 indicate the starting position
+of the gesture; axis 2 tracks its progress. The progress axis may exhibit
+absolute values greater than one.
+*/
+class GestureDetector: public Device
+{
+private:
+ struct TouchPoint
+ {
+ bool down;
+ float down_x;
+ float down_y;
+ float x;
+ float y;
+
+ TouchPoint();
+ };
+
+ Touchscreen &touchscreen;
+ TouchPoint points[3];
+ Gesture current_gesture;
+ unsigned active_points;
+ bool invalid_gesture;
+ float threshold_x_sq;
+ float threshold_y_sq;
+
+public:
+ GestureDetector(Touchscreen &);
+
+ virtual std::string get_button_name(unsigned) const;
+ virtual std::string get_axis_name(unsigned) const;
+
+private:
+ void touch_down(unsigned);
+ void touch_up(unsigned);
+ void touch_move(unsigned, float, float);
+ void start_gesture();
+ void update_progress();
+ void window_resized(unsigned, unsigned);
+};
+
+} // namespace Input
+} // namespace Msp
+
+#endif