1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-11 04:28:58 +00:00

Corrects phase counting for machines that pause after clear. Which is all of them by default.

This commit is contained in:
Thomas Harte 2020-02-29 18:51:55 -05:00
parent 54b3e511e9
commit 346d80e30b

View File

@ -81,27 +81,28 @@ uint16_t Typer::try_type_next_character() {
return 0; return 0;
} }
// Advance phase.
++phase_;
// If this is the start of the output sequence, start with a reset all keys. // If this is the start of the output sequence, start with a reset all keys.
// Then pause unless the caracter mapper says not to. // Then pause unless the caracter mapper says not to.
if(!phase_) { if(phase_ == 1) {
delegate_->clear_all_keys(); delegate_->clear_all_keys();
if(character_mapper_->needs_pause_after_reset_all_keys()) { if(character_mapper_->needs_pause_after_reset_all_keys()) {
return 0xffff; // Arbitrarily. Anything non-zero will do. return 0xffff; // Arbitrarily. Anything non-zero will do.
} }
++phase_;
} }
// Advance phase.
++phase_;
// If the sequence is over, stop. // If the sequence is over, stop.
if(sequence[phase_ - 1] == KeyboardMachine::MappedMachine::KeyEndSequence) { if(sequence[phase_ - 2] == KeyboardMachine::MappedMachine::KeyEndSequence) {
return 0; return 0;
} }
// Otherwise, type the key. // Otherwise, type the key.
delegate_->set_key_state(sequence[phase_ - 1], true); delegate_->set_key_state(sequence[phase_ - 2], true);
return sequence[phase_ - 1]; return sequence[phase_ - 2];
} }
bool Typer::type_next_character() { bool Typer::type_next_character() {