mirror of
https://github.com/libretro/RetroArch
synced 2025-03-28 19:20:35 +00:00
Better scrolling sound implementation, add new 'notice back' sound
The closing info box sound (NOTICE_BACK) plays if you have the regular notice sound on, implemented generally. audio_driver_mixer_play_menu_sound(i) will now stop sound i before playing it, so when you for example, cancel in rapid succession, it will properly play all canceling sound effects instead of not doing anything if the sound is already playing. This scrolling implementation is a lot more general than the first one, to the point where RGUI plays all the correct sounds without any special additions. However, the Ozone sidebar scrolling or category switching in XMB or MaterialUI are still handled inside their driver .c files. This implementation also fixes an issue where if wraparound was disabled the sound would still play if you held on a direction. I've also fixed it manually for XMB category switching, since it's still handled there individually (turns out, Ozone sidebar and MaterialUI categories just don't respect the no wraparound option, so there's no need to implement a fix there as well)
This commit is contained in:
parent
ab27029f2b
commit
8a127eff02
@ -30,7 +30,7 @@ RETRO_BEGIN_DECLS
|
||||
|
||||
#define AUDIO_MIXER_MAX_STREAMS 16
|
||||
|
||||
#define AUDIO_MIXER_MAX_SYSTEM_STREAMS (AUDIO_MIXER_MAX_STREAMS + 7)
|
||||
#define AUDIO_MIXER_MAX_SYSTEM_STREAMS (AUDIO_MIXER_MAX_STREAMS + 8)
|
||||
|
||||
/* do not define more than (MAX_SYSTEM_STREAMS - MAX_STREAMS) */
|
||||
enum audio_mixer_system_slot
|
||||
@ -38,6 +38,7 @@ enum audio_mixer_system_slot
|
||||
AUDIO_MIXER_SYSTEM_SLOT_OK = AUDIO_MIXER_MAX_STREAMS,
|
||||
AUDIO_MIXER_SYSTEM_SLOT_CANCEL,
|
||||
AUDIO_MIXER_SYSTEM_SLOT_NOTICE,
|
||||
AUDIO_MIXER_SYSTEM_SLOT_NOTICE_BACK,
|
||||
AUDIO_MIXER_SYSTEM_SLOT_BGM,
|
||||
AUDIO_MIXER_SYSTEM_SLOT_ACHIEVEMENT_UNLOCK,
|
||||
AUDIO_MIXER_SYSTEM_SLOT_UP,
|
||||
|
@ -1348,6 +1348,7 @@ void audio_driver_load_system_sounds(void)
|
||||
const char *path_ok = NULL;
|
||||
const char *path_cancel = NULL;
|
||||
const char *path_notice = NULL;
|
||||
const char *path_notice_back = NULL;
|
||||
const char *path_bgm = NULL;
|
||||
const char *path_cheevo_unlock = NULL;
|
||||
const char *path_up = NULL;
|
||||
@ -1413,6 +1414,8 @@ void audio_driver_load_system_sounds(void)
|
||||
path_cancel = path;
|
||||
else if (string_is_equal_noncase(basename_noext, "notice"))
|
||||
path_notice = path;
|
||||
else if (string_is_equal_noncase(basename_noext, "notice_back"))
|
||||
path_notice_back = path;
|
||||
else if (string_is_equal_noncase(basename_noext, "bgm"))
|
||||
path_bgm = path;
|
||||
else if (string_is_equal_noncase(basename_noext, "unlock"))
|
||||
@ -1428,8 +1431,12 @@ void audio_driver_load_system_sounds(void)
|
||||
task_push_audio_mixer_load(path_ok, NULL, NULL, true, AUDIO_MIXER_SLOT_SELECTION_MANUAL, AUDIO_MIXER_SYSTEM_SLOT_OK);
|
||||
if (path_cancel && audio_enable_menu_cancel)
|
||||
task_push_audio_mixer_load(path_cancel, NULL, NULL, true, AUDIO_MIXER_SLOT_SELECTION_MANUAL, AUDIO_MIXER_SYSTEM_SLOT_CANCEL);
|
||||
if (path_notice && audio_enable_menu_notice)
|
||||
task_push_audio_mixer_load(path_notice, NULL, NULL, true, AUDIO_MIXER_SLOT_SELECTION_MANUAL, AUDIO_MIXER_SYSTEM_SLOT_NOTICE);
|
||||
if (audio_enable_menu_notice) {
|
||||
if (path_notice)
|
||||
task_push_audio_mixer_load(path_notice, NULL, NULL, true, AUDIO_MIXER_SLOT_SELECTION_MANUAL, AUDIO_MIXER_SYSTEM_SLOT_NOTICE);
|
||||
if (path_notice_back)
|
||||
task_push_audio_mixer_load(path_notice_back, NULL, NULL, true, AUDIO_MIXER_SLOT_SELECTION_MANUAL, AUDIO_MIXER_SYSTEM_SLOT_NOTICE_BACK);
|
||||
}
|
||||
if (path_bgm && audio_enable_menu_bgm)
|
||||
task_push_audio_mixer_load(path_bgm, audio_driver_load_menu_bgm_callback, NULL, true, AUDIO_MIXER_SLOT_SELECTION_MANUAL, AUDIO_MIXER_SYSTEM_SLOT_BGM);
|
||||
if (path_cheevo_unlock && audio_enable_cheevo_unlock)
|
||||
@ -1463,6 +1470,7 @@ void audio_driver_mixer_play_menu_sound_looped(unsigned i)
|
||||
void audio_driver_mixer_play_menu_sound(unsigned i)
|
||||
{
|
||||
audio_driver_st.mixer_streams[i].stop_cb = audio_mixer_menu_stop_cb;
|
||||
audio_driver_mixer_stop_stream(i);
|
||||
audio_driver_mixer_play_stream_internal(i, AUDIO_STREAM_STATE_PLAYING);
|
||||
}
|
||||
|
||||
@ -1472,10 +1480,7 @@ void audio_driver_mixer_play_scroll_sound(bool direction_up)
|
||||
bool audio_enable_menu = settings->bools.audio_enable_menu;
|
||||
bool audio_enable_menu_scroll = settings->bools.audio_enable_menu_scroll;
|
||||
if (audio_enable_menu && audio_enable_menu_scroll)
|
||||
{
|
||||
audio_driver_mixer_stop_stream(direction_up ? AUDIO_MIXER_SYSTEM_SLOT_UP : AUDIO_MIXER_SYSTEM_SLOT_DOWN);
|
||||
audio_driver_mixer_play_menu_sound(direction_up ? AUDIO_MIXER_SYSTEM_SLOT_UP : AUDIO_MIXER_SYSTEM_SLOT_DOWN);
|
||||
}
|
||||
audio_driver_mixer_play_menu_sound(direction_up ? AUDIO_MIXER_SYSTEM_SLOT_UP : AUDIO_MIXER_SYSTEM_SLOT_DOWN);
|
||||
}
|
||||
|
||||
void audio_driver_mixer_play_stream_looped(unsigned i)
|
||||
|
@ -9135,10 +9135,6 @@ 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:
|
||||
@ -9214,17 +9210,9 @@ 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)
|
||||
@ -9238,14 +9226,9 @@ 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
|
||||
|
@ -3990,6 +3990,9 @@ static void ozone_go_to_sidebar(
|
||||
gfx_animation_push(&entry);
|
||||
|
||||
ozone_sidebar_update_collapse(ozone, ozone_collapse_sidebar, true);
|
||||
#ifdef HAVE_AUDIOMIXER
|
||||
audio_driver_mixer_play_scroll_sound(false);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void linebreak_after_colon(char (*str)[255])
|
||||
@ -4281,6 +4284,11 @@ static void ozone_leave_sidebar(
|
||||
gfx_animation_push(&entry);
|
||||
|
||||
ozone_sidebar_update_collapse(ozone, ozone_collapse_sidebar, true);
|
||||
|
||||
#ifdef HAVE_AUDIOMIXER
|
||||
audio_driver_mixer_play_scroll_sound(true);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
static void ozone_free_node(ozone_node_t *node)
|
||||
@ -7879,15 +7887,8 @@ static enum menu_action ozone_parse_menu_entry_action(
|
||||
break;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef HAVE_AUDIOMIXER
|
||||
if (selection_total > 1)
|
||||
audio_driver_mixer_play_scroll_sound(false);
|
||||
#endif
|
||||
if (!menu_navigation_wraparound_enable && selection == selection_total - 1)
|
||||
else if (!menu_navigation_wraparound_enable && selection == selection_total - 1)
|
||||
ozone_start_cursor_wiggle(ozone, MENU_ACTION_DOWN);
|
||||
}
|
||||
|
||||
if ( (ozone->flags2 & OZONE_FLAG2_SHOW_FULLSCREEN_THUMBNAILS)
|
||||
&& (ozone->is_quick_menu))
|
||||
@ -7922,15 +7923,8 @@ static enum menu_action ozone_parse_menu_entry_action(
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef HAVE_AUDIOMIXER
|
||||
if (selection_total > 1)
|
||||
audio_driver_mixer_play_scroll_sound(true);
|
||||
#endif
|
||||
if (!menu_navigation_wraparound_enable && selection == 0)
|
||||
else if (!menu_navigation_wraparound_enable && selection == 0)
|
||||
ozone_start_cursor_wiggle(ozone, MENU_ACTION_UP);
|
||||
}
|
||||
|
||||
if ( (ozone->flags2 & OZONE_FLAG2_SHOW_FULLSCREEN_THUMBNAILS)
|
||||
&& (ozone->is_quick_menu))
|
||||
@ -7974,9 +7968,6 @@ static enum menu_action ozone_parse_menu_entry_action(
|
||||
}
|
||||
|
||||
ozone_go_to_sidebar(ozone, ozone_collapse_sidebar, tag);
|
||||
#ifdef HAVE_AUDIOMIXER
|
||||
audio_driver_mixer_play_scroll_sound(true);
|
||||
#endif
|
||||
new_action = MENU_ACTION_ACCESSIBILITY_SPEAK_TITLE;
|
||||
break;
|
||||
case MENU_ACTION_RIGHT:
|
||||
@ -8005,12 +7996,7 @@ static enum menu_action ozone_parse_menu_entry_action(
|
||||
}
|
||||
|
||||
if (!(ozone->flags & OZONE_FLAG_EMPTY_PLAYLIST))
|
||||
{
|
||||
ozone_leave_sidebar(ozone, ozone_collapse_sidebar, tag);
|
||||
#ifdef HAVE_AUDIOMIXER
|
||||
audio_driver_mixer_play_scroll_sound(false);
|
||||
#endif
|
||||
}
|
||||
|
||||
new_action = MENU_ACTION_ACCESSIBILITY_SPEAK_LABEL;
|
||||
break;
|
||||
@ -8102,10 +8088,6 @@ 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;
|
||||
@ -8126,10 +8108,6 @@ 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;
|
||||
|
@ -51,7 +51,6 @@
|
||||
#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"
|
||||
|
||||
@ -7990,20 +7989,6 @@ 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:
|
||||
|
@ -4491,9 +4491,18 @@ static enum menu_action xmb_parse_menu_entry_action(
|
||||
&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);
|
||||
settings_t *settings = config_get_ptr();
|
||||
size_t category = xmb->categories_selection_ptr;
|
||||
/* We only want the scrolling sound to play if any of the following are true:
|
||||
* 1. Wraparound is enabled (since the category is guaranteed to change)
|
||||
* 2. We're scrolling right, but we aren't on the last category
|
||||
* 3. We're scrolling left, but we aren't on the first category */
|
||||
bool fail_condition = ((action == MENU_ACTION_RIGHT) ? (category == xmb->system_tab_end)
|
||||
: (category == 0)) && !(settings->bools.menu_navigation_wraparound_enable);
|
||||
|
||||
if (((current_time - xmb->last_tab_switch_time) >= XMB_TAB_SWITCH_REPEAT_DELAY ||
|
||||
scroll_accel <= 0) && !fail_condition)
|
||||
audio_driver_mixer_play_scroll_sound(action == MENU_ACTION_RIGHT);
|
||||
#endif
|
||||
if (scroll_accel > 0)
|
||||
{
|
||||
@ -4591,20 +4600,6 @@ 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;
|
||||
|
@ -1193,7 +1193,17 @@ void menu_input_pointer_close_messagebox(struct menu_state *menu_st)
|
||||
/* Determine whether this is a help or info
|
||||
* message box */
|
||||
if (list && list->size)
|
||||
{
|
||||
label = list->list[list->size - 1].label;
|
||||
/* Play sound for closing the info box */
|
||||
#ifdef HAVE_AUDIOMIXER
|
||||
settings_t *settings = config_get_ptr();
|
||||
bool audio_enable_menu = settings->bools.audio_enable_menu;
|
||||
bool audio_enable_menu_notice = settings->bools.audio_enable_menu_notice;
|
||||
if (audio_enable_menu && audio_enable_menu_notice)
|
||||
audio_driver_mixer_play_menu_sound(AUDIO_MIXER_SYSTEM_SLOT_NOTICE_BACK);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Pop stack, if required */
|
||||
if (menu_should_pop_stack(label))
|
||||
@ -7862,6 +7872,14 @@ static int generic_menu_iterate(
|
||||
size_t new_selection_ptr = selection;
|
||||
menu_entries_pop_stack(&new_selection_ptr, 0, 0);
|
||||
menu_st->selection_ptr = selection;
|
||||
/* Play sound for closing the info box */
|
||||
#ifdef HAVE_AUDIOMIXER
|
||||
bool audio_enable_menu = settings->bools.audio_enable_menu;
|
||||
bool audio_enable_menu_notice = settings->bools.audio_enable_menu_notice;
|
||||
if (audio_enable_menu && audio_enable_menu_notice &&
|
||||
string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_INFO_SCREEN)))
|
||||
audio_driver_mixer_play_menu_sound(AUDIO_MIXER_SYSTEM_SLOT_NOTICE_BACK);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (BIT64_GET(menu->state, MENU_STATE_POST_ITERATE))
|
||||
@ -7933,6 +7951,10 @@ int generic_menu_entry_action(
|
||||
|
||||
if (menu_driver_ctx->navigation_decrement)
|
||||
menu_driver_ctx->navigation_decrement(menu_userdata);
|
||||
#ifdef HAVE_AUDIOMIXER
|
||||
if (menu_entries_get_size() != 1)
|
||||
audio_driver_mixer_play_scroll_sound(true);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -7963,6 +7985,10 @@ int generic_menu_entry_action(
|
||||
|
||||
if (menu_driver_ctx->navigation_increment)
|
||||
menu_driver_ctx->navigation_increment(menu_userdata);
|
||||
#ifdef HAVE_AUDIOMIXER
|
||||
if (menu_entries_get_size() != 1)
|
||||
audio_driver_mixer_play_scroll_sound(false);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -7971,6 +7997,10 @@ int generic_menu_entry_action(
|
||||
{
|
||||
if (selection_buf_size > 0)
|
||||
{
|
||||
#ifdef HAVE_AUDIOMIXER
|
||||
if (menu_st->selection_ptr != 0)
|
||||
audio_driver_mixer_play_scroll_sound(false);
|
||||
#endif
|
||||
unsigned scroll_speed = (unsigned)((MAX(scroll_accel, 2) - 2) / 4 + 10);
|
||||
if (!(menu_st->selection_ptr == 0 && !wraparound_enable))
|
||||
{
|
||||
@ -8016,6 +8046,10 @@ int generic_menu_entry_action(
|
||||
{
|
||||
if (selection_buf_size > 0)
|
||||
{
|
||||
#ifdef HAVE_AUDIOMIXER
|
||||
if (menu_st->selection_ptr != menu_entries_get_size() - 1)
|
||||
audio_driver_mixer_play_scroll_sound(false);
|
||||
#endif
|
||||
unsigned scroll_speed = (unsigned)((MAX(scroll_accel, 2) - 2) / 4 + 10);
|
||||
if (!(menu_st->selection_ptr >= selection_buf_size - 1
|
||||
&& !wraparound_enable))
|
||||
|
Loading…
x
Reference in New Issue
Block a user