mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
fix cmd reader blocking main thread
This commit is contained in:
parent
7f4878e2b6
commit
019fe68b48
3 changed files with 22 additions and 1 deletions
|
|
@ -14,8 +14,10 @@
|
|||
|
||||
#ifdef _WIN32
|
||||
#include <Windows.h>
|
||||
#include <conio.h>
|
||||
#pragma comment(lib, "winmm.lib")
|
||||
#else
|
||||
#include <sys/poll.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
|
|
@ -290,3 +292,14 @@ void platform::new_engine_instance(const std::vector<std::string>& args) {
|
|||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool platform::stdin_has_data() {
|
||||
#ifdef _WIN32
|
||||
return _kbhit();
|
||||
#else
|
||||
struct pollfd fds;
|
||||
fds.fd = STDIN_FILENO;
|
||||
fds.events = POLLIN;
|
||||
return poll(&fds, 1, 0) == 1;
|
||||
#endif
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue