mirror of
https://github.com/raspberrypi/pico-sdk.git
synced 2025-12-10 07:14:36 +01:00
Merge d3cb97240f into 8fcd44a171
This commit is contained in:
commit
877b22f5f4
1 changed files with 14 additions and 2 deletions
|
|
@ -48,12 +48,24 @@ void _inittty(void) {
|
|||
//_tty.c_oflag &= ~ONLCR;
|
||||
tcsetattr(STDIN_FILENO, TCSANOW, &_tty);
|
||||
|
||||
fcntl(STDIN_FILENO, F_SETFL, FNONBLOCK);
|
||||
atexit(_resettty);
|
||||
}
|
||||
|
||||
static int non_blocking_getchar(void) {
|
||||
fcntl(STDIN_FILENO, F_SETFL, FNONBLOCK);
|
||||
|
||||
int c = getchar();
|
||||
|
||||
int old = fcntl(STDIN_FILENO, F_GETFL);
|
||||
|
||||
fcntl(STDIN_FILENO, F_SETFL, old & ~FNONBLOCK);
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
#else
|
||||
void _inittty() {}
|
||||
static int non_blocking_getchar(void) { return getchar(); }
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
|
|
@ -67,7 +79,7 @@ static int _nextchar = EOF;
|
|||
|
||||
static bool _peekchar() {
|
||||
if (_nextchar == EOF) {
|
||||
_nextchar = getchar();
|
||||
_nextchar = non_blocking_getchar();
|
||||
}
|
||||
return _nextchar != EOF;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue