mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-24 12:35:31 +00:00
some small changes
This commit is contained in:
parent
f0f81c52cf
commit
70519d3153
5 changed files with 64 additions and 14 deletions
|
|
@ -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.
|
//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) {
|
public static unsafe void HandleInterrupt_21(InterruptContext* aContext) {
|
||||||
byte xScanCode = IORead(0x60);
|
Keyboard.HandleKeyboardInterrupt();
|
||||||
PIC.SignalPrimary();
|
PIC.SignalPrimary();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,19 @@ using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace Cosmos.Hardware {
|
namespace Cosmos.Hardware {
|
||||||
|
public delegate void HandleKeyboardDelegate(byte aScanCode, bool aReleased);
|
||||||
public class Keyboard: Hardware {
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,20 @@ namespace Cosmos.Kernel {
|
||||||
EndLogging();
|
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) {
|
public static void SendError(string aModule, string aData) {
|
||||||
StartLogging();
|
StartLogging();
|
||||||
Serial.Write(0, "<Message Type=\"Error\" Module=\"");
|
Serial.Write(0, "<Message Type=\"Error\" Module=\"");
|
||||||
|
|
|
||||||
|
|
@ -4,5 +4,35 @@ using System.Text;
|
||||||
|
|
||||||
namespace Cosmos.Kernel {
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,16 +6,9 @@ namespace Cosmos.Shell.Console {
|
||||||
class Program {
|
class Program {
|
||||||
static void Main() {
|
static void Main() {
|
||||||
Kernel.CPU.Init();
|
Kernel.CPU.Init();
|
||||||
//System.Console.WriteLine("Cosmos creation complete");
|
System.Console.WriteLine("Cosmos creation complete");
|
||||||
Kernel.Interrupts.DoTest();
|
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue