Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

oldholeps2.c (2180B)


      1 #include "../../include/keyboard.h"
      2 #include <stdint.h>
      3 #include "../../include/strcmp.h"
      4 #include "../../include/io.h"
      5 #include "../../include/print.h"
      6 #include "../../include/commands.h"
      7 #include "../../include/isspace.h"
      8 
      9 #define MODE "black"
     10 
     11 unsigned char whichChar (uint8_t scancode) {
     12     unsigned char map[128] = {
     13         0,  27, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', '\b',
     14         '\t', 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\n',
     15         0, 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', '`', 0,
     16         '\\', 'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/', 0, '*', 0, ' ',
     17         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '-', 0, 0, 0, '+', 0, 0,
     18         0, 0, 0, 0, 0, 0, 0, 0, 0
     19     };
     20 
     21     return map[scancode];
     22 }
     23 
     24 void trigger_newline() {
     25     k_print(MODE, "\n");
     26     k_print(MODE, "KakaOS > ");
     27 }
     28 
     29 char buff[128];
     30 char *buffer = buff;
     31 uint8_t st;
     32 
     33 void keyboard () {
     34     while (1) {
     35             if (inb(0x64)&1) {
     36                 st = inb(0x60);
     37 
     38                 if (st & 0x80) {
     39                     continue;
     40                 }
     41                 else if (st==0x0E) {
     42                     k_delete(MODE);
     43                     if (k_isspace(buff) > 0) {
     44                         buffer--;
     45                         *buffer = '\0';
     46                         //buffer=buff;
     47                     }
     48                 }
     49                 else if (st==0x1C) {
     50                     *buffer = '\0';
     51                     if (k_isspace(buff) < 0) {
     52                         buffer=buff;
     53                         trigger_newline();
     54                     }
     55                     else {
     56                         k_print(MODE, "\n");
     57                         k_print(MODE, commands(buff));
     58                         buffer=buff;
     59                         trigger_newline();
     60                     }
     61                 }
     62                 else {
     63                     if ((char)whichChar(st) != 0) {
     64                         const char ch[] = { (char)whichChar(st), '\0'};
     65                         *buffer = ch[0];
     66                         buffer++;
     67                         k_print(MODE, ch);
     68                     }
     69                 }
     70             }
     71         }
     72 }