diff --git a/source/Cosmos.HAL/ConsoleKeyEx.cs b/source/Cosmos.HAL/ConsoleKeyEx.cs
new file mode 100644
index 000000000..3642e303a
--- /dev/null
+++ b/source/Cosmos.HAL/ConsoleKeyEx.cs
@@ -0,0 +1,133 @@
+namespace Cosmos.HAL
+{
+ public enum ConsoleKeyEx
+ {
+ NoName,
+
+ Escape,
+
+ F1,
+ F2,
+ F3,
+ F4,
+ F5,
+ F6,
+ F7,
+ F8,
+ F9,
+ F10,
+ F11,
+ F12,
+
+ PrintScreen,
+ ScrollLock,
+ PauseBreak,
+
+ Backquote,
+ D1,
+ D2,
+ D3,
+ D4,
+ D5,
+ D6,
+ D7,
+ D8,
+ D9,
+ D0,
+ Minus,
+ Equal,
+ Backslash,
+ Backspace,
+
+ Tab,
+ Q,
+ W,
+ E,
+ R,
+ T,
+ Y,
+ U,
+ I,
+ O,
+ P,
+ LBracket,
+ RBracket,
+ Enter,
+
+ CapsLock,
+ A,
+ S,
+ D,
+ F,
+ G,
+ H,
+ J,
+ K,
+ L,
+ Semicolon,
+ Colon,
+ Apostrophe,
+
+ LowerThan,
+ BiggerThan,
+
+ ExclamationPoint,
+
+ LShift,
+ RShift,
+ Z,
+ X,
+ C,
+ V,
+ B,
+ N,
+ M,
+ Comma,
+ Period,
+ Slash,
+
+ LCtrl,
+ RCtrl,
+ LWin,
+ LAlt,
+ RAlt,
+ Spacebar,
+ AltGr,
+ RWin,
+ Menu,
+
+ Insert,
+ Home,
+ PageUp,
+ Delete,
+ End,
+ PageDown,
+
+ UpArrow,
+ DownArrow,
+ LeftArrow,
+ RightArrow,
+
+ NumLock,
+ NumDivide,
+ NumMultiply,
+ NumMinus,
+ Num7,
+ Num8,
+ Num9,
+ NumPlus,
+ Num4,
+ Num5,
+ Num6,
+ Num1,
+ Num2,
+ Num3,
+ Num0,
+ NumPeriod,
+ NumEnter,
+
+ Power,
+ Sleep,
+ Wake
+ }
+}
\ No newline at end of file
diff --git a/source/Cosmos.HAL/Cosmos.HAL.csproj b/source/Cosmos.HAL/Cosmos.HAL.csproj
index 999080e88..e3cb35736 100644
--- a/source/Cosmos.HAL/Cosmos.HAL.csproj
+++ b/source/Cosmos.HAL/Cosmos.HAL.csproj
@@ -79,8 +79,11 @@
+
-
+
+
+
@@ -122,6 +125,9 @@
+
+
+
diff --git a/source/Cosmos.HAL/DefaultKeyboard.cs b/source/Cosmos.HAL/DefaultKeyboard.cs
deleted file mode 100644
index 53b571adb..000000000
--- a/source/Cosmos.HAL/DefaultKeyboard.cs
+++ /dev/null
@@ -1,460 +0,0 @@
-using System;
-using System.Collections.Generic;
-using Cosmos.Common.Extensions;
-using Cosmos.Core;
-
-namespace Cosmos.HAL
-{
- //public delegate void HandleKeyboardDelegate(byte aScanCode, bool aReleased);
-
- public class DefaultKeyboard : Keyboard
- {
-
- protected override void Initialize()
- {
- if (mKeys == null)
- {
- CreateDefaultKeymap();
- }
- }
-
- private List mKeys;
-
-
-
- private void updateLed()
- {
- IO.Port60.Byte = 0xED;
- while ((new IOPort(0x64).Byte & 2) != 0)
- {
- }
- var led_status = (ScrollLock ? 1 : 0) | ((NumLock ? 1 : 0) << 1) | ((CapsLock ? 1 : 0) << 2);
- IO.Port60.Byte = (byte)led_status;
- while ((new IOPort(0x64).Byte & 2) != 0)
- {
- }
- }
-
- protected override void HandleScancode(byte aScancode, bool aReleased)
- {
- uint key = aScancode;
- if (key == 0x3A && !aReleased)
- {
- // caps lock
- CapsLock = !CapsLock;
- updateLed();
- }
- else if (key == 0x45 && !aReleased)
- {
- // num lock
- NumLock = !NumLock;
- updateLed();
- }
- else if (key == 0x46 && !aReleased)
- {
- // scroll lock
- ScrollLock = !ScrollLock;
- updateLed();
- }
- else
- switch (key)
- {
- case 0x1D:
- {
- ControlPressed = !aReleased;
- break;
- }
- case 0x2A:
- case 0x36:
- {
- ShiftPressed = !aReleased;
- break;
- }
- case 0x38:
- {
- AltPressed = !aReleased;
- break;
- }
- default:
- {
- if (ControlPressed && AltPressed && (key == 0x53))
- {
- Console.WriteLine("Detected Ctrl-Alt-Delete! Rebooting System...");
- Core.Global.CPU.Reboot();
- }
-
- if (!aReleased)
- {
- ConsoleKeyInfoEx keyInfo;
- if (GetKey(key, out keyInfo))
- {
- Enqueue(keyInfo);
- }
- }
-
-
- break;
- }
- }
- }
-
- private void CreateDefaultKeymap()
- {
- mKeys = new List();
-
- /* Scan Norm Shift Ctrl Alt Num Caps ShCaps ShNum ConsoleKey */
- AddKey(0x00, ConsoleKey.NoName);
- AddKey(0x01, ConsoleKey.Escape);
- /* 1 -> 9 */
- AddKey(0x02, '1', '!', '\0', '\0', '1', '1', '!', '1', ConsoleKey.D1);
- AddKey(0x03, '2', '@', '\0', '\0', '2', '2', '@', '2', ConsoleKey.D2);
- AddKey(0x04, '3', '#', '\0', '\0', '3', '3', '#', '3', ConsoleKey.D3);
- AddKey(0x05, '4', '$', '\0', '\0', '4', '4', '$', '4', ConsoleKey.D4);
- AddKey(0x06, '5', '%', '\0', '\0', '5', '5', '%', '5', ConsoleKey.D5);
- AddKey(0x07, '6', '^', '\0', '\0', '6', '6', '^', '6', ConsoleKey.D6);
- AddKey(0x08, '7', '&', '\0', '\0', '7', '7', '&', '7', ConsoleKey.D7);
- AddKey(0x09, '8', '*', '\0', '\0', '8', '8', '*', '8', ConsoleKey.D8);
- AddKey(0x0A, '9', '(', '\0', '\0', '9', '9', '(', '9', ConsoleKey.D9);
- AddKey(0x0B, '0', ')', '\0', '\0', '0', '0', ')', '0', ConsoleKey.D0);
- /* -, =, Bksp, Tab */
- AddKey(0x0C, '-', '_', '\0', '\0', '-', '-', '_', '-', ConsoleKey.OemMinus);
- AddKey(0x0D, '=', '+', '\0', '\0', '=', '=', '+', '=', ConsoleKey.NoName);
- AddKey(0x0E, ConsoleKey.Backspace);
- AddKey(0x0F, '\t', ConsoleKey.Tab);
- /* QWERTYUIOP[] */
- AddKey(0x10, 'q', 'Q', '\0', '\0', 'q', 'Q', 'q', 'Q', ConsoleKey.Q);
- AddKey(0x11, 'w', 'W', '\0', '\0', 'w', 'W', 'w', 'W', ConsoleKey.W);
- AddKey(0x12, 'e', 'E', '\0', '\0', 'e', 'E', 'e', 'E', ConsoleKey.E);
- AddKey(0x13, 'r', 'R', '\0', '\0', 'r', 'R', 'r', 'R', ConsoleKey.R);
- AddKey(0x14, 't', 'T', '\0', '\0', 't', 'T', 't', 'T', ConsoleKey.T);
- AddKey(0x15, 'y', 'Y', '\0', '\0', 'y', 'Y', 'y', 'Y', ConsoleKey.Y);
- AddKey(0x16, 'u', 'U', '\0', '\0', 'u', 'U', 'u', 'U', ConsoleKey.U);
- AddKey(0x17, 'i', 'I', '\0', '\0', 'i', 'I', 'i', 'I', ConsoleKey.I);
- AddKey(0x18, 'o', 'O', '\0', '\0', 'o', 'O', 'o', 'O', ConsoleKey.O);
- AddKey(0x19, 'p', 'P', '\0', '\0', 'p', 'P', 'p', 'P', ConsoleKey.P);
- AddKey(0x1A, '[', '{', '\0', '\0', '[', '{', '[', '{', ConsoleKey.NoName);
- AddKey(0x1B, ']', '}', '\0', '\0', ']', '}', ']', '}', ConsoleKey.NoName);
- /* ENTER, CTRL */
- AddKey(0x1C, '\n', ConsoleKey.Enter);
- AddKey(0x1D, 0, 0, 0, 0, 0, 0, 0, 0, ConsoleKey.NoName);
- /* ASDFGHJKL;'` */
- AddKey(0x1E, 'a', 'A', '\0', '\0', 'a', 'A', 'a', 'A', ConsoleKey.A);
- AddKey(0x1F, 's', 'S', '\0', '\0', 's', 'S', 's', 'S', ConsoleKey.S);
- AddKey(0x20, 'd', 'D', '\0', '\0', 'd', 'D', 'd', 'D', ConsoleKey.D);
- AddKey(0x21, 'f', 'F', '\0', '\0', 'f', 'F', 'f', 'F', ConsoleKey.F);
- AddKey(0x22, 'g', 'G', '\0', '\0', 'g', 'G', 'g', 'G', ConsoleKey.G);
- AddKey(0x23, 'h', 'H', '\0', '\0', 'h', 'H', 'h', 'H', ConsoleKey.H);
- AddKey(0x24, 'j', 'J', '\0', '\0', 'j', 'J', 'j', 'J', ConsoleKey.J);
- AddKey(0x25, 'k', 'K', '\0', '\0', 'k', 'K', 'k', 'K', ConsoleKey.K);
- AddKey(0x26, 'l', 'L', '\0', '\0', 'l', 'L', 'l', 'L', ConsoleKey.L);
- AddKey(0x27, ';', ':', '\0', '\0', ';', ';', ':', ':', ConsoleKey.NoName);
- AddKey(0x28, '\'', '"', '\0', '\0', '\'', '\'', '"', '"', ConsoleKey.NoName);
- AddKey(0x29, '`', '~', '\0', '\0', '`', '`', '~', '~', ConsoleKey.NoName);
- /* Left Shift*/
- AddKey(0x2A, ConsoleKey.NoName);
- /* \ZXCVBNM,./ */
- AddKey(0x2B, '\\', '|', '\0', '\0', '\\', '\\', '|', '|', ConsoleKey.NoName);
- AddKey(0x2C, 'z', 'Z', '\0', '\0', 'z', 'Z', 'z', 'Z', ConsoleKey.Z);
- AddKey(0x2D, 'x', 'X', '\0', '\0', 'x', 'X', 'x', 'X', ConsoleKey.X);
- AddKey(0x2E, 'c', 'C', '\0', '\0', 'c', 'C', 'c', 'C', ConsoleKey.C);
- AddKey(0x2F, 'v', 'V', '\0', '\0', 'v', 'V', 'v', 'V', ConsoleKey.V);
- AddKey(0x30, 'b', 'B', '\0', '\0', 'b', 'B', 'b', 'B', ConsoleKey.B);
- AddKey(0x31, 'n', 'N', '\0', '\0', 'n', 'N', 'n', 'N', ConsoleKey.N);
- AddKey(0x32, 'm', 'M', '\0', '\0', 'm', 'M', 'm', 'M', ConsoleKey.M);
- AddKey(0x33, ',', '<', '\0', '\0', ',', ',', '<', '<', ConsoleKey.OemComma);
- AddKey(0x34, '.', '>', '\0', '\0', '.', '.', '>', '>', ConsoleKey.OemPeriod);
- AddKey(0x35, '/', '?', '\0', '\0', '/', '/', '?', '/', ConsoleKey.Divide); // also numpad divide
- /* Right Shift */
- AddKey(0x36, ConsoleKey.NoName);
- /* Print Screen */
- AddKey(0x37, '*', '*', '\0', '\0', '*', '*', '*', '*', ConsoleKey.PrintScreen); // also numpad multiply
- /* Alt */
- AddKey(0x38, ConsoleKey.NoName);
- /* Space */
- AddKey(0x39, ' ', ConsoleKey.Spacebar);
- /* Caps */
- AddKey(0x3A, ConsoleKey.NoName);
- /* F1-F12 */
- AddKey(0x3B, ConsoleKey.F1);
- AddKey(0x3C, ConsoleKey.F2);
- AddKey(0x3D, ConsoleKey.F3);
- AddKey(0x3E, ConsoleKey.F4);
- AddKey(0x3F, ConsoleKey.F5);
- AddKey(0x40, ConsoleKey.F6);
- AddKey(0x41, ConsoleKey.F7);
- AddKey(0x42, ConsoleKey.F8);
- AddKey(0x43, ConsoleKey.F9);
- AddKey(0x44, ConsoleKey.F10);
- AddKey(0x57, ConsoleKey.F11);
- AddKey(0x58, ConsoleKey.F12);
- /* Num Lock, Scrl Lock */
- AddKey(0x45, ConsoleKey.NoName);
- AddKey(0x46, ConsoleKey.NoName);
- /* HOME, Up, Pgup, -kpad, left, center, right, +keypad, end, down, pgdn, ins, del */
- AddKey(0x47, '\0', '\0', '\0', '\0', '7', '\0', '\0', '\0', ConsoleKey.Home, ConsoleKey.NumPad7);
- AddKey(0x48, '\0', '\0', '\0', '\0', '8', '\0', '\0', '\0', ConsoleKey.UpArrow, ConsoleKey.NumPad8);
- AddKey(0x49, '\0', '\0', '\0', '\0', '9', '\0', '\0', '\0', ConsoleKey.PageUp, ConsoleKey.NumPad9);
- AddKey(0x4A, '-', '-', 0, 0, '-', '-', '-', '-', ConsoleKey.OemMinus);
- AddKey(0x4B, '\0', '\0', '\0', '\0', '4', '\0', '\0', '\0', ConsoleKey.LeftArrow, ConsoleKey.NumPad4);
- AddKey(0x4C, '\0', '\0', '\0', '\0', '5', '\0', '\0', '\0', ConsoleKey.NumPad5);
- AddKey(0x4D, '\0', '\0', '\0', '\0', '6', '\0', '\0', '\0', ConsoleKey.RightArrow, ConsoleKey.NumPad6);
- AddKey(0x4E, '+', '+', 0, 0, '+', '+', '+', '+', ConsoleKey.OemPlus);
- AddKey(0x4F, '\0', '\0', '\0', '\0', '1', '\0', '\0', '\0', ConsoleKey.End, ConsoleKey.NumPad1);
- AddKey(0x50, '\0', '\0', '\0', '\0', '2', '\0', '\0', '\0', ConsoleKey.DownArrow, ConsoleKey.NumPad2);
- AddKey(0x51, '\0', '\0', '\0', '\0', '3', '\0', '\0', '\0', ConsoleKey.PageDown, ConsoleKey.NumPad3);
- AddKey(0x52, '\0', '\0', '\0', '\0', '0', '\0', '\0', '\0', ConsoleKey.Insert, ConsoleKey.NumPad0);
- AddKey(0x53, '\0', '\0', '\0', '\0', '.', '\0', '\0', '\0', ConsoleKey.Delete, ConsoleKey.OemPeriod);
-
-
-
- AddKey(0x5b, ConsoleKey.LeftWindows);
- AddKey(0x5c, ConsoleKey.RightWindows);
-
- }
-
-
- private void AddKey(uint aScanCode, char norm, char shift, char ctrl, char alt, char num, char caps, char shiftcaps, char shiftnum, ConsoleKey aKey)
- {
- mKeys.Add(new KeyMapping(aScanCode, norm, shift, ctrl, alt, num, caps, shiftcaps, shiftnum, aKey));
- }
- private void AddKey(uint aScanCode, char norm, char shift, char ctrl, char alt, char num, char caps, char shiftcaps, char shiftnum, ConsoleKey aKey, ConsoleKey numKey)
- {
- mKeys.Add(new KeyMapping(aScanCode, norm, shift, ctrl, alt, num, caps, shiftcaps, shiftnum, aKey, numKey));
- }
- private void AddKey(uint aScanCode, int norm, int shift, int ctrl, int alt, int num, int caps, int shiftcaps, int shiftnum, ConsoleKey aKey)
- {
- mKeys.Add(new KeyMapping(aScanCode, norm, shift, ctrl, alt, num, caps, shiftcaps, shiftnum, aKey));
- }
- private void AddKey(uint aScanCode, char norm, ConsoleKey aKey)
- {
- mKeys.Add(new KeyMapping(aScanCode, norm, aKey));
- }
- private void AddKey(uint aScanCode, ConsoleKey aKey)
- {
- mKeys.Add(new KeyMapping(aScanCode, aKey));
- }
- public void ChangeKeyMap(List aKeys)
- {
- mKeys = aKeys;
- }
-
- public bool GetCharValue(uint aScanCode, out char aValue)
- {
- for (var index = 0; index < mKeys.Count; index++)
- {
- KeyMapping t = mKeys[index];
- if (t.Scancode == aScanCode)
- {
- var map = t;
- var key = '\0';
-
- if (ShiftPressed && CapsLock)
- {
- key = map.ShiftCaps;
- }
- else if (ShiftPressed)
- {
- key = map.Shift;
- }
- else if (ControlPressed)
- {
- key = map.Ctrl;
- }
- else if (AltPressed)
- {
- key = map.Alt;
- }
- else if (ShiftPressed && NumLock)
- {
- key = map.ShiftNum;
- }
- else if (CapsLock)
- {
- key = map.Caps;
- }
- else if (NumLock)
- {
- key = map.Num;
- }
- else
- {
- key = map.Value;
- }
-
- aValue = key;
- return true;
- }
- }
-
- aValue = '\0';
- return false;
- }
-
- public bool GetKeyValue(uint aScanCode, out ConsoleKey aValue)
- {
- for (var index = 0; index < mKeys.Count; index++)
- {
- var t = mKeys[index];
- if (t.Scancode == aScanCode)
- {
- if (NumLock)
- {
- if (ShiftPressed && aScanCode >= 0x47 && aScanCode != 0x4A && aScanCode != 0x4E && aScanCode <= 0x52)
- {
- aValue = t.Key; // ex: Shift+NumPad4=LeftArrow (extended keyset not supported yet)
- }
- else
- {
- aValue = t.NumLockKey;
- }
- }
- else
- {
- aValue = t.Key;
- }
- //aValue = NumLock ? t.NumLockKey : t.Key;
- return true;
- }
- }
-
- aValue = ConsoleKey.NoName;
- return false;
- }
-
- public bool GetKeyMapping(uint aScanCode, out KeyMapping aValue)
- {
- for (var index = 0; index < mKeys.Count; index++)
- {
- var t = mKeys[index];
- if (t.Scancode == aScanCode)
- {
- aValue = t;
- return true;
- }
- }
-
- aValue = null;
- return false;
- }
-
-
- public bool GetKey(uint aScancode, out ConsoleKeyInfoEx keyInfo)
- {
- ConsoleKey xKey;
-
- if (!GetKeyValue(aScancode, out xKey))
- {
- keyInfo = null;
- return false;
- }
-
- char xChar;
- if (!GetCharValue(aScancode, out xChar))
- {
- keyInfo = null;
- return false;
- }
- keyInfo = new ConsoleKeyInfoEx(xChar, xKey, ShiftPressed, AltPressed, ControlPressed);
- return true;
- }
- public class KeyMapping
- {
- public uint Scancode;
- public char Value;
- public char Shift;
- public char Ctrl;
- public char Alt;
- public char Num;
- public char Caps;
- public char ShiftCaps;
- public char ShiftNum;
- public ConsoleKey Key;
- public ConsoleKey NumLockKey;
-
- public KeyMapping(uint aScanCode, char norm, char shift, char ctrl, char alt, char num, char caps, char shiftcaps, char shiftnum, ConsoleKey aKey)
- {
- Scancode = aScanCode;
- Value = norm;
- Shift = shift;
- Ctrl = ctrl;
- Alt = alt;
- Num = num;
- Caps = caps;
- ShiftCaps = shiftcaps;
- ShiftNum = shiftnum;
- Key = aKey;
- NumLockKey = aKey;
- }
- public KeyMapping(uint aScanCode, char norm, char shift, char ctrl, char alt, char num, char caps, char shiftcaps, char shiftnum, ConsoleKey aKey, ConsoleKey numKey)
- {
- Scancode = aScanCode;
- Value = norm;
- Shift = shift;
- Ctrl = ctrl;
- Alt = alt;
- Num = num;
- Caps = caps;
- ShiftCaps = shiftcaps;
- ShiftNum = shiftnum;
- Key = aKey;
- NumLockKey = numKey;
- }
- public KeyMapping(uint aScanCode, int norm, int shift, int ctrl, int alt, int num, int caps, int shiftcaps, int shiftnum, ConsoleKey aKey)
- {
- Scancode = aScanCode;
- Value = (char)norm;
- Shift = (char)shift;
- Ctrl = (char)ctrl;
- Alt = (char)alt;
- Num = (char)num;
- Caps = (char)caps;
- ShiftCaps = (char)shiftcaps;
- ShiftNum = (char)shiftnum;
- Key = aKey;
- NumLockKey = aKey;
- }
- public KeyMapping(uint aScanCode, byte norm, byte shift, byte ctrl, byte alt, byte num, byte caps, byte shiftcaps, byte shiftnum, ConsoleKey aKey)
- {
- Scancode = aScanCode;
- Value = (char)norm;
- Shift = (char)shift;
- Ctrl = (char)ctrl;
- Alt = (char)alt;
- Num = (char)num;
- Caps = (char)caps;
- ShiftCaps = (char)shiftcaps;
- ShiftNum = (char)shiftnum;
- Key = aKey;
- NumLockKey = aKey;
- }
- public KeyMapping(uint aScanCode, char n, ConsoleKey aKey)
- {
- Scancode = aScanCode;
- Value = n;
- Shift = n;
- Ctrl = n;
- Alt = n;
- Num = n;
- Caps = n;
- ShiftCaps = n;
- ShiftNum = n;
- Key = aKey;
- NumLockKey = aKey;
- }
- public KeyMapping(uint aScanCode, ConsoleKey aKey)
- {
- Scancode = aScanCode;
- Value = '\0';
- Shift = '\0';
- Ctrl = '\0';
- Alt = '\0';
- Num = '\0';
- Caps = '\0';
- ShiftCaps = '\0';
- ShiftNum = '\0';
- Key = aKey;
- NumLockKey = aKey;
- }
- }
- }
-}
diff --git a/source/Cosmos.HAL/Global.cs b/source/Cosmos.HAL/Global.cs
index 8ba2857bc..687693c7e 100644
--- a/source/Cosmos.HAL/Global.cs
+++ b/source/Cosmos.HAL/Global.cs
@@ -4,137 +4,169 @@ using System.Linq;
using System.Text;
using Cosmos.HAL.BlockDevice;
-namespace Cosmos.HAL {
- static public class Global {
- static readonly public Cosmos.Debug.Kernel.Debugger Dbg = new Cosmos.Debug.Kernel.Debugger("Hardware", "");
-
- static public Keyboard Keyboard;
- //static public PIT PIT = new PIT();
- // Must be static init, other static inits rely on it not being null
- static public TextScreenBase TextScreen = new TextScreen();
-
- public static PCI Pci;
-
- private static void InitAta(BlockDevice.Ata.ControllerIdEnum aControllerID, BlockDevice.Ata.BusPositionEnum aBusPosition)
+namespace Cosmos.HAL
+{
+ public static class Global
{
- var xIO = aControllerID == BlockDevice.Ata.ControllerIdEnum.Primary ? Cosmos.Core.Global.BaseIOGroups.ATA1 : Cosmos.Core.Global.BaseIOGroups.ATA2;
- var xATA = new BlockDevice.AtaPio(xIO, aControllerID, aBusPosition);
- if (xATA.DriveType == BlockDevice.AtaPio.SpecLevel.Null)
- {
- return;
- }
- if (xATA.DriveType == BlockDevice.AtaPio.SpecLevel.ATA)
- {
- BlockDevice.BlockDevice.Devices.Add(xATA);
- }
- else
- {
- Ata.AtaDebugger.Send("ATA device with spec level " + (int)xATA.DriveType + " found, which is not supported!");
- return;
- }
- var xMbrData = new byte[512];
- xATA.ReadBlock(0UL, 1U, xMbrData);
- var xMBR = new BlockDevice.MBR(xMbrData);
+ public static readonly Cosmos.Debug.Kernel.Debugger Dbg = new Cosmos.Debug.Kernel.Debugger("Hardware", "");
- if (xMBR.EBRLocation != 0)
- {
- //EBR Detected
- var xEbrData = new byte[512];
- xATA.ReadBlock(xMBR.EBRLocation, 1U, xEbrData);
- var xEBR = new BlockDevice.EBR(xEbrData);
+ public static Keyboard Keyboard;
- for (int i = 0; i < xEBR.Partitions.Count; i++)
+ public static bool NumLock
{
- //var xPart = xEBR.Partitions[i];
- //var xPartDevice = new BlockDevice.Partition(xATA, xPart.StartSector, xPart.SectorCount);
- //BlockDevice.BlockDevice.Devices.Add(xPartDevice);
+ get { return _numLock; }
+ set { _numLock = value; Keyboard?.UpdateLeds(); }
}
- }
- // TODO Change this to foreach when foreach is supported
- Console.WriteLine("Number of MBR partitions found: " + xMBR.Partitions.Count);
- for (int i = 0; i < xMBR.Partitions.Count; i++)
- {
- var xPart = xMBR.Partitions[i];
- if (xPart == null)
+ public static bool CapsLock
{
- Console.WriteLine("Null partition found at idx " + i);
+ get { return _capsLock; }
+ set { _capsLock = value; Keyboard?.UpdateLeds(); }
}
- else
+
+ public static bool ScrollLock
{
- var xPartDevice = new BlockDevice.Partition(xATA, xPart.StartSector, xPart.SectorCount);
- BlockDevice.BlockDevice.Devices.Add(xPartDevice);
- Console.WriteLine("Found partition at idx " + i);
+ get { return _scrollLock; }
+ set
+ {
+ _scrollLock = value;
+ Keyboard?.UpdateLeds();
+ }
}
- }
- }
- // Init devices that are "static"/mostly static. These are devices
- // that all PCs are expected to have. Keyboards, screens, ATA hard drives etc.
- // Despite them being static, some discovery is required. For example, to see if
- // a hard drive is connected or not and if so what type.
- static internal void InitStaticDevices() {
- //TextScreen = new TextScreen();
- Global.Dbg.Send("CLS");
+ //static public PIT PIT = new PIT();
+ // Must be static init, other static inits rely on it not being null
+ public static TextScreenBase TextScreen = new TextScreen();
- //TextScreen.Clear();
+ public static PCI Pci;
+ private static bool _numLock;
+ private static bool _capsLock;
+ private static bool _scrollLock;
- Global.Dbg.Send("Keyboard");
- Keyboard = new DefaultKeyboard();
+ private static void InitAta(BlockDevice.Ata.ControllerIdEnum aControllerID,
+ BlockDevice.Ata.BusPositionEnum aBusPosition)
+ {
+ var xIO = aControllerID == BlockDevice.Ata.ControllerIdEnum.Primary
+ ? Cosmos.Core.Global.BaseIOGroups.ATA1
+ : Cosmos.Core.Global.BaseIOGroups.ATA2;
+ var xATA = new BlockDevice.AtaPio(xIO, aControllerID, aBusPosition);
+ if (xATA.DriveType == BlockDevice.AtaPio.SpecLevel.Null)
+ {
+ return;
+ }
+ if (xATA.DriveType == BlockDevice.AtaPio.SpecLevel.ATA)
+ {
+ BlockDevice.BlockDevice.Devices.Add(xATA);
+ }
+ else
+ {
+ Ata.AtaDebugger.Send("ATA device with spec level " + (int) xATA.DriveType +
+ " found, which is not supported!");
+ return;
+ }
+ var xMbrData = new byte[512];
+ xATA.ReadBlock(0UL, 1U, xMbrData);
+ var xMBR = new BlockDevice.MBR(xMbrData);
- // Find hardcoded ATA controllers
- Global.Dbg.Send("ATA Master");
- InitAta(BlockDevice.Ata.ControllerIdEnum.Primary, BlockDevice.Ata.BusPositionEnum.Master);
+ if (xMBR.EBRLocation != 0)
+ {
+ //EBR Detected
+ var xEbrData = new byte[512];
+ xATA.ReadBlock(xMBR.EBRLocation, 1U, xEbrData);
+ var xEBR = new BlockDevice.EBR(xEbrData);
- //Global.Dbg.Send("ATA Slave");
- //InitAta(BlockDevice.Ata.ControllerIdEnum.Primary, BlockDevice.Ata.BusPositionEnum.Slave);
+ for (int i = 0; i < xEBR.Partitions.Count; i++)
+ {
+ //var xPart = xEBR.Partitions[i];
+ //var xPartDevice = new BlockDevice.Partition(xATA, xPart.StartSector, xPart.SectorCount);
+ //BlockDevice.BlockDevice.Devices.Add(xPartDevice);
+ }
+ }
- //TODO Need to change code to detect if ATA controllers are present or not. How to do this? via PCI enum?
- // They do show up in PCI space as well as the fixed space.
- // Or is it always here, and was our compiler stack corruption issue?
- //InitAta(BlockDevice.Ata.ControllerIdEnum.Secondary, BlockDevice.Ata.BusPositionEnum.Master);
- //InitAta(BlockDevice.Ata.ControllerIdEnum.Secondary, BlockDevice.Ata.BusPositionEnum.Slave);
- }
+ // TODO Change this to foreach when foreach is supported
+ Console.WriteLine("Number of MBR partitions found: " + xMBR.Partitions.Count);
+ for (int i = 0; i < xMBR.Partitions.Count; i++)
+ {
+ var xPart = xMBR.Partitions[i];
+ if (xPart == null)
+ {
+ Console.WriteLine("Null partition found at idx " + i);
+ }
+ else
+ {
+ var xPartDevice = new BlockDevice.Partition(xATA, xPart.StartSector, xPart.SectorCount);
+ BlockDevice.BlockDevice.Devices.Add(xPartDevice);
+ Console.WriteLine("Found partition at idx " + i);
+ }
+ }
+ }
- static internal void InitPciDevices() {
- //TODO Redo this - Global init should be other.
- // Move PCI detection to hardware? Or leave it in core? Is Core PC specific, or deeper?
- // If we let hardware do it, we need to protect it from being used by System.
- // Probably belongs in hardware, and core is more specific stuff like CPU, memory, etc.
- //Core.PCI.OnPCIDeviceFound = PCIDeviceFound;
+ // Init devices that are "static"/mostly static. These are devices
+ // that all PCs are expected to have. Keyboards, screens, ATA hard drives etc.
+ // Despite them being static, some discovery is required. For example, to see if
+ // a hard drive is connected or not and if so what type.
+ internal static void InitStaticDevices()
+ {
+ //TextScreen = new TextScreen();
+ Global.Dbg.Send("CLS");
- //TODO: Since this is FCL, its "common". Otherwise it should be
- // system level and not accessible from Core. Need to think about this
- // for the future.
- Console.WriteLine("Finding PCI Devices");
- PCI.Setup();
+ //TextScreen.Clear();
- }
+ Global.Dbg.Send("Keyboard");
+ Keyboard = new PS2Keyboard();
- static public void Init(TextScreenBase textScreen, Keyboard keyboard)
- {
- if (textScreen != null)
- {
- TextScreen = textScreen;
- }
- if (keyboard != null)
- {
- Keyboard = keyboard;
- }
- Core.Bootstrap.Init();
- Core.Global.Init();
- Global.Dbg.Send("Static Devices");
- InitStaticDevices();
- Global.Dbg.Send("PCI Devices");
- InitPciDevices();
- }
+ // Find hardcoded ATA controllers
+ Global.Dbg.Send("ATA Master");
+ InitAta(BlockDevice.Ata.ControllerIdEnum.Primary, BlockDevice.Ata.BusPositionEnum.Master);
- //static void PCIDeviceFound(Core.PCI.PciInfo aInfo, Core.IOGroup.PciDevice aIO) {
- // Later we need to dynamically load these, but we need to finish the design first.
- // if ((aInfo.VendorID == 0x8086) && (aInfo.DeviceID == 0x7111)) {
+ //Global.Dbg.Send("ATA Slave");
+ //InitAta(BlockDevice.Ata.ControllerIdEnum.Primary, BlockDevice.Ata.BusPositionEnum.Slave);
+
+ //TODO Need to change code to detect if ATA controllers are present or not. How to do this? via PCI enum?
+ // They do show up in PCI space as well as the fixed space.
+ // Or is it always here, and was our compiler stack corruption issue?
+ //InitAta(BlockDevice.Ata.ControllerIdEnum.Secondary, BlockDevice.Ata.BusPositionEnum.Master);
+ //InitAta(BlockDevice.Ata.ControllerIdEnum.Secondary, BlockDevice.Ata.BusPositionEnum.Slave);
+ }
+
+ internal static void InitPciDevices()
+ {
+ //TODO Redo this - Global init should be other.
+ // Move PCI detection to hardware? Or leave it in core? Is Core PC specific, or deeper?
+ // If we let hardware do it, we need to protect it from being used by System.
+ // Probably belongs in hardware, and core is more specific stuff like CPU, memory, etc.
+ //Core.PCI.OnPCIDeviceFound = PCIDeviceFound;
+
+ //TODO: Since this is FCL, its "common". Otherwise it should be
+ // system level and not accessible from Core. Need to think about this
+ // for the future.
+ Console.WriteLine("Finding PCI Devices");
+ PCI.Setup();
+ }
+
+ public static void Init(TextScreenBase textScreen, Keyboard keyboard)
+ {
+ if (textScreen != null)
+ {
+ TextScreen = textScreen;
+ }
+ if (keyboard != null)
+ {
+ Keyboard = keyboard;
+ }
+ Core.Bootstrap.Init();
+ Core.Global.Init();
+ Global.Dbg.Send("Static Devices");
+ InitStaticDevices();
+ Global.Dbg.Send("PCI Devices");
+ InitPciDevices();
+ }
+
+ //static void PCIDeviceFound(Core.PCI.PciInfo aInfo, Core.IOGroup.PciDevice aIO) {
+ // Later we need to dynamically load these, but we need to finish the design first.
+ // if ((aInfo.VendorID == 0x8086) && (aInfo.DeviceID == 0x7111)) {
//ATA1 = new ATA(Core.Global.BaseIOGroups.ATA1);
- // }
- //}
-
- }
-}
+ // }
+ //}
+ }
+}
\ No newline at end of file
diff --git a/source/Cosmos.HAL/KeyEvent.cs b/source/Cosmos.HAL/KeyEvent.cs
new file mode 100644
index 000000000..05aed93e7
--- /dev/null
+++ b/source/Cosmos.HAL/KeyEvent.cs
@@ -0,0 +1,64 @@
+using System;
+
+namespace Cosmos.HAL
+{
+ public class KeyEvent
+ {
+ public enum KeyEventType
+ {
+ Make,
+ Break
+ }
+
+ // todo: once Github issue #137 is fixed, replace this class with ConsoleKeyInfo struct.
+ // Well, this one has more features
+
+ public char KeyChar
+ {
+ get;
+ set;
+ }
+
+ public ConsoleKeyEx Key
+ {
+ get;
+ set;
+ }
+
+ public ConsoleModifiers Modifiers
+ {
+ get;
+ set;
+ }
+
+ public KeyEventType Type { get; set; }
+
+ public KeyEvent()
+ {
+ KeyChar = '\0';
+ Key = ConsoleKeyEx.NoName;
+ this.Modifiers = (ConsoleModifiers)0;
+ Type = KeyEventType.Make;
+ }
+
+ public KeyEvent(char keyChar, ConsoleKeyEx key, bool shift, bool alt, bool control, KeyEventType type)
+ {
+ this.KeyChar = keyChar;
+ this.Key = key;
+ this.Modifiers = (ConsoleModifiers)0;
+ if (shift)
+ {
+ this.Modifiers |= ConsoleModifiers.Shift;
+ }
+ if (alt)
+ {
+ this.Modifiers |= ConsoleModifiers.Alt;
+ }
+ if (control)
+ {
+ this.Modifiers |= ConsoleModifiers.Control;
+ }
+ this.Type = type;
+ }
+ }
+}
\ No newline at end of file
diff --git a/source/Cosmos.HAL/KeyMapping.cs b/source/Cosmos.HAL/KeyMapping.cs
new file mode 100644
index 000000000..ba25061bf
--- /dev/null
+++ b/source/Cosmos.HAL/KeyMapping.cs
@@ -0,0 +1,54 @@
+namespace Cosmos.HAL
+{
+ public class KeyMapping
+ {
+ public uint Scancode;
+ public char Value;
+ public char Shift;
+ public char Num;
+ public char Caps;
+ public char ShiftCaps;
+ public char ShiftNum;
+ public ConsoleKeyEx Key;
+ public ConsoleKeyEx NumLockKey;
+
+ public KeyMapping(uint aScanCode, char norm, char shift, char num, char caps, char shiftcaps, char shiftnum, ConsoleKeyEx aKey)
+ {
+ Scancode = aScanCode;
+ Value = norm;
+ Shift = shift;
+ Num = num;
+ Caps = caps;
+ ShiftCaps = shiftcaps;
+ ShiftNum = shiftnum;
+ Key = aKey;
+ NumLockKey = aKey;
+ }
+
+ public KeyMapping(uint aScanCode, char norm, char shift, char num, char caps, char shiftcaps, char shiftnum, ConsoleKeyEx aKey, ConsoleKeyEx numKey)
+ : this(aScanCode, norm, shift, num, caps, shiftcaps, shiftnum, aKey)
+ {
+ NumLockKey = numKey;
+ }
+
+ public KeyMapping(uint aScanCode, char num, ConsoleKeyEx aKey, ConsoleKeyEx numKey)
+ : this(aScanCode, '\0', '\0', num, '\0', '\0', '\0', aKey, numKey)
+ {
+ }
+
+ public KeyMapping(uint aScanCode, int norm, int shift, int num, int caps, int shiftcaps, int shiftnum, ConsoleKeyEx aKey)
+ : this(aScanCode, (char)norm, (char)shift, (char)num, (char)caps, (char)shiftcaps, (char)shiftnum, aKey)
+ {
+ }
+
+ public KeyMapping(uint aScanCode, char n, ConsoleKeyEx aKey)
+ : this(aScanCode, n, n, n, n, n, n, aKey)
+ {
+ }
+
+ public KeyMapping(uint aScanCode, ConsoleKeyEx aKey)
+ : this(aScanCode, '\0', '\0', '\0', '\0', '\0', '\0', aKey)
+ {
+ }
+ }
+}
\ No newline at end of file
diff --git a/source/Cosmos.HAL/Keyboard.cs b/source/Cosmos.HAL/Keyboard.cs
index d13e82d08..c80482ec1 100644
--- a/source/Cosmos.HAL/Keyboard.cs
+++ b/source/Cosmos.HAL/Keyboard.cs
@@ -2,63 +2,20 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
+using Cosmos.HAL.ScanMaps;
namespace Cosmos.HAL {
- public class ConsoleKeyInfoEx
- {
- // todo: once Github issue #137 is fixed, replace this class with ConsoleKeyInfo struct.
-
- public char KeyChar
- {
- get;
- set;
- }
-
- public ConsoleKey Key
- {
- get;
- set;
- }
-
- public ConsoleModifiers Modifiers
- {
- get;
- set;
- }
-
- public ConsoleKeyInfoEx(char keyChar, ConsoleKey key, bool shift, bool alt, bool control)
- {
- this.KeyChar = keyChar;
- this.Key = key;
- this.Modifiers = (ConsoleModifiers)0;
- if (shift)
- {
- this.Modifiers |= ConsoleModifiers.Shift;
- }
- if (alt)
- {
- this.Modifiers |= ConsoleModifiers.Alt;
- }
- if (control)
- {
- this.Modifiers |= ConsoleModifiers.Control;
- }
- }
- }
-
public abstract class Keyboard : Device {
- // TODO: MtW: I don't like the following line in the baseclass, but for now, lets keep it here.
- protected Core.IOGroup.Keyboard IO = Core.Global.BaseIOGroups.Keyboard;
protected Keyboard()
{
if (mQueuedKeys != null)
{
Console.WriteLine("Skipping creation of key queue!");
}
- mQueuedKeys = new Queue(32);
-
+ mQueuedKeys = new Queue(32);
+ SetKeyLayout(new US_Standard());
Initialize();
- Core.INTs.SetIrqHandler(0x01, HandleIRQ);
+ UpdateLeds();
}
///
@@ -66,38 +23,36 @@ namespace Cosmos.HAL {
///
protected abstract void Initialize();
- private void HandleIRQ(ref Core.INTs.IRQContext aContext)
+ public ScanMapBase KeyLayout { get; private set; }
+
+ public void SetKeyLayout(ScanMapBase layout)
{
- byte xScanCode = IO.Port60.Byte;
- bool xReleased = (xScanCode & 0x80) == 0x80;
- if (xReleased)
- {
- xScanCode = (byte)(xScanCode ^ 0x80);
- }
- HandleScancode(xScanCode, xReleased);
+ KeyLayout = layout;
}
+ public abstract void UpdateLeds();
+
protected abstract void HandleScancode(byte aScancode, bool aReleased);
- private static Queue mQueuedKeys;
+ private static Queue mQueuedKeys;
- protected void Enqueue(ConsoleKeyInfoEx aKey)
+ protected void Enqueue(KeyEvent aKey)
{
mQueuedKeys.Enqueue(aKey);
}
- public bool TryReadKey(out ConsoleKeyInfoEx oKey)
+ public bool TryReadKey(out KeyEvent oKey)
{
if (mQueuedKeys.Count > 0)
{
oKey = mQueuedKeys.Dequeue();
return true;
}
- oKey = default(ConsoleKeyInfoEx);
+ oKey = default(KeyEvent);
return false;
}
- public ConsoleKeyInfoEx ReadKey()
+ public KeyEvent ReadKey()
{
while (mQueuedKeys.Count == 0)
{
@@ -123,11 +78,5 @@ namespace Cosmos.HAL {
get;
protected set;
}
-
- public bool NumLock { get; protected set; }
-
- public bool CapsLock { get; protected set; }
-
- public bool ScrollLock { get; protected set; }
}
}
diff --git a/source/Cosmos.HAL/PS2Keyboard.cs b/source/Cosmos.HAL/PS2Keyboard.cs
new file mode 100644
index 000000000..319f97726
--- /dev/null
+++ b/source/Cosmos.HAL/PS2Keyboard.cs
@@ -0,0 +1,114 @@
+using System;
+using System.Collections.Generic;
+using Cosmos.Common.Extensions;
+using Cosmos.Core;
+
+namespace Cosmos.HAL
+{
+ public class PS2Keyboard : Keyboard
+ {
+ protected Core.IOGroup.Keyboard IO = Core.Global.BaseIOGroups.Keyboard;
+
+ public PS2Keyboard()
+ {
+ }
+
+ protected override void Initialize()
+ {
+ INTs.SetIrqHandler(0x01, HandleIRQ);
+ }
+
+ private void HandleIRQ(ref INTs.IRQContext aContext)
+ {
+ byte xScanCode = IO.Port60.Byte;
+ bool xReleased = (xScanCode & 0x80) == 0x80;
+ if (xReleased)
+ {
+ xScanCode = (byte)(xScanCode ^ 0x80);
+ }
+ HandleScancode(xScanCode, xReleased);
+ }
+
+ public override void UpdateLeds()
+ {
+ IO.Port60.Byte = 0xED;
+ while ((new IOPort(0x64).Byte & 2) != 0)
+ {
+ }
+ var led_status = (Global.ScrollLock ? 1 : 0) | ((Global.NumLock ? 1 : 0) << 1) | ((Global.CapsLock ? 1 : 0) << 2);
+ IO.Port60.Byte = (byte)led_status;
+ while ((new IOPort(0x64).Byte & 2) != 0)
+ {
+ }
+ }
+
+ protected override void HandleScancode(byte aScancode, bool aReleased)
+ {
+ byte key = aScancode;
+ if (key == 0x3A && !aReleased)
+ {
+ // caps lock
+ Global.CapsLock = !Global.CapsLock;
+ UpdateLeds();
+ }
+ else if (key == 0x45 && !aReleased)
+ {
+ // num lock
+ Global.NumLock = !Global.NumLock;
+ UpdateLeds();
+ }
+ else if (key == 0x46 && !aReleased)
+ {
+ // scroll lock
+ Global.ScrollLock = !Global.ScrollLock;
+ UpdateLeds();
+ }
+ else
+ switch (key)
+ {
+ case 0x1D:
+ {
+ ControlPressed = !aReleased;
+ break;
+ }
+ case 0x2A:
+ case 0x36:
+ {
+ ShiftPressed = !aReleased;
+ break;
+ }
+ case 0x38:
+ {
+ AltPressed = !aReleased;
+ break;
+ }
+ default:
+ {
+ if (ControlPressed && AltPressed && (key == 0x53))
+ {
+ Console.WriteLine("Detected Ctrl-Alt-Delete! Rebooting System...");
+ Core.Global.CPU.Reboot();
+ }
+
+ if (!aReleased)
+ {
+ KeyEvent keyInfo;
+ if (GetKey(key, aReleased, out keyInfo))
+ {
+ Enqueue(keyInfo);
+ }
+ }
+
+
+ break;
+ }
+ }
+ }
+
+ public bool GetKey(byte aScancode, bool released, out KeyEvent keyInfo)
+ {
+ keyInfo = KeyLayout.ConvertScanCode(aScancode, ControlPressed, ShiftPressed, AltPressed, Global.NumLock, Global.CapsLock, Global.ScrollLock);
+ return keyInfo != null;
+ }
+ }
+}
diff --git a/source/Cosmos.HAL/ScanMapBase.cs b/source/Cosmos.HAL/ScanMapBase.cs
new file mode 100644
index 000000000..920ab1e4a
--- /dev/null
+++ b/source/Cosmos.HAL/ScanMapBase.cs
@@ -0,0 +1,73 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Cosmos.HAL
+{
+ public abstract class ScanMapBase
+ {
+ protected List _keys;
+
+ protected ScanMapBase()
+ {
+ InitKeys();
+ }
+
+ protected abstract void InitKeys();
+
+ public KeyEvent ConvertScanCode(byte scan2, bool ctrl, bool shift, bool alt, bool num, bool caps, bool scroll)
+ {
+ var keyev = new KeyEvent();
+ var found = false;
+ if (scan2 == 0)
+ {
+ found = true;
+ return keyev;
+ }
+ var scan = scan2;
+ if (alt) keyev.Modifiers |= ConsoleModifiers.Alt;
+ if (ctrl) keyev.Modifiers |= ConsoleModifiers.Control;
+ if (shift) keyev.Modifiers |= ConsoleModifiers.Shift;
+
+ keyev.Type = (scan & 0x80) != 0 ? KeyEvent.KeyEventType.Break : KeyEvent.KeyEventType.Make;
+ if ((scan & 0x80) != 0) scan = (byte)(scan ^ 0x80);
+
+ for (var index = 0; index < _keys.Count; index++)
+ {
+ var t = _keys[index];
+ if (t.Scancode == scan)
+ {
+ found = true;
+ var map = t;
+ var key = '\0';
+
+ if (shift)
+ {
+ if (caps) key = map.ShiftCaps;
+ else if (num) key = map.ShiftNum;
+ else key = map.Shift;
+ }
+ else if (caps)
+ {
+ key = map.Caps;
+ }
+ else if (num)
+ {
+ key = map.Num;
+ }
+ else
+ {
+ key = map.Value;
+ }
+
+ keyev.KeyChar = key;
+ keyev.Key = num ? t.NumLockKey : t.Key;
+ break;
+ }
+ }
+ return found ? keyev : null;
+ }
+ }
+}
diff --git a/source/Cosmos.HAL/ScanMaps/FR_Standard.cs b/source/Cosmos.HAL/ScanMaps/FR_Standard.cs
new file mode 100644
index 000000000..ecb0521b4
--- /dev/null
+++ b/source/Cosmos.HAL/ScanMaps/FR_Standard.cs
@@ -0,0 +1,124 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Cosmos.HAL.ScanMaps
+{
+ public class FR_Standard : ScanMapBase
+ {
+ protected override void InitKeys()
+ {
+ _keys = new List();
+
+ #region Keys
+ /* Scan Norm Shift Num Caps ShCaps ShNum ConsoleKeyEx */
+ _keys.Add(new KeyMapping(0x00, ConsoleKeyEx.NoName));
+ _keys.Add(new KeyMapping(0x01, ConsoleKeyEx.Escape));
+ /* 1 -> 9 */
+ _keys.Add(new KeyMapping(0x02, '&', '1', '&', '1', '&', '1', ConsoleKeyEx.D1));
+ _keys.Add(new KeyMapping(0x03, 'é', '2', 'é', '2', 'é', '2', ConsoleKeyEx.D2));
+ _keys.Add(new KeyMapping(0x04, '"', '3', '"', '3', '"', '3', ConsoleKeyEx.D3));
+ _keys.Add(new KeyMapping(0x05, '\'', '4', '\'', '4', '\'', '4', ConsoleKeyEx.D4));
+ _keys.Add(new KeyMapping(0x06, '(', '5', '(', '5', '(', '5', ConsoleKeyEx.D5));
+ _keys.Add(new KeyMapping(0x07, '-', '6', '-', '6', '-', '6', ConsoleKeyEx.D6));
+ _keys.Add(new KeyMapping(0x08, 'è', '7', 'è', '7', 'è', '7', ConsoleKeyEx.D7));
+ _keys.Add(new KeyMapping(0x09, '_', '8', '_', '8', '_', '8', ConsoleKeyEx.D8));
+ _keys.Add(new KeyMapping(0x0A, 'ç', '9', 'ç', '9', 'ç', '9', ConsoleKeyEx.D9));
+ _keys.Add(new KeyMapping(0x0B, 'à', '0', 'à', '0', 'à', '0', ConsoleKeyEx.D0));
+ /* -, =, Bksp, Tab */
+ _keys.Add(new KeyMapping(0x0C, ')', '°', ')', '°', ')', '°', ConsoleKeyEx.Minus));
+ _keys.Add(new KeyMapping(0x0D, '=', '+', '=', '+', '=', '+', ConsoleKeyEx.Equal));
+ _keys.Add(new KeyMapping(0x0E, ConsoleKeyEx.Backspace));
+ _keys.Add(new KeyMapping(0x0F, ConsoleKeyEx.Tab));
+ /* QWERTYUIOP[] */
+ _keys.Add(new KeyMapping(0x10, 'a', 'A', 'a', 'A', 'a', 'A', ConsoleKeyEx.A));
+ _keys.Add(new KeyMapping(0x11, 'z', 'Z', 'z', 'Z', 'z', 'Z', ConsoleKeyEx.Z));
+ _keys.Add(new KeyMapping(0x12, 'e', 'E', 'e', 'E', 'e', 'E', ConsoleKeyEx.E));
+ _keys.Add(new KeyMapping(0x13, 'r', 'R', 'r', 'R', 'r', 'R', ConsoleKeyEx.R));
+ _keys.Add(new KeyMapping(0x14, 't', 'T', 't', 'T', 't', 'T', ConsoleKeyEx.T));
+ _keys.Add(new KeyMapping(0x15, 'y', 'Y', 'y', 'Y', 'y', 'Y', ConsoleKeyEx.Y));
+ _keys.Add(new KeyMapping(0x16, 'u', 'U', 'u', 'U', 'u', 'U', ConsoleKeyEx.U));
+ _keys.Add(new KeyMapping(0x17, 'i', 'I', 'i', 'I', 'i', 'I', ConsoleKeyEx.I));
+ _keys.Add(new KeyMapping(0x18, 'o', 'O', 'o', 'O', 'o', 'O', ConsoleKeyEx.O));
+ _keys.Add(new KeyMapping(0x19, 'p', 'P', 'p', 'P', 'p', 'P', ConsoleKeyEx.P));
+ _keys.Add(new KeyMapping(0x1A, '^', '¨', '^', '¨', '^', '¨', ConsoleKeyEx.LBracket));
+ _keys.Add(new KeyMapping(0x1B, '$', '£', '$', '£', '$', '£', ConsoleKeyEx.RBracket));
+ /* ENTER, CTRL */
+ _keys.Add(new KeyMapping(0x1C, ConsoleKeyEx.Enter));
+ _keys.Add(new KeyMapping(0x1D, ConsoleKeyEx.LCtrl));
+ /* ASDFGHJKL;'` */
+ _keys.Add(new KeyMapping(0x1E, 'q', 'Q', 'q', 'Q', 'q', 'Q', ConsoleKeyEx.Q));
+ _keys.Add(new KeyMapping(0x1F, 's', 'S', 's', 'S', 's', 'S', ConsoleKeyEx.S));
+ _keys.Add(new KeyMapping(0x20, 'd', 'D', 'd', 'D', 'd', 'D', ConsoleKeyEx.D));
+ _keys.Add(new KeyMapping(0x21, 'f', 'F', 'f', 'F', 'f', 'F', ConsoleKeyEx.F));
+ _keys.Add(new KeyMapping(0x22, 'g', 'G', 'g', 'G', 'g', 'G', ConsoleKeyEx.G));
+ _keys.Add(new KeyMapping(0x23, 'h', 'H', 'h', 'H', 'h', 'H', ConsoleKeyEx.H));
+ _keys.Add(new KeyMapping(0x24, 'j', 'J', 'j', 'J', 'j', 'J', ConsoleKeyEx.J));
+ _keys.Add(new KeyMapping(0x25, 'k', 'K', 'k', 'K', 'k', 'K', ConsoleKeyEx.K));
+ _keys.Add(new KeyMapping(0x26, 'l', 'L', 'l', 'L', 'l', 'L', ConsoleKeyEx.L));
+ _keys.Add(new KeyMapping(0x27, 'm', 'M', 'm', 'M', 'm', 'M', ConsoleKeyEx.M));
+ _keys.Add(new KeyMapping(0x28, 'ù', '%', 'ù', '%', 'ù', '%', ConsoleKeyEx.Apostrophe));
+ _keys.Add(new KeyMapping(0x29, '²', '\0', '²', '²', '\0', '\0', ConsoleKeyEx.Backquote));
+ /* Left Shift*/
+ _keys.Add(new KeyMapping(0x2A, ConsoleKeyEx.LShift));
+ /* \ZXCVBNM,./ */
+ _keys.Add(new KeyMapping(0x2B, '*', 'µ', '*', 'µ', '*', 'µ', ConsoleKeyEx.Backslash));
+ _keys.Add(new KeyMapping(0x2C, 'w', 'W', 'w', 'W', 'w', 'W', ConsoleKeyEx.W));
+ _keys.Add(new KeyMapping(0x2D, 'x', 'X', 'x', 'X', 'x', 'X', ConsoleKeyEx.X));
+ _keys.Add(new KeyMapping(0x2E, 'c', 'C', 'c', 'C', 'c', 'C', ConsoleKeyEx.C));
+ _keys.Add(new KeyMapping(0x2F, 'v', 'V', 'v', 'V', 'v', 'V', ConsoleKeyEx.V));
+ _keys.Add(new KeyMapping(0x30, 'b', 'B', 'b', 'B', 'b', 'B', ConsoleKeyEx.B));
+ _keys.Add(new KeyMapping(0x31, 'n', 'N', 'n', 'N', 'n', 'N', ConsoleKeyEx.N));
+ _keys.Add(new KeyMapping(0x32, ',', '?', ',', '?', ',', '?', ConsoleKeyEx.Comma));
+ _keys.Add(new KeyMapping(0x33, ';', '.', ';', '.', ';', '.', ConsoleKeyEx.Semicolon));
+ _keys.Add(new KeyMapping(0x34, ':', '/', ':', '/', ':', '/', ConsoleKeyEx.Colon));
+ _keys.Add(new KeyMapping(0x35, '!', '§', '!', '§', '!', '§', ConsoleKeyEx.ExclamationPoint)); // also numpad divide
+ /* Right Shift */
+ _keys.Add(new KeyMapping(0x36, ConsoleKeyEx.RShift));
+ /* Print Screen */
+ _keys.Add(new KeyMapping(0x37, '*', '*', '*', '*', '*', '*', ConsoleKeyEx.NumMultiply)); // also numpad multiply
+ /* Alt */
+ _keys.Add(new KeyMapping(0x38, ConsoleKeyEx.LAlt));
+ /* Space */
+ _keys.Add(new KeyMapping(0x39, ' ', ConsoleKeyEx.Spacebar));
+ /* Caps */
+ _keys.Add(new KeyMapping(0x3A, ConsoleKeyEx.CapsLock));
+ /* F1-F12 */
+ _keys.Add(new KeyMapping(0x3B, ConsoleKeyEx.F1));
+ _keys.Add(new KeyMapping(0x3C, ConsoleKeyEx.F2));
+ _keys.Add(new KeyMapping(0x3D, ConsoleKeyEx.F3));
+ _keys.Add(new KeyMapping(0x3E, ConsoleKeyEx.F4));
+ _keys.Add(new KeyMapping(0x3F, ConsoleKeyEx.F5));
+ _keys.Add(new KeyMapping(0x40, ConsoleKeyEx.F6));
+ _keys.Add(new KeyMapping(0x41, ConsoleKeyEx.F7));
+ _keys.Add(new KeyMapping(0x42, ConsoleKeyEx.F8));
+ _keys.Add(new KeyMapping(0x43, ConsoleKeyEx.F9));
+ _keys.Add(new KeyMapping(0x44, ConsoleKeyEx.F10));
+ _keys.Add(new KeyMapping(0x57, ConsoleKeyEx.F11));
+ _keys.Add(new KeyMapping(0x58, ConsoleKeyEx.F12));
+ /* Num Lock, Scrl Lock */
+ _keys.Add(new KeyMapping(0x45, ConsoleKeyEx.NumLock));
+ _keys.Add(new KeyMapping(0x46, ConsoleKeyEx.ScrollLock));
+ /* HOME, Up, Pgup, -kpad, left, center, right, +keypad, end, down, pgdn, ins, del */
+ _keys.Add(new KeyMapping(0x47, '\0', '\0', '7', '\0', '\0', '\0', ConsoleKeyEx.Home, ConsoleKeyEx.Num7));
+ _keys.Add(new KeyMapping(0x48, '\0', '\0', '8', '\0', '\0', '\0', ConsoleKeyEx.UpArrow, ConsoleKeyEx.Num8));
+ _keys.Add(new KeyMapping(0x49, '\0', '\0', '9', '\0', '\0', '\0', ConsoleKeyEx.PageUp, ConsoleKeyEx.Num9));
+ _keys.Add(new KeyMapping(0x4A, '-', '-', '-', '-', '-', '-', ConsoleKeyEx.NumMinus));
+ _keys.Add(new KeyMapping(0x4B, '\0', '\0', '4', '\0', '\0', '\0', ConsoleKeyEx.LeftArrow, ConsoleKeyEx.Num4));
+ _keys.Add(new KeyMapping(0x4C, '\0', '\0', '5', '\0', '\0', '\0', ConsoleKeyEx.Num5));
+ _keys.Add(new KeyMapping(0x4D, '\0', '\0', '6', '\0', '\0', '\0', ConsoleKeyEx.RightArrow, ConsoleKeyEx.Num6));
+ _keys.Add(new KeyMapping(0x4E, '+', '+', '+', '+', '+', '+', ConsoleKeyEx.NumPlus));
+ _keys.Add(new KeyMapping(0x4F, '\0', '\0', '1', '\0', '\0', '\0', ConsoleKeyEx.End, ConsoleKeyEx.Num1));
+ _keys.Add(new KeyMapping(0x50, '\0', '\0', '2', '\0', '\0', '\0', ConsoleKeyEx.DownArrow, ConsoleKeyEx.Num2));
+ _keys.Add(new KeyMapping(0x51, '\0', '\0', '3', '\0', '\0', '\0', ConsoleKeyEx.PageDown, ConsoleKeyEx.Num3));
+ _keys.Add(new KeyMapping(0x52, '\0', '\0', '0', '\0', '\0', '\0', ConsoleKeyEx.Insert, ConsoleKeyEx.Num0));
+ _keys.Add(new KeyMapping(0x53, '\0', '\0', '.', '\0', '\0', '\0', ConsoleKeyEx.Delete, ConsoleKeyEx.NumPeriod));
+
+ _keys.Add(new KeyMapping(0x5b, ConsoleKeyEx.LWin));
+ _keys.Add(new KeyMapping(0x5c, ConsoleKeyEx.RWin));
+ #endregion
+ }
+ }
+}
diff --git a/source/Cosmos.HAL/ScanMaps/US_Standard.cs b/source/Cosmos.HAL/ScanMaps/US_Standard.cs
new file mode 100644
index 000000000..cd1ff0c49
--- /dev/null
+++ b/source/Cosmos.HAL/ScanMaps/US_Standard.cs
@@ -0,0 +1,128 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Cosmos.HAL.ScanMaps
+{
+ public class US_Standard : ScanMapBase
+ {
+ protected override void InitKeys()
+ {
+ _keys = new List();
+
+ #region Keys
+
+ /* Scan Norm Shift Ctrl Alt Num Caps ShCaps ShNum ConsoleKeyEx */
+ _keys.Add(new KeyMapping(0x00, ConsoleKeyEx.NoName));
+ _keys.Add(new KeyMapping(0x01, ConsoleKeyEx.Escape));
+ /* 1 -> 9 */
+ _keys.Add(new KeyMapping(0x02, '1', '!', '1', '1', '!', '1', ConsoleKeyEx.D1));
+ _keys.Add(new KeyMapping(0x03, '2', '@', '2', '2', '@', '2', ConsoleKeyEx.D2));
+ _keys.Add(new KeyMapping(0x04, '3', '#', '3', '3', '#', '3', ConsoleKeyEx.D3));
+ _keys.Add(new KeyMapping(0x05, '4', '$', '4', '4', '$', '4', ConsoleKeyEx.D4));
+ _keys.Add(new KeyMapping(0x06, '5', '%', '5', '5', '%', '5', ConsoleKeyEx.D5));
+ _keys.Add(new KeyMapping(0x07, '6', '^', '6', '6', '^', '6', ConsoleKeyEx.D6));
+ _keys.Add(new KeyMapping(0x08, '7', '&', '7', '7', '&', '7', ConsoleKeyEx.D7));
+ _keys.Add(new KeyMapping(0x09, '8', '*', '8', '8', '*', '8', ConsoleKeyEx.D8));
+ _keys.Add(new KeyMapping(0x0A, '9', '(', '9', '9', '(', '9', ConsoleKeyEx.D9));
+ _keys.Add(new KeyMapping(0x0B, '0', ')', '0', '0', ')', '0', ConsoleKeyEx.D0));
+ /* -, =, Bksp, Tab */
+ _keys.Add(new KeyMapping(0x0C, '-', '_', '-', '-', '_', '-', ConsoleKeyEx.Minus));
+ _keys.Add(new KeyMapping(0x0D, '=', '+', '=', '=', '+', '=', ConsoleKeyEx.Equal));
+ _keys.Add(new KeyMapping(0x0E, ConsoleKeyEx.Backspace));
+ _keys.Add(new KeyMapping(0x0F, ConsoleKeyEx.Tab));
+ /* QWERTYUIOP[] */
+ _keys.Add(new KeyMapping(0x10, 'q', 'Q', 'q', 'Q', 'q', 'Q', ConsoleKeyEx.Q));
+ _keys.Add(new KeyMapping(0x11, 'w', 'W', 'w', 'W', 'w', 'W', ConsoleKeyEx.W));
+ _keys.Add(new KeyMapping(0x12, 'e', 'E', 'e', 'E', 'e', 'E', ConsoleKeyEx.E));
+ _keys.Add(new KeyMapping(0x13, 'r', 'R', 'r', 'R', 'r', 'R', ConsoleKeyEx.R));
+ _keys.Add(new KeyMapping(0x14, 't', 'T', 't', 'T', 't', 'T', ConsoleKeyEx.T));
+ _keys.Add(new KeyMapping(0x15, 'y', 'Y', 'y', 'Y', 'y', 'Y', ConsoleKeyEx.Y));
+ _keys.Add(new KeyMapping(0x16, 'u', 'U', 'u', 'U', 'u', 'U', ConsoleKeyEx.U));
+ _keys.Add(new KeyMapping(0x17, 'i', 'I', 'i', 'I', 'i', 'I', ConsoleKeyEx.I));
+ _keys.Add(new KeyMapping(0x18, 'o', 'O', 'o', 'O', 'o', 'O', ConsoleKeyEx.O));
+ _keys.Add(new KeyMapping(0x19, 'p', 'P', 'p', 'P', 'p', 'P', ConsoleKeyEx.P));
+ _keys.Add(new KeyMapping(0x1A, '[', '{', '[', '{', '[', '{', ConsoleKeyEx.LBracket));
+ _keys.Add(new KeyMapping(0x1B, ']', '}', ']', '}', ']', '}', ConsoleKeyEx.RBracket));
+ /* ENTER, CTRL */
+ _keys.Add(new KeyMapping(0x1C, ConsoleKeyEx.Enter));
+ _keys.Add(new KeyMapping(0x1D, ConsoleKeyEx.LCtrl));
+ /* ASDFGHJKL;'` */
+ _keys.Add(new KeyMapping(0x1E, 'a', 'A', 'a', 'A', 'a', 'A', ConsoleKeyEx.A));
+ _keys.Add(new KeyMapping(0x1F, 's', 'S', 's', 'S', 's', 'S', ConsoleKeyEx.S));
+ _keys.Add(new KeyMapping(0x20, 'd', 'D', 'd', 'D', 'd', 'D', ConsoleKeyEx.D));
+ _keys.Add(new KeyMapping(0x21, 'f', 'F', 'f', 'F', 'f', 'F', ConsoleKeyEx.F));
+ _keys.Add(new KeyMapping(0x22, 'g', 'G', 'g', 'G', 'g', 'G', ConsoleKeyEx.G));
+ _keys.Add(new KeyMapping(0x23, 'h', 'H', 'h', 'H', 'h', 'H', ConsoleKeyEx.H));
+ _keys.Add(new KeyMapping(0x24, 'j', 'J', 'j', 'J', 'j', 'J', ConsoleKeyEx.J));
+ _keys.Add(new KeyMapping(0x25, 'k', 'K', 'k', 'K', 'k', 'K', ConsoleKeyEx.K));
+ _keys.Add(new KeyMapping(0x26, 'l', 'L', 'l', 'L', 'l', 'L', ConsoleKeyEx.L));
+ _keys.Add(new KeyMapping(0x27, ';', ':', ';', ';', ':', ':', ConsoleKeyEx.Semicolon));
+ _keys.Add(new KeyMapping(0x28, '\'', '"', '\'', '\'', '"', '"', ConsoleKeyEx.Apostrophe));
+ _keys.Add(new KeyMapping(0x29, '`', '~', '`', '`', '~', '~', ConsoleKeyEx.Backquote));
+ /* Left Shift*/
+ _keys.Add(new KeyMapping(0x2A, ConsoleKeyEx.LShift));
+ /* \ZXCVBNM,./ */
+ _keys.Add(new KeyMapping(0x2B, '\\', '|', '\\', '\\', '|', '|', ConsoleKeyEx.Backslash));
+ _keys.Add(new KeyMapping(0x2C, 'z', 'Z', 'z', 'Z', 'z', 'Z', ConsoleKeyEx.Z));
+ _keys.Add(new KeyMapping(0x2D, 'x', 'X', 'x', 'X', 'x', 'X', ConsoleKeyEx.X));
+ _keys.Add(new KeyMapping(0x2E, 'c', 'C', 'c', 'C', 'c', 'C', ConsoleKeyEx.C));
+ _keys.Add(new KeyMapping(0x2F, 'v', 'V', 'v', 'V', 'v', 'V', ConsoleKeyEx.V));
+ _keys.Add(new KeyMapping(0x30, 'b', 'B', 'b', 'B', 'b', 'B', ConsoleKeyEx.B));
+ _keys.Add(new KeyMapping(0x31, 'n', 'N', 'n', 'N', 'n', 'N', ConsoleKeyEx.N));
+ _keys.Add(new KeyMapping(0x32, 'm', 'M', 'm', 'M', 'm', 'M', ConsoleKeyEx.M));
+ _keys.Add(new KeyMapping(0x33, ',', '<', ',', ',', '<', '<', ConsoleKeyEx.Comma));
+ _keys.Add(new KeyMapping(0x34, '.', '>', '.', '.', '>', '>', ConsoleKeyEx.Period));
+ _keys.Add(new KeyMapping(0x35, '/', '?', '/', '/', '?', '/', ConsoleKeyEx.Slash)); // also numpad divide
+ /* Right Shift */
+ _keys.Add(new KeyMapping(0x36, ConsoleKeyEx.RShift));
+ /* Print Screen */
+ _keys.Add(new KeyMapping(0x37, '*', '*', '*', '*', '*', '*', ConsoleKeyEx.NumMultiply));
+ // also numpad multiply
+ /* Alt */
+ _keys.Add(new KeyMapping(0x38, ConsoleKeyEx.LAlt));
+ /* Space */
+ _keys.Add(new KeyMapping(0x39, ' ', ConsoleKeyEx.Spacebar));
+ /* Caps */
+ _keys.Add(new KeyMapping(0x3A, ConsoleKeyEx.CapsLock));
+ /* F1-F12 */
+ _keys.Add(new KeyMapping(0x3B, ConsoleKeyEx.F1));
+ _keys.Add(new KeyMapping(0x3C, ConsoleKeyEx.F2));
+ _keys.Add(new KeyMapping(0x3D, ConsoleKeyEx.F3));
+ _keys.Add(new KeyMapping(0x3E, ConsoleKeyEx.F4));
+ _keys.Add(new KeyMapping(0x3F, ConsoleKeyEx.F5));
+ _keys.Add(new KeyMapping(0x40, ConsoleKeyEx.F6));
+ _keys.Add(new KeyMapping(0x41, ConsoleKeyEx.F7));
+ _keys.Add(new KeyMapping(0x42, ConsoleKeyEx.F8));
+ _keys.Add(new KeyMapping(0x43, ConsoleKeyEx.F9));
+ _keys.Add(new KeyMapping(0x44, ConsoleKeyEx.F10));
+ _keys.Add(new KeyMapping(0x57, ConsoleKeyEx.F11));
+ _keys.Add(new KeyMapping(0x58, ConsoleKeyEx.F12));
+ /* Num Lock, Scrl Lock */
+ _keys.Add(new KeyMapping(0x45, ConsoleKeyEx.NumLock));
+ _keys.Add(new KeyMapping(0x46, ConsoleKeyEx.ScrollLock));
+ /* HOME, Up, Pgup, -kpad, left, center, right, +keypad, end, down, pgdn, ins, del */
+ _keys.Add(new KeyMapping(0x47, '\0', '\0', '7', '\0', '\0', '\0', ConsoleKeyEx.Home, ConsoleKeyEx.Num7));
+ _keys.Add(new KeyMapping(0x48, '\0', '\0', '8', '\0', '\0', '\0', ConsoleKeyEx.UpArrow, ConsoleKeyEx.Num8));
+ _keys.Add(new KeyMapping(0x49, '\0', '\0', '9', '\0', '\0', '\0', ConsoleKeyEx.PageUp, ConsoleKeyEx.Num9));
+ _keys.Add(new KeyMapping(0x4A, '-', '-', '-', '-', '-', '-', ConsoleKeyEx.NumMinus));
+ _keys.Add(new KeyMapping(0x4B, '\0', '\0', '4', '\0', '\0', '\0', ConsoleKeyEx.LeftArrow, ConsoleKeyEx.Num4));
+ _keys.Add(new KeyMapping(0x4C, '\0', '\0', '5', '\0', '\0', '\0', ConsoleKeyEx.Num5));
+ _keys.Add(new KeyMapping(0x4D, '\0', '\0', '6', '\0', '\0', '\0', ConsoleKeyEx.RightArrow, ConsoleKeyEx.Num6));
+ _keys.Add(new KeyMapping(0x4E, '+', '+', '+', '+', '+', '+', ConsoleKeyEx.NumPlus));
+ _keys.Add(new KeyMapping(0x4F, '\0', '\0', '1', '\0', '\0', '\0', ConsoleKeyEx.End, ConsoleKeyEx.Num1));
+ _keys.Add(new KeyMapping(0x50, '\0', '\0', '2', '\0', '\0', '\0', ConsoleKeyEx.DownArrow, ConsoleKeyEx.Num2));
+ _keys.Add(new KeyMapping(0x51, '\0', '\0', '3', '\0', '\0', '\0', ConsoleKeyEx.PageDown, ConsoleKeyEx.Num3));
+ _keys.Add(new KeyMapping(0x52, '\0', '\0', '0', '\0', '\0', '\0', ConsoleKeyEx.Insert, ConsoleKeyEx.Num0));
+ _keys.Add(new KeyMapping(0x53, '\0', '\0', '.', '\0', '\0', '\0', ConsoleKeyEx.Delete,
+ ConsoleKeyEx.NumPeriod));
+
+ _keys.Add(new KeyMapping(0x5b, ConsoleKeyEx.LWin));
+ _keys.Add(new KeyMapping(0x5c, ConsoleKeyEx.RWin));
+
+ #endregion
+ }
+ }
+}
diff --git a/source/Cosmos.System.Plugs/System/ConsoleImpl.cs b/source/Cosmos.System.Plugs/System/ConsoleImpl.cs
index 0011caa8c..d7b439cf4 100644
--- a/source/Cosmos.System.Plugs/System/ConsoleImpl.cs
+++ b/source/Cosmos.System.Plugs/System/ConsoleImpl.cs
@@ -304,7 +304,7 @@ namespace Cosmos.System.Plugs.System {
public static int Read() {
// TODO special cases, if needed, that returns -1
- ConsoleKeyInfoEx xResult;
+ KeyEvent xResult;
if (HAL.Global.Keyboard.TryReadKey(out xResult))
{
@@ -318,7 +318,7 @@ namespace Cosmos.System.Plugs.System {
// ReadKey() pure CIL
- public static ConsoleKeyInfoEx ReadKey(Boolean intercept) {
+ public static KeyEvent ReadKey(Boolean intercept) {
var key = Cosmos.HAL.Global.Keyboard.ReadKey();
if (false == intercept && key.KeyChar != '\0')
@@ -336,13 +336,14 @@ namespace Cosmos.System.Plugs.System {
return null;
}
List chars = new List(32);
- ConsoleKeyInfoEx current;
+ KeyEvent current;
int currentCount = 0;
- while ((current = HAL.Global.Keyboard.ReadKey()).Key != ConsoleKey.Enter)
+ while ((current = HAL.Global.Keyboard.ReadKey()).Key != ConsoleKeyEx.Enter)
{
+ if (current.Key == ConsoleKeyEx.NumEnter) break;
//Check for "special" keys
- if (current.Key == ConsoleKey.Backspace) // Backspace
+ if (current.Key == ConsoleKeyEx.Backspace) // Backspace
{
if (currentCount > 0)
{
@@ -364,7 +365,7 @@ namespace Cosmos.System.Plugs.System {
}
continue;
}
- else if (current.Key == ConsoleKey.LeftArrow)
+ else if (current.Key == ConsoleKeyEx.LeftArrow)
{
if (currentCount > 0)
{
@@ -373,7 +374,7 @@ namespace Cosmos.System.Plugs.System {
}
continue;
}
- else if (current.Key == ConsoleKey.RightArrow)
+ else if (current.Key == ConsoleKeyEx.RightArrow)
{
if (currentCount < chars.Count)
{
diff --git a/source/Cosmos.System/Global.cs b/source/Cosmos.System/Global.cs
index 74c86e338..5b3847ccf 100644
--- a/source/Cosmos.System/Global.cs
+++ b/source/Cosmos.System/Global.cs
@@ -4,23 +4,47 @@ using System.Linq;
using System.Text;
using Cosmos.HAL;
-namespace Cosmos.System {
- static public class Global {
- static readonly public Cosmos.Debug.Kernel.Debugger Dbg = new Cosmos.Debug.Kernel.Debugger("System", "");
- static public Console Console = new Console(null);
+namespace Cosmos.System
+{
+ public static class Global
+ {
+ public static readonly Cosmos.Debug.Kernel.Debugger Dbg = new Cosmos.Debug.Kernel.Debugger("System", "");
+ public static Console Console = new Console(null);
- static public void Init(TextScreenBase textScreen, Keyboard keyboard){
- // We must init Console before calling Inits. This is part of the
- // "minimal" boot to allow output
- Global.Dbg.Send("Creating Console");
- if (textScreen != null)
- {
- Console = new Console(textScreen);
- }
+ public static bool NumLock
+ {
+ get { return HAL.Global.NumLock; }
+ set { HAL.Global.NumLock = value; }
+ }
- Global.Dbg.Send("HW Init");
- Cosmos.HAL.Global.Init(textScreen, keyboard);
- //Network.NetworkStack.Init();
+ public static bool CapsLock
+ {
+ get { return HAL.Global.CapsLock; }
+ set { HAL.Global.CapsLock = value; }
+ }
+
+ public static bool ScrollLock
+ {
+ get { return HAL.Global.ScrollLock; }
+ set { HAL.Global.ScrollLock = value; }
+ }
+
+ public static void Init(TextScreenBase textScreen, Keyboard keyboard)
+ {
+ // We must init Console before calling Inits. This is part of the
+ // "minimal" boot to allow output
+ Global.Dbg.Send("Creating Console");
+ if (textScreen != null)
+ {
+ Console = new Console(textScreen);
+ }
+
+ Global.Dbg.Send("HW Init");
+ Cosmos.HAL.Global.Init(textScreen, keyboard);
+ NumLock = false;
+ CapsLock = false;
+ ScrollLock = false;
+ //Network.NetworkStack.Init();
+ }
}
- }
-}
+}
\ No newline at end of file
diff --git a/source/Cosmos.sln b/source/Cosmos.sln
index 9347c32f2..c581665cb 100644
--- a/source/Cosmos.sln
+++ b/source/Cosmos.sln
@@ -98,7 +98,6 @@ Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "Docs", "..\Docs\", "{67E7DE
Release.AspNetCompiler.FixedNames = "false"
Release.AspNetCompiler.Debug = "False"
VWDPort = "8987"
- SlnRelativePath = "..\Docs\"
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cosmos.Debug.DebugStub", "Cosmos.Debug.DebugStub\Cosmos.Debug.DebugStub.csproj", "{A7F3F078-CF99-4018-9A35-2D6DC9517ADB}"