Gondwana Game Engine Development (master) - 2.6.1
Gondwana is a cross-platform 2.5D game and rendering engine written in C#/.NET 8. It provides fine-grained control over rendering, timing, and scene composition, with built-in support for parallax, z-ordering, pixel overhang, collision detection, and particle effects. Gondwana targets desktop and web platforms using SkiaSharp for graphics and pluggable audio backends for desktop and browser targets.
Loading...
Searching...
No Matches
Gondwana.Input.Touch.TouchEventPoller Class Referencesealed

Provides centralized polling and event management for touch input. This singleton class monitors touch adapter state each engine frame, detects contact transitions, and raises events with comprehensive touch point information, with support for event throttling and pause functionality. More...

Inheritance diagram for Gondwana.Input.Touch.TouchEventPoller:
Gondwana.Input.Touch.ITouchInput

Public Member Functions

void StartMonitoringTouch (double timeBetweenEvents=-1, bool isPaused=false)
 Starts or reconfigures touch input monitoring with the specified settings. This method creates a new configuration that controls event throttling and pause state. Call this method to begin monitoring touch input or to change monitoring settings.
void StopMonitoringTouch ()
 Stops monitoring touch input by clearing the configuration. After calling this method, touch events will no longer be raised until StartMonitoringTouch is called again.
void Dispose ()
 Releases recognizers and the current platform adapter.

Static Public Member Functions

static void Initialize (ITouchAdapter adapter, TouchEventConfiguration? config=null)
 Initializes the singleton instance of the TouchEventPoller with the specified touch adapter and optional configuration. This method replaces the existing instance and configures it to monitor touch input through the provided adapter.
static void Reset ()
 Disposes and clears the current singleton instance, including its adapter.

Properties

static ? TouchEventPoller Instance [get]
 Gets the singleton instance of the TouchEventPoller class. This instance is created through the Initialize method and provides centralized access to touch event polling functionality throughout the application.
IReadOnlyList< TouchPoint > ActiveTouches [get]
 Gets the list of touch contact points that are currently active (in contact with the surface). This list is updated before each event is raised and reflects the state at the time of the last pointer action. An empty list indicates no fingers are currently in contact.
ITouchAdapter? Adapter [get]
 Gets the touch adapter currently in use, which provides access to the underlying touch state including active contacts and ended contacts. Returns null if no adapter has been configured.
TouchEventConfiguration? Configuration [get]
 Gets the current touch event configuration, which controls movement-event throttling and pause state. Returns null if touch monitoring has been stopped or not yet configured.
TapGestureRecognizer TapRecognizer [get]
 Gets the tap gesture recognizer used by this poller. Adjust TapGestureRecognizer.MaxTapDurationSeconds and TapGestureRecognizer.MaxTapMovementPixels to tune tap detection thresholds.
SwipeGestureRecognizer SwipeRecognizer [get]
 Gets the swipe gesture recognizer used by this poller. Adjust SwipeGestureRecognizer.MinimumSwipeSpeedPixelsPerSecond to tune swipe detection thresholds.
PinchGestureRecognizer PinchRecognizer [get]
 Gets the pinch gesture recognizer used by this poller.

Events

EventHandler< TouchEventArgs >? TouchBegan
EventHandler< TouchEventArgs >? TouchMoved
EventHandler< TouchEventArgs >? TouchEnded
Action< GestureEventArgs >? TouchEvent
 Occurs when any recognized gesture — tap, swipe, or pinch — is detected. Inspect GestureEventArgs.IsTap, GestureEventArgs.IsSwipe, or GestureEventArgs.IsPinch to determine the gesture kind, then access the corresponding property (GestureEventArgs.Tap, GestureEventArgs.Swipe, or GestureEventArgs.Pinch) for the specific data.
Events inherited from Gondwana.Input.Touch.ITouchInput
EventHandler< TouchEventArgs > TouchBegan
 Occurs when a new touch contact begins — a finger or pointer first makes contact with the surface. The TouchEventArgs.Touch property contains the new contact point with TouchPhase.Began.
EventHandler< TouchEventArgs > TouchMoved
 Occurs when an active touch contact moves across the surface. The TouchEventArgs.Touch property contains the updated contact point with TouchPhase.Moved.
EventHandler< TouchEventArgs > TouchEnded
 Occurs when an active touch contact ends — a finger or pointer lifts from the surface, or the contact is cancelled by the system. The TouchEventArgs.Touch property contains the final contact point with TouchPhase.Ended or TouchPhase.Cancelled.

Detailed Description

Provides centralized polling and event management for touch input. This singleton class monitors touch adapter state each engine frame, detects contact transitions, and raises events with comprehensive touch point information, with support for event throttling and pause functionality.

TouchEventPoller implements ITouchInput so that all gesture recognizers (TapGestureRecognizer, SwipeGestureRecognizer, PinchGestureRecognizer) work unchanged.

The adapter (ITouchAdapter) is a passive state holder updated by platform events on the UI thread. The poller is called by the engine each frame to diff state, detect transitions, and raise events on the engine thread.

Definition at line 23 of file TouchEventPoller.cs.

Member Function Documentation

◆ Dispose()

void Gondwana.Input.Touch.TouchEventPoller.Dispose ( )

Releases recognizers and the current platform adapter.

Definition at line 297 of file TouchEventPoller.cs.

◆ Initialize()

void Gondwana.Input.Touch.TouchEventPoller.Initialize ( ITouchAdapter adapter,
TouchEventConfiguration? config = null )
static

Initializes the singleton instance of the TouchEventPoller with the specified touch adapter and optional configuration. This method replaces the existing instance and configures it to monitor touch input through the provided adapter.

Parameters
adapterThe touch adapter that provides access to the current touch state including active contacts and ended contacts. This adapter abstracts platform-specific touch input handling.
configOptional configuration for touch event monitoring. If null, a default configuration is created using Engine.Instance's Gondwana.Configuration.EngineConfiguration.TimeBetweenTouchEvents as the throttle interval.

Definition at line 47 of file TouchEventPoller.cs.

◆ Reset()

void Gondwana.Input.Touch.TouchEventPoller.Reset ( )
static

Disposes and clears the current singleton instance, including its adapter.

Definition at line 61 of file TouchEventPoller.cs.

◆ StartMonitoringTouch()

void Gondwana.Input.Touch.TouchEventPoller.StartMonitoringTouch ( double timeBetweenEvents = -1,
bool isPaused = false )

Starts or reconfigures touch input monitoring with the specified settings. This method creates a new configuration that controls event throttling and pause state. Call this method to begin monitoring touch input or to change monitoring settings.

Parameters
timeBetweenEventsThe minimum time interval in seconds between consecutive touch movement events. Touch beginnings, endings, and cancellations are never throttled. Use the default time between touch events from Gondwana.Configuration.EngineConfiguration.TimeBetweenTouchEvents when a value less than zero is supplied. A value of 0 means no throttling.
isPausedA value indicating whether event processing for touch should be initially paused. When paused, touch will not generate events even if contacts change. Default is false.

Definition at line 267 of file TouchEventPoller.cs.

◆ StopMonitoringTouch()

void Gondwana.Input.Touch.TouchEventPoller.StopMonitoringTouch ( )

Stops monitoring touch input by clearing the configuration. After calling this method, touch events will no longer be raised until StartMonitoringTouch is called again.

Definition at line 279 of file TouchEventPoller.cs.

Property Documentation

◆ ActiveTouches

IReadOnlyList<TouchPoint> Gondwana.Input.Touch.TouchEventPoller.ActiveTouches
get

Gets the list of touch contact points that are currently active (in contact with the surface). This list is updated before each event is raised and reflects the state at the time of the last pointer action. An empty list indicates no fingers are currently in contact.

Implements Gondwana.Input.Touch.ITouchInput.

Definition at line 71 of file TouchEventPoller.cs.

◆ Adapter

ITouchAdapter? Gondwana.Input.Touch.TouchEventPoller.Adapter
get

Gets the touch adapter currently in use, which provides access to the underlying touch state including active contacts and ended contacts. Returns null if no adapter has been configured.

Definition at line 78 of file TouchEventPoller.cs.

◆ Configuration

TouchEventConfiguration? Gondwana.Input.Touch.TouchEventPoller.Configuration
get

Gets the current touch event configuration, which controls movement-event throttling and pause state. Returns null if touch monitoring has been stopped or not yet configured.

Definition at line 84 of file TouchEventPoller.cs.

◆ Instance

? TouchEventPoller Gondwana.Input.Touch.TouchEventPoller.Instance
staticget

Gets the singleton instance of the TouchEventPoller class. This instance is created through the Initialize method and provides centralized access to touch event polling functionality throughout the application.

Definition at line 30 of file TouchEventPoller.cs.

◆ PinchRecognizer

PinchGestureRecognizer Gondwana.Input.Touch.TouchEventPoller.PinchRecognizer
get

Gets the pinch gesture recognizer used by this poller.

Definition at line 128 of file TouchEventPoller.cs.

◆ SwipeRecognizer

SwipeGestureRecognizer Gondwana.Input.Touch.TouchEventPoller.SwipeRecognizer
get

Gets the swipe gesture recognizer used by this poller. Adjust SwipeGestureRecognizer.MinimumSwipeSpeedPixelsPerSecond to tune swipe detection thresholds.

Definition at line 123 of file TouchEventPoller.cs.

◆ TapRecognizer

TapGestureRecognizer Gondwana.Input.Touch.TouchEventPoller.TapRecognizer
get

Gets the tap gesture recognizer used by this poller. Adjust TapGestureRecognizer.MaxTapDurationSeconds and TapGestureRecognizer.MaxTapMovementPixels to tune tap detection thresholds.

Definition at line 116 of file TouchEventPoller.cs.

Event Documentation

◆ TouchBegan

EventHandler<TouchEventArgs>? Gondwana.Input.Touch.TouchEventPoller.TouchBegan

Definition at line 87 of file TouchEventPoller.cs.

◆ TouchEnded

EventHandler<TouchEventArgs>? Gondwana.Input.Touch.TouchEventPoller.TouchEnded

Definition at line 93 of file TouchEventPoller.cs.

◆ TouchEvent

Action<GestureEventArgs>? Gondwana.Input.Touch.TouchEventPoller.TouchEvent

Occurs when any recognized gesture — tap, swipe, or pinch — is detected. Inspect GestureEventArgs.IsTap, GestureEventArgs.IsSwipe, or GestureEventArgs.IsPinch to determine the gesture kind, then access the corresponding property (GestureEventArgs.Tap, GestureEventArgs.Swipe, or GestureEventArgs.Pinch) for the specific data.

The internal gesture recognizers (TapRecognizer, SwipeRecognizer, PinchRecognizer) are owned by this poller instance. They subscribe to this poller's own touch events and their lifetime is bound to the lifetime of this instance — when the instance is replaced via Initialize the entire object graph (poller + recognizers + subscriptions) becomes unreachable and is collected together.

Definition at line 109 of file TouchEventPoller.cs.

◆ TouchMoved

EventHandler<TouchEventArgs>? Gondwana.Input.Touch.TouchEventPoller.TouchMoved

Definition at line 90 of file TouchEventPoller.cs.