diff --git a/Source/Plugins/Plugin_Wiimote/Src/Config.cpp b/Source/Plugins/Plugin_Wiimote/Src/Config.cpp index 442a05a9e4..64ad2a08ad 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/Config.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/Config.cpp @@ -35,10 +35,10 @@ void Config::Load() // get resolution - iniFile.Get("Settings", "SidewaysDPad", &bSidewaysDPad, 0); // Hardware - iniFile.Get("Settings", "WideScreen", &bWideScreen, 0); - iniFile.Get("Settings", "ExtensionConnected", &bExtensionConnected, 0); - + iniFile.Get("Settings", "SidewaysDPad", &bSidewaysDPad, false); // Hardware + iniFile.Get("Settings", "WideScreen", &bWideScreen, false); + iniFile.Get("Settings", "NunchuckConnected", &bNunchuckConnected, false); + iniFile.Get("Settings", "ClassicControllerConnected", &bClassicControllerConnected, false); } void Config::Save() @@ -47,7 +47,8 @@ void Config::Save() iniFile.Load(FULL_CONFIG_DIR "Wiimote.ini"); iniFile.Set("Settings", "SidewaysDPad", bSidewaysDPad); iniFile.Set("Settings", "WideScreen", bWideScreen); - iniFile.Set("Settings", "ExtensionConnected", bExtensionConnected); + iniFile.Set("Settings", "NunchuckConnected", bNunchuckConnected); + iniFile.Set("Settings", "ClassicControllerConnected", bClassicControllerConnected); iniFile.Save(FULL_CONFIG_DIR "Wiimote.ini"); diff --git a/Source/Plugins/Plugin_Wiimote/Src/Config.h b/Source/Plugins/Plugin_Wiimote/Src/Config.h index 0366f896bf..ab97f95f6e 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/Config.h +++ b/Source/Plugins/Plugin_Wiimote/Src/Config.h @@ -33,7 +33,7 @@ struct Config // General bool bSidewaysDPad; bool bWideScreen; - bool bExtensionConnected; + bool bNunchuckConnected, bClassicControllerConnected; }; extern Config g_Config; diff --git a/Source/Plugins/Plugin_Wiimote/Src/ConfigDlg.cpp b/Source/Plugins/Plugin_Wiimote/Src/ConfigDlg.cpp index 237e5e291f..05e8a47038 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/ConfigDlg.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/ConfigDlg.cpp @@ -18,7 +18,7 @@ //#include "Common.h" // for u16 #include "ConfigDlg.h" #include "Config.h" -#include "EmuSubroutines.h" // for WmRequestStatus_ +#include "EmuSubroutines.h" // for WmRequestStatus BEGIN_EVENT_TABLE(ConfigDialog,wxDialog) @@ -27,7 +27,8 @@ BEGIN_EVENT_TABLE(ConfigDialog,wxDialog) EVT_BUTTON(ID_ABOUTOGL, ConfigDialog::AboutClick) EVT_CHECKBOX(ID_SIDEWAYSDPAD, ConfigDialog::GeneralSettingsChanged) EVT_CHECKBOX(ID_WIDESCREEN, ConfigDialog::GeneralSettingsChanged) - EVT_CHECKBOX(ID_EXTENSIONCONNECTED, ConfigDialog::GeneralSettingsChanged) + EVT_CHECKBOX(ID_NUNCHUCKCONNECTED, ConfigDialog::GeneralSettingsChanged) + EVT_CHECKBOX(ID_CLASSICCONTROLLERCONNECTED, ConfigDialog::GeneralSettingsChanged) END_EVENT_TABLE() ConfigDialog::ConfigDialog(wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &position, const wxSize& size, long style) @@ -73,8 +74,10 @@ void ConfigDialog::CreateGUIControls() m_SidewaysDPad->SetValue(g_Config.bSidewaysDPad); m_WideScreen = new wxCheckBox(m_PageEmu, ID_WIDESCREEN, wxT("WideScreen Mode (for correct aiming)"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); m_WideScreen->SetValue(g_Config.bWideScreen); - m_ExtensionConnected = new wxCheckBox(m_PageEmu, ID_EXTENSIONCONNECTED, wxT("Extension connected"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); - m_ExtensionConnected->SetValue(g_Config.bExtensionConnected); + m_NunchuckConnected = new wxCheckBox(m_PageEmu, ID_NUNCHUCKCONNECTED, wxT("Nunchuck connected"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + m_NunchuckConnected->SetValue(g_Config.bNunchuckConnected); + m_ClassicControllerConnected = new wxCheckBox(m_PageEmu, ID_CLASSICCONTROLLERCONNECTED, wxT("Classic Controller connected"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + m_ClassicControllerConnected->SetValue(g_Config.bClassicControllerConnected); // ---------------------------------------------------------------------- @@ -85,7 +88,8 @@ void ConfigDialog::CreateGUIControls() sBasic = new wxGridBagSizer(0, 0); sBasic->Add(m_SidewaysDPad, wxGBPosition(0, 0), wxGBSpan(1, 2), wxALL, 5); sBasic->Add(m_WideScreen, wxGBPosition(1, 0), wxGBSpan(1, 2), wxALL, 5); - sBasic->Add(m_ExtensionConnected, wxGBPosition(2, 0), wxGBSpan(1, 2), wxALL, 5); + sBasic->Add(m_NunchuckConnected, wxGBPosition(2, 0), wxGBSpan(1, 2), wxALL, 5); + sBasic->Add(m_ClassicControllerConnected, wxGBPosition(3, 0), wxGBSpan(1, 2), wxALL, 5); sbBasic->Add(sBasic); sGeneral->Add(sbBasic, 0, wxEXPAND|wxALL, 5); @@ -117,6 +121,15 @@ void ConfigDialog::AboutClick(wxCommandEvent& WXUNUSED (event)) } +void ConfigDialog::DoExtensionConnectedDisconnected() +{ + // generate connect/disconnect status event + u8 DataFrame[8]; // make a blank report for it + wm_request_status *rs = (wm_request_status*)DataFrame; + if(WiiMoteEmu::g_ReportingChannel > 0) + WiiMoteEmu::WmRequestStatus(WiiMoteEmu::g_ReportingChannel, rs); +} + void ConfigDialog::GeneralSettingsChanged(wxCommandEvent& event) { switch (event.GetId()) @@ -124,17 +137,23 @@ void ConfigDialog::GeneralSettingsChanged(wxCommandEvent& event) case ID_SIDEWAYSDPAD: g_Config.bSidewaysDPad = m_SidewaysDPad->IsChecked(); break; + case ID_WIDESCREEN: g_Config.bWideScreen = m_WideScreen->IsChecked(); break; - case ID_EXTENSIONCONNECTED: - g_Config.bExtensionConnected = m_ExtensionConnected->IsChecked(); - // generate connect/disconnect status event - u8 DataFrame[8]; // make a blank report for it - wm_request_status *rs = (wm_request_status*)DataFrame; - if(WiiMoteEmu::g_ReportingChannel > 0) - WiiMoteEmu::WmRequestStatus(WiiMoteEmu::g_ReportingChannel, rs); - break; + case ID_NUNCHUCKCONNECTED: + g_Config.bNunchuckConnected = m_NunchuckConnected->IsChecked(); + // generate connect/disconnect status event + memcpy(WiiMoteEmu::g_RegExt + 0xfa, WiiMoteEmu::nunchuck_id, sizeof(WiiMoteEmu::nunchuck_id)); + DoExtensionConnectedDisconnected(); + break; + + case ID_CLASSICCONTROLLERCONNECTED: + g_Config.bClassicControllerConnected = m_ClassicControllerConnected->IsChecked(); + // generate connect/disconnect status event + memcpy(WiiMoteEmu::g_RegExt + 0xfa, WiiMoteEmu::classic_id, sizeof(WiiMoteEmu::classic_id)); + DoExtensionConnectedDisconnected(); + break; } } \ No newline at end of file diff --git a/Source/Plugins/Plugin_Wiimote/Src/ConfigDlg.h b/Source/Plugins/Plugin_Wiimote/Src/ConfigDlg.h index 9b68936349..afd91ba404 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/ConfigDlg.h +++ b/Source/Plugins/Plugin_Wiimote/Src/ConfigDlg.h @@ -59,7 +59,7 @@ class ConfigDialog : public wxDialog wxCheckBox *m_SidewaysDPad; // general settings wxCheckBox *m_WideScreen; - wxCheckBox *m_ExtensionConnected; + wxCheckBox *m_NunchuckConnected, *m_ClassicControllerConnected; enum { @@ -72,13 +72,14 @@ class ConfigDialog : public wxDialog ID_SIDEWAYSDPAD, ID_WIDESCREEN, - ID_EXTENSIONCONNECTED + ID_NUNCHUCKCONNECTED, ID_CLASSICCONTROLLERCONNECTED }; void OnClose(wxCloseEvent& event); void CreateGUIControls(); void AboutClick(wxCommandEvent& event); + void DoExtensionConnectedDisconnected(); void GeneralSettingsChanged(wxCommandEvent& event); }; diff --git a/Source/Plugins/Plugin_Wiimote/Src/EmuMain.cpp b/Source/Plugins/Plugin_Wiimote/Src/EmuMain.cpp index ddeb7a5153..46042d8089 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/EmuMain.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/EmuMain.cpp @@ -490,7 +490,7 @@ void WmRequestStatus(u16 _channelID, wm_request_status* rs) pStatus->battery = 0x5f; // fully charged // Read config value for this one - if(g_Config.bExtensionConnected) + if(g_Config.bNunchuckConnected || g_Config.bClassicControllerConnected) pStatus->extension = 1; else pStatus->extension = 0; diff --git a/Source/Plugins/Plugin_Wiimote/Src/EmuSubroutines.cpp b/Source/Plugins/Plugin_Wiimote/Src/EmuSubroutines.cpp index 12b32c2c2c..e60780dd7f 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/EmuSubroutines.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/EmuSubroutines.cpp @@ -46,6 +46,7 @@ #include "EmuSubroutines.h" #include "EmuDefinitions.h" #include "Console.h" // for startConsoleWin, wprintf, GetConsoleHwnd +#include "Config.h" // for g_Config extern SWiimoteInitialize g_WiimoteInitialize; @@ -132,9 +133,16 @@ void Initialize() //WriteCrypted16(g_RegExt, 0xfe, 0x0000); // Fully inserted Nunchuk - // Copy nuncuck id and calibration to its register + // Copy extension id and calibration to its register memcpy(g_RegExt + 0x20, nunchuck_calibration, sizeof(nunchuck_calibration)); - memcpy(g_RegExt + 0xfa, nunchuck_id, sizeof(nunchuck_id)); + if(g_Config.bNunchuckConnected) + { + memcpy(g_RegExt + 0xfa, nunchuck_id, sizeof(nunchuck_id)); + } + else if(g_Config.bClassicControllerConnected) + { + memcpy(g_RegExt + 0xfa, classic_id, sizeof(classic_id)); + } // g_RegExt[0xfd] = 0x1e; diff --git a/Source/Plugins/Plugin_Wiimote/Src/EmuSubroutines.h b/Source/Plugins/Plugin_Wiimote/Src/EmuSubroutines.h index 65b1abd22e..dc9b6e567a 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/EmuSubroutines.h +++ b/Source/Plugins/Plugin_Wiimote/Src/EmuSubroutines.h @@ -84,13 +84,20 @@ static const u8 nunchuck_calibration[] = }; -/* The nunchuck id. It should be written to the last bytes of the +/* The Nunchuck id. It should be written to the last bytes of the extension register */ static const u8 nunchuck_id[] = { 0x00, 0x00, 0xa4, 0x20, 0x00, 0x00 }; +/* The Classic Controller id. It should be written to the last bytes of the + extension register */ +static const u8 classic_id[] = +{ + 0x00, 0x00, 0x00, 0x00, 0x01, 0x01 +}; + /* The id for nothing inserted */ static const u8 nothing_id[] = {