Commit a13568ec by malcolm

Added Modifier maps, screen clearing, backspace bugfixes, and more

parent 7012db9b
Showing with 38 additions and 6 deletions
...@@ -6,11 +6,22 @@ ...@@ -6,11 +6,22 @@
#include "term.h" #include "term.h"
#include "comp.h" #include "comp.h"
char scan_map[256] = {' ','E','1','2','3','4','5','6','7','8','9','0','-','=','\b','\t','q','w','e','r','t','y','u','i','o','p', char scan_map[256] = {'','','1','2','3','4','5','6','7','8','9','0','-','=','\b','\t',
'[',']','\n','^','a','s','d','f','g','h','j','k','l',';','\'','`','S','\\','z','x','c','v','b','n','m', 'q','w','e','r','t','y','u','i','o','p','[',']','\n','^','a','s',
',','.','/','S','O','A',' ','C','F','F','F','F','F','F','F','F','F','F','L','L',}; 'd','f','g','h','j','k','l',';','\'','`','S','\\','z','x','c','v',
'b','n','m',',','.','/','','','',' ','','','','','','',
'','','','','','',''};
char shift_map[256] = {'','','!','@','#','$','%','^','&','*','(',')','_','+','\b','\t',
'Q','W','E','R','T','Y','U','I','O','P','{','}','\n','^','A','S',
'D','F','G','H','J','K','L',':','\"','~','S','|','Z','X','C','V',
'B','N','M','<','>','?','','','',' ','','','','','','',
'','','','','','',''};
char kb_buf[256]; char kb_buf[256];
int kb_buf_size; int kb_buf_size;
int modifiers[6] = {0,0,0};
#define MOD_SHIFT 0
#define MOD_CTRL 1
#define MOD_ALT 2
void terminal_writeint(int n) void terminal_writeint(int n)
{ {
...@@ -33,6 +44,10 @@ void io_process(char* s, int ss) ...@@ -33,6 +44,10 @@ void io_process(char* s, int ss)
serial_writestring(s+7); serial_writestring(s+7);
serial_writestring("\n"); serial_writestring("\n");
} }
else if(strncmp(s,"clear",5)==0)
{
terminal_clear();
}
else if(strncmp(s,"hex ",4)==0) else if(strncmp(s,"hex ",4)==0)
{ {
terminal_hexstring(s+4,ss-4); terminal_hexstring(s+4,ss-4);
...@@ -96,18 +111,31 @@ void io_process(char* s, int ss) ...@@ -96,18 +111,31 @@ void io_process(char* s, int ss)
void kbd_irq() void kbd_irq()
{ {
int a = inb(0x60); int a = inb(0x60);
//serial_hexword(a); if(a==0x2a || a==0x36)
{
modifiers[MOD_SHIFT]=1;
}
else if(a==0xaa || a==0xba)
{
modifiers[MOD_SHIFT]=0;
}
else
{
if(a==0x4b) if(a==0x4b)
terminal_adjustcursor(-1,0); terminal_adjustcursor(-1,0);
else if(a==0x4d) else if(a==0x4d)
terminal_adjustcursor(1,0); terminal_adjustcursor(1,0);
else if(a==0x48) else if(a==0x48)
terminal_adjustcursor(0,-1); terminal_adjustcursor(0,0);//-1);
else if(a==0x50) else if(a==0x50)
terminal_adjustcursor(0,1); terminal_adjustcursor(0,0);//1);
else if(a<0x80) else if(a<0x80)
{ {
char in = scan_map[a]; char in = scan_map[a];
if(modifiers[MOD_SHIFT]==1)
{
in = shift_map[a];
}
if(in == '\n')//enter pressed if(in == '\n')//enter pressed
{ {
io_process(kb_buf, kb_buf_size); io_process(kb_buf, kb_buf_size);
...@@ -120,10 +148,13 @@ void kbd_irq() ...@@ -120,10 +148,13 @@ void kbd_irq()
} }
else if(in=='\b') else if(in=='\b')
{ {
if(kb_buf_size>0)
{
kb_buf_size--; kb_buf_size--;
kb_buf[kb_buf_size]='\0'; kb_buf[kb_buf_size]='\0';
terminal_putchar(in); terminal_putchar(in);
} }
}
else else
{ {
kb_buf[kb_buf_size]=in; kb_buf[kb_buf_size]=in;
...@@ -131,6 +162,7 @@ void kbd_irq() ...@@ -131,6 +162,7 @@ void kbd_irq()
terminal_putchar(in); terminal_putchar(in);
} }
} }
}
//else //else
//terminal_putchar(scan_map[a-0x80]); //terminal_putchar(scan_map[a-0x80]);
//serial_writestring("\n"); //serial_writestring("\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment