-
Notifications
You must be signed in to change notification settings - Fork 290
Closed
Description
Sample 8 can enable the usbkeyboard,and echo the typed letter on screen
I want to write an "Echo Server",when user typed a line,the server will echo the while line,so I change the sample 8 code:
void CKernel::KeyPressedHandler (const char *pString)
{
s_pThis->m_Screen.Write (pString, strlen (pString));
if(pString[0]!='\n')
{
strcat(s_pThis->s,pString);
}
else
{
strcat(s_pThis->s,pString);
s_pThis->m_Screen.Write (s_pThis->s, strlen (s_pThis->s));
strcpy(s_pThis->s,"");
}
}
and add
strcpy(s_pThis->s,"");
in function
boolean CKernel::Initialize (void)
before
return bOK;
if got key not equal '\n',strcat it,else write it on screen and clear the buffer.
the prog works fine,but I write it in the call-back function KeyPressedHandler.I want write the logic in the "main function",in circle it should be the
TShutdownMode CKernel::Run (void)
function,like write
scanf(line)
printf(line)
in c,I can write it in the main function.After all I can't always put the logic code in the call-back function
How to do this?Thanks!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels