refactor: Moved wiimote reading to event-based calls

This commit is contained in:
Gerard Gascón 2024-06-15 13:20:08 +02:00
parent e8996a382d
commit 42f5ed78fe
3 changed files with 168 additions and 34 deletions

View file

@ -16,7 +16,7 @@ public class JoyConRead : IGamepadReader {
HidDevice? device = GetHidDevice();
if (device == null) {
Console.WriteLine("No controller. Please connect Joy-Con or Pro controller via Bluetooth.");
Console.WriteLine("No controller. Please connect Joy-Con via Bluetooth.");
Console.WriteLine("Press any key to exit program.");
Console.ReadKey();
return;
@ -39,11 +39,14 @@ public class JoyConRead : IGamepadReader {
Console.WriteLine("JoyCon ready for presenting.");
Console.WriteLine("Press Enter to exit program.");
while (Console.ReadKey().Key != ConsoleKey.Enter) { }
while (Console.ReadKey().Key != ConsoleKey.Enter) {
await Task.Yield();
}
joycon.Stop();
Console.WriteLine();
Console.WriteLine("Stopped.");
await Task.CompletedTask;
}
private static async Task LogDeviceInfo(JoyCon joycon) {