diff --git a/CHANGELOG.md b/CHANGELOG.md index 37d7692f..262931a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -#### 1.2.0 (2025-04-06) +#### 2.0.0 (2025-04-06) - You can now customize the actions (touches or keyboard keys) for all buttons on all supported Zwift devices - now shows the battery level of the connected devices - add more troubleshooting information diff --git a/keypress_simulator/packages/keypress_simulator/.gitignore b/keypress_simulator/packages/keypress_simulator/.gitignore new file mode 100644 index 00000000..01c49d55 --- /dev/null +++ b/keypress_simulator/packages/keypress_simulator/.gitignore @@ -0,0 +1,29 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +.vscode/ + +# Flutter/Dart/Pub related +# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. +/pubspec.lock +**/doc/api/ +.dart_tool/ +.packages +build/ diff --git a/keypress_simulator/packages/keypress_simulator/.metadata b/keypress_simulator/packages/keypress_simulator/.metadata new file mode 100644 index 00000000..0b5ddf05 --- /dev/null +++ b/keypress_simulator/packages/keypress_simulator/.metadata @@ -0,0 +1,10 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: db747aa1331bd95bc9b3874c842261ca2d302cd5 + channel: stable + +project_type: plugin diff --git a/keypress_simulator/packages/keypress_simulator/CHANGELOG.md b/keypress_simulator/packages/keypress_simulator/CHANGELOG.md new file mode 100644 index 00000000..a2579009 --- /dev/null +++ b/keypress_simulator/packages/keypress_simulator/CHANGELOG.md @@ -0,0 +1,7 @@ +## 0.2.0 + +* feat: Convert to federated plugin + +## 0.1.0 + +* First release. diff --git a/keypress_simulator/packages/keypress_simulator/LICENSE b/keypress_simulator/packages/keypress_simulator/LICENSE new file mode 100644 index 00000000..eea05ab7 --- /dev/null +++ b/keypress_simulator/packages/keypress_simulator/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022-2024 LiJianying + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/keypress_simulator/packages/keypress_simulator/README-ZH.md b/keypress_simulator/packages/keypress_simulator/README-ZH.md new file mode 120000 index 00000000..7da944f1 --- /dev/null +++ b/keypress_simulator/packages/keypress_simulator/README-ZH.md @@ -0,0 +1 @@ +../../README-ZH.md \ No newline at end of file diff --git a/keypress_simulator/packages/keypress_simulator/README.md b/keypress_simulator/packages/keypress_simulator/README.md new file mode 120000 index 00000000..fe840054 --- /dev/null +++ b/keypress_simulator/packages/keypress_simulator/README.md @@ -0,0 +1 @@ +../../README.md \ No newline at end of file diff --git a/keypress_simulator/packages/keypress_simulator/analysis_options.yaml b/keypress_simulator/packages/keypress_simulator/analysis_options.yaml new file mode 100644 index 00000000..095b1d67 --- /dev/null +++ b/keypress_simulator/packages/keypress_simulator/analysis_options.yaml @@ -0,0 +1 @@ +include: package:mostly_reasonable_lints/flutter.yaml diff --git a/keypress_simulator/packages/keypress_simulator/lib/keypress_simulator.dart b/keypress_simulator/packages/keypress_simulator/lib/keypress_simulator.dart new file mode 100644 index 00000000..4c8a7e89 --- /dev/null +++ b/keypress_simulator/packages/keypress_simulator/lib/keypress_simulator.dart @@ -0,0 +1 @@ +export 'src/keypress_simulator.dart'; diff --git a/keypress_simulator/packages/keypress_simulator/lib/src/keypress_simulator.dart b/keypress_simulator/packages/keypress_simulator/lib/src/keypress_simulator.dart new file mode 100644 index 00000000..40a06279 --- /dev/null +++ b/keypress_simulator/packages/keypress_simulator/lib/src/keypress_simulator.dart @@ -0,0 +1,54 @@ +import 'dart:async'; +import 'dart:io'; + +import 'package:flutter/services.dart'; +import 'package:keypress_simulator_platform_interface/keypress_simulator_platform_interface.dart'; + +class KeyPressSimulator { + KeyPressSimulator._(); + + /// The shared instance of [KeyPressSimulator]. + static final KeyPressSimulator instance = KeyPressSimulator._(); + + KeyPressSimulatorPlatform get _platform => KeyPressSimulatorPlatform.instance; + + Future isAccessAllowed() { + return _platform.isAccessAllowed(); + } + + Future requestAccess({bool onlyOpenPrefPane = false}) { + return _platform.requestAccess(onlyOpenPrefPane: onlyOpenPrefPane); + } + + Future simulateMouseClick(Offset position) { + return _platform.simulateMouseClick(position); + } + + /// Simulate key down. + Future simulateKeyDown(PhysicalKeyboardKey? key, [List modifiers = const []]) { + return _platform.simulateKeyPress(key: key, modifiers: modifiers, keyDown: true); + } + + /// Simulate key up. + Future simulateKeyUp(PhysicalKeyboardKey? key, [List modifiers = const []]) { + return _platform.simulateKeyPress(key: key, modifiers: modifiers, keyDown: false); + } + + @Deprecated('Please use simulateKeyDown & simulateKeyUp methods.') + Future simulateCtrlCKeyPress() async { + const key = PhysicalKeyboardKey.keyC; + final modifiers = Platform.isMacOS ? [ModifierKey.metaModifier] : [ModifierKey.controlModifier]; + await simulateKeyDown(key, modifiers); + await simulateKeyUp(key, modifiers); + } + + @Deprecated('Please use simulateKeyDown & simulateKeyUp methods.') + Future simulateCtrlVKeyPress() async { + const key = PhysicalKeyboardKey.keyV; + final modifiers = Platform.isMacOS ? [ModifierKey.metaModifier] : [ModifierKey.controlModifier]; + await simulateKeyDown(key, modifiers); + await simulateKeyUp(key, modifiers); + } +} + +final keyPressSimulator = KeyPressSimulator.instance; diff --git a/keypress_simulator/packages/keypress_simulator/pubspec.yaml b/keypress_simulator/packages/keypress_simulator/pubspec.yaml new file mode 100644 index 00000000..8cd7cccd --- /dev/null +++ b/keypress_simulator/packages/keypress_simulator/pubspec.yaml @@ -0,0 +1,36 @@ +name: keypress_simulator +description: This plugin allows Flutter desktop apps to simulate key presses. +version: 0.2.0 +homepage: https://github.com/leanflutter/keypress_simulator + +platforms: + macos: + windows: + +environment: + sdk: ">=3.0.0 <4.0.0" + flutter: ">=3.3.0" + +dependencies: + flutter: + sdk: flutter + keypress_simulator_macos: + path: ../keypress_simulator_macos + keypress_simulator_platform_interface: + path: ../keypress_simulator_platform_interface + keypress_simulator_windows: + path: ../keypress_simulator_windows + +dev_dependencies: + flutter_test: + sdk: flutter + mostly_reasonable_lints: ^0.1.1 + +flutter: + plugin: + platforms: + macos: + default_package: keypress_simulator_macos + windows: + default_package: keypress_simulator_windows + diff --git a/keypress_simulator/packages/keypress_simulator_macos/.gitignore b/keypress_simulator/packages/keypress_simulator_macos/.gitignore new file mode 100644 index 00000000..ac5aa989 --- /dev/null +++ b/keypress_simulator/packages/keypress_simulator_macos/.gitignore @@ -0,0 +1,29 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. +/pubspec.lock +**/doc/api/ +.dart_tool/ +build/ diff --git a/keypress_simulator/packages/keypress_simulator_macos/.metadata b/keypress_simulator/packages/keypress_simulator_macos/.metadata new file mode 100644 index 00000000..6422a999 --- /dev/null +++ b/keypress_simulator/packages/keypress_simulator_macos/.metadata @@ -0,0 +1,30 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: "67457e669f79e9f8d13d7a68fe09775fefbb79f4" + channel: "stable" + +project_type: plugin + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: 67457e669f79e9f8d13d7a68fe09775fefbb79f4 + base_revision: 67457e669f79e9f8d13d7a68fe09775fefbb79f4 + - platform: macos + create_revision: 67457e669f79e9f8d13d7a68fe09775fefbb79f4 + base_revision: 67457e669f79e9f8d13d7a68fe09775fefbb79f4 + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/keypress_simulator/packages/keypress_simulator_macos/CHANGELOG.md b/keypress_simulator/packages/keypress_simulator_macos/CHANGELOG.md new file mode 100644 index 00000000..2f145cea --- /dev/null +++ b/keypress_simulator/packages/keypress_simulator_macos/CHANGELOG.md @@ -0,0 +1,3 @@ +## 0.2.0 + +* First release. diff --git a/keypress_simulator/packages/keypress_simulator_macos/LICENSE b/keypress_simulator/packages/keypress_simulator_macos/LICENSE new file mode 100644 index 00000000..eea05ab7 --- /dev/null +++ b/keypress_simulator/packages/keypress_simulator_macos/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022-2024 LiJianying + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/keypress_simulator/packages/keypress_simulator_macos/README.md b/keypress_simulator/packages/keypress_simulator_macos/README.md new file mode 100644 index 00000000..87a076f0 --- /dev/null +++ b/keypress_simulator/packages/keypress_simulator_macos/README.md @@ -0,0 +1,12 @@ +# keypress_simulator_macos + +[![pub version][pub-image]][pub-url] + +[pub-image]: https://img.shields.io/pub/v/keypress_simulator_macos.svg +[pub-url]: https://pub.dev/packages/keypress_simulator_macos + +The macOS implementation of [keypress_simulator](https://pub.dev/packages/keypress_simulator). + +## License + +[MIT](./LICENSE) diff --git a/keypress_simulator/packages/keypress_simulator_macos/analysis_options.yaml b/keypress_simulator/packages/keypress_simulator_macos/analysis_options.yaml new file mode 100644 index 00000000..095b1d67 --- /dev/null +++ b/keypress_simulator/packages/keypress_simulator_macos/analysis_options.yaml @@ -0,0 +1 @@ +include: package:mostly_reasonable_lints/flutter.yaml diff --git a/keypress_simulator/packages/keypress_simulator_macos/macos/Classes/KeypressSimulatorMacosPlugin.swift b/keypress_simulator/packages/keypress_simulator_macos/macos/Classes/KeypressSimulatorMacosPlugin.swift new file mode 100644 index 00000000..c73577ec --- /dev/null +++ b/keypress_simulator/packages/keypress_simulator_macos/macos/Classes/KeypressSimulatorMacosPlugin.swift @@ -0,0 +1,114 @@ +import Cocoa +import FlutterMacOS + +public class KeypressSimulatorMacosPlugin: NSObject, FlutterPlugin { + public static func register(with registrar: FlutterPluginRegistrar) { + let channel = FlutterMethodChannel(name: "dev.leanflutter.plugins/keypress_simulator", binaryMessenger: registrar.messenger) + let instance = KeypressSimulatorMacosPlugin() + registrar.addMethodCallDelegate(instance, channel: channel) + } + + public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { + switch call.method { + case "isAccessAllowed": + isAccessAllowed(call, result: result) + break + case "requestAccess": + requestAccess(call, result: result) + break + case "simulateKeyPress": + simulateKeyPress(call, result: result) + break + case "simulateMouseClick": + simulateMouseClick(call, result: result) + break + default: + result(FlutterMethodNotImplemented) + } + } + public func isAccessAllowed(_ call: FlutterMethodCall, result: @escaping FlutterResult) { + result(AXIsProcessTrusted()) + } + + public func requestAccess(_ call: FlutterMethodCall, result: @escaping FlutterResult) { + let args:[String: Any] = call.arguments as! [String: Any] + let onlyOpenPrefPane: Bool = args["onlyOpenPrefPane"] as! Bool + + if (!onlyOpenPrefPane) { + let options = [kAXTrustedCheckOptionPrompt.takeRetainedValue(): true] as CFDictionary + AXIsProcessTrustedWithOptions(options) + } else { + let prefpaneUrl = URL(string: "x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility")! + NSWorkspace.shared.open(prefpaneUrl) + } + result(true) + } + + public func simulateKeyPress(_ call: FlutterMethodCall, result: @escaping FlutterResult) { + let args:[String: Any] = call.arguments as! [String: Any] + + let keyCode: Int? = args["keyCode"] as? Int + let modifiers: Array = args["modifiers"] as! Array + let keyDown: Bool = args["keyDown"] as! Bool + + let event = _createKeyPressEvent(keyCode, modifiers, keyDown); + event.post(tap: .cghidEventTap); + result(true) + } + + + public func simulateMouseClick(_ call: FlutterMethodCall, result: @escaping FlutterResult) { + let args:[String: Any] = call.arguments as! [String: Any] + + let x: Double = args["x"] as! Double + let y: Double = args["y"] as! Double + + let point = CGPoint(x: x, y: y) + + // Move mouse to the point + /*let move = CGEvent(mouseEventSource: nil, + mouseType: .mouseMoved, + mouseCursorPosition: point, + mouseButton: .left) + move?.post(tap: .cghidEventTap)*/ + + // Mouse down + let mouseDown = CGEvent(mouseEventSource: nil, + mouseType: .leftMouseDown, + mouseCursorPosition: point, + mouseButton: .left) + mouseDown?.post(tap: .cghidEventTap) + + // Mouse up + let mouseUp = CGEvent(mouseEventSource: nil, + mouseType: .leftMouseUp, + mouseCursorPosition: point, + mouseButton: .left) + mouseUp?.post(tap: .cghidEventTap) + result(true) + } + + public func _createKeyPressEvent(_ keyCode: Int?, _ modifiers: Array, _ keyDown: Bool) -> CGEvent { + let virtualKey: CGKeyCode = CGKeyCode(UInt32(keyCode ?? 0)) + var flags: CGEventFlags = CGEventFlags() + + if (modifiers.contains("shiftModifier")) { + flags.insert(CGEventFlags.maskShift) + } + if (modifiers.contains("controlModifier")) { + flags.insert(CGEventFlags.maskControl) + } + if (modifiers.contains("altModifier")) { + flags.insert(CGEventFlags.maskAlternate) + } + if (modifiers.contains("metaModifier")) { + flags.insert(CGEventFlags.maskCommand) + } + if (modifiers.contains("functionModifier")) { + flags.insert(CGEventFlags.maskSecondaryFn) + } + let eventKeyPress = CGEvent(keyboardEventSource: nil, virtualKey: virtualKey, keyDown: keyDown); + eventKeyPress!.flags = flags + return eventKeyPress! + } +} diff --git a/keypress_simulator/packages/keypress_simulator_macos/macos/keypress_simulator_macos.podspec b/keypress_simulator/packages/keypress_simulator_macos/macos/keypress_simulator_macos.podspec new file mode 100644 index 00000000..81ed8532 --- /dev/null +++ b/keypress_simulator/packages/keypress_simulator_macos/macos/keypress_simulator_macos.podspec @@ -0,0 +1,23 @@ +# +# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. +# Run `pod lib lint keypress_simulator_macos.podspec` to validate before publishing. +# +Pod::Spec.new do |s| + s.name = 'keypress_simulator_macos' + s.version = '0.0.1' + s.summary = 'A new Flutter plugin project.' + s.description = <<-DESC +A new Flutter plugin project. + DESC + s.homepage = 'http://example.com' + s.license = { :file => '../LICENSE' } + s.author = { 'Your Company' => 'email@example.com' } + + s.source = { :path => '.' } + s.source_files = 'Classes/**/*' + s.dependency 'FlutterMacOS' + + s.platform = :osx, '10.11' + s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' } + s.swift_version = '5.0' +end diff --git a/keypress_simulator/packages/keypress_simulator_macos/pubspec.yaml b/keypress_simulator/packages/keypress_simulator_macos/pubspec.yaml new file mode 100644 index 00000000..c414c0b1 --- /dev/null +++ b/keypress_simulator/packages/keypress_simulator_macos/pubspec.yaml @@ -0,0 +1,27 @@ +name: keypress_simulator_macos +description: macOS implementation of the keypress_simulator plugin. +version: 0.2.0 +repository: https://github.com/leanflutter/keypress_simulator/tree/main/packages/keypress_simulator_macos + +environment: + sdk: '>=3.0.0 <4.0.0' + flutter: '>=3.3.0' + +dependencies: + flutter: + sdk: flutter + keypress_simulator_platform_interface: + path: ../keypress_simulator_platform_interface + +dev_dependencies: + flutter_test: + sdk: flutter + mostly_reasonable_lints: ^0.1.1 + +flutter: + plugin: + implements: keypress_simulator + platforms: + macos: + pluginClass: KeypressSimulatorMacosPlugin + diff --git a/keypress_simulator/packages/keypress_simulator_platform_interface/.gitignore b/keypress_simulator/packages/keypress_simulator_platform_interface/.gitignore new file mode 100644 index 00000000..ac5aa989 --- /dev/null +++ b/keypress_simulator/packages/keypress_simulator_platform_interface/.gitignore @@ -0,0 +1,29 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. +/pubspec.lock +**/doc/api/ +.dart_tool/ +build/ diff --git a/keypress_simulator/packages/keypress_simulator_platform_interface/.metadata b/keypress_simulator/packages/keypress_simulator_platform_interface/.metadata new file mode 100644 index 00000000..9e91d2fd --- /dev/null +++ b/keypress_simulator/packages/keypress_simulator_platform_interface/.metadata @@ -0,0 +1,27 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: "67457e669f79e9f8d13d7a68fe09775fefbb79f4" + channel: "stable" + +project_type: plugin + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: 67457e669f79e9f8d13d7a68fe09775fefbb79f4 + base_revision: 67457e669f79e9f8d13d7a68fe09775fefbb79f4 + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/keypress_simulator/packages/keypress_simulator_platform_interface/CHANGELOG.md b/keypress_simulator/packages/keypress_simulator_platform_interface/CHANGELOG.md new file mode 100644 index 00000000..2f145cea --- /dev/null +++ b/keypress_simulator/packages/keypress_simulator_platform_interface/CHANGELOG.md @@ -0,0 +1,3 @@ +## 0.2.0 + +* First release. diff --git a/keypress_simulator/packages/keypress_simulator_platform_interface/LICENSE b/keypress_simulator/packages/keypress_simulator_platform_interface/LICENSE new file mode 100644 index 00000000..eea05ab7 --- /dev/null +++ b/keypress_simulator/packages/keypress_simulator_platform_interface/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022-2024 LiJianying + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/keypress_simulator/packages/keypress_simulator_platform_interface/README.md b/keypress_simulator/packages/keypress_simulator_platform_interface/README.md new file mode 100644 index 00000000..907200d1 --- /dev/null +++ b/keypress_simulator/packages/keypress_simulator_platform_interface/README.md @@ -0,0 +1,16 @@ +# keypress_simulator_platform_interface + +[![pub version][pub-image]][pub-url] + +[pub-image]: https://img.shields.io/pub/v/keypress_simulator_platform_interface.svg +[pub-url]: https://pub.dev/packages/keypress_simulator_platform_interface + +A common platform interface for the [keypress_simulator](https://pub.dev/packages/keypress_simulator) plugin. + +## Usage + +To implement a new platform-specific implementation of keypress_simulator, extend `KeyPressSimulatorPlatform` with an implementation that performs the platform-specific behavior, and when you register your plugin, set the default `KeyPressSimulatorPlatform` by calling `KeyPressSimulatorPlatform.instance = MyPlatformKeyPressSimulator()`. + +## License + +[MIT](./LICENSE) diff --git a/keypress_simulator/packages/keypress_simulator_platform_interface/analysis_options.yaml b/keypress_simulator/packages/keypress_simulator_platform_interface/analysis_options.yaml new file mode 100644 index 00000000..095b1d67 --- /dev/null +++ b/keypress_simulator/packages/keypress_simulator_platform_interface/analysis_options.yaml @@ -0,0 +1 @@ +include: package:mostly_reasonable_lints/flutter.yaml diff --git a/keypress_simulator/packages/keypress_simulator_platform_interface/lib/keypress_simulator_platform_interface.dart b/keypress_simulator/packages/keypress_simulator_platform_interface/lib/keypress_simulator_platform_interface.dart new file mode 100644 index 00000000..fdd2ecad --- /dev/null +++ b/keypress_simulator/packages/keypress_simulator_platform_interface/lib/keypress_simulator_platform_interface.dart @@ -0,0 +1,4 @@ +library keypress_simulator_platform_interface; + +export 'src/keypress_simulator_method_channel.dart'; +export 'src/keypress_simulator_platform_interface.dart'; diff --git a/keypress_simulator/packages/keypress_simulator_platform_interface/lib/src/keypress_simulator_method_channel.dart b/keypress_simulator/packages/keypress_simulator_platform_interface/lib/src/keypress_simulator_method_channel.dart new file mode 100644 index 00000000..19775b2e --- /dev/null +++ b/keypress_simulator/packages/keypress_simulator_platform_interface/lib/src/keypress_simulator_method_channel.dart @@ -0,0 +1,63 @@ +import 'package:flutter/services.dart'; +import 'package:flutter/widgets.dart'; +import 'package:keypress_simulator_platform_interface/src/keypress_simulator_platform_interface.dart'; +import 'package:uni_platform/uni_platform.dart'; + +/// An implementation of [KeyPressSimulatorPlatform] that uses method channels. +class MethodChannelKeyPressSimulator extends KeyPressSimulatorPlatform { + /// The method channel used to interact with the native platform. + @visibleForTesting + final methodChannel = const MethodChannel( + 'dev.leanflutter.plugins/keypress_simulator', + ); + + @override + Future isAccessAllowed() async { + if (UniPlatform.isMacOS) { + return await methodChannel.invokeMethod('isAccessAllowed'); + } + return true; + } + + @override + Future requestAccess({ + bool onlyOpenPrefPane = false, + }) async { + if (UniPlatform.isMacOS) { + final Map arguments = { + 'onlyOpenPrefPane': onlyOpenPrefPane, + }; + await methodChannel.invokeMethod('requestAccess', arguments); + } + } + + @override + Future simulateKeyPress({ + KeyboardKey? key, + List modifiers = const [], + bool keyDown = true, + }) async { + PhysicalKeyboardKey? physicalKey = key is PhysicalKeyboardKey ? key : null; + if (key is LogicalKeyboardKey) { + physicalKey = key.physicalKey; + } + if (key != null && physicalKey == null) { + throw UnsupportedError('Unsupported key: $key.'); + } + final Map arguments = { + 'keyCode': physicalKey?.keyCode, + 'modifiers': modifiers.map((e) => e.name).toList(), + 'keyDown': keyDown, + }..removeWhere((key, value) => value == null); + await methodChannel.invokeMethod('simulateKeyPress', arguments); + } + + @override + Future simulateMouseClick(Offset position) async { + final Map arguments = { + 'x': position.dx, + 'y': position.dy, + }; + await methodChannel.invokeMethod('simulateMouseClick', arguments); + } +} diff --git a/keypress_simulator/packages/keypress_simulator_platform_interface/lib/src/keypress_simulator_platform_interface.dart b/keypress_simulator/packages/keypress_simulator_platform_interface/lib/src/keypress_simulator_platform_interface.dart new file mode 100644 index 00000000..78743c62 --- /dev/null +++ b/keypress_simulator/packages/keypress_simulator_platform_interface/lib/src/keypress_simulator_platform_interface.dart @@ -0,0 +1,47 @@ +import 'package:flutter/services.dart'; +import 'package:keypress_simulator_platform_interface/src/keypress_simulator_method_channel.dart'; +import 'package:plugin_platform_interface/plugin_platform_interface.dart'; + +abstract class KeyPressSimulatorPlatform extends PlatformInterface { + /// Constructs a KeyPressSimulatorPlatform. + KeyPressSimulatorPlatform() : super(token: _token); + + static final Object _token = Object(); + + static KeyPressSimulatorPlatform _instance = MethodChannelKeyPressSimulator(); + + /// The default instance of [KeyPressSimulatorPlatform] to use. + /// + /// Defaults to [MethodChannelKeyPressSimulator]. + static KeyPressSimulatorPlatform get instance => _instance; + + /// Platform-specific implementations should set this with their own + /// platform-specific class that extends [KeyPressSimulatorPlatform] when + /// they register themselves. + static set instance(KeyPressSimulatorPlatform instance) { + PlatformInterface.verifyToken(instance, _token); + _instance = instance; + } + + Future isAccessAllowed() { + throw UnimplementedError('isAccessAllowed() has not been implemented.'); + } + + Future requestAccess({ + bool onlyOpenPrefPane = false, + }) { + throw UnimplementedError('requestAccess() has not been implemented.'); + } + + Future simulateKeyPress({ + KeyboardKey? key, + List modifiers = const [], + bool keyDown = true, + }) { + throw UnimplementedError('simulateKeyPress() has not been implemented.'); + } + + Future simulateMouseClick(Offset position) { + throw UnimplementedError('simulateKeyPress() has not been implemented.'); + } +} diff --git a/keypress_simulator/packages/keypress_simulator_platform_interface/pubspec.yaml b/keypress_simulator/packages/keypress_simulator_platform_interface/pubspec.yaml new file mode 100644 index 00000000..4b85fcf1 --- /dev/null +++ b/keypress_simulator/packages/keypress_simulator_platform_interface/pubspec.yaml @@ -0,0 +1,20 @@ +name: keypress_simulator_platform_interface +description: A common platform interface for the keypress_simulator plugin. +version: 0.2.0 +homepage: https://github.com/leanflutter/keypress_simulator/blob/main/packages/keypress_simulator_platform_interface + +environment: + sdk: '>=3.0.0 <4.0.0' + flutter: '>=3.3.0' + +dependencies: + collection: ^1.18.0 + flutter: + sdk: flutter + plugin_platform_interface: ^2.1.8 + uni_platform: ^0.1.2 + +dev_dependencies: + flutter_test: + sdk: flutter + mostly_reasonable_lints: ^0.1.1 diff --git a/keypress_simulator/packages/keypress_simulator_platform_interface/test/src/keypress_simulator_method_channel_test.dart b/keypress_simulator/packages/keypress_simulator_platform_interface/test/src/keypress_simulator_method_channel_test.dart new file mode 100644 index 00000000..af2c3b90 --- /dev/null +++ b/keypress_simulator/packages/keypress_simulator_platform_interface/test/src/keypress_simulator_method_channel_test.dart @@ -0,0 +1,32 @@ +import 'package:flutter/services.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:keypress_simulator_platform_interface/src/keypress_simulator_method_channel.dart'; + +void main() { + TestWidgetsFlutterBinding.ensureInitialized(); + + MethodChannelKeyPressSimulator platform = MethodChannelKeyPressSimulator(); + const MethodChannel channel = MethodChannel( + 'dev.leanflutter.plugins/keypress_simulator', + ); + + setUp(() { + TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger + .setMockMethodCallHandler( + channel, + (MethodCall methodCall) async { + if (methodCall.method == 'isAccessAllowed') return true; + return '42'; + }, + ); + }); + + tearDown(() { + TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger + .setMockMethodCallHandler(channel, null); + }); + + test('isAccessAllowed', () async { + expect(await platform.isAccessAllowed(), true); + }); +} diff --git a/keypress_simulator/packages/keypress_simulator_windows/pubspec.yaml b/keypress_simulator/packages/keypress_simulator_windows/pubspec.yaml index 7be83923..1f94f85a 100644 --- a/keypress_simulator/packages/keypress_simulator_windows/pubspec.yaml +++ b/keypress_simulator/packages/keypress_simulator_windows/pubspec.yaml @@ -10,7 +10,8 @@ environment: dependencies: flutter: sdk: flutter - keypress_simulator_platform_interface: ^0.2.0 + keypress_simulator_platform_interface: + path: ../keypress_simulator_platform_interface dev_dependencies: flutter_test: diff --git a/keypress_simulator/packages/keypress_simulator_windows/windows/keypress_simulator_windows_plugin.cpp b/keypress_simulator/packages/keypress_simulator_windows/windows/keypress_simulator_windows_plugin.cpp index e63e92f8..6c40b0fe 100644 --- a/keypress_simulator/packages/keypress_simulator_windows/windows/keypress_simulator_windows_plugin.cpp +++ b/keypress_simulator/packages/keypress_simulator_windows/windows/keypress_simulator_windows_plugin.cpp @@ -85,11 +85,39 @@ void KeypressSimulatorWindowsPlugin::SimulateKeyPress( result->Success(flutter::EncodableValue(true)); } +void KeypressSimulatorWindowsPlugin::SimulateMouseClick( + const flutter::MethodCall& method_call, + std::unique_ptr> result) { + const EncodableMap& args = std::get(*method_call.arguments()); + + UINT x = std::get(args.at(EncodableValue("x"))); + UINT y = std::get(args.at(EncodableValue("y"))); + + // Move the mouse to the specified coordinates + SetCursorPos(x, y); + + // Prepare input for mouse down and up + INPUT input = {0}; + input.type = INPUT_MOUSE; + + // Mouse left button down + input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN; + SendInput(1, &input, sizeof(INPUT)); + + // Mouse left button up + input.mi.dwFlags = MOUSEEVENTF_LEFTUP; + SendInput(1, &input, sizeof(INPUT)); + + result->Success(flutter::EncodableValue(true)); +} + void KeypressSimulatorWindowsPlugin::HandleMethodCall( const flutter::MethodCall& method_call, std::unique_ptr> result) { if (method_call.method_name().compare("simulateKeyPress") == 0) { SimulateKeyPress(method_call, std::move(result)); + } else if (method_call.method_name().compare("simulateMouseClick") == 0) { + SimulateMouseClick(method_call, std::move(result)); } else { result->NotImplemented(); } diff --git a/lib/main.dart b/lib/main.dart index a7c9118c..e1a1da07 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -9,6 +9,7 @@ import 'package:swift_control/theme.dart'; import 'package:swift_control/utils/actions/android.dart'; import 'package:swift_control/utils/actions/desktop.dart'; import 'package:swift_control/utils/settings/settings.dart'; +import 'package:window_manager/window_manager.dart'; import 'bluetooth/connection.dart'; import 'utils/actions/base_actions.dart'; @@ -19,13 +20,16 @@ final accessibilityHandler = Accessibility(); final flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin(); final settings = Settings(); -void main() { +void main() async { + WidgetsFlutterBinding.ensureInitialized(); if (kIsWeb) { actionHandler = StubActions(); } else if (Platform.isAndroid) { actionHandler = AndroidActions(); } else { actionHandler = DesktopActions(); + // Must add this line. + await windowManager.ensureInitialized(); } runApp(const SwiftPlayApp()); diff --git a/lib/pages/device.dart b/lib/pages/device.dart index f004e7a0..8a988a40 100644 --- a/lib/pages/device.dart +++ b/lib/pages/device.dart @@ -6,7 +6,6 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:swift_control/main.dart'; import 'package:swift_control/pages/touch_area.dart'; -import 'package:swift_control/widgets/custom_keymap_selector.dart'; import 'package:swift_control/widgets/logviewer.dart'; import 'package:swift_control/widgets/title.dart'; @@ -128,22 +127,7 @@ class _DevicePageState extends State { hintText: 'Select your Keymap', ), - if ((Platform.isMacOS || Platform.isWindows || kDebugMode) && - actionHandler.supportedApp is CustomApp) - ElevatedButton( - onPressed: () async { - final app = await showCustomKeymapDialog( - context, - customApp: actionHandler.supportedApp as CustomApp, - ); - if (app != null) { - settings.setApp(app); - } - setState(() {}); - }, - child: Text('Customize key map'), - ), - if ((Platform.isAndroid || kDebugMode) && actionHandler.supportedApp is CustomApp) + if (actionHandler.supportedApp is CustomApp) ElevatedButton( onPressed: () async { final result = await Navigator.of( @@ -154,7 +138,7 @@ class _DevicePageState extends State { } setState(() {}); }, - child: Text('Customize touch areas'), + child: Text('Customize Keymap'), ), ], ), diff --git a/lib/pages/touch_area.dart b/lib/pages/touch_area.dart index 53158ead..afa819cf 100644 --- a/lib/pages/touch_area.dart +++ b/lib/pages/touch_area.dart @@ -7,13 +7,16 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:image_picker/image_picker.dart'; import 'package:swift_control/main.dart'; +import 'package:window_manager/window_manager.dart'; import '../bluetooth/messages/click_notification.dart'; import '../bluetooth/messages/notification.dart'; import '../bluetooth/messages/play_notification.dart'; import '../bluetooth/messages/ride_notification.dart'; +import '../utils/keymap/apps/custom_app.dart'; import '../utils/keymap/buttons.dart'; import '../utils/keymap/keymap.dart'; +import '../widgets/custom_keymap_selector.dart'; final touchAreaSize = 42.0; @@ -49,6 +52,9 @@ class _TouchAreaSetupPageState extends State { _actionSubscription.cancel(); // Exit full screen SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: SystemUiOverlay.values); + if (Platform.isWindows || Platform.isLinux || Platform.isMacOS) { + windowManager.setFullScreen(false); + } } @override @@ -56,6 +62,9 @@ class _TouchAreaSetupPageState extends State { super.initState(); SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky, overlays: []); + if (Platform.isWindows || Platform.isLinux || Platform.isMacOS) { + windowManager.setFullScreen(true); + } _actionSubscription = connection.actionStream.listen((data) { if (!mounted) { return; @@ -101,33 +110,22 @@ class _TouchAreaSetupPageState extends State { itemBuilder: (context) => [ PopupMenuItem( - value: PhysicalKeyboardKey.mediaPlayPause, - child: const Text('Media: Play/Pause'), - ), - PopupMenuItem( - value: PhysicalKeyboardKey.mediaStop, - child: const Text('Media: Stop'), - ), - PopupMenuItem( - value: PhysicalKeyboardKey.mediaTrackPrevious, - child: const Text('Media: Previous'), - ), - PopupMenuItem( - value: PhysicalKeyboardKey.mediaTrackNext, - child: const Text('Media: Next'), - ), - PopupMenuItem( - value: PhysicalKeyboardKey.audioVolumeUp, - child: const Text('Media: Volume Up'), - ), - PopupMenuItem( - value: PhysicalKeyboardKey.audioVolumeDown, - child: const Text('Media: Volume Down'), + value: null, + child: const Text('Set Keyboard shortcut'), + onTap: () async { + await showDialog( + context: context, + builder: + (c) => + HotKeyListenerDialog(customApp: actionHandler.supportedApp! as CustomApp, keyPair: keyPair), + ); + setState(() {}); + }, ), if (keyPair.physicalKey != null) PopupMenuItem( value: null, - child: const Text('Unset'), + child: const Text('Use as touch button'), onTap: () { keyPair.physicalKey = null; keyPair.logicalKey = null; @@ -148,23 +146,17 @@ class _TouchAreaSetupPageState extends State { Draggable( feedback: Material( color: Colors.transparent, - child: _TouchDot( - color: Colors.yellow, - icon: keyPair.physicalKey != null ? Icons.music_note_outlined : Icons.add, - label: label, - keyPair: keyPair, - ), + child: _TouchDot(color: Colors.yellow, label: label, keyPair: keyPair), ), + onDragUpdate: (details) { + print('Dragging: ${details.localPosition}'); + }, childWhenDragging: const SizedBox.shrink(), onDraggableCanceled: (_, offset) { + print('Drag canceled: ${offset}'); setState(() => onPositionChanged(offset)); }, - child: _TouchDot( - color: color, - icon: keyPair.physicalKey != null ? Icons.music_note_outlined : Icons.add, - label: label, - keyPair: keyPair, - ), + child: _TouchDot(color: color, label: label, keyPair: keyPair), ), ], ), @@ -175,7 +167,8 @@ class _TouchAreaSetupPageState extends State { @override Widget build(BuildContext context) { - final devicePixelRatio = MediaQuery.devicePixelRatioOf(context); + final isDesktop = Platform.isWindows || Platform.isLinux || Platform.isMacOS; + final devicePixelRatio = isDesktop ? 1.0 : MediaQuery.devicePixelRatioOf(context); return Scaffold( body: Stack( children: [ @@ -210,12 +203,13 @@ class _TouchAreaSetupPageState extends State { (keyPair) => _buildDraggableArea( position: Offset( keyPair.touchPosition.dx / devicePixelRatio - touchAreaSize / 2, - keyPair.touchPosition.dy / devicePixelRatio - touchAreaSize / 2, + keyPair.touchPosition.dy / devicePixelRatio - touchAreaSize / 2 - (isDesktop ? touchAreaSize * 1.5 : 0), ), keyPair: keyPair, onPositionChanged: (newPos) { - final devicePixelRatio = MediaQuery.devicePixelRatioOf(context); - final converted = newPos.translate(touchAreaSize / 2, touchAreaSize / 2) * devicePixelRatio; + final converted = + newPos.translate(touchAreaSize / 2, touchAreaSize / 2 + (isDesktop ? touchAreaSize * 1.5 : 0)) * + devicePixelRatio; keyPair.touchPosition = converted; setState(() {}); }, @@ -235,7 +229,8 @@ class _TouchAreaSetupPageState extends State { actionHandler.supportedApp?.keymap.reset(); setState(() {}); }, - label: const Icon(Icons.lock_reset), + icon: const Icon(Icons.lock_reset), + label: Text('Reset'), ), ElevatedButton.icon(onPressed: _saveAndClose, icon: const Icon(Icons.save), label: const Text("Save")), ], @@ -249,11 +244,10 @@ class _TouchAreaSetupPageState extends State { class _TouchDot extends StatelessWidget { final Color color; - final IconData icon; final String label; final KeyPair keyPair; - const _TouchDot({required this.color, required this.label, required this.keyPair, required this.icon}); + const _TouchDot({required this.color, required this.label, required this.keyPair}); @override Widget build(BuildContext context) { @@ -268,7 +262,13 @@ class _TouchDot extends StatelessWidget { shape: BoxShape.circle, border: Border.all(color: Colors.black, width: 2), ), - child: Icon(icon), + child: Icon( + keyPair.isSpecialKey + ? Icons.music_note_outlined + : keyPair.physicalKey != null + ? Icons.keyboard_alt_outlined + : Icons.add, + ), ), Text(label, style: TextStyle(color: Colors.black, fontSize: 12)), @@ -280,7 +280,7 @@ class _TouchDot extends StatelessWidget { PhysicalKeyboardKey.mediaTrackNext => 'Media: Next', PhysicalKeyboardKey.audioVolumeUp => 'Media: Volume Up', PhysicalKeyboardKey.audioVolumeDown => 'Media: Volume Down', - _ => '?', + _ => keyPair.logicalKey?.keyLabel ?? 'Unknown', }, style: TextStyle(color: Colors.grey, fontSize: 12)), ], ); diff --git a/lib/utils/actions/desktop.dart b/lib/utils/actions/desktop.dart index 5577cc74..de1c0947 100644 --- a/lib/utils/actions/desktop.dart +++ b/lib/utils/actions/desktop.dart @@ -14,8 +14,14 @@ class DesktopActions extends BaseActions { return ('Keymap entry not found for action: $action'); } - await keyPressSimulator.simulateKeyDown(keyPair.physicalKey); - await keyPressSimulator.simulateKeyUp(keyPair.physicalKey); - return 'Key pressed: ${keyPair.logicalKey?.keyLabel}'; + if (keyPair.physicalKey != null) { + await keyPressSimulator.simulateKeyDown(keyPair.physicalKey); + await keyPressSimulator.simulateKeyUp(keyPair.physicalKey); + return 'Key pressed: ${keyPair.logicalKey?.keyLabel}'; + } else { + final point = supportedApp!.resolveTouchPosition(action: action, windowInfo: null); + await keyPressSimulator.simulateMouseClick(point); + return 'Mouse clicked at: $point'; + } } } diff --git a/lib/widgets/custom_keymap_selector.dart b/lib/widgets/custom_keymap_selector.dart index 8eec119f..3d7ce10d 100644 --- a/lib/widgets/custom_keymap_selector.dart +++ b/lib/widgets/custom_keymap_selector.dart @@ -13,63 +13,6 @@ import 'package:swift_control/utils/keymap/keymap.dart'; import '../utils/keymap/apps/custom_app.dart'; -Future showCustomKeymapDialog(BuildContext context, {required CustomApp customApp}) { - return showDialog( - context: context, - builder: (context) { - return GearHotkeyDialog(customApp: customApp); - }, - ); -} - -class GearHotkeyDialog extends StatefulWidget { - final CustomApp customApp; - const GearHotkeyDialog({super.key, required this.customApp}); - - @override - State createState() => _GearHotkeyDialogState(); -} - -class _GearHotkeyDialogState extends State { - @override - Widget build(BuildContext context) { - return AlertDialog( - title: Text('Customize key map'), - content: Column( - mainAxisAlignment: MainAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - TextButton.icon( - icon: Icon(Icons.add), - onPressed: () async { - await showDialog( - context: context, - builder: (c) => HotKeyListenerDialog(customApp: widget.customApp, keyPair: null), - ); - setState(() {}); - }, - label: Text('Add Key'), - ), - ...widget.customApp.keymap.keyPairs.map( - (e) => ListTile( - title: Text(e.buttons.joinToString(transform: (e) => e.name)), - subtitle: Text('Currently: ${e.toString()}'), - onTap: () async { - await showDialog( - context: context, - builder: (c) => HotKeyListenerDialog(customApp: widget.customApp, keyPair: e), - ); - setState(() {}); - }, - ), - ), - ], - ), - actions: [TextButton(onPressed: () => Navigator.of(context).pop(widget.customApp), child: Text("OK"))], - ); - } -} - class HotKeyListenerDialog extends StatefulWidget { final CustomApp customApp; final KeyPair? keyPair; diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc index 7299b5cf..6cf6d508 100644 --- a/linux/flutter/generated_plugin_registrant.cc +++ b/linux/flutter/generated_plugin_registrant.cc @@ -7,13 +7,21 @@ #include "generated_plugin_registrant.h" #include +#include #include +#include void fl_register_plugins(FlPluginRegistry* registry) { g_autoptr(FlPluginRegistrar) file_selector_linux_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin"); file_selector_plugin_register_with_registrar(file_selector_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); g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin"); url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar); + g_autoptr(FlPluginRegistrar) window_manager_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "WindowManagerPlugin"); + window_manager_plugin_register_with_registrar(window_manager_registrar); } diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake index 786ff5c2..74bbc59d 100644 --- a/linux/flutter/generated_plugins.cmake +++ b/linux/flutter/generated_plugins.cmake @@ -4,7 +4,9 @@ list(APPEND FLUTTER_PLUGIN_LIST file_selector_linux + screen_retriever_linux url_launcher_linux + window_manager ) list(APPEND FLUTTER_FFI_PLUGIN_LIST diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index 48b7b782..cb222ffa 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -9,16 +9,20 @@ import file_selector_macos import flutter_local_notifications import keypress_simulator_macos import package_info_plus +import screen_retriever_macos import shared_preferences_foundation import universal_ble import url_launcher_macos +import window_manager func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin")) FlutterLocalNotificationsPlugin.register(with: registry.registrar(forPlugin: "FlutterLocalNotificationsPlugin")) KeypressSimulatorMacosPlugin.register(with: registry.registrar(forPlugin: "KeypressSimulatorMacosPlugin")) FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin")) + ScreenRetrieverMacosPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverMacosPlugin")) SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) UniversalBlePlugin.register(with: registry.registrar(forPlugin: "UniversalBlePlugin")) UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) + WindowManagerPlugin.register(with: registry.registrar(forPlugin: "WindowManagerPlugin")) } diff --git a/macos/Podfile.lock b/macos/Podfile.lock index 0aff5fb7..a51035a4 100644 --- a/macos/Podfile.lock +++ b/macos/Podfile.lock @@ -8,6 +8,8 @@ PODS: - FlutterMacOS - package_info_plus (0.0.1): - FlutterMacOS + - screen_retriever_macos (0.0.1): + - FlutterMacOS - shared_preferences_foundation (0.0.1): - Flutter - FlutterMacOS @@ -16,6 +18,8 @@ PODS: - FlutterMacOS - url_launcher_macos (0.0.1): - FlutterMacOS + - window_manager (0.2.0): + - FlutterMacOS DEPENDENCIES: - file_selector_macos (from `Flutter/ephemeral/.symlinks/plugins/file_selector_macos/macos`) @@ -23,9 +27,11 @@ DEPENDENCIES: - FlutterMacOS (from `Flutter/ephemeral`) - keypress_simulator_macos (from `Flutter/ephemeral/.symlinks/plugins/keypress_simulator_macos/macos`) - package_info_plus (from `Flutter/ephemeral/.symlinks/plugins/package_info_plus/macos`) + - screen_retriever_macos (from `Flutter/ephemeral/.symlinks/plugins/screen_retriever_macos/macos`) - shared_preferences_foundation (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin`) - universal_ble (from `Flutter/ephemeral/.symlinks/plugins/universal_ble/darwin`) - url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`) + - window_manager (from `Flutter/ephemeral/.symlinks/plugins/window_manager/macos`) EXTERNAL SOURCES: file_selector_macos: @@ -38,12 +44,16 @@ EXTERNAL SOURCES: :path: Flutter/ephemeral/.symlinks/plugins/keypress_simulator_macos/macos package_info_plus: :path: Flutter/ephemeral/.symlinks/plugins/package_info_plus/macos + screen_retriever_macos: + :path: Flutter/ephemeral/.symlinks/plugins/screen_retriever_macos/macos shared_preferences_foundation: :path: Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin universal_ble: :path: Flutter/ephemeral/.symlinks/plugins/universal_ble/darwin url_launcher_macos: :path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos + window_manager: + :path: Flutter/ephemeral/.symlinks/plugins/window_manager/macos SPEC CHECKSUMS: file_selector_macos: cc3858c981fe6889f364731200d6232dac1d812d @@ -51,9 +61,11 @@ SPEC CHECKSUMS: FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24 keypress_simulator_macos: f8556f9101f9f2f175652e0bceddf0fe82a4c6b2 package_info_plus: 12f1c5c2cfe8727ca46cbd0b26677728972d9a5b + screen_retriever_macos: 776e0fa5d42c6163d2bf772d22478df4b302b161 shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78 universal_ble: cf52a7b3fd2e7c14d6d7262e9fdadb72ab6b88a6 url_launcher_macos: c82c93949963e55b228a30115bd219499a6fe404 + window_manager: 3a1844359a6295ab1e47659b1a777e36773cd6e8 PODFILE CHECKSUM: 7eb978b976557c8c1cd717d8185ec483fd090a82 diff --git a/pubspec.lock b/pubspec.lock index a8361e58..e1d910df 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -386,29 +386,26 @@ packages: keypress_simulator: dependency: "direct main" description: - name: keypress_simulator - sha256: d5aa5ed472b6b396f41fd6dcee99f4afb2c7ac6202af622b4cec7955de6ed7f6 - url: "https://pub.dev" - source: hosted + path: "keypress_simulator/packages/keypress_simulator" + relative: true + source: path version: "0.2.0" keypress_simulator_macos: dependency: transitive description: - name: keypress_simulator_macos - sha256: babb698b1331cff0301de839c7bc6b051d84f98ddb137cf9a6dda6c6caeb78ac - url: "https://pub.dev" - source: hosted + path: "keypress_simulator/packages/keypress_simulator_macos" + relative: true + source: path version: "0.2.0" keypress_simulator_platform_interface: dependency: transitive description: - name: keypress_simulator_platform_interface - sha256: "38c35fee6b107ff10cfb6bdb61e32eb0db17545ed64399a357794431212ca4b4" - url: "https://pub.dev" - source: hosted + path: "keypress_simulator/packages/keypress_simulator_platform_interface" + relative: true + source: path version: "0.2.0" keypress_simulator_windows: - dependency: "direct overridden" + dependency: transitive description: path: "keypress_simulator/packages/keypress_simulator_windows" relative: true @@ -630,6 +627,46 @@ packages: url: "https://pub.dev" source: hosted version: "3.1.0" + screen_retriever: + dependency: transitive + description: + name: screen_retriever + sha256: "570dbc8e4f70bac451e0efc9c9bb19fa2d6799a11e6ef04f946d7886d2e23d0c" + url: "https://pub.dev" + source: hosted + version: "0.2.0" + screen_retriever_linux: + dependency: transitive + description: + name: screen_retriever_linux + sha256: f7f8120c92ef0784e58491ab664d01efda79a922b025ff286e29aa123ea3dd18 + url: "https://pub.dev" + source: hosted + version: "0.2.0" + screen_retriever_macos: + dependency: transitive + description: + name: screen_retriever_macos + sha256: "71f956e65c97315dd661d71f828708bd97b6d358e776f1a30d5aa7d22d78a149" + url: "https://pub.dev" + source: hosted + version: "0.2.0" + screen_retriever_platform_interface: + dependency: transitive + description: + name: screen_retriever_platform_interface + sha256: ee197f4581ff0d5608587819af40490748e1e39e648d7680ecf95c05197240c0 + url: "https://pub.dev" + source: hosted + version: "0.2.0" + screen_retriever_windows: + dependency: transitive + description: + name: screen_retriever_windows + sha256: "449ee257f03ca98a57288ee526a301a430a344a161f9202b4fcc38576716fe13" + url: "https://pub.dev" + source: hosted + version: "0.2.0" shared_preferences: dependency: "direct main" description: @@ -875,6 +912,14 @@ packages: url: "https://pub.dev" source: hosted version: "5.12.0" + window_manager: + dependency: "direct main" + description: + name: window_manager + sha256: "732896e1416297c63c9e3fb95aea72d0355f61390263982a47fd519169dc5059" + url: "https://pub.dev" + source: hosted + version: "0.4.3" xdg_directories: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 25c9ce47..9824e15a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: swift_control description: "SwiftControl - Control your virtual riding" publish_to: 'none' # Remove this line if you wish to publish to pub.dev -version: 1.2.0+0 +version: 2.0.0+0 environment: sdk: ^3.7.0 @@ -18,7 +18,9 @@ dependencies: dartx: any image_picker: ^1.1.2 pointycastle: any - keypress_simulator: any + window_manager: ^0.4.3 + keypress_simulator: + path: keypress_simulator/packages/keypress_simulator shared_preferences: ^2.5.3 flex_color_scheme: ^8.2.0 package_info_plus: ^8.3.0 @@ -26,10 +28,6 @@ dependencies: path: accessibility http: ^1.3.0 -dependency_overrides: - keypress_simulator_windows: - path: keypress_simulator/packages/keypress_simulator_windows - dev_dependencies: flutter_test: sdk: flutter diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index e06ea60e..4b74dcdd 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -9,8 +9,10 @@ #include #include #include +#include #include #include +#include void RegisterPlugins(flutter::PluginRegistry* registry) { FileSelectorWindowsRegisterWithRegistrar( @@ -19,8 +21,12 @@ void RegisterPlugins(flutter::PluginRegistry* registry) { registry->GetRegistrarForPlugin("KeypressSimulatorWindowsPluginCApi")); PermissionHandlerWindowsPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin")); + ScreenRetrieverWindowsPluginCApiRegisterWithRegistrar( + registry->GetRegistrarForPlugin("ScreenRetrieverWindowsPluginCApi")); UniversalBlePluginCApiRegisterWithRegistrar( registry->GetRegistrarForPlugin("UniversalBlePluginCApi")); UrlLauncherWindowsRegisterWithRegistrar( registry->GetRegistrarForPlugin("UrlLauncherWindows")); + WindowManagerPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("WindowManagerPlugin")); } diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index ea1a1f6f..c1bc4ca3 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -6,8 +6,10 @@ list(APPEND FLUTTER_PLUGIN_LIST file_selector_windows keypress_simulator_windows permission_handler_windows + screen_retriever_windows universal_ble url_launcher_windows + window_manager ) list(APPEND FLUTTER_FFI_PLUGIN_LIST