|
Player12
An open source football management simulator
|
Recognises a two-finger sideways swipe from wheel samples. More...
#include <swipe_gesture.h>
Public Types | |
| enum class | Step : uint8_t { NONE , BACK , FORWARD } |
Public Member Functions | |
| SwipeGesture ()=default | |
| SwipeGesture (const SwipeTuning &settings) | |
| Step | feed (float dx, float dy, std::uint64_t timestamp_ns) |
| Adds a wheel sample; returns the step it completes, if any. | |
| void | suppress (std::uint64_t timestamp_ns) |
| Ignores the rest of the current gesture, e.g. while it runs over a list that scrolls sideways or while a dialog is open. | |
| void | reset () |
| Forgets the gesture in progress. | |
| float | progress (std::uint64_t now_ns) const |
How far the gesture has gone at now_ns: 0 when none, up to 1 towards Back and down to -1 towards Forward (±1 once it stepped). | |
| const SwipeTuning & | getTuning () const |
Private Types | |
| enum class | Phase : uint8_t { IDLE , UNDECIDED , SIDEWAYS , IGNORED , DONE } |
Private Member Functions | |
| bool | expired (std::uint64_t now_ns) const |
Private Attributes | |
| SwipeTuning | tuning |
| Phase | phase = Phase::IDLE |
| float | travel_x = 0.0f |
| float | travel_y = 0.0f |
| std::uint64_t | last_ns = 0 |
Recognises a two-finger sideways swipe from wheel samples.
Fed with each wheel sample (dx > 0: the fingers moved right), it reports one step per gesture once the sideways travel passes the threshold, and then ignores the rest of that gesture. A gesture that starts vertically is a page scroll and is ignored until it ends; so is one that drifts into a vertical scroll. A pause longer than the idle gap starts a new gesture.
|
strongprivate |
|
strong |
|
default |
|
inlineexplicit |
|
private |
| SwipeGesture::Step SwipeGesture::feed | ( | float | dx, |
| float | dy, | ||
| std::uint64_t | timestamp_ns | ||
| ) |
Adds a wheel sample; returns the step it completes, if any.
|
inline |
| float SwipeGesture::progress | ( | std::uint64_t | now_ns | ) | const |
How far the gesture has gone at now_ns: 0 when none, up to 1 towards Back and down to -1 towards Forward (±1 once it stepped).
| void SwipeGesture::reset | ( | ) |
Forgets the gesture in progress.
| void SwipeGesture::suppress | ( | std::uint64_t | timestamp_ns | ) |
Ignores the rest of the current gesture, e.g. while it runs over a list that scrolls sideways or while a dialog is open.
|
private |
|
private |
|
private |
|
private |
|
private |