From 6492afc46f005ff3f4e090c8faee7a2f9cc83020 Mon Sep 17 00:00:00 2001 From: Jonas Bark Date: Wed, 10 Dec 2025 19:14:13 +0100 Subject: [PATCH] MyWhoosh: updated default keymap to use steering instead of navigating --- CHANGELOG.md | 3 +- lib/bluetooth/devices/zwift/constants.dart | 4 +- lib/bluetooth/devices/zwift/zwift_play.dart | 2 +- lib/pages/button_simulator.dart | 115 +++++++++----------- lib/utils/keymap/apps/my_whoosh.dart | 8 +- 5 files changed, 63 insertions(+), 69 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4cf5dfe..0ec5d50 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,8 @@ - control your trainer manually without requiring a controller - just like a Companion app **Fixes**: -- Gamepads: handle analog values correctly on Windows +- Gamepads: handle analog values correctly on Windows +- MyWhoosh: updated default keymap to use steering instead of navigating ### 4.0.0 (07-12-2025) diff --git a/lib/bluetooth/devices/zwift/constants.dart b/lib/bluetooth/devices/zwift/constants.dart index d487c70..fec014a 100644 --- a/lib/bluetooth/devices/zwift/constants.dart +++ b/lib/bluetooth/devices/zwift/constants.dart @@ -71,13 +71,13 @@ class ZwiftButtons { ); static const ControllerButton navigationLeft = ControllerButton( 'navigationLeft', - action: InGameAction.navigateLeft, + action: InGameAction.steerLeft, icon: Icons.keyboard_arrow_left, color: Colors.black, ); static const ControllerButton navigationRight = ControllerButton( 'navigationRight', - action: InGameAction.navigateRight, + action: InGameAction.steerRight, icon: Icons.keyboard_arrow_right, color: Colors.black, ); diff --git a/lib/bluetooth/devices/zwift/zwift_play.dart b/lib/bluetooth/devices/zwift/zwift_play.dart index 948d003..1e13bed 100644 --- a/lib/bluetooth/devices/zwift/zwift_play.dart +++ b/lib/bluetooth/devices/zwift/zwift_play.dart @@ -72,7 +72,7 @@ class ZwiftPlay extends ZwiftDevice { super.showInformation(context), Checkbox( - trailing: Text(context.i18n.enableVibrationFeedback), + trailing: Expanded(child: Text(context.i18n.enableVibrationFeedback)), state: core.settings.getVibrationEnabled() ? CheckboxState.checked : CheckboxState.unchecked, onChanged: (value) async { await core.settings.setVibrationEnabled(value == CheckboxState.checked); diff --git a/lib/pages/button_simulator.dart b/lib/pages/button_simulator.dart index 6bc57d6..b2fe8c4 100644 --- a/lib/pages/button_simulator.dart +++ b/lib/pages/button_simulator.dart @@ -1,6 +1,7 @@ import 'package:dartx/dartx.dart'; import 'package:flutter/material.dart' show BackButton; import 'package:shadcn_flutter/shadcn_flutter.dart'; +import 'package:swift_control/bluetooth/devices/trainer_connection.dart'; import 'package:swift_control/utils/actions/android.dart'; import 'package:swift_control/utils/actions/desktop.dart'; import 'package:swift_control/utils/core.dart'; @@ -66,67 +67,11 @@ class ButtonSimulator extends StatelessWidget { (action) => PrimaryButton( size: ButtonSize(1.6), child: Text(action.title), - onPressed: () async { - if (action.possibleValues != null) { - showDropdown( - context: context, - builder: (context) => DropdownMenu( - children: action.possibleValues! - .map( - (e) => MenuButton( - child: Text(e.toString()), - onPressed: (c) async { - await connection.sendAction( - KeyPair( - buttons: [], - physicalKey: null, - logicalKey: null, - inGameAction: action, - inGameActionValue: e, - ), - isKeyDown: true, - isKeyUp: false, - ); - await connection.sendAction( - KeyPair( - buttons: [], - physicalKey: null, - logicalKey: null, - inGameAction: action, - inGameActionValue: e, - ), - isKeyDown: false, - isKeyUp: true, - ); - }, - ), - ) - .toList(), - ), - ); - return; - } else { - await connection.sendAction( - KeyPair( - buttons: [], - physicalKey: null, - logicalKey: null, - inGameAction: action, - ), - isKeyDown: true, - isKeyUp: false, - ); - await connection.sendAction( - KeyPair( - buttons: [], - physicalKey: null, - logicalKey: null, - inGameAction: action, - ), - isKeyDown: false, - isKeyUp: true, - ); - } + onTapDown: (c) async { + _sendKey(context, down: true, action: action, connection: connection); + }, + onTapUp: (c) async { + _sendKey(context, down: false, action: action, connection: connection); }, ), ) @@ -188,4 +133,52 @@ class ButtonSimulator extends StatelessWidget { ), ); } + + Future _sendKey( + BuildContext context, { + required bool down, + required InGameAction action, + required TrainerConnection connection, + }) async { + if (action.possibleValues != null) { + if (down) return; + showDropdown( + context: context, + builder: (context) => DropdownMenu( + children: action.possibleValues! + .map( + (e) => MenuButton( + child: Text(e.toString()), + onPressed: (c) async { + await connection.sendAction( + KeyPair( + buttons: [], + physicalKey: null, + logicalKey: null, + inGameAction: action, + inGameActionValue: e, + ), + isKeyDown: false, + isKeyUp: true, + ); + }, + ), + ) + .toList(), + ), + ); + return; + } else { + await connection.sendAction( + KeyPair( + buttons: [], + physicalKey: null, + logicalKey: null, + inGameAction: action, + ), + isKeyDown: down, + isKeyUp: !down, + ); + } + } } diff --git a/lib/utils/keymap/apps/my_whoosh.dart b/lib/utils/keymap/apps/my_whoosh.dart index a9f1c84..4d648e5 100644 --- a/lib/utils/keymap/apps/my_whoosh.dart +++ b/lib/utils/keymap/apps/my_whoosh.dart @@ -40,7 +40,7 @@ class MyWhoosh extends SupportedApp { ), ), ...ControllerButton.values - .filter((e) => e.action == InGameAction.navigateRight) + .filter((e) => e.action == InGameAction.steerRight) .map( (b) => KeyPair( buttons: [b], @@ -48,11 +48,11 @@ class MyWhoosh extends SupportedApp { logicalKey: LogicalKeyboardKey.arrowRight, touchPosition: Offset(60, 80), isLongPress: true, - inGameAction: InGameAction.navigateRight, + inGameAction: InGameAction.steerRight, ), ), ...ControllerButton.values - .filter((e) => e.action == InGameAction.navigateLeft) + .filter((e) => e.action == InGameAction.steerLeft) .map( (b) => KeyPair( buttons: [b], @@ -60,7 +60,7 @@ class MyWhoosh extends SupportedApp { logicalKey: LogicalKeyboardKey.arrowLeft, touchPosition: Offset(32, 80), isLongPress: true, - inGameAction: InGameAction.navigateLeft, + inGameAction: InGameAction.steerLeft, ), ), ...ControllerButton.values