Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ Future<Map<String, GamepadDeviceKey>> defaultGamepadDeviceLookup() async {

final devices = {
for (final controller in controllers)
controller.id: GamepadDeviceKey(name: controller.name),
controller.id: GamepadDeviceKey(
name: controller.name,
vendorId: controller.vendorId,
productId: controller.productId,
),
};

for (final controller in controllers) {
Expand Down
2 changes: 1 addition & 1 deletion packages/nesd/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ dependencies:
flutter_material_design_icons: ^3.1.0+7447
flutter_riverpod: ^3.4.3
freezed_annotation: ^3.1.0
gamepads: ^0.1.11
gamepads: ^0.1.12
hooks_riverpod: ^3.4.3
idb_shim: ^2.9.9
image: ^4.10.1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:gamepads/gamepads.dart';
import 'package:nesd/ui/emulator/input/gamepad/gamepad_device_directory.dart';
Expand All @@ -8,6 +9,8 @@ import 'package:nesd/ui/emulator/input/gamepad/gamepad_input_mapper.dart';
import 'package:nesd/ui/emulator/input/gamepad/gamepad_slot_registry.dart';

void main() {
TestWidgetsFlutterBinding.ensureInitialized();

const dualSense = GamepadDeviceKey(
name: 'Sony DualSense',
vendorId: 1356,
Expand Down Expand Up @@ -187,4 +190,44 @@ void main() {
expect(registry.slotOf('0'), 0);
expect(calls, 1);
});

group('the default lookup', () {
const channel = MethodChannel('xyz.luan/gamepads');

final messenger =
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger;

void listGamepads(List<Map<String, Object>> gamepads) =>
messenger.setMockMethodCallHandler(
channel,
(call) async => call.method == 'listGamepads' ? gamepads : null,
);

tearDown(() => messenger.setMockMethodCallHandler(channel, null));

test('carries the ids the platform reports', () async {
listGamepads([
{
'id': '0',
'name': 'Sony DualSense',
'vendorId': 1356,
'productId': 3302,
},
]);

expect(await defaultGamepadDeviceLookup(), {'0': dualSense});
});

test('leaves the ids null where the platform has none', () async {
listGamepads([
{'id': '0', 'name': 'Sony Interactive Entertainment - DualSense'},
]);

expect(await defaultGamepadDeviceLookup(), {
'0': const GamepadDeviceKey(
name: 'Sony Interactive Entertainment - DualSense',
),
});
});
});
}
34 changes: 13 additions & 21 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -428,66 +428,58 @@ packages:
dependency: transitive
description:
name: gamepads
sha256: "8134c967c29496cbc20e73c88b31c6d11765e846b8e465c52b436fe6e88339ce"
sha256: "212cafc5d240b5067eee2a0650b903ddbc18eafbc71a0d1064f8c06587db8ea6"
url: "https://pub.dev"
source: hosted
version: "0.1.11"
version: "0.1.12"
gamepads_android:
dependency: transitive
description:
name: gamepads_android
sha256: f3a600e1212374771bdd47206088940a36fb75791b3c4223eccfa487dfd1ed0f
sha256: c50ccad8cd5dab70b9a1eda11862f2756da2a82005b9b580fbb0f4b2c0fbd3a2
url: "https://pub.dev"
source: hosted
version: "0.1.9"
version: "0.1.10"
gamepads_darwin:
dependency: transitive
description:
name: gamepads_darwin
sha256: "113d50ad327aa5f1b5df6807310a4f23865c01330f7a62d5c53c9df8933f948a"
url: "https://pub.dev"
source: hosted
version: "0.1.3"
gamepads_ios:
dependency: transitive
description:
name: gamepads_ios
sha256: "9a65f16797c7479d2bc6d7967d45e8b2448c6302b128fcf3231460f839021a37"
sha256: ab7d2c8ee84ffc989a8c942204c1bc2d6c6585dfa640a30c5e72ef5e4cdf8c91
url: "https://pub.dev"
source: hosted
version: "0.1.4"
gamepads_linux:
dependency: transitive
description:
name: gamepads_linux
sha256: "80bf70df6da6185926e6d8b2feb98e725e6fe99290afafaea91dba471e8c1c1e"
sha256: ec986955e9cbe505c0874bb960ec6a87d8c2c31e30ff5453d4c9be2020eac097
url: "https://pub.dev"
source: hosted
version: "0.1.2"
version: "0.1.3"
gamepads_platform_interface:
dependency: transitive
description:
name: gamepads_platform_interface
sha256: "9ddb3b61c780284a17739d759929d2e32b912d12d9145ee493ffe2b43fc6256a"
sha256: "51b243f64c3d02900ac37eef0ed0177710ef5b0a1265dbf46bb93ca0f4200f17"
url: "https://pub.dev"
source: hosted
version: "0.1.3"
version: "0.1.4"
gamepads_web:
dependency: transitive
description:
name: gamepads_web
sha256: "4f044a6003b34a8d5c5854924fbbfd64b6653bcb49169cf2aca26938f812672e"
sha256: "5ceaa635cdba536f1ee2b650227c39f5e4a8b1ec6588b00ea0ea6e7291d8e62e"
url: "https://pub.dev"
source: hosted
version: "0.1.2"
version: "0.1.3"
gamepads_windows:
dependency: transitive
description:
name: gamepads_windows
sha256: ecd1dc845a0ad6260a3016cd74f3e365c4006a458ae2c5c5eed7a72d33dd5738
sha256: "2caf3abda6fe5a7ff7f434b00e71cfc823b594ef30326b7347e4635f1f0bad9c"
url: "https://pub.dev"
source: hosted
version: "0.3.1"
version: "0.3.2"
glob:
dependency: transitive
description:
Expand Down
Loading