Added mic button to gcpad 1 and 2 diags. Both mic slots use gcpad 1 currently. Totally untested.

This commit is contained in:
Jordan Woyak 2011-10-09 04:27:43 -05:00
parent 3790a16ece
commit ceef98b882
5 changed files with 25 additions and 5 deletions

View File

@ -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];

View File

@ -107,4 +107,15 @@ void Rumble(u8 _numPAD, unsigned int _uType, unsigned int _uStrength)
}
}
bool GetMicButton(u8 pad)
{
std::unique_lock<std::recursive_mutex> lk(g_plugin.controls_lock, std::try_to_lock);
if (!lk.owns_lock())
return false;
return ((GCPad*)g_plugin.controllers[pad])->GetMicButton();
}
}

View File

@ -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

View File

@ -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();
}

View File

@ -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;