Merge branch 'feature/mediabutton'

This commit is contained in:
Jonas Bark
2025-11-07 20:45:30 +01:00
9 changed files with 62 additions and 0 deletions

View File

@@ -6,6 +6,7 @@ import 'package:dartx/dartx.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:gamepads/gamepads.dart';
import 'package:media_key_detector/media_key_detector.dart';
import 'package:swift_control/bluetooth/devices/bluetooth_device.dart';
import 'package:swift_control/bluetooth/devices/gamepad/gamepad_device.dart';
import 'package:swift_control/bluetooth/devices/hid/hid_device.dart';
@@ -166,6 +167,9 @@ class Connection {
if (settings.getMyWhooshLinkEnabled() && settings.getTrainerApp() is MyWhoosh && !whooshLink.isStarted.value) {
startMyWhooshServer();
}
mediaKeyDetector.addListener((mediaKey) {
print('Media key pressed: $mediaKey');
});
}
Future<void> startMyWhooshServer() {

View File

@@ -9,6 +9,7 @@
#include <bluetooth_low_energy_linux/bluetooth_low_energy_linux_plugin.h>
#include <file_selector_linux/file_selector_plugin.h>
#include <gamepads_linux/gamepads_linux_plugin.h>
#include <media_key_detector_linux/media_key_detector_plugin.h>
#include <screen_retriever_linux/screen_retriever_linux_plugin.h>
#include <url_launcher_linux/url_launcher_plugin.h>
#include <window_manager/window_manager_plugin.h>
@@ -23,6 +24,9 @@ void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) gamepads_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "GamepadsLinuxPlugin");
gamepads_linux_plugin_register_with_registrar(gamepads_linux_registrar);
g_autoptr(FlPluginRegistrar) media_key_detector_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "MediaKeyDetectorPlugin");
media_key_detector_plugin_register_with_registrar(media_key_detector_linux_registrar);
g_autoptr(FlPluginRegistrar) screen_retriever_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "ScreenRetrieverLinuxPlugin");
screen_retriever_linux_plugin_register_with_registrar(screen_retriever_linux_registrar);

View File

@@ -6,6 +6,7 @@ list(APPEND FLUTTER_PLUGIN_LIST
bluetooth_low_energy_linux
file_selector_linux
gamepads_linux
media_key_detector_linux
screen_retriever_linux
url_launcher_linux
window_manager

View File

@@ -11,6 +11,7 @@ import file_selector_macos
import flutter_local_notifications
import gamepads_darwin
import keypress_simulator_macos
import media_key_detector_macos
import package_info_plus
import path_provider_foundation
import screen_retriever_macos
@@ -27,6 +28,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
FlutterLocalNotificationsPlugin.register(with: registry.registrar(forPlugin: "FlutterLocalNotificationsPlugin"))
GamepadsDarwinPlugin.register(with: registry.registrar(forPlugin: "GamepadsDarwinPlugin"))
KeypressSimulatorMacosPlugin.register(with: registry.registrar(forPlugin: "KeypressSimulatorMacosPlugin"))
MediaKeyDetectorPlugin.register(with: registry.registrar(forPlugin: "MediaKeyDetectorPlugin"))
FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
ScreenRetrieverMacosPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverMacosPlugin"))

View File

@@ -13,6 +13,8 @@ PODS:
- FlutterMacOS
- keypress_simulator_macos (0.0.1):
- FlutterMacOS
- media_key_detector_macos (0.0.1):
- FlutterMacOS
- package_info_plus (0.0.1):
- FlutterMacOS
- path_provider_foundation (0.0.1):
@@ -41,6 +43,7 @@ DEPENDENCIES:
- FlutterMacOS (from `Flutter/ephemeral`)
- gamepads_darwin (from `Flutter/ephemeral/.symlinks/plugins/gamepads_darwin/macos`)
- keypress_simulator_macos (from `Flutter/ephemeral/.symlinks/plugins/keypress_simulator_macos/macos`)
- media_key_detector_macos (from `Flutter/ephemeral/.symlinks/plugins/media_key_detector_macos/macos`)
- package_info_plus (from `Flutter/ephemeral/.symlinks/plugins/package_info_plus/macos`)
- path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin`)
- screen_retriever_macos (from `Flutter/ephemeral/.symlinks/plugins/screen_retriever_macos/macos`)
@@ -65,6 +68,8 @@ EXTERNAL SOURCES:
:path: Flutter/ephemeral/.symlinks/plugins/gamepads_darwin/macos
keypress_simulator_macos:
:path: Flutter/ephemeral/.symlinks/plugins/keypress_simulator_macos/macos
media_key_detector_macos:
:path: Flutter/ephemeral/.symlinks/plugins/media_key_detector_macos/macos
package_info_plus:
:path: Flutter/ephemeral/.symlinks/plugins/package_info_plus/macos
path_provider_foundation:
@@ -90,6 +95,7 @@ SPEC CHECKSUMS:
FlutterMacOS: d0db08ddef1a9af05a5ec4b724367152bb0500b1
gamepads_darwin: 07af6c60c282902b66574c800e20b2b26e68fda8
keypress_simulator_macos: f8556f9101f9f2f175652e0bceddf0fe82a4c6b2
media_key_detector_macos: a93757a483b4b47283ade432b1af9e427c47329f
package_info_plus: 12f1c5c2cfe8727ca46cbd0b26677728972d9a5b
path_provider_foundation: 0b743cbb62d8e47eab856f09262bb8c1ddcfe6ba
screen_retriever_macos: 776e0fa5d42c6163d2bf772d22478df4b302b161

View File

@@ -620,6 +620,46 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.11.1"
media_key_detector:
dependency: "direct main"
description:
name: media_key_detector
sha256: "397150df1e60e2a813370248bb6f55405794960e6078ddac8bd96f8a763a16d1"
url: "https://pub.dev"
source: hosted
version: "0.0.1"
media_key_detector_linux:
dependency: transitive
description:
name: media_key_detector_linux
sha256: de4a0e898a0d045bc82902880487d05bd59783b0acd6996463fe57c90ecd0374
url: "https://pub.dev"
source: hosted
version: "0.0.1"
media_key_detector_macos:
dependency: transitive
description:
name: media_key_detector_macos
sha256: c2513c9c4cc97c8d2ce8378918c7daf3937f90976352452a640c2cdb1df4636e
url: "https://pub.dev"
source: hosted
version: "0.0.1"
media_key_detector_platform_interface:
dependency: transitive
description:
name: media_key_detector_platform_interface
sha256: "081b36b74d47f21e5e03435b038434cc3b58c501e47daf7885aa4615bcaf8836"
url: "https://pub.dev"
source: hosted
version: "0.0.1"
media_key_detector_windows:
dependency: transitive
description:
name: media_key_detector_windows
sha256: "3bfa26a8b24947805aa3f19ca621ce8c57d3cf2f22de2630d8fa01f064d62c8a"
url: "https://pub.dev"
source: hosted
version: "0.0.1"
meta:
dependency: transitive
description:

View File

@@ -35,6 +35,7 @@ dependencies:
path: keypress_simulator/packages/keypress_simulator
shared_preferences: ^2.5.3
flex_color_scheme: ^8.3.0
media_key_detector: ^0.0.1
accessibility:
path: accessibility

View File

@@ -10,6 +10,7 @@
#include <file_selector_windows/file_selector_windows.h>
#include <gamepads_windows/gamepads_windows_plugin_c_api.h>
#include <keypress_simulator_windows/keypress_simulator_windows_plugin_c_api.h>
#include <media_key_detector_windows/media_key_detector_windows.h>
#include <permission_handler_windows/permission_handler_windows_plugin.h>
#include <screen_retriever_windows/screen_retriever_windows_plugin_c_api.h>
#include <universal_ble/universal_ble_plugin_c_api.h>
@@ -25,6 +26,8 @@ void RegisterPlugins(flutter::PluginRegistry* registry) {
registry->GetRegistrarForPlugin("GamepadsWindowsPluginCApi"));
KeypressSimulatorWindowsPluginCApiRegisterWithRegistrar(
registry->GetRegistrarForPlugin("KeypressSimulatorWindowsPluginCApi"));
MediaKeyDetectorWindowsRegisterWithRegistrar(
registry->GetRegistrarForPlugin("MediaKeyDetectorWindows"));
PermissionHandlerWindowsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin"));
ScreenRetrieverWindowsPluginCApiRegisterWithRegistrar(

View File

@@ -7,6 +7,7 @@ list(APPEND FLUTTER_PLUGIN_LIST
file_selector_windows
gamepads_windows
keypress_simulator_windows
media_key_detector_windows
permission_handler_windows
screen_retriever_windows
universal_ble