X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Fdrv%2Fvterm.c;h=7aebd28e65c8d5144e60d39f62c350dabcca66f9;hb=bf7d1cd5635d41bd7c58bf99c61cdc670291c543;hp=2011f1c519831a3cbcb6f462637b63433381be50;hpb=b71ce3a65f255d487f1f869ba88c6924b11ad7e5;p=tpg%2Facess2.git diff --git a/Kernel/drv/vterm.c b/Kernel/drv/vterm.c index 2011f1c5..7aebd28e 100644 --- a/Kernel/drv/vterm.c +++ b/Kernel/drv/vterm.c @@ -1,7 +1,8 @@ /* * Acess2 Virtual Terminal Driver */ -#include +#define DEBUG 1 +#include #include #include #include @@ -9,10 +10,12 @@ #include #include +#define USE_CTRL_ALT 0 + // === CONSTANTS === #define VERSION ((0<<8)|(50)) -#define NUM_VTS 7 +#define NUM_VTS 8 #define MAX_INPUT_CHARS32 64 #define MAX_INPUT_CHARS8 (MAX_INPUT_CHARS32*4) #define VT_SCROLLBACK 1 // 2 Screens of text @@ -315,7 +318,7 @@ Uint64 VT_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer) break; case TERM_MODE_FB: - case TERM_MODE_OPENGL: + //case TERM_MODE_: while(pos < Length) { while(term->InputRead == term->InputWrite) Threads_Yield(); @@ -345,6 +348,28 @@ Uint64 VT_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer) case TERM_MODE_TEXT: VT_int_PutString(term, Buffer, Length); break; + case TERM_MODE_FB: + if( term->RealWidth > term->Width || term->RealHeight > term->Height ) + { + #if 0 + int x, y, h; + x = Offset/4; y = x / term->Width; x %= term->Width; + w = Length/4+x; h = w / term->Width; w %= term->Width; + while(h--) + { + VFS_WriteAt( giVT_OutputDevHandle, + (x+y*term->RealWidth)*4, + term->Width * 4, + Buffer + ); + Buffer = (void*)( (Uint)Buffer + term->Width*term->Height*4 ); + } + #endif + return 0; + } + else { + return VFS_WriteAt( giVT_OutputDevHandle, Offset, Length, Buffer ); + } } //LEAVE('i', 0); @@ -359,42 +384,63 @@ int VT_Terminal_IOCtl(tVFS_Node *Node, int Id, void *Data) { int *iData = Data; tVTerm *term = Node->ImplPtr; + ENTER("pNode iId pData", Node, Id, Data); + + if(Id >= DRV_IOCTL_LOOKUP) { + if( Threads_GetUID() != 0 ) return -1; + } + switch(Id) { - case DRV_IOCTL_TYPE: return DRV_TYPE_TERMINAL; - case DRV_IOCTL_IDENT: memcpy(Data, "VT\0\0", 4); return 0; - case DRV_IOCTL_VERSION: return VERSION; - case DRV_IOCTL_LOOKUP: return 0; + case DRV_IOCTL_TYPE: + LEAVE('i', DRV_TYPE_TERMINAL); + return DRV_TYPE_TERMINAL; + case DRV_IOCTL_IDENT: + memcpy(Data, "VT\0\0", 4); + LEAVE('i', 0); + return 0; + case DRV_IOCTL_VERSION: + LEAVE('x', VERSION); + return VERSION; + case DRV_IOCTL_LOOKUP: + LEAVE('i', 0); + return 0; // Get/Set the mode (and apply any changes) case TERM_IOCTL_MODETYPE: - if(Data == NULL) return term->Mode; - - if(term->Mode != *iData) { - VT_int_ChangeMode(term, *iData); + if(Data != NULL) + { + if(term->Mode != *iData) + VT_int_ChangeMode(term, *iData); + + // Update the screen dimensions + if(giVT_CurrentTerminal == Node->Inode) + VT_SetTerminal( giVT_CurrentTerminal ); } - - // Update the screen dimensions - if(giVT_CurrentTerminal == Node->Inode) - VT_SetTerminal( giVT_CurrentTerminal ); - break; + LEAVE('i', term->Mode); + return term->Mode; // Get/set the terminal width case TERM_IOCTL_WIDTH: - if(Data == NULL) return term->Width; - term->Width = *iData; - break; + if(Data != NULL) term->Width = *iData; + Log("VT_Terminal_IOCtl - RETURN term->Width = %i", term->Width); + LEAVE('i', term->Width); + return term->Width; // Get/set the terminal height case TERM_IOCTL_HEIGHT: - if(Data == NULL) return term->Height; - term->Height = *iData; - break; + if(Data != NULL) term->Height = *iData; + Log("VT_Terminal_IOCtl - RETURN term->Height = %i", term->Height); + LEAVE('i', term->Height); + return term->Height; - default: - return -1; + case TERM_IOCTL_FORCESHOW: + VT_SetTerminal( Node->Inode ); + LEAVE('i', 1); + return 1; } - return 0; + LEAVE('i', -1); + return -1; } /** @@ -438,6 +484,11 @@ void VT_SetTerminal(int ID) /** * \fn void VT_KBCallBack(Uint32 Codepoint) * \brief Called on keyboard interrupt + * \param Codepoint Pseudo-UTF32 character + * + * Handles a key press and sends the key code to the user's buffer. + * If the code creates a kernel-magic sequence, it is not passed to the + * user and is handled in-kernel. */ void VT_KBCallBack(Uint32 Codepoint) { @@ -452,6 +503,10 @@ void VT_KBCallBack(Uint32 Codepoint) Codepoint &= 0x7FFFFFFF; switch(Codepoint) { + #if !USE_CTRL_ALT + case KEY_RSHIFT: gbVT_CtrlDown = 0; break; + case KEY_LSHIFT: gbVT_AltDown = 0; break; + #else case KEY_LALT: case KEY_RALT: gbVT_AltDown = 0; @@ -460,12 +515,17 @@ void VT_KBCallBack(Uint32 Codepoint) case KEY_RCTRL: gbVT_CtrlDown = 0; break; + #endif } return; } switch(Codepoint) { + #if !USE_CTRL_ALT + case KEY_RSHIFT: gbVT_CtrlDown = 1; break; + case KEY_LSHIFT: gbVT_AltDown = 1; break; + #else case KEY_LALT: case KEY_RALT: gbVT_AltDown = 1; @@ -474,10 +534,13 @@ void VT_KBCallBack(Uint32 Codepoint) case KEY_RCTRL: gbVT_CtrlDown = 1; break; + #endif default: + #if USE_CTRL_ALT if(!gbVT_AltDown || !gbVT_CtrlDown) break; + #endif switch(Codepoint) { case KEY_F1: VT_SetTerminal(0); return; @@ -895,8 +958,8 @@ void VT_int_ChangeMode(tVTerm *Term, int NewMode) free(Term->Text); Term->Buffer = calloc( Term->Width*Term->Height, sizeof(Uint32) ); break; - case TERM_MODE_OPENGL: - return; + //case TERM_MODE_OPENGL: + // return; } Term->Mode = NewMode;