diff --git a/Machines/PCCompatible/PCCompatible.cpp b/Machines/PCCompatible/PCCompatible.cpp index c0ce68025..3bed28766 100644 --- a/Machines/PCCompatible/PCCompatible.cpp +++ b/Machines/PCCompatible/PCCompatible.cpp @@ -362,19 +362,26 @@ class KeyboardController { //; 00 - force clock line low, resetting keyboard, but on a 01->00 transition, //; IRQ1 would remain high void set_mode(uint8_t mode) { + printf("Mode: %02x\n", mode); + const auto last_mode = mode_; mode_ = Mode(mode); switch(mode_) { case Mode::NormalOperation: break; case Mode::NoIRQsIgnoreInput: pic_.apply_edge<1>(false); break; + case Mode::Reset: + input_.clear(); + [[fallthrough]]; case Mode::ClearIRQReset: pic_.apply_edge<1>(false); - [[fallthrough]]; - case Mode::Reset: - reset_delay_ = 15; // Arbitrarily. break; } + + // If the reset condition ends, start a counter through until reset is complete. + if(last_mode == Mode::Reset && mode_ != Mode::Reset) { + reset_delay_ = 15; // Arbitrarily. + } } void run_for(Cycles cycles) { @@ -403,7 +410,7 @@ class KeyboardController { } void post(uint8_t value) { - if(mode_ == Mode::NoIRQsIgnoreInput) { + if(mode_ != Mode::NormalOperation || reset_delay_) { return; } input_.push_back(value);