Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,6 @@ service-account.json
.env
lib/generated
pubspec_overrides.yaml

# FVM Version Cache
.fvm/
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ class MethodChannelKeyPressSimulator extends KeyPressSimulatorPlatform {
}) async {
PhysicalKeyboardKey? physicalKey = key is PhysicalKeyboardKey ? key : null;
if (key is LogicalKeyboardKey) {
physicalKey = key.physicalKey;
physicalKey = PhysicalKeyboardKey(key.keyId);
}
if (key != null && physicalKey == null) {
throw UnsupportedError('Unsupported key: $key.');
}
final Map<Object?, Object?> arguments = {
'keyCode': physicalKey?.keyCode,
'keyCode': physicalKey?.usbHidUsage,
'modifiers': modifiers.map((e) => e.name).toList(),
'keyDown': keyDown,
'targetAppName': targetApp,
Expand Down Expand Up @@ -87,3 +87,6 @@ class MethodChannelKeyPressSimulator extends KeyPressSimulatorPlatform {
await methodChannel.invokeMethod('simulateMediaKey', arguments);
}
}



3 changes: 2 additions & 1 deletion lib/bluetooth/devices/zwift/ftms_mdns_emulator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class FtmsMdnsEmulator extends TrainerConnection {
}

Future<void> startServer() async {
return clickEmulator.startServer(core.settings.getTrainerApp() is Rouvy);
return clickEmulator.startServer();
}

void stop() {
Expand Down Expand Up @@ -119,3 +119,4 @@ class FtmsMdnsConstants {
static const DC_MESSAGE_ENABLE_CHARACTERISTIC_NOTIFICATIONS = 0x05; // Enable Characteristic Notifications
static const DC_MESSAGE_CHARACTERISTIC_NOTIFICATION = 0x06; // Characteristic Notification
}

3 changes: 2 additions & 1 deletion lib/bluetooth/devices/zwift/zwift_device.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ abstract class ZwiftDevice extends BluetoothDevice {
}

try {
if (bytes.startsWith(startCommand)) {
if (bytes.length >= startCommand.length && bytes.sublist(0, startCommand.length).toString() == startCommand.toString()) {
processDevicePublicKeyResponse(bytes);
} else {
processData(bytes);
Expand Down Expand Up @@ -221,3 +221,4 @@ abstract class ZwiftDevice extends BluetoothDevice {
);
}
}

3 changes: 2 additions & 1 deletion lib/utils/keymap/apps/custom_app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class CustomApp extends SupportedApp {
return;
}

final keyPairs = data.map((e) => KeyPair.decode(e)).whereNotNull().toList();
final keyPairs = data.map((e) => KeyPair.decode(e)).whereType<KeyPair>().toList();
if (keyPairs.isEmpty) {
return;
}
Expand Down Expand Up @@ -83,3 +83,4 @@ class CustomApp extends SupportedApp {
}
}
}

9 changes: 3 additions & 6 deletions lib/utils/keymap/manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,7 @@ class KeymapManager {
} else {
final customApp = CustomApp(profileName: newName);

final connectedDeviceButtons = IterableFlatMap(
core.connection.controllerDevices,
).flatMap((e) => e.availableButtons).toSet();
final connectedDeviceButtons = core.connection.controllerDevices.expand((e) => e.availableButtons).toSet();
core.actionHandler.supportedApp!.keymap.keyPairs.forEachIndexed((pair, index) {
pair.buttons.filter((button) => connectedDeviceButtons.contains(button) == true).forEachIndexed((
button,
Expand Down Expand Up @@ -290,9 +288,7 @@ class KeymapManager {
} else {
final customApp = CustomApp(profileName: newName);

final connectedDeviceButtons = IterableFlatMap(
core.connection.controllerDevices,
).flatMap((e) => e.availableButtons).toSet();
final connectedDeviceButtons = core.connection.controllerDevices.expand((e) => e.availableButtons).toSet();
core.actionHandler.supportedApp!.keymap.keyPairs.forEachIndexed((pair, index) {
pair.buttons.filter((button) => connectedDeviceButtons.contains(button) == true).forEachIndexed((
button,
Expand All @@ -317,3 +313,4 @@ class KeymapManager {
}
}
}