initialize method
Implementation
Future<void> initialize({Function(GamepadState state)? onCallback}) async {
try {
List<int> devices = await getAvaibleDevices();
if (devices.isNotEmpty) {
await selectGamepad(devices[0]);
}
await WinGamepad.initialize();
isConnected = true;
} catch (_) {}
WinGamepad.eventStream.listen((event) {
update(Map<String, dynamic>.from(event));
if (onCallback != null) {
onCallback(state);
}
});
}