void IOBSDConsole::keyboardEvent(OSObject * target, /* eventType */ unsigned eventType, /* flags */ unsigned flags, /* keyCode */ unsigned /* key */, /* charCode */ unsigned charCode, /* charSet */ unsigned charSet, /* originalCharCode */ unsigned /* origCharCode */, /* originalCharSet */ unsigned /* origCharSet */, /* keyboardType */ unsigned /* keyboardType */, /* repeat */ bool /* repeat */, /* atTime */ AbsoluteTime /* ts */, OSObject * sender, void * refcon) { static const char cursorCodes[] = { 'D', 'A', 'C', 'B' }; if ( ((IOBSDConsole *)target)->displayManager != NULL ) { // if there is a display manager, tell it there is user activity ((IOBSDConsole *)target)->displayManager->activityTickle(kIOPMSuperclassPolicy1); } if( (eventType == NX_KEYDOWN) && ((flags & NX_ALTERNATEMASK) != NX_ALTERNATEMASK)) { if( (charSet == NX_SYMBOLSET) && (charCode >= 0xac) && (charCode <= 0xaf)) { cons_cinput( '\033'); cons_cinput( 'O'); charCode = cursorCodes[ charCode - 0xac ]; } cons_cinput( charCode); } }
void serial_keyboard_poll(void) { int chr; uint64_t next; while(1) { chr = _serial_getc(0, 1, 0, 1); /* Get a character if there is one */ if(chr < 0) /* The serial buffer is empty */ break; cons_cinput((char)chr); /* Buffer up the character */ } clock_interval_to_deadline(16, 1000000, &next); /* Get time of pop */ assert_wait_deadline((event_t)serial_keyboard_poll, THREAD_UNINT, next); /* Show we are "waiting" */ thread_block((thread_continue_t)serial_keyboard_poll); /* Wait for it */ panic("serial_keyboard_poll: Shouldn't never ever get here...\n"); }