Using your first sample code there is a problem. To best illustrate, I'm adding a single line of code at the end so that you end up with this:
$CONSOLE:ONLY
_DEST _CONSOLE: _SOURCE _CONSOLE
PRINT "Foo"
t# = TIMER
SLEEP 2
PRINT USING "##.### seconds"; TIMER - t#
INPUT "Enter some text: ", Text$
If allowed to run with no user input, it runs just fine. However, if you press a key during the 2 second pause the program advances as expected without waiting for the 2 seconds, but when it reaches the input statement note that as you try to type you see no characters displayed. You have to press ENTER twice to get past the input statement.
I experience the same problem with the second sample where I again add the input statement:
$CONSOLE:ONLY
_DEST _CONSOLE: _SOURCE _CONSOLE
PRINT "Foo"
SLEEP
INPUT "Enter some text: ", Text$
This glitch here is a screen flag setting.
For whatever reason, QB64 doesn't initially enable our window to work with mouse input. Since mouse support is something I added when I added the single character input routines, I had to go in and enable it for us, which was done via this little snippet:
fdwMode = ENABLE_EXTENDED_FLAGS;
SetConsoleMode(hStdin, fdwMode);
fdwMode = ENABLE_WINDOW_INPUT | ENABLE_MOUSE_INPUT;
SetConsoleMode(hStdin, fdwMode);
Basically, tell the console that I wanted window input and mouse input...
BUT, the problem was, I wasn't accounting for the flags which were normally set for the console window (like ENABLE_ECHO_INPUT). When you called the single key routine, permissions with the window were changed, and it wouldn't echo text back on it anymore...
Fix to this appears to be rather simple..ish:
GetConsoleMode(hStdin, (LPDWORD)&dwMode);
fdwMode = ENABLE_EXTENDED_FLAGS;
SetConsoleMode(hStdin, fdwMode);
fdwMode = dwMode | ENABLE_WINDOW_INPUT | ENABLE_MOUSE_INPUT;
SetConsoleMode(hStdin, fdwMode);
Get the old console flags, use them as the standard base of flags for the screen, and enable the mouse input with them....
Initial testing shows that things appear to be working without any glitches, but I wouldn't swear to it without further testing.
Grab the libqb.cpp below, follow the instructions with the previous post to place it and purge the old library, and test the heck out of it. Any glitches found now are ones which I won't have to try and address later, after I've forgotten exactly what the heck I've done so far with the source...
As far as I can tell, everything passes muster -- mouse input, single character input, INPUT$, and SLEEP. If something is off, just let me know and I'll see about addressing it and correcting the problem.