From aba01c87e35ba365d06c12f86236fc34a4237001 Mon Sep 17 00:00:00 2001 From: Skirlez Date: Mon, 26 Dec 2022 23:31:50 +0200 Subject: [PATCH] add scrolling sounds for rgui, xmb, and glui and fix the ozone implementation + hebrew translation for menu sounds submenu also adds audio_driver_mixer_play_scroll_sound to menu_cbs_left and menu_cbs_right which are (seemingly) responsible for the large scroll on some menus (and also bumper scrolling on glui's playlist menu?). --- intl/msg_hash_he.h | 24 ++++++++++++++++++++++++ menu/cbs/menu_cbs_left.c | 7 ++++++- menu/cbs/menu_cbs_right.c | 12 ++++++++++-- menu/drivers/materialui.c | 31 +++++++++++++++++++++++++++---- menu/drivers/ozone.c | 12 +++++++++--- menu/drivers/rgui.c | 15 +++++++++++++++ menu/drivers/xmb.c | 20 ++++++++++++++++++++ 7 files changed, 111 insertions(+), 10 deletions(-) diff --git a/intl/msg_hash_he.h b/intl/msg_hash_he.h index a2c6787197..e823a23153 100644 --- a/intl/msg_hash_he.h +++ b/intl/msg_hash_he.h @@ -471,6 +471,30 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_AUDIO_ENABLE_MENU, "מערבל שמע (מיקסר)" ) +MSG_HASH( + MENU_ENUM_SUBLABEL_AUDIO_ENABLE_MENU, + ".נגן מספר זרמי צליל גם בתפריט" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_MENU_SOUND_OK, + "הפעל צליל 'אוקי'" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_MENU_SOUND_CANCEL, + "הפעל צליל 'בטל'" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_MENU_SOUND_NOTICE, + "הפעל צליל 'שים לב'" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_MENU_SOUND_BGM, + "הפעל צליל 'מוזיקת רקע'" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_MENU_SOUND_SCROLL, + "הפעל צלילי 'גלילה'" + ) /* Settings > Input */ diff --git a/menu/cbs/menu_cbs_left.c b/menu/cbs/menu_cbs_left.c index cbac61fd39..37d04ec4f9 100644 --- a/menu/cbs/menu_cbs_left.c +++ b/menu/cbs/menu_cbs_left.c @@ -248,7 +248,12 @@ static int action_left_scroll(unsigned type, const char *label, bool pending_push = false; menu_driver_ctl(MENU_NAVIGATION_CTL_CLEAR, &pending_push); } - + if (selection != menu_navigation_get_selection()) + { +#ifdef HAVE_AUDIOMIXER + audio_driver_mixer_play_scroll_sound(true); +#endif + } return 0; } diff --git a/menu/cbs/menu_cbs_right.c b/menu/cbs/menu_cbs_right.c index 4a229ca270..c7f97be083 100644 --- a/menu/cbs/menu_cbs_right.c +++ b/menu/cbs/menu_cbs_right.c @@ -242,7 +242,7 @@ static int action_right_scroll(unsigned type, const char *label, unsigned scroll_speed = (unsigned)((MAX(scroll_accel, 2) - 2) / 4 + 1); unsigned fast_scroll_speed = 10 * scroll_speed; - if (selection + fast_scroll_speed < (menu_entries_get_size())) + if (selection + fast_scroll_speed < (menu_entries_get_size())) { size_t idx = selection + fast_scroll_speed; @@ -251,8 +251,16 @@ static int action_right_scroll(unsigned type, const char *label, } else { - if ((menu_entries_get_size() > 0)) + if ((menu_entries_get_size() > 0)) { menu_driver_ctl(MENU_NAVIGATION_CTL_SET_LAST, NULL); + } + } + + if (selection != menu_navigation_get_selection()) + { +#ifdef HAVE_AUDIOMIXER + audio_driver_mixer_play_scroll_sound(false); +#endif } } diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index b02a698b70..c9e47c8e2e 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -49,6 +49,7 @@ #include "../../core_info.h" #include "../../configuration.h" +#include "../../audio/audio_driver.h" #include "../../tasks/tasks_internal.h" #include "../../runtime_file.h" #include "../../file_path_special.h" @@ -9134,6 +9135,10 @@ static enum menu_action materialui_parse_menu_entry_action( * > If current selection is off screen, * auto select 'middle' item */ materialui_auto_select_onscreen_entry(mui, MUI_ONSCREEN_ENTRY_CENTRE); +#ifdef HAVE_AUDIOMIXER + if (menu_entries_get_size() != 1) + audio_driver_mixer_play_scroll_sound(action == MENU_ACTION_UP); +#endif break; case MENU_ACTION_LEFT: case MENU_ACTION_RIGHT: @@ -9145,14 +9150,18 @@ static enum menu_action materialui_parse_menu_entry_action( { retro_time_t current_time = menu_driver_get_current_time(); size_t scroll_accel = 0; - - /* Determine whether input repeat is + /* Determine whether in put repeat is * currently active * > This is always true when scroll * acceleration is greater than zero */ menu_driver_ctl(MENU_NAVIGATION_CTL_GET_SCROLL_ACCEL, &scroll_accel); +#ifdef HAVE_AUDIOMIXER + if ((current_time - mui->last_tab_switch_time) >= MUI_TAB_SWITCH_REPEAT_DELAY || + scroll_accel <= 0) + audio_driver_mixer_play_scroll_sound(action == MENU_ACTION_RIGHT); +#endif if (scroll_accel > 0) { /* Ignore input action if tab switch period @@ -9205,8 +9214,17 @@ static enum menu_action materialui_parse_menu_entry_action( } /* > ...otherwise, if current selection is off * screen, auto select *last* item */ - else + else + { materialui_auto_select_onscreen_entry(mui, MUI_ONSCREEN_ENTRY_LAST); +#ifdef HAVE_AUDIOMIXER + /* > The playlist if above leads to code + * that already plays the scrolling sound correctly, + * So this is for every case that isn't the playlist tab. */ + if (menu_navigation_get_selection() != 0) + audio_driver_mixer_play_scroll_sound(true); +#endif + } break; case MENU_ACTION_SCROLL_DOWN: /* Ascend alphabet (A towards Z) @@ -9220,8 +9238,13 @@ static enum menu_action materialui_parse_menu_entry_action( } /* > ...otherwise, if current selection is off * screen, auto select *first* item */ - else + else { materialui_auto_select_onscreen_entry(mui, MUI_ONSCREEN_ENTRY_FIRST); +#ifdef HAVE_AUDIOMIXER + if (menu_navigation_get_selection() != menu_entries_get_size() - 1) + audio_driver_mixer_play_scroll_sound(false); +#endif + } break; case MENU_ACTION_SCAN: /* - If this is a playlist, 'scan' command is used diff --git a/menu/drivers/ozone.c b/menu/drivers/ozone.c index c59d531626..317fafa6d5 100644 --- a/menu/drivers/ozone.c +++ b/menu/drivers/ozone.c @@ -8099,7 +8099,10 @@ static enum menu_action ozone_parse_menu_entry_action( new_action = MENU_ACTION_ACCESSIBILITY_SPEAK_TITLE; break; } - +#ifdef HAVE_AUDIOMIXER + if (selection != 0) + audio_driver_mixer_play_scroll_sound(true); +#endif if ( (ozone->flags2 & OZONE_FLAG2_SHOW_FULLSCREEN_THUMBNAILS) && (ozone->is_quick_menu)) return MENU_ACTION_NOOP; @@ -8120,7 +8123,10 @@ static enum menu_action ozone_parse_menu_entry_action( new_action = MENU_ACTION_ACCESSIBILITY_SPEAK_TITLE; break; } - +#ifdef HAVE_AUDIOMIXER + if (selection < selection_total - 1) + audio_driver_mixer_play_scroll_sound(false); +#endif if ( (ozone->flags2 & OZONE_FLAG2_SHOW_FULLSCREEN_THUMBNAILS) && (ozone->is_quick_menu)) return MENU_ACTION_NOOP; @@ -8187,11 +8193,11 @@ static int ozone_menu_entry_action( /* Check whether current selection has changed * (due to automatic on screen entry selection...) */ size_t new_selection = menu_navigation_get_selection(); + if (new_selection != selection) { /* Selection has changed - must update * entry pointer */ - MENU_ENTRY_INITIALIZE(new_entry); menu_entry_get(&new_entry, 0, new_selection, NULL, true); entry_ptr = &new_entry; diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index 218eb6d6fe..85efeae3d6 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -51,6 +51,7 @@ #include "../../input/input_osk.h" #include "../../configuration.h" +#include "../../audio/audio_driver.h" #include "../../file_path_special.h" #include "../../gfx/drivers_font_renderer/bitmap.h" @@ -7989,6 +7990,20 @@ static enum menu_action rgui_parse_menu_entry_action( if ( (rgui->flags & RGUI_FLAG_SHOW_FULLSCREEN_THUMBNAIL) && (rgui->is_quick_menu)) new_action = MENU_ACTION_NOOP; +#ifdef HAVE_AUDIOMIXER + if (action == MENU_ACTION_UP || action == MENU_ACTION_DOWN) + { + if (menu_entries_get_size() != 1) + audio_driver_mixer_play_scroll_sound(action == MENU_ACTION_UP); + } + else + { + size_t selection = menu_navigation_get_selection(); + if ((action == MENU_ACTION_SCROLL_UP && selection != 0) || + (action == MENU_ACTION_SCROLL_DOWN && selection != menu_entries_get_size() - 1)) + audio_driver_mixer_play_scroll_sound(action == MENU_ACTION_SCROLL_UP); + } +#endif break; case MENU_ACTION_LEFT: case MENU_ACTION_RIGHT: diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 4897febc6d..dd51c77e06 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -55,6 +55,7 @@ #include "../../file_path_special.h" #include "../../configuration.h" +#include "../../audio/audio_driver.h" #include "../../tasks/tasks_internal.h" @@ -4489,6 +4490,11 @@ static enum menu_action xmb_parse_menu_entry_action( menu_driver_ctl(MENU_NAVIGATION_CTL_GET_SCROLL_ACCEL, &scroll_accel); +#ifdef HAVE_AUDIOMIXER + if ((current_time - xmb->last_tab_switch_time) >= XMB_TAB_SWITCH_REPEAT_DELAY || + scroll_accel <= 0) + audio_driver_mixer_play_scroll_sound(action == MENU_ACTION_RIGHT); +#endif if (scroll_accel > 0) { /* Ignore input action if tab switch period @@ -4585,6 +4591,20 @@ static enum menu_action xmb_parse_menu_entry_action( case MENU_ACTION_DOWN: case MENU_ACTION_SCROLL_UP: case MENU_ACTION_SCROLL_DOWN: +#ifdef HAVE_AUDIOMIXER + if (action == MENU_ACTION_UP || action == MENU_ACTION_DOWN) + { + if (menu_entries_get_size() != 1) + audio_driver_mixer_play_scroll_sound(action == MENU_ACTION_UP); + } + else + { + size_t selection = menu_navigation_get_selection(); + if ((action == MENU_ACTION_SCROLL_UP && selection != 0) || + (action == MENU_ACTION_SCROLL_DOWN && selection != menu_entries_get_size() - 1)) + audio_driver_mixer_play_scroll_sound(action == MENU_ACTION_SCROLL_UP); + } +#endif if (xmb->show_fullscreen_thumbnails && xmb->is_quick_menu) return MENU_ACTION_NOOP; break;