From 92a95e0090bd55e13146a01cbd23c34ac23225dd Mon Sep 17 00:00:00 2001 From: Lephenixnoir Date: Tue, 27 Aug 2024 11:50:49 +0200 Subject: [PATCH] libfxlink: no-colors option + don't always enumerate devices [Windows] Enumerating devices constantly caused some sort of error/crash that would stop the monitor after just one frame or so. --- README.md | 2 +- libfxlink/defs.c | 4 ++++ libfxlink/devices.c | 6 ++---- libfxlink/include/fxlink/config.h.in | 3 +++ 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 2b8a908..4c71317 100644 --- a/README.md +++ b/README.md @@ -187,6 +187,6 @@ Install the cross-compiler and cross-libraries from AUR. Configure and build. Install to get libfxlink. ```bash -% x86_64-w64-mingw32-cmake -B build-win64 -DCMAKE_INSTALL_PREFIX="$HOME/.local" -DFXLINK_DISABLE_UDISKS2=1 -DFXLINK_DISABLE_POLL=1 +% x86_64-w64-mingw32-cmake -B build-win64 -DCMAKE_INSTALL_PREFIX="$HOME/.local" -DFXLINK_DISABLE_UDISKS2=1 -DFXLINK_DISABLE_POLL=1 -DFXLINK_DISABLE_ANSIESC=1 % make -C build-win64 install ``` diff --git a/libfxlink/defs.c b/libfxlink/defs.c index a6a9074..02412f6 100644 --- a/libfxlink/defs.c +++ b/libfxlink/defs.c @@ -15,6 +15,9 @@ char const *fmt_to_ANSI(int format) { +#ifdef FXLINK_DISABLE_ANSIESC + return ""; +#else static char buf[64]; int n = 0; @@ -36,6 +39,7 @@ char const *fmt_to_ANSI(int format) strcpy(buf+n, "\e[3m"), n += 4; return buf; +#endif } char *fxlink_gen_file_name(char const *path, char const *name, diff --git a/libfxlink/devices.c b/libfxlink/devices.c index 8f08cd2..ad3d835 100644 --- a/libfxlink/devices.c +++ b/libfxlink/devices.c @@ -227,7 +227,8 @@ void fxlink_device_analysis_1(struct fxlink_device *fdev, bool quiet) if(!quiet) { hlog("calculators %s", fxlink_device_id(fdev)); - log_("%1$d interface%2$s, class code%2$s", calc->interface_count, + log_("%d interface%s, class code%s", calc->interface_count, + calc->interface_count != 1 ? "s" : "", calc->interface_count != 1 ? "s" : ""); for(int i = 0; i < calc->interface_count; i++) { @@ -842,9 +843,6 @@ bool fxlink_device_list_track(struct fxlink_device_list *list, void fxlink_device_list_refresh(struct fxlink_device_list *list) { - if(!list->hotplug_supported) - enumerate_devices(list->ctx, list); - for(int i = 0; i < list->count; i++) { struct fxlink_device *fdev = &list->devices[i]; /* Finish analysis */ diff --git a/libfxlink/include/fxlink/config.h.in b/libfxlink/include/fxlink/config.h.in index 446795b..d3908c7 100644 --- a/libfxlink/include/fxlink/config.h.in +++ b/libfxlink/include/fxlink/config.h.in @@ -16,5 +16,8 @@ /* Disable poll-based interfaces. */ #cmakedefine FXLINK_DISABLE_POLL +/* Disable printing ANSI escape sequences. */ +#cmakedefine FXLINK_DISABLE_ANSIESC + /* fxSDK version */ #define FXLINK_VERSION "@CMAKE_PROJECT_VERSION@"