mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-31 05:11:08 +00:00
Keyboard cleanup
This commit is contained in:
parent
724389f8fd
commit
818c184792
6 changed files with 45 additions and 57 deletions
|
|
@ -56,7 +56,7 @@
|
|||
<Compile Include="Bus\USB\USBHostOHCI.cs" />
|
||||
<Compile Include="Bus\USB\USBHostOHCIRegisters.cs" />
|
||||
<Compile Include="Device.cs" />
|
||||
<Compile Include="KeyboardOld.cs" />
|
||||
<Compile Include="Keyboard.cs" />
|
||||
<Compile Include="Network\Devices\RTL8139\BinaryHelper.cs" />
|
||||
<Compile Include="Network\Devices\RTL8139\Packet.cs" />
|
||||
<Compile Include="Network\Devices\RTL8139\PacketHeader.cs" />
|
||||
|
|
@ -80,7 +80,6 @@
|
|||
<Compile Include="Network\TCPIPModel\PhysicalLayer\Ethernet2\Ethernet2Frame.cs" />
|
||||
<Compile Include="Network\TCPIPModel\TransportLayer\UDP\UDPPacket.cs" />
|
||||
<Compile Include="Storage\ATA\ATA.cs" />
|
||||
<Compile Include="PC\Bus\Keyboard.cs" />
|
||||
<Compile Include="PC\Bus\PIC.cs" />
|
||||
<Compile Include="PC\Bus\PCIBus.cs" />
|
||||
<Compile Include="PC\DebugUtil.cs" />
|
||||
|
|
@ -89,7 +88,6 @@
|
|||
<Compile Include="Global.cs" />
|
||||
<Compile Include="Old\DebugUtil.cs" />
|
||||
<Compile Include="Old\Hardware.cs" />
|
||||
<Compile Include="Old\Keyboard.cs" />
|
||||
<Compile Include="Old\PIT.cs" />
|
||||
<Compile Include="Bus\PCIBus.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.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();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
@ -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!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue