_CONSOLEINPUT is blocking - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: Chatting and Socializing (https://qb64phoenix.com/forum/forumdisplay.php?fid=11) +--- Forum: General Discussion (https://qb64phoenix.com/forum/forumdisplay.php?fid=2) +--- Thread: _CONSOLEINPUT is blocking (/showthread.php?tid=3388) |
_CONSOLEINPUT is blocking - mdijkens - 01-17-2025 I can't find it in the documentation, but _CONSOLEINPUT seems blocking (waiting for a key) after the first call. Code: (Select All)
Will only show one 0 and then waits for a keypress...Is there any other way to check non-blocking for a key in a $CONSOLE window? RE: _CONSOLEINPUT is blocking - SMcNeill - 01-17-2025 For a single keypress? Not usually. Why not create a normal program, hide the normal screen, use it to read the keystrokes via INKEY$ or _KEYHIT, and then process it on the visible CONSOLE if you need to do something like that? RE: _CONSOLEINPUT is blocking - RhoSigma - 01-17-2025 _CONSOLEINPUT is like _MOUSEINPUT, it just shows if new input is available and returns 1 for new keyboard input and 2 for new mouse input, however to retrieve the keyboard input use _CINP and for mouse the respective _MOUSExxx functions. _CONSOLEINPUT blocks until the actual input is retrieved, see example on the _CONSOLEINPUT and _CINP wiki pages. RE: _CONSOLEINPUT is blocking - DSMan195276 - 01-17-2025 I'm with @mdijkens that this seems like a bug. We're currently calling `ReadConsoleInput` which blocks when there are no new events, we can call `GetNumberOfConsoleInputEvents` beforehand to check if it will block or not. RE: _CONSOLEINPUT is blocking - mdijkens - 01-17-2025 (7 hours ago)RhoSigma Wrote: _CONSOLEINPUT is like _MOUSEINPUT, it just shows if new input is available and returns 1 for new keyboard input and 2 for new mouse input, however to retrieve the keyboard input use _CINP and for mouse the respective _MOUSExxx functions. _CONSOLEINPUT blocks until the actual input is retrieved, see example on the _CONSOLEINPUT and _CINP wiki pages.Yes, I know, but the point is that it is blocking Code: (Select All)
Here I would expect to see --------------------------- all the time except when pressing keys RE: _CONSOLEINPUT is blocking - RhoSigma - 01-17-2025 Just as @DSMan195276 mentioned above, it's the used WINAPI function which blocks until at least one input event could be read. I've made the fix suggested by him and will push it for the next release. However, if you cant wait, here's the fixed version of the C-Function, just look for it in internal\c\libqb.cpp and replace it. Code: (Select All) int32 func__getconsoleinput() { After that compile the following program and it should print "-" for no input, "M' for mouse input (Quick Edit mode must be off for mouse events (info added to the _CONSOLEINPUT Wiki page)) and the respective scan codes for keyboard input. Code: (Select All)
RE: _CONSOLEINPUT is blocking - mdijkens - 01-17-2025 That is great. I am going to make that change. Would be nice to have that in next version; waiting for input is easy enough if you still need that |