From daf052754b3cf2433f4ed134d81a0400ace31c33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Pedro?= Date: Tue, 12 Sep 2017 23:48:54 +0100 Subject: [PATCH 1/2] Fixed setup. --- Setup/Cosmos.iss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Setup/Cosmos.iss b/Setup/Cosmos.iss index 6e9c885ac..919002af8 100644 --- a/Setup/Cosmos.iss +++ b/Setup/Cosmos.iss @@ -83,7 +83,7 @@ Source: ".\Build\VSIP\NASM\*"; DestDir: "{app}\Build\NASM"; Flags: ignoreversion Source: ".\Build\VSIP\Cosmos.Deploy.USB.exe"; DestDir: "{app}\Build\Tools"; Flags: ignoreversion uninsremovereadonly Source: ".\Build\VSIP\Cosmos.Deploy.Pixie.exe"; DestDir: "{app}\Build\Tools"; Flags: ignoreversion uninsremovereadonly Source: ".\Build\VSIP\Cosmos.Build.Common.dll"; DestDir: "{app}\Build\Tools"; Flags: ignoreversion uninsremovereadonly -Source: ".\Build\VSIP\MSBuild\*"; DestDir: "{app}\Build\VSIP\"; Flags: ignoreversion uninsremovereadonly +Source: ".\Build\VSIP\MSBuild\*"; DestDir: "{app}\Build\VSIP\"; Flags: ignoreversion recursesubdirs uninsremovereadonly Source: ".\Build\VSIP\Cosmos.Debug.GDB.exe"; DestDir: "{app}\Build\VSIP\"; Flags: ignoreversion uninsremovereadonly ; Kernel assemblies Source: ".\Build\VSIP\Cosmos.Debug.Kernel*"; DestDir: "{app}\Kernel"; Flags: ignoreversion uninsremovereadonly From 3e5aff94630d27c4968b56191e7f4c372c853313 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Pedro?= Date: Fri, 15 Sep 2017 00:23:47 +0100 Subject: [PATCH 2/2] Implemented Console.KeyAvailable. --- .../Keyboard/KeyboardManager.cs | 11 +++++++- .../System/ConsoleImpl.cs | 26 +++++++++++++++++-- .../System/ConsolePalImpl.cs | 24 ----------------- 3 files changed, 34 insertions(+), 27 deletions(-) delete mode 100644 source/Cosmos.System2_Plugs/System/ConsolePalImpl.cs diff --git a/source/Cosmos.System2/Keyboard/KeyboardManager.cs b/source/Cosmos.System2/Keyboard/KeyboardManager.cs index ee04eee07..6bf3fa843 100644 --- a/source/Cosmos.System2/Keyboard/KeyboardManager.cs +++ b/source/Cosmos.System2/Keyboard/KeyboardManager.cs @@ -48,8 +48,17 @@ namespace Cosmos.System get; set; } + + + public static bool KeyAvailable + { + get + { + return mQueuedKeys.Count > 0; + } + } - public static List Keyboards = new List(); +public static List Keyboards = new List(); private static ScanMapBase _scanMap = new US_Standard(); private static Queue mQueuedKeys = new Queue(); diff --git a/source/Cosmos.System2_Plugs/System/ConsoleImpl.cs b/source/Cosmos.System2_Plugs/System/ConsoleImpl.cs index 2b2d9ee36..8ee1c2b47 100644 --- a/source/Cosmos.System2_Plugs/System/ConsoleImpl.cs +++ b/source/Cosmos.System2_Plugs/System/ConsoleImpl.cs @@ -199,8 +199,7 @@ namespace Cosmos.System_Plugs.System public static bool get_KeyAvailable() { - WriteLine("Not implemented: get_KeyAvailable"); - return false; + return KeyboardManager.KeyAvailable; } public static int get_LargestWindowHeight() @@ -394,6 +393,29 @@ namespace Cosmos.System_Plugs.System } } + // ReadKey() pure CIL + + public static ConsoleKeyInfo ReadKey(bool intercept) + { + var key = KeyboardManager.ReadKey(); + if (intercept == false && key.KeyChar != '\0') + { + Write(key.KeyChar); + } + + //TODO: Plug HasFlag and use the next 3 lines instead of the 3 following lines + + //bool xShift = key.Modifiers.HasFlag(ConsoleModifiers.Shift); + //bool xAlt = key.Modifiers.HasFlag(ConsoleModifiers.Alt); + //bool xControl = key.Modifiers.HasFlag(ConsoleModifiers.Control); + + bool xShift = (key.Modifiers & ConsoleModifiers.Shift) == ConsoleModifiers.Shift; + bool xAlt = (key.Modifiers & ConsoleModifiers.Alt) == ConsoleModifiers.Alt; + bool xControl = (key.Modifiers & ConsoleModifiers.Control) == ConsoleModifiers.Control; + + return new ConsoleKeyInfo(key.KeyChar, key.Key.ToConsoleKey(), xShift, xAlt, xControl); + } + public static String ReadLine() { var xConsole = GetConsole(); diff --git a/source/Cosmos.System2_Plugs/System/ConsolePalImpl.cs b/source/Cosmos.System2_Plugs/System/ConsolePalImpl.cs deleted file mode 100644 index 0acb66af0..000000000 --- a/source/Cosmos.System2_Plugs/System/ConsolePalImpl.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using Cosmos.System; -using Cosmos.IL2CPU.API; -using Cosmos.IL2CPU.API.Attribs; - -namespace Cosmos.System_Plugs.System -{ - [Plug(TargetName = "System.ConsolePal, System.Console")] - public class ConsolePalImpl - { - // ReadKey() pure CIL - - public static ConsoleKeyInfo ReadKey(bool intercept) - { - var key = KeyboardManager.ReadKey(); - if (intercept == false && key.KeyChar != '\0') - { - global::System.Console.Write(key.KeyChar); - } - - return new ConsoleKeyInfo(key.KeyChar, key.Key.ToConsoleKey(), (key.Modifiers & ConsoleModifiers.Shift) != 0, (key.Modifiers & ConsoleModifiers.Alt) != 0, (key.Modifiers & ConsoleModifiers.Control) != 0); - } - } -}