From 431929fa1d222ce31a3f39e5e859c085832c0862 Mon Sep 17 00:00:00 2001 From: aldelaro5 Date: Sun, 4 Dec 2016 14:17:27 -0500 Subject: [PATCH 1/2] Moved the Mic button of the GCPad to its own group. This is needed to separate it from the GCPad input configuration dialog as it would be moved to its own dialog. --- Source/Core/Core/HW/GCPadEmu.cpp | 15 +++++++++------ Source/Core/Core/HW/GCPadEmu.h | 2 ++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Source/Core/Core/HW/GCPadEmu.cpp b/Source/Core/Core/HW/GCPadEmu.cpp index 7a533c3762..1dbed8adda 100644 --- a/Source/Core/Core/HW/GCPadEmu.cpp +++ b/Source/Core/Core/HW/GCPadEmu.cpp @@ -24,8 +24,7 @@ static const u16 trigger_bitmasks[] = { static const u16 dpad_bitmasks[] = {PAD_BUTTON_UP, PAD_BUTTON_DOWN, PAD_BUTTON_LEFT, PAD_BUTTON_RIGHT}; -static const char* const named_buttons[] = {"A", "B", "X", "Y", "Z", _trans("Start"), - _trans("Mic")}; +static const char* const named_buttons[] = {"A", "B", "X", "Y", "Z", _trans("Start")}; static const char* const named_triggers[] = { // i18n: The left trigger button (labeled L on real controllers) @@ -39,11 +38,9 @@ static const char* const named_triggers[] = { GCPad::GCPad(const unsigned int index) : m_index(index) { - int const mic_hax = index > 1; - // buttons groups.emplace_back(m_buttons = new Buttons(_trans("Buttons"))); - for (unsigned int i = 0; i < sizeof(named_buttons) / sizeof(*named_buttons) - mic_hax; ++i) + for (unsigned int i = 0; i < sizeof(named_buttons) / sizeof(*named_buttons); ++i) m_buttons->controls.emplace_back(new ControlGroup::Input(named_buttons[i])); // sticks @@ -61,6 +58,10 @@ GCPad::GCPad(const unsigned int index) : m_index(index) groups.emplace_back(m_rumble = new ControlGroup(_trans("Rumble"))); m_rumble->controls.emplace_back(new ControlGroup::Output(_trans("Motor"))); + // Microphone + groups.emplace_back(m_mic = new Buttons(_trans("Microphone"))); + m_mic->controls.emplace_back(new ControlGroup::Input(_trans("Button"))); + // dpad groups.emplace_back(m_dpad = new Buttons(_trans("D-Pad"))); for (auto& named_direction : named_directions) @@ -95,6 +96,8 @@ ControllerEmu::ControlGroup* GCPad::GetGroup(PadGroup group) return m_triggers; case PadGroup::Rumble: return m_rumble; + case PadGroup::Mic: + return m_mic; case PadGroup::Options: return m_options; default: @@ -220,5 +223,5 @@ void GCPad::LoadDefaults(const ControllerInterface& ciface) bool GCPad::GetMicButton() const { auto lock = ControllerEmu::GetStateLock(); - return (0.0f != m_buttons->controls.back()->control_ref->State()); + return (0.0f != m_mic->controls.back()->control_ref->State()); } diff --git a/Source/Core/Core/HW/GCPadEmu.h b/Source/Core/Core/HW/GCPadEmu.h index 8969ef6333..067c3f2720 100644 --- a/Source/Core/Core/HW/GCPadEmu.h +++ b/Source/Core/Core/HW/GCPadEmu.h @@ -18,6 +18,7 @@ enum class PadGroup DPad, Triggers, Rumble, + Mic, Options }; @@ -43,6 +44,7 @@ private: Buttons* m_dpad; MixedTriggers* m_triggers; ControlGroup* m_rumble; + Buttons* m_mic; ControlGroup* m_options; const unsigned int m_index; From 9ff95c58fab7be00c8fe494606f956b6bc60fb1d Mon Sep 17 00:00:00 2001 From: aldelaro5 Date: Sun, 4 Dec 2016 16:28:44 -0500 Subject: [PATCH 2/2] Add a special input configuration dialog for the GameCube Mic This is more logical as the mic is plugged into an EXI slot so it should be configured via the GameCube config dialog. This also allows to pass the right port number for the new dialog. --- Source/Core/DolphinWX/CMakeLists.txt | 1 + .../DolphinWX/Config/GameCubeConfigPane.cpp | 30 +++++++++++++--- .../DolphinWX/Config/GameCubeConfigPane.h | 1 + Source/Core/DolphinWX/DolphinWX.vcxproj | 2 ++ .../Core/DolphinWX/DolphinWX.vcxproj.filters | 6 ++++ .../DolphinWX/Input/MicButtonConfigDiag.cpp | 36 +++++++++++++++++++ .../DolphinWX/Input/MicButtonConfigDiag.h | 14 ++++++++ 7 files changed, 85 insertions(+), 5 deletions(-) create mode 100644 Source/Core/DolphinWX/Input/MicButtonConfigDiag.cpp create mode 100644 Source/Core/DolphinWX/Input/MicButtonConfigDiag.h diff --git a/Source/Core/DolphinWX/CMakeLists.txt b/Source/Core/DolphinWX/CMakeLists.txt index 31927c0422..05a2071492 100644 --- a/Source/Core/DolphinWX/CMakeLists.txt +++ b/Source/Core/DolphinWX/CMakeLists.txt @@ -46,6 +46,7 @@ set(GUI_SRCS Input/InputConfigDiagBitmaps.cpp Input/HotkeyInputConfigDiag.cpp Input/GCPadInputConfigDiag.cpp + Input/MicButtonConfigDiag.cpp Input/GCKeyboardInputConfigDiag.cpp Input/WiimoteInputConfigDiag.cpp Input/NunchukInputConfigDiag.cpp diff --git a/Source/Core/DolphinWX/Config/GameCubeConfigPane.cpp b/Source/Core/DolphinWX/Config/GameCubeConfigPane.cpp index fd127fdc90..2b866d49ce 100644 --- a/Source/Core/DolphinWX/Config/GameCubeConfigPane.cpp +++ b/Source/Core/DolphinWX/Config/GameCubeConfigPane.cpp @@ -4,6 +4,7 @@ #include "DolphinWX/Config/GameCubeConfigPane.h" +#include #include #include @@ -22,8 +23,10 @@ #include "Core/Core.h" #include "Core/HW/EXI.h" #include "Core/HW/GCMemcard.h" +#include "Core/HW/GCPad.h" #include "Core/NetPlayProto.h" #include "DolphinWX/Config/ConfigMain.h" +#include "DolphinWX/Input/MicButtonConfigDiag.h" #include "DolphinWX/WxEventUtils.h" #include "DolphinWX/WxUtils.h" @@ -167,6 +170,7 @@ void GameCubeConfigPane::LoadGUIValues() for (int i = 0; i < 3; ++i) { bool isMemcard = false; + bool isMic = false; // Add strings to the wxChoice list, the third wxChoice is the SP1 slot if (i == 2) @@ -192,7 +196,7 @@ void GameCubeConfigPane::LoadGUIValues() isMemcard = m_exi_devices[i]->SetStringSelection(slot_devices[5]); break; case EXIDEVICE_MIC: - m_exi_devices[i]->SetStringSelection(slot_devices[6]); + isMic = m_exi_devices[i]->SetStringSelection(slot_devices[6]); break; case EXIDEVICE_ETH: m_exi_devices[i]->SetStringSelection(sp1_devices[2]); @@ -203,7 +207,7 @@ void GameCubeConfigPane::LoadGUIValues() break; } - if (!isMemcard && i < 2) + if (!isMemcard && !isMic && i < 2) m_memcard_path[i]->Disable(); } } @@ -265,14 +269,30 @@ void GameCubeConfigPane::OnSP1Changed(wxCommandEvent& event) ChooseEXIDevice(event.GetString(), 2); } +void GameCubeConfigPane::HandleEXISlotChange(int slot, const wxString& title) +{ + assert(slot >= 0 && slot <= 1); + + if (!m_exi_devices[slot]->GetStringSelection().compare(_(EXIDEV_MIC_STR))) + { + InputConfig* const pad_plugin = Pad::GetConfig(); + MicButtonConfigDialog dialog(this, *pad_plugin, title, slot); + dialog.ShowModal(); + } + else + { + ChooseSlotPath(false, SConfig::GetInstance().m_EXIDevice[slot]); + } +} + void GameCubeConfigPane::OnSlotAButtonClick(wxCommandEvent& event) { - ChooseSlotPath(true, SConfig::GetInstance().m_EXIDevice[0]); + HandleEXISlotChange(0, wxString(_("GameCube Microphone Slot A"))); } void GameCubeConfigPane::OnSlotBButtonClick(wxCommandEvent& event) { - ChooseSlotPath(false, SConfig::GetInstance().m_EXIDevice[1]); + HandleEXISlotChange(1, wxString(_("GameCube Microphone Slot B"))); } void GameCubeConfigPane::ChooseEXIDevice(const wxString& deviceName, int deviceNum) @@ -297,7 +317,7 @@ void GameCubeConfigPane::ChooseEXIDevice(const wxString& deviceName, int deviceN tempType = EXIDEVICE_DUMMY; // Gray out the memcard path button if we're not on a memcard or AGP - if (tempType == EXIDEVICE_MEMORYCARD || tempType == EXIDEVICE_AGP) + if (tempType == EXIDEVICE_MEMORYCARD || tempType == EXIDEVICE_AGP || tempType == EXIDEVICE_MIC) m_memcard_path[deviceNum]->Enable(); else if (deviceNum == 0 || deviceNum == 1) m_memcard_path[deviceNum]->Disable(); diff --git a/Source/Core/DolphinWX/Config/GameCubeConfigPane.h b/Source/Core/DolphinWX/Config/GameCubeConfigPane.h index 85ecec9b83..d5b232e67f 100644 --- a/Source/Core/DolphinWX/Config/GameCubeConfigPane.h +++ b/Source/Core/DolphinWX/Config/GameCubeConfigPane.h @@ -34,6 +34,7 @@ private: void OnSlotBButtonClick(wxCommandEvent&); void ChooseEXIDevice(const wxString& device_name, int device_id); + void HandleEXISlotChange(int slot, const wxString& title); void ChooseSlotPath(bool is_slot_a, TEXIDevices device_type); wxArrayString m_ipl_language_strings; diff --git a/Source/Core/DolphinWX/DolphinWX.vcxproj b/Source/Core/DolphinWX/DolphinWX.vcxproj index a4738e1af5..932439f982 100644 --- a/Source/Core/DolphinWX/DolphinWX.vcxproj +++ b/Source/Core/DolphinWX/DolphinWX.vcxproj @@ -106,6 +106,7 @@ + @@ -185,6 +186,7 @@ + diff --git a/Source/Core/DolphinWX/DolphinWX.vcxproj.filters b/Source/Core/DolphinWX/DolphinWX.vcxproj.filters index eb099a84b3..ac522da116 100644 --- a/Source/Core/DolphinWX/DolphinWX.vcxproj.filters +++ b/Source/Core/DolphinWX/DolphinWX.vcxproj.filters @@ -119,6 +119,9 @@ GUI\InputConfig + + GUI\InputConfig + GUI\InputConfig @@ -332,6 +335,9 @@ GUI\InputConfig + + GUI\InputConfig + GUI\InputConfig diff --git a/Source/Core/DolphinWX/Input/MicButtonConfigDiag.cpp b/Source/Core/DolphinWX/Input/MicButtonConfigDiag.cpp new file mode 100644 index 0000000000..f42571bfe5 --- /dev/null +++ b/Source/Core/DolphinWX/Input/MicButtonConfigDiag.cpp @@ -0,0 +1,36 @@ +// Copyright 2016 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include "DolphinWX/Input/MicButtonConfigDiag.h" + +#include "Core/HW/GCPad.h" +#include "Core/HW/GCPadEmu.h" + +MicButtonConfigDialog::MicButtonConfigDialog(wxWindow* const parent, InputConfig& config, + const wxString& name, const int port_num) + : InputConfigDialog(parent, config, name, port_num) +{ + const int space5 = FromDIP(5); + + auto* const device_chooser = CreateDeviceChooserGroupBox(); + + auto* const group_box_button = + new ControlGroupBox(Pad::GetGroup(port_num, PadGroup::Mic), this, this); + + auto* const controls_sizer = new wxBoxSizer(wxHORIZONTAL); + controls_sizer->Add(group_box_button, 0, wxEXPAND); + + auto* const szr_main = new wxBoxSizer(wxVERTICAL); + szr_main->AddSpacer(space5); + szr_main->Add(device_chooser, 0, wxEXPAND); + szr_main->AddSpacer(space5); + szr_main->Add(controls_sizer, 1, wxEXPAND | wxLEFT | wxRIGHT, space5); + szr_main->AddSpacer(space5); + szr_main->Add(CreateButtonSizer(wxCLOSE | wxNO_DEFAULT), 0, wxEXPAND | wxLEFT | wxRIGHT, space5); + szr_main->AddSpacer(space5); + + SetSizer(szr_main); + Center(); + UpdateGUI(); +} diff --git a/Source/Core/DolphinWX/Input/MicButtonConfigDiag.h b/Source/Core/DolphinWX/Input/MicButtonConfigDiag.h new file mode 100644 index 0000000000..49e9089031 --- /dev/null +++ b/Source/Core/DolphinWX/Input/MicButtonConfigDiag.h @@ -0,0 +1,14 @@ +// Copyright 2016 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#pragma once + +#include "DolphinWX/Input/InputConfigDiag.h" + +class MicButtonConfigDialog final : public InputConfigDialog +{ +public: + MicButtonConfigDialog(wxWindow* parent, InputConfig& config, const wxString& name, + int port_num = 0); +};