From 964b89aa67311d289a69180c986c0646bb5fbaee Mon Sep 17 00:00:00 2001 From: edde746 <86283021+edde746@users.noreply.github.com> Date: Mon, 23 Feb 2026 08:05:55 +0100 Subject: [PATCH] fix(windows): release gamepad handles on window blur --- lib/services/gamepad_service.dart | 8 +++++++- pubspec.lock | 4 ++-- pubspec.yaml | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/services/gamepad_service.dart b/lib/services/gamepad_service.dart index e7eacc3e..237be9e1 100644 --- a/lib/services/gamepad_service.dart +++ b/lib/services/gamepad_service.dart @@ -101,7 +101,10 @@ class GamepadService with WindowListener { } @override - void onWindowFocus() => _windowFocused = true; + void onWindowFocus() { + _windowFocused = true; + Gamepad.instance.resume(); + } @override void onWindowBlur() { @@ -123,6 +126,9 @@ class GamepadService with WindowListener { _leftStickDown = false; _leftStickLeft = false; _leftStickRight = false; + + // Release native device handles so other apps can use the gamepad. + Gamepad.instance.pause(); } void _handleGamepadEvent(GamepadEvent event) { diff --git a/pubspec.lock b/pubspec.lock index 1dc9759c..acb9df56 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1263,10 +1263,10 @@ packages: dependency: "direct main" description: name: universal_gamepad - sha256: afd3106195aa2052ec23fe61069cad8d0caed255c7e2e6ed33a403e0a94f365e + sha256: b638bd9d2bf25c15cf815c7f1a66629d56e8d5229178d7347ffc68efd7c646dd url: "https://pub.dev" source: hosted - version: "1.4.4" + version: "1.5.0" url_launcher: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 79d9ce43..bf1c46b5 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -38,7 +38,7 @@ dependencies: path: wakelock_plus path_provider: ^2.1.0 path: ^1.9.0 - universal_gamepad: ^1.4.4 + universal_gamepad: ^1.5.0 drift: ^2.28.2 sqlite3_flutter_libs: ^0.5.41 workmanager: ^0.9.0+3