overlays: use enum for sound effects

This commit is contained in:
Megamouse 2025-11-18 18:28:03 +01:00
parent e938b93f48
commit e2cbbcf646
14 changed files with 69 additions and 41 deletions

View file

@ -1,7 +1,6 @@
#include "stdafx.h" #include "stdafx.h"
#include "../overlay_manager.h" #include "../overlay_manager.h"
#include "overlay_friends_list_dialog.h" #include "overlay_friends_list_dialog.h"
#include "Emu/System.h"
#include "Emu/NP/rpcn_config.h" #include "Emu/NP/rpcn_config.h"
#include "Emu/vfs_config.h" #include "Emu/vfs_config.h"
@ -306,11 +305,11 @@ namespace rsx
} }
} }
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_decide.wav"); play_sound(sound_effect::accept);
return; return;
} }
case pad_button::circle: case pad_button::circle:
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_cancel.wav"); play_sound(sound_effect::cancel);
close_dialog = true; close_dialog = true;
break; break;
case pad_button::square: case pad_button::square:
@ -359,7 +358,7 @@ namespace rsx
// Play a sound unless this is a fast auto repeat which would induce a nasty noise // Play a sound unless this is a fast auto repeat which would induce a nasty noise
else if (!is_auto_repeat || m_auto_repeat_ms_interval >= m_auto_repeat_ms_interval_default) else if (!is_auto_repeat || m_auto_repeat_ms_interval >= m_auto_repeat_ms_interval_default)
{ {
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_cursor.wav"); play_sound(sound_effect::cursor);
} }
} }

View file

@ -1,6 +1,5 @@
#include "stdafx.h" #include "stdafx.h"
#include "overlay_home_menu_message_box.h" #include "overlay_home_menu_message_box.h"
#include "Emu/System.h"
#include "Emu/system_config.h" #include "Emu/system_config.h"
namespace rsx namespace rsx
@ -77,7 +76,7 @@ namespace rsx
{ {
case pad_button::cross: case pad_button::cross:
{ {
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_decide.wav"); play_sound(sound_effect::accept);
if (m_on_accept) if (m_on_accept)
{ {
m_on_accept(); m_on_accept();
@ -86,7 +85,7 @@ namespace rsx
} }
case pad_button::circle: case pad_button::circle:
{ {
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_cancel.wav"); play_sound(sound_effect::cancel);
if (m_on_cancel) if (m_on_cancel)
{ {
m_on_cancel(); m_on_cancel();

View file

@ -160,7 +160,7 @@ namespace rsx
// Play a sound unless this is a fast auto repeat which would induce a nasty noise // Play a sound unless this is a fast auto repeat which would induce a nasty noise
if (!is_auto_repeat || auto_repeat_interval_ms >= user_interface::m_auto_repeat_ms_interval_default) if (!is_auto_repeat || auto_repeat_interval_ms >= user_interface::m_auto_repeat_ms_interval_default)
{ {
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_decide.wav"); play_sound(sound_effect::accept);
} }
return func(button_press); return func(button_press);
} }
@ -169,7 +169,7 @@ namespace rsx
} }
case pad_button::circle: case pad_button::circle:
{ {
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_cancel.wav"); play_sound(sound_effect::cancel);
if (parent) if (parent)
{ {
set_current_page(parent); set_current_page(parent);
@ -244,7 +244,7 @@ namespace rsx
// Play a sound unless this is a fast auto repeat which would induce a nasty noise // Play a sound unless this is a fast auto repeat which would induce a nasty noise
if (!is_auto_repeat || auto_repeat_interval_ms >= user_interface::m_auto_repeat_ms_interval_default) if (!is_auto_repeat || auto_repeat_interval_ms >= user_interface::m_auto_repeat_ms_interval_default)
{ {
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_cursor.wav"); play_sound(sound_effect::cursor);
} }
return page_navigation::stay; return page_navigation::stay;
} }

View file

@ -127,11 +127,11 @@ namespace rsx
{ {
return_code = selection_code::error; return_code = selection_code::error;
} }
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_decide.wav"); play_sound(sound_effect::accept);
close_dialog = true; close_dialog = true;
break; break;
case pad_button::circle: case pad_button::circle:
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_cancel.wav"); play_sound(sound_effect::cancel);
close_dialog = true; close_dialog = true;
break; break;
case pad_button::dpad_up: case pad_button::dpad_up:
@ -167,7 +167,7 @@ namespace rsx
// Play a sound unless this is a fast auto repeat which would induce a nasty noise // Play a sound unless this is a fast auto repeat which would induce a nasty noise
else if (!is_auto_repeat || m_auto_repeat_ms_interval >= m_auto_repeat_ms_interval_default) else if (!is_auto_repeat || m_auto_repeat_ms_interval >= m_auto_repeat_ms_interval_default)
{ {
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_cursor.wav"); play_sound(sound_effect::cursor);
} }
} }

View file

@ -82,7 +82,7 @@ namespace rsx
if (m_list->m_items.empty() || is_auto_repeat) if (m_list->m_items.empty() || is_auto_repeat)
break; break;
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_decide.wav"); play_sound(sound_effect::accept);
if (!get_current_selection().empty()) if (!get_current_selection().empty())
{ {
@ -95,7 +95,7 @@ namespace rsx
close_dialog = true; close_dialog = true;
break; break;
case pad_button::circle: case pad_button::circle:
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_cancel.wav"); play_sound(sound_effect::cancel);
close_dialog = true; close_dialog = true;
break; break;
case pad_button::dpad_up: case pad_button::dpad_up:
@ -131,7 +131,7 @@ namespace rsx
// Play a sound unless this is a fast auto repeat which would induce a nasty noise // Play a sound unless this is a fast auto repeat which would induce a nasty noise
else if (!is_auto_repeat || m_auto_repeat_ms_interval >= m_auto_repeat_ms_interval_default) else if (!is_auto_repeat || m_auto_repeat_ms_interval >= m_auto_repeat_ms_interval_default)
{ {
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_cursor.wav"); play_sound(sound_effect::cursor);
} }
} }

View file

@ -132,7 +132,7 @@ namespace rsx
switch (button_press) switch (button_press)
{ {
case pad_button::circle: case pad_button::circle:
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_cancel.wav"); play_sound(sound_effect::cancel);
close_dialog = true; close_dialog = true;
break; break;
case pad_button::square: case pad_button::square:
@ -172,7 +172,7 @@ namespace rsx
// Play a sound unless this is a fast auto repeat which would induce a nasty noise // Play a sound unless this is a fast auto repeat which would induce a nasty noise
else if (!is_auto_repeat || m_auto_repeat_ms_interval >= m_auto_repeat_ms_interval_default) else if (!is_auto_repeat || m_auto_repeat_ms_interval >= m_auto_repeat_ms_interval_default)
{ {
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_cursor.wav"); play_sound(sound_effect::cursor);
} }
} }

View file

@ -4,7 +4,6 @@
#include "overlay_media_list_dialog.h" #include "overlay_media_list_dialog.h"
#include "Emu/Cell/Modules/cellMusic.h" #include "Emu/Cell/Modules/cellMusic.h"
#include "Emu/System.h"
#include "Emu/VFS.h" #include "Emu/VFS.h"
#include "Utilities/StrUtil.h" #include "Utilities/StrUtil.h"
#include "Utilities/Thread.h" #include "Utilities/Thread.h"
@ -154,13 +153,13 @@ namespace rsx
return_code = m_list->get_selected_index(); return_code = m_list->get_selected_index();
m_stop_input_loop = true; m_stop_input_loop = true;
play_cursor_sound = false; play_cursor_sound = false;
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_decide.wav"); play_sound(sound_effect::accept);
break; break;
case pad_button::circle: case pad_button::circle:
return_code = selection_code::canceled; return_code = selection_code::canceled;
m_stop_input_loop = true; m_stop_input_loop = true;
play_cursor_sound = false; play_cursor_sound = false;
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_cancel.wav"); play_sound(sound_effect::cancel);
break; break;
case pad_button::dpad_up: case pad_button::dpad_up:
m_list->select_previous(); m_list->select_previous();
@ -182,7 +181,7 @@ namespace rsx
// Play a sound unless this is a fast auto repeat which would induce a nasty noise // Play a sound unless this is a fast auto repeat which would induce a nasty noise
if (play_cursor_sound && (!is_auto_repeat || m_auto_repeat_ms_interval >= m_auto_repeat_ms_interval_default)) if (play_cursor_sound && (!is_auto_repeat || m_auto_repeat_ms_interval >= m_auto_repeat_ms_interval_default))
{ {
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_cursor.wav"); play_sound(sound_effect::cursor);
} }
} }

View file

@ -155,7 +155,7 @@ namespace rsx
return_code = CELL_MSGDIALOG_BUTTON_YES; return_code = CELL_MSGDIALOG_BUTTON_YES;
} }
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_decide.wav"); play_sound(sound_effect::accept);
break; break;
} }
case pad_button::circle: case pad_button::circle:
@ -175,7 +175,7 @@ namespace rsx
return_code = CELL_MSGDIALOG_BUTTON_NO; return_code = CELL_MSGDIALOG_BUTTON_NO;
} }
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_cancel.wav"); play_sound(sound_effect::cancel);
break; break;
} }
default: return; default: return;
@ -238,10 +238,7 @@ namespace rsx
if (!type.se_mute_on) if (!type.se_mute_on)
{ {
if (type.se_normal) play_sound(type.se_normal ? sound_effect::dialog_ok : sound_effect::dialog_error);
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_system_ok.wav");
else
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_system_ng.wav");
} }
set_text(text); set_text(text);

View file

@ -823,7 +823,7 @@ namespace rsx
} }
case pad_button::start: case pad_button::start:
{ {
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_oskenter.wav"); play_sound(sound_effect::osk_accept);
Close(CELL_OSKDIALOG_CLOSE_CONFIRM); Close(CELL_OSKDIALOG_CLOSE_CONFIRM);
play_cursor_sound = false; play_cursor_sound = false;
break; break;
@ -840,7 +840,7 @@ namespace rsx
} }
case pad_button::cross: case pad_button::cross:
{ {
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_oskenter.wav"); play_sound(sound_effect::osk_accept);
on_accept(); on_accept();
m_reset_pulse = true; m_reset_pulse = true;
play_cursor_sound = false; play_cursor_sound = false;
@ -848,7 +848,7 @@ namespace rsx
} }
case pad_button::circle: case pad_button::circle:
{ {
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_oskcancel.wav"); play_sound(sound_effect::osk_cancel);
Close(CELL_OSKDIALOG_CLOSE_CANCEL); Close(CELL_OSKDIALOG_CLOSE_CANCEL);
play_cursor_sound = false; play_cursor_sound = false;
break; break;
@ -890,7 +890,7 @@ namespace rsx
// Play a sound unless this is a fast auto repeat which would induce a nasty noise // Play a sound unless this is a fast auto repeat which would induce a nasty noise
if (play_cursor_sound && (!is_auto_repeat || m_auto_repeat_ms_interval >= m_auto_repeat_ms_interval_default)) if (play_cursor_sound && (!is_auto_repeat || m_auto_repeat_ms_interval >= m_auto_repeat_ms_interval_default))
{ {
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_cursor.wav"); play_sound(sound_effect::cursor);
} }
if (m_reset_pulse) if (m_reset_pulse)

View file

@ -2,7 +2,6 @@
#include "overlay_save_dialog.h" #include "overlay_save_dialog.h"
#include "overlay_video.h" #include "overlay_video.h"
#include "Utilities/date_time.h" #include "Utilities/date_time.h"
#include "Emu/System.h"
namespace rsx namespace rsx
{ {
@ -133,11 +132,11 @@ namespace rsx
if (m_no_saves) if (m_no_saves)
break; break;
return_code = m_list->get_selected_index(); return_code = m_list->get_selected_index();
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_decide.wav"); play_sound(sound_effect::accept);
close_dialog = true; close_dialog = true;
break; break;
case pad_button::circle: case pad_button::circle:
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_cancel.wav"); play_sound(sound_effect::cancel);
close_dialog = true; close_dialog = true;
break; break;
case pad_button::dpad_up: case pad_button::dpad_up:
@ -173,7 +172,7 @@ namespace rsx
// Play a sound unless this is a fast auto repeat which would induce a nasty noise // Play a sound unless this is a fast auto repeat which would induce a nasty noise
else if (!is_auto_repeat || m_auto_repeat_ms_interval >= m_auto_repeat_ms_interval_default) else if (!is_auto_repeat || m_auto_repeat_ms_interval >= m_auto_repeat_ms_interval_default)
{ {
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_cursor.wav"); play_sound(sound_effect::cursor);
} }
} }

View file

@ -1,7 +1,6 @@
#include "stdafx.h" #include "stdafx.h"
#include "overlay_trophy_notification.h" #include "overlay_trophy_notification.h"
#include "Emu/Cell/ErrorCodes.h" #include "Emu/Cell/ErrorCodes.h"
#include "Emu/System.h"
namespace rsx namespace rsx
{ {
@ -70,7 +69,7 @@ namespace rsx
{ {
// First tick // First tick
creation_time_us = timestamp_us; creation_time_us = timestamp_us;
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_trophy.wav"); play_sound(sound_effect::trophy);
return; return;
} }

View file

@ -113,11 +113,11 @@ namespace rsx
{ {
return_code = selection_code::error; return_code = selection_code::error;
} }
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_decide.wav"); play_sound(sound_effect::accept);
close_dialog = true; close_dialog = true;
break; break;
case pad_button::circle: case pad_button::circle:
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_cancel.wav"); play_sound(sound_effect::cancel);
close_dialog = true; close_dialog = true;
break; break;
case pad_button::dpad_up: case pad_button::dpad_up:
@ -153,7 +153,7 @@ namespace rsx
// Play a sound unless this is a fast auto repeat which would induce a nasty noise // Play a sound unless this is a fast auto repeat which would induce a nasty noise
else if (!is_auto_repeat || m_auto_repeat_ms_interval >= m_auto_repeat_ms_interval_default) else if (!is_auto_repeat || m_auto_repeat_ms_interval >= m_auto_repeat_ms_interval_default)
{ {
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_cursor.wav"); play_sound(sound_effect::cursor);
} }
} }

View file

@ -15,6 +15,28 @@ namespace rsx
{ {
namespace overlays namespace overlays
{ {
void play_sound(sound_effect sound)
{
const auto get_sound_filename = [sound]()
{
switch (sound)
{
case sound_effect::cursor: return "snd_cursor"sv;
case sound_effect::accept: return "snd_decide"sv;
case sound_effect::cancel: return "snd_cancel"sv;
case sound_effect::osk_accept: return "snd_oskenter"sv;
case sound_effect::osk_cancel: return "snd_oskcancel"sv;
case sound_effect::dialog_ok: return "snd_system_ok"sv;
case sound_effect::dialog_error: return "snd_system_ng"sv;
case sound_effect::trophy: return "snd_trophy"sv;
}
fmt::throw_exception("Unreachable (sound=%d)", static_cast<u32>(sound));
};
Emu.GetCallbacks().play_sound(fmt::format("%ssounds/%s.wav", fs::get_config_dir(), get_sound_filename()));
}
thread_local DECLARE(user_interface::g_thread_bit) = 0; thread_local DECLARE(user_interface::g_thread_bit) = 0;
u32 user_interface::alloc_thread_bit() u32 user_interface::alloc_thread_bit()

View file

@ -17,6 +17,20 @@ namespace rsx
{ {
namespace overlays namespace overlays
{ {
enum class sound_effect
{
cursor,
accept,
cancel,
osk_accept,
osk_cancel,
dialog_ok,
dialog_error,
trophy,
};
void play_sound(sound_effect sound);
// Bitfield of UI signals to overlay manager // Bitfield of UI signals to overlay manager
enum status_bits : u32 enum status_bits : u32
{ {