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

View File

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

View File

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

View File

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

View File

@ -136,9 +136,20 @@ struct wm_drums_extension
u16 bt; // buttons u16 bt; // buttons
}; };
struct wm_report { struct wm_report
{
u8 wm; 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 #define WM_RUMBLE 0x10

View File

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