diff --git a/source/Cosmos/Cosmos.Hardware/Cosmos.Hardware.csproj b/source/Cosmos/Cosmos.Hardware/Cosmos.Hardware.csproj index 30bb1d6ef..cc186586e 100644 --- a/source/Cosmos/Cosmos.Hardware/Cosmos.Hardware.csproj +++ b/source/Cosmos/Cosmos.Hardware/Cosmos.Hardware.csproj @@ -56,7 +56,7 @@ - + @@ -80,7 +80,6 @@ - @@ -89,7 +88,6 @@ - diff --git a/source/Cosmos/Cosmos.Hardware/Global.cs b/source/Cosmos/Cosmos.Hardware/Global.cs index d6991b2a8..99c10ea8b 100644 --- a/source/Cosmos/Cosmos.Hardware/Global.cs +++ b/source/Cosmos/Cosmos.Hardware/Global.cs @@ -20,8 +20,11 @@ namespace Cosmos.Hardware { PC.Bus.PCIBus.Init(); - Device.Add(new PC.Bus.CPU.Keyboard()); - KeyboardOld.Initialize(); + // Old + Keyboard.Initialize(); + // New + //Device.Add(new PC.Bus.CPU.Keyboard()); + Cosmos.Hardware.PC.Bus.PCIBus.Init(); } diff --git a/source/Cosmos/Cosmos.Hardware/KeyboardOld.cs b/source/Cosmos/Cosmos.Hardware/Keyboard.cs similarity index 79% rename from source/Cosmos/Cosmos.Hardware/KeyboardOld.cs rename to source/Cosmos/Cosmos.Hardware/Keyboard.cs index 052e253f3..5c77455e0 100644 --- a/source/Cosmos/Cosmos.Hardware/KeyboardOld.cs +++ b/source/Cosmos/Cosmos.Hardware/Keyboard.cs @@ -2,11 +2,46 @@ using System.Collections; using System.Collections.Generic; using System.Text; -using HW = Cosmos.Hardware; namespace Cosmos.Hardware { - public class KeyboardOld { - private class KeyMapping { + + //public class Keyboard : Cosmos.Hardware.SerialDevice { + // public Keyboard() { + // mType = DeviceType.Keyboard; + // } + + // public void InterruptReceived() { + // byte xByte = Kernel.CPUBus.Read8(0x60); + // ByteReceived(xByte); + // } + // public override string Name { + // get { + // return "Keyboard"; + // } + // } + //} + + public delegate void HandleKeyboardDelegate(byte aScanCode, bool aReleased); + public class Keyboard : Hardware { + private static HandleKeyboardDelegate mHandleKeyboardKey; + public static void Initialize(HandleKeyboardDelegate aHandleKeyboardKeyDelegate) { + mHandleKeyboardKey = aHandleKeyboardKeyDelegate; + } + + public static void HandleKeyboardInterrupt() { + if (mHandleKeyboardKey != null) { + byte xScanCode = IOReadByte(0x60); + bool xReleased = (xScanCode & 0x80) == 0x80; + if (xReleased) { + xScanCode = (byte)(xScanCode ^ 0x80); + } + mHandleKeyboardKey(xScanCode, xReleased); + } else { + DebugUtil.SendError("Keyboard", "No Keyboard Handler found!"); + } + } + + private class KeyMapping { public uint Scancode; public char Value; public KeyMapping(uint aScanCode, char aValue) { diff --git a/source/Cosmos/Cosmos.Hardware/Old/Keyboard.cs b/source/Cosmos/Cosmos.Hardware/Old/Keyboard.cs deleted file mode 100644 index 045197caf..000000000 --- a/source/Cosmos/Cosmos.Hardware/Old/Keyboard.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Cosmos.Hardware { - public delegate void HandleKeyboardDelegate(byte aScanCode, bool aReleased); - public class Keyboard: Hardware { - private static HandleKeyboardDelegate mHandleKeyboardKey; - public static void Initialize(HandleKeyboardDelegate aHandleKeyboardKeyDelegate) { - mHandleKeyboardKey = aHandleKeyboardKeyDelegate; - } - - public static void HandleKeyboardInterrupt() { - if (mHandleKeyboardKey != null) { - byte xScanCode = IOReadByte(0x60); - bool xReleased = (xScanCode & 0x80) == 0x80; - if (xReleased) { - xScanCode = (byte)(xScanCode ^ 0x80); - } - mHandleKeyboardKey(xScanCode, xReleased); - } else { - DebugUtil.SendError("Keyboard", "No Keyboard Handler found!"); - } - } - } -} diff --git a/source/Cosmos/Cosmos.Hardware/PC/Bus/Keyboard.cs b/source/Cosmos/Cosmos.Hardware/PC/Bus/Keyboard.cs deleted file mode 100644 index b786a6f5a..000000000 --- a/source/Cosmos/Cosmos.Hardware/PC/Bus/Keyboard.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Cosmos.Hardware.PC.Bus.CPU { - public class Keyboard : Cosmos.Hardware.SerialDevice { - public Keyboard() { - mType = DeviceType.Keyboard; - } - - public void InterruptReceived() { - byte xByte = Kernel.CPUBus.Read8(0x60); - ByteReceived(xByte); - } - public override string Name { - get { - return "Keyboard"; - } - } - } -} diff --git a/source/Cosmos/Cosmos.Kernel.Plugs/Console.cs b/source/Cosmos/Cosmos.Kernel.Plugs/Console.cs index cd81c54fc..7a94171e4 100644 --- a/source/Cosmos/Cosmos.Kernel.Plugs/Console.cs +++ b/source/Cosmos/Cosmos.Kernel.Plugs/Console.cs @@ -116,7 +116,7 @@ namespace Cosmos.Kernel.Plugs { // HACK: convert this to "while ((current = Keyboard.ReadChar()) != '\n') {" // MTW: SOmehow an invalid opcode exception is occurring. while (true) { - current = Cosmos.Hardware.KeyboardOld.ReadChar(); + current = Cosmos.Hardware.Keyboard.ReadChar(); if (current == '\n') { break; } else if (current == '\u0968') { // Backspace