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.Blazor.Input.Keyboard.BlazorKeyboardAdapter Class Referencesealed

Keyboard adapter for Blazor applications that feeds the Gondwana KeyboardEventPoller by translating browser KeyboardEvent.code values into BlazorKey integer codes. More...

Inheritance diagram for Gondwana.Blazor.Input.Keyboard.BlazorKeyboardAdapter:
Gondwana.Input.Keyboard.IKeyboardAdapter

Public Member Functions

 BlazorKeyboardAdapter (BlazorBitmapRenderSurfaceComponent component)
 Initializes a new instance of BlazorKeyboardAdapter and attaches it to the keyboard events on the specified render surface component.
 BlazorKeyboardAdapter (BlazorRenderSurfaceComponentBase component)
 Initializes a new instance of BlazorKeyboardAdapter for any Gondwana Blazor render surface.
bool IsDown (int keyCode)
 Returns true if the specified platform-agnostic key code is currently down. Key codes should be stable integers agreed upon by the adapter and the engine. For WinForms, this should be the Windows Virtual-Key code (0..255).
Parameters
keyCodeThe key code to query.
Returns
true if the key is currently pressed; otherwise, false.

void Dispose ()
 Releases all resources and removes event handlers registered by this adapter.

Static Public Member Functions

static ? int GetKeyCodeFromString (string keyName)
 Converts a key name (a BlazorKey member name or a browser KeyboardEvent.code string) to its integer key code.

Properties

KeyboardModifierState CurrentKeyboardModifiers [get]
 Gets the current state of modifier keys, such as Shift, Ctrl, and Alt. Must be safe to read from the Engine thread at high frequency.

Detailed Description

Keyboard adapter for Blazor applications that feeds the Gondwana KeyboardEventPoller by translating browser KeyboardEvent.code values into BlazorKey integer codes.

Key codes correspond to BlazorKey values cast to int. Use GetKeyCodeFromString to resolve a key name at runtime, or use (int)BlazorKey.Space directly in game code.

Keyboard events are captured on the canvas element owned by BlazorRenderSurfaceComponentBase. The canvas must have focus for events to be received; the component requests focus automatically on first render.

Definition at line 26 of file BlazorKeyboardAdapter.cs.

Constructor & Destructor Documentation

◆ BlazorKeyboardAdapter() [1/2]

Gondwana.Blazor.Input.Keyboard.BlazorKeyboardAdapter.BlazorKeyboardAdapter ( BlazorBitmapRenderSurfaceComponent component)

Initializes a new instance of BlazorKeyboardAdapter and attaches it to the keyboard events on the specified render surface component.

Parameters
componentThe render surface component to capture keyboard input from.
Exceptions
ArgumentNullExceptionThrown when component is null.

Definition at line 45 of file BlazorKeyboardAdapter.cs.

◆ BlazorKeyboardAdapter() [2/2]

Gondwana.Blazor.Input.Keyboard.BlazorKeyboardAdapter.BlazorKeyboardAdapter ( BlazorRenderSurfaceComponentBase component)

Initializes a new instance of BlazorKeyboardAdapter for any Gondwana Blazor render surface.

Parameters
componentThe render surface component to capture keyboard input from.
Exceptions
ArgumentNullExceptionThrown when component is null.

Definition at line 56 of file BlazorKeyboardAdapter.cs.

Member Function Documentation

◆ Dispose()

void Gondwana.Blazor.Input.Keyboard.BlazorKeyboardAdapter.Dispose ( )

Releases all resources and removes event handlers registered by this adapter.

Definition at line 124 of file BlazorKeyboardAdapter.cs.

◆ GetKeyCodeFromString()

? int Gondwana.Blazor.Input.Keyboard.BlazorKeyboardAdapter.GetKeyCodeFromString ( string keyName)
static

Converts a key name (a BlazorKey member name or a browser KeyboardEvent.code string) to its integer key code.

Parameters
keyNameThe key name to resolve.
Returns
The integer key code, or null if the name is not recognized.

Definition at line 81 of file BlazorKeyboardAdapter.cs.

◆ IsDown()

bool Gondwana.Blazor.Input.Keyboard.BlazorKeyboardAdapter.IsDown ( int keyCode)

Returns true if the specified platform-agnostic key code is currently down. Key codes should be stable integers agreed upon by the adapter and the engine. For WinForms, this should be the Windows Virtual-Key code (0..255).

Parameters
keyCodeThe key code to query.
Returns
true if the key is currently pressed; otherwise, false.

Implements Gondwana.Input.Keyboard.IKeyboardAdapter.

Definition at line 69 of file BlazorKeyboardAdapter.cs.

Property Documentation

◆ CurrentKeyboardModifiers

KeyboardModifierState Gondwana.Blazor.Input.Keyboard.BlazorKeyboardAdapter.CurrentKeyboardModifiers
get

Gets the current state of modifier keys, such as Shift, Ctrl, and Alt. Must be safe to read from the Engine thread at high frequency.

Implements Gondwana.Input.Keyboard.IKeyboardAdapter.

Definition at line 36 of file BlazorKeyboardAdapter.cs.