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...
|
| 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 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.
|
|
| 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.
|
| IMouseAdapter? | 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.
|
| MouseEventConfiguration? | 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.
|
| 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, MouseButtonState > | 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.
|
| 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.
|
|
| 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.
|
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.
◆ Initialize()
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
-
| adapter | The 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. |
| mouseEventConfiguration | Optional 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
-
| trackMouseMovement | A 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. |
| timeBetweenEvents | The 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. |
| isPaused | A 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.
◆ Adapter
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
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
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
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
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.
◆ 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.