From d7c2033273f59ccb86c87e4776407786377260be Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Thu, 21 Apr 2022 10:16:36 +0800 Subject: [PATCH] emulation: keyboard: support "Wake Up" sequence The hardcoded sequence "F1+F4" will wake a device that is suspended. Signed-off-by: Sean Cross --- emulation/peripherals/keyboard.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/emulation/peripherals/keyboard.cs b/emulation/peripherals/keyboard.cs index 8478542ef..89db99bed 100644 --- a/emulation/peripherals/keyboard.cs +++ b/emulation/peripherals/keyboard.cs @@ -63,7 +63,8 @@ namespace Antmicro.Renode.Peripherals.Input }, writeCallback: (_, value) => { - if (value != 0) { + if (value != 0) + { injectedKeys.Enqueue((char)value); UpdateInterrupts(); } @@ -230,6 +231,18 @@ namespace Antmicro.Renode.Peripherals.Input this.irqKeyPressedStatus = true; this.UpdateInterrupts(); 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; } @@ -256,6 +269,7 @@ namespace Antmicro.Renode.Peripherals.Input irqKeyPressedPending.Value = false; irqInjectEnabled.Value = false; irqInjectPending.Value = false; + RegistersCollection.Reset(); } private Dictionary PressedKeys = new Dictionary { };