From 36574bdf4685967e9a4921f1ac5875eb4ca8bb81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerard=20Gasc=C3=B3n?= <52170489+GerardGascon@users.noreply.github.com> Date: Fri, 7 Jun 2024 01:40:28 +0200 Subject: [PATCH] refactor: made GamepadReader an interface --- GamepadReader.cs | 8 ++++---- JoyConRead.cs | 8 ++++---- Program.cs | 2 +- SlideSwitcher.cs | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/GamepadReader.cs b/GamepadReader.cs index 77770ef..2fbf258 100644 --- a/GamepadReader.cs +++ b/GamepadReader.cs @@ -1,8 +1,8 @@ namespace SwitchSlidePresenter; -public abstract class GamepadReader { - public abstract event Action NextSlide; - public abstract event Action PrevSlide; +public interface IGamepadReader { + public event Action NextSlide; + public event Action PrevSlide; - public abstract Task Read(); + public Task Read(); } \ No newline at end of file diff --git a/JoyConRead.cs b/JoyConRead.cs index 49c1153..5496085 100644 --- a/JoyConRead.cs +++ b/JoyConRead.cs @@ -10,11 +10,11 @@ using wtf.cluster.JoyCon.Rumble; namespace SwitchSlidePresenter; -public class JoyConRead : GamepadReader { - public override event Action NextSlide; - public override event Action PrevSlide; +public class JoyConRead : IGamepadReader { + public event Action NextSlide; + public event Action PrevSlide; - public override async Task Read() { + public async Task Read() { Console.OutputEncoding = Encoding.UTF8; HidDevice? device = GetHidDevice(); diff --git a/Program.cs b/Program.cs index 91aef77..99e227d 100644 --- a/Program.cs +++ b/Program.cs @@ -1,7 +1,7 @@ namespace SwitchSlidePresenter { class Program { private static async Task Main() { - GamepadReader reader = new JoyConRead(); + IGamepadReader reader = new JoyConRead(); SlideSwitcher switcher = new(reader); await reader.Read(); switcher.Dispose(); diff --git a/SlideSwitcher.cs b/SlideSwitcher.cs index 837c292..645d039 100644 --- a/SlideSwitcher.cs +++ b/SlideSwitcher.cs @@ -1,9 +1,9 @@ namespace SwitchSlidePresenter; public class SlideSwitcher : IDisposable { - private readonly GamepadReader _reader; + private readonly IGamepadReader _reader; - public SlideSwitcher(GamepadReader reader) { + public SlideSwitcher(IGamepadReader reader) { _reader = reader; _reader.NextSlide += NextSlide; _reader.PrevSlide += PreviousSlide;