some small changes

This commit is contained in:
mterwoord_cp 2007-11-26 15:33:59 +00:00
parent f0f81c52cf
commit 70519d3153
5 changed files with 64 additions and 14 deletions

View file

@ -67,7 +67,7 @@ namespace Cosmos.Hardware {
//IRQ 1 - Keyboard. Reserved for the system. Cannot be altered even if no keyboard is present or needed.
public static unsafe void HandleInterrupt_21(InterruptContext* aContext) {
byte xScanCode = IORead(0x60);
Keyboard.HandleKeyboardInterrupt();
PIC.SignalPrimary();
}

View file

@ -3,6 +3,19 @@ using System.Collections.Generic;
using System.Text;
namespace Cosmos.Hardware {
public class Keyboard : 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;
}
internal static void HandleKeyboardInterrupt() {
if (mHandleKeyboardKey != null) {
//mHandleKeyboardKey(
byte xScanCode = IORead(0x60);
mHandleKeyboardKey(xScanCode, (xScanCode & 0x80) == 0x80);
}
}
}
}

View file

@ -26,6 +26,20 @@ namespace Cosmos.Kernel {
EndLogging();
}
public static void SendKeyboardEvent(byte aScanCode, bool aReleased) {
StartLogging();
Serial.Write(0, "<KeyboardEvent ScanCode=\"");
Hardware.DebugUtil.WriteNumber(aScanCode, 8);
Serial.Write(0, "\" Released=\"");
if (aReleased) {
Serial.Write(0, "true");
} else {
Serial.Write(0, "false");
}
Serial.Write(0, "\"/>\r\n");
EndLogging();
}
public static void SendError(string aModule, string aData) {
StartLogging();
Serial.Write(0, "<Message Type=\"Error\" Module=\"");

View file

@ -3,6 +3,36 @@ using System.Collections.Generic;
using System.Text;
namespace Cosmos.Kernel {
public class Keyboard {
}
public class Keyboard {
private static Queue<ushort> mBuffer;
private const int BufferSize = 64;
private static bool mEscaped;
private void HandleScancode(byte aScancode, bool aReleased) {
ushort xTheScancode = aScancode;
if (mEscaped) {
xTheScancode = (ushort)(xTheScancode + 256);
mEscaped = false;
}
switch (xTheScancode) {
case 0xE0: {
mEscaped = true;
break;
}
default: {
if (mBuffer.Count < BufferSize) {
mBuffer.Enqueue(xTheScancode);
}
break;
}
}
if (!aReleased) {
DebugUtil.SendKeyboardEvent(aScancode, aReleased);
}
}
public static void Initialize() {
mBuffer = new Queue<ushort>(BufferSize);
}
}
}

View file

@ -6,16 +6,9 @@ namespace Cosmos.Shell.Console {
class Program {
static void Main() {
Kernel.CPU.Init();
//System.Console.WriteLine("Cosmos creation complete");
System.Console.WriteLine("Cosmos creation complete");
Kernel.Interrupts.DoTest();
object o = new object();
System.Console.WriteLine("Object Created");
if (o == null) {
System.Console.WriteLine("Object == null");
} else {
System.Console.WriteLine("Object != null");
}
o = null;
}
}
}