feat: Implement host shortcut system for desktop window management and input suppression

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
2026-03-20 11:35:22 +01:00
parent c81eb6750d
commit 862191d245
3 changed files with 143 additions and 20 deletions

View File

@@ -95,6 +95,9 @@ class Wolf3dFlutterInput extends Wolf3dInput {
double _mouseDeltaY = 0.0;
bool _previousMouseRightDown = false;
bool _queuedBack = false;
// One-frame suppression lets host shortcuts (for example Alt+Enter) consume
// overlapping gameplay keys before the engine reads keyboard state.
final Set<WolfInputAction> _suppressedActionsOnce = <WolfInputAction>{};
// Mouse-look is optional so touch or keyboard-only hosts can keep the same
@@ -155,6 +158,9 @@ class Wolf3dFlutterInput extends Wolf3dInput {
}
/// Suppresses [action] for the next [update] tick only.
///
/// This is primarily used by host-level shortcuts that share physical keys
/// with gameplay/menu actions.
void suppressActionOnce(WolfInputAction action) {
_suppressedActionsOnce.add(action);
}
@@ -166,6 +172,7 @@ class Wolf3dFlutterInput extends Wolf3dInput {
/// Returns whether any bound key for [action] is currently pressed.
bool _isActive(WolfInputAction action, Set<LogicalKeyboardKey> pressedKeys) {
// Host-consumed actions should appear inactive for exactly one update.
if (_suppressedActionsOnce.contains(action)) {
return false;
}
@@ -177,6 +184,7 @@ class Wolf3dFlutterInput extends Wolf3dInput {
WolfInputAction action,
Set<LogicalKeyboardKey> newlyPressed,
) {
// Suppressed actions also block edge-triggered press detection.
if (_suppressedActionsOnce.contains(action)) {
return false;
}
@@ -240,6 +248,8 @@ class Wolf3dFlutterInput extends Wolf3dInput {
_previousKeys = Set.from(pressedKeys);
_previousMouseRightDown = isMouseRightDown;
_queuedBack = false;
// Clear one-shot suppression so the action behaves normally next frame.
_suppressedActionsOnce.clear();
}
}