Allow suppressing console output on PC build

This commit is contained in:
Kuba Szczodrzyński 2024-02-10 18:20:54 +01:00
parent 3cb5eb2d58
commit 3fcae65fad
No known key found for this signature in database
GPG Key ID: 43037AC62A600562
2 changed files with 12 additions and 1 deletions

View File

@ -246,7 +246,7 @@ bool PosixDevice::is_system_pin(uint8_t pin)
return false;
}
void Win32Device::run_thread(void (*func)(void*), void* arg)
void PosixDevice::run_thread(void (*func)(void*), void* arg)
{
pthread_t thread;
pthread_create(&thread, NULL, (void* (*)(void*))func, arg);

View File

@ -17,6 +17,7 @@
#if defined(POSIX)
#include <netdb.h>
#include <unistd.h>
#include <fcntl.h>
#include <linux/limits.h>
#include <sys/types.h>
#include <pwd.h>
@ -112,6 +113,7 @@ void usage(const char* progName, const char* version)
<< std::endl
<< "Options:" << std::endl
<< " -h | --help Print this help" << std::endl
<< " -q | --quiet Suppress console output (can improve performance)" << std::endl
#if !USE_FBDEV
<< " -W | --width Width of the window" << std::endl
<< " -H | --height Height of the window" << std::endl
@ -140,6 +142,15 @@ int main(int argc, char* argv[])
for(int arg = 1; arg < argc; arg++) {
if(strncmp(argv[arg], "--help", 6) == 0 || strncmp(argv[arg], "-h", 2) == 0) {
showhelp = true;
} else if(strncmp(argv[arg], "--quiet", 7) == 0 || strncmp(argv[arg], "-q", 2) == 0) {
#if defined(WINDOWS)
FreeConsole();
#endif
#if defined(POSIX)
int nullfd = open("/dev/null", O_WRONLY);
dup2(nullfd, 1);
close(nullfd);
#endif
#if !USE_FBDEV
} else if(strncmp(argv[arg], "--width", 7) == 0 || strncmp(argv[arg], "-W", 2) == 0) {
if(arg + 1 < argc) {