mirror of
https://github.com/jonasbark/swiftcontrol.git
synced 2026-12-02 10:09:09 +01:00
FulGaz takes nothing from a controller. Decompiling 7.0.6 (Android) and 7.0.9 (macOS) found no key handling, no gamepad, no OpenBikeControl and no Zwift service — and no trainer discovery over the network either: the macOS build ships a "Direct Connect Trainers" local-network permission string with nothing behind it (no NSBonjourServices, no Bonjour APIs linked, no UDP). So the one thing BikeControl can be to it is a Bluetooth trainer on a second device, doing the virtual shifting itself. Three capability members on SupportedApp express that, all defaulting to today's behaviour so no other app changes: - virtualShiftingTransports — which Bridge transports the app can find us on. The enum's own doc comment already promised this; the member was missing. Narrowed to Bluetooth for FulGaz, which collapses the VS transport toggle and coerces a saved wifi mode. - acceptsSimulatedInput — false for FulGaz, so Local and the remote Bluetooth keyboard/mouse stop being offered as dead ends. - receivesButtonEvents — derived; pins the target to "another device" in both target pickers and in applyTrainerAppSelection, mirroring BikeControl. Two consequences worth calling out. With every tile hidden, hasNoConnectionMethod would have read as unfinished setup and disabled the onboarding Continue button — for FulGaz that state is the finished one. And the connection step promised a network advertisement the app never looks for, so apps with no wifi transport now get their own Bluetooth wording (6 locales). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
84 lines
3.1 KiB
Dart
84 lines
3.1 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:bike_control/utils/core.dart';
|
|
import 'package:bike_control/utils/keymap/apps/bike_control.dart';
|
|
import 'package:bike_control/utils/keymap/apps/custom_app.dart';
|
|
import 'package:bike_control/utils/keymap/apps/my_whoosh.dart';
|
|
import 'package:bike_control/utils/keymap/apps/supported_app.dart';
|
|
import 'package:bike_control/utils/requirements/multi.dart';
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
/// Applies the trainer app selection, stopping unsupported emulators,
|
|
/// initializing the action handler, and starting the enabled connection method.
|
|
///
|
|
/// Shared by [ConfigurationPage] and the onboarding wizard.
|
|
Future<void> applyTrainerAppSelection(SupportedApp selectedApp) async {
|
|
if (selectedApp is! MyWhoosh) {
|
|
if (core.whooshLink.isStarted.value) {
|
|
core.whooshLink.stopServer();
|
|
}
|
|
}
|
|
if (!selectedApp.supports(AppConnectionMethod.zwiftMdns)) {
|
|
if (core.zwiftMdnsEmulator.isStarted.value) {
|
|
core.zwiftMdnsEmulator.stop();
|
|
}
|
|
// TODO restart mDNS when advertisementName changes
|
|
}
|
|
if (!selectedApp.supports(AppConnectionMethod.zwiftBle)) {
|
|
if (core.zwiftEmulator.isStarted.value) {
|
|
core.zwiftEmulator.stopAdvertising();
|
|
}
|
|
}
|
|
if (!selectedApp.supports(AppConnectionMethod.rouvyMdns)) {
|
|
if (core.rouvyMdnsEmulator.isStarted.value) {
|
|
core.rouvyMdnsEmulator.stop();
|
|
}
|
|
}
|
|
if (core.obpMdnsEmulator.isStarted.value) {
|
|
core.obpMdnsEmulator.stopServer();
|
|
}
|
|
if (core.obpBluetoothEmulator.isStarted.value) {
|
|
core.obpBluetoothEmulator.stopServer();
|
|
}
|
|
|
|
core.settings.setTrainerApp(selectedApp);
|
|
if (core.actionHandler.supportedApp == null ||
|
|
(core.actionHandler.supportedApp is! CustomApp && selectedApp is! CustomApp)) {
|
|
core.actionHandler.init(selectedApp);
|
|
core.settings.setKeyMap(selectedApp);
|
|
}
|
|
core.logic.startEnabledConnectionMethod();
|
|
|
|
if (selectedApp is BikeControl) {
|
|
core.settings.setLastTarget(Target.thisDevice);
|
|
} else if (!selectedApp.receivesButtonEvents) {
|
|
// Nothing we can send reaches this app locally, so a stale "this device"
|
|
// would leave the rider on a target that cannot work.
|
|
core.settings.setLastTarget(Target.otherDevice);
|
|
}
|
|
}
|
|
|
|
/// Applies the target selection, enabling OBP methods or local connection
|
|
/// as appropriate, and starting the enabled connection method.
|
|
///
|
|
/// Shared by [ConfigurationPage] and the onboarding wizard.
|
|
Future<void> applyTargetSelection(Target target) async {
|
|
await core.settings.setLastTarget(target);
|
|
|
|
if ((core.settings.getTrainerApp()?.supports(AppConnectionMethod.obpBle) == true ||
|
|
core.settings.getTrainerApp()?.supports(AppConnectionMethod.obpMdns) == true) &&
|
|
!core.logic.emulatorEnabled) {
|
|
core.settings.setObpMdnsEnabled(true);
|
|
}
|
|
|
|
// enable local connection on Windows if the app doesn't support OBP
|
|
if (target == Target.thisDevice &&
|
|
!core.settings.getTrainerApp()!.supports(AppConnectionMethod.obpBle) &&
|
|
!core.settings.getTrainerApp()!.supports(AppConnectionMethod.obpMdns) &&
|
|
!kIsWeb &&
|
|
Platform.isWindows) {
|
|
core.settings.setLocalEnabled(true);
|
|
}
|
|
core.logic.startEnabledConnectionMethod();
|
|
}
|