HotkeyManager: Add HK_TOGGLE_WII_SPEAK_MUTE

This commit is contained in:
Sepalani
2025-05-07 21:27:50 +04:00
parent 4efbd35a5e
commit eff334524a
7 changed files with 35 additions and 9 deletions

View File

@ -88,6 +88,7 @@ constexpr std::array<const char*, NUM_HOTKEYS> s_hotkey_labels{{
_trans("Connect Balance Board"),
_trans("Toggle SD Card"),
_trans("Toggle USB Keyboard"),
_trans("Toggle Wii Speak Mute"),
_trans("Next Profile"),
_trans("Previous Profile"),
@ -345,7 +346,7 @@ constexpr std::array<HotkeyGroupInfo, NUM_HOTKEY_GROUPS> s_groups_info = {
{_trans("Stepping"), HK_STEP, HK_SKIP},
{_trans("Program Counter"), HK_SHOW_PC, HK_SET_PC},
{_trans("Breakpoint"), HK_BP_TOGGLE, HK_MBP_ADD},
{_trans("Wii"), HK_TRIGGER_SYNC_BUTTON, HK_TOGGLE_USB_KEYBOARD},
{_trans("Wii"), HK_TRIGGER_SYNC_BUTTON, HK_TOGGLE_WII_SPEAK_MUTE},
{_trans("Controller Profile 1"), HK_NEXT_WIIMOTE_PROFILE_1, HK_PREV_GAME_WIIMOTE_PROFILE_1},
{_trans("Controller Profile 2"), HK_NEXT_WIIMOTE_PROFILE_2, HK_PREV_GAME_WIIMOTE_PROFILE_2},
{_trans("Controller Profile 3"), HK_NEXT_WIIMOTE_PROFILE_3, HK_PREV_GAME_WIIMOTE_PROFILE_3},

View File

@ -74,6 +74,7 @@ enum Hotkey
HK_BALANCEBOARD_CONNECT,
HK_TOGGLE_SD_CARD,
HK_TOGGLE_USB_KEYBOARD,
HK_TOGGLE_WII_SPEAK_MUTE,
HK_NEXT_WIIMOTE_PROFILE_1,
HK_PREV_WIIMOTE_PROFILE_1,

View File

@ -61,8 +61,11 @@ void WiiSpeakWindow::CreateMainWindow()
auto* config_layout = new QHBoxLayout();
auto checkbox_mic_muted = new QCheckBox(tr("Mute"), this);
checkbox_mic_muted->setChecked(Config::Get(Config::MAIN_WII_SPEAK_MUTED));
connect(checkbox_mic_muted, &QCheckBox::toggled, this, &WiiSpeakWindow::SetWiiSpeakMuted);
checkbox_mic_muted->setChecked(Settings::Instance().IsWiiSpeakMuted());
connect(&Settings::Instance(), &Settings::WiiSpeakMuteChanged, checkbox_mic_muted,
&QCheckBox::setChecked);
connect(checkbox_mic_muted, &QCheckBox::toggled, &Settings::Instance(),
&Settings::SetWiiSpeakMuted);
checkbox_mic_muted->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
config_layout->addWidget(checkbox_mic_muted);
@ -122,11 +125,6 @@ void WiiSpeakWindow::EmulateWiiSpeak(bool emulate)
Config::SetBaseOrCurrent(Config::MAIN_EMULATE_WII_SPEAK, emulate);
}
void WiiSpeakWindow::SetWiiSpeakMuted(bool muted)
{
Config::SetBaseOrCurrent(Config::MAIN_WII_SPEAK_MUTED, muted);
}
void WiiSpeakWindow::OnEmulationStateChanged(Core::State state)
{
const bool running = state != Core::State::Uninitialized;

View File

@ -21,7 +21,6 @@ private:
void CreateMainWindow();
void OnEmulationStateChanged(Core::State state);
void EmulateWiiSpeak(bool emulate);
void SetWiiSpeakMuted(bool muted);
void OnInputDeviceChange();
QCheckBox* m_checkbox_enabled;

View File

@ -296,6 +296,15 @@ void HotkeyScheduler::Run()
Settings::Instance().SetUSBKeyboardConnected(
!Settings::Instance().IsUSBKeyboardConnected());
}
if (IsHotkey(HK_TOGGLE_WII_SPEAK_MUTE))
{
const bool muted = !Settings::Instance().IsWiiSpeakMuted();
Settings::Instance().SetWiiSpeakMuted(muted);
// i18n: Wii Speak (un)muted notification message
const QString msg = tr("Wii Speak %1").arg(muted ? tr("muted") : tr("unmuted"));
OSD::AddMessage(msg.toStdString());
}
}
if (IsHotkey(HK_PREV_WIIMOTE_PROFILE_1))

View File

@ -795,6 +795,20 @@ void Settings::SetUSBKeyboardConnected(bool connected)
}
}
bool Settings::IsWiiSpeakMuted() const
{
return Config::Get(Config::MAIN_WII_SPEAK_MUTED);
}
void Settings::SetWiiSpeakMuted(bool muted)
{
if (IsWiiSpeakMuted() == muted)
return;
Config::SetBaseOrCurrent(Config::MAIN_WII_SPEAK_MUTED, muted);
emit WiiSpeakMuteChanged(muted);
}
void Settings::SetIsContinuouslyFrameStepping(bool is_stepping)
{
m_continuously_frame_stepping = is_stepping;

View File

@ -119,6 +119,9 @@ public:
bool IsUSBKeyboardConnected() const;
void SetUSBKeyboardConnected(bool connected);
bool IsWiiSpeakMuted() const;
void SetWiiSpeakMuted(bool muted);
void SetIsContinuouslyFrameStepping(bool is_stepping);
bool GetIsContinuouslyFrameStepping() const;
@ -222,6 +225,7 @@ signals:
void DevicesChanged();
void SDCardInsertionChanged(bool inserted);
void USBKeyboardConnectionChanged(bool connected);
void WiiSpeakMuteChanged(bool muted);
void EnableGfxModsChanged(bool enabled);
private: