emulation: keyboard: support "Wake Up" sequence

The hardcoded sequence "F1+F4" will wake a device that is suspended.

Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
Sean Cross 2022-04-21 10:16:36 +08:00
parent b5a858938a
commit d7c2033273

View file

@ -63,7 +63,8 @@ namespace Antmicro.Renode.Peripherals.Input
}, },
writeCallback: (_, value) => writeCallback: (_, value) =>
{ {
if (value != 0) { if (value != 0)
{
injectedKeys.Enqueue((char)value); injectedKeys.Enqueue((char)value);
UpdateInterrupts(); UpdateInterrupts();
} }
@ -230,6 +231,18 @@ namespace Antmicro.Renode.Peripherals.Input
this.irqKeyPressedStatus = true; this.irqKeyPressedStatus = true;
this.UpdateInterrupts(); this.UpdateInterrupts();
this.irqKeyPressedStatus = false; this.irqKeyPressedStatus = false;
// Wake the machine if it's suspended.
if (PressedKeys.ContainsKey(KeyScanCode.F1)
&& PressedKeys.ContainsKey(KeyScanCode.F4)
&& (scanCode == KeyScanCode.F1 || scanCode == KeyScanCode.F4)
&& isPress
&& machine.IsPaused
)
{
this.Log(LogLevel.Debug, "Resuming machine");
machine.Start();
}
return; return;
} }
@ -256,6 +269,7 @@ namespace Antmicro.Renode.Peripherals.Input
irqKeyPressedPending.Value = false; irqKeyPressedPending.Value = false;
irqInjectEnabled.Value = false; irqInjectEnabled.Value = false;
irqInjectPending.Value = false; irqInjectPending.Value = false;
RegistersCollection.Reset();
} }
private Dictionary<KeyScanCode, bool> PressedKeys = new Dictionary<KeyScanCode, bool> { }; private Dictionary<KeyScanCode, bool> PressedKeys = new Dictionary<KeyScanCode, bool> { };