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 @@ ...@@ -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,39 +111,56 @@ void io_process(char* s, int ss) ...@@ -96,39 +111,56 @@ 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)
if(a==0x4b) {
terminal_adjustcursor(-1,0); modifiers[MOD_SHIFT]=1;
else if(a==0x4d) }
terminal_adjustcursor(1,0); else if(a==0xaa || a==0xba)
else if(a==0x48) {
terminal_adjustcursor(0,-1); modifiers[MOD_SHIFT]=0;
else if(a==0x50) }
terminal_adjustcursor(0,1); else
else if(a<0x80) {
{ if(a==0x4b)
char in = scan_map[a]; terminal_adjustcursor(-1,0);
if(in == '\n')//enter pressed 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); char in = scan_map[a];
for(int i=0;i<kb_buf_size;i++) 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 //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