mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-08 04:20:14 -05:00
Merge pull request #1115 from OpenSpace/feature/continuous-pinch
Feature/continuous pinch
This commit is contained in:
@@ -32,6 +32,9 @@
|
||||
|
||||
namespace openspace {
|
||||
|
||||
// The TouchInput represents a single finger/device-input at a specific point in time.
|
||||
// the fingerId and touchDeviceId coupled with the timestamp allows this to be compared
|
||||
// with other TouchInputs in order to calculate gesture-like behaviour.
|
||||
struct TouchInput {
|
||||
TouchInput(size_t touchDeviceId, size_t fingerId, float x, float y, double timestamp);
|
||||
glm::vec2 screenCoordinates(glm::vec2 resolution) const;
|
||||
@@ -46,19 +49,25 @@ struct TouchInput {
|
||||
float y;
|
||||
float dx = 0.f; // movement in x direction since last touch input
|
||||
float dy = 0.f; // movement in y direction since last touch input
|
||||
double timestamp; // timestamp in seconds from global touch initialization
|
||||
double timestamp; // timestamp in seconds from global touch initialization
|
||||
};
|
||||
|
||||
// The TouchInputHolder holds one or many TouchInputs, in order to track the history of
|
||||
// the finger/input device
|
||||
class TouchInputHolder {
|
||||
public:
|
||||
TouchInputHolder(TouchInput input);
|
||||
|
||||
// tryAddInput:
|
||||
// Succeeds upon a different input than last.
|
||||
// Fails upon a too similar input as last.
|
||||
// Updates time for the last input if same position.
|
||||
bool tryAddInput(TouchInput input);
|
||||
|
||||
void clearInputs();
|
||||
|
||||
// Checks whether or not this Holder actually holds a specific input (based on IDs)
|
||||
// Succeeds when `input` is held by this Holder
|
||||
// Fails if `input` is not held by this Holder
|
||||
bool holdsInput(const TouchInput &input) const;
|
||||
|
||||
size_t touchDeviceId() const;
|
||||
@@ -72,12 +81,14 @@ public:
|
||||
double gestureTime() const;
|
||||
|
||||
size_t numInputs() const;
|
||||
const TouchInput& firstInput() const;
|
||||
const TouchInput& latestInput() const;
|
||||
const std::deque<TouchInput>& peekInputs() const;
|
||||
|
||||
private:
|
||||
//A deque of recorded inputs. Adding newer points to the front of the queue
|
||||
std::deque<TouchInput> _inputs;
|
||||
TouchInput _firstInput;
|
||||
|
||||
size_t _touchDeviceId;
|
||||
size_t _fingerId;
|
||||
|
||||
Reference in New Issue
Block a user