Recoding inputService

Too much debugging was needed and was rapidly becoming spaghetti-code,
re-coding it in a much nicer and easier way to read and hopefully need
less debugging.