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;
|
namespace SwitchSlidePresenter;
|
||||||
|
|
||||||
public abstract class GamepadReader {
|
public interface IGamepadReader {
|
||||||
public abstract event Action NextSlide;
|
public event Action NextSlide;
|
||||||
public abstract event Action PrevSlide;
|
public event Action PrevSlide;
|
||||||
|
|
||||||
public abstract Task Read();
|
public Task Read();
|
||||||
}
|
}
|
|
@ -10,11 +10,11 @@ using wtf.cluster.JoyCon.Rumble;
|
||||||
|
|
||||||
namespace SwitchSlidePresenter;
|
namespace SwitchSlidePresenter;
|
||||||
|
|
||||||
public class JoyConRead : GamepadReader {
|
public class JoyConRead : IGamepadReader {
|
||||||
public override event Action NextSlide;
|
public event Action NextSlide;
|
||||||
public override event Action PrevSlide;
|
public event Action PrevSlide;
|
||||||
|
|
||||||
public override async Task Read() {
|
public async Task Read() {
|
||||||
Console.OutputEncoding = Encoding.UTF8;
|
Console.OutputEncoding = Encoding.UTF8;
|
||||||
|
|
||||||
HidDevice? device = GetHidDevice();
|
HidDevice? device = GetHidDevice();
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
namespace SwitchSlidePresenter {
|
namespace SwitchSlidePresenter {
|
||||||
class Program {
|
class Program {
|
||||||
private static async Task Main() {
|
private static async Task Main() {
|
||||||
GamepadReader reader = new JoyConRead();
|
IGamepadReader reader = new JoyConRead();
|
||||||
SlideSwitcher switcher = new(reader);
|
SlideSwitcher switcher = new(reader);
|
||||||
await reader.Read();
|
await reader.Read();
|
||||||
switcher.Dispose();
|
switcher.Dispose();
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
namespace SwitchSlidePresenter;
|
namespace SwitchSlidePresenter;
|
||||||
|
|
||||||
public class SlideSwitcher : IDisposable {
|
public class SlideSwitcher : IDisposable {
|
||||||
private readonly GamepadReader _reader;
|
private readonly IGamepadReader _reader;
|
||||||
|
|
||||||
public SlideSwitcher(GamepadReader reader) {
|
public SlideSwitcher(IGamepadReader reader) {
|
||||||
_reader = reader;
|
_reader = reader;
|
||||||
_reader.NextSlide += NextSlide;
|
_reader.NextSlide += NextSlide;
|
||||||
_reader.PrevSlide += PreviousSlide;
|
_reader.PrevSlide += PreviousSlide;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue