COBE 0.1 ALPHA

D:/COBE-Packet/cobe/system/keyboard.c

gehe zur Dokumentation dieser Datei
00001 #include <keyboard.h>
00002 #include <io.h>
00003 #include <stdio.h>
00004 
00005 int caps;
00006 
00008 
00009 char get_key() {
00010 
00011         
00012         int temp = inb(0x61);
00013         unsigned char newScancode = inb(0x60);  //----------Lese Zeichen aus dem Tastatur-Puffer aus----------
00014 
00015         outb(0x20, 0x20);
00016         outb(0x61,temp | 0x80);
00017         outb(0x61,temp & 0x7F); 
00018 
00019         if(newScancode == 0xAA) caps = 0x0; //Shift-End
00020         
00021         if(newScancode >= 0x80)  return 0;  //Zweites Zeichen beim schreiben ignorieren!
00022 
00023         if(newScancode == 0x1C)  //Enter
00024         {
00025                 kprintf("  ");
00026                 kputchar('<');
00027                 endgets = 1;
00028                 return 0;
00029         }
00030 
00031         if(newScancode == 0x4B)  //Left
00032         {
00033                 position_x--;
00034                 char temp0 = getkey_oncursor(position_y,position_x);
00035                 setcolor(0x0F);
00036                 kputchar(temp0);
00037                 position_x -= 1;
00038                 string_i--;
00039                 
00040                 char temp = getkey_oncursor(position_y,position_x);
00041                 setcolor(0x87);
00042                 kputchar(temp);
00043                 setcolor(0x0F);
00044                 position_x--;
00045                 return 0;
00046         }
00047         
00048         if(newScancode == 0x0E)         //Backspace
00049         {   
00050                 if(string_i == 0) return 0;
00051                 position_x--;
00052                 kputchar(' ');
00053                 position_x--;
00054                 string_i--;
00055                 move_cursor(position_y,position_x);
00056                 return 0;
00057         }
00058 
00059         if(newScancode == 0x2A) //Shift
00060         {
00061                 caps = 0x20;
00062                 return 0;
00063         }
00064 
00065         newScancode = trans_scancode(newScancode);      //----------Wandelt den Scan-Code in ein ASCII Zeichen um----------
00066         kputchar(newScancode); move_cursor(position_y,position_x);
00067         string[string_i] = newScancode;
00068         string_i++;
00069 
00070         return newScancode;
00071 }
00072 
00074 
00075 char trans_scancode(char sc) {
00076 
00077 
00078         if(sc == 0x39) { sc = 0x20; return sc; } //Space
00079         if(sc == 0x34 && caps != 0x20) { sc = 0x2E; return sc; } //.
00080         if(sc == 0x33 && caps != 0x20) { sc = 0x2C; return sc; }//,
00081         if(caps == 0x20 && sc == 0x34) { sc = 0x3A; return sc; }//:
00082         if(caps == 0x20 && sc == 0x33) { sc = 0x3B; return sc; }//;
00083 
00084         switch(sc)
00085         {
00086         
00087         case 0x1E:                              //a /A
00088         sc = 0x61 - caps;
00089         break;
00090         
00091         case 0x30:                                      //b /B
00092         sc = 0x62 - caps;
00093         break;
00094         
00095         case 0x2E:                                      //c /C
00096         sc = 0x63 - caps;
00097         break;
00098         
00099         case 0x20:                                      //d /D
00100         sc = 0x64 - caps;
00101         break;
00102         
00103         case 0x12:                  //e /E
00104         sc = 0x65 - caps;
00105         break;
00106         
00107         case 0x21:                              //f /F
00108         sc = 0x66 - caps;
00109         break;
00110         
00111         case 0x22:                              //g /G
00112         sc = 0x67 - caps;
00113         break;
00114         
00115         case 0x23:                              //h /H
00116         sc = 0x68 - caps;
00117         break;
00118         
00119         case 0x17:                              //i /I
00120         sc = 0x69 - caps;
00121         break;
00122         
00123         case 0x24:                              //j /J
00124         sc = 0x6A - caps;
00125         break;
00126         
00127         case 0x25:                              //k /K
00128         sc = 0x6B - caps;
00129         break;
00130         
00131         case 0x26:                              //l /L
00132         sc = 0x6C - caps;
00133         break;
00134         
00135         case 0x32:                              //n /M
00136         sc = 0x6D - caps;
00137         break;
00138         
00139         case 0x31:                              //n /N
00140         sc = 0x6E - caps;
00141         break;
00142         
00143         case 0x18:                              //o /O
00144         sc = 0x6F - caps;
00145         break;
00146         
00147         case 0x19:                              //p /P
00148         sc = 0x70 - caps;
00149         break;
00150         
00151         case 0x10:                              //q /Q
00152         sc = 0x71 - caps;
00153         break;
00154         
00155         case 0x13:                              //r /R
00156         sc = 0x72 - caps;
00157         break;
00158         
00159         case 0x1F:                              //s /S
00160         sc = 0x73 - caps;
00161         break;
00162         
00163         case 0x14:                              //t /T
00164         sc = 0x74 - caps;
00165         break;
00166         
00167         case 0x16:                              //u /U
00168         sc = 0x75 - caps;
00169         break;
00170         
00171         case 0x2F:                              //V /V
00172         sc = 0x76 - caps;
00173         break;
00174         
00175         case 0x11:                              //w /W
00176         sc = 0x77 - caps;
00177         break;
00178         
00179         case 0x2D:                              //x /X
00180         sc = 0x78 - caps;
00181         break;
00182         
00183         case 0x2C:                              //y /Y
00184         sc = 0x79 - caps;
00185         break;
00186         
00187         case 0x15:                              //z /Z
00188         sc = 0x7A - caps;
00189         break;
00190         
00191         case 0x0B:                              //1
00192         sc = 0x30 - (caps/2);
00193         break;
00194         
00195         case 0x02:                              //2
00196         sc = 0x31 - (caps/2);
00197         break;
00198         
00199         case 0x03:                              //3
00200         sc = 0x32 - (caps/2);
00201         break;
00202         
00203         case 0x04:                              //4
00204         sc = 0x33 - (caps/2);
00205         break;
00206         
00207         case 0x05:                              //5
00208         sc = 0x34 - (caps/2);
00209         break;
00210         
00211         case 0x06:                              //6
00212         sc = 0x35 - (caps/2);
00213         break;
00214         
00215         case 0x07:                              //7
00216         sc = 0x36 - (caps/2);
00217         break;
00218         
00219         case 0x08:                              //8
00220         sc = 0x37 - (caps/2);
00221         break;
00222         
00223         case 0x09:                              //9
00224         sc = 0x38 - (caps/2);
00225         break;
00226         
00227         case 0x0A:                              //0
00228         sc = 0x39 - (caps/2);
00229         break;
00230         
00231         case 0x4E:                                      //+
00232         case 0x1B:
00233         sc = 0x2B;
00234         break;
00235         
00236         case 0x35:                                      //-
00237         case 0x4A:
00238         sc = 0x2D;
00239         break;
00240         
00241         /*case 0x35:                            // /
00242         sc = 0x2F;
00243         break;*/
00244         
00245         case 0x37:                                      // *
00246         sc = 0x2A;
00247         break;
00248         
00249         default:
00250         sc = 0x20;
00251         break;
00252         }
00253         
00254         return sc;
00255 }
 Alle Datenstrukturen Dateien Funktionen Variablen Typdefinitionen Makrodefinitionen