input working, double chars for now(next thing to figure out), can now quite with ctrl-D

This commit is contained in:
Jared Young 2019-11-04 03:09:57 +00:00
parent e05edfb687
commit 1994e4fdb4
3 changed files with 23 additions and 0 deletions

View File

@ -98,6 +98,7 @@ extern "C" void gc_collect(void) {
// Receive single character
int mp_hal_stdin_rx_chr(void) {
unsigned char c = 0;
c = retro::Console::currentInstance->ReadChar();
return c;
}

View File

@ -326,6 +326,27 @@ std::string Console::ReadLine()
return buffer;
}
char Console::ReadChar()
{
if(!consolePort)
return 0;
char c;
c = WaitNextChar();
if(!c)
{
eof = true;
return 0;
}
if(c == '\r')
c = '\n';
putch(c);
return c;
}
void Console::InvalidateCursor()
{
if(cursorDrawn)

View File

@ -40,6 +40,7 @@ namespace retro
void write(const char *s, int n);
std::string ReadLine();
char ReadChar();
static Console *currentInstance;