ps2d: disable keyboard before running self test

Beforehand, if you spammed 'enter' (or any key) upon startup, your self
test would fail with 1C or 9C (the scancodes for pressing and releasing
enter respectively). We now disable the keyboard earlier, and this fixes
the issue.
This commit is contained in:
Connor-GH
2026-03-10 14:19:11 -05:00
parent 6393a33380
commit 15790b1e1a
+13 -11
View File
@@ -291,17 +291,6 @@ impl Ps2 {
}
}
self.retry(format_args!("keyboard defaults"), 4, |x| {
// Set defaults and disable scanning
let b = x.keyboard_command(KeyboardCommand::SetDefaultsDisable)?;
if b != 0xFA {
error!("keyboard failed to set defaults: {:02X}", b);
return Err(Error::CommandRetry);
}
Ok(b)
})?;
{
// Set scancode set to 2
let scancode_set = 2;
@@ -334,6 +323,19 @@ impl Ps2 {
self.set_config(config)?;
}
// The keyboard seems to still collect bytes even when we disable
// the port, so we must disable the keyboard too
self.retry(format_args!("keyboard defaults"), 4, |x| {
// Set defaults and disable scanning
let b = x.keyboard_command(KeyboardCommand::SetDefaultsDisable)?;
if b != 0xFA {
error!("keyboard failed to set defaults: {:02X}", b);
return Err(Error::CommandRetry);
}
Ok(b)
})?;
{
// Perform the self test
self.command(Command::TestController)?;