Commit a13568ec by malcolm

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

parent 7012db9b
Showing with 65 additions and 33 deletions
......@@ -6,11 +6,22 @@
#include "term.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',
'[',']','\n','^','a','s','d','f','g','h','j','k','l',';','\'','`','S','\\','z','x','c','v','b','n','m',
',','.','/','S','O','A',' ','C','F','F','F','F','F','F','F','F','F','F','L','L',};
char scan_map[256] = {'','','1','2','3','4','5','6','7','8','9','0','-','=','\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 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];
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)
{
......@@ -33,6 +44,10 @@ void io_process(char* s, int ss)
serial_writestring(s+7);
serial_writestring("\n");
}
else if(strncmp(s,"clear",5)==0)
{
terminal_clear();
}
else if(strncmp(s,"hex ",4)==0)
{
terminal_hexstring(s+4,ss-4);
......@@ -96,39 +111,56 @@ void io_process(char* s, int ss)
void kbd_irq()
{
int a = inb(0x60);
//serial_hexword(a);
if(a==0x4b)
terminal_adjustcursor(-1,0);
else if(a==0x4d)
terminal_adjustcursor(1,0);
else if(a==0x48)
terminal_adjustcursor(0,-1);
else if(a==0x50)
terminal_adjustcursor(0,1);
else if(a<0x80)
{
char in = scan_map[a];
if(in == '\n')//enter pressed
if(a==0x2a || a==0x36)
{
modifiers[MOD_SHIFT]=1;
}
else if(a==0xaa || a==0xba)
{
modifiers[MOD_SHIFT]=0;
}
else
{
if(a==0x4b)
terminal_adjustcursor(-1,0);
else if(a==0x4d)
terminal_adjustcursor(1,0);
else if(a==0x48)
terminal_adjustcursor(0,0);//-1);
else if(a==0x50)
terminal_adjustcursor(0,0);//1);
else if(a<0x80)
{
io_process(kb_buf, kb_buf_size);
for(int i=0;i<kb_buf_size;i++)
char in = scan_map[a];
if(modifiers[MOD_SHIFT]==1)
{
kb_buf[i]='\0';
in = shift_map[a];
}
if(in == '\n')//enter pressed
{
io_process(kb_buf, kb_buf_size);
for(int i=0;i<kb_buf_size;i++)
{
kb_buf[i]='\0';
}
kb_buf_size=0;
terminal_writestring("> ");
}
else if(in=='\b')
{
if(kb_buf_size>0)
{
kb_buf_size--;
kb_buf[kb_buf_size]='\0';
terminal_putchar(in);
}
}
else
{
kb_buf[kb_buf_size]=in;
kb_buf_size++;
terminal_putchar(in);
}
kb_buf_size=0;
terminal_writestring("> ");
}
else if(in=='\b')
{
kb_buf_size--;
kb_buf[kb_buf_size]='\0';
terminal_putchar(in);
}
else
{
kb_buf[kb_buf_size]=in;
kb_buf_size++;
terminal_putchar(in);
}
}
//else
......
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