X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Fdrv%2Fkb.c;h=608b058a6dae1b073a6357bbbdbdf8a63659a915;hb=391af300bd045791b8aaf50cf44b2d503c763213;hp=14ff74ba1ad3b08d40089a872af8793f20544dc0;hpb=7083f886afa0c52f5d46f463a70f5b35b050e632;p=tpg%2Facess2.git diff --git a/Kernel/drv/kb.c b/Kernel/drv/kb.c index 14ff74ba..608b058a 100644 --- a/Kernel/drv/kb.c +++ b/Kernel/drv/kb.c @@ -29,14 +29,14 @@ tDevFS_Driver gKB_DevInfo = { NULL, "PS2Keyboard", { .NumACLs = 0, - .Size = -1, - .Read = KB_Read, + .Size = 0, + //.Read = KB_Read, .IOCtl = KB_IOCtl } }; tKeybardCallback gKB_Callback = NULL; Uint8 **gpKB_Map = gpKBDUS; -Uint8 gbaKB_States[3*256]; +Uint8 gbaKB_States[256]; int gbKB_ShiftState = 0; int gbKB_CapsState = 0; int gbKB_KeyUp = 0; @@ -66,7 +66,7 @@ void KB_IRQHandler() { Uint8 scancode; Uint32 ch; - int keyNum; + // int keyNum; //if( inportb(0x64) & 0x20 ) return; @@ -105,7 +105,7 @@ void KB_IRQHandler() // Translate ch = gpKB_Map[giKB_KeyLayer][scancode]; - keyNum = giKB_KeyLayer * 256 + scancode; + //keyNum = giKB_KeyLayer * 256 + scancode; // Check for unknown key if(!ch && !gbKB_KeyUp) Warning("UNK %i %x", giKB_KeyLayer, scancode); @@ -117,19 +117,19 @@ void KB_IRQHandler() if (gbKB_KeyUp) { gbKB_KeyUp = 0; - gbaKB_States[ keyNum ] = 0; // Unset key state flag + gbaKB_States[ ch ] = 0; // Unset key state flag if( !gbaKB_States[KEY_LSHIFT] && !gbaKB_States[KEY_RSHIFT] ) gbKB_ShiftState = 0; - KB_AddBuffer(KEY_KEYUP); - KB_AddBuffer(ch); + if(ch != 0 && gKB_Callback) + gKB_Callback( ch & 0x80000000 ); return; } // Set the bit relating to the key - gbaKB_States[keyNum] = 1; + gbaKB_States[ch] = 1; if(ch == KEY_LSHIFT || ch == KEY_RSHIFT) gbKB_ShiftState = 1; @@ -140,12 +140,11 @@ void KB_IRQHandler() } // Ignore Non-Printable Characters - if(ch == 0 || ch & 0x80) return; + if(ch == 0) return; // --- Check for Kernel Magic Combos - if(gbaKB_States[KEY_LCTRL])// && gbaKB_States[KEY_LALT]) + if(gbaKB_States[KEY_LCTRL] && gbaKB_States[KEY_LALT]) { - LOG("ch = 0x%02x", ch); switch(ch) { case 'd': __asm__ __volatile__ ("xchg %bx, %bx"); break; @@ -158,6 +157,7 @@ void KB_IRQHandler() { switch(ch) { + case 0: break; case '`': ch = '~'; break; case '1': ch = '!'; break; case '2': ch = '@'; break; @@ -186,48 +186,7 @@ void KB_IRQHandler() } } - if(gKB_Callback) gKB_Callback(ch); -} - -/** - * \fn void KB_AddBuffer(char ch) - * \brief Add to the keyboard ring buffer - */ -void KB_AddBuffer(char ch) -{ - // Add to buffer - gaKB_Buffer[ giKB_InsertPoint++ ] = ch; - // - Wrap - if( giKB_InsertPoint == KB_BUFFER_SIZE ) giKB_InsertPoint = 0; - // - Force increment read pointer - if( giKB_InsertPoint == giKB_ReadPoint ) giKB_ReadPoint ++; -} - -/** - * \fn Uint64 KB_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Dest) - * \brief Read from the ring buffer - * \param Node Unused - * \param Offset Unused (Character Device) - * \param Length Number of bytes to read - * \param Dest Destination - */ -Uint64 KB_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Dest) -{ - int pos = 0; - char *dstbuf = Dest; - - if(giKB_InUse) return -1; - giKB_InUse = 1; - - while(giKB_ReadPoint != giKB_InsertPoint && pos < Length) - { - dstbuf[pos++] = gaKB_Buffer[ giKB_ReadPoint++ ]; - if( giKB_ReadPoint == KB_BUFFER_SIZE ) giKB_InsertPoint = 0; - } - - giKB_InUse = 0; - - return Length; + if(gKB_Callback && ch != 0) gKB_Callback(ch); } /**