From 349bc50e55b8d758efce65478a313d8a9ece320d Mon Sep 17 00:00:00 2001 From: DarthMew Date: Mon, 7 Oct 2024 00:24:46 +0200 Subject: [PATCH] Add Ability to Hide OSD Messages --- libretro.cpp | 55 ++++++++++++++++++++++++++--------------- libretro_core_options.h | 14 +++++++++++ 2 files changed, 49 insertions(+), 20 deletions(-) diff --git a/libretro.cpp b/libretro.cpp index 2b33079ac..02fce1ceb 100644 --- a/libretro.cpp +++ b/libretro.cpp @@ -86,6 +86,7 @@ static retro_input_state_t input_state_cb; static unsigned frame_count = 0; static unsigned internal_frame_count = 0; static bool display_internal_framerate = false; +static bool display_notifications = true; static bool allow_frame_duping = false; static bool failed_init = false; static unsigned image_offset = 0; @@ -3986,6 +3987,17 @@ static void check_variables(bool startup) else display_internal_framerate = false; + var.key = BEETLE_OPT(display_osd); + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (strcmp(var.value, "enabled") == 0) + display_notifications = true; + else if (strcmp(var.value, "disabled") == 0) + display_notifications = false; + } + else + display_notifications = true; + var.key = BEETLE_OPT(crop_overscan); if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { @@ -5292,27 +5304,30 @@ void MDFND_DispMessage( enum retro_message_target target, enum retro_message_type type, const char *str) { - if (libretro_msg_interface_version >= 1) - { - struct retro_message_ext msg = { - str, - 3000, - priority, - level, - target, - type, - -1 - }; - environ_cb(RETRO_ENVIRONMENT_SET_MESSAGE_EXT, &msg); - } - else - { - struct retro_message msg = + if (display_notifications) + { + if (libretro_msg_interface_version >= 1) + { + struct retro_message_ext msg = { + str, + 3000, + priority, + level, + target, + type, + -1 + }; + environ_cb(RETRO_ENVIRONMENT_SET_MESSAGE_EXT, &msg); + } + else { - str, - 180 - }; - environ_cb(RETRO_ENVIRONMENT_SET_MESSAGE, &msg); + struct retro_message msg = + { + str, + 180 + }; + environ_cb(RETRO_ENVIRONMENT_SET_MESSAGE, &msg); + } } } diff --git a/libretro_core_options.h b/libretro_core_options.h index bc73764d7..b997b0419 100644 --- a/libretro_core_options.h +++ b/libretro_core_options.h @@ -352,6 +352,20 @@ struct retro_core_option_v2_definition option_defs_us[] = { }, "disabled" }, + { + BEETLE_OPT(display_osd), + "Display OSD Messages", + NULL, + "Display OSD messages generated by the core.", + NULL, + "osd", + { + { "enabled", NULL }, + { "disabled", NULL }, + { NULL, NULL }, + }, + "enabled" + }, #if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) || defined(HAVE_VULKAN) { BEETLE_OPT(display_vram),