Kernel - Fixing vterm bug with 32-bit input, slight fix to keymap
authorJohn Hodge <[email protected]>
Mon, 21 Nov 2011 01:34:17 +0000 (09:34 +0800)
committerJohn Hodge <[email protected]>
Mon, 21 Nov 2011 01:34:17 +0000 (09:34 +0800)
Kernel/drv/vterm.c
Kernel/include/api_drv_keyboard.h
Modules/Input/PS2KbMouse/kb_kbdus.h

index 4fd0616..57ce082 100644 (file)
@@ -482,7 +482,7 @@ Uint64 VT_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
                        ((char*)Buffer)[pos] = term->InputBuffer[term->InputRead];
                        pos ++;
                        term->InputRead ++;
-                       while(term->InputRead > MAX_INPUT_CHARS8)
+                       while(term->InputRead >= MAX_INPUT_CHARS8)
                                term->InputRead -= MAX_INPUT_CHARS8;
                }
                break;
@@ -495,8 +495,9 @@ Uint64 VT_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
                avail = term->InputWrite - term->InputRead;
                if(avail < 0)
                        avail += MAX_INPUT_CHARS32;
+               Length /= 4;
                if(avail > Length - pos)
-                       avail = Length/4 - pos;
+                       avail = Length - pos;
                
                codepoint_in = (void*)term->InputBuffer;
                codepoint_buf = Buffer;
@@ -506,7 +507,7 @@ Uint64 VT_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
                        codepoint_buf[pos] = codepoint_in[term->InputRead];
                        pos ++;
                        term->InputRead ++;
-                       while(term->InputRead > MAX_INPUT_CHARS32)
+                       while(term->InputRead >= MAX_INPUT_CHARS32)
                                term->InputRead -= MAX_INPUT_CHARS32;
                }
                pos *= 4;
@@ -1053,13 +1054,26 @@ void VT_KBCallBack(Uint32 Codepoint)
        {
                // Encode the raw key event
                Uint32  *raw_in = (void*)term->InputBuffer;
+       
+               #if 0
+               // Drop new keys
+               if( term->InputWrite == term->InputRead )
+                       return ;                
+               #endif
+
                raw_in[ term->InputWrite ] = Codepoint;
                term->InputWrite ++;
-               term->InputWrite %= MAX_INPUT_CHARS32;
+               if(term->InputWrite >= MAX_INPUT_CHARS32)
+                       term->InputWrite -= MAX_INPUT_CHARS32;
+               
+               #if 1
+               // TODO: Should old or new be dropped?
                if(term->InputRead == term->InputWrite) {
                        term->InputRead ++;
-                       term->InputRead %= MAX_INPUT_CHARS32;
+                       if( term->InputRead >= MAX_INPUT_CHARS32 )
+                               term->InputRead -= MAX_INPUT_CHARS32;
                }
+               #endif
        }
        
        VFS_MarkAvaliable(&term->Node, 1);
@@ -1324,6 +1338,9 @@ int VT_int_ParseEscape(tVTerm *Term, char *Buffer)
                                        if(argc != 1)   break;
                                        switch(args[0])
                                        {
+                                       case 25:
+                                               Term->Flags &= ~VT_FLAG_HIDECSR;
+                                               break;
                                        case 1047:
                                                VT_int_ToggleAltBuffer(Term, 1);
                                                break;
@@ -1333,6 +1350,9 @@ int VT_int_ParseEscape(tVTerm *Term, char *Buffer)
                                        if(argc != 1)   break;
                                        switch(args[0])
                                        {
+                                       case 25:
+                                               Term->Flags |= VT_FLAG_HIDECSR;
+                                               break;
                                        case 1047:
                                                VT_int_ToggleAltBuffer(Term, 0);
                                                break;
index 2085df6..57ca247 100644 (file)
@@ -116,7 +116,8 @@ enum eTplKeyboard_KeyCodes {
        KEY_KPENTER, KEY_KPSLASH, KEY_KPMINUS, KEY_KPPLUS, KEY_KPSTAR,\r
        KEY_KPHOME, KEY_KPUP, KEY_KPPGUP, KEY_KPLEFT, KEY_KP5, KEY_KPRIGHT,\r
        KEY_KPEND, KEY_KPDOWN, KEY_KPPGDN, KEY_KPINS, KEY_KPDEL,\r
-       KEY_WIN, KEY_MENU,\r
+       KEY_LWIN, KEY_RWIN,\r
+       KEY_MENU,\r
        /**\r
         * \}\r
         */\r
index 523935f..5df3257 100644 (file)
@@ -37,10 +37,8 @@ Uint32       gpKBDUS2[256] = {
 /*10*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, KEY_KPENTER, KEY_RCTRL, 0, 0,\r
 /*20*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\r
 /*30*/ 0, 0, 0, 0, 0, KEY_KPSLASH, 0, 0, KEY_RALT, 0, 0, 0, 0, 0, 0, 0,\r
-/*40*/ 0, 0, 0, 0, 0, 0, 0, KEY_HOME,\r
-                       KEY_UP, KEY_PGUP, 0, KEY_LEFT, 0, KEY_RIGHT, 0, KEY_END,\r
-/*50*/ KEY_DOWN, KEY_PGDOWN, KEY_INS, KEY_DEL, 0, 0, 0, 0,\r
-                       0, 0, KEY_WIN, 0, 0, KEY_MENU, 0, 0,\r
+/*40*/ 0, 0, 0, 0, 0, 0, 0, KEY_HOME, KEY_UP, KEY_PGUP, 0, KEY_LEFT, 0, KEY_RIGHT, 0, KEY_END,\r
+/*50*/ KEY_DOWN, KEY_PGDOWN, KEY_INS, KEY_DEL, 0, 0, 0, 0, 0, 0, 0, KEY_LWIN, KEY_RWIN, KEY_MENU, 0, 0,\r
 /*60*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\r
 /*70*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\r
 };\r

UCC git Repository :: git.ucc.asn.au