New Wiimote Plugin: Fix Emulated Wiimote Problem.(fixes issue 3230) Made the "Connected to X Wiimotes" text update on all tabs when clicking "Refresh"/"Pair Up". Some other cleanup.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6216 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Jordan Woyak 2010-09-18 16:43:43 +00:00
parent 7216699fc4
commit eda652b7a0
6 changed files with 63 additions and 53 deletions

View File

@ -435,6 +435,12 @@ bool Joystick::UpdateInput()
bool Joystick::UpdateOutput()
{
size_t ok_count = 0;
DIEFFECT eff;
ZeroMemory(&eff, sizeof(eff));
eff.dwSize = sizeof(DIEFFECT);
eff.dwFlags = DIEFF_CARTESIAN | DIEFF_OBJECTOFFSETS;
std::vector<EffectState>::iterator
i = m_state_out.begin(),
e = m_state_out.end();
@ -444,10 +450,6 @@ bool Joystick::UpdateOutput()
{
if (i->size)
{
DIEFFECT eff;
ZeroMemory(&eff, sizeof(eff));
eff.dwSize = sizeof(DIEFFECT);
eff.dwFlags = DIEFF_CARTESIAN | DIEFF_OBJECTOFFSETS;
eff.cbTypeSpecificParams = i->size;
eff.lpvTypeSpecificParams = i->params;
// set params and start effect

View File

@ -16,16 +16,16 @@ WiimoteConfigPage::WiimoteConfigPage(wxWindow* const parent, const int index)
, m_index(index)
{
// input source
m_input_src_choice = new wxChoice(this, -1, wxDefaultPosition);
m_input_src_choice->Append(wxT("None"));
m_input_src_choice->Append(wxT("Emulated Wiimote"));
m_input_src_choice->Append(wxT("Real Wiimote"));
m_input_src_choice->Append(wxT("Hybrid Wiimote"));
m_input_src_choice->Select(g_wiimote_sources[m_index]);
_connect_macro_(m_input_src_choice, WiimoteConfigPage::SelectSource, wxEVT_COMMAND_CHOICE_SELECTED, this);
const wxString src_choices[] = { wxT("None"),
wxT("Emulated Wiimote"), wxT("Real Wiimote"), wxT("Hybrid Wiimote") };
wxChoice* const input_src_choice = new wxChoice(this, -1, wxDefaultPosition, wxDefaultSize,
sizeof(src_choices)/sizeof(*src_choices), src_choices);
input_src_choice->Select(g_wiimote_sources[m_index]);
_connect_macro_(input_src_choice, WiimoteConfigPage::SelectSource, wxEVT_COMMAND_CHOICE_SELECTED, this);
wxStaticBoxSizer* const input_src_sizer = new wxStaticBoxSizer(wxHORIZONTAL, this, wxT("Input Source"));
input_src_sizer->Add(m_input_src_choice, 1, wxEXPAND | wxALL, 5);
input_src_sizer->Add(input_src_choice, 1, wxEXPAND | wxALL, 5);
// emulated wiimote
wxButton* const configure_wiimote_emu_btn = new wxButton(this, -1, wxT("Configure"));
@ -34,18 +34,17 @@ WiimoteConfigPage::WiimoteConfigPage(wxWindow* const parent, const int index)
_connect_macro_(configure_wiimote_emu_btn, WiimoteConfigDiag::ConfigEmulatedWiimote, wxEVT_COMMAND_BUTTON_CLICKED, parent->GetParent());
// real wiimote
m_connected_wiimotes_txt = new wxStaticText(this, -1, wxEmptyString);
m_connected_wiimotes_txt->SetLabel(ConnectedWiimotesString());
connected_wiimotes_txt = new wxStaticText(this, -1, ConnectedWiimotesString());
wxButton* const refresh_btn = new wxButton(this, -1, wxT("Refresh"), wxDefaultPosition);
_connect_macro_(refresh_btn, WiimoteConfigPage::RefreshRealWiimotes, wxEVT_COMMAND_BUTTON_CLICKED, this);
_connect_macro_(refresh_btn, WiimoteConfigDiag::RefreshRealWiimotes, wxEVT_COMMAND_BUTTON_CLICKED, parent->GetParent());
wxStaticBoxSizer* const wiimote_real_sizer = new wxStaticBoxSizer(wxVERTICAL, this, wxT("Real Wiimote"));
wiimote_real_sizer->AddStretchSpacer(1);
wiimote_real_sizer->Add(m_connected_wiimotes_txt, 0, wxALIGN_CENTER | wxBOTTOM | wxLEFT | wxRIGHT, 5);
wiimote_real_sizer->Add(connected_wiimotes_txt, 0, wxALIGN_CENTER | wxBOTTOM | wxLEFT | wxRIGHT, 5);
#ifdef _WIN32
wxButton* const pairup_btn = new wxButton(this, -1, wxT("Pair Up"), wxDefaultPosition);
_connect_macro_(pairup_btn, WiimoteConfigPage::PairUpRealWiimotes, wxEVT_COMMAND_BUTTON_CLICKED, this);
_connect_macro_(pairup_btn, WiimoteConfigDiag::PairUpRealWiimotes, wxEVT_COMMAND_BUTTON_CLICKED, parent->GetParent());
wiimote_real_sizer->Add(pairup_btn, 0, wxALIGN_CENTER | wxBOTTOM, 5);
#endif
wiimote_real_sizer->Add(refresh_btn, 0, wxALIGN_CENTER, 5);
@ -95,8 +94,15 @@ void WiimoteConfigDiag::ConfigEmulatedWiimote(wxCommandEvent& event)
m_emu_config_diag->Destroy();
}
void WiimoteConfigDiag::UpdateGUI()
{
for (size_t p = 0; p < m_pad_notebook->GetPageCount(); ++p)
((WiimoteConfigPage*)m_pad_notebook->GetPage(p))->
connected_wiimotes_txt->SetLabel(ConnectedWiimotesString());
}
#ifdef _WIN32
void WiimoteConfigPage::PairUpRealWiimotes(wxCommandEvent& event)
void WiimoteConfigDiag::PairUpRealWiimotes(wxCommandEvent& event)
{
const int paired = WiimoteReal::PairUp();
@ -105,6 +111,7 @@ void WiimoteConfigPage::PairUpRealWiimotes(wxCommandEvent& event)
// Will this message be anoying?
//PanicAlert("Paired %d wiimotes.", paired);
WiimoteReal::Refresh();
UpdateGUI();
}
else if (paired < 0)
PanicAlert("A supported bluetooth device was not found!\n"
@ -112,16 +119,16 @@ void WiimoteConfigPage::PairUpRealWiimotes(wxCommandEvent& event)
}
#endif
void WiimoteConfigPage::RefreshRealWiimotes(wxCommandEvent& event)
void WiimoteConfigDiag::RefreshRealWiimotes(wxCommandEvent& event)
{
WiimoteReal::Refresh();
m_connected_wiimotes_txt->SetLabel(ConnectedWiimotesString());
UpdateGUI();
}
void WiimoteConfigPage::SelectSource(wxCommandEvent& event)
{
// should be kinda fine, maybe should just set when user clicks OK, w/e change it later
g_wiimote_sources[m_index] = m_input_src_choice->GetSelection();
g_wiimote_sources[m_index] = event.GetInt();
}
void WiimoteConfigDiag::Save(wxCommandEvent& event)

View File

@ -20,27 +20,27 @@ class WiimoteConfigPage : public wxNotebookPage
public:
WiimoteConfigPage(wxWindow* const parent, const int index);
#ifdef _WIN32
void PairUpRealWiimotes(wxCommandEvent& event);
#endif
void RefreshRealWiimotes(wxCommandEvent& event);
void SelectSource(wxCommandEvent& event);
wxStaticText* connected_wiimotes_txt;
private:
const int m_index;
wxStaticText* m_connected_wiimotes_txt;
wxChoice* m_input_src_choice;
};
class WiimoteConfigDiag : public wxDialog
{
public:
WiimoteConfigDiag(wxWindow* const parent, InputPlugin& plugin);
#ifdef _WIN32
void PairUpRealWiimotes(wxCommandEvent& event);
#endif
void RefreshRealWiimotes(wxCommandEvent& event);
void ConfigEmulatedWiimote(wxCommandEvent& event);
void Save(wxCommandEvent& event);
void UpdateGUI();
private:
InputPlugin& m_plugin;

View File

@ -93,7 +93,7 @@ void Wiimote::HidOutputReport(const wm_report* const sr, const bool send_ack)
// wiibrew:
// In every single Output Report, bit 0 (0x01) of the first byte controls the Rumble feature.
m_rumble_on = (sr->data[0] & 0x01) != 0;
m_rumble_on = sr->rumble;
switch (sr->wm)
{
@ -105,7 +105,6 @@ void Wiimote::HidOutputReport(const wm_report* const sr, const bool send_ack)
case WM_LEDS : // 0x11
//INFO_LOG(WIIMOTE, "Set LEDs: 0x%02x", sr->data[0]);
m_status.leds = sr->data[0] >> 4;
return; // no ack
break;
case WM_REPORT_MODE : // 0x12
@ -114,18 +113,16 @@ void Wiimote::HidOutputReport(const wm_report* const sr, const bool send_ack)
case WM_IR_PIXEL_CLOCK : // 0x13
//INFO_LOG(WIIMOTE, "WM IR Clock: 0x%02x", sr->data[0]);
//m_ir_clock = (sr->data[0] & 0x04) ? 1 : 0;
if (0 == (sr->data[0] & 0x02)) // only ack if 0x02 bit is set
//m_ir_clock = sr->enable;
if (false == sr->ack)
return;
break;
case WM_SPEAKER_ENABLE : // 0x14
//INFO_LOG(WIIMOTE, "WM Speaker Enable: 0x%02x", sr->data[0]);
//PanicAlert( "WM Speaker Enable: %d", sr->data[0] );
m_status.speaker = (sr->data[0] & 0x04) ? 1 : 0;
if (0 == (sr->data[0] & 0x02)) // only ack if 0x02 bit is set
m_status.speaker = sr->enable;
if (false == sr->ack)
return;
break;
@ -159,9 +156,8 @@ void Wiimote::HidOutputReport(const wm_report* const sr, const bool send_ack)
if (sr->data[0] & 0x04)
memset(&m_channel_status, 0, sizeof(m_channel_status));
#endif
m_speaker_mute = (sr->data[0] & 0x04) ? 1 : 0;
if (0 == (sr->data[0] & 0x02)) // only ack if 0x02 bit is set
m_speaker_mute = sr->enable;
if (false == sr->ack)
return;
break;
@ -170,9 +166,8 @@ void Wiimote::HidOutputReport(const wm_report* const sr, const bool send_ack)
// This enables or disables the IR lights, we update the global variable g_IR
// so that WmRequestStatus() knows about it
//INFO_LOG(WIIMOTE, "WM IR Enable: 0x%02x", sr->data[0]);
m_status.ir = (sr->data[0] & 0x04) ? 1 : 0;
if (0 == (sr->data[0] & 0x02)) // only ack if 0x02 bit is set
m_status.ir = sr->enable;
if (false == sr->ack)
return;
break;

View File

@ -136,9 +136,20 @@ struct wm_drums_extension
u16 bt; // buttons
};
struct wm_report {
struct wm_report
{
u8 wm;
u8 data[0];
union
{
u8 data[0];
struct
{
u8 rumble : 1; // enable/disable rumble
// only valid for certain reports
u8 ack : 1; // respond with an ack
u8 enable : 1; // enable/disable certain features
};
};
};
#define WM_RUMBLE 0x10

View File

@ -23,16 +23,14 @@
#define PLUGIN_VERSION 0x0100
#define PLUGIN_NAME "Dolphin Wiimote New Incomplete"
#ifdef DEBUGFAST
#define PLUGIN_NAME "Dolphin Wiimote New"
#if defined(DEBUGFAST)
#define PLUGIN_FULL_NAME PLUGIN_NAME" (DebugFast)"
#else
#ifdef _DEBUG
#elif defined(_DEBUG)
#define PLUGIN_FULL_NAME PLUGIN_NAME" (Debug)"
#else
#define PLUGIN_FULL_NAME PLUGIN_NAME
#endif
#endif
// plugin globals
InputPlugin g_plugin( "WiimoteNew", "Wiimote", "Wiimote" );
@ -49,11 +47,8 @@ class wxDLLApp : public wxApp
IMPLEMENT_APP_NO_MAIN(wxDLLApp)
WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst);
// copied from GCPad
HINSTANCE g_hInstance;
#endif
#ifdef _WIN32
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved )
{
switch (fdwReason)