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.Keyboard.KeyboardEventPoller Class Referencesealed

Cross-platform singleton keyboard handler with throttling and manual input state feeding. More...

Public Member Functions

void StartMonitoringKey (int keyCode, string? displayName=null, double timeBetweenEvents=-1, bool isPaused=false)
 Primary API: monitor by platform-agnostic key code. Platform layers (WinForms, SDL, etc.) are responsible for mapping their key enums/names to key codes.
void StopMonitoringKey (int keyCode)
 Unregisters a specific key from event monitoring by its platform-agnostic key code. After calling this method, the key will no longer be polled and will not generate KeyDown events until it is registered again using StartMonitoringKey.
void StopMonitoringKey (string key)
 Unregisters a specific key from event monitoring by parsing its string representation. If the string can be parsed as an integer key code, the key will be unregistered. After calling this method, the key will no longer generate KeyDown events.
void StopMonitoringAllKeys ()
 Unregisters all keys from event monitoring, clearing all key configurations and state tracking. After calling this method, no keys will generate events until they are registered again using StartMonitoringKey. This is useful for resetting the keyboard state when changing game modes or screens.

Static Public Member Functions

static void Initialize (IKeyboardAdapter adapter)
 Initializes the singleton instance of the KeyboardEventPoller with the specified keyboard adapter. This method replaces the existing instance and configures it to monitor keyboard input through the provided adapter.

Properties

static ? KeyboardEventPoller Instance [get]
 Singleton instance of the KeyboardEventPoller class.
IKeyboardAdapter? Adapter [get]
 Gets the current keyboard adapter in use.
bool PauseAllKeyEvents [get, set]
 Pauses all key events globally.
IReadOnlyDictionary< int, KeyEventConfiguration > AllKeyConfigs [get]
 Exposes monitored key configurations. Treat as engine-thread-only unless you add external synchronization.

Events

Action< KeyDownEventArgs >? KeyDown
 Occurs when a monitored keyboard key is pressed, released, or repeated based on its configuration and throttling settings. Subscribe to this event to handle keyboard input in your application. The event provides information about the key action (pressed, released, or repeated) and current keyboard modifier states.

Detailed Description

Cross-platform singleton keyboard handler with throttling and manual input state feeding.

Definition at line 9 of file KeyboardEventPoller.cs.

Member Function Documentation

◆ Initialize()

void Gondwana.Input.Keyboard.KeyboardEventPoller.Initialize ( IKeyboardAdapter adapter)
static

Initializes the singleton instance of the KeyboardEventPoller with the specified keyboard adapter. This method replaces the existing instance and configures it to monitor keyboard input through the provided adapter.

Parameters
adapterThe keyboard adapter that provides access to the current keyboard state and key press information. This adapter abstracts platform-specific keyboard input handling.

Definition at line 24 of file KeyboardEventPoller.cs.

◆ StartMonitoringKey()

void Gondwana.Input.Keyboard.KeyboardEventPoller.StartMonitoringKey ( int keyCode,
string? displayName = null,
double timeBetweenEvents = -1,
bool isPaused = false )

Primary API: monitor by platform-agnostic key code. Platform layers (WinForms, SDL, etc.) are responsible for mapping their key enums/names to key codes.

Parameters
keyCodeThe key code to query.
displayNameThe display name.
timeBetweenEventsThe time between events.
isPausedWhether event processing starts paused.

Definition at line 129 of file KeyboardEventPoller.cs.

◆ StopMonitoringAllKeys()

void Gondwana.Input.Keyboard.KeyboardEventPoller.StopMonitoringAllKeys ( )

Unregisters all keys from event monitoring, clearing all key configurations and state tracking. After calling this method, no keys will generate events until they are registered again using StartMonitoringKey. This is useful for resetting the keyboard state when changing game modes or screens.

Definition at line 185 of file KeyboardEventPoller.cs.

◆ StopMonitoringKey() [1/2]

void Gondwana.Input.Keyboard.KeyboardEventPoller.StopMonitoringKey ( int keyCode)

Unregisters a specific key from event monitoring by its platform-agnostic key code. After calling this method, the key will no longer be polled and will not generate KeyDown events until it is registered again using StartMonitoringKey.

Parameters
keyCodeThe platform-agnostic key code identifying the key to stop monitoring. This should match the key code used when calling StartMonitoringKey.

Definition at line 155 of file KeyboardEventPoller.cs.

◆ StopMonitoringKey() [2/2]

void Gondwana.Input.Keyboard.KeyboardEventPoller.StopMonitoringKey ( string key)

Unregisters a specific key from event monitoring by parsing its string representation. If the string can be parsed as an integer key code, the key will be unregistered. After calling this method, the key will no longer generate KeyDown events.

Parameters
keyA string representation of the key code to stop monitoring. The string must be parseable as an integer. If parsing fails, this method has no effect.

Definition at line 173 of file KeyboardEventPoller.cs.

Property Documentation

◆ Adapter

IKeyboardAdapter? Gondwana.Input.Keyboard.KeyboardEventPoller.Adapter
get

Gets the current keyboard adapter in use.

Definition at line 54 of file KeyboardEventPoller.cs.

◆ AllKeyConfigs

IReadOnlyDictionary<int, KeyEventConfiguration> Gondwana.Input.Keyboard.KeyboardEventPoller.AllKeyConfigs
get

Exposes monitored key configurations. Treat as engine-thread-only unless you add external synchronization.

Definition at line 197 of file KeyboardEventPoller.cs.

◆ Instance

? KeyboardEventPoller Gondwana.Input.Keyboard.KeyboardEventPoller.Instance
staticget

Singleton instance of the KeyboardEventPoller class.

Definition at line 14 of file KeyboardEventPoller.cs.

◆ PauseAllKeyEvents

bool Gondwana.Input.Keyboard.KeyboardEventPoller.PauseAllKeyEvents
getset

Pauses all key events globally.

Definition at line 59 of file KeyboardEventPoller.cs.

Event Documentation

◆ KeyDown

Action<KeyDownEventArgs>? Gondwana.Input.Keyboard.KeyboardEventPoller.KeyDown

Occurs when a monitored keyboard key is pressed, released, or repeated based on its configuration and throttling settings. Subscribe to this event to handle keyboard input in your application. The event provides information about the key action (pressed, released, or repeated) and current keyboard modifier states.

Definition at line 35 of file KeyboardEventPoller.cs.