diff --git a/Source/Core/Core/Src/HW/EXI_DeviceMic.cpp b/Source/Core/Core/Src/HW/EXI_DeviceMic.cpp index 8e37fe7d75..b13f22f785 100644 --- a/Source/Core/Core/Src/HW/EXI_DeviceMic.cpp +++ b/Source/Core/Core/Src/HW/EXI_DeviceMic.cpp @@ -208,9 +208,7 @@ void CEXIMic::TransferByte(u8 &byte) case cmdGetStatus: if (pos == 0) { - SPADStatus silly; - Pad::GetStatus(0, &silly); - status.button = !!(silly.button & PAD_BUTTON_A); + status.button = Pad::GetMicButton(0); // TODO: slot A/B -> 0/1 } byte = status.U8[pos ^ 1]; diff --git a/Source/Core/Core/Src/HW/GCPad.cpp b/Source/Core/Core/Src/HW/GCPad.cpp index 8027c82db5..65b920409e 100644 --- a/Source/Core/Core/Src/HW/GCPad.cpp +++ b/Source/Core/Core/Src/HW/GCPad.cpp @@ -107,4 +107,15 @@ void Rumble(u8 _numPAD, unsigned int _uType, unsigned int _uStrength) } } +bool GetMicButton(u8 pad) +{ + + std::unique_lock lk(g_plugin.controls_lock, std::try_to_lock); + + if (!lk.owns_lock()) + return false; + + return ((GCPad*)g_plugin.controllers[pad])->GetMicButton(); +} + } diff --git a/Source/Core/Core/Src/HW/GCPad.h b/Source/Core/Core/Src/HW/GCPad.h index c3e1ace61e..f7f6af2f20 100644 --- a/Source/Core/Core/Src/HW/GCPad.h +++ b/Source/Core/Core/Src/HW/GCPad.h @@ -33,6 +33,7 @@ InputPlugin *GetPlugin(); void GetStatus(u8 _numPAD, SPADStatus* _pPADStatus); void Rumble(u8 _numPAD, unsigned int _uType, unsigned int _uStrength); +bool GetMicButton(u8 pad); } #endif diff --git a/Source/Core/Core/Src/HW/GCPadEmu.cpp b/Source/Core/Core/Src/HW/GCPadEmu.cpp index 47e32b1efc..837c9104cc 100644 --- a/Source/Core/Core/Src/HW/GCPadEmu.cpp +++ b/Source/Core/Core/Src/HW/GCPadEmu.cpp @@ -25,7 +25,8 @@ const u16 button_bitmasks[] = PAD_BUTTON_X, PAD_BUTTON_Y, PAD_TRIGGER_Z, - PAD_BUTTON_START + PAD_BUTTON_START, + 0 // MIC HAX }; const u16 trigger_bitmasks[] = @@ -47,6 +48,7 @@ const char* const named_buttons[] = "Y", "Z", _trans("Start"), + "Mic" }; const char* const named_triggers[] = @@ -63,10 +65,11 @@ const char* const named_triggers[] = GCPad::GCPad(const unsigned int index) : m_index(index) { + int const mic_hax = index > 1; // buttons groups.push_back(m_buttons = new Buttons(_trans("Buttons"))); - for (unsigned int i=0; i < sizeof(named_buttons)/sizeof(*named_buttons); ++i) + for (unsigned int i=0; i < sizeof(named_buttons)/sizeof(*named_buttons) - mic_hax; ++i) m_buttons->controls.push_back(new ControlGroup::Input(named_buttons[i])); // sticks @@ -203,3 +206,8 @@ void GCPad::LoadDefaults(const ControllerInterface& ciface) set_control(m_triggers, 0, "Q"); // L set_control(m_triggers, 1, "W"); // R } + +bool GCPad::GetMicButton() const +{ + return m_buttons->controls.back()->control_ref->State(); +} diff --git a/Source/Core/Core/Src/HW/GCPadEmu.h b/Source/Core/Core/Src/HW/GCPadEmu.h index 5fa67e284f..5185ff221c 100644 --- a/Source/Core/Core/Src/HW/GCPadEmu.h +++ b/Source/Core/Core/Src/HW/GCPadEmu.h @@ -29,6 +29,8 @@ public: GCPad(const unsigned int index); void GetInput(SPADStatus* const pad); void SetOutput(const bool on); + + bool GetMicButton() const; std::string GetName() const;