Files
ppsspp/Common/Input/GestureDetector.h

52 lines
1.2 KiB
C
Raw Permalink Normal View History

#pragma once
#include <cstdint>
#include "Common/Input/InputState.h"
#include "Common/Math/geom2d.h"
2013-05-25 15:12:46 +02:00
// Mainly for detecting (multi-)touch gestures but also useable for left button mouse dragging etc.
2013-10-16 11:29:58 +02:00
// Currently only supports simple scroll-drags with inertia.
// TODO: Two-finger zoom/rotate etc.
2013-05-25 15:12:46 +02:00
enum Gesture {
GESTURE_DRAG_VERTICAL = 1,
GESTURE_DRAG_HORIZONTAL = 2,
GESTURE_TWO_FINGER_ZOOM = 4,
GESTURE_TWO_FINGER_ZOOM_ROTATE = 8,
};
// May track multiple gestures at the same time. You simply call GetGestureInfo
// with the gesture you are interested in.
2013-05-25 16:52:27 +02:00
class GestureDetector {
2013-05-25 15:12:46 +02:00
public:
GestureDetector();
TouchInput Update(const TouchInput &touch, const Bounds &bounds);
2013-08-20 11:35:54 +02:00
void UpdateFrame();
bool IsGestureActive(Gesture gesture, int touchId) const;
bool GetGestureInfo(Gesture gesture, int touchId, float info[4]) const;
2013-05-25 15:12:46 +02:00
private:
enum Locals {
2013-10-16 11:29:58 +02:00
MAX_PTRS = 10,
2013-05-25 15:12:46 +02:00
};
struct Pointer {
bool down;
double downTime;
float lastX;
float lastY;
float downX;
float downY;
float deltaX;
float deltaY;
float distanceX;
float distanceY;
float estimatedInertiaX;
float estimatedInertiaY;
uint32_t active;
2013-05-25 15:12:46 +02:00
};
Pointer pointers[MAX_PTRS]{};
2013-05-25 15:12:46 +02:00
};