using System.Collections.Generic;
using System.Linq;
using Domain.Input;

namespace Domain {
	public class CustomInput {
		private readonly List<InputReader> _readers = new();
		private readonly KeyHistory _history;

		public CustomInput() {
			_history = new KeyHistory();

			_readers.Add(new CedillaReader(_history));
			_readers.Add(new GeminadaReader(_history));
			_readers.Add(new TxReader(_history));
			_readers.Add(new IxReader(_history));
			_readers.Add(new NyReader(_history));
			_readers.Add(new TgReader(_history));
			_readers.Add(new TjReader(_history));
			_readers.Add(new LlReader(_history));
			_readers.Add(new SsReader(_history));
			_readers.Add(new AObertaReader(_history));
			_readers.Add(new EObertaReader(_history));
			_readers.Add(new OObertaReader(_history));
			_readers.Add(new IDieresiReader(_history));
		}

		public void UpdateInput() {
			_history.CheckPresses();
			foreach (InputReader reader in _readers)
				reader.UpdateInput();
		}

		public bool AnyKeyDown() => _readers.Any(reader => reader.KeyDown());
	}
}