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
EngineInputSystems.cs
7
8namespace Gondwana;
9
13public sealed class EngineInputSystems
14{
15 internal EngineInputSystems() { }
16
17 private IGamepadManager<IGamepadAdapter>? _gamepadManager = null;
18 private long _lastGamepadConnectionUpdateTick;
19 private long _lastGamepadPollTick;
20
30 public IGamepadManager<IGamepadAdapter>? GamepadManager
31 {
32 get => _gamepadManager;
33 set
34 {
35 _gamepadManager = value;
36
37 if (value is null)
38 {
39 _lastGamepadConnectionUpdateTick = 0;
40 _lastGamepadPollTick = 0;
41 GamepadEventPoller.Initialize(null);
42 return;
43 }
44
45 // Prime discovery and state once so platform host initialization hooks can immediately
46 // observe controllers that were already connected when the manager was installed.
47 value.UpdateConnections();
48 value.Poll();
49
50 long tick = HighResTimer.GetCurrentTick();
51 _lastGamepadConnectionUpdateTick = tick;
52 _lastGamepadPollTick = tick;
53
54 GamepadEventPoller.Initialize(value.ConnectedAdapters);
55 }
56 }
57
63 internal void RefreshGamepads(long tick, EngineConfiguration configuration)
64 {
65 ArgumentNullException.ThrowIfNull(configuration);
66
67 var manager = _gamepadManager;
68 if (manager is null)
69 return;
70
71 if (IsGamepadRefreshDue(
72 tick,
73 _lastGamepadConnectionUpdateTick,
75 {
76 manager.UpdateConnections();
77 GamepadEventPoller.Instance?.RefreshAdapters(manager.ConnectedAdapters);
78 _lastGamepadConnectionUpdateTick = tick;
79 }
80
81 if (IsGamepadRefreshDue(
82 tick,
83 _lastGamepadPollTick,
84 configuration.GamepadPollFrequencyHz))
85 {
86 manager.Poll();
87 _lastGamepadPollTick = tick;
88 }
89 }
90
91 private static bool IsGamepadRefreshDue(long tick, long lastTick, double frequencyHz)
92 {
93 if (frequencyHz <= 0d)
94 return false;
95
96 long intervalTicks = Math.Max(
97 1,
98 (long)(HighResTimer.TicksPerSecond / frequencyHz));
99
100 return tick - lastTick >= intervalTicks;
101 }
102
115
129
143
154 {
155 get => TouchEventPoller.Instance?.Adapter;
156 set
157 {
158 if (value is null)
159 TouchEventPoller.Reset();
160 else
161 TouchEventPoller.Initialize(value);
162 }
163 }
164
180}
Settings used by the engine when cycling.
double GamepadPollFrequencyHz
Gets or sets how often the engine refreshes the state of already-connected gamepads.
double GamepadConnectionUpdateFrequencyHz
Gets or sets how often the engine checks for gamepad connection and disconnection changes.
MouseEventPoller? MouseEventPoller
Gets the mouse event polling subsystem, if initialized.
KeyboardEventPoller? KeyboardEventPoller
Gets the keyboard event polling subsystem, if initialized.
TouchEventPoller? TouchEventPoller
Gets the touch event polling subsystem, if initialized.
GamepadEventPoller? GamepadEventPoller
Gets the gamepad event polling subsystem, if initialized.
ITouchAdapter? TouchAdapter
Gets or sets the touch adapter responsible for providing raw touch state to the engine.
IGamepadManager< IGamepadAdapter >? GamepadManager
Gets or sets the gamepad manager responsible for handling gamepad input.
Provides centralized polling and event management for gamepad button inputs across multiple gamepad d...
static ? GamepadEventPoller Instance
Gets the singleton instance of the GamepadEventPoller class. This instance is created automatically o...
static ? KeyboardEventPoller Instance
Singleton instance of the KeyboardEventPoller class.
static ? MouseEventPoller Instance
Gets the singleton instance of the MouseEventPoller class. This instance is created through the Initi...
Defines a passive adapter interface for accessing touch device state. Implementations update their in...