Ich benutze die ver 4.4.0 aus dem Einsteiger Tut (crosscompiler für win).
der komplette code:
#include "System.h"
unsigned short Groß = 0;
//das Keyboardlayout für kleinschrift
char *kbddeklein[128] =
{
"^","1","2","3","4","5","6","7","8","9","0","ß","´","\r","\t","q","w","e",
"r","t","z","u","i","o","p","ue","+","feststell","a","s","d","f","g","h","j","k",
"l","oe","ae","#","\n","shift","<","y","x","c","v","b","n","m",",",".","-","shift",
"ctrl","start","alt"," ","altgr","windows","ctrl",0
};
//Das Keyboardlayout für Grosschrift wenn Shift oder Feststell Gedrückt ist
char *kbddegross[128] =
{
"°","!","\2","§","$","%","&","/","(",")","=","?","`","\r","\t","Q","W","E",
"R","T","Z","U","I","O","P","UE","*","feststell","A","S","D","F","G","H","J",
"K","L","OE","AE","'","\n","shift",">","Y","X","C","V","B","N","M",";",":",
"_","shift","ctrl","start","alt"," ","altgr","windows","ctrl",0
};
//Handelt einen Keyboard Interrupt
void keyboard_handler(struct regs *r)
{
char scancode; //Die Var für den Scancode
char *scaned; //das Zeichen
scancode = inb(0x60); //Den Keyboardpuffer lesen
if (Groß = 0)
{
scaned[0] = kbddeklein[scancode];
}
else if (Groß = 1)
{
scaned[0] = kbddegroß[scancode];
}
else if (Groß = 2)
{
scaned[0] = kbddegroß[scancode];
Groß = Groß - 2;
}
else if (Groß = 3)
{
scaned[0] = kbddeklein[scancode];
Groß = Groß - 2;
}
//Hier kann auf besontere Tasten eingegangen werden
if (scaned == "feststell") //Feststelltaste
{
Groß = 1; //Alles Großschreiben
}
else if (scaned == "shift") //shifttaste
{
Groß = Groß + 2; //nachstes Zeichen jenachdem ob feststell
//aktiviert ist groß oder klein schriben
}
else if (scaned == "windows") //rechte windows taste
{
}
else if (scaned == "start") //linke windows taste (start)
{
}
else if (scaned == "ctrl") //Strg taste
{
}
else if (scaned == "alt") //Alt taste
{
}
else if (scaned == "altgr") //Alt Gr Taste (einige Zeichen werden hieredurch ausgelöst)
{
}
else if (scaned == 0); //Nullen sind nicht definiert: nicht handeln
else //wenn keiner der oben genannten Zeichen
{ //zutrifft ist das Zeichen Von anderen Funktionen nutzbar
InputCommandCharacter(scaned);
}
}
keyboard_install()
{
irq_install_handler(1,keyboard_handler);
}
Die Funktion InputCommandCharacter() liegt in Kernel.c und schreibt das übergebene Zeichen in einen Puffer um es dann später als Befehl zu werten.
Die irq_install_handler(1,keyboard_handler); sitzt bei mir in einer anderen recourcendatei, welche jetzt nich so wichtig ist und installiert die Funktion keyboard_handler an irq 1.
Der Errorcode:
C:\MeinOs>Umgebung\crosstools-complete\bin\i586-elf-gcc -O -Wall -Werror -c -o Keyboard.o Keyboard.c
Keyboard.c:3: error: stray '\337' in program
Keyboard.c: In function 'keyboard_handler':
Keyboard.c:31: error: stray '\337' in program
cc1.exe: warnings being treated as errors
Keyboard.c:31: error: suggest parentheses around assignment used as truth value
Keyboard.c:33: error: array subscript has type 'char'
Keyboard.c:33: error: assignment makes integer from pointer without a cast
Keyboard.c:35: error: stray '\337' in program
Keyboard.c:35: error: suggest parentheses around assignment used as truth value
Keyboard.c:37: error: stray '\337' in program
Keyboard.c:37: error: 'kbddegro' undeclared (first use in this function)
Keyboard.c:37: error: (Each undeclared identifier is reported only once
Keyboard.c:37: error: for each function it appears in.)
Keyboard.c:39: error: stray '\337' in program
Keyboard.c:39: error: suggest parentheses around assignment used as truth value
Keyboard.c:41: error: stray '\337' in program
Keyboard.c:42: error: stray '\337' in program
Keyboard.c:42: error: stray '\337' in program
Keyboard.c:44: error: stray '\337' in program
Keyboard.c:44: error: suggest parentheses around assignment used as truth value
Keyboard.c:46: error: array subscript has type 'char'
Keyboard.c:46: error: assignment makes integer from pointer without a cast
Keyboard.c:47: error: stray '\337' in program
Keyboard.c:47: error: stray '\337' in program
Keyboard.c:54: error: comparison with string literal results in unspecified beha
vior
Keyboard.c:56: error: stray '\337' in program
Keyboard.c:58: error: comparison with string literal results in unspecified beha
vior
Keyboard.c:60: error: stray '\337' in program
Keyboard.c:60: error: stray '\337' in program
Keyboard.c:63: error: comparison with string literal results in unspecified beha
vior
Keyboard.c:66: error: comparison with string literal results in unspecified beha
vior
Keyboard.c:69: error: comparison with string literal results in unspecified beha
vior
Keyboard.c:72: error: comparison with string literal results in unspecified beha
vior
Keyboard.c:75: error: comparison with string literal results in unspecified beha
vior
Keyboard.c:82: error: implicit declaration of function 'InputCommandCharacter'
Keyboard.c: At top level:
Keyboard.c:87: error: return type defaults to 'int'
Keyboard.c:86: error: conflicting types for 'keyboard_install'
System.h:57: note: previous declaration of 'keyboard_install' was here
Ich hab grade in nem anderen Forum gelesen, dass vlt gcc nich richtig funzt. Werde mal zur sicherheit gcc nochmal runterlaen...