From 009fdb10198b325180eefb60a5cc2bb6439fcf1c Mon Sep 17 00:00:00 2001 From: Jonas Bark Date: Tue, 3 Feb 2026 09:40:57 +0100 Subject: [PATCH] bug fixes around keymap --- lib/bluetooth/devices/base_device.dart | 2 +- lib/pages/touch_area.dart | 2 ++ lib/utils/keymap/keymap.dart | 13 ++++++++----- lib/widgets/keymap_explanation.dart | 4 ++-- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/bluetooth/devices/base_device.dart b/lib/bluetooth/devices/base_device.dart index f65f8411..32677942 100644 --- a/lib/bluetooth/devices/base_device.dart +++ b/lib/bluetooth/devices/base_device.dart @@ -49,7 +49,7 @@ abstract class BaseDevice { String get name => _name ?? runtimeType.toString(); - String get buttonExplanation => 'Click a button on this device to configure them.'; + String get buttonExplanation => isConnected ? 'Connecting...' : 'Click a button on this device to configure them.'; @override bool operator ==(Object other) => diff --git a/lib/pages/touch_area.dart b/lib/pages/touch_area.dart index d6d21225..c512476c 100644 --- a/lib/pages/touch_area.dart +++ b/lib/pages/touch_area.dart @@ -296,6 +296,8 @@ class _TouchAreaSetupPageState extends State { final relativeX = ((newPos.dx - _imageRect.left) / _imageRect.width).clamp(0.0, 1.0); final relativeY = ((newPos.dy - _imageRect.top) / _imageRect.height).clamp(0.0, 1.0); keyPair.touchPosition = Offset(relativeX * 100.0, relativeY * 100.0); + keyPair.inGameAction = null; + keyPair.inGameActionValue = null; setState(() {}); }, color: Colors.red, diff --git a/lib/utils/keymap/keymap.dart b/lib/utils/keymap/keymap.dart index 4bf6c5d2..5c75a75b 100644 --- a/lib/utils/keymap/keymap.dart +++ b/lib/utils/keymap/keymap.dart @@ -104,14 +104,17 @@ class Keymap { void addNewButtons(List availableButtons) { final newButtons = availableButtons.filter((button) => getKeyPair(button) == null); for (final button in newButtons) { + final buttonFromBase = core.settings.getTrainerApp()?.keymap.getKeyPair(button); addKeyPair( KeyPair( - touchPosition: Offset.zero, + touchPosition: buttonFromBase?.touchPosition ?? Offset.zero, buttons: [button], inGameAction: button.action, - physicalKey: null, - logicalKey: null, - isLongPress: false, + physicalKey: buttonFromBase?.physicalKey, + logicalKey: buttonFromBase?.logicalKey, + isLongPress: buttonFromBase?.isLongPress ?? false, + inGameActionValue: buttonFromBase?.inGameActionValue, + androidAction: buttonFromBase?.androidAction, ), ); } @@ -247,7 +250,7 @@ class KeyPair { : (physicalKey != null && core.actionHandler.supportedModes.contains(SupportedMode.keyboard)) ? null : (touchPosition != Offset.zero && core.logic.showLocalRemoteOptions) - ? 'X:${touchPosition.dx.toInt()}, Y:${touchPosition.dy.toInt()}' + ? 'X:${touchPosition.dx.toInt()}, Y:${touchPosition.dy.toInt()}${inGameAction != null ? ' (${inGameAction!.title})' : ''}' : ''; if (text != null && text.isNotEmpty) { return text; diff --git a/lib/widgets/keymap_explanation.dart b/lib/widgets/keymap_explanation.dart index a94a5e92..31790a41 100644 --- a/lib/widgets/keymap_explanation.dart +++ b/lib/widgets/keymap_explanation.dart @@ -101,9 +101,9 @@ class _KeymapExplanationState extends State { for (final devicePair in keyButtonMap.entries) ...[ SizedBox(height: 12), ColoredTitle(text: devicePair.key.toString()), - if (devicePair.value.isEmpty && devicePair.key.buttonExplanation != null) + if (devicePair.value.isEmpty) Text( - devicePair.key.buttonExplanation!, + devicePair.key.buttonExplanation, style: TextStyle(height: 1), ).muted, for (final keyPair in devicePair.value) ...[