TouchInput
Per-frame touch state. SDL events arrive between Update() calls; Update() folds them into a stable snapshot and drops Ended/Canceled entries so each frame sees only currently-active contacts plus their final-frame Ended states.
- Module
- Input
- Header
#include "Input/TouchInput.h"- Namespace
Mowo
Public functions
| Returns | Name | Description |
|---|---|---|
void | OnFingerDown | Called by InputManager / Window from SDL_EVENT_FINGER_* handlers. |
void | OnFingerMotion | |
void | OnFingerUp | |
void | OnFingerCanceled | |
void | Update | Called once per frame before event polling — promotes Began/Moved → Stationary, drops Ended/Canceled. |
const std::vector<TouchPoint>& | GetActiveTouches | Active touches snapshot for the current frame. |
size_t | TouchCount | |
bool | HasAnyTouch | |
bool | IsMultiTouch | |
const TouchPoint* | GetTouchByFingerId | Lookup by SDL finger ID — returns nullptr if not active this frame. |
const TouchPoint* | GetTouch | Lookup by zero-based index (for for (int i = 0; i < TouchCount(); ++i) iteration in scripting languages without iterator support). |
Function details
OnFingerDown
void OnFingerDown(uint64_t fingerId, float x, float y, float pressure)Called by InputManager / Window from SDL_EVENT_FINGER_* handlers. x/y are pixel coordinates (window space), already converted from SDL's normalised 0..1 by the caller. SDL doesn't emit Stationary — that's synthesised internally.
OnFingerMotion
void OnFingerMotion(uint64_t fingerId, float x, float y, float dx, float dy, float pressure)OnFingerUp
void OnFingerUp(uint64_t fingerId, float x, float y, float pressure)OnFingerCanceled
void OnFingerCanceled(uint64_t fingerId)Update
void Update()Called once per frame before event polling — promotes Began/Moved → Stationary, drops Ended/Canceled. Window's ProcessMessages runs polling immediately after this, so the new SDL events overwrite the synthesised Stationary phase for any finger that actually moved.
GetActiveTouches
const std::vector<TouchPoint>& GetActiveTouches() constActive touches snapshot for the current frame. Includes Ended/Canceled entries for the single frame they fired in — gameplay can detect a release without missing it.
TouchCount
size_t TouchCount() constHasAnyTouch
bool HasAnyTouch() constIsMultiTouch
bool IsMultiTouch() constGetTouchByFingerId
const TouchPoint* GetTouchByFingerId(uint64_t fingerId) constLookup by SDL finger ID — returns nullptr if not active this frame.
GetTouch
const TouchPoint* GetTouch(size_t index) constLookup by zero-based index (for for (int i = 0; i < TouchCount(); ++i) iteration in scripting languages without iterator support).