refactor: made GamepadReader an interface
This commit is contained in:
parent
9e0abe972f
commit
36574bdf46
4 changed files with 11 additions and 11 deletions
|
@ -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();
|
||||
}
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue