From cfcce71392915b538d0d3a1230c79aa0bee04f92 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 25 Jan 2020 17:17:53 +0100 Subject: [PATCH] - Add HAVE_BLISSBOX - Do not use logging functions inside internal task functions - should always be done outside at end handler function --- Makefile.common | 6 +++++- griffin/griffin.c | 2 ++ qb/config.libs.sh | 8 +++++++ qb/config.params.sh | 1 + tasks/task_autodetect.c | 46 ++++++++++++++++++++--------------------- 5 files changed, 38 insertions(+), 25 deletions(-) diff --git a/Makefile.common b/Makefile.common index be4a7be9e4..8b97ae33ba 100644 --- a/Makefile.common +++ b/Makefile.common @@ -231,7 +231,6 @@ OBJ += \ managers/state_manager.o \ gfx/drivers_font_renderer/bitmapfont.o \ tasks/task_autodetect.o \ - tasks/task_autodetect_blissbox.o \ input/input_autodetect_builtin.o \ input/input_keymaps.o \ input/input_remapping.o \ @@ -265,6 +264,11 @@ OBJ += \ manual_content_scan.o \ disk_control_interface.o +ifeq ($(HAVE_BLISSBOX), 1) + DEFINES += -DHAVE_BLISSBOX + OBJ += tasks/task_autodetect_blissbox.o +endif + ifeq ($(HAVE_AUDIOMIXER), 1) DEFINES += -DHAVE_AUDIOMIXER OBJ += tasks/task_audio_mixer.o \ diff --git a/griffin/griffin.c b/griffin/griffin.c index b4bd31a673..ae90d9545e 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -607,7 +607,9 @@ FONTS INPUT ============================================================ */ #include "../tasks/task_autodetect.c" +#ifdef HAVE_BLISSBOX #include "../tasks/task_autodetect_blissbox.c" +#endif #ifdef HAVE_AUDIOMIXER #include "../tasks/task_audio_mixer.c" #endif diff --git a/qb/config.libs.sh b/qb/config.libs.sh index 4c63f102a1..b6bdeb0ec0 100644 --- a/qb/config.libs.sh +++ b/qb/config.libs.sh @@ -353,6 +353,14 @@ check_platform Win32 WASAPI 'WASAPI is' true check_platform Win32 XAUDIO 'XAudio is' true check_platform Win32 WINMM 'WinMM is' true +if [ "$HAVE_BLISSBOX" != 'no' ]; then + if [ "$HAVE_LIBUSB" != 'no' ] || [ "$OS" = 'Win32' ]; then + add_opt BLISSBOX yes + else + add_opt BLISSBOX no + fi +fi + if [ "$HAVE_OPENGL" != 'no' ] && [ "$HAVE_OPENGLES" != 'yes' ]; then if [ "$OS" = 'Darwin' ]; then check_header OPENGL "OpenGL/gl.h" diff --git a/qb/config.params.sh b/qb/config.params.sh index 9c8c38f660..f4150397ce 100644 --- a/qb/config.params.sh +++ b/qb/config.params.sh @@ -1,5 +1,6 @@ HAVE_LIBRETRO= # Libretro library used HAVE_ASSETS_DIR= # Assets install directory +HAVE_BLISSBOX=auto # Blissbox support HAVE_ANGLE=no # ANGLE support (OpenGL wrapper) HAVE_GDI=yes # GDI support (Win32-only) HAVE_OPENGLES_LIBS= # Link flags for custom GLES library diff --git a/tasks/task_autodetect.c b/tasks/task_autodetect.c index 29b6207302..a242e5d7b0 100644 --- a/tasks/task_autodetect.c +++ b/tasks/task_autodetect.c @@ -27,11 +27,12 @@ #include "../configuration.h" #include "../file_path_special.h" #include "../list_special.h" -#include "../verbosity.h" #include "../retroarch.h" #include "tasks_internal.h" +#ifdef HAVE_BLISSBOX #include "../input/include/blissbox.h" +#endif typedef struct autoconfig_disconnect autoconfig_disconnect_t; @@ -101,6 +102,7 @@ static int input_autoconfigure_joypad_try_from_conf(config_file_t *conf, int input_vid = 0; int input_pid = 0; int score = 0; + bool check_pid = false; ident[0] = input_driver[0] = '\0'; @@ -113,20 +115,30 @@ static int input_autoconfigure_joypad_try_from_conf(config_file_t *conf, if (config_get_int (conf, "input_product_id", &tmp_int)) input_pid = tmp_int; +#ifdef HAVE_BLISSBOX if (params->vid == BLISSBOX_VID) input_pid = BLISSBOX_PID; +#endif + + check_pid = + (params->vid == input_vid) + && (params->pid == input_pid) + && (params->vid != 0) + && (params->pid != 0); + +#ifdef HAVE_BLISSBOX + check_pid = check_pid + && (params->vid != BLISSBOX_VID) + && (params->pid != BLISSBOX_PID); +#endif /* Check for VID/PID */ - if ( (params->vid == input_vid) - && (params->pid == input_pid) - && (params->vid != 0) - && (params->pid != 0) - && (params->vid != BLISSBOX_VID) - && (params->pid != BLISSBOX_PID)) + if (check_pid) score += 3; /* Check for name match */ - if (!string_is_empty(params->name) + if ( + !string_is_empty(params->name) && !string_is_empty(ident) && string_is_equal(ident, params->name)) score += 2; @@ -269,12 +281,7 @@ static bool input_autoconfigure_joypad_from_conf_dir( } if (!list) - { - RARCH_LOG("[Autoconf]: No profiles found.\n"); return false; - } - - RARCH_LOG("[Autoconf]: %d profiles found.\n", (int)list->size); for (i = 0; i < list->size; i++) { @@ -302,7 +309,6 @@ static bool input_autoconfigure_joypad_from_conf_dir( if (index >= 0 && current_best > 0 && best_conf) { - RARCH_LOG("[Autoconf]: selected configuration: %s\n", best_path); input_autoconfigure_joypad_add(best_conf, params, task); ret = 1; } @@ -368,20 +374,12 @@ static void input_autoconfigure_connect_handler(retro_task_t *task) if (input_autoconfigure_joypad_from_conf_internal(params, task)) { - RARCH_LOG("[Autoconf]: no profiles found for %s (%d/%d). Using fallback\n", - !string_is_empty(params->name) ? params->name : "N/A", - params->vid, params->pid); - snprintf(msg, sizeof(msg), "%s (%ld/%ld) %s.", !string_is_empty(params->name) ? params->name : "N/A", (long)params->vid, (long)params->pid, msg_hash_to_str(MSG_DEVICE_NOT_CONFIGURED_FALLBACK)); } #else - RARCH_LOG("[Autoconf]: no profiles found for %s (%d/%d).\n", - !string_is_empty(params->name) ? params->name : "N/A", - params->vid, params->pid); - snprintf(msg, sizeof(msg), "%s (%ld/%ld) %s.", !string_is_empty(params->name) ? params->name : "N/A", (long)params->vid, (long)params->pid, @@ -408,8 +406,6 @@ static void input_autoconfigure_disconnect_handler(retro_task_t *task) task_set_finished(task, true); - RARCH_LOG("%s: %s\n", msg_hash_to_str(MSG_AUTODETECT), params->msg); - if (!string_is_empty(params->msg)) free(params->msg); free(params); @@ -528,8 +524,10 @@ void input_autoconfigure_connect( state->max_users = *( input_driver_get_uint(INPUT_ACTION_MAX_USERS)); +#ifdef HAVE_BLISSBOX if (state->vid == BLISSBOX_VID) input_autoconfigure_override_handler(state); +#endif if (!string_is_empty(state->name)) input_config_set_device_name(state->idx, state->name);