Gondwana Game Engine
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, mobile, and web platforms using SkiaSharp for graphics and NAudio for sound.
Loading...
Searching...
No Matches
Gondwana.Input.Mouse.MouseEventPoller Class Referencesealed

Provides centralized polling and event management for mouse input, including button presses, cursor movement, and scroll wheel activity. This singleton class monitors mouse state and raises events with comprehensive information including button states, position data, scroll deltas, and keyboard modifier states, with support for event throttling and pause functionality. More...

Public Member Functions

void StartMonitoringMouse (bool trackMouseMovement=true, double timeBetweenEvents=-1, bool isPaused=false)
 Starts or reconfigures mouse input monitoring with the specified settings. This method creates a new configuration that controls movement tracking, event throttling, and pause state. Call this method to begin monitoring mouse input or to change monitoring settings.
void StopMonitoringMouse ()
 Stops monitoring mouse input by clearing the configuration. After calling this method, mouse events will no longer be raised until StartMonitoringMouse is called again. This is useful for completely disabling mouse input, such as during specific game states or when transitioning between scenes.

Static Public Member Functions

static void Initialize (IMouseAdapter adapter, MouseEventConfiguration? mouseEventConfiguration=null)
 Initializes the singleton instance of the MouseEventPoller with the specified mouse adapter and optional configuration. This method replaces the existing instance and configures it to monitor mouse input through the provided adapter.

Properties

static ? MouseEventPoller Instance [get]
 Gets the singleton instance of the MouseEventPoller class. This instance is created through the Initialize method and provides centralized access to mouse event polling functionality throughout the application.
IMouseAdapterAdapter [get]
 Gets the mouse adapter currently in use, which provides access to the underlying mouse hardware state including cursor position, pressed buttons, and scroll wheel data. Returns null if no adapter has been configured.
MouseEventConfigurationConfiguration [get]
 Gets the current mouse event configuration, which controls movement tracking, throttling intervals, and pause state. Returns null if mouse monitoring has been stopped or not yet configured.
Point CurrentPosition [get]
 Gets the current position of the mouse cursor in screen or client coordinates. If no adapter is configured, returns the default Point value (0, 0). This property provides convenient access to the cursor position without requiring direct access to the adapter.
KeyboardModifierState CurrentKeyboardModifiers [get]
 Gets the current state of keyboard modifier keys (Shift, Ctrl, Alt) at the time of the last poll. If no adapter is configured, returns KeyboardModifierState.None. This allows mouse event handlers to detect modified mouse operations like Ctrl+Click or Shift+Drag.
IReadOnlyDictionary< MouseButton, MouseButtonStateButtonStates [get]
 Gets a read-only dictionary containing the current state of all monitored mouse buttons, including whether each button is down, was just pressed, or was just released. This provides direct access to button states outside of event handling, useful for polling-based input checks in game loops or update methods.
int ScrollDelta [get]
 Gets the most recent scroll wheel delta value captured during the last poll. Positive values indicate upward scrolling, negative values indicate downward scrolling, and 0 indicates no scrolling. This provides direct access to scroll state outside of event handling.

Events

Action< MouseEventArgs >? MouseEvent
 Occurs when mouse input is detected and the configuration allows the event to be raised based on throttling settings. This event provides comprehensive mouse state information including button states (with press/release transitions), cursor position (current and previous), scroll wheel delta, and keyboard modifier states. Subscribe to this event to handle all mouse input in your application.

Detailed Description

Provides centralized polling and event management for mouse input, including button presses, cursor movement, and scroll wheel activity. This singleton class monitors mouse state and raises events with comprehensive information including button states, position data, scroll deltas, and keyboard modifier states, with support for event throttling and pause functionality.

Member Function Documentation

◆ Initialize()

void Gondwana.Input.Mouse.MouseEventPoller.Initialize ( IMouseAdapter adapter,
MouseEventConfiguration? mouseEventConfiguration = null )
static

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

Parameters
adapterThe mouse adapter that provides access to the current mouse state including cursor position, button presses, scroll wheel data, and keyboard modifiers. This adapter abstracts platform-specific mouse input handling.
mouseEventConfigurationOptional configuration for mouse event monitoring. If null, a default configuration is created with mouse movement tracking enabled and the throttling interval set from Engine.Configuration.TimeBetweenMouseEvents.

◆ StartMonitoringMouse()

void Gondwana.Input.Mouse.MouseEventPoller.StartMonitoringMouse ( bool trackMouseMovement = true,
double timeBetweenEvents = -1,
bool isPaused = false )

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

Parameters
trackMouseMovementA value indicating whether mouse cursor movement should be tracked and reported in events. Set to true to track all mouse movements including hover, or false to only track explicit actions like button presses and scrolling. Default is true.
timeBetweenEventsThe minimum time interval in seconds between consecutive mouse events. Use this to throttle high-frequency mouse input. A value of -1 (default) uses the engine's default time between mouse events from Engine.Configuration.TimeBetweenMouseEvents. A value of 0 means no throttling.
isPausedA value indicating whether event processing for the mouse should be initially paused. When paused, the mouse will not generate events even if moved, clicked, or scrolled. Default is false.

◆ StopMonitoringMouse()

void Gondwana.Input.Mouse.MouseEventPoller.StopMonitoringMouse ( )

Stops monitoring mouse input by clearing the configuration. After calling this method, mouse events will no longer be raised until StartMonitoringMouse is called again. This is useful for completely disabling mouse input, such as during specific game states or when transitioning between scenes.

Property Documentation

◆ Adapter

IMouseAdapter? Gondwana.Input.Mouse.MouseEventPoller.Adapter
get

Gets the mouse adapter currently in use, which provides access to the underlying mouse hardware state including cursor position, pressed buttons, and scroll wheel data. Returns null if no adapter has been configured.

◆ ButtonStates

IReadOnlyDictionary<MouseButton, MouseButtonState> Gondwana.Input.Mouse.MouseEventPoller.ButtonStates
get

Gets a read-only dictionary containing the current state of all monitored mouse buttons, including whether each button is down, was just pressed, or was just released. This provides direct access to button states outside of event handling, useful for polling-based input checks in game loops or update methods.

◆ Configuration

MouseEventConfiguration? Gondwana.Input.Mouse.MouseEventPoller.Configuration
get

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

◆ CurrentKeyboardModifiers

KeyboardModifierState Gondwana.Input.Mouse.MouseEventPoller.CurrentKeyboardModifiers
get

Gets the current state of keyboard modifier keys (Shift, Ctrl, Alt) at the time of the last poll. If no adapter is configured, returns KeyboardModifierState.None. This allows mouse event handlers to detect modified mouse operations like Ctrl+Click or Shift+Drag.

◆ CurrentPosition

Point Gondwana.Input.Mouse.MouseEventPoller.CurrentPosition
get

Gets the current position of the mouse cursor in screen or client coordinates. If no adapter is configured, returns the default Point value (0, 0). This property provides convenient access to the cursor position without requiring direct access to the adapter.

◆ Instance

? MouseEventPoller Gondwana.Input.Mouse.MouseEventPoller.Instance
staticget

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

◆ ScrollDelta

int Gondwana.Input.Mouse.MouseEventPoller.ScrollDelta
get

Gets the most recent scroll wheel delta value captured during the last poll. Positive values indicate upward scrolling, negative values indicate downward scrolling, and 0 indicates no scrolling. This provides direct access to scroll state outside of event handling.

Event Documentation

◆ MouseEvent

Action<MouseEventArgs>? Gondwana.Input.Mouse.MouseEventPoller.MouseEvent

Occurs when mouse input is detected and the configuration allows the event to be raised based on throttling settings. This event provides comprehensive mouse state information including button states (with press/release transitions), cursor position (current and previous), scroll wheel delta, and keyboard modifier states. Subscribe to this event to handle all mouse input in your application.