Commit 61c18429 authored by Gerard Gascón's avatar Gerard Gascón
Browse files

feat: most sequential characters working

parent 77ee7a84
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -12,6 +12,13 @@ namespace Domain {

			_readers.Add(typeof(CedillaReader), new CedillaReader());
			_readers.Add(typeof(GeminadaReader), new GeminadaReader(_history));
			_readers.Add(typeof(TxReader), new TxReader(_history));
			_readers.Add(typeof(IxReader), new IxReader(_history));
			_readers.Add(typeof(NyReader), new NyReader(_history));
			_readers.Add(typeof(TgReader), new TgReader(_history));
			_readers.Add(typeof(TjReader), new TjReader(_history));
			_readers.Add(typeof(LlReader), new LlReader(_history));
			_readers.Add(typeof(SsReader), new SsReader(_history));
		}

		public void UpdateInput() {
+2 −53
Original line number Diff line number Diff line
@@ -2,58 +2,7 @@
using System.Linq;

namespace Domain.Input {
	public class GeminadaReader : InputReader {
		protected sealed override int Key { get; } = 0x33;
		private int LKey { get; } = 76;

		private bool _lPressed;
		private bool _lWasPressed;
		private bool _dotPressed;
		private bool _dotWasPressed;

		private readonly KeyHistory _history;
		private readonly List<int> _desiredSequence;

		public GeminadaReader(KeyHistory history) {
			_history = history;
			_desiredSequence = new List<int> { LKey, Key, LKey };
		}

		public override void UpdateInput() {
			if (UpdateDotInputDown()) {
				_history.KeyPressed(Key);
			}

			WasPressed = IsPressed;
			IsPressed = _history.ContainsSequence(_desiredSequence);
		}

		private bool UpdateDotInputDown() {
			_dotWasPressed = _dotPressed;
			short dotState = Win32API.GetAsyncKeyState(Key);

			if (!_dotWasPressed && dotState != 0) {
				_dotPressed = true;
				return true;
			}
			if (_dotPressed && dotState == 0) {
				_dotPressed = false;
			}
			return false;
		}

		private bool UpdateLInputDown() {
			_lWasPressed = _lPressed;
			short lState = Win32API.GetAsyncKeyState(LKey);

			if (!_lWasPressed && lState != 0) {
				_lPressed = true;
				return true;
			}
			if (_lPressed && lState == 0) {
				_lPressed = false;
			}
			return false;
		}
	public class GeminadaReader : SequentialInputReader {
		public GeminadaReader(KeyHistory history) : base(history, new List<int>{ 76, 0x33, 76 }) { }
	}
}
 No newline at end of file
+8 −0
Original line number Diff line number Diff line
using System.Collections.Generic;
using System.Linq;

namespace Domain.Input {
	public class IxReader : SequentialInputReader {
		public IxReader(KeyHistory history) : base(history, new List<int>{ 0x49, 0x58 }) { }
	}
}
 No newline at end of file
+3 −0
Original line number Diff line number Diff line
fileFormatVersion: 2
guid: 96e8ae30bc1b46a8bb80786992cffa75
timeCreated: 1713130888
 No newline at end of file
+8 −0
Original line number Diff line number Diff line
using System.Collections.Generic;
using System.Linq;

namespace Domain.Input {
	public class LlReader : SequentialInputReader {
		public LlReader(KeyHistory history) : base(history, new List<int>{ 0x4C, 0x4C }) { }
	}
}
 No newline at end of file
Loading