diff --git a/CHANGELOG.md b/CHANGELOG.md index f575e447..b468a6b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,12 @@ ### 4.0.0 (unreleased) **Features:** -- a brand new design +- a brand-new design + - Accessibility Permission is now optional on Android - Zwift is now fully supported on all operating systems - you can choose between network based control or bluetooth based control -- BikeControl is now translated to German and French (contact me if you want to help with more translations) -- support for KICKR BIKE PRO +- BikeControl is now translated to German and French (contact me if you'd like to help with more translations) +- support for Wahoo KICKR BIKE PRO - support for the OpenBikeControl protocol for supported Trainer apps - this enables seamless and official integration, independent of the operating system - learn more at https://openbikecontrol.org diff --git a/lib/bluetooth/devices/base_device.dart b/lib/bluetooth/devices/base_device.dart index 37b6d35a..e4818d82 100644 --- a/lib/bluetooth/devices/base_device.dart +++ b/lib/bluetooth/devices/base_device.dart @@ -149,12 +149,16 @@ abstract class BaseDevice { Widget showInformation(BuildContext context); ControllerButton? getOrAddButton(String key, ControllerButton Function() creator) { - final button = core.actionHandler.supportedApp?.keymap.getOrAddButton(key, creator); + if (core.actionHandler.supportedApp is CustomApp) { + final button = core.actionHandler.supportedApp?.keymap.getOrAddButton(key, creator); - if (button != null && availableButtons.none((e) => e.name == button.name)) { - availableButtons.add(button); - core.settings.setKeyMap(core.actionHandler.supportedApp!); + if (button != null && availableButtons.none((e) => e.name == button.name)) { + availableButtons.add(button); + core.settings.setKeyMap(core.actionHandler.supportedApp!); + } + return button; + } else { + return null; } - return button; } } diff --git a/lib/utils/actions/android.dart b/lib/utils/actions/android.dart index be007b81..4975d1b5 100644 --- a/lib/utils/actions/android.dart +++ b/lib/utils/actions/android.dart @@ -5,7 +5,6 @@ import 'package:swift_control/bluetooth/devices/hid/hid_device.dart'; import 'package:swift_control/gen/l10n.dart'; import 'package:swift_control/utils/actions/base_actions.dart'; import 'package:swift_control/utils/core.dart'; -import 'package:swift_control/utils/keymap/apps/custom_app.dart'; import 'package:swift_control/utils/keymap/buttons.dart'; import 'package:swift_control/widgets/keymap_explanation.dart'; @@ -29,20 +28,18 @@ class AndroidActions extends BaseActions { }); hidKeyPressed().listen((keyPressed) { - if (supportedApp is CustomApp) { - final hidDevice = HidDevice(keyPressed.source); - final button = hidDevice.getOrAddButton(keyPressed.hidKey, () => ControllerButton(keyPressed.hidKey))!; + final hidDevice = HidDevice(keyPressed.source); + final button = hidDevice.getOrAddButton(keyPressed.hidKey, () => ControllerButton(keyPressed.hidKey))!; - var availableDevice = core.connection.controllerDevices.firstOrNullWhere((e) => e.name == hidDevice.name); - if (availableDevice == null) { - core.connection.addDevices([hidDevice]); - availableDevice = hidDevice; - } - if (keyPressed.keyDown) { - availableDevice.handleButtonsClicked([button]); - } else if (keyPressed.keyUp) { - availableDevice.handleButtonsClicked([]); - } + var availableDevice = core.connection.controllerDevices.firstOrNullWhere((e) => e.name == hidDevice.name); + if (availableDevice == null) { + core.connection.addDevices([hidDevice]); + availableDevice = hidDevice; + } + if (keyPressed.keyDown) { + availableDevice.handleButtonsClicked([button]); + } else if (keyPressed.keyUp) { + availableDevice.handleButtonsClicked([]); } }); } diff --git a/lib/widgets/scan.dart b/lib/widgets/scan.dart index 4e4e4195..e4bbe141 100644 --- a/lib/widgets/scan.dart +++ b/lib/widgets/scan.dart @@ -141,6 +141,9 @@ class _ScanWidgetState extends State { setState(() { _needsPermissions = permissions; }); + if (permissions.isEmpty) { + core.connection.performScanning(); + } }); } }